Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Circular Object Detection

Hello All,

              I am working on a circular object detection through NI vision module and am using Basler Monochromatic camera. I tried using the both IMAQ pattern detection and geometric detection ,but the time taken to process the image is too long. Both these processes are taking a time of around 60ms to 85ms, but I want it to be much more faster in order of 20 to 25ms.

It would be really helpful if someone can suggest us any algorithm for much more robust detection.

 

Thanks in advance..!!!! . Smiley Happy

0 Kudos
Message 1 of 5
(5,326 Views)

I can think of a few methods, but I need more information.

 

Can you post an image that shows an example of what you are trying to find?  Can you describe the process or what creates the circles?  Can you give us more background?

 

Are they always perfect circles?  White on black background, or strong enough contrast to threshold easily?  Is the diameter fixed, or does it vary?  Just one at a time, or multiple circles in one image?

 

The simplest idea is to extract one horizontal line of pixels and search it for a bright section that would be crossing a circle.  Move down about half a diameter and check again, repeating to bottom of image.  If you find one, find the two edges and check a vertical line passing through that point.  That should be a vertical diameter passing through the center of the circle, and should give you enough information to locate the circle.

 

If the circle is moving slowly, you can start the next image by checking where the last circle was.  You will find it in one shot if it hasn't moved more that half a diameter.

 

Processing a single line of pixels is much faster than trying to process an area of pixels.  You might be able to get down to a few milliseconds.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 5
(5,305 Views)

Sir,

Am trying to detect a white ball on a dark background.

Infact the setup is very much similar to this, a camera is mounted vertically facing downwards with a dark background placed on the floor. The ball will be thrown such that it passes through the field of view of the camera. I need to extract the X and Y direction velocities of this moving ball in the 2D picture frame and the X coordinates where it made an exit in the picture frame. Since the ball is thrown at some speed (not very high speed), I am left with very small amount of time for detection as well as computation of the velocity.It is here that I need a help in the algorithm.

Also can you please elaborate your alogorithm that you wrote. Do you want me to search in each row or coloumn of picture for white pixels against the dark ones and how would it know that the white pixel detected is a part of the circle and not some noise due to light intensity variation.

 

Thanks and Regards,

 

Akshay

0 Kudos
Message 3 of 5
(5,302 Views)

If the ball is passing in front of the camera the same way every time, I would use a large circular buffer for acquiring images.  In each image, I would extract a vertical line near the edge where the ball will start.  Check if the ball has started, and if not you are done with the image.  You might have to check a few vertical lines if the ball will be moving really fast.

 

For your line analysis, you could use the detect edge routines to find matching pairs of edges.  You could also just look for a region of pixels that is significantly brighter than the background.

 

Once you find the starting image, you can track it across the image.  Start from the previous location and search using spaced vertical lines going in the direction of travel.  Once you locate it vertically, use a horizontal line to locate the center of the ball.  You could have some false positives on the vertical line, but the horizontal line should always measure a very precise value for the diameter of the ball, which should be constant or in a small range if it is at different distances..

 

After detecting the initial image, you could actually use pattern matching if you want.  If you set the ROI to only include the area where the ball could be, it will search a much smaller area and be much faster.  If you don't like the vertical line search, just search every third or fourth image for the ball, possibly limiting the search area using an ROI.  Once you locate the ball, you could search in previous and later images to locate it in each frame.

 

Yet another idea.  Measure the background brightness with no ball, and set the threshold level a little higher than that.  You can very quickly apply a fixed threshold level, then use blob analysis on any resulting objects to see if it is the ball.  If it isn't quite accurate enough, use it to get the ROI around the ball, then use pattern matching to get more precise results for the ball.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 5
(5,293 Views)

Dear Akshay,

 

All of Bruce comments are good.

I would like to add some.

I did 2 years back algorithm like that on Quadcore PC (PXI RT System) and it run in 700 FPS. You should have no problem to achive 200 FPS with today PC.

What I did

1. Sum the image on X and sum the image on Y (IMAQ Linear Average). From the vector on X and Vector on Y you can find the center of the ball to good precision (Smooth the vector and find maximum).

2. I needed higher presision. So I created an ROI around the ball (IMAQ Extract) .

3. Threshold on the ROI (IMAQ Thershold).

4. Morphologicl cleaning (opening)

5. Centroied of the blob (IMAQ Centroied).

 

To utilze the processor more efficently I sapparatt the procesing into pipeline processing. I did some of the processing in the acquasition loop (step 1).

Then  register event and do the rest of the processing in even base loop.

 

This is what I did at the time. I would suggest that you will also look at optical flow algorithms in IMAQVision. This algorithm should be a good fit for the task.

 

Thanks - Amit,

 

Amit Shachaf
0 Kudos
Message 5 of 5
(5,264 Views)