Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing cap_pvpapi interface #3322

Merged
merged 1 commit into from
Nov 10, 2014
Merged

fixing cap_pvpapi interface #3322

merged 1 commit into from
Nov 10, 2014

Conversation

StevenPuttemans
Copy link

This PR tries to fix the following 3 reported issues

A complete remake of the PvAPI API interface solving bugs but also

  • allowing the use of MANTA type cameras
  • allowing multiple AVT cameras at the same time

@StevenPuttemans
Copy link
Author

Okay for the person that will look into/review this, please take a look here: https://github.com/StevenPuttemans/opencv_tryout_code/blob/master/camera_interfacing/AVT_manta_camera.cpp

This is a working interface with an AVT Manta Camera. However, if I look at the OpenCV implementation I find many weird constructions that assure the building will never work. Check my remark at http://code.opencv.org/issues/3947

I think we should use this PR to fix as much as possible

@StevenPuttemans
Copy link
Author

@asmorkalov I took some time to debug some stuff, basically this capture implementation is completely wrong. It has hardcoded maximum resolution sizes which is just completely wrong and gives very bad results on all camera's that were not used by the original programmer.

I will see if I can make it way more universal and update this PR to include all neccesary fixes.

@@ -146,14 +146,13 @@ bool CvCaptureCAM_PvAPI::open( int index )
tPvCameraInfo camInfo;
tPvIpSettings ipSettings;


if (PvInitialize()) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is error 2, this should be !PvInitialize(). The function returns 0 when initialization is busy and thus waiting untill a camera is up should depend on it being 0. Will update this already and some other snippets.

@vpisarev
Copy link
Contributor

vpisarev commented Oct 9, 2014

👍

@StevenPuttemans
Copy link
Author

New discussion, the suggested approach of mono8 being monochrome false and mono16 being monochrome true is incorrect. I have a monochromo manta camera, which returns mono8 as type. I know the data is stored as a bayer pattern for the proscilla series, so afaik the true and false should be switched right?

@StevenPuttemans
Copy link
Author

Second discussion: I managed to completely reconfigure the initialization of the camera interface to also support the Manta series of AVT through this API. However, we should have an option to indicate in a VideoCapture if it is a manta or a proscilla series. This is important when configuring the camera settings, Proscilla has more settings then manta.

Suggestion, doing something like

VideoCapture(0 | PVAPI_PROSCILLA)
VideoCapture(0 | PVAPI_MANTA)

Could be enough, but I don't really have an idea on how to approach this.
@vpisarev @asmorkalov could you guys share some ideas on this?

//PvAttrUint32Get(Camera.Handle,"PacketSize",&maxSize);
if (PvCaptureAdjustPacketSize(Camera.Handle,maxSize)!=ePvErrSuccess)
return false;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusting the package size with a static value is dangerous, not all systems and ethernet cards support this. This is mainly done to avoid overhead, probably by the original author. It will work on some systems but fail miserably on others. Just let the standard package sizes be used and ignore the overhead it creates.

@StevenPuttemans
Copy link
Author

@ all readers, do check the remarks I left.
I keep updating the code so they show as outdated diffs but the remarks still stand

@StevenPuttemans
Copy link
Author

First big update

  • The initialization of a VideoCapture object is now working properly and now errors are generated anymore.
  • After that I get a segmentation error when I try to apply camera >> frame; for grabbing a new frame. However the >> operator doesnt allow to jump into code, so I will see if I can debug it with the seperate questions.

I hope someone with a Proscilla camera can find the time to see if it still works for them.

@ShaiV
Copy link

ShaiV commented Oct 10, 2014

Unlike Manta, Prosilica does not generate a device name that includes the string "Prosilica".
Therefore, the code starting at line 209 with the definition of Boolean variable PVAPI_PROSCILLA should be changed. My suggestion is to have the default at Prosilica and in case the name contains Manta, change the interface to Manta. This is the suggested code change:

        // Define if we have a PROSCILLA or MANTA GigE camera series
        bool PVAPI_MANTA = false;
        strtok(camInfo.DisplayName, "_");
        if (strcmp(camInfo.DisplayName, "Manta") == 0){
            PVAPI_MANTA = true;
        }

