Ask Your Question
1

Prosilica camera camera with opencv 2.4.6

asked 2014-01-17 14:01:33 -0600

developper2000 gravatar image

Hello,

I am using a prosilica camera with opencv on Mac Os 10.8.5 . I tried to capture video using Qt editor. But I get this error Warning, camera failed to properly initialize! Cleaned up camera. I tried a lot of number but it did not work. any help please!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-01-23 07:54:15 -0600

I am using a code snippet that was created for the AVT guppy and manta camera, but which should also work perfectly for using it on the proscilla series. Take a look at it!

/**********************************************************************************
* Copyright (C) 2008 Metron Hong Kong Limited.  All Rights Reserved.
*
* Reproduction or disclosure of this file or its contents is granted without 
* prior written consent of Metron Hong Kong Limited.
***
* Code name: CaptureSaveMono.cpp
* Written by: Antonio Yu, Chief Consultant
* Date: 1 May, 2008
* Version: 1.0
* 
* Adapted by Stijn De Beugher on 2/04/2012
* Tested in combination with a AVT MANTA 201 MonoChrome camera
***
* Adapted by Steven Puttemans on 03/05/2013 
* Changed compatibility to windows environments
**********************************************************************************/

#include <PvApi.h>
#include <cxcore.h>
#include <cv.h>
#include <highgui.h>
#include <string.h>
#include <iostream>
#include <time.h>

// Added this library in order to be windows compatible
#include <io.h>

using namespace std;

// camera's data type definition
typedef struct 
{
    unsigned long   UID;
    tPvHandle       Handle;
    tPvFrame        Frame;

} tCamera;

#define CH_MONO 1   // Single channel for mono images

int main(int argc, char* argv[])
{
    string input = "";
    string output_folder = "";
    int maxframecounter  = 100;
    string extension = ".pgm";  
    tCamera         myCamera;
    tPvCameraInfo   cameraInfo;
    unsigned long   frameSize;
    tPvErr          Errcode;

    // Check if arguments are given correct
    // Else put in other values
    if( argc == 1 ){
        printf( "This script will capture and save images derived from a MANTA GigE camera \n"
                "This script uses some required and some adaptable parameters:  \n"
                "manta_GigE_2.exe\n"
                "  <output folder>  \n"
                "  <nr of frames = 100>  \n"
                "  <output format = '.pgm'>  \n");
        return 0;
    }

    // Check if the output path and other parameters are given, initialize them with correct value
    if (argc >= 2){
        output_folder = argv[1];
        // Check if seperate nr of frames and output format are given
        if (argv[2]){
            maxframecounter = atoi(argv[2]);
        }
        if (argv[3]){
            extension = argv[3];
        }
    }

    cout << "Frame capturing configured, starting the actual capture." << endl;

    // Initialize the API
    if(!PvInitialize())
    { 
        // Wait for the response from a camera after the initialization of the driver
        ////////////////////////////////////////////////////////////        
        clock_t startT, endT;
        startT = clock();
        float start = float(startT/CLOCKS_PER_SEC); 
        while(PvCameraCount() == 0)
        {           
            endT = clock();
            float end = float(endT/CLOCKS_PER_SEC); 
            if(end>(start+5))
            {               
                break;
            }
        }

        /////////////////////////////////////////////////////////////
        unsigned long numCams = PvCameraList(&cameraInfo, 1, NULL);
        cout << "numcams = \t" << numCams << endl;      
        if (numCams == 1)
        {
            // Get the camera ID
            myCamera.UID = cameraInfo.UniqueId;
            cout << "Camera ID =  \t " << myCamera.UID << endl;     

            // Open the camera
            if(!PvCameraOpen(myCamera.UID, ePvAccessMaster, &(myCamera.Handle)))
            {
                // Get the image size of every capture
                Errcode = PvAttrUint32Get(myCamera.Handle, "TotalBytesPerFrame", &frameSize);
                if (Errcode != ePvErrSuccess)
                    throw Errcode;

                cout << "Frame size = \t" << frameSize << endl;

                // Allocate a buffer to store the image
                memset(&myCamera.Frame, 0, sizeof(tPvFrame));
                myCamera.Frame.ImageBufferSize = frameSize;
                myCamera.Frame.ImageBuffer = new char[frameSize];

                // Get the width & height of the image
                tPvUint32 width, height;
                PvAttrUint32Get(myCamera.Handle, "Width", &width);
                PvAttrUint32Get(myCamera.Handle, "Height", &height);

                cout << "Frame width = \t" << width << endl;
                cout << "Frame height = \t" << height << endl;

                // Start the camera
                PvCaptureStart(myCamera.Handle);

                // Set the camera to capture continuously
                Errcode = PvAttrEnumSet(myCamera.Handle, "AcquisitionMode", "Continuous");
                if (Errcode != ePvErrSuccess)
                    throw Errcode;

                cout <<"start the acquisition" << endl;
                Errcode = PvCommandRun(myCamera.Handle ...
(more)
edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-17 14:01:33 -0600

Seen: 918 times

Last updated: Jan 23 '14