Cartesian coordinate system in perspective projection

I am still implementing a perspective projection for an Augmented Reality application. I already asked a few questions about the calculation of the viewport and other camera materials that are explained from Aldream in this thread.

However, at the moment I am not getting a useful value, and I think it depends on my calculation of the Cartesian coordinate space.

I had different ways of converting latitude, longitude, and altitude to a Cartesian coordinate space, but none of them work properly. I am currently using ECEF (with Earth orientation), but I have also tried different calculations, for example, a combination of the haversine formula and trigonometry (to calculate x and y from the distance and the relationship between two points).

So my question is:

How does Cartesian coordinate space affect my perspective projection? Where should I “compensate” for my units? (For example, when do I use a meter or centimeter)?

Suppose I use ECEF, than get the values ​​in the meter, for example, my camera is at a height of (0,0,2 m), and my point is at (10,10,0). Now I can easily use the function mentioned in wikipedia, and then using the dx, dy, dz conversion explained in my other topic (mentioned above). What I still do not understand: how does this projection “know” that my units are in the coordinate system? I think this is the mistake I am making right now. I do not process units of my coordinate system and therefore cannot get a good value from my projection.

When I use the coordinate system with a centimeter as a unit, all my values ​​from my perspective projection increase. Where do I need to "solve" this problem? Should I "convert" the width of the camera and the height of the camera from pixel to meter? Do I need to convert a coordinate system to a pixel? What coordinate system should be used to solve this situation? I hope you understand my problem.

Edit: I decided it myself. I changed my coordinate system from ecef to my own system (using haversine and bearing, and then calculating x, y, z), and now I get good values! :)

+2
source share
1 answer

I will try another way to explain it here. :)

Short answer: the unit of your Cartesian positions does not matter if you keep it homogeneous , i.e. while you apply this unit to both your scene and your camera .

For a longer answer, return to the formula used ...

Projection to screen

WITH

  • d relative Cartesian coordinates
  • s size of your printed surface
  • r size of your “touch” / recording surface (ie r_x and r_y size of the sensor and r_z its focal length)
  • b position on your printed surface

.. and perform pseudomeric analysis. We have:

 [PIXEL] = (([LENGTH] x [PIXEL]) / ([LENGTH] * [LENGTH])) * [LENGTH] 

Regardless of what you use as a unit for LENGTH , it will be homogenized, i.e. only the proportion is maintained.

Example:

 [PIXEL] = (([MilliM] x [PIXEL]) / ([MilliMeter] * [MilliMeter])) * [MilliMeter] = (([Meter/1000] x [PIXEL]) / ([Meter/1000] * [Meter/1000])) * [Meter/1000] = 1000 * 1000 / 1000 /1000 * (([Meter] x [PIXEL]) / ([Meter] * [Meter])) * [Meter] = (([Meter] x [PIXEL]) / ([Meter] * [Meter])) * [Meter] 

Return to my explanations in another topic:

projection.jpg

If we use these notations for the expression b_x :

 b_x = (d_x * s_x) / (d_z * r_x) * r_z = (d_x * w) / (d_z * 2 * f * tan(α)) * f = (d_x * w) / (d_z * 2 * tan(α)) // with w in px 

You use (d_x, d_y, d_z) = (X,Y,Z) or (d_x, d_y, d_z) = (1000*X,1000*Y,1000*Z) , the coefficient d_x / d_z will not change.


Now for the reasons underlying your problem, you should perhaps check to see if you are correctly applying the correct device to your camera’s position / distance to the scene. Also check your α or focal length block, depending on which one you are using.

If you think that a later proposal is most likely. It is easy to forget to also apply the right block to the characteristics of your camera.

+3
source

Source: https://habr.com/ru/post/1481481/


All Articles