Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Line scan camera ring buffer processing

Hello!

I'm using Visual C++ 2003 together with the Vision Development Module version 8.0 to write a machine vision application. I have to detect and measure single objects on a conveyor belt. The conveyor belt is black and the objects are not, so the presence of the objects can be detected by checking for reasonably bright pixels. A line scan camera records images continuously.

Currently, I plan to do the following:

imaqSetupRing(...);
imagStartAquisition(...);

while(true) {
    imaqExtractFromRing(...);
    if (many white pixels, aka start of object)
        start remebering lines to second buffer;
    if (not so many white pixels, aka end of object)
        stop remembering lines and process aquired image of object
    imaqReleaseImage(...);
}

While I know from experience that this should work, I have some questions regarding how the NI Vision Development Module fits into the picture:

1. Is the above approach reasonable from a performance point of view when the NI Vision Development Module is used? Are there other usage patterns implemented in the NI Vision Development Module which could be used to implement a similar behaviour? Would it increase performance significantly to use NI IMAQ functions for the aquisition (img...)?

2. Am I right that the imageToExtract parameter to imaqExtractFromRing() always increases but the imageNumber parameter will be within [0,ring buffer size[ ?

3. If yes, why can't I use imageToExtract modulo ring buffer size to calculate imageNumber?

4. When I use imaqExtractFromRing() to get the next line, will the function wait until an image actually has been aquired?

5. What happens if the imageToExtract parameter overflows? For my application this will happen after about 200 hours, which is short enough to worry about in a production environment.

Thanks in advance for any pointers!
Markus

0 Kudos
Message 1 of 5
(4,757 Views)
Dear Markus

I can't answer your questions in detail, but the example under this link
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3F11556A4E034080020E74861&p_...
implements pretty much what you want, I guess.

Best regards

Philipp Roessler
Message 2 of 5
(4,684 Views)
Hello Markus,

have you check out the examples that are contained in the following directory:

C:\Program Files\National Instruments\NI-IMAQ\Sample\MSVC\Ring.

The code will have to be converted into the .NET environment in order for you to view the code. This is usually done by .NET automatically.

You should notice that the imaqExtractfromRing function is not even used in the example. Instead, the imgSessionExamineBuffer function is used for C++ based Ring acquisition.

The imageToExtract argument will receive a buffer number to extract, which will increase as more images are acquired. If you are concerned about reaching the terminal count, you should be able to have specific control over which buffer index that you wish to extract instead of just incrementing the index indefinitely. Your strategy to have a dedicated. buffer for each line is acquired from the line scan camera This is a really inefficient way of doing this. Instead, if you know how many lines constitute an image with your camera, you should configure your software to acquire a set number of lines to fill a buffer. The driver will wait until the buffer is filled with all of the lines before it proceeds to the next buffer.

I hope this information helps. If there any additional questions regarding this issue, please reply back with your questions.

Best regards

Benjamin
Message 3 of 5
(4,642 Views)
Hello Benjamin,

thanks for your reply. I was on vacation until yesterday and therefore I'm replying a little bit late, so I hope this reply still reaches you.

You wrote that I should have a look at the Ring example that comes with the NI-IMAQ toolkit. I do know the example you mentioned. Infact, part of my original question was if it would increase performance significantly if I used the img... functions (e.g. imgSessionExamineBuffer) instead of the imaq... functions (e.g. imaqExtractFromRing). From my understanding, the imaq... functions are just a thin wrapper around the img... functions which return data in a different format. I asked this because I'd like to use the imaq.... functions because they seem more high-level and return the data in the format I want (Image*), so I don't have to write additional code for conversion. In my opinion, the problem is rather that the documentation on these functions is sparse and there is no example provided. E.g. I asked if imaqExtractFromRing() waits until an image actually has been aquired. My tests say that it usually does, but the documentation does not mention it. This creates a certain uncertainity that makes me feel uneasy about using that API, especially as the application we're building will be used in an environment where failure of the system could create damage to the client.

You wrote that I "should be able to have specific control over which buffer index [...] to extract". Could you elaborate on this? Neither the documentation nor the example you mentioned covers this scenario. Infact, question 2 and 3 of my original message still remain unanswered. All the documentation to imaqExtractFromRing() says is that the imageToExtract parameter should be increased.

You wrote that aquiring one line at a time is inefficient and I should configure my software to acquire a set number of lines to a buffer if I know how many lines constitute one image. However, as I wrote in my original post, I do not know how many lines constitute one image because the objects to recognize can have different lengths. I'm a bit puzzled that this is even remarkable because I would have imagined that applications with line scan cameras where objects have different lengths should be common. Anyway, my tests show that there are no performance problems acquiring some thousand lines per second as individual images with the NI Vision toolkit, as long as the number of buffers used is large enough to acount for the largest possible jitter in the computing system.

Best regards

Markus

0 Kudos
Message 4 of 5
(4,571 Views)
Dear Markus

The imageToExtract parameter in the function "imaqExtractFromRing(...)" is
(as stated in the help) a "cumulative" number that refers to the buffer
number you would like to extract. The imageNumber parameter in this same
function is also the buffer number of the image you would like to extract
but returned from the image. So when you are specifying a buffer number to
extract this is redundant information. But if you are using the option to
set the imageToExtract parameter = "IMG_CURRENT_BUFFER" it will return the
image that is currently being acquired. So in this case the imageNumber
parameter would be useful so you would know which buffer number you are
currently extracting.

I encourage you to look at the website at
http://zone.ni.com/devzone/cda/epd/p/id/4328 for very useful pointers
regarding your sort of ring wise image acquisition (especially
C:\Programme\National Instruments\NI-IMAQ\Sample\MSVC\Signal IO\VHA Ring).

Best regards

Philipp R.
Message 5 of 5
(4,489 Views)