我如何通过 python 连接以太网连接的相机(Flir AX8 相机)

How can i connect ethernet connected camera through python (Flir AX8 camera)

我正在尝试通过 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'

导入cv2 将 numpy 导入为 np

虽然正确: cap=cv2.VideoCapture('http://admin:admin@169.254.253.219/snapshot.jpg?user=admin&pwd=admin&strm=0') ret,img=cap.read() cv2.imshow('videos output',img) k=cv2.waitKey(1) 如果 k==ord('q'): 休息

cap.release() cv2.destroyAllWindows