03-07-2019 07:19 AM
Hi!
I'm trying to build a circle detector to find the centres of circles. I am using a 180 degree camera for a wider field of view, but this means that I need to somehow translate the coordinates my algorithm thinks it's reading to actual x/y coorindates based on the distortion due to the lens. Any idea how I can mathematically describe and implement this relationship?
Thanks! I've attached a pic of my front panel for context
Solved! Go to Solution.
03-07-2019 10:58 AM
Look into grid calibration functions in vision VIs
It will allow to transform pixels into coordinates on the flat surface.
03-07-2019 02:13 PM
Hi, and thanks for your reply. I've looked into this method but it only seems to work by undistorting the image, which takes a lot of processing time and slows down my VI. Is there any way I can translate the x/y pixel position outputted by my object detector into azimuth and elevation angles relative to the center of the camera? Perhaps a mathematical equation relating the two together?
03-07-2019 04:36 PM
X and Y are the original pixel coordinates. Xc and Yc are the pixel coordinates of the center of the circle. R is the radius of the circle in pixels.
Define X1 and Y1 as:
X1 = (X-Xc) / R
Y1 = (Y-Yc) / R
If we knew the azimuth (A) and elevation (E) angles, we could write:
Y1 = sin(E)
X1 = sin(A) * cos(E)
Therefore, solve for E, then A to get your spherical coordinates.
E = asin(Y1)
A = asin(X1 / cos(E))
Bruce
03-07-2019 04:47 PM - edited 03-07-2019 04:52 PM
Hi and thank you for your answer! By original pixel coordinates (X and Y), do you mean from the center of the camera's field of view? Also, does this work considering the 180-degree camera lens?
03-07-2019 06:07 PM
The center of the circle is Xc, Yc in camera pixels, as I said. You subtract the center from the X, Y coordinates, then divide by the radius.
This will only work with the 180 degree lens.
Bruce
03-07-2019 06:23 PM
I'm still confused as to what you mean by X and Y coordinates. What do these coordinates point to? I understand what Xc and Yc are. Thanks!
03-07-2019 07:54 PM
X and Y are the coordinates of the spot you found. The point that you wanted to convert to spherical coordinates.
Bruce
03-08-2019 02:20 AM
Oh I see, so Xc and Yc are the fisheye circle then? I got confused because the object i am detecting is also a circle. Thanks!
03-08-2019 09:11 AM
But this formula is valid only when
1) image plane (desk with keyboard) is perpendicular to camera axis
Otherwise point Y1 will be at different absolute angle than point -Y1
2) No lens distortions (fisheye has a lot) - it is not Sine anymore.