我正在尝试通过python连接Flir AX8摄像头。此摄像头连接到笔记本电脑的以太网端口。因此,VideoCapture()无法识别端口,我尝试了它的所有索引(0,1,2),但它没有连接。有谁能帮我把相机和python连接起来吗?
我尝试过通过VideoCapture(1)和VideoCapture('IP address')进行连接
使用IP地址:
import cv2, time
video=cv2.VideoCapture('http://admin:admin@IP address/')
a=0
while True:
a=a+1
check, frame = video.read()
print(check)
print(frame)
#gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow("Capturing",frame)
key=cv2.waitKey(1)
if key== ord('q'):
break
print(a)
video.release()
cv2.destroyAllWindows使用索引0,1,2:
import cv2, time
video=cv2.VideoCapture(1)
a=0
while True:
a=a+1
check, frame = video.read()
print(check)
print(frame)
#gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow("Capturing",frame)
key=cv2.waitKey(1)
if key== ord('q'):
break
print(a)
video.release()
cv2.destroyAllWindows在这两种情况下,我都得到了以下错误:
False
None
Traceback (most recent call last):
File "C:\Users\yashw\Desktop\ex.py", line 15, in <module>
cv2.imshow("Capturing",frame)
cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'发布于 2019-07-15 13:45:24
将cv2导入numpy作为np导入
如果为True: cap=cv2.VideoCapture('http://admin:admin@169.254.253.219/snapshot.jpg?user=admin&pwd=admin&strm=0') ret,img=cap.read() cv2.imshow(‘视频输出’,img) k=cv2.waitKey(1) if k==ord('q'):break
cap.release() cv2.destroyAllWindows
https://stackoverflow.com/questions/56802499
复制相似问题