-
Notifications
You must be signed in to change notification settings - Fork 70
/
dsst_tracker.hpp
707 lines (578 loc) · 24.5 KB
/
dsst_tracker.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
/*
// License Agreement (3-clause BSD License)
// Copyright (c) 2015, Klaus Haag, all rights reserved.
// Third party copyrights and patents are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the names of the copyright holders nor the names of the contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall copyright holders or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
*/
/* This class represents a C++ implementation of the Discriminative Scale
Space Tracker (DSST) [1]. The class contains the 2D translational filter.
The 1D scale filter can be found in scale_estimator.hpp.
It is implemented closely to the Matlab implementation by the original authors:
http://www.cvl.isy.liu.se/en/research/objrec/visualtracking/scalvistrack/index.html
However, some implementation details differ and some difference in performance
has to be expected.
Additionally, target loss detection is implemented according to [2].
Every complex matrix is as default in CCS packed form:
see: https://software.intel.com/en-us/node/504243
and http://docs.opencv.org/modules/core/doc/operations_on_arrays.html
References:
[1] M. Danelljan, et al.,
"Accurate Scale Estimation for Robust Visual Tracking,"
in Proc. BMVC, 2014.
[2] D. Bolme, et al.,
“Visual Object Tracking using Adaptive Correlation Filters,”
in Proc. CVPR, 2010.
*/
#ifndef DSST_TRACKER_HPP_
#define DSST_TRACKER_HPP_
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/core/traits.hpp>
#include <memory>
#include <iostream>
#include <fstream>
#include "cv_ext.hpp"
#include "mat_consts.hpp"
#include "feature_channels.hpp"
#include "gradientMex.hpp"
#include "math_helper.hpp"
#include "cf_tracker.hpp"
#include "scale_estimator.hpp"
#include "dsst_debug.hpp"
#include "psr.hpp"
namespace cf_tracking
{
struct DsstParameters
{
double padding = static_cast<double>(1.6);
double outputSigmaFactor = static_cast<double>(0.05);
double lambda = static_cast<double>(0.01);
double learningRate = static_cast<double>(0.012);
int templateSize = 100;
int cellSize = 2;
bool enableTrackingLossDetection = false;
double psrThreshold = 13.5;
int psrPeakDel = 1;
bool enableScaleEstimator = true;
double scaleSigmaFactor = static_cast<double>(0.25);
double scaleStep = static_cast<double>(1.02);
int scaleCellSize = 4;
int numberOfScales = 33;
//testing
bool originalVersion = false;
int resizeType = cv::INTER_LINEAR;
bool useFhogTranspose = false;
};
class DsstTracker : public CfTracker
{
public:
typedef float T; // set precision here double or float
static const int CV_TYPE = cv::DataType<T>::type;
typedef cv::Size_<T> Size;
typedef cv::Point_<T> Point;
typedef cv::Rect_<T> Rect;
typedef FhogFeatureChannels<T> FFC;
typedef DsstFeatureChannels<T> DFC;
typedef mat_consts::constants<T> consts;
DsstTracker(DsstParameters paras, DsstDebug<T>* debug = 0)
: _isInitialized(false),
_scaleEstimator(0),
_PADDING(static_cast<T>(paras.padding)),
_OUTPUT_SIGMA_FACTOR(static_cast<T>(paras.outputSigmaFactor)),
_LAMBDA(static_cast<T>(paras.lambda)),
_LEARNING_RATE(static_cast<T>(paras.learningRate)),
_CELL_SIZE(paras.cellSize),
_TEMPLATE_SIZE(paras.templateSize),
_PSR_THRESHOLD(static_cast<T>(paras.psrThreshold)),
_PSR_PEAK_DEL(paras.psrPeakDel),
_MIN_AREA(10),
_MAX_AREA_FACTOR(0.8),
_ID("DSSTcpp"),
_ENABLE_TRACKING_LOSS_DETECTION(paras.enableTrackingLossDetection),
_ORIGINAL_VERSION(paras.originalVersion),
_RESIZE_TYPE(paras.resizeType),
_USE_CCS(true),
_debug(debug)
{
if (paras.enableScaleEstimator)
{
ScaleEstimatorParas<T> sp;
sp.scaleCellSize = paras.scaleCellSize;
sp.scaleStep = static_cast<T>(paras.scaleStep);
sp.numberOfScales = paras.numberOfScales;
sp.scaleSigmaFactor = static_cast<T>(paras.scaleSigmaFactor);
sp.lambda = static_cast<T>(paras.lambda);
sp.learningRate = static_cast<T>(paras.learningRate);
sp.useFhogTranspose = paras.useFhogTranspose;
sp.resizeType = paras.resizeType;
sp.originalVersion = paras.originalVersion;
_scaleEstimator = new ScaleEstimator<T>(sp);
}
if (paras.useFhogTranspose)
cvFhog = &piotr::cvFhogT < T, DFC > ;
else
cvFhog = &piotr::cvFhog < T, DFC > ;
if (_USE_CCS)
calcDft = &cf_tracking::dftCcs;
else
calcDft = &cf_tracking::dftNoCcs;
// init dft
cv::Mat initDft = (cv::Mat_<T>(1, 1) << 1);
calcDft(initDft, initDft, 0);
if (CV_MAJOR_VERSION < 3)
{
std::cout << "DsstTracker: Using OpenCV Version: " << CV_MAJOR_VERSION << std::endl;
std::cout << "For more speed use 3.0 or higher!" << std::endl;
}
}
virtual ~DsstTracker()
{
delete _scaleEstimator;
}
virtual bool reinit(const cv::Mat& image, cv::Rect_<int>& boundingBox)
{
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
return reinit_(image, bb);
}
virtual bool reinit(const cv::Mat& image, cv::Rect_<float>& boundingBox)
{
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
return reinit_(image, bb);
}
virtual bool reinit(const cv::Mat& image, cv::Rect_<double>& boundingBox)
{
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
return reinit_(image, bb);
}
virtual bool update(const cv::Mat& image, cv::Rect_<int>& boundingBox)
{
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
if (update_(image, bb) == false)
return false;
boundingBox.x = static_cast<int>(round(bb.x));
boundingBox.y = static_cast<int>(round(bb.y));
boundingBox.width = static_cast<int>(round(bb.width));
boundingBox.height = static_cast<int>(round(bb.height));
return true;
}
virtual bool update(const cv::Mat& image, cv::Rect_<float>& boundingBox)
{
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
if (update_(image, bb) == false)
return false;
boundingBox.x = static_cast<float>(bb.x);
boundingBox.y = static_cast<float>(bb.y);
boundingBox.width = static_cast<float>(bb.width);
boundingBox.height = static_cast<float>(bb.height);
return true;
}
virtual bool update(const cv::Mat& image, cv::Rect_<double>& boundingBox)
{
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
if (update_(image, bb) == false)
return false;
boundingBox.x = static_cast<double>(bb.x);
boundingBox.y = static_cast<double>(bb.y);
boundingBox.width = static_cast<double>(bb.width);
boundingBox.height = static_cast<double>(bb.height);
return true;
}
virtual bool updateAt(const cv::Mat& image, cv::Rect_<int>& boundingBox)
{
bool isValid = false;
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
isValid = updateAt_(image, bb);
boundingBox.x = static_cast<int>(round(bb.x));
boundingBox.y = static_cast<int>(round(bb.y));
boundingBox.width = static_cast<int>(round(bb.width));
boundingBox.height = static_cast<int>(round(bb.height));
return isValid;
}
virtual bool updateAt(const cv::Mat& image, cv::Rect_<float>& boundingBox)
{
bool isValid = false;
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
isValid = updateAt_(image, bb);
boundingBox.x = static_cast<float>(bb.x);
boundingBox.y = static_cast<float>(bb.y);
boundingBox.width = static_cast<float>(bb.width);
boundingBox.height = static_cast<float>(bb.height);
return isValid;
}
virtual bool updateAt(const cv::Mat& image, cv::Rect_<double>& boundingBox)
{
bool isValid = false;
Rect bb = Rect(
static_cast<T>(boundingBox.x),
static_cast<T>(boundingBox.y),
static_cast<T>(boundingBox.width),
static_cast<T>(boundingBox.height)
);
isValid = updateAt_(image, bb);
boundingBox.x = static_cast<double>(bb.x);
boundingBox.y = static_cast<double>(bb.y);
boundingBox.width = static_cast<double>(bb.width);
boundingBox.height = static_cast<double>(bb.height);
return isValid;
}
virtual TrackerDebug* getTrackerDebug()
{
return _debug;
}
virtual const std::string getId()
{
return _ID;
}
private:
DsstTracker& operator=(const DsstTracker&)
{}
bool reinit_(const cv::Mat& image, Rect& boundingBox)
{
_pos.x = floor(boundingBox.x) + floor(boundingBox.width * consts::c0_5);
_pos.y = floor(boundingBox.y) + floor(boundingBox.height * consts::c0_5);
Size targetSize = Size(boundingBox.width, boundingBox.height);
_templateSz = Size(floor(targetSize.width * (1 + _PADDING)),
floor(targetSize.height * (1 + _PADDING)));
_scale = 1.0;
if (!_ORIGINAL_VERSION)
{
// resize to fixed side length _TEMPLATE_SIZE to stabilize FPS
if (_templateSz.height > _templateSz.width)
_scale = _templateSz.height / _TEMPLATE_SIZE;
else
_scale = _templateSz.width / _TEMPLATE_SIZE;
_templateSz = Size(floor(_templateSz.width / _scale), floor(_templateSz.height / _scale));
}
_baseTargetSz = Size(targetSize.width / _scale, targetSize.height / _scale);
_templateScaleFactor = 1 / _scale;
Size templateSzByCells = Size(floor((_templateSz.width) / _CELL_SIZE),
floor((_templateSz.height) / _CELL_SIZE));
// translation filter output target
T outputSigma = sqrt(_templateSz.area() / ((1 + _PADDING) * (1 + _PADDING)))
* _OUTPUT_SIGMA_FACTOR / _CELL_SIZE;
_y = gaussianShapedLabels2D<T>(outputSigma, templateSzByCells);
calcDft(_y, _yf, 0);
// translation filter hann window
cv::Mat cosWindowX;
cv::Mat cosWindowY;
cosWindowY = hanningWindow<T>(_yf.rows);
cosWindowX = hanningWindow<T>(_yf.cols);
_cosWindow = cosWindowY * cosWindowX.t();
std::shared_ptr<DFC> hfNum(0);
cv::Mat hfDen;
if (getTranslationTrainingData(image, hfNum, hfDen, _pos) == false)
return false;
_hfNumerator = hfNum;
_hfDenominator = hfDen;
if (_scaleEstimator)
{
_scaleEstimator->reinit(image, _pos, targetSize,
_scale * _templateScaleFactor);
}
_lastBoundingBox = boundingBox;
_isInitialized = true;
return true;
}
bool getTranslationTrainingData(const cv::Mat& image, std::shared_ptr<DFC>& hfNum,
cv::Mat& hfDen, const Point& pos) const
{
std::shared_ptr<DFC> xt(0);
if (getTranslationFeatures(image, xt, pos, _scale) == false)
return false;
std::shared_ptr<DFC> xtf;
if (_USE_CCS)
xtf = DFC::dftFeatures(xt);
else
xtf = DFC::dftFeatures(xt, cv::DFT_COMPLEX_OUTPUT);
hfNum = DFC::mulSpectrumsFeatures(_yf, xtf, true);
hfDen = DFC::sumFeatures(DFC::mulSpectrumsFeatures(xtf, xtf, true));
return true;
}
bool getTranslationFeatures(const cv::Mat& image, std::shared_ptr<DFC>& features,
const Point& pos, T scale) const
{
cv::Mat patch;
Size patchSize = _templateSz * scale;
if (getSubWindow(image, patch, patchSize, pos) == false)
return false;
if (_ORIGINAL_VERSION)
depResize(patch, patch, _templateSz);
else
resize(patch, patch, _templateSz, 0, 0, _RESIZE_TYPE);
if (_debug != 0)
_debug->showPatch(patch);
cv::Mat floatPatch;
patch.convertTo(floatPatch, CV_32FC(3));
features.reset(new DFC());
cvFhog(floatPatch, features, _CELL_SIZE, DFC::numberOfChannels() - 1);
// append gray-scale image
if (patch.channels() == 1)
{
if (_CELL_SIZE != 1)
resize(patch, patch, features->channels[0].size(), 0, 0, _RESIZE_TYPE);
features->channels[DFC::numberOfChannels() - 1] = patch / 255.0 - 0.5;
}
else
{
if (_CELL_SIZE != 1)
resize(patch, patch, features->channels[0].size(), 0, 0, _RESIZE_TYPE);
cv::Mat grayFrame;
cvtColor(patch, grayFrame, cv::COLOR_BGR2GRAY);
grayFrame.convertTo(grayFrame, CV_TYPE);
grayFrame = grayFrame / 255.0 - 0.5;
features->channels[DFC::numberOfChannels() - 1] = grayFrame;
}
DFC::mulFeatures(features, _cosWindow);
return true;
}
bool update_(const cv::Mat& image, Rect& boundingBox)
{
return updateAtScalePos(image, _pos, _scale, boundingBox);
}
bool updateAt_(const cv::Mat& image, Rect& boundingBox)
{
bool isValid = false;
T scale = 0;
Point pos(boundingBox.x + boundingBox.width * consts::c0_5,
boundingBox.y + boundingBox.height * consts::c0_5);
// caller's box may have a different aspect ratio
// compared to the _targetSize; use the larger side
// to calculate scale
if (boundingBox.width > boundingBox.height)
scale = boundingBox.width / _baseTargetSz.width;
else
scale = boundingBox.height / _baseTargetSz.height;
isValid = updateAtScalePos(image, pos, scale, boundingBox);
return isValid;
}
bool updateAtScalePos(const cv::Mat& image, const Point& oldPos, const T oldScale,
Rect& boundingBox)
{
++_frameIdx;
if (!_isInitialized)
return false;
T newScale = oldScale;
Point newPos = oldPos;
cv::Point2i maxResponseIdx;
cv::Mat response;
// in case of error return the last box
boundingBox = _lastBoundingBox;
if (detectModel(image, response, maxResponseIdx, newPos, newScale) == false)
return false;
// return box
Rect tempBoundingBox;
tempBoundingBox.width = _baseTargetSz.width * newScale;
tempBoundingBox.height = _baseTargetSz.height * newScale;
tempBoundingBox.x = newPos.x - tempBoundingBox.width / 2;
tempBoundingBox.y = newPos.y - tempBoundingBox.height / 2;
if (_ENABLE_TRACKING_LOSS_DETECTION)
{
if (evalReponse(image, response, maxResponseIdx,
tempBoundingBox) == false)
return false;
}
if (updateModel(image, newPos, newScale) == false)
return false;
boundingBox &= Rect(0, 0, static_cast<T>(image.cols), static_cast<T>(image.rows));
boundingBox = tempBoundingBox;
_lastBoundingBox = tempBoundingBox;
return true;
}
bool evalReponse(const cv::Mat &image, const cv::Mat& response,
const cv::Point2i& maxResponseIdx,
const Rect& tempBoundingBox) const
{
T peakValue = 0;
T psrClamped = calcPsr(response, maxResponseIdx, _PSR_PEAK_DEL, peakValue);
if (_debug != 0)
{
_debug->showResponse(response, peakValue);
_debug->setPsr(psrClamped);
}
if (psrClamped < _PSR_THRESHOLD)
return false;
// check if we are out of image, too small or too large
Rect imageRect(Point(0, 0), image.size());
Rect intersection = imageRect & tempBoundingBox;
double bbArea = tempBoundingBox.area();
double areaThreshold = _MAX_AREA_FACTOR * imageRect.area();
double intersectDiff = std::abs(bbArea - intersection.area());
if (intersectDiff > 0.01 || bbArea < _MIN_AREA
|| bbArea > areaThreshold)
return false;
return true;
}
bool detectModel(const cv::Mat& image, cv::Mat& response,
cv::Point2i& maxResponseIdx, Point& newPos,
T& newScale) const
{
// find translation
std::shared_ptr<DFC> xt(0);
if (getTranslationFeatures(image, xt, newPos, newScale) == false)
return false;
std::shared_ptr<DFC> xtf;
if (_USE_CCS)
xtf = DFC::dftFeatures(xt);
else
xtf = DFC::dftFeatures(xt, cv::DFT_COMPLEX_OUTPUT);
std::shared_ptr<DFC> sampleSpec = DFC::mulSpectrumsFeatures(_hfNumerator, xtf, false);
cv::Mat sumXtf = DFC::sumFeatures(sampleSpec);
cv::Mat hfDenLambda = addRealToSpectrum<T>(_LAMBDA, _hfDenominator);
cv::Mat responseTf;
if (_USE_CCS)
divSpectrums(sumXtf, hfDenLambda, responseTf, 0, false);
else
divideSpectrumsNoCcs<T>(sumXtf, hfDenLambda, responseTf);
cv::Mat translationResponse;
idft(responseTf, translationResponse, cv::DFT_REAL_OUTPUT | cv::DFT_SCALE);
cv::Point delta;
double maxResponse;
cv::Point_<T> subDelta;
minMaxLoc(translationResponse, 0, &maxResponse, 0, &delta);
subDelta = delta;
if (_CELL_SIZE != 1)
subDelta = subPixelDelta<T>(translationResponse, delta);
T posDeltaX = (subDelta.x + 1 - floor(translationResponse.cols / consts::c2_0)) * newScale;
T posDeltaY = (subDelta.y + 1 - floor(translationResponse.rows / consts::c2_0)) * newScale;
newPos.x += round(posDeltaX * _CELL_SIZE);
newPos.y += round(posDeltaY * _CELL_SIZE);
if (_debug != 0)
_debug->showResponse(translationResponse, maxResponse);
if (_scaleEstimator)
{
//find scale
T tempScale = newScale * _templateScaleFactor;
if (_scaleEstimator->detectScale(image, newPos,
tempScale) == false)
return false;
newScale = tempScale / _templateScaleFactor;
}
response = translationResponse;
maxResponseIdx = delta;
return true;
}
bool updateModel(const cv::Mat& image, const Point& newPos,
T newScale)
{
_pos = newPos;
_scale = newScale;
std::shared_ptr<DFC> hfNum(0);
cv::Mat hfDen;
if (getTranslationTrainingData(image, hfNum, hfDen, _pos) == false)
return false;
_hfDenominator = (1 - _LEARNING_RATE) * _hfDenominator + _LEARNING_RATE * hfDen;
DFC::mulValueFeatures(_hfNumerator, (1 - _LEARNING_RATE));
DFC::mulValueFeatures(hfNum, _LEARNING_RATE);
DFC::addFeatures(_hfNumerator, hfNum);
if (_scaleEstimator)
{
if (_scaleEstimator->updateScale(image, newPos, newScale * _templateScaleFactor) == false)
return false;
}
return true;
}
private:
typedef void(*cvFhogPtr)
(const cv::Mat& img, std::shared_ptr<DFC>& cvFeatures, int binSize, int fhogChannelsToCopy);
cvFhogPtr cvFhog = 0;
typedef void(*dftPtr)
(const cv::Mat& input, cv::Mat& output, int flags);
dftPtr calcDft = 0;
cv::Mat _cosWindow;
cv::Mat _y;
std::shared_ptr<DFC> _hfNumerator;
cv::Mat _hfDenominator;
cv::Mat _yf;
Point _pos;
Size _templateSz;
Size _templateSizeNoFloor;
Size _baseTargetSz;
Rect _lastBoundingBox;
T _scale; // _scale is the scale of the template; not the target
T _templateScaleFactor; // _templateScaleFactor is used to calc the target scale
ScaleEstimator<T>* _scaleEstimator;
int _frameIdx = 1;
bool _isInitialized;
const double _MIN_AREA;
const double _MAX_AREA_FACTOR;
const T _PADDING;
const T _OUTPUT_SIGMA_FACTOR;
const T _LAMBDA;
const T _LEARNING_RATE;
const T _PSR_THRESHOLD;
const int _PSR_PEAK_DEL;
const int _CELL_SIZE;
const int _TEMPLATE_SIZE;
const std::string _ID;
const bool _ENABLE_TRACKING_LOSS_DETECTION;
const int _RESIZE_TYPE;
const bool _ORIGINAL_VERSION;
const bool _USE_CCS;
DsstDebug<T>* _debug;
};
}
#endif /* KCF_TRACKER_H_ */