MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ track_keypoints() [2/2]

MAYAFLUX_API std::vector< TrackResult > MayaFlux::Kinesis::Vision::track_keypoints ( std::span< const float >  prev_gray,
std::span< const float >  curr_gray,
uint32_t  w,
uint32_t  h,
std::span< const glm::vec2 >  prev_points,
uint32_t  window_radius = 7,
uint32_t  max_iterations = 20,
float  eigen_threshold = 1e-4F,
float  error_threshold = 0.3F 
)

Track keypoints from prev_gray to curr_gray via Lucas-Kanade.

For each input point, solves the Lucas-Kanade optical flow equation within a window_radius x window_radius patch using iterative Newton-Raphson refinement. Iteration stops when the displacement update falls below 0.03 pixels or max_iterations is reached.

A point is marked tracked=false if:

  • The structure tensor within its window is near-singular (min eigenvalue below eigen_threshold)
  • The tracked position moves outside the image boundary
  • The residual error after convergence exceeds error_threshold

prev_points and the returned vector have the same length and order. Callers should discard points where tracked == false before passing to subsequent frames.

Parameters
prev_grayPrevious frame, single-channel float, size w * h.
curr_grayCurrent frame, single-channel float, size w * h.
wImage width in pixels.
hImage height in pixels.
prev_pointsPoints to track in normalised [0, 1] coordinates.
window_radiusHalf-size of the tracking patch in pixels.
max_iterationsMaximum Newton-Raphson iterations per point.
eigen_thresholdMinimum eigenvalue for structure tensor validity.
error_thresholdMaximum residual error to accept a track.
Returns
TrackResult per input point, same order.

Definition at line 171 of file OpticalFlow.cpp.

180{
181 auto grad = sobel(prev_gray, w, h);
182 return track_keypoints(prev_gray, curr_gray,
183 grad.dx, grad.dy,
184 w, h, prev_points,
185 window_radius, max_iterations,
186 eigen_threshold, error_threshold);
187}
uint32_t h
Definition InkPress.cpp:28
void sobel(std::span< const float > gray, std::span< float > dx, std::span< float > dy, std::span< float > tmp, uint32_t w, uint32_t h)
Sobel gradient writing dx and dy into caller-supplied buffers.
Definition Gradient.cpp:66
std::vector< TrackResult > track_keypoints(std::span< const float > prev_gray, std::span< const float > curr_gray, uint32_t w, uint32_t h, std::span< const glm::vec2 > prev_points, uint32_t window_radius, uint32_t max_iterations, float eigen_threshold, float error_threshold)
Track keypoints from prev_gray to curr_gray via Lucas-Kanade.

References h, sobel(), and track_keypoints().

Referenced by MayaFlux::Kinesis::Vision::VisionExecutor::run(), and track_keypoints().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: