1
0
forked from HQU-gxy/CVTH3PE

28 Commits

Author SHA1 Message Date
6cd13064f3 fix: various
- Added the `LeastMeanSquareVelocityFilter` to improve tracking velocity estimation using historical 3D poses.
- Updated the `triangulate_one_point_from_multiple_views_linear` and `triangulate_points_from_multiple_views_linear` functions to enhance documentation and ensure proper handling of input parameters.
- Refined the logic in triangulation functions to ensure correct handling of homogeneous coordinates.
- Improved error handling in the `LastDifferenceVelocityFilter` to assert non-negative time deltas, enhancing robustness.
2025-06-18 10:35:23 +08:00
4bc3fce0b1 feat: Add minimum affinity filter to affinity result grouping
- Introduced a `min_affinity` parameter to the `affinity_result_by_tracking` function, allowing users to specify a threshold for filtering affinity results.
- Updated the logic to skip results with affinities below the specified minimum, enhancing the relevance of grouped detections.
- Improved function documentation to include details about the new parameter and its purpose.
2025-05-03 17:29:50 +08:00
1f8d70803f feat: Implement time-weighted triangulation for enhanced 3D point reconstruction
- Added two new functions: `triangulate_one_point_from_multiple_views_linear_time_weighted` and `triangulate_points_from_multiple_views_linear_time_weighted` to perform triangulation with time-based weighting, improving accuracy in 3D point estimation.
- Introduced a method to group detections by camera while preserving the latest detection, enhancing tracking state management.
- Updated the `update_tracking` function to incorporate time-weighted triangulation, allowing for more robust updates to tracking states based on new detections.
- Refactored the `TrackingState` to utilize a mapping of historical detections by camera, improving data organization and access.
2025-05-03 17:17:47 +08:00
c31cc4e7bf refactor: Enhance tracking state management and velocity filter integration
- Introduced `TrackingState` to encapsulate the state of tracking, improving data organization and immutability.
- Updated the `Tracking` class to utilize `TrackingState`, enhancing clarity in state management.
- Refactored methods to access keypoints and timestamps through the new state structure, ensuring consistency across the codebase.
- Added a `DummyVelocityFilter` for cases where no velocity estimation is needed, improving flexibility in tracking implementations.
- Cleaned up imports and improved type hints for better code organization.
2025-05-02 12:44:58 +08:00
c78850855c feat: Introduce LastDifferenceVelocityFilter for improved tracking velocity estimation
- Added a new `LastDifferenceVelocityFilter` class to estimate tracking velocities based on the last observed keypoints, enhancing the tracking capabilities.
- Updated the `Tracking` class to utilize the new velocity filter, allowing for more accurate predictions of keypoints over time.
- Refactored the `predict` method to support various input types (float, timedelta, datetime) for better flexibility in time handling.
- Improved timestamp handling in the `perpendicular_distance_camera_2d_points_to_tracking_raycasting` function to ensure adherence to minimum delta time constraints.
- Cleaned up imports and type hints for better organization and clarity across the codebase.
2025-05-02 11:11:32 +08:00
072bf1c46f feat: Integrate pyrsistent for enhanced tracking state management
- Added `pyrsistent` as a dependency to manage historical detections in the `Tracking` class, improving data integrity and immutability.
- Updated the `GlobalTrackingState` to include historical detections using `PVector`, facilitating better tracking of past detections.
- Introduced a new `update_tracking` function to handle timestamp updates for tracking objects, enhancing the tracking logic.
- Refactored imports and type hints for improved organization and clarity across the codebase.
2025-04-30 10:04:39 +08:00
cea21dc434 Revert "refactor: Optimize affinity matrix calculation with parallel processing"
This reverts commit e79e899b87.
2025-04-29 16:22:53 +08:00
e79e899b87 refactor: Optimize affinity matrix calculation with parallel processing
- Introduced parallel processing using `ThreadPoolExecutor` to enhance the performance of the `calculate_affinity_matrix` function, allowing simultaneous processing of multiple cameras.
- Added a new helper function `_single_camera_job` to encapsulate the logic for processing individual camera detections, improving code organization and readability.
- Updated the function signature to include an optional `max_workers` parameter for controlling the number of threads used in parallel execution.
- Enhanced documentation to clarify the purpose and parameters of the new parallel processing implementation.
2025-04-29 16:14:07 +08:00
29ca66ad47 refactor: Update affinity matrix calculation and dependencies
- Replaced the `linear_sum_assignment` import from `scipy.optimize` with `hungarian_algorithm` from `optax` to enhance performance in affinity matrix calculations.
- Introduced a new `AffinityResult` class to encapsulate results of affinity computations, including trackings and detections, improving the structure of the affinity calculation process.
- Removed deprecated functions and debug print statements to streamline the codebase.
- Updated `pyproject.toml` and `uv.lock` to include `optax` as a dependency, ensuring compatibility with the new implementation.
- Refactored imports and type hints for better organization and consistency across the codebase.
2025-04-29 15:45:24 +08:00
ce1d5f3cf7 refactor: Improve timestamp handling in camera affinity matrix calculation
- Replaced direct access to tracking and detection timestamps with a more efficient use of `itertools.chain` to gather timestamps, enhancing readability and performance in `calculate_camera_affinity_matrix_jax`.
- Maintained precision in timestamp calculations to ensure accurate results in affinity computations.
2025-04-29 13:05:52 +08:00
29c8ef3990 fix: fix the timestamp precision error cause the jax version not giving the correct result
Epoch timestamps are ~1.7 × 10⁹; storing them in float32 wipes out
sub‑second detail (resolution ≈ 200 ms).  Keep them in float64 until
after subtraction so we preserve Δt‑on‑the‑order‑of‑milliseconds.

