kornia.tracking¶
- class kornia.tracking.HomographyTracker(initial_matcher=None, fast_matcher=None, ransac=None, minimum_inliers_num=30)[source]¶
Perform local-feature-based tracking of the target planar object in the sequence of the frames.
- Parameters:
initial_matcher (
Optional[LocalFeature], optional) – image matching module, e.g.LocalFeatureMatcherorLoFTR. Default:GFTTAffNetHardNet.fast_matcher (
Optional[Module], optional) – fast image matching module, e.g.LocalFeatureMatcherorLoFTR. Default:DescriptorMatcher.ransac (
Optional[Module], optional) – homography estimation module. Default:RANSAC.minimum_inliers_num (
int, optional) – threshold for number inliers for matching to be successful. Default:30
- property device: device¶
Return the device used by the current target image tensor.
- Returns:
The
torch.devicewhereself.targetis allocated.
- property dtype: dtype¶
Return the data type used by the current target image tensor.
- Returns:
The
torch.dtypeofself.target.
- match_initial(x)[source]¶
Estimate a homography from the initial target frame to frame
x.- Parameters:
x (
Tensor) – Current frame tensor to match against the stored target image.- Return type:
- Returns:
A tuple
(H, is_valid)whereHis the estimated homography matrix andis_validindicates whether enough inliers were found.
The method updates keypoint counters, inlier statistics, and stores the estimated homography as
previous_homographyon success.
- reset_tracking()[source]¶
Reset temporal tracking state from previously processed frames.
- Return type:
- Returns:
None.
- set_target(target)[source]¶
Register a new target image and refresh cached matcher features.
- Parameters:
target (
Tensor) – Reference target image tensor used for subsequent matching.- Return type:
- Returns:
None.
The method clears previously cached features and precomputes new feature representations when the configured matchers expose an
extract_featuresmethod.
- track_next_frame(x)[source]¶
Track the target in frame
xusing the previous homography prior.- Parameters:
x (
Tensor) – Current frame tensor to align with the target image.- Return type:
- Returns:
A tuple
(H, is_valid)whereHis the updated homography andis_validindicates whether tracking remained reliable.
The frame is first prewarped by the inverse of the previous homography, then matched with
fast_matcherand verified using RANSAC.