1
0
forked from HQU-gxy/CVTH3PE

feat: Enhance play notebook and camera module with new functionalities

- Updated play notebook with additional imports and new functions for point triangulation and undistortion.
- Introduced `triangulate_one_point_from_multiple_views_linear` and `triangulate_points_from_multiple_views_linear` for batch triangulation of points.
- Added `triangle_from_cluster` function to facilitate triangulation from detection clusters.
- Enhanced `CameraParams` and `Detection` dataclasses with a projection matrix property for improved usability.
- Cleaned up imports and execution counts in the notebook for better organization.
This commit is contained in:
2025-04-17 11:48:53 +08:00
parent 3cc93e5eae
commit 40f3150417
3 changed files with 308 additions and 65 deletions

View File

@ -1,7 +1,4 @@
{ {
"python.analysis.typeCheckingMode": "basic", "python.analysis.typeCheckingMode": "basic",
"python.analysis.autoImportCompletions": true, "python.analysis.autoImportCompletions": true,
"cSpell.words": [
"triu"
]
} }

View File

@ -13,7 +13,7 @@ CameraID: TypeAlias = str # pylint: disable=invalid-name
@jaxtyped(typechecker=beartype) @jaxtyped(typechecker=beartype)
@dataclass @dataclass(frozen=True)
class CameraParams: class CameraParams:
""" """
Camera parameters: intrinsic matrix, extrinsic matrix, and distortion coefficients Camera parameters: intrinsic matrix, extrinsic matrix, and distortion coefficients
@ -42,9 +42,23 @@ class CameraParams:
The size of image plane (width, height) The size of image plane (width, height)
""" """
@property
def projection_matrix(self) -> Num[Array, "3 4"]:
"""
Returns the 3x4 projection matrix K @ [R|t].
The result is cached on first access. (lazy evaluation)
"""
pm = getattr(self, "_proj", None)
if pm is None:
pm = self.K @ self.Rt[:3, :]
# object.__setattr__ bypasses the frozendataclass blocker
object.__setattr__(self, "_proj", pm)
return pm
@jaxtyped(typechecker=beartype) @jaxtyped(typechecker=beartype)
@dataclass @dataclass(frozen=True)
class Camera: class Camera:
""" """
a description of a camera a description of a camera
@ -61,7 +75,7 @@ class Camera:
@jaxtyped(typechecker=beartype) @jaxtyped(typechecker=beartype)
@dataclass @dataclass(frozen=True)
class Detection: class Detection:
""" """
One detection from a camera One detection from a camera

File diff suppressed because one or more lines are too long