Code Monkey home page Code Monkey logo

Comments (8)

filipetrocadoferreira avatar filipetrocadoferreira commented on July 24, 2024 1

AH! I think the problem was related with the issue #78
Doing

ndc_points [:,1] *= -1

solved

Thanks for the help! And congratulations for this amazing work.

from pytorch3d.

nikhilaravi avatar nikhilaravi commented on July 24, 2024

@filipetrocadoferreira Do you mean for each pixel in the rendered image you want to know the position of the vertices?

from pytorch3d.

filipetrocadoferreira avatar filipetrocadoferreira commented on July 24, 2024

Basically, is applying the same transformations as the render to the 3D vertex and get their 2D location in the image.

from pytorch3d.

filipetrocadoferreira avatar filipetrocadoferreira commented on July 24, 2024

using cameras.transform_points() i get the points in 'screen' coordinate system, but to go from this to 2D pixel coordinates I'm having a bit of a trouble

from pytorch3d.

nikhilaravi avatar nikhilaravi commented on July 24, 2024

By 2D pixel coordinates do you mean NDC coordinates in the range [-1, 1] or coordinates in the range x = [0, W], y = [0, H] where the image is of size (H, W)?

If you have a code snippet you can provide of what you are trying to achieve that would also be helpful.

from pytorch3d.

filipetrocadoferreira avatar filipetrocadoferreira commented on July 24, 2024

range x = [0, W], y = [0, H] where the image is of size (H, W)

This one.
I'm having trouble to go from NDC to image coordinates.

from pytorch3d.

nikhilaravi avatar nikhilaravi commented on July 24, 2024

Ok so the output of cameras.transform_points() will be in NDC coordinates in the range [-1, 1]. If i understand correctly, from this you want to go to pixel coordinates in the range y: [0, H] and x: [0, W].

To do this you just need to do the inverse of this PixToNdc function:

float PixToNdc(int i, int S) {
// NDC x-offset + (i * pixel_width + half_pixel_width)
return -1 + (2 * i + 1.0f) / S;
}

i.e. In C++

float NdcToPix(int i, int S) {
  // where S is the size of the dimension e.g. H or W
  return ((i + 1.0f) * S - 1.0f)/2.0;
}

from pytorch3d.

nikhilaravi avatar nikhilaravi commented on July 24, 2024

@filipetrocadoferreira oh ok makes sense that the rendering problem was affecting your calculations! I will close this issue - please monitor #78 for updates on the rendering fix.

from pytorch3d.

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.