'Access Xiaomi IP Camera in Python with OpenCV
I'm trying to access my IP camera stream in Python.
Camera: Xiaomi Mi Home Security Camera 360° 1080p
I got the IP address of the camera from the Mi Home app: 192.168.2.94
import cv2
cap = cv2.VideoCapture('http://192.168.2.94')
while True:
r, f = cap.read()
cv2.imshow('IP Camera stream',f)
I'm getting the following error:
Traceback (most recent call last):
File "<pyshell#60>", line 4, in <module>
cv2.imshow('IP Camera stream',f)
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
Can you please help?
Solution 1:[1]
import cv2
# rtsp://username:[email protected]/port
cap = cv2.VideoCapture('rtsp://username:[email protected]/554')
while True:
ret, img = cap.read()
if ret == True:
cv2.imshow('video output', img)
k = cv2.waitKey(10)& 0xff
if k == 27:
break
cap.release()
cv2.destroyAllWindows()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
