2

I have laptop with Windows 10 and Marvell Yukon 88E8072 PCI-E Gigabit Ethernet Controller. I have Allied Vision Manta camera connected to my laptop. I installed Visual Studio 2015 and also I installed Allied Vision SDK - Vimba Viewer. I am able to capture images with Vimba Viewer interface soo I know that camera is working ok.

The problem is when I try to capture images in Visual Studio. I downloaded sample source code and with this code I am able to capture image from my webcam.This is code:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <opencv2\video\video.hpp>
#include "opencv2/highgui/highgui.hpp"



using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
//cerr << getBuildInformation() << endl;

VideoCapture cap(0); // open the video camera no. 0 - we camera, 1- should     be GigE camera?

if (!cap.isOpened())  // if not success, exit program
{
    cout << "Cannot open the video cam" << endl;
    return -1;
}

double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

cout << "Frame size : " << dWidth << " x " << dHeight << endl;

namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

while (1)
{
    Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
    {
        cout << "Cannot read a frame from video stream" << endl;
        break;
    }

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }
}
return 0;
}

If I change VideoCapture cap(0) to VideoCapture cap(1), so that I should get video from GigE camera, I get a message ''Canot open the video cam'', so cap.isOpen() is false (see code above).

I am assuming that this has to do something with PvAPI driver not installed/included correctly. When I run:

cerr << getBuildInformation() << endl;

in cmd I see under Video I/O there is a line that says: PvAPI NO!

My question is, how can I configure my sistem to be able to capture images from Allied Vision Camera, model Manta in Visual Studio?

jok23
  • 286
  • 1
  • 5
  • 19
  • 1
    If you can already capture with Vimba, than use that (and use OpenCV for processing). The VideoCapture just contains a relatively simplistic wrapper around PvAPI (using polled mode IIRC) -- I consider it useful only for some simple prototyping at best. It would be a massive step back. Personally I just use PvAPI directly, but Vimba should work just as well. Also, to use the PvAPI support, you need to build your own copy of OpenCV. | BTW, why do you include the same header twice, and why are your includes so inconsistent (both types of slashes, "" and <> for same library,...)? – Dan Mašek Feb 06 '17 at 14:16
  • Tnx for response! Sory for bad include stuff (my mistake). So...I did some researching about using Vimba as you said and I found out that Vimba already has some APIs for C++ and C#. There is also Vimba Viewer Class Generator that is probably tool to create classes that can help you with connecting camera to OpenCV... I don't know if this is what I am looking for. Is it possible that I create class with this tool, import this class in Visual Studio and then just use some functions from this class to get images from camera? – jok23 Feb 06 '17 at 17:55
  • 1
    Yeah, use the C++ API. There seems to be a decent manual included as well as many examples. The "AsynchronousGrab" (the console version) is probably what you want to investigate, and there are couple that show integration with OpenCV to do the processing. – Dan Mašek Feb 06 '17 at 18:18
  • Thank you for advice! Ok, currently I am trying to use ''ListCamera'' examples, that probably print all infomation about connected cameras to computer. I import solution ''ListCameras'' in Visual Studio 2015. Then I succesfully build solution and then I run Local Windows Debugger button. Program doesn't find any camera. In the console I get message : ''Cameras found: 0''. And output console says: [link]https://www.dropbox.com/s/5w4axivpl1cy10g/outputConsoleStuff.txt?dl=0 What can be the reason? Maybe antivirus f-secure?? But there is and exeption for vimba added in f-sefuce exception tab... – jok23 Feb 07 '17 at 07:23

2 Answers2

3

SO FOR ALL ENGINEERS WHO ARE TRYING (AND ARE NEW LIKE ME IN MACHINE VISION) TO USE VIMBA VIEWER APIs (C++, C#) TO CONNECT WITH MANTA CAMERAS, THIS IS HOW IT IS DONE:

  1. Install Visual Studio 2015 from here
  2. Install the latest version of OpenCV from here and use this tutorial to install and configure OpenCV in the correct way.
  3. Connect Allied Vision camera (Manta) to your computer (you must have GigE controller in your computer)
  4. Install Vimba Viewer SDK from here and install drivers using Vimba Viewer Driver software. Rebbot computer.
  5. Run Vimba Viewer and see if your camera is detected and capture some images with camera.
  6. Close Vimba Viewer and then run Visual Studio. Open some of the APIs C++ examples from folder: ...\Allied Vision\Vimba_2.0\VimbaCPP_Examples . I suggest using ListCameras for the first time. You will be able to check if your camera is recognized by VS2015. If everything is ok, you should see camera parameters in VS console.

POSIBLE PROBLEMS THAT I HAD AND FIXES:

  • Visual Studio is crashing when you run APIs examples. FIX: Close Vimba Viewer
  • APIs C++ ListCameras doesn't find your camera: FIX: dissable firewal, all antiviruses or add exceptions in your antivirus programs to ListCameras.exe, Visual Studio 2015 and Vimba Viewer.
jok23
  • 286
  • 1
  • 5
  • 19
  • 4
    you are just describing the obvious. It's like telling someone who asks how to cook a certain meal: buy food, put it into a pot, cook it. eat. – Piglet Jun 09 '17 at 20:21
0

The C++ examples are a little hard to track down, so I'm pasting here the code snippet from there:

std::string name;
CameraPtrVector cameras;
VmbSystem &system = VmbSystem::GetInstance();
if( VmbErrorSuccess == system.Startup() )
{
    if( VmbErrorSuccess == system.GetCameras( cameras ) )
    {
        for( CameraPtrVector::iterator iter = cameras.begin();
              cameras.end() != iter;
              ++iter )
        {
             if( VmbErrorSuccess == (*iter)->GetName( name ) )
             {
              std::cout << name << std::endl;
             }
        }
    }
}

This would be found in C:\Program Files\Allied Vision\VimbaX\doc (it's an HTML compiled "readthedocs") when you install the VimbaX SDK from https://www.alliedvision.com/en/products/software/vimba-x-sdk/

The rest of the documentation there will help you grab frames and more.

Roy Shilkrot
  • 3,079
  • 29
  • 25
  • Vimba and VimbaX have some differences, so not all VimbaX examples can be used one to one (but a lot is the same, so you can copy most of the code). The Vimba examples are under User/Public/Public Documents/Allied Vision/Vimba_6.0 . With most installations, the examples folder should be linked under the "Allied Vision Vimba" Tab in the Windows Start menu. – T F Mar 14 '23 at 10:53