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
c8b31cd9
Commit
c8b31cd9
authored
Jul 10, 2014
by
Alex Leontiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vadim
parent
c06bb0dc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
59 deletions
+23
-59
benchmark.cpp
modules/tracking/samples/benchmark.cpp
+5
-26
tracker.cpp
modules/tracking/samples/tracker.cpp
+0
-14
trackerMedianFlow.cpp
modules/tracking/src/trackerMedianFlow.cpp
+5
-1
trackerTLD.cpp
modules/tracking/src/trackerTLD.cpp
+13
-18
No files found.
modules/tracking/samples/benchmark.cpp
View file @
c8b31cd9
...
...
@@ -23,18 +23,6 @@ vector<Scalar> palette;
void
print_table
(
char
*
videos
[],
int
videoNum
,
char
*
algorithms
[],
int
algNum
,
const
vector
<
vector
<
char
*>
>&
results
,
char
*
tableName
);
static
void
listTrackers
(){
vector
<
String
>
algorithms
;
Algorithm
::
getList
(
algorithms
);
cout
<<
"
\n
Available tracker algorithms:
\n
"
;
for
(
size_t
i
=
0
;
i
<
algorithms
.
size
();
i
++
){
const
char
*
algoname
=
algorithms
[
i
].
c_str
();
char
*
pos
=
NULL
;
if
((
pos
=
strstr
((
char
*
)
algoname
,
"TRACKER."
))
!=
NULL
){
printf
(
"%s
\n
"
,
pos
+
8
);
}
}
}
static
int
lineToRect
(
char
*
line
,
Rect2d
&
res
){
char
*
ptr
=
line
,
*
pos
=
ptr
;
if
(
line
==
NULL
||
line
[
0
]
==
'\0'
){
...
...
@@ -75,21 +63,11 @@ static void help(){
cout
<<
"
\n\n
Hot keys:
\n
"
"
\t
q - quit the program
\n
"
"
\t
p - pause video
\n
"
;
listTrackers
();
exit
(
EXIT_SUCCESS
);
}
static
void
parseCommandLineArgs
(
int
argc
,
char
**
argv
,
char
*
videos
[],
char
*
gts
[],
int
*
vc
,
char
*
algorithms
[],
char
*
initBoxes
[][
CMDLINEMAX
],
int
*
ac
){
vector
<
String
>
trackers
;
Algorithm
::
getList
(
trackers
);
for
(
int
i
=
0
;
i
<
(
int
)
trackers
.
size
();
i
++
){
if
(
strstr
(
trackers
[
i
].
c_str
(),
"TRACKER."
)
!=
trackers
[
i
].
c_str
()){
trackers
.
erase
(
trackers
.
begin
()
+
i
);
i
--
;
}
}
*
ac
=*
vc
=
0
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
){
if
(
argv
[
i
][
0
]
==
'-'
){
...
...
@@ -105,13 +83,14 @@ static void parseCommandLineArgs(int argc, char** argv,char* videos[],char* gts[
}
continue
;
}
bool
isVideo
=
tru
e
;
for
(
int
j
=
0
;
j
<
(
int
)
trackers
.
size
()
;
j
++
){
if
(
strcmp
(
argv
[
i
],
trackers
[
j
].
c_str
()
+
8
)
==
0
){
isVideo
=
fals
e
;
bool
isVideo
=
fals
e
;
for
(
int
j
=
0
,
len
=
strlen
(
argv
[
i
]);
j
<
len
;
j
++
){
if
(
!
(
'A'
<=
argv
[
i
][
j
]
&&
argv
[
i
][
j
]
<=
'Z'
)
&&
argv
[
i
][
j
]
!=
'.'
){
isVideo
=
tru
e
;
break
;
}
}
if
(
isVideo
){
videos
[
*
vc
]
=
argv
[
i
];
i
++
;
...
...
modules/tracking/samples/tracker.cpp
View file @
c8b31cd9
...
...
@@ -19,19 +19,6 @@ static const char* keys =
"{@start_frame |0| Start frame }"
"{@bounding_frame |0,0,0,0| Initial bounding frame}"
};
static
void
listTrackers
(){
vector
<
String
>
algorithms
;
Algorithm
::
getList
(
algorithms
);
cout
<<
"
\n
Available tracker algorithms:
\n
"
;
for
(
size_t
i
=
0
;
i
<
algorithms
.
size
();
i
++
){
const
char
*
algoname
=
algorithms
[
i
].
c_str
();
char
*
pos
=
NULL
;
if
((
pos
=
strstr
((
char
*
)
algoname
,
"TRACKER."
))
!=
NULL
){
printf
(
"%s
\n
"
,
pos
+
8
);
}
}
}
static
void
onMouse
(
int
event
,
int
x
,
int
y
,
int
,
void
*
)
{
if
(
!
selectObject
)
...
...
@@ -78,7 +65,6 @@ static void help()
cout
<<
"
\n\n
Hot keys:
\n
"
"
\t
q - quit the program
\n
"
"
\t
p - pause video
\n
"
;
listTrackers
();
}
int
main
(
int
argc
,
char
**
argv
){
...
...
modules/tracking/src/trackerMedianFlow.cpp
View file @
c8b31cd9
...
...
@@ -77,8 +77,12 @@ namespace cv
class
TrackerMedianFlowImpl
:
public
TrackerMedianFlow
{
public
:
TrackerMedianFlowImpl
(
TrackerMedianFlow
::
Params
paramsIn
)
:
termcrit
(
TermCriteria
::
COUNT
|
TermCriteria
::
EPS
,
20
,
0.3
){
params
=
paramsIn
;
isInit
=
false
;}
bool
medianFlowImpl
(
Mat
oldImage
,
Mat
newImage
,
Rect2d
&
oldBox
);
void
read
(
const
FileNode
&
fn
);
void
write
(
FileStorage
&
fs
)
const
;
private
:
bool
initImpl
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
);
bool
updateImpl
(
const
Mat
&
image
,
Rect2d
&
boundingBox
);
bool
medianFlowImpl
(
Mat
oldImage
,
Mat
newImage
,
Rect2d
&
oldBox
);
Rect2d
vote
(
const
std
::
vector
<
Point2f
>&
oldPoints
,
const
std
::
vector
<
Point2f
>&
newPoints
,
const
Rect2d
&
oldRect
,
Point2f
&
mD
);
//FIXME: this can be optimized: current method uses sort->select approach, there are O(n) selection algo for median; besides
//it makes copy all the time
...
...
modules/tracking/src/trackerTLD.cpp
View file @
c8b31cd9
...
...
@@ -102,7 +102,7 @@ private:
TLDDetector
*
detector_
;
};
class
Data
:
public
TrackerTLD
::
Private
{
class
Data
{
public
:
Data
(
Rect2d
initBox
);
Size
getMinSize
(){
return
minSize
;}
...
...
@@ -118,7 +118,7 @@ private:
class
TrackerTLDModel
;
class
TLDDetector
:
public
TrackerTLD
::
Private
{
class
TLDDetector
{
public
:
TLDDetector
(
const
TrackerTLD
::
Params
&
params
,
Ptr
<
TrackerModel
>
model_in
)
:
model
(
model_in
),
params_
(
params
){}
~
TLDDetector
(){}
...
...
@@ -128,6 +128,7 @@ public:
protected
:
friend
class
MyMouseCallbackDEBUG
;
Ptr
<
TrackerModel
>
model
;
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
);
bool
ensembleClassifier
(
const
uchar
*
data
,
int
rowstep
){
return
ensembleClassifierNum
(
data
,
rowstep
)
>
0.5
;}
double
ensembleClassifierNum
(
const
uchar
*
data
,
int
rowstep
);
...
...
@@ -168,7 +169,7 @@ class TrackerProxyImpl : public TrackerProxy{
public
:
TrackerProxyImpl
(
Tparams
params
=
Tparams
())
:
params_
(
params
){}
bool
init
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
){
trackerPtr
=
Ptr
<
T
>
(
new
T
(
params_
)
);
trackerPtr
=
T
::
createTracker
(
);
return
trackerPtr
->
init
(
image
,
boundingBox
);
}
bool
update
(
const
Mat
&
image
,
Rect2d
&
boundingBox
){
...
...
@@ -223,7 +224,7 @@ class TrackerTLDImpl : public TrackerTLD
TrackerTLD
::
Params
params
;
Ptr
<
Data
>
data
;
Ptr
<
TrackerProxy
>
tracker
;
Ptr
<
TrackerProxy
>
tracker
Proxy
;
Ptr
<
TLDDetector
>
detector
;
};
...
...
@@ -244,28 +245,25 @@ Ptr<TrackerTLD> TrackerTLD::createTracker(const TrackerTLD::Params ¶meters){
TrackerTLDImpl
::
TrackerTLDImpl
(
const
TrackerTLD
::
Params
&
parameters
)
:
params
(
parameters
){
isInit
=
false
;
tracker
=
Ptr
<
TrackerProxyImpl
<
TrackerMedianFlow
,
TrackerMedianFlow
::
Params
>
>
(
tracker
Proxy
=
Ptr
<
TrackerProxyImpl
<
TrackerMedianFlow
,
TrackerMedianFlow
::
Params
>
>
(
new
TrackerProxyImpl
<
TrackerMedianFlow
,
TrackerMedianFlow
::
Params
>
());
}
TrackerTLD
::~
TrackerTLD
(){
}
void
TrackerTLD
::
read
(
const
cv
::
FileNode
&
fn
)
void
TrackerTLDImpl
::
read
(
const
cv
::
FileNode
&
fn
)
{
params
.
read
(
fn
);
}
void
TrackerTLD
::
write
(
cv
::
FileStorage
&
fs
)
const
void
TrackerTLD
Impl
::
write
(
cv
::
FileStorage
&
fs
)
const
{
params
.
write
(
fs
);
}
bool
TrackerTLD
::
initImpl
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
){
bool
TrackerTLD
Impl
::
initImpl
(
const
Mat
&
image
,
const
Rect2d
&
boundingBox
){
Mat
image_gray
;
tracker
->
init
(
image
,
boundingBox
);
tracker
Proxy
->
init
(
image
,
boundingBox
);
cvtColor
(
image
,
image_gray
,
COLOR_BGR2GRAY
);
data
=
new
Data
(
boundingBox
);
data
=
Ptr
<
Data
>
(
new
Data
(
boundingBox
)
);
double
scale
=
data
->
getScale
();
Rect2d
myBoundingBox
=
boundingBox
;
if
(
scale
>
1.0
){
...
...
@@ -278,7 +276,7 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
myBoundingBox
.
height
*=
scale
;
}
model
=
Ptr
<
TrackerTLDModel
>
(
new
TrackerTLDModel
(
params
,
image_gray
,
myBoundingBox
,
data
->
getMinSize
()));
detector
=
new
TLDDetector
(
params
,
model
);
detector
=
Ptr
<
TLDDetector
>
(
new
TLDDetector
(
params
,
model
)
);
data
->
confident
=
false
;
data
->
failedLastTime
=
false
;
...
...
@@ -294,10 +292,9 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
return
true
;
}
bool
TrackerTLD
::
updateImpl
(
const
Mat
&
image
,
Rect2d
&
boundingBox
){
bool
TrackerTLD
Impl
::
updateImpl
(
const
Mat
&
image
,
Rect2d
&
boundingBox
){
Mat
image_gray
,
image_blurred
,
imageForDetector
;
cvtColor
(
image
,
image_gray
,
COLOR_BGR2GRAY
);
Data
*
data
=
((
Data
*
)
static_cast
<
TrackerTLD
::
Private
*>
(
privateInfo
[
2
]));
double
scale
=
data
->
getScale
();
if
(
scale
>
1.0
){
resize
(
image_gray
,
imageForDetector
,
Size
(
cvRound
(
image
.
cols
*
scale
),
cvRound
(
image
.
rows
*
scale
)));
...
...
@@ -306,8 +303,6 @@ bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){
}
GaussianBlur
(
imageForDetector
,
image_blurred
,
GaussBlurKernelSize
,
0.0
);
TrackerTLDModel
*
tldModel
=
((
TrackerTLDModel
*
)
static_cast
<
TrackerModel
*>
(
model
));
TrackerProxy
*
trackerProxy
=
(
TrackerProxy
*
)
static_cast
<
Private
*>
(
privateInfo
[
0
]);
TLDDetector
*
detector
=
((
TLDDetector
*
)
static_cast
<
TrackerTLD
::
Private
*>
(
privateInfo
[
1
]));
data
->
frameNum
++
;
Mat_
<
uchar
>
standardPatch
(
15
,
15
);
std
::
vector
<
Rect2d
>
detectorResults
;
...
...
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