Ip Camera Qr | Telegram Free
This project demonstrates how to set up an IP camera that streams video accessible via a QR code and sends alerts or snapshots to a Telegram chat — using free or open-source tools where possible. It covers hardware/software choices, network setup, QR-code generation for easy access, Telegram integration, privacy considerations, and an example implementation.
Pros:
Cons:
RTSP_URL = "rtsp://admin:password@192.168.1.100:554/stream1" TELEGRAM_BOT_TOKEN = "YOUR_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID"
bot = Bot(token=TELEGRAM_BOT_TOKEN)
def detect_motion(frame1, frame2): # Simple frame differencing for motion detection diff = cv2.absdiff(frame1, frame2) gray = cv2.cvtColor(diff, cv2.COLOR_BGR2GRAY) blur = cv2.GaussianBlur(gray, (5, 5), 0) _, thresh = cv2.threshold(blur, 20, 255, cv2.THRESH_BINARY) return cv2.countNonZero(thresh) > 500 # Sensitivity threshold
async def main(): cap = cv2.VideoCapture(RTSP_URL) ret, frame1 = cap.read() ret, frame2 = cap.read() ip camera qr telegram free
while True:
ret, frame3 = cap.read()
if not ret:
break
if detect_motion(frame1, frame3):
# Save snapshot
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
img_path = f"alert_timestamp.jpg"
cv2.imwrite(img_path, frame3)
# Send to Telegram
with open(img_path, 'rb') as photo:
await bot.send_photo(chat_id=CH_ID, photo=photo,
caption=f"🚨 Motion Detected at timestamp")
print("Alert sent to Telegram!")
await asyncio.sleep(10) # Cooldown to prevent spam
frame1, frame2 = frame2, frame3
await asyncio.sleep(0.1)
asyncio.run(main())
Before we start, make sure you have the following: This project demonstrates how to set up an