public class TLD extends Object
processImage(FImage)
function must be called with suceutive
frames in which objects are: - Tracked using MedianFlowTracker
-
...and if not tracked correctly detected using the DetectorCascade
. -
... if tracked or detected correctly, but the object is different enough, it
is learnt using DetectorCascade
!Modifier and Type | Field and Description |
---|---|
boolean |
alternating
Whether some frames are skipped
|
Rectangle |
currBB
The current bounding box
|
float |
currConf
The confidence of the current bounding box.
|
FImage |
currImg
The current frame, where #currBB will be detected
|
DetectorCascade |
detectorCascade
The detector
|
boolean |
detectorEnabled
Whether the
DetectorCascade is enabled |
boolean |
learningEnabled
Whether previously unseen frames are learnt from
|
MedianFlowTracker |
medianFlowTracker
The tracker
|
Rectangle |
prevBB
the previous bounding box
|
FImage |
prevImg
The previous frame, where #prevBB was detected
|
boolean |
trackerEnabled
Whether the
MedianFlowTracker is enabled |
Constructor and Description |
---|
TLD(int width,
int height) |
Modifier and Type | Method and Description |
---|---|
void |
fuseHypotheses()
The bounding box is retrieved from the tracker and detector as well as
the number of clusters detected by the detector
Clustering step. |
void |
initialLearning()
The initial learning is done using the input bounding box.
|
boolean |
isLearning() |
void |
learn()
If the detection results are good and
fuseHypotheses() believes
that the area was tracked to, but was not detected well then there is
potential that the classifiers should be updated with the bounding box. |
void |
processImage(FImage img)
An attempt is made to track the object from the previous frame.
|
void |
release()
Stop tracking whatever is currently being tracked
|
void |
selectObject(FImage img,
Rectangle bb)
Set the current object being tracked.
|
public boolean trackerEnabled
MedianFlowTracker
is enabledpublic boolean detectorEnabled
DetectorCascade
is enabledpublic boolean learningEnabled
public boolean alternating
public DetectorCascade detectorCascade
public MedianFlowTracker medianFlowTracker
public float currConf
MedianFlowTracker.trackerBB
is extracted from
the currImg
and confidence is gauged using NNClassifier
public TLD(int width, int height)
width
- height
- public void release()
public void selectObject(FImage img, Rectangle bb) throws Exception
DetectorCascade.init()
. The initialLearning()
is
calledimg
- bb
- Exception
public void processImage(FImage img)
DetectorCascade
instance is used regardless to detect the object.
The fuseHypotheses()
is then used to combine the estimate of the
tracker and detector together. Finally, using the detectorCascade the
learn function is called and the classifier is improvedimg
- public void fuseHypotheses()
Clustering
step.
If exactly one cluster exists in Clustering
(i.e. the detector is
very sure) the detector confidence is included. If the tracker was able
to keep track of the bounding box (i.e. trackerBB is not null) then the
tracker confidence is combined.
if the detector is more confident than the tracker and their overlap is
very small, the detectors BB is used. Otherwise the trackers BB and
confidence is used. If the trackerBB is used the tracking is valid only
if the tracking was invalid last time and the confidence is above
NNClassifier.thetaTP
or if the tracking was valid last time a
smaller threshold of NNClassifier.thetaFP
is used.
TODO: Maybe a better combination of the two bounding boxes from the
detector and tracker would be better?public void initialLearning()
VarianceFilter
is told its
VarianceFilter.minVar
by finding the variance of the selected
patch.
Next all patches in DetectorCascade
with a large offset (over
0.6f) with the selected box are used as positive examples while all
windows with an overlap of less tha 0.2f and a variance greater than the
minimum variance (i.e. they pass the variance check but yet do not
overlap) are used as negative examples. The EnsembleClassifier
is
trained on the positive examples for EnsembleClassifier
.
Finally, the negative and positive examples are all fed to the
NNClassifier
using the NNClassifier
.
The usage of these 3 classifiers is explained in more detail in
DetectorCascade.detect(FImage)
. The NNClassifier
is also
used to calculate confidences in fuseHypotheses()
public void learn()
fuseHypotheses()
believes
that the area was tracked to, but was not detected well then there is
potential that the classifiers should be updated with the bounding box.
The bounding box is used to extract highly overlapping windows as
positive examples, and two kinds of negative examples are collected if
they overlap less than 0.2f. For the ensemble classifier, negative
examples are collected if the results of the DetectorCascade
public boolean isLearning()