-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PerspectiveCameras issue with PulsarPointsRenderer #1352
Comments
Quick update: I had a look at https://github.com/facebookresearch/pytorch3d/blob/main/pytorch3d/renderer/points/pulsar/unified.py, and it seems that the
Attached (cow.zip) is a .ply point cloud file of the pytorch3d cow mesh, and below is a code to reproduce a simple example, with the
|
Hi @maximeraafat ! Thanks for reaching out and sorry for the delay in responding to this issue! Indeed, the |
Hi @classner, thank you for your helpful reply! Unfortunately, your suggestion doesn't fully solve the issue, but I think this is the right direction. I heuristically noticed that changing from (or to) NDC coordinates doesn't affect Pulsar rendering at all (or at least not in the cow scenario shared in the code above). However, changing principle point seems to help. When I set the center to I realised that the issue now is probably the focal length, so I first changed it to Alright, so we got already the scale right, but two issues are remaining : the orientation and the center. After some trials, I tried to play a bit with the rotation parameters, but I don't think this is the right way to go... Finally, after lots of experiments, I found that setting the center as Again as a reference, below you can find the default point render we aim to obtain: Any additional comments or suggestions are very welcome. In the meanwhile I will continue testing different scenarios, perhaps also with other perspective cameras, to see whether different settings might not encounter such issues. |
Hi @maximeraafat , Glad we tracked down the reason (I opened a bug report earlier this year here btw.: #1276 )! Two things:
|
Hi @classner, thanks for your feedback again! As per your suggestion, I dived deeper into the unified interface and did investigate the values passed to the Pulsar renderer via pdb. It turned out that my previous experiments were only getting better by coincidence, and slightly changing focal length or principle points again renders two completely different things for the default point renderer and Pulsar. I noticed that Pulsar actually doesn't consider cameras in screen space, and always assumes cameras in NDC space. I therefore tested a very simple camera in NDC space, to see whether the default point renderer and Pulsar are capable of rendering the same scene there, but even this fails... My example is the following (everything is the same as above, except for the camera, and a radius of 0.001 passed to
Even by flipping the render along the first axis and adapting the principle points manually, the focal length still does not seem to be right, and manually adjusting it for every camera for the closest match possible is obviously not the right way to go. If you have any further feedback or suggestions, every idea is welcome! 🙂 |
This commit addresses several braking changes to PyTorch3d camera conventions that made the unified system unusable at the moment (see facebookresearch#1352 and facebookresearch#1276). This commit fixes all these problems and tests using the test case from facebookresearch#1352. The results are equivalent for `FoVOrthographicCameras`, `OrthographicCameras`, `FoVPerspectiveCameras` and `PerspectiveCameras`. We used to have a test case for the unified interface for Pulsar that compared the rendering results with some 'ground truth' images. This test seems to have been removed, thus leading to these breaking changes remaining undiscovered for a long time. Would be great if we could revive that test case!
Hi @maximeraafat , I just looked at this with #1369 . You can directly clone from there and everything works as expected for all cameras and in NDC or non-NDC format. This was due to changes in the PyTorch3D cameras that were not propagated to the unified interface. Test case (uncomment different camera types):
@bottler , @gkioxari : would be great if we could introduce another test case for the unified interface. I used to have one in the past (comparing results with ground truth expected results, just placing some points on a sphere; that made debugging of point size quite easy), but it must have been removed at some point. Happy to have fixed it this time, but it would be great if breaking changes could be detected by such a test case and then be fixed by the change author. Otherwise there's always a bunch of reverse engineering... |
@maximeraafat side note: in case you are experimenting for benchmarking using the direct interface saves a bunch of conversions from the unified interface and is significantly faster. If you are looking at a fixed test case it's easy to just grab the parameters for Pulsar from the unified interface here:
|
Hi @classner, thank you so much for the fix! I didn't get to experiment yet with the updated unified interface, but if I encounter more issues I will let you know. Also, thank you for the very helpful tip on using the direct interface instead of the unified interface, I will definitely make use of it! |
Actually I just pulled the pull request #1369 and installed from source, the code above works as expected. Is the the pull request expected to the merged into future releases? |
The pull request isn't quite right - EG is asymmetrical with respect to horizontal and vertical, and breaks tests in test_camera_pixels which are actually correct. It needs fixing from someone before it can be merged. |
Hi, thank you for this amazing work!
I've been running into some issues with pulsar rendering, and would appreciate your help. I am loading some parameters from calibrated cameras into a
PerspectiveCameras
object, and render the scene with both the defaultPointsRenderer
and thePulsarPointsRenderer
classes. The default renderer works perfectly and the image is calibrated as expected, but I fail to do the same with pulsar, and my rendered scene is empty.A previous issue seem to address this problem (#772), but doesn't explain how to handle the focal length and principal points in the absence of
K
. I've tried to convert them into a 4x4 intrinsics matrixK
(and then follow the advise in #772), but this didn't resolve the issue.In another attend, I used the
pytorch3d.utils.pulsar_from_cameras_projection
function as suggested in #590 and #734, but there doesn't seem to be a direct way to provide the converted parameters to an object of thePulsarPointsRenderer
class. The conversion function outputs translation, rotation, focal length, sensor width, and principal point parameters in pulsar convention, but thePulsarPointsRenderer
forward doesn't use a sensor width as input. Even when omitting sensor width in the forward, pulsar still doesn't render the scene from the desired view. Could you please explain how to use the mentioned camera parameters with pulsar?Below is a code example in which I first initialise the default point and pulsar renders, then render the scene with the default renderer (no problem here), and finally experiment with different scenarios for pulsar, which all resulted in a fully black and empty render.
Thank you in advance!
The text was updated successfully, but these errors were encountered: