Radius pixels when the sphere is projected into 2D Image.

Asked 1 years ago, Updated 1 years ago, 109 views

I understand that 3D spheres are projected in circles in 2D Image. Of course, it is not a complete circle, but I understand that it gets closer to the circle depending on the performance of the camera.

So I thought I could get the Z coordinates relative to the camera with the radius pixel of the circle, so I was checking, but the results I actually did were replaced by the theory, so I'm asking you a question.

I made Sphere and Camera in iOS Scenecit and tested it.

Reference is made to stack overflow for the formula.

// Z  : Camera Coordinate Z Distance
// Based on ClipSpace, maybe Pixel = clip radius * Resolution.y
approximate radius on screen[CLIP SPACE] = world radius * cot(fov / 2) / Z

However, there is a phenomenon that the calculated pixel differs from the pixel of the circle in the actual image.

The calculated pixels are about 671 pixels, and the actual image shows a circular radius pixel of about 712 pixels. In this situation, I calculated the Z value thinking it was 0.3, but I don't know if it was wrong or if I was missing something.

In the eyes of camera math experts, is there anything I missed?

I even used the function, which calculates which 2d point the 3d point is attached to the image, to determine the difference between the two pixels calculated above the pixel number. However, it is very questionable that there is a difference in the number of pixels in the circle in the actual image.

camera math

2022-09-21 10:03

1 Answers

First of all, having fov is perspective projection I think we need a viewport, near z value, or local length to calculate accurately, but... Let's try to guess the default value and catch the error.

The currently obtained 671 is not the radius of the phase formed in the viewport.

In the picture in the answer to the stack overflow that you linked,

The length of the part corresponding to the red line (corresponding to the radius of the sphere) appears to have been obtained.

(Not exactly, but it looks like it.))

Assuming that the image is actually formed on a plane with z of zero,

You need to find the length of the statue on the plane as shown in the figure above.

I can't get it from the beginning because I don't know all the factors of the camera and viewport, and you told me something vaguely

671 You can verify it assuming that the value obtained the length of the first figure.

For convenience of calculation, I'll mark it like the picture below.

The length of the radius of the phase is obtained by the resemblance of a triangle and the great Pythagorean theorem and trigonometric functions.

OC = 0.3
OH = 0.1
CH = (0.3 ^ 2 - 0.1 ^ 2) ^ 0.5 = 0.282842712

angle = OCH
cos(angle) = CH / OC = 0.94280904

by likeness

OH / OR' = cos(angle)
OR' = 0.1 / 0.94280904 = 0.106066017

You must obtain the value at the point in the 0.106066017 position in the world coordinate system.

To apply the functions of the Scenekit mentioned above, You have to put (0, 0.106066017, 0) instead of (0, 0.1, 0).

Anyway, if you keep calculating for verification,

You can apply a proportional expression to the values above.

If the radius value in the 0.1 position is 671, what is the radius value X in the 0.106066017 position?

0.1: 671 = 0.106066017: X
X = 671 * 0.106066017 / 0.1 = 711.70297407 = About 712

Approximately 712. This is the calculated value and it almost fits the radius of the circle you see.

It was confirmed that you obtained it by specifying the wrong value.

You can think about the two-dimensional image that is formed by projection, and the shadow that is formed on objects in the three-dimensional world. It would be easier to understand if you imagine how light from a point source would make a shadow of a sphere.


2022-09-21 10:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.