Now whenever you see PVAPI_PROSILCA, change it to !PVAPI_MANTA.

Here's the complete listing that deals with this:

        // Define if we have a PROSCILLA or MANTA GigE camera series
        bool PVAPI_MANTA = false;
        strtok(camInfo.DisplayName, "_");
        if (strcmp(camInfo.DisplayName, "Manta") == 0){
            PVAPI_MANTA = true;
        }
        tPvUint32 frameWidth, frameHeight, frameSize;
        char pixelFormat[256];
        PvAttrUint32Get(Camera.Handle, "TotalBytesPerFrame", &frameSize);
        PvAttrUint32Get(Camera.Handle, "Width", &frameWidth);
        PvAttrUint32Get(Camera.Handle, "Height", &frameHeight);
        PvAttrEnumGet(Camera.Handle, "PixelFormat", pixelFormat,256,NULL);
        if(!PVAPI_MANTA){
            // Retrieve the maximum possible packet size from the camera
            // Then adjust the packet size to that value
            unsigned long maxSize;
            PvAttrUint32Get(Camera.Handle,"PacketSize",&maxSize);
            if(PvCaptureAdjustPacketSize(Camera.Handle,maxSize)!=ePvErrSuccess){
                return false;
            }
        }
        if(PVAPI_MANTA){
            // Explicitly set the width and height correctly since camera can remember configurations
            PvAttrUint32Set(Camera.Handle, "RegionX", 0 );
            PvAttrUint32Set(Camera.Handle, "RegionY", 0 );
            PvAttrUint32Set(Camera.Handle, "Width", frameWidth);
            PvAttrUint32Set(Camera.Handle, "Height", frameHeight);
        }
        // Start the camera
        PvCaptureStart(Camera.Handle);
        if(!PVAPI_MANTA){
            // Set the camera explicitly to capture data frames continuously
            if(PvAttrEnumSet(Camera.Handle, "AcquisitionMode", "Continuous")!= ePvErrSuccess)
            {
                fprintf(stderr,"Could not set Prosilica/Manta Acquisition Mode\n");
                return false;
            }
        }
        if(PvCommandRun(Camera.Handle, "AcquisitionStart")!= ePvErrSuccess)
        {
            fprintf(stderr,"Could not start Prosilica/Manta acquisition\n");
            return false;
        }
        if(PvAttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun")!= ePvErrSuccess)
        {
            fprintf(stderr,"Error setting Prosilica/Manta trigger to \"Freerun\"");
            return false;
        }
        if (!PVAPI_MANTA){
            // Settings depending on the pixelformat
            if (strcmp(pixelFormat, "Mono8")==0) {
                monocrome = true;
                grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
                grayframe->widthStep = (int)frameWidth;
                frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
                frame->widthStep = (int)frameWidth*3;
                Camera.Frame.ImageBufferSize = frameSize;
                Camera.Frame.ImageBuffer = grayframe->imageData;
            }
            else if (strcmp(pixelFormat, "Mono16")==0) {
                monocrome = true;
                grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
                grayframe->widthStep = (int)frameWidth;
                frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 3);
                frame->widthStep = (int)frameWidth*3;
                Camera.Frame.ImageBufferSize = frameSize;
                Camera.Frame.ImageBuffer = grayframe->imageData;
            }
            else if (strcmp(pixelFormat, "Bgr24")==0) {
                monocrome = false;
                frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
                frame->widthStep = (int)frameWidth*3;
                Camera.Frame.ImageBufferSize = frameSize;
                Camera.Frame.ImageBuffer = frame->imageData;
            }
            else
                return false;
        }
        if (PVAPI_MANTA){
            monocrome = true;
            grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
            grayframe->widthStep = (int)frameWidth;
            Camera.Frame.ImageBufferSize = frameSize;
            Camera.Frame.ImageBuffer = grayframe->imageData;
        }
        return true;
  • Shai

