Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading checkerboard colors with webcam

Hello,

I am trying to create a VI that uses a webcam to look at a checkerboard and scan each square to check if it is red, green or blue. I have created numerous ROIs by creating rectangles that are turned into ROIs and stored in a 2D array, and then constantly checked in the main loop containing an IMAQ colorlearn VI to check for color. When I run the VI however, it seems to flash NaN and some values, meanwhile the color detection doesn't seem to be going through. My Camera is filming in 1024 x 720, and the spacing/size of the rectangles in the bottom loop has been chosen for the camera format.

 

I would really appreciate if someone was willing to spare the time to point out what is amiss.WebCam.PNG

 

0 Kudos
Message 1 of 2
(2,551 Views)

Hello GaussianNoise,

 

From the looks of the VI, I'm betting the ROI "Array" local variable in your top loop is being read before the bottom loop has enough time to store all of the ROIs that you create. LabVIEW allows for parallel processes, but when you are reading from one resource that hasn't been fully populated yet, you can run into issues like the one you are seeing. Is it possible to ensure that your bottom loop runs first before the second loop runs at all? To do this, all you really need is to wire the Array output from the bottom loop directly to the Index array function that your Array local variable is connected to. This will ensure that the bottom loop (initialization from what I can tell) completely executes before you start reading from it/using it. 

 

Let us know if you have any trouble!

John H.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 2
(2,493 Views)