Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

VBAI and vbaiGetInspectionImage

Solved!
Go to solution

Hi,

we are using VBAI 2012, CVI 2012 and a Basler ACE Camera for vision inspection. We want to start an inspection in VBAI over CVI. Meanwhile we can start and stop an inspection by CVI. But it is not possible to get an image in CVI. We do not know why.

 

Here is our code:

 

    //
    rw = vbaiLaunchLocalVBAIEngine(Name, VBAI_2012, 1, SessionName, STRLEN);
    rw = vbaiOpenConnection(SessionName, NULL, 0, &Session);
    rw = vbaiOpenInspection(Session, "c:\\test2.vbai");
    rw = vbaiStartInspection(Session);

    // Create an image
    image = imaqCreateImage(IMAQ_IMAGE_U8, 0);
    rw = vbaiGetInspectionImage(Session, NULL, 1, 1, image, &Flag);
    rw = imaqDisplayImage(image, 0, TRUE);

Unfortunately we always get a false Flag and never a picture. Can anybody help us on this

 

Thanks

Oliver

0 Kudos
Message 1 of 13
(4,942 Views)

My guess is that your inspection doesn't get to the "End" terminal state because this is where we update the inspection image. If this is not easy to change your inspection to go through the End state, you can also specify the step GUID instead of using NULL. This will get the current image associated with that GUID immediately so it may be in the middle of processing and if you call the function repeatedly, you may get the same image multiple times. the GUID can be the step GUID of the step that acquired the image or an image Variable GUID. See the shipping example for additional comments on using this function. The shipping example is located under <Vision Builder AI>/API Examples/CVI Examples.

 

Hope this helps,

Brad

0 Kudos
Message 2 of 13
(4,938 Views)

Hello Brad,

our VBAI Program is very easy, just for a test to find a solution for the API programming. I attached a screenshot of it as example.

I tried to find something about the GUID but I was not successful. I will now check the example which you proposed and will give feedback about our results

 

thanks

Oliver

0 Kudos
Message 3 of 13
(4,931 Views)
Solution
Accepted by OZI

Try checking the box that says "Display Resulting Image" that is right above the step on the right. I think this might be the problem...if you never display the image, we don't have a display image to return to you. Using the step GUID for the acquisition step would also work. Let us know if this is the case and I can have a Knowledge Base made.

 

Thanks,

Brad

Message 4 of 13
(4,923 Views)

Hello Brad,

yes this was the solution.

 

We unchecked this box on our application on all steps to save performance. So also in our test application it was unchecked. By checking the box the CVI Application gets the pictures of VBAI

 

Many thanks for your help

 

greetings

Oliver

0 Kudos
Message 5 of 13
(4,910 Views)

Hello

we have now the same problem with a NI smart camera 1772. Is it generally possible to get images with a smart camera like with the vision builder AI server? We have the same software as like for a normal camera, with the normal camera it works, with the smart camera we do not get an image.

 

Is it generally possible to get images with the VBAI API programming with a smart camera 1772?

 

thanks

Oliver

 

0 Kudos
Message 6 of 13
(4,725 Views)

Yes, it should definitely be supported. Do you get errors? If you run one of the shipping Tutorials on the Smart Camera (i.e. Tutorial 1 or 6), can you get those images using the API? Are you using CVI or LabVIEW to call the VBAI API on Windows and connect to the smart camera to get the images? Pleaqse provide more details since what you are describing is not expected.

 

Thanks,

Brad

0 Kudos
Message 7 of 13
(4,723 Views)

Hello Brad,

after we fixed the problems with the Basler camera we found a very good solution for our application. Now we want to convert an other application basing on a 1772 to the same solution. In the moment there is a programm running on the 1772 writen with VBAI 2011. The application on the computer is running under CVI 2012SP1. The application shall still run on the 1772 but the results shall be presented on the PC.

 

Here is a part of the code:

 

rw = vbaiOpenConnection(CameraCmd, NULL, 0, &Cam.Session);
rw = vbaiOpenInspection(Cam.Session, Cam.cProgramPath);
rw = vbaiStartInspection(Cam.Session);
rw = vbaiGetInspectionImage(Cam.Session, NULL, 1, 1, Cam.imPicture, &Flag);

All is running except there we do not receive a picture from the 1772. That means Flag is always 0

In the last step we checked the box with the "Display result image for this state"

 

Do I have to check this in every step or only in the last step?

 

thanks

Oliver

 

 

 

 

0 Kudos
Message 8 of 13
(4,719 Views)

Only the last state is required. I assume you're checking the error of the other calls and everything looks good. In particular the Load Inspection works? The path for an inspection on RT should be determined based on what vbaiGetTargetInpections returns. I just tested this with my Smart Camera and VBAI 2013 and it works fine, so I think there's probably something you're missing. Try one of the shipping examples to ensure the simple case works. Make sure your inspection goes through the End state and doesn't just loop on an acquire state. There are ways to work around this End State requirement, but I just wanted to make sure something simple works first.

 

Hope this helps,

Brad

Message 9 of 13
(4,716 Views)

Hello Brad

I added a new State at the end of the inspection and I add an other AquireImage to this state to be sure that there is a Picture

 

With vbaiGetTargetInpections I checked that I really see the real time target, and I found the four programs which I have on the target, so the connection seems to be ok

 

I add the path of the right inspection from the result of vbaiGetTargetInpections

 

I get results from the camera over the CNVCreateSubscriber, so the connection seems also ok here.

 

But I still do not get a picture with rw = vbaiGetInspectionImage(Cam.Session, NULL, 1, 1, Cam.imPicture, &Flag);

The Flag is always NULL

 

Any other idea?

 

thanks

Oliver

 

0 Kudos
Message 10 of 13
(4,708 Views)