Map Point Visibility Test
Implement a visibility test for map points in visual SLAM to determine if a point is visible from a given camera pose. This involves evaluating the point's projection onto the image plane and checking various conditions for visibility.
The concept of visibility is crucial in SLAM as it allows for efficient tracking of map points by only considering those that are currently visible. A map point is considered visible if it has a positive depth value and projects within the image bounds. The pinhole camera model is often used to describe this projection, where a 3D point is projected onto the image plane using the camera's intrinsic parameters and extrinsic parameters and .
To determine visibility, the following steps are taken:
- Transform the map point to the camera's coordinate system using .
- Check if the point has a positive depth value.
- Project the point onto the image plane using .
- Calculate the image coordinates and .
- Check the bounds: and , where image_size is .
Output
Return a dict with:
- 'visible': True only if the depth is positive and is inside the image.
- 'projection': rounded to 1 decimal place, or None if the point is not visible.
- 'depth': the camera-frame depth (the third coordinate of ), rounded to 2 decimal places when positive.
This technique is widely used in autonomous vehicles and robotics for SLAM and 3D reconstruction.
Example
map_point = [0, 0, 5] # 5m in front camera_pose = [identity_R, zero_t] K = [[500,0,320],[0,500,240],[0,0,1]] image_size = (480, 640)
{'visible': True, 'projection': [320, 240], 'depth': 5.0}- Inputs:
map_pointis the world point ;camera_poseholds a rotation and translation ;Khas focal length and principal point ;image_sizeis . - To camera frame: . Its third coordinate is the depth, : the point is in front of the camera.
- Project: , so and .
- Bounds: and — inside the image.
- Output:
{'visible': True, 'projection': [320, 240], 'depth': 5.0}. Notice that a point on the optical axis lands exactly on the principal point; moving it to gives , while sits behind the camera and is not visible.
Constraints
- map_point: 3D point [X, Y, Z]
- camera_pose: [R, t] camera extrinsics
- K: Camera intrinsics
- image_size: (H, W)
- Return: Dict with 'visible', 'projection', 'depth'