4
votes

I want to ask if someone have idea if it's possible to implement a VideoCapture using OpenCV+Python and a GigE Vision Camera, I tried with cv2.VideoCapture(0) but I am always obtaining the video of the integrated webcam. I was trying new beta of OpenCV and using 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()

Thanks in advance.

3
try: print cv2.getBuildInformation() i'm pretty sure, that the prebuild binaries do not come with support for pvapi or such. you will need the resp. SDK, and rebuild from srcberak
Ok I obtained that info, as you said PvAPI:NO and GigEVisionSDK:NO, so can you explain me a little bit in detail how I can rebuild from src???? I mean, I have installed the SDK of the camera but I do not know how to do the rebuild. ThanksproveYourself
you will need cmake(-gui), the opencv src (and some dependancies, like numpy) and rebuild the whole thing from scratch.berak
you mean creating my own libs???proveYourself
yes. build your own opencv libs locally.berak

3 Answers

3
votes

It could be easier to use harvesters for this task. It would give you all the needed flexibility, and it is optimized for GIGE cameras. https://github.com/genicam/harvesters

I have been using it for a while, and it looks simple enough and fast enough.

0
votes

There probably is a way to do so, a german company called Stemmer Imaging developped a Python library for the GenICam standard. That should do the trick. At the moment I am researching for myself to accomplish the same task, and this is what I found:

Link 1 as well as this Link 2.

Personally I was not able to get it working so far, but that should only be a matter of time.

-3
votes

Passing another integer value in function cv2.VideoCapture(int) instead of 0 selects another camera that is connected. example 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()