@ShaiV
Copy link

ShaiV commented Oct 10, 2014

The change that polls the number of cameras is not working for me. This is due to the wait implementation inside the while loop (this might be different on Linux and Windows).
The suggested code change for Windows is this (notice the addition of Sleep(10)):

    if (!PvInitialize()) {
        // Wait until the initialisation actually succeeded in opening up a camera
        // Ensure multiple cameras can be opened if preferred by grabbing the current amount before the initialisation
        while((PvCameraCount() != (numCameras+1)) && (initializeTimeOut--))
        {
            cvWaitKey(10);
            Sleep(10);
        }
        if (initializeTimeOut == 0){
            fprintf(stderr,"ERROR: camera intialisation timeout [5000ms].\n");
        }
        numCameras=PvCameraList(cameraList, MAX_CAMERAS, NULL);
    }

I'm not sure why you switch between PvCamerList() function and PvCameraCount(). Wouldn't it be best to use just one? They seem to be interchangeble.
I haven't tried this on Linux yet.

  • Shai

@ShaiV
Copy link

ShaiV commented Oct 10, 2014

There is also an issue when you have two cameras with two different interfaces installed. For example, I have a webcam which is a USB device and a Prosilica. The prosilica is device 1; the USB is device 0.

This causes issues with indexing since the code assumes that the camera with index 1 is the second PVAPI camera (counting starts at zero). Which is wrong-- it is actually the first camera. There are several places we have to touch to fix this.

  1. The sanity check in line 166:
    if (numCameras <= 0 || index >= (int)numCameras){
    Here the check for index>=(int) numCameras should be removed. Since again, counting does not start at zero. And camera with index 2 might be the first camera.
  2. The same problem also appears in 171. The index value may be 1 as requested by the user whereas the camera list might only have one element.

The fix is not so simple. It should also involve changing how the index variable is treated.

  • Shai

@ShaiV
Copy link

ShaiV commented Oct 10, 2014

In line 265 under "mono8", monocrome flag is set to false which is wrong. It should be set to true.
Also, all "mono16" should be set to monocrome, not color.
Only Bgr24 should be set to color.

  • Shai

@StevenPuttemans
Copy link
Author

Thanks for all your remarks! Will adapt where possible :)

Some remarks / discussion

  1. Adapted to the !PVAPI_MANTA approach.
  2. After reading again both manta and proscilla can use the same loop for type definition, so combined again. It can be that my further problems are due to the fact that the color image isn't created in the manta only loop --> this i need to check at work on monday.
  3. I need to use PvCameraList once to initialize camera information for further grabbing the UID of the cam. The others are all replaced by PvCameraCount to be uniform coding.
  4. Discovered that Manta only needs the Freerun option, the acquisition mode and acquisition start are parameters that don't influence the camera working process so put them to prossilla only.
  5. adapted the monocrome true and false statements

@StevenPuttemans
Copy link
Author

As to the index, I suggest we get the code running for 1 proscilla or 1 manta first; simply disconnect the others for a moment. Lets then make a new PR and bug for the multiple camera handling and indexing :)

@StevenPuttemans
Copy link
Author

There was a trailing whitespace error whch I resolved.
As to Shai, can you explain what errors are generated by cvWaitKey(0)?
Because this works perfectly on my system.

@StevenPuttemans
Copy link
Author

O forget my last remark; found the reason why this fails. I just recalled that cvWaitKey ONLY works if there is an active window available. Since this is not the case at initialization, the wait never happens.

I will change it into a sleep command!

@ShaiV
Copy link

ShaiV commented Oct 10, 2014

Steven, cvWaitKey() does not generate any errors. However, on my system it does not actually wait. Hence, the code that supposedly waits for 5 seconds exits very fast without any timeout and the result is that the camera is not identified properly (the code does not wait enough time for it to initalize). If you add Sleep(10) after cvWaitKey(10) then an actual wait is performed and things work OK.

  • Shai

@StevenPuttemans
Copy link
Author

