LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spherical Lens to 2D coordinates (conversion)

Solved!
Go to solution

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

 

sph1.PNG

0 Kudos
Message 1 of 12
(3,925 Views)

Look into grid calibration functions in vision VIs

It will allow to transform pixels into coordinates on the flat surface.

0 Kudos
Message 2 of 12
(3,894 Views)

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? 

0 Kudos
Message 3 of 12
(3,883 Views)
Solution
Accepted by topic author mr97

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

Bruce Ammons
Ammons Engineering
Message 4 of 12
(3,868 Views)

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?

0 Kudos
Message 5 of 12
(3,865 Views)

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

Bruce Ammons
Ammons Engineering
0 Kudos
Message 6 of 12
(3,858 Views)

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!

0 Kudos
Message 7 of 12
(3,852 Views)

X and Y are the coordinates of the spot you found.  The point that you wanted to convert to spherical coordinates.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 8 of 12
(3,846 Views)

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!

0 Kudos
Message 9 of 12
(3,833 Views)

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.

 

Message 10 of 12
(3,815 Views)