- Introduced a `_DEBUG_CURRENT_TRACKING` variable to track the current indices of tracking and detection during calculations.
- Added a `_global_current_tracking_str` function to format the current tracking state for debugging purposes.
- Enhanced `calculate_distance_2d` and `calculate_tracking_detection_affinity` functions with debug print statements to log intermediate values, improving traceability of calculations.
- Updated `perpendicular_distance_camera_2d_points_to_tracking_raycasting` to accept `delta_t` from the caller while ensuring it adheres to a minimum threshold.
- Refactored timestamp handling in `calculate_camera_affinity_matrix_jax` to maintain precision during calculations.
2025-04-29 12:56:58 +08:00
7dd703edd6 wip 2025-04-29 12:18:19 +08:00
65cc646927 feat: Introduce Tracking class and refactor pose prediction
- Added a new `Tracking` class to encapsulate tracking data, including keypoints and velocity, with a method for predicting 3D poses based on velocity.
- Refactored the pose prediction logic in `calculate_camera_affinity_matrix_jax` to utilize the new `predict` method from the `Tracking` class, enhancing clarity and modularity.
- Introduced an `AffinityResult` class to manage results of affinity computations, including trackings and detections, improving the structure of the affinity calculation process.
- Updated imports and type hints for better organization and consistency across the codebase.
2025-04-29 12:14:08 +08:00
86fcc5f283 feat: Enhance 3D pose prediction and camera affinity calculations
- Introduced a JAX-friendly implementation of `predict_pose_3d` to predict 3D poses based on tracking velocities, improving performance by avoiding Python control flow.
- Updated `calculate_camera_affinity_matrix_jax` to streamline the affinity matrix calculation, incorporating velocity handling for trackings and enhancing clarity in the distance computation.
- Added properties for normalized keypoints in the `Detection` class, allowing for lazy evaluation and improved usability.
- Enhanced documentation throughout to clarify function purposes and parameters.
2025-04-29 12:06:07 +08:00
da4c51d04f feat: Implement AffinityResult class and optimize camera affinity matrix calculation
- Added a new `AffinityResult` class to encapsulate the results of affinity computations, including the affinity matrix, trackings, and their respective indices.
- Introduced a vectorized implementation of `calculate_camera_affinity_matrix_jax` to enhance performance by leveraging JAX's capabilities, replacing the previous double-for-loop approach.
- Updated tests in `test_affinity.py` to include parameterized benchmarks for comparing the performance of the new vectorized method against the naive implementation, ensuring accuracy and efficiency.
2025-04-28 19:08:16 +08:00
487dd4e237 feat: Add hypothesis testing and update dependencies
- Added property-based tests for camera affinity calculations using Hypothesis, enhancing test coverage and reliability.
- Updated `.gitignore` to include `.hypothesis` directory.
- Added `hypothesis` and `pytest` as dependencies in `pyproject.toml` and `uv.lock` for improved testing capabilities.
- Refactored imports in `playground.py` to include `Sequence` and `Mapping` from `beartype.typing`.
- Introduced a new test file `tests/test_affinity.py` for structured testing of affinity calculations.
2025-04-28 18:21:08 +08:00
b3ed20296a revert 2025-04-28 18:01:24 +08:00
7ee4002567 wip 2025-04-28 16:39:23 +08:00
ebcd38eb52 feat: Add camera affinity calculations and iterative processing in playground.py
- Introduced `calculate_camera_affinity_matrix` to compute affinity between trackings and detections for individual cameras, enhancing modularity.
- Added `process_detections_iteratively` to handle detections camera by camera, improving efficiency and scalability.
- Enhanced type hints and documentation for new functions, clarifying parameters and return values.
- Refactored existing affinity calculation logic to integrate new functionalities, ensuring better organization and readability.
2025-04-28 16:11:57 +08:00
a31f609133 chore: unicode 2025-04-27 18:12:09 +08:00
d9aaa96d0a refactor: Enhance type hints and documentation for distance calculation functions in playground.py
- Updated the return type of `perpendicular_distance_point_to_line_two_points` to `Float[Array, ""]` for improved type clarity.
- Added detailed docstrings to `perpendicular_distance_point_to_line_two_points`, specifying arguments and return values for better understanding.
- Streamlined the distance calculation in `perpendicular_distance_camera_2d_points_to_tracking_raycasting` by removing unnecessary type casting, enhancing code readability.
2025-04-27 18:08:45 +08:00
9639bcb794 refactor: Update type hints and streamline distance calculations in playground.py
- Changed the return type of `perpendicular_distance_point_to_line_two_points` to `jnp.floating[Any]` for improved type accuracy.
- Refactored the `perpendicular_distance_camera_2d_points_to_tracking_raycasting` function to store distances in a typed variable, enhancing clarity and type safety.
- Improved the overall readability of the distance calculation logic by returning the computed distances directly.
2025-04-27 18:00:56 +08:00
d4ade248dc feat: Add calculate_affinity_matrix function to streamline affinity calculations
- Introduced a new function `calculate_affinity_matrix` to compute the affinity matrix between trackings and detections, enhancing modularity and clarity.
- Updated the existing affinity calculation logic to utilize the new function, improving code organization and readability.
- Adjusted the image size parameter in the distance calculation to ensure proper type handling.
- Enhanced documentation for the new function, detailing its parameters, return values, and matrix layout for better understanding.
2025-04-27 17:57:12 +08:00
41e0141bde refactor: Update type hints and enhance affinity calculations in playground.py
- Changed function signatures to use `Sequence` instead of `list` for better type flexibility.
- Introduced a new function `calculate_tracking_detection_affinity` to streamline the calculation of affinities between tracking and detection objects.
- Refactored existing affinity calculation logic to improve clarity and performance, leveraging the new affinity function.
- Removed commented-out code to clean up the implementation and enhance readability.
2025-04-27 17:45:31 +08:00
4f48c78cfb fix: Update distance calculation in playground.py to include image size parameter
- Modified the distance calculation function to accept an image size parameter, enhancing accuracy in 2D distance computations.
- Improved the integration of camera parameters into the tracking logic for better performance and reliability.
2025-04-27 17:00:56 +08:00
a4cc34f599 feat: Enhance playground.py with new 3D tracking and affinity calculations
- Added functions for calculating perpendicular distances between predicted 3D tracking points and camera rays, improving 3D tracking accuracy.
- Introduced a new function for calculating 3D affinity scores based on distances and time differences, enhancing the integration of 3D tracking with existing systems.
- Updated existing functions to support new data types and improved documentation for clarity on parameters and return values.
- Refactored affinity calculation logic to utilize JAX for performance optimization in distance computations.
2025-04-27 16:56:49 +08:00
5b5ccbd92b feat: Enhance playground.py with new tracking and affinity calculation functionalities
- Introduced new functions for calculating 2D distances and affinities between detections, improving tracking capabilities.
- Added a `Tracking` dataclass with detailed docstrings for better clarity on its attributes.
- Refactored code to utilize `shallow_copy` for handling detections and improved organization of imports.
- Enhanced the cross-view association logic to accommodate the new functionalities, ensuring better integration with existing tracking systems.
2025-04-27 16:03:05 +08:00
2e63a3f9bf feat: Migrate play notebook to Python script and update dependencies
- Removed the `play.ipynb` notebook and created a new `playground.py` script to enhance code organization and maintainability.
- Updated `pyproject.toml` to include `jupytext` for Jupyter notebook conversion support.
- Added instructions in `README.md` for converting notebooks using Jupytext.
- Enhanced the `uv.lock` file to reflect the new dependency on Jupytext.
2025-04-25 17:25:56 +08:00