From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to improve rectangle detection?

Hi, I am building a system where cameras are used to solve sample location in a turntable. The main feature is to detect this rectangle shaped sample holder, and track it's corners when it's being rotated. I am using vision assistant, and within it, shape detection function to do this. The issue is that I can't figure out how to make the detection better. In the pictures below, you can see that the shape detection seem to work quite well when the object is straight, but when it's turned, the detection algorithm doesn't do very good job.

 

 

1.png

2.png

0 Kudos
Message 1 of 4
(3,437 Views)

Hi, 

I notice you are using the Detect Shapes VI (via vision assistant). I would try using the Pattern Match VIs instead.

(there is an example in the vision section of the example finder called 'Pattern Matching (All).vi that would be worth looking at).

0 Kudos
Message 2 of 4
(3,420 Views)

Thanks for your input. Pattern matching does indeed seem much more stabile form of detection. However, I still need to know the pixel coordinates for the rectangle corners, so I thought shape detection would still be sensible to use. I was able to tie the shape detection ROI to the coordinates from pattern matching, and while editing the vision assistant, you can see that the shape detection does detect the rectangle quite well. But when running the VI, it's as if the program doesn't detect rectangles, and number of matches just stays at zero. Any idea what is going on?

 

pattern.png

0 Kudos
Message 3 of 4
(3,399 Views)

Personally I would move away from the vision assistant and write your code straight into LabVIEW, I have always had more success this way.

 

You should be able to find your corners with the ROI descriptor data that comes out of the pattern match vi

http://zone.ni.com/reference/en-XX/help/370281U-01/imaqvision/imaq_match_pattern_4/

0 Kudos
Message 4 of 4
(3,393 Views)