Yeah just discovered the same thing, since I was debugging and I moved instruction by instruction it worked. I am guessing that this would solve my problem at work also, but thats for monday.

BTW you know the reason of creating a 3 channel frame image in the monochrome cases? Seems overkill...

@ShaiV
Copy link

ShaiV commented Oct 10, 2014

I would also suggest changing the strcmp() function calls to stricmp() function calls when checking for pixelformat; it is a little more robust. This is for "mono8", "mono16" and "Bgr24" strings.

Here's something that's been bothering me. In case of "mono8" and "mono16", there is no need to generate a color frame. I've checked this and it seems to work OK with "mono8":

        if (!PVAPI_MANTA){
            // Settings depending on the pixelformat
            if (stricmp(pixelFormat, "Mono8")==0) {
                monocrome = true;
                grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
                grayframe->widthStep = (int)frameWidth;
                /*
                frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 3);
                frame->widthStep = (int)frameWidth*3;
                */
                Camera.Frame.ImageBufferSize = frameSize;
                Camera.Frame.ImageBuffer = grayframe->imageData;
            }
            else if (stricmp(pixelFormat, "Mono16")==0) {
                monocrome = true;
                grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
                grayframe->widthStep = (int)frameWidth;
                /*
                frame = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 3);
                frame->widthStep = (int)frameWidth*3;
                */
                Camera.Frame.ImageBufferSize = frameSize;
                Camera.Frame.ImageBuffer = grayframe->imageData;
            }

Notice the commenting of the lines associated with the frame variable (only grayframe variable is used).
This will be a little more memory efficient and slightly faster.
But requires some more testing (it works well on my system).

  • Shai

@ShaiV
Copy link

ShaiV commented Oct 10, 2014

That's exactly what I wrote-- no need for a 3 color frame.

  • Shai

@StevenPuttemans
Copy link
Author

Will change! And again, Linux Manta test on monday :)

@ShaiV
Copy link

ShaiV commented Oct 11, 2014

This is something I wanted to discuss. First of all, I don't like the use of the PVAPI_MANTA variable. I read through the code and came to a conclusion that the reason for this lies in the topic explained below: initilization of camera parameters.

In my view, changing camera's parameters upon initialization, unless absolutely necessary, should not be done. The necessary parameters are: Setting the AcquisitionStart, setting the AcquisitionMode and setting the FrameStartTriggerMode. All other parameters should not be set on PvCameraOpen().

The reason is that users set the values with the GigEViewer application which comes with the camera's SDK. For example, say I want a slower bit-rate so as not to clog my bandwidth, then adjusting the maximum packet size automatically in PvCameraOpen() will not allow me to do that. The same goes for ROI.
For example, the lines of code:

        if(!PVAPI_MANTA)
        {
            // Retrieve the maximum possible packet size from the camera
            // Then adjust the packet size to that value
            unsigned long maxSize;
            PvAttrUint32Get(Camera.Handle,"PacketSize",&maxSize);
            if(PvCaptureAdjustPacketSize(Camera.Handle,maxSize)!=ePvErrSuccess){
                return false;
            }
        }

Should be removed. It's up to the user that configured the camera to set this value.
The code in PvCameraOpen() should only open the camera and set it to read frames.
If the user wishes to change camera parameters he should do so explicitly after the camera is opened. This can be done by adding an overloaded function setPropery() to the camera that accepts two flavors: setProperty(string, string) and setProperty(string, int). This will allow the user to change all sorts of camera parameters.

More notes:
The code

        if(!PVAPI_MANTA)
        {
            // Set the camera explicitly to capture data frames continuously
            if(PvAttrEnumSet(Camera.Handle, "AcquisitionMode", "Continuous")!= ePvErrSuccess)
            {
                fprintf(stderr,"Could not set Prosilica/Manta Acquisition Mode\n");
                return false;
            }
        }

Why is there an if(!PVAPI_MANTA) here? Shouldn't this be for all cameras?

Once you remove all these initializations, there should be no reason to have the PVAPI_MANTA flag. You could merge everything to one mainline. The default acquisition mode should be set to mono8 so as to support MANTA.

