Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

https://docs.opencv.org/master/javadoc/org/opencv/tracking/TrackerKCF.html

https://docs.opencv.org/master/javadoc/org/opencv/tracking/TrackerKCF.html

indeed, there are no java samples, but something like this should get you started:

Tracker tracker = TrackerKCF.create();

// later:
Rect2d roi = new Rect2d(11,12,100,100);
tracker.init(image, roi);

// then:
boolean ok = tracker.update(image, roi);
// if it returns false (object lost), you have to create a new Tracker, with a new ROI

https://docs.opencv.org/master/javadoc/org/opencv/tracking/TrackerKCF.html

indeed, there are no java samples, but something like this should get you started:

import org.opencv.tracking.*;

Tracker tracker = TrackerKCF.create();

// later:
Rect2d roi = new Rect2d(11,12,100,100);
tracker.init(image, roi);

// then:
boolean ok = tracker.update(image, roi);
// if it returns false (object lost), you have to create a new Tracker, with a new ROI

https://docs.opencv.org/master/javadoc/org/opencv/tracking/TrackerKCF.html

indeed, there are no java samples, but something like this should get you started:

import org.opencv.tracking.*;

Tracker tracker = TrackerKCF.create();

// later:
then:
Rect2d roi = new Rect2d(11,12,100,100);
tracker.init(image, roi);

// then:
later:
boolean ok = tracker.update(image, roi);
// if it returns false (object lost), you have to create a new Tracker, with a new ROI