Hi Thomas and others.
I saw (but didn't understand) the binary search algorithm for calculating distance in psmove_fusion.cpp and I saw the psmove_tracker_distance_from_radius method in psmove_tracker.c
I thought there must be a simpler, faster, and maybe more accurate way based on trigonometry. Thomas, did you ever investigate this?
First, some constants.
Does anyone know the exact diameter of the sphere, as measured with a caliper? I used a very crude technique and got 45 mm, and I saw the official tech specs for the entire controller had the diameter as 46 mm.
The source code has the blue-dot FOV as 75 degrees. Is that horizontal, vertical, diagonal? What is the source of that number?
Do we know the pincushion distortion?
If we take the blue dot fov as 75 diagonal, and the sphere diameter as 46 mm, then the distance, in mm, can be calculated as:
d = 23 / sind( r_pix * 75/800 ); where r_pix is the radius of the sphere in pixels.
This method can be adapted to any camera as long as we know the FOV and the frame width.
In words, the logic is something like this:
The camera has an angular resolution of 800 pixels (diag) per 75 degrees (diag).
Therefore, an object that occupies r_pix pixels will occupy r_pix * 75/800 degrees of visual angle.
The sine of this angle is equal to the ratio of the radius (measured 23?) to the distance (d = from camera focal point to centre of sphere).
Solve for d.
I tried this for different values of r_pix and got a curve similar in shape to the one on page 41 of
Thomas' thesis.
Here is my equation (in red) overlayed on top of Thomas' data.
The fit is pretty good, but not great. There are some problems. At least 2 that I know of:
1. I don't know the focal point of the camera. If it is somewhere behind the camera then this will add an artificial offset to my distances, shifting the red curve to the right, as it is here.
2. I have not considered lens distortion. Does the radius in pixels get calculated after undistorting the image? It should, but then we need to know its distortion.
3. My estimate for sphere radius may be off.
Comments?