OpenCV + GigE Vision Cameras +c++

6.7k Views Asked by At

since a few days, I work on a camera Mako (use ethernet (GigE)). I need to get back the video flow to integrate it on a software house. I try to use the library of OpenCV on the code::blocks but I always have an error saying that it does not manage to see the Video flow. Could anybody help me? Thank you so much for your help :)

#include <opencv2/imgproc/imgproc_c.h>
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>

int main(int argc, char** argv)
{
      printf("Press ESC to exit\n");
      cvNamedWindow( "First Example of PVAPI Integrated", CV_WINDOW_AUTOSIZE );
      CvCapture* capture = cvCreateCameraCapture( CV_CAP_PVAPI );
      assert( capture != NULL );

      IplImage* frame;

      while(1)
      {
            frame = cvQueryFrame(capture);

            if(!frame) break;
            cvShowImage( "First Example of PVAPI Integrated", frame);
            char c = cvWaitKey(2500);
            if( c == 27) break;
      }
      cvReleaseCapture( &capture );
      cvDestroyWindow( "First Example of PVAPI Integrated" );
}

Img_error

1

There are 1 best solutions below

0
On

I have done this using an HX series GigE camera from Baumer and Baumer's GAPI SDK. GAPI is based on genIcam and should work for any genIcam compliant camera (Mako from Allied Vision is genIcam compliant).

I provided a comprehensive explanation of how I did this using openCV, Visual Studios C++, and Baumer's GAPI SDK HERE.

In summary you need to

  1. Install openCV for C++
  2. Install GAPI SDK
  3. Configure your C++ project as specified in Baumer's programmer's guide
  4. Use the 005_PixelTransformation example code from Baumer and add the openCV window to view the captured frames

You can refer to the programmer's guide and other example codes for steps like changing camera parameters (ROI, exposure time, gain, etc.).

NOTE: This is how I did it. It's not the only way to do it. Basler makes a similar API and they provide documentation and examples too, so you could try that. Allied Vision's PV_API is now legacy software. Their new SDK is Vimba 2.0.