Thanks,

  • Shai

@ShaiV
Copy link

ShaiV commented Oct 11, 2014

Two issue: a bug with the initialization process and the index issue in case several cameras of different protocols are installed on the system with PVAPI cameras as well.

The problem with the initialization code is that first we issue a call to:

unsigned int numCameras = PvCameraList(cameraList, MAX_CAMERAS, NULL);

and only then we call PvInitialize(). The problem is that PvCameraList() populates the array variable cameraList with all the visible cameras. However, since PvInitialize() is not called before PvCameraList(), the list is just random values without any cameras because there was no camera initialization. Therefore, after a call to PvInitialize(), one must also call the PvCameraList() to properly populate the cameraList array (see below for a fix).

The second issue is with the index variable that is passed as a parameter to the function. The problem is that this index is just a random number that has no meaning, since the cameras are identified with the Unique ID variable. To be able to open the camera, all that is needed is to set the Unique ID to the last value in the camerList array.

This approach will ensure that even if you have a different protocol camera (for example, USB and PvAPI), the index will be properly set. The problem is if you have two PVAPI cameras. I'm not sure how this will work-- it needs to be tested.

Here's the suggested code change that deals with both the index issue and the initialization process.

    int initializeTimeOut = 500;
    unsigned int numCameras = PvCameraCount();
    if(PvInitialize()==ePvErrSuccess)
    {
        // Wait until the initialisation actually succeeded in opening up a camera
        // Ensure multiple cameras can be opened if preferred by grabbing the current amount before the initialisation
        while((PvCameraCount()!=(numCameras+1)) && (initializeTimeOut--))
            Sleep(10);
        if(!initializeTimeOut)
        {
            fprintf(stderr,"ERROR: camera initialization timeout [5000ms].\n");
            return false;
        }
        numCameras = PvCameraList(cameraList, MAX_CAMERAS, NULL);
    }
    else
    {
        fprintf(stderr, "ERROR: Some required system resources were not available, PvInitialize().\n");
        return false;
    }
    // no cameras found
    if(!numCameras)
    {
        fprintf(stderr, "ERROR: No cameras found.\n");
        return false;
    }
    
    // since we've just initialized the camera with PvInitialize(), it is the last camera on our list
    // notice how PvInitialize() does not care about the index and so we shouldn't as well-- it has its own
    // unique ID, UID.
    Camera.UID = cameraList[numCameras-1].UniqueId;
    if(PvCameraIpSettingsGet(Camera.UID,&ipSettings)==ePvErrNotFound)
    {
        fprintf(stderr, "The specified camera UID %lu could not be found, PvCameraIpSettingsGet().\n", Camera.UID);
        return false;
    }
    
    if(PvCameraInfo(Camera.UID,&camInfo)==ePvErrNotFound)
    {
        fprintf(stderr, "The specified camera UID %lu could not be found, PvCameraInfo().\n", Camera.UID);
        return false;
    }
    else
    {
        /*
        struct in_addr addr;
        addr.s_addr = ipSettings.CurrentIpAddress;
        printf("Current address:\t%s\n",inet_ntoa(addr));
        addr.s_addr = ipSettings.CurrentIpSubnet;
        printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
        addr.s_addr = ipSettings.CurrentIpGateway;
        printf("Current gateway:\t%s\n",inet_ntoa(addr));
        */
    }
  • Shai

@StevenPuttemans
Copy link
Author

Lets fire up the discussion

  1. I agree that initialization is important not to include specific configuration details for the camera. However, Manta doesn't have a Acquisition mode option, since that camera can only grab continously. Therefore that configuration pushes an error and thus it stops initializing. This is the only reason why the PVAPI_MANTA parameter is actually needed.
  2. I agree that the specific format setting is something that needs to be done by the user. However I do not agree that this should be done with the gigEviewer. Instead I think we should expand the getters and setter functions to push more functionality and warn there if a camera doesn't support the option.
  3. The overload functions is indeed a good approach
  4. As to why that extra !PVAPI_MANTA is there for the AcquisitionMode, simply because that function is NOT supported by Manta camera
  5. I will deal with your adaptations tonight

