Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

finding the closest reference point for the object center

Hello,

My program detects the roi of an object and tries to determine the it's position with respect to 4 reference points placed near the corners of the roi. Iam planning to measure the euclidean distance to detemine the nearest reference point for the object center but iam not sure how to do this. Anyone knows how to do this?

0 Kudos
Message 1 of 10
(5,901 Views)

Hello,

 

assuming that the object center means the center of mass, you can segment the object from the background (inside a ROI) and calculate its center of mass (you can use Particle Analysis Report.vi) . Then use a distance criteria to check the distance between all four reference points.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 2 of 10
(5,897 Views)

Hello klemen,

I already have the program of a vi that returns the object center co-ordinates for a frame. The reference points have been stored in variables during initial calibration procedure. My main problem is how to determine the closest reference point when object center is within the roi in real-time. I'm not sure whether pure mathematical distance calculation of the 5 points using something like a formula node or image distance criteria using maybe caliper function works faster.

0 Kudos
Message 3 of 10
(5,882 Views)

Hello,

 

take a look at the following thread, post 5 (altenbach's post). I don't think it gets any simpler than this...

 

http://forums.ni.com/t5/Machine-Vision/how-to-dynamically-measure-distance-between-two-points/td-p/2...

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 4 of 10
(5,876 Views)

Hello,

The link answered my question , my input is a 1D array of 2 elements so when i tried to implement it using the type cast node i get a string output. How should i convert this to a 2d array in a simple way for it to work?     

abc.jpg

0 Kudos
Message 5 of 10
(5,863 Views)

hello,

i tried this out.. seemed to work alright..

.

new.gif

i do have one more question though...... i need the program to keep track of the closest reference point for different frames such that when the object is closest to that point continuously for a number of frames or a time limit, it will generate an action. How do i design something like this?

0 Kudos
Message 6 of 10
(5,858 Views)

Hello,

 

use a counter (loop iteration or better yet a timer counter). Then when the counter reaches the specified value, generate an event according to your preference. You could for example use Value (Signaling) Property:

 

http://zone.ni.com/reference/en-XX/help/371361H-01/lvprop/ctrl_value_signaling/

 

Or just a simple case structure, reseting the values after the case is processed.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 7 of 10
(5,855 Views)

Thanks....i have a silly doubt. Since i calculate the distances individually how can i easily program the vi to determine the reference point based on the shortest distance ?

0 Kudos
Message 8 of 10
(5,848 Views)

Build a cluster (for each reference point) with two elemets:

 

1. calculated distance (SGL or DBL),

2. name of the reference point (string).

 

Then:

 

1. build array of all 4 clusters,

2. sort array (ascending order),

3. index the first element in the sorted array,

4. unbundle the cluster to get the name and the calculated distance.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 9 of 10
(5,843 Views)

Thank you....it's working nicely. I'm trying to control the cursor position programmatically and enable clicks. I found this vi . Is it the best way?

0 Kudos
Message 10 of 10
(5,829 Views)