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
bf0c8712
Commit
bf0c8712
authored
Nov 03, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #341 from Auron-X:TLD/VOT2015_Datasets_Support
parents
d255138c
1db7b6e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1057 additions
and
222 deletions
+1057
-222
dataset.hpp
modules/datasets/include/opencv2/datasets/dataset.hpp
+21
-0
track_vot.hpp
modules/datasets/include/opencv2/datasets/track_vot.hpp
+96
-0
track_vot.cpp
modules/datasets/samples/track_vot.cpp
+100
-0
track_vot.cpp
modules/datasets/src/track_vot.cpp
+236
-0
CMakeLists.txt
modules/tracking/CMakeLists.txt
+1
-1
tldDataset.hpp
modules/tracking/include/opencv2/tracking/tldDataset.hpp
+1
-1
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+0
-0
multiTracker_dataset.cpp
modules/tracking/samples/multiTracker_dataset.cpp
+231
-0
tracker_dataset.cpp
modules/tracking/samples/tracker_dataset.cpp
+75
-80
multiTracker.cpp
modules/tracking/src/multiTracker.cpp
+0
-0
multiTracker.hpp
modules/tracking/src/multiTracker.hpp
+58
-0
multiTracker_alt.cpp
modules/tracking/src/multiTracker_alt.cpp
+121
-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/datasets/include/opencv2/datasets/dataset.hpp
View file @
bf0c8712
...
...
@@ -477,6 +477,27 @@ To run benchmark execute:
./opencv/build/bin/example_datasets_tr_svt_benchmark -p=/home/user/path_to_unpacked_folders/svt/svt1/
~~~
@defgroup datasets_track Tracking
### VOT 2015 Database
Implements loading dataset:
"VOT 2015 dataset comprises 60 short sequences showing various objects in challenging backgrounds.
The sequences were chosen from a large pool of sequences including the ALOV dataset, OTB2 dataset,
non-tracking datasets, Computer Vision Online, Professor Bob Fisher’s Image Database, Videezy,
Center for Research in Computer Vision, University of Central Florida, USA, NYU Center for Genomics
and Systems Biology, Data Wrangling, Open Access Directory and Learning and Recognition in Vision
Group, INRIA, France. The VOT sequence selection protocol was applied to obtain a representative
set of challenging sequences.": <http://box.vicos.si/vot/vot2015.zip>
Usage:
-# From link above download dataset file: `vot2015.zip`
-# Unpack `vot2015.zip` into folder: `VOT2015/`
-# To load data run:
~~~
./opencv/build/bin/example_datasets_track_vot -p=/home/user/path_to_unpacked_files/VOT2015/
~~~
@}
*/
...
...
modules/datasets/include/opencv2/datasets/track_vot.hpp
0 → 100644
View file @
bf0c8712
/*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) 2014, Itseez Inc, 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 Itseez Inc 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_DATASETS_TRACK_VOT_HPP
#define OPENCV_DATASETS_TRACK_VOT_HPP
#include <string>
#include <vector>
#include "opencv2/datasets/dataset.hpp"
#include "opencv2/datasets/util.hpp"
using
namespace
std
;
namespace
cv
{
namespace
datasets
{
//! @addtogroup datasets_track
//! @{
struct
TRACK_votObj
:
public
Object
{
int
id
;
std
::
string
imagePath
;
vector
<
Point2d
>
gtbb
;
};
class
CV_EXPORTS
TRACK_vot
:
public
Dataset
{
public
:
static
Ptr
<
TRACK_vot
>
create
();
virtual
void
load
(
const
std
::
string
&
path
)
=
0
;
virtual
int
getDatasetsNum
()
=
0
;
virtual
int
getDatasetLength
(
int
id
)
=
0
;
virtual
bool
initDataset
(
int
id
)
=
0
;
virtual
bool
getNextFrame
(
Mat
&
frame
)
=
0
;
virtual
vector
<
Point2d
>
getGT
()
=
0
;
protected
:
vector
<
vector
<
Ptr
<
TRACK_votObj
>
>
>
data
;
int
activeDatasetID
;
int
frameCounter
;
};
//! @}
}
}
#endif
modules/datasets/samples/track_vot.cpp
0 → 100644
View file @
bf0c8712
/*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) 2014, Itseez Inc, 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 Itseez Inc 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/datasets/track_vot.hpp"
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
datasets
;
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
keys
=
"{ help h usage ? | | show this message }"
"{ path p |true| path to folder with dataset }"
"{ datasetID id |1| Dataset ID}"
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
path
(
parser
.
get
<
string
>
(
"path"
));
int
datasetID
(
parser
.
get
<
int
>
(
"datasetID"
));
if
(
parser
.
has
(
"help"
)
||
path
==
"true"
)
{
parser
.
printMessage
();
getchar
();
return
-
1
;
}
Ptr
<
TRACK_vot
>
dataset
=
TRACK_vot
::
create
();
dataset
->
load
(
path
);
printf
(
"Datasets number: %d
\n
"
,
dataset
->
getDatasetsNum
());
for
(
int
i
=
1
;
i
<=
dataset
->
getDatasetsNum
();
i
++
)
printf
(
"
\t
Dataset #%d size: %d
\n
"
,
i
,
dataset
->
getDatasetLength
(
i
));
dataset
->
initDataset
(
datasetID
);
for
(
int
i
=
0
;
i
<
dataset
->
getDatasetLength
(
datasetID
);
i
++
)
{
Mat
frame
;
if
(
!
dataset
->
getNextFrame
(
frame
))
break
;
//Draw Ground Truth BB
vector
<
Point2d
>
gtPoints
=
dataset
->
getGT
();
for
(
int
j
=
0
;
j
<
(
int
)(
gtPoints
.
size
()
-
1
);
j
++
)
line
(
frame
,
gtPoints
[
j
],
gtPoints
[
j
+
1
],
Scalar
(
0
,
255
,
0
),
2
);
line
(
frame
,
gtPoints
[
0
],
gtPoints
[(
int
)(
gtPoints
.
size
()
-
1
)],
Scalar
(
0
,
255
,
0
),
2
);
imshow
(
"VOT 2015 DATASET TEST..."
,
frame
);
waitKey
(
100
);
}
getchar
();
return
0
;
}
\ No newline at end of file
modules/datasets/src/track_vot.cpp
0 → 100644
View file @
bf0c8712
/*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) 2014, Itseez Inc, 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 Itseez Inc 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/datasets/track_vot.hpp"
#include <sys/stat.h>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
using
namespace
std
;
namespace
cv
{
namespace
datasets
{
class
TRACK_votImpl
:
public
TRACK_vot
{
public
:
//Constructor
TRACK_votImpl
()
{
activeDatasetID
=
1
;
frameCounter
=
0
;
}
//Destructor
virtual
~
TRACK_votImpl
()
{}
//Load Dataset
virtual
void
load
(
const
string
&
path
);
protected
:
virtual
int
getDatasetsNum
();
virtual
int
getDatasetLength
(
int
id
);
virtual
bool
initDataset
(
int
id
);
virtual
bool
getNextFrame
(
Mat
&
frame
);
virtual
vector
<
Point2d
>
getGT
();
void
loadDataset
(
const
string
&
path
);
string
numberToString
(
int
number
);
};
void
TRACK_votImpl
::
load
(
const
string
&
path
)
{
loadDataset
(
path
);
}
string
TRACK_votImpl
::
numberToString
(
int
number
)
{
string
out
;
char
numberStr
[
9
];
sprintf
(
numberStr
,
"%u"
,
number
);
for
(
unsigned
int
i
=
0
;
i
<
8
-
strlen
(
numberStr
);
++
i
)
{
out
+=
"0"
;
}
out
+=
numberStr
;
return
out
;
}
inline
bool
fileExists
(
const
std
::
string
&
name
)
{
struct
stat
buffer
;
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
}
void
TRACK_votImpl
::
loadDataset
(
const
string
&
rootPath
)
{
string
nameListPath
=
rootPath
+
"/list.txt"
;
ifstream
namesList
(
nameListPath
.
c_str
());
vector
<
int
>
datasetsLengths
;
string
datasetName
;
if
(
namesList
.
is_open
())
{
int
currDatasetID
=
0
;
//All datasets/folders loop
while
(
getline
(
namesList
,
datasetName
))
{
currDatasetID
++
;
vector
<
Ptr
<
TRACK_votObj
>
>
objects
;
//All frames/images loop
Ptr
<
TRACK_votObj
>
currDataset
(
new
TRACK_votObj
);
//Open dataset's ground truth file
string
gtListPath
=
rootPath
+
"/"
+
datasetName
+
"/groundtruth.txt"
;
ifstream
gtList
(
gtListPath
.
c_str
());
if
(
!
gtList
.
is_open
())
printf
(
"Error to open groundtruth.txt!!!"
);
//Make a list of datasets lengths
int
currFrameID
=
1
;
if
(
currDatasetID
==
0
)
printf
(
"VOT 2015 Dataset Initialization...
\n
"
);
bool
trFLG
=
true
;
do
{
currFrameID
++
;
string
fullPath
=
rootPath
+
"/"
+
datasetName
+
"/"
+
numberToString
(
currFrameID
)
+
".jpg"
;
if
(
!
fileExists
(
fullPath
))
break
;
//Make VOT Object
Ptr
<
TRACK_votObj
>
currObj
(
new
TRACK_votObj
);
currObj
->
imagePath
=
fullPath
;
currObj
->
id
=
currFrameID
;
//Get Ground Truth data
double
x1
=
0
,
y1
=
0
,
x2
=
0
,
y2
=
0
,
x3
=
0
,
y3
=
0
,
x4
=
0
,
y4
=
0
;
string
tmp
;
getline
(
gtList
,
tmp
);
sscanf
(
tmp
.
c_str
(),
"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf"
,
&
x1
,
&
y1
,
&
x2
,
&
y2
,
&
x3
,
&
y3
,
&
x4
,
&
y4
);
currObj
->
gtbb
.
push_back
(
Point2d
(
x1
,
y1
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x2
,
y2
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x3
,
y3
));
currObj
->
gtbb
.
push_back
(
Point2d
(
x4
,
y4
));
//Add object to storage
objects
.
push_back
(
currObj
);
}
while
(
trFLG
);
datasetsLengths
.
push_back
(
currFrameID
-
1
);
data
.
push_back
(
objects
);
}
}
else
{
printf
(
"Couldn't find a *list.txt* in VOT 2015 folder!!!"
);
}
namesList
.
close
();
return
;
}
int
TRACK_votImpl
::
getDatasetsNum
()
{
return
(
int
)(
data
.
size
());
}
int
TRACK_votImpl
::
getDatasetLength
(
int
id
)
{
if
(
id
>
0
&&
id
<=
(
int
)
data
.
size
())
return
(
int
)(
data
[
id
-
1
].
size
());
else
{
printf
(
"Dataset ID is out of range...
\n
Allowed IDs are: 1~%d
\n
"
,
(
int
)
data
.
size
());
return
-
1
;
}
}
bool
TRACK_votImpl
::
initDataset
(
int
id
)
{
if
(
id
>
0
&&
id
<=
(
int
)
data
.
size
())
{
activeDatasetID
=
id
;
return
true
;
}
else
{
printf
(
"Dataset ID is out of range...
\n
Allowed IDs are: 1~%d
\n
"
,
(
int
)
data
.
size
());
return
false
;
}
}
bool
TRACK_votImpl
::
getNextFrame
(
Mat
&
frame
)
{
if
(
frameCounter
>=
(
int
)
data
[
activeDatasetID
-
1
].
size
())
return
false
;
string
imgPath
=
data
[
activeDatasetID
-
1
][
frameCounter
]
->
imagePath
;
frame
=
imread
(
imgPath
);
frameCounter
++
;
return
!
frame
.
empty
();
}
Ptr
<
TRACK_vot
>
TRACK_vot
::
create
()
{
return
Ptr
<
TRACK_votImpl
>
(
new
TRACK_votImpl
);
}
vector
<
Point2d
>
TRACK_votImpl
::
getGT
()
{
Ptr
<
TRACK_votObj
>
currObj
=
data
[
activeDatasetID
-
1
][
frameCounter
-
1
];
return
currObj
->
gtbb
;
}
}
}
modules/tracking/CMakeLists.txt
View file @
bf0c8712
set
(
the_description
"Tracking API"
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui
)
ocv_define_module
(
tracking opencv_imgproc opencv_core opencv_video opencv_highgui
opencv_datasets
)
modules/tracking/include/opencv2/tracking/tldDataset.hpp
View file @
bf0c8712
...
...
@@ -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 @
bf0c8712
This diff is collapsed.
Click to expand it.
modules/tracking/samples/multiTracker_dataset.cpp
0 → 100644
View file @
bf0c8712
/*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/datasets/track_vot.hpp"
#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
;
using
namespace
cv
::
datasets
;
#define NUM_TEST_FRAMES 1000
static
Mat
image
;
static
bool
paused
;
static
bool
selectObjects
=
false
;
static
bool
startSelection
=
false
;
vector
<
Rect2d
>
boundingBoxes
;
int
targetsCnt
=
0
;
int
targetsNum
=
0
;
Rect2d
boundingBox
;
static
const
char
*
keys
=
{
"{@tracker_algorithm | | Tracker algorithm }"
"{@target_num |1| Number of targets }"
"{@dataset_path |true| Dataset path }"
"{@dataset_id |1| Dataset ID }"
};
static
void
onMouse
(
int
event
,
int
x
,
int
y
,
int
,
void
*
)
{
if
(
!
selectObjects
)
{
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
);
boundingBoxes
.
push_back
(
boundingBox
);
targetsCnt
++
;
if
(
targetsCnt
==
targetsNum
)
{
paused
=
false
;
selectObjects
=
true
;
}
startSelection
=
false
;
break
;
case
EVENT_MOUSEMOVE
:
if
(
startSelection
&&
!
selectObjects
)
{
//draw the bounding box
Mat
currentFrame
;
image
.
copyTo
(
currentFrame
);
for
(
int
i
=
0
;
i
<
(
int
)
boundingBoxes
.
size
();
i
++
)
rectangle
(
currentFrame
,
boundingBoxes
[
i
],
Scalar
(
255
,
0
,
0
),
2
,
1
);
rectangle
(
currentFrame
,
Point
((
int
)
boundingBox
.
x
,
(
int
)
boundingBox
.
y
),
Point
(
x
,
y
),
Scalar
(
255
,
0
,
0
),
2
,
1
);
imshow
(
"Tracking API"
,
currentFrame
);
}
break
;
}
}
}
static
void
help
()
{
cout
<<
"
\n
This example shows the functionality of
\"
Long-term optical tracking API
\"
"
"TLD dataset ID: 1~10, VOT2015 dataset ID: 1~60
\n
"
"-- pause video [p] and draw a bounding boxes around the targets to start the tracker
\n
"
"Example:
\n
"
"./example_tracking_multiTracker_dataset<tracker_algorithm> <number_of_targets> <dataset_path> <dataset_id>
\n
"
<<
endl
;
cout
<<
"
\n\n
Hot keys:
\n
"
"
\t
q - quit the program
\n
"
"
\t
p - pause video
\n
"
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
tracker_algorithm
=
parser
.
get
<
string
>
(
0
);
targetsNum
=
parser
.
get
<
int
>
(
1
);
string
datasetRootPath
=
parser
.
get
<
string
>
(
2
);
int
datasetID
=
parser
.
get
<
int
>
(
3
);
if
(
tracker_algorithm
.
empty
()
||
datasetRootPath
.
empty
()
||
targetsNum
<
1
)
{
help
();
return
-
1
;
}
Mat
frame
;
paused
=
false
;
namedWindow
(
"Tracking API"
,
0
);
setMouseCallback
(
"Tracking API"
,
onMouse
,
0
);
MultiTrackerTLD
mt
;
//Init Dataset
Ptr
<
TRACK_vot
>
dataset
=
TRACK_vot
::
create
();
dataset
->
load
(
datasetRootPath
);
dataset
->
initDataset
(
datasetID
);
//Read first frame
dataset
->
getNextFrame
(
frame
);
frame
.
copyTo
(
image
);
for
(
int
i
=
0
;
i
<
(
int
)
boundingBoxes
.
size
();
i
++
)
rectangle
(
image
,
boundingBoxes
[
i
],
Scalar
(
255
,
0
,
0
),
2
,
1
);
imshow
(
"Tracking API"
,
image
);
bool
initialized
=
false
;
paused
=
true
;
int
frameCounter
=
0
;
//Time measurment
int64
e3
=
getTickCount
();
for
(;;)
{
if
(
!
paused
)
{
//Time measurment
int64
e1
=
getTickCount
();
if
(
initialized
){
if
(
!
dataset
->
getNextFrame
(
frame
))
break
;
frame
.
copyTo
(
image
);
}
if
(
!
initialized
&&
selectObjects
)
{
//Initialize the tracker and add targets
for
(
int
i
=
0
;
i
<
(
int
)
boundingBoxes
.
size
();
i
++
)
{
if
(
!
mt
.
addTarget
(
frame
,
boundingBoxes
[
i
],
tracker_algorithm
))
{
cout
<<
"Trackers Init Error!!!"
;
return
0
;
}
rectangle
(
frame
,
boundingBoxes
[
i
],
mt
.
colors
[
0
],
2
,
1
);
}
initialized
=
true
;
}
else
if
(
initialized
)
{
//Update all targets
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
);
frameCounter
++
;
//Time measurment
int64
e2
=
getTickCount
();
double
t1
=
(
e2
-
e1
)
/
getTickFrequency
();
cout
<<
frameCounter
<<
"
\t
frame : "
<<
t1
*
1000.0
<<
"ms"
<<
endl
;
}
char
c
=
(
char
)
waitKey
(
2
);
if
(
c
==
'q'
)
break
;
if
(
c
==
'p'
)
paused
=
!
paused
;
//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/samples/t
ld_tes
t.cpp
→
modules/tracking/samples/t
racker_datase
t.cpp
View file @
bf0c8712
...
...
@@ -39,17 +39,21 @@
//
//M*/
#include "opencv2/datasets/track_vot.hpp"
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
datasets
;
#define NUM_TEST_FRAMES
1
00
#define TEST_VIDEO_INDEX
7
//TLD Dataset Video Index from 1-10
#define NUM_TEST_FRAMES
3
00
#define TEST_VIDEO_INDEX
1
//TLD Dataset Video Index from 1-10
//#define RECORD_VIDEO_FLG
static
Mat
image
;
...
...
@@ -58,6 +62,12 @@ static bool paused;
static
bool
selectObject
=
false
;
static
bool
startSelection
=
false
;
static
const
char
*
keys
=
{
"{@tracker_algorithm | | Tracker algorithm }"
"{@dataset_path |true| Dataset path }"
"{@dataset_id |1| Dataset ID }"
};
static
void
onMouse
(
int
event
,
int
x
,
int
y
,
int
,
void
*
)
{
if
(
!
selectObject
)
...
...
@@ -93,19 +103,39 @@ static void onMouse(int event, int x, int y, int, void*)
}
}
int
main
()
static
void
help
()
{
cout
<<
"
\n
This example shows the functionality of
\"
Long-term optical tracking API
\"
"
"TLD dataset ID: 1~10, VOT2015 dataset ID: 1~60
\n
"
"-- pause video [p] and draw a bounding box around the target to start the tracker
\n
"
"Example:
\n
"
"./example_tracking_tracker_dataset <tracker_algorithm> <dataset_path> <dataset_id>
\n
"
<<
endl
;
cout
<<
"
\n\n
Hot keys:
\n
"
"
\t
q - quit the program
\n
"
"
\t
p - pause video
\n
"
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
//
// "MIL", "BOOSTING", "MEDIANFLOW", "TLD"
//
string
tracker_algorithm_name
=
"TLD"
;
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
tracker_algorithm
=
parser
.
get
<
string
>
(
0
);
string
datasetRootPath
=
parser
.
get
<
string
>
(
1
);
int
datasetID
=
parser
.
get
<
int
>
(
2
);
if
(
tracker_algorithm
.
empty
()
||
datasetRootPath
.
empty
())
{
help
();
return
-
1
;
}
Mat
frame
;
paused
=
false
;
namedWindow
(
"Tracking API"
,
0
);
setMouseCallback
(
"Tracking API"
,
onMouse
,
0
);
Ptr
<
Tracker
>
tracker
=
Tracker
::
create
(
tracker_algorithm_name
);
//Create Tracker
Ptr
<
Tracker
>
tracker
=
Tracker
::
create
(
tracker_algorithm
);
if
(
tracker
==
NULL
)
{
cout
<<
"***Error in the instantiation of the tracker...***
\n
"
;
...
...
@@ -113,107 +143,72 @@ int main()
return
0
;
}
//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
;
boundingBox
=
tld
::
tld_InitDataset
(
TEST_VIDEO_INDEX
,
"D:/opencv/TLD_dataset"
);
frame
=
tld
::
tld_getNextDatasetFrame
();
frame
.
copyTo
(
image
);
//Init Dataset
Ptr
<
TRACK_vot
>
dataset
=
TRACK_vot
::
create
();
dataset
->
load
(
datasetRootPath
);
dataset
->
initDataset
(
datasetID
);
// Setup output video
#ifdef RECORD_VIDEO_FLG
String
outputFilename
=
"test.avi"
;
VideoWriter
outputVideo
;
outputVideo
.
open
(
outputFilename
,
-
1
,
30
,
Size
(
image
.
cols
,
image
.
rows
));
if
(
!
outputVideo
.
isOpened
())
{
std
::
cout
<<
"!!! Output video could not be opened"
<<
std
::
endl
;
getchar
();
return
;
}
#endif
//Read first frame
dataset
->
getNextFrame
(
frame
);
frame
.
copyTo
(
image
);
rectangle
(
image
,
boundingBox
,
Scalar
(
255
,
0
,
0
),
2
,
1
);
imshow
(
"Tracking API"
,
image
);
bool
initialized
=
false
;
paused
=
true
;
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
;
//Time measurment
int64
e1
=
getTickCount
();
if
(
initialized
){
if
(
!
dataset
->
getNextFrame
(
frame
))
break
;
frame
.
copyTo
(
image
);
}
frame
.
copyTo
(
image
);
if
(
selectObject
)
if
(
!
initialized
&&
selectObject
)
{
if
(
!
initialized
)
//initializes the tracker
if
(
!
tracker
->
init
(
frame
,
boundingBox
))
{
//initializes the tracker
if
(
!
tracker
->
init
(
frame
,
boundingBox
))
{
cout
<<
"***Could not initialize tracker...***
\n
"
;
return
0
;
}
initialized
=
true
;
rectangle
(
image
,
boundingBox
,
Scalar
(
255
,
0
,
0
),
2
,
1
);
cout
<<
"***Could not initialize tracker...***
\n
"
;
return
-
1
;
}
else
initialized
=
true
;
}
else
if
(
initialized
)
{
//updates the tracker
if
(
tracker
->
update
(
frame
,
boundingBox
))
{
//updates the tracker
if
(
tracker
->
update
(
frame
,
boundingBox
))
{
rectangle
(
image
,
boundingBox
,
Scalar
(
255
,
0
,
0
),
2
,
1
);
}
rectangle
(
image
,
boundingBox
,
Scalar
(
255
,
0
,
0
),
2
,
1
);
}
}
imshow
(
"Tracking API"
,
image
);
#ifdef RECORD_VIDEO_FLG
outputVideo
<<
image
;
#endif
frameCounter
++
;
//Time measurment
int64
e2
=
getTickCount
();
double
t1
=
(
e2
-
e1
)
/
getTickFrequency
();
cout
<<
frameCounter
<<
"
\t
frame : "
<<
t1
*
1000.0
<<
"ms"
<<
endl
;
//waitKey(0);
}
char
c
=
(
char
)
waitKey
(
2
);
if
(
c
==
'q'
)
break
;
if
(
c
==
'p'
)
paused
=
!
paused
;
//waitKey(0);
}
//Time measurment
...
...
modules/tracking/src/multiTracker.cpp
View file @
bf0c8712
This diff is collapsed.
Click to expand it.
modules/tracking/src/multiTracker.hpp
0 → 100644
View file @
bf0c8712
/*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/multiTracker_alt.cpp
0 → 100644
View file @
bf0c8712
/*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 "precomp.hpp"
namespace
cv
{
// constructor
MultiTracker
::
MultiTracker
(
const
String
&
trackerType
)
:
defaultAlgorithm
(
trackerType
){};
// destructor
MultiTracker
::~
MultiTracker
(){};
// add an object to be tracked, defaultAlgorithm is used
bool
MultiTracker
::
add
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
){
// quit if defaultAlgorithm has not been configured
if
(
defaultAlgorithm
==
""
){
printf
(
"Default algorithm was not defined!
\n
"
);
return
false
;
}
// add a new tracked object
return
add
(
defaultAlgorithm
.
c_str
(),
image
,
boundingBox
);
};
// add a new tracked object
bool
MultiTracker
::
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
const
Rect2d
&
boundingBox
){
// declare a new tracker
Ptr
<
Tracker
>
newTracker
=
Tracker
::
create
(
trackerType
);
// add the created tracker algorithm to the trackers list
trackerList
.
push_back
(
newTracker
);
// add the ROI to the bounding box list
objects
.
push_back
(
boundingBox
);
// initialize the created tracker
return
trackerList
.
back
()
->
init
(
image
,
boundingBox
);
};
// add a set of objects to be tracked
bool
MultiTracker
::
add
(
const
String
&
trackerType
,
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
){
// status of the tracker addition
bool
stat
=
false
;
// add tracker for all input objects
for
(
unsigned
i
=
0
;
i
<
boundingBox
.
size
();
i
++
){
stat
=
add
(
trackerType
,
image
,
boundingBox
[
i
]);
if
(
!
stat
)
break
;
}
// return the status
return
stat
;
};
// add a set of object to be tracked, defaultAlgorithm is used.
bool
MultiTracker
::
add
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
boundingBox
){
// quit if defaultAlgorithm has not been configured
if
(
defaultAlgorithm
==
""
){
printf
(
"Default algorithm was not defined!
\n
"
);
return
false
;
}
return
add
(
defaultAlgorithm
.
c_str
(),
image
,
boundingBox
);
};
// update position of the tracked objects, the result is stored in internal storage
bool
MultiTracker
::
update
(
const
Mat
&
image
){
for
(
unsigned
i
=
0
;
i
<
trackerList
.
size
();
i
++
){
trackerList
[
i
]
->
update
(
image
,
objects
[
i
]);
}
return
true
;
};
// update position of the tracked objects, the result is copied to external variable
bool
MultiTracker
::
update
(
const
Mat
&
image
,
std
::
vector
<
Rect2d
>
&
boundingBox
){
update
(
image
);
boundingBox
=
objects
;
return
true
;
};
}
/* namespace cv */
\ No newline at end of file
modules/tracking/src/tldDataset.cpp
View file @
bf0c8712
...
...
@@ -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 @
bf0c8712
This diff is collapsed.
Click to expand it.
modules/tracking/src/tldDetector.hpp
View file @
bf0c8712
...
...
@@ -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 @
bf0c8712
...
...
@@ -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 @
bf0c8712
...
...
@@ -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 @
bf0c8712
...
...
@@ -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 @
bf0c8712
...
...
@@ -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