MIL tracking
Learn an online appearance classifier from bags of nearby positive and negative samples.
The previous position is a starting estimate, not the new target location.
Sample patches around the current target.
The illustrative response map peaks near the new position. Ambiguous or occluded targets can produce weak or competing peaks.
Choose the best-scoring patch in the next search area.
Choose the best-scoring patch in the next search area.
Illustrative example. The stages explain the method; they are not a live OpenCV execution.
Try it on an image
Experiment at pixel level
Track an input rectangle into the second image with MIL.
The engine loads on your first run. Your images stay in this browser.
Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.
Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Select a pixel
Select a pixel
When to use it
Track a user-selected object when initialization is approximate and online adaptation is useful.
How it works
- 01Sample patches around the current target.
- 02Update a multiple-instance learning classifier.
- 03Choose the best-scoring patch in the next search area.
candidate patches → online classifier → selected location
What to tune
Sampling radii and candidate counts affect the search region and update cost.
Where it breaks down
Appearance updates can reinforce drift. Occlusion and abrupt displacement remain difficult.
TypeScript API
Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.
All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.
Related methods
Lucas-Kanade optical flow
Follow selected points by finding the small displacement that best aligns each local patch.
Farneback dense optical flow
Estimate a displacement vector at every pixel using local polynomial approximations.
DIS dense optical flow
Combine fast patch alignment with spatial propagation and dense refinement.
Dual TV-L1 optical flow
Estimate flow with a robust data term and a total-variation smoothness penalty.