Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems using Ring acquisition.

I have recently found out that I am processing a captured image multiple times.
I am using the imgSessionStatus()... imgSessionExamineBuffer()...[subsample]... imgSessionReleaseBuffer()... and then process scenario in a continuous loop. There is a 3 buffer ring in use.
What I have found is that the loop seems to come around faster than the image gets captured. The same image gets processed 3 times.
Is there a way to indicate that there is a fresh image ready to process?
(I am using 1428 in Visual C++)
BTW...My camera is limited to 22fps for integration purposes and...imgSnap() yields choppy images.
0 Kudos
Message 1 of 9
(5,342 Views)
Hello,
As acquisition of 3 images begins, images 0 through 4 fill up the buffer list. As more images are acquired, they overwrite the old images in the buffer list with new images. This process continues until the acquisition stops. What could be happening is that you are only specifying buffers numbers 1 to 3. You need to specify 0, 1, 2, 3, 4, 5..and so on in order to avoid overwriting the old images.
Also you can increase the buffer size to see if that makes a difference. Refer to Ring Acquisition Tutorial to understand how you can setup ring acquisition. Also look at IMAQ Ring Examples to get an idea of how to use our IMAQ functions to perform ring acquisition.
Good luck with your application and have a great day!
Regards,
Koninika
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 9
(5,337 Views)
My ImaqBuffers[] array contains 3 elements. I use imgSessionStatus() to return which bufNumber is active. I then call "rval = imgSessionExamineBuffer (view->SessionID, bufNumber, &currBufNum, &bufAddr);" and use *(ImaqBuffers[bufNumber]) to sub-sample the acquired image.
Although bufNumber is looping from 0 to 2, it appears as if the image is not changing until the buffer comes back around to 0.
0 Kudos
Message 3 of 9
(5,337 Views)
I see the exact same problem of imgSessionExamineBuffer returning the same buffer index even though I call it with a bigger cumulative index each time in my loop. In each iteration of my loop I display the acquired image and write it to disk. With large images I fully expect some buffers to be skipped, but I certainly do not expect the same buffer to be returned twice in a row. Does anyone have an explanation for this and/or how to either fix the problem or use an alternative method for retrieving the buffers of a ring acquisition?

Thank you very much,

Jerry
0 Kudos
Message 4 of 9
(5,191 Views)
Jerry,

Is your acquisition code and processing code all in the same loop? Also, are you positive that it's the same image being processed? You could test this by loading completely different images into the buffer from files and using those, because with acquiring at 30 fps, two adjacent images would look really similar unless your recording something happening at really high speed.
0 Kudos
Message 5 of 9
(5,171 Views)
Thank you, Tyler. Yes, my acquisition code and processing code are all in the same loop and therefore I am fully expecting some frames to be lost. The way I determine which image is returned is by the value returned in the third parameter of imgSessionExamineBuffer which I believe is supposed to be the cumulative index of the image returned. If two images have the same value in this parameter, I consider them to be the same. However, I have never actually looked at the images and compared them pixel by pixel. It is a good point though and I will go ahead and do the comparison. Please let me know if you have any more suggestions/ideas. Thanks again!

Jerry
0 Kudos
Message 6 of 9
(5,169 Views)
Tyler,

I have verified that those images are indeed the same, pixel for pixel.

Jerry
0 Kudos
Message 7 of 9
(5,159 Views)
Hmm, that's interesting. Have you tried running the ring buffer examples that download with IMAQ? They'd be located at C:\Program Files\National Instruments\NI-IMAQ\Sample\MSVC\Ring. I'd be curious to see if you saw the same problem with these because they've been thoroughly tested. They may help you see where something is wrong too.
0 Kudos
Message 8 of 9
(5,140 Views)
Tyler,

My code follows NI's low level ring (LL Ring) example very closely, the main differences being I added code to write the images to disk as they are acquired and I use the IMAQ vision library to display the images. But again I have never run the example itself. I will try to do so when I get a chance. Another good suggestion - thanks!

Jerry
0 Kudos
Message 9 of 9
(5,136 Views)