Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
d41639a9
Commit
d41639a9
authored
Aug 27, 2015
by
Vladimir
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into Itseez/master
parents
e18103e2
c11abeb7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
489 additions
and
141 deletions
+489
-141
tldDataset.hpp
modules/tracking/include/opencv2/tracking/tldDataset.hpp
+1
-1
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+86
-0
multiTracker_test.cpp
modules/tracking/samples/multiTracker_test.cpp
+227
-0
multiTracker.cpp
modules/tracking/src/multiTracker.cpp
+0
-0
multiTracker.hpp
modules/tracking/src/multiTracker.hpp
+58
-0
tldDataset.cpp
modules/tracking/src/tldDataset.cpp
+100
-60
tldDetector.cpp
modules/tracking/src/tldDetector.cpp
+0
-0
tldDetector.hpp
modules/tracking/src/tldDetector.hpp
+9
-8
tldEnsembleClassifier.hpp
modules/tracking/src/tldEnsembleClassifier.hpp
+1
-1
tldModel.cpp
modules/tracking/src/tldModel.cpp
+0
-44
tldTracker.cpp
modules/tracking/src/tldTracker.cpp
+7
-20
tldTracker.hpp
modules/tracking/src/tldTracker.hpp
+0
-7
No files found.
modules/tracking/include/opencv2/tracking/tldDataset.hpp
View file @
d41639a9
...
...
@@ -48,7 +48,7 @@ namespace cv
{
namespace
tld
{
CV_EXPORTS
cv
::
Rect2d
tld_InitDataset
(
int
datasetInd
,
const
char
*
rootPath
=
"TLD_dataset"
);
CV_EXPORTS
cv
::
Rect2d
tld_InitDataset
(
int
videoInd
,
const
char
*
rootPath
=
"TLD_dataset"
,
int
datasetInd
=
0
);
CV_EXPORTS
cv
::
Mat
tld_getNextDatasetFrame
();
}
}
...
...
modules/tracking/include/opencv2/tracking/tracker.hpp
View file @
d41639a9
...
...
@@ -49,6 +49,7 @@
#include "onlineBoosting.hpp"
#include <iostream>
#define BOILERPLATE_CODE(name,classname) \
static Ptr<classname> createTracker(const classname::Params ¶meters=classname::Params());\
virtual ~classname(){};
...
...
@@ -564,6 +565,11 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
virtual
void
read
(
const
FileNode
&
fn
)
=
0
;
virtual
void
write
(
FileStorage
&
fs
)
const
=
0
;
Ptr
<
TrackerModel
>
getModel
()
{
return
model
;
}
protected
:
virtual
bool
initImpl
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
)
=
0
;
...
...
@@ -576,6 +582,7 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
Ptr
<
TrackerModel
>
model
;
};
/************************************ Specific TrackerStateEstimator Classes ************************************/
/** @brief TrackerStateEstimator based on Boosting
...
...
@@ -1243,6 +1250,85 @@ class CV_EXPORTS_W TrackerKCF : public Tracker
BOILERPLATE_CODE
(
"KCF"
,
TrackerKCF
);
};
/************************************ Multi-Tracker Classes ************************************/
/** @brief Base abstract class for the long-term Multi Object Trackers:
@sa Tracker, MultiTrackerTLD
*/
class
CV_EXPORTS_W
MultiTracker
{
public
:
/** @brief Constructor for Multitracker
*/
MultiTracker
()
{
targetNum
=
0
;
}
/** @brief Add a new target to a tracking-list and initialize the tracker with a know bounding box that surrounding the target
@param image The initial frame
@param boundingBox The initial boundig box of target
@param tracker_algorithm_name Multi-tracker algorithm name
@return True if new target initialization went succesfully, false otherwise
*/
bool
addTarget
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
,
char
*
tracker_algorithm_name
);
/** @brief Update all trackers from the tracking-list, find a new most likely bounding boxes for the targets
@param image The current frame
@return True means that all targets were located and false means that tracker couldn't locate one of the targets in
current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
missing from the frame (say, out of sight)
*/
bool
update
(
const
Mat
&
image
);
/** @brief Current number of targets in tracking-list
*/
int
targetNum
;
/** @brief Trackers list for Multi-Object-Tracker
*/
std
::
vector
<
Ptr
<
Tracker
>
>
trackers
;
/** @brief Bounding Boxes list for Multi-Object-Tracker
*/
std
::
vector
<
Rect2d
>
boundingBoxes
;
/** @brief List of randomly generated colors for bounding boxes display
*/
std
::
vector
<
Scalar
>
colors
;
};
/** @brief Multi Object Tracker for TLD. TLD is a novel tracking framework that explicitly decomposes
the long-term tracking task into tracking, learning and detection.
The tracker follows the object from frame to frame. The detector localizes all appearances that
have been observed so far and corrects the tracker if necessary. The learning estimates detector’s
errors and updates it to avoid these errors in the future. The implementation is based on @cite TLD .
The Median Flow algorithm (see cv::TrackerMedianFlow) was chosen as a tracking component in this
implementation, following authors. Tracker is supposed to be able to handle rapid motions, partial
occlusions, object absence etc.
@sa Tracker, MultiTracker, TrackerTLD
*/
class
CV_EXPORTS_W
MultiTrackerTLD
:
public
MultiTracker
{
public
:
/** @brief Update all trackers from the tracking-list, find a new most likely bounding boxes for the targets by
optimized update method using some techniques to speedup calculations specifically for MO TLD. The only limitation
is that all target bounding boxes should have approximately same aspect ratios. Speed boost is around 20%
@param image The current frame.
@return True means that all targets were located and false means that tracker couldn't locate one of the targets in
current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
missing from the frame (say, out of sight)
*/
bool
update_opt
(
const
Mat
&
image
);
};
//! @}
}
/* namespace cv */
...
...
modules/tracking/samples/multiTracker_test.cpp
0 → 100644
View file @
d41639a9
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights 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:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 the Intel Corporation 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.
//
//M*/
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using
namespace
std
;
using
namespace
cv
;
#define NUM_TEST_FRAMES 100
#define TEST_VIDEO_INDEX 15 //TLD Dataset Video Index from 1-10 for TLD and 1-60 for VOT
//#define RECORD_VIDEO_FLG
static
Mat
image
;
static
bool
paused
;
static
bool
selectObject
=
false
;
static
bool
startSelection
=
false
;
Rect2d
boundingBox
;
static
void
onMouse
(
int
event
,
int
x
,
int
y
,
int
,
void
*
)
{
if
(
!
selectObject
)
{
switch
(
event
)
{
case
EVENT_LBUTTONDOWN
:
//set origin of the bounding box
startSelection
=
true
;
boundingBox
.
x
=
x
;
boundingBox
.
y
=
y
;
boundingBox
.
width
=
boundingBox
.
height
=
0
;
break
;
case
EVENT_LBUTTONUP
:
//sei with and height of the bounding box
boundingBox
.
width
=
std
::
abs
(
x
-
boundingBox
.
x
);
boundingBox
.
height
=
std
::
abs
(
y
-
boundingBox
.
y
);
paused
=
false
;
selectObject
=
true
;
break
;
case
EVENT_MOUSEMOVE
:
if
(
startSelection
&&
!
selectObject
)
{
//draw the bounding box
Mat
currentFrame
;
image
.
copyTo
(
currentFrame
);
rectangle
(
currentFrame
,
Point
((
int
)
boundingBox
.
x
,
(
int
)
boundingBox
.
y
),
Point
(
x
,
y
),
Scalar
(
255
,
0
,
0
),
2
,
1
);
imshow
(
"Tracking API"
,
currentFrame
);
}
break
;
}
}
}
int
main
()
{
//
// "MIL", "BOOSTING", "MEDIANFLOW", "TLD"
//
char
*
tracker_algorithm_name
=
(
char
*
)
"TLD"
;
Mat
frame
;
paused
=
false
;
namedWindow
(
"Tracking API"
,
0
);
setMouseCallback
(
"Tracking API"
,
onMouse
,
0
);
MultiTrackerTLD
mt
;
//Get the first frame
////Open the capture
// VideoCapture cap(0);
// if( !cap.isOpened() )
// {
// cout << "Video stream error";
// return;
// }
//cap >> frame;
//From TLD dataset
selectObject
=
true
;
Rect2d
boundingBox1
=
tld
::
tld_InitDataset
(
TEST_VIDEO_INDEX
,
"D:/opencv/VOT 2015"
,
1
);
Rect2d
boundingBox2
(
470
,
490
,
50
,
120
);
frame
=
tld
::
tld_getNextDatasetFrame
();
frame
.
copyTo
(
image
);
// Setup output video
#ifdef RECORD_VIDEO_FLG
String
outputFilename
=
"test.avi"
;
VideoWriter
outputVideo
;
outputVideo
.
open
(
outputFilename
,
-
1
,
15
,
Size
(
image
.
cols
,
image
.
rows
));
if
(
!
outputVideo
.
isOpened
())
{
std
::
cout
<<
"!!! Output video could not be opened"
<<
std
::
endl
;
getchar
();
return
0
;
}
#endif
rectangle
(
image
,
boundingBox
,
Scalar
(
255
,
0
,
0
),
2
,
1
);
imshow
(
"Tracking API"
,
image
);
bool
initialized
=
false
;
int
frameCounter
=
0
;
//Time measurment
int64
e3
=
getTickCount
();
for
(;;)
{
//Time measurment
int64
e1
=
getTickCount
();
//Frame num
frameCounter
++
;
if
(
frameCounter
==
NUM_TEST_FRAMES
)
break
;
char
c
=
(
char
)
waitKey
(
2
);
if
(
c
==
'q'
||
c
==
27
)
break
;
if
(
c
==
'p'
)
paused
=
!
paused
;
if
(
!
paused
)
{
//cap >> frame;
frame
=
tld
::
tld_getNextDatasetFrame
();
if
(
frame
.
empty
())
{
break
;
}
frame
.
copyTo
(
image
);
if
(
selectObject
)
{
if
(
!
initialized
)
{
//initializes the tracker
mt
.
addTarget
(
frame
,
boundingBox1
,
tracker_algorithm_name
);
rectangle
(
frame
,
boundingBox1
,
mt
.
colors
[
0
],
2
,
1
);
mt
.
addTarget
(
frame
,
boundingBox2
,
tracker_algorithm_name
);
rectangle
(
frame
,
boundingBox2
,
mt
.
colors
[
1
],
2
,
1
);
initialized
=
true
;
}
else
{
//updates the tracker
if
(
mt
.
update
(
frame
))
{
for
(
int
i
=
0
;
i
<
mt
.
targetNum
;
i
++
)
rectangle
(
frame
,
mt
.
boundingBoxes
[
i
],
mt
.
colors
[
i
],
2
,
1
);
}
}
}
imshow
(
"Tracking API"
,
frame
);
#ifdef RECORD_VIDEO_FLG
outputVideo
<<
frame
;
#endif
//Time measurment
int64
e2
=
getTickCount
();
double
t1
=
(
e2
-
e1
)
/
getTickFrequency
();
cout
<<
frameCounter
<<
"
\t
frame : "
<<
t1
*
1000.0
<<
"ms"
<<
endl
;
//waitKey(0);
}
}
//Time measurment
int64
e4
=
getTickCount
();
double
t2
=
(
e4
-
e3
)
/
getTickFrequency
();
cout
<<
"Average Time for Frame: "
<<
t2
*
1000.0
/
frameCounter
<<
"ms"
<<
endl
;
cout
<<
"Average FPS: "
<<
1.0
/
t2
*
frameCounter
<<
endl
;
waitKey
(
0
);
return
0
;
}
\ No newline at end of file
modules/tracking/src/multiTracker.cpp
0 → 100644
View file @
d41639a9
This diff is collapsed.
Click to expand it.
modules/tracking/src/multiTracker.hpp
0 → 100644
View file @
d41639a9
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights 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:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 the Intel Corporation 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.
//
//M*/
#ifndef OPENCV_MULTITRACKER
#define OPENCV_MULTITRACKER
#include "precomp.hpp"
#include "tldTracker.hpp"
#include "tldUtils.hpp"
#include <math.h>
namespace
cv
{
void
detect_all
(
const
Mat
&
img
,
const
Mat
&
imgBlurred
,
std
::
vector
<
Rect2d
>&
res
,
std
::
vector
<
std
::
vector
<
tld
::
TLDDetector
::
LabeledPatch
>
>
&
patches
,
std
::
vector
<
bool
>&
detect_flgs
,
std
::
vector
<
Ptr
<
Tracker
>
>&
trackers
);
void
ocl_detect_all
(
const
Mat
&
img
,
const
Mat
&
imgBlurred
,
std
::
vector
<
Rect2d
>&
res
,
std
::
vector
<
std
::
vector
<
tld
::
TLDDetector
::
LabeledPatch
>
>
&
patches
,
std
::
vector
<
bool
>&
detect_flgs
,
std
::
vector
<
Ptr
<
Tracker
>
>&
trackers
);
}
#endif
\ No newline at end of file
modules/tracking/src/tldDataset.cpp
View file @
d41639a9
...
...
@@ -48,70 +48,108 @@ namespace cv
char
tldRootPath
[
100
];
int
frameNum
=
0
;
bool
flagPNG
=
false
;
bool
flagVOT
=
false
;
cv
::
Rect2d
tld_InitDataset
(
int
datasetInd
,
const
char
*
rootPath
)
//TLD Dataset Parameters
const
char
*
tldFolderName
[
10
]
=
{
"01_david"
,
"02_jumping"
,
"03_pedestrian1"
,
"04_pedestrian2"
,
"05_pedestrian3"
,
"06_car"
,
"07_motocross"
,
"08_volkswagen"
,
"09_carchase"
,
"10_panda"
};
const
char
*
votFolderName
[
60
]
=
{
"bag"
,
"ball1"
,
"ball2"
,
"basketball"
,
"birds1"
,
"birds2"
,
"blanket"
,
"bmx"
,
"bolt1"
,
"bolt2"
,
"book"
,
"butterfly"
,
"car1"
,
"car2"
,
"crossing"
,
"dinosaur"
,
"fernando"
,
"fish1"
,
"fish2"
,
"fish3"
,
"fish4"
,
"girl"
,
"glove"
,
"godfather"
,
"graduate"
,
"gymnastics1"
,
"gymnastics2 "
,
"gymnastics3"
,
"gymnastics4"
,
"hand"
,
"handball1"
,
"handball2"
,
"helicopter"
,
"iceskater1"
,
"iceskater2"
,
"leaves"
,
"marching"
,
"matrix"
,
"motocross1"
,
"motocross2"
,
"nature"
,
"octopus"
,
"pedestrian1"
,
"pedestrian2"
,
"rabbit"
,
"racing"
,
"road"
,
"shaking"
,
"sheep"
,
"singer1"
,
"singer2"
,
"singer3"
,
"soccer1"
,
"soccer2"
,
"soldier"
,
"sphere"
,
"tiger"
,
"traffic"
,
"tunnel"
,
"wiper"
};
const
Rect2d
tldInitBB
[
10
]
=
{
Rect2d
(
165
,
93
,
51
,
54
),
Rect2d
(
147
,
110
,
33
,
32
),
Rect2d
(
47
,
51
,
21
,
36
),
Rect2d
(
130
,
134
,
21
,
53
),
Rect2d
(
154
,
102
,
24
,
52
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
337
,
219
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
)
};
const
Rect2d
votInitBB
[
60
]
=
{
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
490
,
400
,
40
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
450
,
380
,
60
,
60
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
225
,
175
,
50
,
50
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
560
,
460
,
50
,
120
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
Rect2d
(
142
,
125
,
90
,
39
),
Rect2d
(
290
,
43
,
23
,
40
),
Rect2d
(
273
,
77
,
27
,
25
),
Rect2d
(
145
,
84
,
54
,
37
),
Rect2d
(
58
,
100
,
27
,
22
),
};
int
tldFrameOffset
[
10
]
=
{
100
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
int
votFrameOffset
[
60
]
=
{
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
};
bool
tldFlagPNG
[
10
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
};
bool
votFlagPNG
[
60
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
};
cv
::
Rect2d
tld_InitDataset
(
int
videoInd
,
const
char
*
rootPath
,
int
datasetInd
)
{
char
*
folderName
=
(
char
*
)
""
;
int
x
=
0
;
int
y
=
0
;
int
w
=
0
;
int
h
=
0
;
flagPNG
=
false
;
frameNum
=
1
;
if
(
datasetInd
==
1
)
{
folderName
=
(
char
*
)
"01_david"
;
x
=
165
,
y
=
83
;
w
=
51
;
h
=
54
;
frameNum
=
100
;
}
if
(
datasetInd
==
2
)
{
folderName
=
(
char
*
)
"02_jumping"
;
x
=
147
,
y
=
110
;
w
=
33
;
h
=
32
;
}
if
(
datasetInd
==
3
)
{
folderName
=
(
char
*
)
"03_pedestrian1"
;
x
=
47
,
y
=
51
;
w
=
21
;
h
=
36
;
}
if
(
datasetInd
==
4
)
{
folderName
=
(
char
*
)
"04_pedestrian2"
;
x
=
130
,
y
=
134
;
w
=
21
;
h
=
53
;
}
if
(
datasetInd
==
5
)
{
folderName
=
(
char
*
)
"05_pedestrian3"
;
x
=
154
,
y
=
102
;
w
=
24
;
h
=
52
;
}
if
(
datasetInd
==
6
)
{
folderName
=
(
char
*
)
"06_car"
;
x
=
142
,
y
=
125
;
w
=
90
;
h
=
39
;
}
if
(
datasetInd
==
7
)
{
folderName
=
(
char
*
)
"07_motocross"
;
x
=
290
,
y
=
43
;
w
=
23
;
h
=
40
;
flagPNG
=
true
;
}
if
(
datasetInd
==
8
)
{
folderName
=
(
char
*
)
"08_volkswagen"
;
x
=
273
,
y
=
77
;
w
=
27
;
h
=
25
;
}
if
(
datasetInd
==
9
)
{
folderName
=
(
char
*
)
"09_carchase"
;
x
=
145
,
y
=
84
;
w
=
54
;
h
=
37
;
}
if
(
datasetInd
==
10
){
folderName
=
(
char
*
)
"10_panda"
;
x
=
58
,
y
=
100
;
w
=
27
;
h
=
22
;
double
x
=
0
,
y
=
0
,
w
=
0
,
h
=
0
;
//Index range
// 1-10 TLD Dataset
// 1-60 VOT 2015 Dataset
int
id
=
videoInd
-
1
;
if
(
datasetInd
==
0
)
{
folderName
=
(
char
*
)
tldFolderName
[
id
];
x
=
tldInitBB
[
id
].
x
;
y
=
tldInitBB
[
id
].
y
;
w
=
tldInitBB
[
id
].
width
;
h
=
tldInitBB
[
id
].
height
;
frameNum
=
tldFrameOffset
[
id
];
flagPNG
=
tldFlagPNG
[
id
];
flagVOT
=
false
;
}
if
(
datasetInd
==
1
)
{
folderName
=
(
char
*
)
votFolderName
[
id
];
x
=
votInitBB
[
id
].
x
;
y
=
votInitBB
[
id
].
y
;
w
=
votInitBB
[
id
].
width
;
h
=
votInitBB
[
id
].
height
;
frameNum
=
votFrameOffset
[
id
];
flagPNG
=
votFlagPNG
[
id
];
flagVOT
=
true
;
}
strcpy
(
tldRootPath
,
rootPath
);
strcat
(
tldRootPath
,
"
\\
"
);
...
...
@@ -127,6 +165,8 @@ namespace cv
char
numStr
[
10
];
strcpy
(
fullPath
,
tldRootPath
);
strcat
(
fullPath
,
"
\\
"
);
if
(
flagVOT
)
strcat
(
fullPath
,
"000"
);
if
(
frameNum
<
10
)
strcat
(
fullPath
,
"0000"
);
else
if
(
frameNum
<
100
)
strcat
(
fullPath
,
"000"
);
else
if
(
frameNum
<
1000
)
strcat
(
fullPath
,
"00"
);
...
...
modules/tracking/src/tldDetector.cpp
View file @
d41639a9
This diff is collapsed.
Click to expand it.
modules/tracking/src/tldDetector.hpp
View file @
d41639a9
...
...
@@ -66,13 +66,15 @@ namespace cv
static
const
cv
::
Size
GaussBlurKernelSize
(
3
,
3
);
class
TLDDetector
{
public
:
TLDDetector
(){}
~
TLDDetector
(){}
inline
double
ensembleClassifierNum
(
const
uchar
*
data
);
inline
void
prepareClassifiers
(
int
rowstep
);
double
ensembleClassifierNum
(
const
uchar
*
data
);
void
prepareClassifiers
(
int
rowstep
);
double
Sr
(
const
Mat_
<
uchar
>&
patch
);
double
ocl_Sr
(
const
Mat_
<
uchar
>&
patch
);
double
Sc
(
const
Mat_
<
uchar
>&
patch
);
...
...
@@ -93,15 +95,14 @@ namespace cv
bool
isObject
,
shouldBeIntegrated
;
};
bool
detect
(
const
Mat
&
img
,
const
Mat
&
imgBlurred
,
Rect2d
&
res
,
std
::
vector
<
LabeledPatch
>&
patches
,
Size
initSize
);
bool
ocl_detect
(
const
Mat
&
img
,
const
Mat
&
imgBlurred
,
Rect2d
&
res
,
std
::
vector
<
LabeledPatch
>&
patches
,
Size
initSize
);
protected
:
bool
ocl_detect
(
const
Mat
&
img
,
const
Mat
&
imgBlurred
,
Rect2d
&
res
,
std
::
vector
<
LabeledPatch
>&
patches
,
Size
initSize
);
friend
class
MyMouseCallbackDEBUG
;
void
computeIntegralImages
(
const
Mat
&
img
,
Mat_
<
double
>&
intImgP
,
Mat_
<
double
>&
intImgP2
){
integral
(
img
,
intImgP
,
intImgP2
,
CV_64F
);
}
inline
bool
patchVariance
(
Mat_
<
double
>&
intImgP
,
Mat_
<
double
>&
intImgP2
,
double
*
originalVariance
,
Point
pt
,
Size
size
);
static
void
computeIntegralImages
(
const
Mat
&
img
,
Mat_
<
double
>&
intImgP
,
Mat_
<
double
>&
intImgP2
){
integral
(
img
,
intImgP
,
intImgP2
,
CV_64F
);
}
static
inline
bool
patchVariance
(
Mat_
<
double
>&
intImgP
,
Mat_
<
double
>&
intImgP2
,
double
*
originalVariance
,
Point
pt
,
Size
size
);
};
}
}
...
...
modules/tracking/src/tldEnsembleClassifier.hpp
View file @
d41639a9
...
...
@@ -54,7 +54,7 @@ namespace cv
double
posteriorProbability
(
const
uchar
*
data
,
int
rowstep
)
const
;
double
posteriorProbabilityFast
(
const
uchar
*
data
)
const
;
void
prepareClassifier
(
int
rowstep
);
private
:
TLDEnsembleClassifier
(
const
std
::
vector
<
Vec4b
>&
meas
,
int
beg
,
int
end
);
static
void
stepPrefSuff
(
std
::
vector
<
Vec4b
>
&
arr
,
int
pos
,
int
len
,
int
gridSize
);
int
code
(
const
uchar
*
data
,
int
rowstep
)
const
;
...
...
modules/tracking/src/tldModel.cpp
View file @
d41639a9
...
...
@@ -140,7 +140,6 @@ namespace cv
detector
->
classifiers
[
k
].
integrate
(
blurredPatch
,
false
);
}
}
//dprintf(("positive patches: %d\nnegative patches: %d\n", (int)positiveExamples.size(), (int)negativeExamples.size()));
}
...
...
@@ -180,16 +179,6 @@ namespace cv
detector
->
classifiers
[
i
].
integrate
(
blurredPatch
,
patches
[
k
].
isObject
);
}
}
/*
if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0)
dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel));
if( negativeIntoEnsemble > 0 )
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n"));*/
}
...
...
@@ -198,9 +187,6 @@ namespace cv
int
positiveIntoModel
=
0
,
negativeIntoModel
=
0
,
positiveIntoEnsemble
=
0
,
negativeIntoEnsemble
=
0
;
if
((
int
)
eForModel
.
size
()
==
0
)
return
;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
for
(
int
k
=
0
;
k
<
(
int
)
eForModel
.
size
();
k
++
)
{
double
sr
=
detector
->
Sr
(
eForModel
[
k
]);
...
...
@@ -231,19 +217,6 @@ namespace cv
detector
->
classifiers
[
i
].
integrate
(
eForEnsemble
[
k
],
isPositive
);
}
}
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency() * 1000;
//printf("Integrate Additional: %fms\n", t);
/*
if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0 )
dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel));
if( negativeIntoEnsemble > 0 )
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n"));*/
}
void
TrackerTLDModel
::
ocl_integrateAdditional
(
const
std
::
vector
<
Mat_
<
uchar
>
>&
eForModel
,
const
std
::
vector
<
Mat_
<
uchar
>
>&
eForEnsemble
,
bool
isPositive
)
...
...
@@ -251,10 +224,6 @@ namespace cv
int
positiveIntoModel
=
0
,
negativeIntoModel
=
0
,
positiveIntoEnsemble
=
0
,
negativeIntoEnsemble
=
0
;
if
((
int
)
eForModel
.
size
()
==
0
)
return
;
//int64 e1, e2;
//double t;
//e1 = getTickCount();
//Prepare batch of patches
int
numOfPatches
=
(
int
)
eForModel
.
size
();
Mat_
<
uchar
>
stdPatches
(
numOfPatches
,
225
);
...
...
@@ -301,19 +270,6 @@ namespace cv
detector
->
classifiers
[
i
].
integrate
(
eForEnsemble
[
k
],
isPositive
);
}
}
//e2 = getTickCount();
//t = (e2 - e1) / getTickFrequency() * 1000;
//printf("Integrate Additional OCL: %fms\n", t);
/*
if( negativeIntoModel > 0 )
dfprintf((stdout, "negativeIntoModel = %d ", negativeIntoModel));
if( positiveIntoModel > 0 )
dfprintf((stdout, "positiveIntoModel = %d ", positiveIntoModel));
if( negativeIntoEnsemble > 0 )
dfprintf((stdout, "negativeIntoEnsemble = %d ", negativeIntoEnsemble));
if( positiveIntoEnsemble > 0 )
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n"));*/
}
//Push the patch to the model
...
...
modules/tracking/src/tldTracker.cpp
View file @
d41639a9
...
...
@@ -45,6 +45,13 @@
namespace
cv
{
TrackerTLD
::
Params
::
Params
(){}
void
TrackerTLD
::
Params
::
read
(
const
cv
::
FileNode
&
/*fn*/
){}
void
TrackerTLD
::
Params
::
write
(
cv
::
FileStorage
&
/*fs*/
)
const
{}
Ptr
<
TrackerTLD
>
TrackerTLD
::
createTracker
(
const
TrackerTLD
::
Params
&
parameters
)
{
return
Ptr
<
tld
::
TrackerTLDImpl
>
(
new
tld
::
TrackerTLDImpl
(
parameters
));
...
...
@@ -112,7 +119,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
Mat_
<
uchar
>
standardPatch
(
STANDARD_PATCH_SIZE
,
STANDARD_PATCH_SIZE
);
std
::
vector
<
TLDDetector
::
LabeledPatch
>
detectorResults
;
//best overlap around 92%
std
::
vector
<
Rect2d
>
candidates
;
std
::
vector
<
double
>
candidatesRes
;
bool
trackerNeedsReInit
=
false
;
...
...
@@ -128,7 +134,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
else
DETECT_FLG
=
tldModel
->
detector
->
detect
(
imageForDetector
,
image_blurred
,
tmpCandid
,
detectorResults
,
tldModel
->
getMinSize
());
}
if
(
(
(
i
==
0
)
&&
!
data
->
failedLastTime
&&
trackerProxy
->
update
(
image
,
tmpCandid
)
)
||
(
DETECT_FLG
))
{
candidates
.
push_back
(
tmpCandid
);
...
...
@@ -144,15 +149,8 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
trackerNeedsReInit
=
true
;
}
}
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)));
//for( int i = 0; i < (int)candidatesRes.size(); i++ )
//dprintf(("\tcandidatesRes[%d] = %f\n", i, candidatesRes[i]));
//data->printme();
//tldModel->printme(stdout);
if
(
it
==
candidatesRes
.
end
()
)
{
data
->
confident
=
false
;
...
...
@@ -169,16 +167,7 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
#if 1
if
(
it
!=
candidatesRes
.
end
()
)
{
resample
(
imageForDetector
,
candidates
[
it
-
candidatesRes
.
begin
()],
standardPatch
);
//dfprintf((stderr, "%d %f %f\n", data->frameNum, tldModel->Sc(standardPatch), tldModel->Sr(standardPatch)));
//if( candidatesRes.size() == 2 && it == (candidatesRes.begin() + 1) )
//dfprintf((stderr, "detector WON\n"));
}
else
{
//dfprintf((stderr, "%d x x\n", data->frameNum));
}
#endif
if
(
*
it
>
CORE_THRESHOLD
)
...
...
@@ -209,7 +198,6 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
detectorResults
[
i
].
isObject
=
expertResult
;
}
tldModel
->
integrateRelabeled
(
imageForDetector
,
image_blurred
,
detectorResults
);
//dprintf(("%d relabeled by nExpert\n", negRelabeled));
pExpert
.
additionalExamples
(
examplesForModel
,
examplesForEnsemble
);
if
(
ocl
::
haveOpenCL
())
tldModel
->
ocl_integrateAdditional
(
examplesForModel
,
examplesForEnsemble
,
true
);
...
...
@@ -296,7 +284,6 @@ Data::Data(Rect2d initBox)
minSize
.
width
=
(
int
)(
initBox
.
width
*
20.0
/
minDim
);
minSize
.
height
=
(
int
)(
initBox
.
height
*
20.0
/
minDim
);
frameNum
=
0
;
//dprintf(("minSize = %dx%d\n", minSize.width, minSize.height));
}
void
Data
::
printme
(
FILE
*
port
)
...
...
modules/tracking/src/tldTracker.hpp
View file @
d41639a9
...
...
@@ -52,12 +52,6 @@
namespace
cv
{
TrackerTLD
::
Params
::
Params
(){}
void
TrackerTLD
::
Params
::
read
(
const
cv
::
FileNode
&
/*fn*/
){}
void
TrackerTLD
::
Params
::
write
(
cv
::
FileStorage
&
/*fs*/
)
const
{}
namespace
tld
{
class
TrackerProxy
...
...
@@ -128,7 +122,6 @@ public:
void
read
(
const
FileNode
&
fn
);
void
write
(
FileStorage
&
fs
)
const
;
protected
:
class
Pexpert
{
public
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment