Skip to content

Commit 3011e80

Browse files
committed
Merge pull request #2 from Auron-X/TLD_fixes_&_optimizations
Tld fixes & optimizations
2 parents 26f16e6 + 7569b8a commit 3011e80

13 files changed

+21
-30
lines changed

modules/tracking/samples/tld_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int main()
118118
// VideoCapture cap(0);
119119
// if( !cap.isOpened() )
120120
// {
121-
// cout << "Video stream error";
121+
// cout << "Video stream error";
122122
// return;
123123
// }
124124
//cap >> frame;

modules/tracking/src/TrackingFunctionPF.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace cv{
2424
Mat_<double> HShist, Vhist;
2525
};
2626
TrackingHistogram _origHist;
27-
2827
const TrackingFunctionPF & operator = (const TrackingFunctionPF &);
2928
};
3029

modules/tracking/src/tldDetector.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace cv
5353
}
5454

5555
// Calculate posterior probability, that the patch belongs to the current EC model
56-
double TLDDetector::ensembleClassifierNum(const uchar* data)
56+
double TLDDetector::ensembleClassifierNum(const uchar* data)
5757
{
5858
double p = 0;
5959
for (int k = 0; k < (int)classifiers.size(); k++)
@@ -146,7 +146,6 @@ namespace cv
146146
Rect2d maxScRect;
147147

148148
//Detection part
149-
//To fix: use precalculated BB
150149
do
151150
{
152151
Mat_<double> intImgP, intImgP2;

modules/tracking/src/tldDetector.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ namespace cv
7070
public:
7171
TLDDetector(){}
7272
~TLDDetector(){}
73-
7473
inline double ensembleClassifierNum(const uchar* data);
7574
inline void prepareClassifiers(int rowstep);
7675
double Sr(const Mat_<uchar>& patch);
@@ -89,8 +88,8 @@ namespace cv
8988
};
9089
bool detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize);
9190
protected:
92-
93-
91+
92+
9493

9594
friend class MyMouseCallbackDEBUG;
9695
void computeIntegralImages(const Mat& img, Mat_<double>& intImgP, Mat_<double>& intImgP2){ integral(img, intImgP, intImgP2, CV_64F); }

modules/tracking/src/tldEnsembleClassifier.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ namespace cv
5555
measurements.assign(meas.begin() + beg, meas.begin() + end);
5656
offset.assign(mpc, Point2i(0, 0));
5757
}
58-
59-
// Calculate measure locations from 15x15 grid on minSize patches
58+
// Calculate measure locations from 15x15 grid on minSize patches
6059
void TLDEnsembleClassifier::stepPrefSuff(std::vector<Vec4b>& arr, int pos, int len, int gridSize)
6160
{
6261
#if 0
@@ -92,7 +91,7 @@ namespace cv
9291
}
9392
#endif
9493
}
95-
94+
9695
// Calculate offsets for classifier
9796
void TLDEnsembleClassifier::prepareClassifier(int rowstep)
9897
{
@@ -106,7 +105,7 @@ namespace cv
106105
}
107106
}
108107
}
109-
108+
110109
// Integrate patch into the Ensemble Classifier model
111110
void TLDEnsembleClassifier::integrate(const Mat_<uchar>& patch, bool isPositive)
112111
{
@@ -137,7 +136,7 @@ namespace cv
137136
return posNum / (posNum + negNum);
138137
}
139138

140-
// Calculate the 13-bit fern index
139+
// Calculate the 13-bit fern index
141140
int TLDEnsembleClassifier::codeFast(const uchar* data) const
142141
{
143142
int position = 0;
@@ -188,7 +187,7 @@ namespace cv
188187
stepPrefSuff(measurements, 2, size.height, gridSize);
189188
stepPrefSuff(measurements, 3, size.height, gridSize);
190189

191-
//Compile fern classifiers
190+
//Compile fern classifiers
192191
for (int i = 0, howMany = (int)measurements.size() / measurePerClassifier; i < howMany; i++)
193192
classifiers.push_back(TLDEnsembleClassifier(measurements, i * measurePerClassifier, (i + 1) * measurePerClassifier));
194193

modules/tracking/src/tldEnsembleClassifier.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,5 @@ namespace cv
6565
int lastStep_;
6666
};
6767

