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 projects within the image bounds, has a positive depth value, and its viewing angle is within a certain threshold. The pinhole camera model is often used to describe this projection, where a 3D point P is projected onto the image plane using the camera's intrinsic parameters K and extrinsic parameters R and t.
To determine visibility, the following steps are taken:
- Transform the map point to the camera's coordinate system using Pcamβ=Rβ P+t.
- Check if the point has a positive depth value.
- Project the point onto the image plane using p=Kβ Pcamβ.
- Calculate the image coordinates u=p2βp0ββ and v=p2βp1ββ.
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}- Transform point to camera coords: [0,0,5]
- Depth = 5 > 0 β
- Project: [320, 240] - center of image β
- Within image bounds β β Point is 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'
More from CV: Structure from Motion and SLAM
- Background Knowledge
In feature-based visual SLAM, the world is represented by map points (3D landmarks) and camera poses (position + orientation). At each new frame, the system needs to decide which existing 3D points are potentially visible in the current camera, so it can try to match their descriptors in the image. Checking every map point is too expensive, so we do a visibility test / culling to quickly discard points that cannot be seen.
Geometrically, visibility is determined by the camera projection model. A 3D point in world coordinates is transformed into the camera frame using the camera pose, then projected onto the image plane using intrinsics. For a point to be a useful candidate: it must lie in front of the camera (positive depth), its projection must fall inside the image boundaries, the viewing angle with respect to the pointβs preferred viewing direction must not be too oblique, and its distance should match the scale level at which the pointβs descriptor was created (to keep matching robust and efficient, as in ORB-SLAM).
- Algorithm / Approach
The typical pattern is:
-
For each candidate 3D map point, perform a cheap sequence of geometric tests in increasing cost:
-
Transform to camera coordinates.
-
Check depth sign.
-
Project to pixel coordinates.
-
Check image bounds + possible border margin.
-
Check viewing direction (angle between pointβs normal / mean viewing vector and current viewing ray).
-
Check distance vs. scale range (use pointβs min/max distance based on pyramid levels used when the point was observed).
-
If a point passes all tests, mark it as visible and include it in the candidate set for descriptor matching / tracking.
This is purely geometric; it does not perform any descriptor comparison itself, just filters the set of points to try.
- Step-by-Step Strategy
Assume:
- Camera pose as Tcwβ=[Rcwββ£tcwβ] (world β camera).
- Camera intrinsics K=βfxβ00β0fyβ0βcxβcyβ1ββ.
- Map point has:
- 3D position Xwβ
- A normal/viewing direction n (e.g., average viewing vector from when it was created)
- A min and max distance dminβ,dmaxβ derived from its scale level.
Step-by-step:
- Transform point to camera frame
- Compute Xcβ=RcwβXwβ+tcwβ.
- Let Xcβ=(X,Y,Z).
- Depth (front-of-camera) check
- If Zβ€0, the point is behind the camera β not visible.
- Project onto image plane
- Compute normalized coordinates:
- xnβ=X/Z,ynβ=Y/Z.
- Apply intrinsics:
- u=fxβxnβ+cxβ
- v=fyβynβ+cyβ.
- Image bounds check
- If u or v is outside [0,\text{width})Γ[0,\text{height}) (optionally with a small margin for patch size), cull the point.
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
Editor locked
The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.