OpenCV + Python + GigE 视觉相机

pro*_*elf 5 python opencv

我想问是否有人知道是否可以使用 OpenCV+Python 和 GigE Vision 相机实现 VideoCapture,我尝试使用 cv2.VideoCapture(0) 但我总是获取集成网络摄像头的视频。我正在尝试 OpenCV 的新测试版并使用 Windows

import numpy as np
import cv2

capture = cv2.VideoCapture(0)

while (True):
 frame = capture.read()
 cv2.imshow('camera',frame)
 if cv2.waitKey(1) & 0xFF == odd('q'):
  break

capture.release()
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)

提前致谢。

Mot*_*uda 5

使用收割机来完成这项任务可能会更容易。它将为您提供所需的所有灵活性,并且针对 GIGE 相机进行了优化。 https://github.com/genicam/harvesters

我已经使用了一段时间了,它看起来足够简单,也足够快。


Adi*_*ala -5

在函数 cv2.VideoCapture(int) 中传递另一个整数值而不是 0 来选择连接的另一个摄像机。示例 cv2.VideoCapture(1)

import numpy as np
import cv2

capture = cv2.VideoCapture(1)

while (True):
 frame = capture.read()
 cv2.imshow('camera',frame)
 if cv2.waitKey(1) & 0xFF == odd('q'):
  break

capture.release()
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)