02-24-2014 05:05 AM
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?
02-24-2014 06:58 AM - edited 02-24-2014 07:02 AM
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
02-24-2014 10:19 PM
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.
02-25-2014 01:08 AM - edited 02-25-2014 01:09 AM
Hello,
take a look at the following thread, post 5 (altenbach's post). I don't think it gets any simpler than this...
Best regards,
K
02-25-2014 11:21 PM
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?
02-26-2014 12:08 AM
hello,
i tried this out.. seemed to work alright..
.
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?
02-26-2014 12:42 AM
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
02-26-2014 04:31 AM
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 ?
02-26-2014 05:26 AM - edited 02-26-2014 05:27 AM
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
02-27-2014 01:13 AM
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?