Commit ac5ffe31 authored by Kirill Kornyakov's avatar Kirill Kornyakov

Merge pull request #109 from lenlen/tld_test_and_doc_update

Tracking API doc update and test-perftest TLD tracker
parents d0c3a2ee 775aecc0
@startuml
package "Tracker package" #DDDDDD {
class Algorithm {
}
class Tracker{
Ptr<TrackerFeatureSet> featureSet;
Ptr<TrackerSampler> sampler;
Ptr<TrackerModel> model;
---
+static Ptr<Tracker> create(const string& trackerType);
+bool init(const Mat& image, const Rect& boundingBox);
+bool update(const Mat& image, Rect& boundingBox);
}
class Tracker
note right: Tracker is the general interface for each specialized trackers
class TrackerMIL{
+Params
---
TrackerMIL(TrackerMIL::Params parameters);
+bool init(const Mat& image, const Rect& boundingBox);
+bool update(const Mat& image, Rect& boundingBox);
}
class TrackerBoosting{
+Params
---
TrackerBoosting(TrackerBoosting::Params parameters);
+bool init(const Mat& image, const Rect& boundingBox);
+bool update(const Mat& image, Rect& boundingBox);
}
Algorithm <|-- Tracker : virtual inheritance
Tracker <|-- TrackerMIL
Tracker <|-- TrackerBoosting
note "Single instance of the Tracker" as N1
TrackerBoosting .. N1
TrackerMIL .. N1
}
@enduml
@startuml
package "Tracker" #DDDDDD {
}
package "TrackerFeature" #DDDDDD {
}
package "TrackerSampler" #DDDDDD {
}
package "TrackerModel" #DDDDDD {
}
Tracker -> TrackerModel: create
Tracker -> TrackerSampler: create
Tracker -> TrackerFeature: create
@enduml
\ No newline at end of file
...@@ -21,49 +21,25 @@ The TrackerSampler and the TrackerFeatureSet are the visual representation of th ...@@ -21,49 +21,25 @@ The TrackerSampler and the TrackerFeatureSet are the visual representation of th
A recent benchmark between these algorithms can be found in [OOT]_. A recent benchmark between these algorithms can be found in [OOT]_.
UML design: .. only:: plantuml
-----------
**General diagram** UML design:
-----------
.. image:: pics/package.png .. toctree::
:width: 50%
:alt: General diagram
:align: center
**Tracker diagram** uml/package
uml/Tracker
uml/TrackerSampler
uml/TrackerFeature
uml/TrackerModel
.. image:: pics/Tracker.png
:width: 80%
:alt: Tracker diagram
:align: center
**TrackerSampler diagram**
.. image:: pics/TrackerSampler.png
:width: 100%
:alt: TrackerSampler diagram
:align: center
**TrackerFeatureSet diagram**
.. image:: pics/TrackerFeature.png
:width: 100%
:alt: TrackerFeatureSet diagram
:align: center
**TrackerModel diagram**
.. image:: pics/TrackerModel.png
:width: 100%
:alt: TrackerModel diagram
:align: center
To see how API works, try tracker demo: To see how API works, try tracker demo:
https://github.com/lenlen/opencv/blob/tracking_api/samples/cpp/tracker.cpp https://github.com/lenlen/opencv/blob/tracking_api/samples/cpp/tracker.cpp
.. note:: This Tracking API has been designed with PlantUML. If you modify this API please change UML files under modules/tracking/misc/ .. note:: This Tracking API has been designed with PlantUML. If you modify this API please change UML files under modules/tracking/doc/uml/
The following reference was used in the API The following reference was used in the API
......
Tracker diagram
===============
.. uml::
..@startuml
package "Tracker package" #DDDDDD {
class Algorithm
class Tracker{
Ptr<TrackerFeatureSet> featureSet;
Ptr<TrackerSampler> sampler;
Ptr<TrackerModel> model;
---
+static Ptr<Tracker> create(const string& trackerType);
+bool init(const Mat& image, const Rect& boundingBox);
+bool update(const Mat& image, Rect& boundingBox);
}
class Tracker
note right: Tracker is the general interface for each specialized trackers
class TrackerMIL{
+static Ptr<TrackerMIL> createTracker(const TrackerMIL::Params &parameters);
+virtual ~TrackerMIL();
}
class TrackerBoosting{
+static Ptr<TrackerBoosting> createTracker(const TrackerBoosting::Params &parameters);
+virtual ~TrackerBoosting();
}
Algorithm <|-- Tracker : virtual inheritance
Tracker <|-- TrackerMIL
Tracker <|-- TrackerBoosting
note "Single instance of the Tracker" as N1
TrackerBoosting .. N1
TrackerMIL .. N1
}
..@enduml
@startuml TrackerFeatureSet diagram
package "TrackerFeature package" #DDDDDD { =========================
class TrackerFeatureSet{ .. uml::
..@startuml
package "TrackerFeature package" #DDDDDD {
class TrackerFeatureSet{
-vector<pair<string, Ptr<TrackerFeature> > > features -vector<pair<string, Ptr<TrackerFeature> > > features
-vector<Mat> responses -vector<Mat> responses
... ...
...@@ -16,16 +21,16 @@ class TrackerFeatureSet{ ...@@ -16,16 +21,16 @@ class TrackerFeatureSet{
+bool addTrackerFeature(string trackerFeatureType); +bool addTrackerFeature(string trackerFeatureType);
+bool addTrackerFeature(Ptr<TrackerFeature>& feature); +bool addTrackerFeature(Ptr<TrackerFeature>& feature);
-clearResponses(); -clearResponses();
} }
class TrackerFeature <<virtual>>{ class TrackerFeature <<virtual>>{
static Ptr<TrackerFeature> = create(const string& trackerFeatureType); static Ptr<TrackerFeature> = create(const string& trackerFeatureType);
compute(const std::vector<Mat>& images, Mat& response); compute(const std::vector<Mat>& images, Mat& response);
selection(Mat& response, int npoints); selection(Mat& response, int npoints);
} }
note bottom: Can be specialized as in table II\nA tracker can use more types of features note bottom: Can be specialized as in table II\nA tracker can use more types of features
class TrackerFeatureFeature2D{ class TrackerFeatureFeature2D{
-vector<Keypoints> keypoints -vector<Keypoints> keypoints
--- ---
TrackerFeatureFeature2D(string detectorType, string descriptorType); TrackerFeatureFeature2D(string detectorType, string descriptorType);
...@@ -33,23 +38,23 @@ class TrackerFeatureFeature2D{ ...@@ -33,23 +38,23 @@ class TrackerFeatureFeature2D{
--- ---
compute(const std::vector<Mat>& images, Mat& response); compute(const std::vector<Mat>& images, Mat& response);
selection( Mat& response, int npoints); selection( Mat& response, int npoints);
} }
class TrackerFeatureHOG{ class TrackerFeatureHOG{
TrackerFeatureHOG(); TrackerFeatureHOG();
~TrackerFeatureHOG(); ~TrackerFeatureHOG();
--- ---
compute(const std::vector<Mat>& images, Mat& response); compute(const std::vector<Mat>& images, Mat& response);
selection(Mat& response, int npoints); selection(Mat& response, int npoints);
} }
TrackerFeatureSet *-- TrackerFeature TrackerFeatureSet *-- TrackerFeature
TrackerFeature <|-- TrackerFeatureHOG TrackerFeature <|-- TrackerFeatureHOG
TrackerFeature <|-- TrackerFeatureFeature2D TrackerFeature <|-- TrackerFeatureFeature2D
note "Per readability and simplicity in this diagram\n there are only two TrackerFeature but you\n can considering the implementation of the other TrackerFeature" as N1 note "Per readability and simplicity in this diagram\n there are only two TrackerFeature but you\n can considering the implementation of the other TrackerFeature" as N1
TrackerFeatureHOG .. N1 TrackerFeatureHOG .. N1
TrackerFeatureFeature2D .. N1 TrackerFeatureFeature2D .. N1
} }
@enduml ..@enduml
@startuml TrackerModel diagram
package "TrackerModel package" #DDDDDD { ====================
class Typedef << (T,#FF7700) >>{ .. uml::
..@startuml
package "TrackerModel package" #DDDDDD {
class Typedef << (T,#FF7700) >>{
ConfidenceMap ConfidenceMap
Trajectory Trajectory
} }
class TrackerModel{ class TrackerModel{
-vector<ConfidenceMap> confidenceMaps; -vector<ConfidenceMap> confidenceMaps;
-Trajectory trajectory; -Trajectory trajectory;
-Ptr<TrackerStateEstimator> stateEstimator; -Ptr<TrackerStateEstimator> stateEstimator;
...@@ -24,39 +29,39 @@ class TrackerModel{ ...@@ -24,39 +29,39 @@ class TrackerModel{
+const vector<ConfidenceMap>& getConfidenceMaps(); +const vector<ConfidenceMap>& getConfidenceMaps();
+const ConfidenceMap& getLastConfidenceMap(); +const ConfidenceMap& getLastConfidenceMap();
} }
class TrackerTargetState <<virtual>>{ class TrackerTargetState <<virtual>>{
Point2f targetPosition; Point2f targetPosition;
--- ---
Point2f getTargetPosition(); Point2f getTargetPosition();
void setTargetPosition(Point2f position); void setTargetPosition(Point2f position);
} }
class TrackerTargetState class TrackerTargetState
note bottom: Each TrackerStateEstimator can create own state note bottom: Each tracker can create own state
class TrackerStateEstimator <<virtual>>{ class TrackerStateEstimator <<virtual>>{
~TrackerStateEstimator(); ~TrackerStateEstimator();
static Ptr<TrackerStateEstimator> create(const String& trackeStateEstimatorType); static Ptr<TrackerStateEstimator> create(const String& trackeStateEstimatorType);
Ptr<TrackerTargetState> estimate(const vector<ConfidenceMap>& confidenceMaps) Ptr<TrackerTargetState> estimate(const vector<ConfidenceMap>& confidenceMaps)
void update(vector<ConfidenceMap>& confidenceMaps) void update(vector<ConfidenceMap>& confidenceMaps)
} }
class TrackerStateEstimatorSVM{ class TrackerStateEstimatorSVM{
TrackerStateEstimatorSVM() TrackerStateEstimatorSVM()
~TrackerStateEstimatorSVM() ~TrackerStateEstimatorSVM()
Ptr<TrackerTargetState> estimate(const vector<ConfidenceMap>& confidenceMaps) Ptr<TrackerTargetState> estimate(const vector<ConfidenceMap>& confidenceMaps)
void update(vector<ConfidenceMap>& confidenceMaps) void update(vector<ConfidenceMap>& confidenceMaps)
} }
class TrackerStateEstimatorMILBoosting{ class TrackerStateEstimatorMILBoosting{
TrackerStateEstimatorMILBoosting() TrackerStateEstimatorMILBoosting()
~TrackerStateEstimatorMILBoosting() ~TrackerStateEstimatorMILBoosting()
Ptr<TrackerTargetState> estimate(const vector<ConfidenceMap>& confidenceMaps) Ptr<TrackerTargetState> estimate(const vector<ConfidenceMap>& confidenceMaps)
void update(vector<ConfidenceMap>& confidenceMaps) void update(vector<ConfidenceMap>& confidenceMaps)
} }
TrackerModel -> TrackerStateEstimator: create TrackerModel -> TrackerStateEstimator: create
TrackerModel *-- TrackerTargetState TrackerModel *-- TrackerTargetState
TrackerStateEstimator <|-- TrackerStateEstimatorMILBoosting TrackerStateEstimator <|-- TrackerStateEstimatorMILBoosting
TrackerStateEstimator <|-- TrackerStateEstimatorSVM TrackerStateEstimator <|-- TrackerStateEstimatorSVM
} }
@enduml ..@enduml
@startuml TrackerSampler diagram
package "TrackerSampler package" #DDDDDD { ======================
class TrackerSampler{ .. uml::
..@startuml
package "TrackerSampler package" #DDDDDD {
class TrackerSampler{
-vector<pair<String, Ptr<TrackerSamplerAlgorithm> > > samplers -vector<pair<String, Ptr<TrackerSamplerAlgorithm> > > samplers
-vector<Mat> samples; -vector<Mat> samples;
... ...
...@@ -14,31 +19,27 @@ class TrackerSampler{ ...@@ -14,31 +19,27 @@ class TrackerSampler{
+bool addTrackerSamplerAlgorithm(Ptr<TrackerSamplerAlgorithm>& sampler); +bool addTrackerSamplerAlgorithm(Ptr<TrackerSamplerAlgorithm>& sampler);
--- ---
-void clearSamples(); -void clearSamples();
} }
class TrackerSamplerAlgorithm{ class TrackerSamplerAlgorithm{
~TrackerSamplerAlgorithm(); ~TrackerSamplerAlgorithm();
+static Ptr<TrackerSamplerAlgorithm> create(const String& trackerSamplerType); +static Ptr<TrackerSamplerAlgorithm> create(const String& trackerSamplerType);
+bool sampling(const Mat& image, Rect boundingBox, vector<Mat>& sample); +bool sampling(const Mat& image, Rect boundingBox, vector<Mat>& sample);
} }
note bottom: A tracker could sample the target\nor it could sample the target and the background note bottom: A tracker could sample the target\nor it could sample the target and the background
class TrackerSamplerCS{ class TrackerSamplerCS{
TrackerSamplerCS(); TrackerSamplerCS();
~TrackerSamplerCS(); ~TrackerSamplerCS();
+bool sampling(const Mat& image, Rect boundingBox, vector<Mat>& sample); +bool sampling(const Mat& image, Rect boundingBox, vector<Mat>& sample);
} }
class TrackerSamplerCSC{ class TrackerSamplerCSC{
TrackerSamplerCSC(); TrackerSamplerCSC();
~TrackerSamplerCSC(); ~TrackerSamplerCSC();
+bool sampling(const Mat& image, Rect boundingBox, vector<Mat>& sample); +bool sampling(const Mat& image, Rect boundingBox, vector<Mat>& sample);
} }
TrackerSampler *-- TrackerSamplerAlgorithm }
TrackerSamplerAlgorithm <|-- TrackerSamplerCS ..@enduml
TrackerSamplerAlgorithm <|-- TrackerSamplerCSC
}
@enduml
General diagram
===============
.. uml::
..@startuml
package "Tracker"
package "TrackerFeature"
package "TrackerSampler"
package "TrackerModel"
Tracker -> TrackerModel: create
Tracker -> TrackerSampler: create
Tracker -> TrackerFeature: create
..@enduml
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
* - [AAM] S. Salti, A. Cavallaro, L. Di Stefano, Adaptive Appearance Modeling for Video Tracking: Survey and Evaluation * - [AAM] S. Salti, A. Cavallaro, L. Di Stefano, Adaptive Appearance Modeling for Video Tracking: Survey and Evaluation
* - [AMVOT] X. Li, W. Hu, C. Shen, Z. Zhang, A. Dick, A. van den Hengel, A Survey of Appearance Models in Visual Object Tracking * - [AMVOT] X. Li, W. Hu, C. Shen, Z. Zhang, A. Dick, A. van den Hengel, A Survey of Appearance Models in Visual Object Tracking
* *
* This Tracking API has been designed with PlantUML. If you modify this API please change UML files under modules/tracking/misc/ * This Tracking API has been designed with PlantUML. If you modify this API please change UML files under modules/tracking/doc/uml
* *
*/ */
......
...@@ -273,3 +273,73 @@ PERF_TEST_P(tracking, boosting, testing::Combine(TESTSET_NAMES, SEGMENTS)) ...@@ -273,3 +273,73 @@ PERF_TEST_P(tracking, boosting, testing::Combine(TESTSET_NAMES, SEGMENTS))
SANITY_CHECK( bbs_mat, 15, ERROR_RELATIVE ); SANITY_CHECK( bbs_mat, 15, ERROR_RELATIVE );
} }
PERF_TEST_P(tracking, tld, testing::Combine(TESTSET_NAMES, SEGMENTS))
{
string video = get<0>( GetParam() );
int segmentId = get<1>( GetParam() );
int startFrame;
string prefix;
string suffix;
string datasetMeta = getDataPath( TRACKING_DIR + "/" + video + "/" + video + ".yml" );
checkData( datasetMeta, startFrame, prefix, suffix );
int gtStartFrame = startFrame;
vector<Rect> gtBBs;
string gtFile = getDataPath( TRACKING_DIR + "/" + video + "/gt.txt" );
if( !getGroundTruth( gtFile, gtBBs ) )
FAIL()<< "Ground truth file " << gtFile << " can not be read" << endl;
int bbCounter = (int)gtBBs.size();
Mat frame;
bool initialized = false;
vector<Rect> bbs;
Ptr<Tracker> tracker = Tracker::create( "TLD" );
string folder = TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
int numSegments = ( sizeof ( SEGMENTS)/sizeof(int) );
int endFrame = 0;
getSegment( segmentId, numSegments, bbCounter, startFrame, endFrame );
Rect currentBBi = gtBBs[startFrame - gtStartFrame];
Rect2d currentBB(currentBBi);
TEST_CYCLE_N(1)
{
VideoCapture c;
c.open( getDataPath( TRACKING_DIR + "/" + video + "/" + FOLDER_IMG + "/" + video + ".webm" ) );
c.set( CAP_PROP_POS_FRAMES, startFrame );
for ( int frameCounter = startFrame; frameCounter < endFrame; frameCounter++ )
{
c >> frame;
if( frame.empty() )
{
break;
}
if( !initialized )
{
if( !tracker->init( frame, currentBB ) )
{
FAIL()<< "Could not initialize tracker" << endl;
return;
}
initialized = true;
}
else if( initialized )
{
tracker->update( frame, currentBB );
}
bbs.push_back( currentBB );
}
}
//save the bounding boxes in a Mat
Mat bbs_mat( (int)bbs.size(), 4, CV_32F );
getMatOfRects( bbs, bbs_mat );
SANITY_CHECK( bbs_mat, 15, ERROR_RELATIVE );
}
...@@ -347,11 +347,11 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -347,11 +347,11 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
std::vector<double>::iterator it = std::max_element(candidatesRes.begin(), candidatesRes.end()); std::vector<double>::iterator it = std::max_element(candidatesRes.begin(), candidatesRes.end());
dfprintf((stdout, "scale = %f\n", log(1.0 * boundingBox.width / (data->getMinSize()).width) / log(SCALE_STEP))); //dfprintf((stdout, "scale = %f\n", log(1.0 * boundingBox.width / (data->getMinSize()).width) / log(SCALE_STEP)));
for( int i = 0; i < (int)candidatesRes.size(); i++ ) //for( int i = 0; i < (int)candidatesRes.size(); i++ )
dprintf(("\tcandidatesRes[%d] = %f\n", i, candidatesRes[i])); //dprintf(("\tcandidatesRes[%d] = %f\n", i, candidatesRes[i]));
data->printme(); //data->printme();
tldModel->printme(stdout); //tldModel->printme(stdout);
if( it == candidatesRes.end() ) if( it == candidatesRes.end() )
{ {
...@@ -371,13 +371,13 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -371,13 +371,13 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
if( it != candidatesRes.end() ) if( it != candidatesRes.end() )
{ {
resample(imageForDetector, candidates[it - candidatesRes.begin()], standardPatch); resample(imageForDetector, candidates[it - candidatesRes.begin()], standardPatch);
dfprintf((stderr, "%d %f %f\n", data->frameNum, tldModel->Sc(standardPatch), tldModel->Sr(standardPatch))); //dfprintf((stderr, "%d %f %f\n", data->frameNum, tldModel->Sc(standardPatch), tldModel->Sr(standardPatch)));
if( candidatesRes.size() == 2 && it == (candidatesRes.begin() + 1) ) //if( candidatesRes.size() == 2 && it == (candidatesRes.begin() + 1) )
dfprintf((stderr, "detector WON\n")); //dfprintf((stderr, "detector WON\n"));
} }
else else
{ {
dfprintf((stderr, "%d x x\n", data->frameNum)); //dfprintf((stderr, "%d x x\n", data->frameNum));
} }
#endif #endif
...@@ -409,7 +409,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox) ...@@ -409,7 +409,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
detectorResults[i].isObject = expertResult; detectorResults[i].isObject = expertResult;
} }
tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults); tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults);
dprintf(("%d relabeled by nExpert\n", negRelabeled)); //dprintf(("%d relabeled by nExpert\n", negRelabeled));
pExpert.additionalExamples(examplesForModel, examplesForEnsemble); pExpert.additionalExamples(examplesForModel, examplesForEnsemble);
tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, true); tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, true);
examplesForModel.clear(); examplesForEnsemble.clear(); examplesForModel.clear(); examplesForEnsemble.clear();
...@@ -497,7 +497,7 @@ timeStampPositiveNext(0), timeStampNegativeNext(0), params_(params), boundingBox ...@@ -497,7 +497,7 @@ timeStampPositiveNext(0), timeStampNegativeNext(0), params_(params), boundingBox
classifiers[k].integrate(blurredPatch, false); classifiers[k].integrate(blurredPatch, false);
} }
} }
dprintf(("positive patches: %d\nnegative patches: %d\n", (int)positiveExamples.size(), (int)negativeExamples.size())); //dprintf(("positive patches: %d\nnegative patches: %d\n", (int)positiveExamples.size(), (int)negativeExamples.size()));
} }
void TLDDetector::generateScanGrid(int rows, int cols, Size initBox, std::vector<Rect2d>& res, bool withScaling) void TLDDetector::generateScanGrid(int rows, int cols, Size initBox, std::vector<Rect2d>& res, bool withScaling)
...@@ -532,7 +532,7 @@ void TLDDetector::generateScanGrid(int rows, int cols, Size initBox, std::vector ...@@ -532,7 +532,7 @@ void TLDDetector::generateScanGrid(int rows, int cols, Size initBox, std::vector
break; break;
} }
} }
dprintf(("%d rects in res\n", (int)res.size())); //dprintf(("%d rects in res\n", (int)res.size()));
} }
bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches) bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches)
...@@ -554,7 +554,7 @@ bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std ...@@ -554,7 +554,7 @@ bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std
double tmp = 0, maxSc = -5.0; double tmp = 0, maxSc = -5.0;
Rect2d maxScRect; Rect2d maxScRect;
START_TICK("detector"); //START_TICK("detector");
do do
{ {
Mat_<double> intImgP, intImgP2; Mat_<double> intImgP, intImgP2;
...@@ -605,9 +605,9 @@ bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std ...@@ -605,9 +605,9 @@ bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std
GaussianBlur(resized_img, blurred_img, GaussBlurKernelSize, 0.0f); GaussianBlur(resized_img, blurred_img, GaussBlurKernelSize, 0.0f);
} }
while( size.width >= initSize.width && size.height >= initSize.height ); while( size.width >= initSize.width && size.height >= initSize.height );
END_TICK("detector"); //END_TICK("detector");
dfprintf((stdout, "after NCC: nneg = %d npos = %d\n", nneg, npos)); //dfprintf((stdout, "after NCC: nneg = %d npos = %d\n", nneg, npos));
#if !1 #if !1
std::vector<Rect2d> poss, negs; std::vector<Rect2d> poss, negs;
...@@ -618,11 +618,11 @@ bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std ...@@ -618,11 +618,11 @@ bool TLDDetector::detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std
else else
negs.push_back(patches[i].rect); negs.push_back(patches[i].rect);
} }
dfprintf((stdout, "%d pos and %d neg\n", (int)poss.size(), (int)negs.size())); //dfprintf((stdout, "%d pos and %d neg\n", (int)poss.size(), (int)negs.size()));
drawWithRects(img, negs, poss, "tech"); drawWithRects(img, negs, poss, "tech");
#endif #endif
dfprintf((stdout, "%d after ensemble\n", pass)); //dfprintf((stdout, "%d after ensemble\n", pass));
if( maxSc < 0 ) if( maxSc < 0 )
return false; return false;
res = maxScRect; res = maxScRect;
...@@ -727,6 +727,7 @@ void TrackerTLDModel::integrateRelabeled(Mat& img, Mat& imgBlurred, const std::v ...@@ -727,6 +727,7 @@ void TrackerTLDModel::integrateRelabeled(Mat& img, Mat& imgBlurred, const std::v
classifiers[i].integrate(blurredPatch, patches[k].isObject); classifiers[i].integrate(blurredPatch, patches[k].isObject);
} }
} }
/*
if( negativeIntoModel > 0 ) if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel)); dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0) if( positiveIntoModel > 0)
...@@ -735,7 +736,7 @@ void TrackerTLDModel::integrateRelabeled(Mat& img, Mat& imgBlurred, const std::v ...@@ -735,7 +736,7 @@ void TrackerTLDModel::integrateRelabeled(Mat& img, Mat& imgBlurred, const std::v
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble)); dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 ) if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble)); dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n")); dfprintf((stdout, "\n"));*/
} }
void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForModel, const std::vector<Mat_<uchar> >& eForEnsemble, bool isPositive) void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForModel, const std::vector<Mat_<uchar> >& eForEnsemble, bool isPositive)
...@@ -771,6 +772,7 @@ void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForM ...@@ -771,6 +772,7 @@ void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForM
classifiers[i].integrate(eForEnsemble[k], isPositive); classifiers[i].integrate(eForEnsemble[k], isPositive);
} }
} }
/*
if( negativeIntoModel > 0 ) if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel)); dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0 ) if( positiveIntoModel > 0 )
...@@ -779,7 +781,7 @@ void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForM ...@@ -779,7 +781,7 @@ void TrackerTLDModel::integrateAdditional(const std::vector<Mat_<uchar> >& eForM
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble)); dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 ) if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble)); dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n")); dfprintf((stdout, "\n"));*/
} }
int TrackerTLDImpl::Pexpert::additionalExamples(std::vector<Mat_<uchar> >& examplesForModel, std::vector<Mat_<uchar> >& examplesForEnsemble) int TrackerTLDImpl::Pexpert::additionalExamples(std::vector<Mat_<uchar> >& examplesForModel, std::vector<Mat_<uchar> >& examplesForEnsemble)
...@@ -844,7 +846,7 @@ Data::Data(Rect2d initBox) ...@@ -844,7 +846,7 @@ Data::Data(Rect2d initBox)
minSize.width = (int)(initBox.width * 20.0 / minDim); minSize.width = (int)(initBox.width * 20.0 / minDim);
minSize.height = (int)(initBox.height * 20.0 / minDim); minSize.height = (int)(initBox.height * 20.0 / minDim);
frameNum = 0; frameNum = 0;
dprintf(("minSize = %dx%d\n", minSize.width, minSize.height)); //dprintf(("minSize = %dx%d\n", minSize.width, minSize.height));
} }
void Data::printme(FILE* port) void Data::printme(FILE* port)
......
...@@ -408,6 +408,20 @@ TEST_P(OPE_Overlap, Boosting) ...@@ -408,6 +408,20 @@ TEST_P(OPE_Overlap, Boosting)
RecordProperty( "ratioSuccess", test.getRatioSucc() ); RecordProperty( "ratioSuccess", test.getRatioSucc() );
} }
TEST_P(OPE_Distance, TLD)
{
TrackerOPETest test( Tracker::create( "TLD" ), TrackerOPETest::DISTANCE, dataset, threshold );
test.run();
RecordProperty( "ratioSuccess", test.getRatioSucc() );
}
TEST_P(OPE_Overlap, TLD)
{
TrackerOPETest test( Tracker::create( "TLD" ), TrackerOPETest::OVERLAP, dataset, threshold );
test.run();
RecordProperty( "ratioSuccess", test.getRatioSucc() );
}
INSTANTIATE_TEST_CASE_P( Tracking, OPE_Distance, testing::Combine( TESTSET_NAMES, LOCATION_ERROR_THRESHOLD ) ); INSTANTIATE_TEST_CASE_P( Tracking, OPE_Distance, testing::Combine( TESTSET_NAMES, LOCATION_ERROR_THRESHOLD ) );
INSTANTIATE_TEST_CASE_P( Tracking, OPE_Overlap, testing::Combine( TESTSET_NAMES, OVERLAP_THRESHOLD ) ); INSTANTIATE_TEST_CASE_P( Tracking, OPE_Overlap, testing::Combine( TESTSET_NAMES, OVERLAP_THRESHOLD ) );
......
...@@ -515,6 +515,20 @@ TEST_P(SRE_Overlap, Boosting) ...@@ -515,6 +515,20 @@ TEST_P(SRE_Overlap, Boosting)
RecordProperty( "ratioSuccess", test.getRatioSucc() ); RecordProperty( "ratioSuccess", test.getRatioSucc() );
} }
TEST_P(SRE_Distance, TLD)
{
TrackerSRETest test( Tracker::create( "TLD" ), TrackerSRETest::DISTANCE, dataset, shift, threshold );
test.run();
RecordProperty( "ratioSuccess", test.getRatioSucc() );
}
TEST_P(SRE_Overlap, TLD)
{
TrackerSRETest test( Tracker::create( "TLD" ), TrackerSRETest::OVERLAP, dataset, shift, threshold );
test.run();
RecordProperty( "ratioSuccess", test.getRatioSucc() );
}
INSTANTIATE_TEST_CASE_P( Tracking, SRE_Distance, testing::Combine( TESTSET_NAMES, SPATIAL_SHIFTS, LOCATION_ERROR_THRESHOLD ) ); INSTANTIATE_TEST_CASE_P( Tracking, SRE_Distance, testing::Combine( TESTSET_NAMES, SPATIAL_SHIFTS, LOCATION_ERROR_THRESHOLD ) );
INSTANTIATE_TEST_CASE_P( Tracking, SRE_Overlap, testing::Combine( TESTSET_NAMES, SPATIAL_SHIFTS, OVERLAP_THRESHOLD ) ); INSTANTIATE_TEST_CASE_P( Tracking, SRE_Overlap, testing::Combine( TESTSET_NAMES, SPATIAL_SHIFTS, OVERLAP_THRESHOLD ) );
......
...@@ -485,6 +485,20 @@ TEST_P(TRE_Overlap, Boosting) ...@@ -485,6 +485,20 @@ TEST_P(TRE_Overlap, Boosting)
RecordProperty( "ratioSuccess", test.getRatioSucc() ); RecordProperty( "ratioSuccess", test.getRatioSucc() );
} }
TEST_P(TRE_Distance, TLD)
{
TrackerTRETest test( Tracker::create( "TLD" ), TrackerTRETest::DISTANCE, dataset, threshold, segment );
test.run();
RecordProperty( "ratioSuccess", test.getRatioSucc() );
}
TEST_P(TRE_Overlap, TLD)
{
TrackerTRETest test( Tracker::create( "TLD" ), TrackerTRETest::OVERLAP, dataset, threshold, segment );
test.run();
RecordProperty( "ratioSuccess", test.getRatioSucc() );
}
INSTANTIATE_TEST_CASE_P( Tracking, TRE_Distance, testing::Combine( TESTSET_NAMES, SEGMENTS, LOCATION_ERROR_THRESHOLD ) ); INSTANTIATE_TEST_CASE_P( Tracking, TRE_Distance, testing::Combine( TESTSET_NAMES, SEGMENTS, LOCATION_ERROR_THRESHOLD ) );
INSTANTIATE_TEST_CASE_P( Tracking, TRE_Overlap, testing::Combine( TESTSET_NAMES, SEGMENTS, OVERLAP_THRESHOLD ) ); INSTANTIATE_TEST_CASE_P( Tracking, TRE_Overlap, testing::Combine( TESTSET_NAMES, SEGMENTS, OVERLAP_THRESHOLD ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment