Reputation: 11
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?
Upvotes: 1
Views: 15369
Reputation: 43
One year after question - but maybe still someone accessing this post :)
Xiaomi Camera's connects only to the cloud. There is no opened TCP/UDP ports that can be used for streaming directly to the endpoint device, or configure device via WebUI. That is irritating but security-friendly.
Only way to bypass this - is to flash custom OS for the camera.
Upvotes: 1
Reputation: 1469
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()
Upvotes: 1