As a small remark. If you plan to discuss code further, place this as remarks inside the code at the files changed tab. This will keep the discussion a bit more clear. Thanks again for your help!

@ShaiV
Copy link

ShaiV commented Oct 11, 2014

Thanks Steven,
I didn't know about the Manta specific parameters. If that is the case, then do please leave the Manta code as is.

I've tried implementing my suggestion with an overloaded function but the details are too deep and will cause an overhaul of the entire VideoCapture class so for now I think I'll leave it as is. It's good enough for now. Myabe when I have some more time on my hands. While we're at it, the VideoCapture(index) mechanism should be changed to accomodate for this.

Now to tackle a few more bugs/issues. They all creep up when you start hooking up more than one camera. The first issue is if you call PvInitialize() more than once, it will fail (the DLL is already open). This is probably why the original author did not check the PvInitialize() return value, and is indeed a required change.

As suspected, although my initial fix was able to allow for different interface cameras (USB and PVAPI) to work well, it did not handle several PVAPI cameras. This is because PvCameraList() lists all the cameras and not just one after the other.

I therefore implemented a different mechanism. The code keeps trying to open cameras in the cameraList until all the list is exhausted. This way successive calls to VideoCapture() will go through all the PVAPI cameras and you will be able to access them all. See the code that uses the variable findNewCamera for details.

I've made several changes to the function bool CvCaptureCAM_PvAPI::open(int index). I've tried to leave remakrs whenever applicable. By the way, I did a dummy index++ call just so the warning message of an unsued variable will not be shown; if you know of a better way please change this.

First, the change to PvInitialize():

    tPvCameraInfo cameraList[MAX_CAMERAS];
    tPvCameraInfo  camInfo;
    tPvIpSettings ipSettings;
    index++;  // to avoid a warning, we don't really use index
    // Initialization parameters [500 x 10 ms = 5000 ms timeout]
    int initializeTimeOut = 500;
    unsigned int numCameras = PvCameraCount();
    // disregard any errors, since this might be called several times and only needs to be 
    // called once or will return an error
    PvInitialize(); 
    // this if sentence is not needed due to PvInitialize() being called without reading ther result
    //if(PvInitialize()==ePvErrSuccess)
    {
        // Wait until the initialisation actually succeeded in opening up a camera
        // Ensure multiple cameras can be opened if preferred by grabbing the current amount before the initialisation
        while((PvCameraCount()!=(numCameras+1)) && (initializeTimeOut--))
            Sleep(10);
        if(!initializeTimeOut)
        {
            fprintf(stderr,"ERROR: camera initialization timeout [5000ms].\n");
            return false;
        }
        numCameras = PvCameraList(cameraList, MAX_CAMERAS, NULL);
    }
    // the else branch is no longer needed
    /*
    else
    {
        fprintf(stderr, "ERROR: Some required system resources were not available, PvInitialize().\n");
        return false;
    }
    */
    // no cameras found
    if(!numCameras)
    {
        fprintf(stderr, "ERROR: No cameras found.\n");
        return false;
    }

Now the change to read the next available PVAPI camera:

// try opening the cameras in the list, one-by-one until a camera that is not used is found
unsigned int findNewCamera;
for(findNewCamera=0; findNewCamera<numCameras; findNewCamera++)
{
    Camera.UID = cameraList[findNewCamera].UniqueId;
    if(PvCameraOpen(Camera.UID, ePvAccessMaster, &(Camera.Handle))==ePvErrSuccess)
        break;
}
if(findNewCamera == numCameras)
{
    fprintf(stderr, "Could not find a new camera to connect to.\n");
    return false;
}

if(PvCameraIpSettingsGet(Camera.UID, &ipSettings)==ePvErrNotFound)
{
    fprintf(stderr, "The specified camera UID %lu could not be found, PvCameraIpSettingsGet().\n", Camera.UID);
    return false;
}

