Skip to content

Conversation

@horizon-blue
Copy link
Contributor

@horizon-blue horizon-blue commented Nov 25, 2025

(Part of MET-48)

Summary of Changes

This PR complete the camera Intrinsics and defines two functions for it:

  • get_ray_direction: given a pixel coordinate (px, py), returns the direction of the ray in camera frame
  • get_ray_directions: returns a 2D array of all ray directions in the camera frame. If a range is specified, then this method only compute a subset of the rays.

Depends on how we implement the kernel at the end, we may not need both functions, but let's still have them here now just in case...

Test Plans

On Python side, you can find a basic correctness testing in test_camera.py, which checks the value of our Intrinsics::get_ray_direction against the ground truth fucntion refactored from run_fmb.py

Due to the complexity of binding Array2D<Vec3D, device> to Python, I'm leaving the testing of the batched get_ray_directions to C++ side, where test_camera.cu only performs a basic sanity check to ensure that the adjacent rays are pointing toward different direction (and of course, that the function runs without error).

As always, you can run the tests with

pixi run test

Copy link
Contributor Author

MET-48 Implement `Camera`

maybe with the ability to create Rays?

@horizon-blue horizon-blue marked this pull request as ready for review November 25, 2025 07:27

TEST(GpuConfidenceTest, ConfidenceMultipleValuesGPU_AllTypes) {
using test_float = float;
constexpr float rtol = 1e-6F;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My compiler has been complaining about this unused variable for a while lol

Comment on lines -12 to -13
float near;
float far;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables are not used in the current implementation, though we can always add them back later if needed

@horizon-blue horizon-blue force-pushed the xiaoyan/array2d-with-device-type branch from 93536ee to 1e3da46 Compare November 25, 2025 20:37
@horizon-blue horizon-blue changed the base branch from xiaoyan/array2d-with-device-type to master November 25, 2025 20:57
@horizon-blue horizon-blue force-pushed the xiaoyan/camera-intrinsics branch from 1e77c73 to b58ca50 Compare November 25, 2025 20:57
return norms


def get_camera_rays(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I see that you took their code and made it into a GT function here

.def_ro("cx", &Intrinsics::cx)
.def_ro("cy", &Intrinsics::cy)
.def("get_ray_direction", &Intrinsics::get_ray_direction,
"Get the direction of the ray going through pixel (px, py) in camera frame",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this (px, py) convention? is this the same as (i,j)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it does not matter, as long as we know that camera looks at bottom left as origin and Y is upwards while X is rightwards, it should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, (px, py) is essentially the 2D coordinate in the pixel space

Copy link
Contributor

@arijit-dasgupta arijit-dasgupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! this has become a lot simpler now that we're not storing the origin point.

@horizon-blue horizon-blue force-pushed the xiaoyan/camera-intrinsics branch from b58ca50 to d26d491 Compare November 30, 2025 01:08
@horizon-blue
Copy link
Contributor Author

Update: Rebased after resolving conflicts. I'm going to merge this PR as-is once the CI passes to keep us moving forward and will work on pixel coordinate iterator & the other improvements in followups.

@horizon-blue horizon-blue merged commit 1bb706c into master Nov 30, 2025
1 check passed
@horizon-blue horizon-blue deleted the xiaoyan/camera-intrinsics branch November 30, 2025 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants