09-23-2013 05:55 AM
09-24-2013 01:19 AM - edited 09-24-2013 01:23 AM
Hello,
first, if you want to measure the distance with only one camera, you need to have and maintain a constant distance between the camera and the measured surface - the point. If you move either, the measurements will not be valid anymore, since there will be a change in the magnification.
For passing your pixels position to the controller, you will need to calibrate the system - you need to find the relation between pixels shift and the controller. This should be straightforward - after setting up your system, you need to move the point with the cotroller and note the pixels shift (in both axes). You could do some statistical analysis of the repeatability of your motion.
Before this, it is also good to cancel out the lens distortion, because it is not linear and will affect your measurements when moving the point through the camera's field of view. You can use the NI calibration training interface. Try to cover the entire field of view of your camera with the calibration grid.
About the method to use in order to obtain the marked point coordinates you could simply (auto) threshold your image. Try to have as much as contrast as possible between the background and the point (if the the paper is white and the point is black, you should have no problem. If your point is for example red, use the green channel, etc...). In the first iteration, you could mark the area where this point is positioned or you could make some other estimation. In every next iteration, you can just threshold the image inside a specified ROI, that is determined with the position of the point. This ROI should be adaptive, so that in every subsequent iteration it "moves" with the point. I have attached a simple example of getting the (center of mass - assuming constant density) coordinates of the point that can be used as a starting point.
Alternatively, you could also look at the pattern and geometric matching methods. If you have LV2013, you could also try the new tracking library - you can get the example code (used in real-time) from one of the posts here: https://decibel.ni.com/content/blogs/kl3m3n
Hope this helps.
Best regards,
K