if(PvCameraInfo(Camera.UID, &camInfo)==ePvErrNotFound)
{
    fprintf(stderr, "The specified camera UID %lu could not be found, PvCameraInfo().\n", Camera.UID);
    return false;
}
else
{
    /*
    struct in_addr addr;
    addr.s_addr = ipSettings.CurrentIpAddress;
    printf("Current address:\t%s\n",inet_ntoa(addr));
    addr.s_addr = ipSettings.CurrentIpSubnet;
    printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
    addr.s_addr = ipSettings.CurrentIpGateway;
    printf("Current gateway:\t%s\n",inet_ntoa(addr));
    */
}

// this if sentence is no longer needed since the camera was opened with the findNewCamera code
//if (PvCameraOpen(Camera.UID, ePvAccessMaster, &(Camera.Handle))==ePvErrSuccess)
{
    // If your camera supports multiple pixel formats and you explicitly want to set the BGR24 format,

Thanks,

  • Shai

PS, I'm not that familiar with Git and don't know how to add remarks inside the code; I'll look it up for the next time.

@StevenPuttemans
Copy link
Author

Added a small sample. This can later be used to add examples of how to address the properties. Want to keep this PR as basic as possible before we move on to other fixes in this API.

@ShaiV
Copy link

ShaiV commented Oct 14, 2014

Works well with two Prosilica cameras in color and in monochrome modes. Some minor cosmetic comments on the code to follow.

{
Camera.UID = cameraList[findNewCamera].UniqueId;
if(PvCameraOpen(Camera.UID, ePvAccessMaster, &(Camera.Handle))==ePvErrSuccess){
printf("Camera found and opended with UID = %d\n", (int)Camera.UID);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change this to fprintf(stderr, "Camera found ...") instead of regular printf()?
Also a minor typo: "opened" instead of "opended"

@ShaiV
Copy link

ShaiV commented Oct 14, 2014

Like I said, works very well and should be committed.

  • Shai

@StevenPuttemans
Copy link
Author

All minor fixes applied and fixed the warnings and build errors.
@asmorkalov could you take the time to review it now?

@StevenPuttemans
Copy link
Author

PING! :)

tPvCameraInfo cameraList[MAX_CAMERAS];
// In order not to break the current VideoCapture interface we want to avoid warning of index not being used
// So we use a bogus operation for this
index++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just remove parameter name from function header to solve warnings:
bool CvCaptureCAM_PvAPI::open( int )

@asmorkalov
Copy link
Contributor

It looks ok for me. Please look at my comments and I can merge it after fixes.

@StevenPuttemans
Copy link
Author

Updated!

@StevenPuttemans
Copy link
Author

@asmorkalov fixed it, could be best to merge it now?

@asmorkalov
Copy link
Contributor

👍

@StevenPuttemans
Copy link
Author

Tss I broke it :D Let me restore :)

series are supported. Testing this with both cams for Windows and Linux
exhaustively.

Optimizing memory footprint by removing unused calls.

Adapted with the input of Shai

Added small example that illustrates how it should work.
@StevenPuttemans
Copy link
Author

Back in order!

@StevenPuttemans
Copy link
Author

@vpisarev @asmorkalov or @SpecLad

could one of you merge this? I complete ruined my other branches and want to delete my repo to recreate it. For this I first need this good branch to be merged! It has been authorized by @asmorkalov

@vpisarev vpisarev assigned vpisarev and unassigned asmorkalov Nov 7, 2014
@vpisarev
Copy link
Contributor

vpisarev commented Nov 7, 2014

👍

@StevenPuttemans
Copy link
Author

Thank you so much! This litterally took ages :D

@opencv-pushbot opencv-pushbot merged commit 7dce2d0 into opencv:2.4 Nov 10, 2014
@StevenPuttemans
Copy link
Author

O great! No idea why pushbot took so long but NICE! Thanks to @ShaiV for helping me out and making this possible!

@StevenPuttemans StevenPuttemans deleted the fix_pvpapi_interface branch November 12, 2014 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port/backport done Label for maintainers. Authors of PR can ignore this
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants