我试着用Python访问我的IP摄像头流。
相机:小米米家居安全相机360°1080 p
我从Mi Home应用程序获得了摄像头的IP地址: 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)
我得到了以下错误:
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'
你能帮忙吗?
发布于 2022-03-18 14:09:10
import cv2
# rtsp://username:password@192.168.2.94/port
cap = cv2.VideoCapture('rtsp://username:password@192.168.2.94/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()
https://stackoverflow.com/questions/71526561
复制相似问题