Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Object Recognition Acquisition Rate

So I am currently using a Prosilica GC 640 camera to track a mouse ball along a surface.  The camera is running at 200 fps, and 493X493 resolution, and I have the Count Objects VI, tracking the ball with the parameters I specify (max/min size, brightness), and then output the pixel coordinates of the center to a text file.  I am currently running into two problems due to inefficiencies in my code:
 
1)  If I try to run the program twice, the array I'm storing the position data to before it gets written to the text file doesn't clear itself and the second run just starts at the point where the first run left off.  I'm sure there is a better way to get the data into an array/clear the array between runs.
 
2) When the program writes the data to a file, I have it write the frame number, x position, and y position of the center of the ball.  However it frequently will only record say every 4 frames of position, but the camera is still acquiring at full speed.  If I take down the "ExposureTimeAbs" parameter in the measurement and automation explorer settings, it will record a bit faster, but the darker image makes it harder to recognize the ball.  I'm sure there might be a more efficient way to buffer/record the data so that I get the position at the full desired rate of 200 fps, any tips on this would be appreciated.
 
I'm posting my code and a screenshot of what the images look like.
 
Also the code is set up so that it only takes pictures if you hold down the capture button, so its not recording images non-stop.
 
Thanks,
-Ted
Download All
0 Kudos
Message 1 of 4
(3,469 Views)
Hi Ted,

Thanks for posting to the NI forums.  I don't know if you posted an old version of your code, but all I see when I open the VI is code for a snap, and a count objects VI that is disconnected and off to the side. 

If you are calculating the position data in a loop with a shift register, try wiring an empty constant to the shift register to initialize the loop variable.  You can just right click on the input to the shift register, and select create >> constant.

When you write the data to file, don't open and close the file every time in the loop. Instead, open the file before the loop, write to the file inside the loop, and close the file after the loop. If writing to the file is missing values because it takes too long, one possibility is to use the producer consumer architecture.  The producer loop could acquire the images and find the center, then pass those values to the queue.  The consumer loop would take values from the queue and write them to file.

Hope this helps!
Maclean G.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 4
(3,454 Views)
Sorry it was a earlier draft of the code...here is the actual vi that I'm using.
 
-Ted
0 Kudos
Message 3 of 4
(3,451 Views)
Hi Ted,

To clear the position array, right click on the initializer terminal, and  select create >> constant.  That will set the array to empty every time the VI starts.  I suggest you move the Diagram Disable structure in the top left corner of the while loop outside of the loop, so that you aren't initializing the cluster every iteration.  As a tip, you don't need to cast integers to longs manually, instead you can right click on the numeric (indicators, constants, and controls), and select Representation as shown below. 



Instead of using Array to Cluster and Unbundle (or Bundle and Cluster to Array), I suggest just using Index Array (or Build Array).  Little changes like this might speed up your program enough to capture all of the data.  If not, I would still suggest the producer consumer architecture.

Hope this helps,

Message Edited by Maclean on 09-27-2007 12:31 PM

Maclean G.
Applications Engineering
National Instruments
Message 4 of 4
(3,448 Views)