Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Camera Snap lost when add analysis functions

When I try to analyze the image from a USB camera, the image "disappears" so I get no analysis.
 
I have a working USB camera from which I can snap an image  (IMAQ Create > IMAQ USB Snap > Image Display). I have an image analysis VI worked out through Vision Assistant that works fine from a image file (that was taken with the USB camera above) (IMAQ olorThreshold > IMAQ Morphology [erode] > IMAQ Particle Analysis).
 
But when I connect the image out of the IMAQ USB Snap.vi to the image src input of the IMAQ ColorThreshold function, I no longer get an image and of course there's no analysis.
 
When i put a disable structure around the analysis functions (and thus see an image) the image specs (?) show
320x240 1/1 32-bit RGB image 0,0,2  (0,0)
When I remove the disable structure  (thus getting no image), I see
320x240 1/1 8-bit RGB image 0  (0,0).
 
I don't understand how adding analysis functions after the snap vi changes it's operation. I'd appreciate comments on this question, and/or on why my snap and analyze vi is not working.
Jim Austin
0 Kudos
Message 1 of 7
(4,266 Views)

Hello!

 

Did you allocated memory in the function?

 

Can you send us a piece of your code to understand better?

 

Regards

0 Kudos
Message 2 of 7
(4,256 Views)
Could you send the simple VI that shows this problem.  I think this will be the easiest way to see where the problem lies.  You can find out yourself if you wire the error cluster for all VIs and then put the VI in highlight execution mode and watch for any errors and see where the first problem happens.  It looks like you may be trying to do greyscale processing on a color image and that returns an error and doesn't output the image, so all subsequent functions fail and don't output an image.
0 Kudos
Message 3 of 7
(4,236 Views)
The VI I mentioned in my first post is attached. As I said, it shows an image when run with the diagram disable structure in place around the analysis functions, but behaves as discribed above when run without the disable.
 
Carmo,
I read some of the write-ups on IMAQ allocation. They indicate that the "approved" snap, grab, etc. call Configure Buffer internally; are you saying that USB Snap does not? If so can you point me to an example of allocating for a USB Snap?
 
Brad,
Haven't noticed errors from the VI but will run again to make sure (will be tomorrow when I'm at the facility that has the camera). The camera is a Logitech Fusion, which is a color camera, and the first analysis function is IMAQ ColorThreshold so wouldn't expect a color/grayscale problem. This is code generated by Vision Assistant from this camera, so would hope it's correct (?) ...
 
I appreciate the input from both of you. And if you know of a cache of USB examples I'd appreciate a pointer; NI lack of support for USB cameras is a pain!?
Jim
0 Kudos
Message 4 of 7
(4,226 Views)
Hello Jim Austin,

Thank you for using National Instruments discussion forums.  It sounds like there might be an issue with your image management in the code.  It is key to note that VIs like IMAQ ColorThreshold have two "Image" inputs: "Image SRC" and "Image DST".  Each image has a defined space and location in memory that is either used or operated on depending on the VI.  If you only connect the source image (Image SRC) then the VI will perform its operations on the Source Image.  This means that the image data in memory is being manipulated.  So if for example you also have an image display connected to the source image it will reflect these changes dynamically.  To do processing on an image and still preserve the original image you will need to to make a copy of the image using "IMAQ Copy.vi " or make sure you wire a different image (using another IMAQ Create.vi) into the "Image DST" input.  The output of the VI will now be the original image values that are now manipulated but saved in the memory space for the "Image DST" input.  I hope this information is clear.  Let me know if it is not or if you have any questions.  Thanks and have a great day.

Regards,
Mark T
Applications Engineer
National Instruments
0 Kudos
Message 5 of 7
(4,223 Views)

Mark,

Thanks for your reply. Yes, your information is perfectly clear; it is indeed key to understand that Image Src is a reference to an image storage space, not a data input. Now the documentation in the NI Vision for LabVIEW User Manual makes sense, as well as the behavior of my VI.

 

I created an Image Dst space and the VI is now working. It might be helpful to have a big “NOTE” at the beginning of the User Manual that says “Many NI Vision functions use a reference to an image space, NOT the image data itself!”

 

Thanks again for your help!

Jim
0 Kudos
Message 6 of 7
(4,207 Views)
Hello Jim,

I am very glad you got the VI working correctly.  Yes I agree that the image memory allocation is a little confusing the first time you use it.  I just want to add a little bit of clarification to your last statement.  The image inputs and outputs on all Vision VIs that use the IMAQ image format are all references to images in memory.  So in otherwords they all reference the image in memory but some will actually change the image data while others use the image data for calculations to determine some output.  As long as that makes sense it sounds like this topic is clear now.  Good luck with the rest of your programming.  Let us know if you have anymore questions.  Thanks and have a great day.

Regards,
Mark T
Applications Engineer
National Instruments
0 Kudos
Message 7 of 7
(4,197 Views)