Code Monkey home page Code Monkey logo

Comments (7)

nkolot avatar nkolot commented on August 10, 2024

If you look at how we are computing the orthographic projection:

def orthographic_projection(X, camera):
    """Perform orthographic projection of 3D points X using the camera parameters
    Args:
        X: size = [B, N, 3]
        camera: size = [B, 3]
    Returns:
        Projected 2D points -- size = [B, N, 2]
    """ 
    camera = camera.view(-1, 1, 3)
    X_trans = X[:, :, :2] + camera[:, :, 1:]
    shape = X_trans.shape
    X_2d = (camera[:, :, 0] * X_trans.view(shape[0], -1)).view(shape)
    return X_2d

You can see that the first coefficient in the camera is the scaling factor whereas the second and third the translation in the x and y direction. So more formally, the transformation we are doing is

[X,Y,Z] -> camera[0] * [X+camera[1], Y+camera[2]]

I hope this helps

from graphcmr.

vladsterz avatar vladsterz commented on August 10, 2024

Thanks for the fast reply.
This in fact helps alot.

from graphcmr.

vladsterz avatar vladsterz commented on August 10, 2024

Hello, I can't figure how to use the predicted camera parameters in order to project the predicted points of the model onto the image.

Actually I want to make my intention clear. Given this camera parameters and the predicted SMPL model, is it possible for me to project every point of the mesh to the image? How is it done?
As I understand, this is handled by OpenDR.
Thanks in advance.

from graphcmr.

nkolot avatar nkolot commented on August 10, 2024

The orthographic projection function that I mentioned above projects the mesh in the normalized image plane. If you want to do the projection in pixel coordinates, you have to convert the projected coordinates from [-1,1] to [0,224] by a simple translation and scaling.

You can also do the perspective projection from scratch as K * [R,t] * [X,Y,Z] as we show in demo.py. Assuming a fixed focal length, first we get the camera translation

camera_translation = torch.stack([pred_camera[:,1], pred_camera[:,2], 2*FOCAL_LENGTH/(224 * pred_camera[:,0] +1e-9)],dim=-1)

This is t in the above projection equation. R will be the identity matrix and K will be

        FOCAL_LENGTH                0                  224/2
K =          0                 FOCAL_LENGTH.           224/2
             0                      0                    1

from graphcmr.

vladsterz avatar vladsterz commented on August 10, 2024

Thanks once again for the helpful response. Closing it, for now...

from graphcmr.

RohanChacko avatar RohanChacko commented on August 10, 2024

Hi,
Can you tell me how you arrived at the tz term in the translation expression
camera_translation = torch.stack([pred_camera[:,1], pred_camera[:,2], 2*FOCAL_LENGTH/(224 * pred_camera[:,0] +1e-9)],dim=-1)? It would be helpful if you could explain the reasoning.

from graphcmr.

Ironbrotherstyle avatar Ironbrotherstyle commented on August 10, 2024

Same question. If you have any mathematical solution, please let me know, thank you.

from graphcmr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.