68-
6968
}
7069
}

modules/tracking/src/tldModel.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@ namespace cv
6464

6565
//Calculate the variance in initial BB
6666
originalVariance_ = variance(image(boundingBox));
67-
6867
//Find the scale
6968
double scale = scaleAndBlur(image, cvRound(log(1.0 * boundingBox.width / (minSize.width)) / log(SCALE_STEP)),
7069
scaledImg, blurredImg, GaussBlurKernelSize, SCALE_STEP);
7170
GaussianBlur(image, image_blurred, GaussBlurKernelSize, 0.0);
7271
TLDDetector::generateScanGrid(image.rows, image.cols, minSize_, scanGrid);
73-
getClosestN(scanGrid, Rect2d(boundingBox.x / scale, boundingBox.y / scale, boundingBox.width / scale,
72+
getClosestN(scanGrid, Rect2d(boundingBox.x / scale, boundingBox.y / scale, boundingBox.width / scale,
7473
boundingBox.height / scale), 10, closest);
7574

7675
Mat_<uchar> blurredPatch(minSize);
@@ -271,7 +270,7 @@ namespace cv
271270
}
272271

273272

274-
273+
275274

276275
}
277276
}

modules/tracking/src/tldModel.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ namespace cv
5151
namespace tld
5252
{
5353

54-
5554

5655

5756
class TrackerTLDModel : public TrackerModel
@@ -75,14 +74,13 @@ namespace cv
7574

7675
protected:
7776
Size minSize_;
78-
7977
TrackerTLD::Params params_;
8078
void pushIntoModel(const Mat_<uchar>& example, bool positive);
8179
void modelEstimationImpl(const std::vector<Mat>& /*responses*/){}
8280
void modelUpdateImpl(){}
83-
Rect2d boundingBox_;
81+
Rect2d boundingBox_;
8482
RNG rng;
85-
83+
8684
};
8785

8886
}

modules/tracking/src/tldTracker.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox)
8989
myBoundingBox.width *= scale;
9090
myBoundingBox.height *= scale;
9191
}
92-
model = Ptr<TrackerTLDModel>(new TrackerTLDModel(params, image_gray, myBoundingBox, data->getMinSize()));
92+
model = Ptr<TrackerTLDModel>(new TrackerTLDModel(params, image_gray, myBoundingBox, data->getMinSize()));
9393

9494
data->confident = false;
9595
data->failedLastTime = false;
@@ -119,7 +119,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
119119
for( int i = 0; i < 2; i++ )
120120
{
121121
Rect2d tmpCandid = boundingBox;
122-
if( ( (i == 0) && !data->failedLastTime && trackerProxy->update(image, tmpCandid) ) ||
122+
if( ( (i == 0) && !data->failedLastTime && trackerProxy->update(image, tmpCandid) ) ||
123123
((i == 1) && (tldModel->detector->detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize()))))
124124
{
125125
candidates.push_back(tmpCandid);
@@ -292,6 +292,6 @@ void Data::printme(FILE* port)
292292
dfprintf((port, "\tminSize = %dx%d\n", minSize.width, minSize.height));
293293
}
294294

295-
}
295+
}
296296

297-
}
297+
}

modules/tracking/src/tldTracker.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include<algorithm>
5050
#include<limits.h>
5151

52-
namespace cv
52+
namespace cv
5353
{
5454

5555
TrackerTLD::Params::Params(){}
@@ -60,7 +60,6 @@ void TrackerTLD::Params::write(cv::FileStorage& /*fs*/) const {}
6060

6161
namespace tld
6262
{
63-
6463

6564
class TrackerProxy
6665
{

0 commit comments

Comments
 (0)