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
efc0322e
Commit
efc0322e
authored
Jun 02, 2015
by
Kurnianggoro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a framework for choosing the descriptor
parent
e7466085
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
+27
-7
tracker.hpp
modules/tracking/include/opencv2/tracking/tracker.hpp
+3
-1
trackerKCF.cpp
modules/tracking/src/trackerKCF.cpp
+24
-6
No files found.
modules/tracking/include/opencv2/tracking/tracker.hpp
View file @
efc0322e
...
...
@@ -1198,6 +1198,7 @@ class CV_EXPORTS_W TrackerTLD : public Tracker
class
CV_EXPORTS_W
TrackerKCF
:
public
Tracker
{
public
:
enum
MODE
{
GRAY
,
CN
,
CN2
};
struct
CV_EXPORTS
Params
{
Params
();
...
...
@@ -1209,7 +1210,8 @@ class CV_EXPORTS_W TrackerKCF : public Tracker
double
interp_factor
;
// linear interpolation factor for adaptation
double
output_sigma_factor
;
// spatial bandwidth (proportional to target)
bool
resize
;
// activate the resize feature to improve the processing speed
int
max_patch_size
;
// threshold for the ROI size
int
max_patch_size
;
// threshold for the ROI size
MODE
descriptor
;
// descriptor type
};
/** @brief Constructor
...
...
modules/tracking/src/trackerKCF.cpp
View file @
efc0322e
...
...
@@ -169,6 +169,10 @@ namespace cv{
// initialize the hann window filter
createHanningWindow
(
hann
,
roi
.
size
(),
CV_64F
);
if
(
params
.
descriptor
==
CN
){
Mat
layers
[]
=
{
hann
,
hann
,
hann
,
hann
,
hann
,
hann
,
hann
,
hann
,
hann
,
hann
};
merge
(
layers
,
10
,
hann
);
}
// create gaussian response
y
=
Mat
::
zeros
(
roi
.
height
,
roi
.
width
,
CV_64F
);
...
...
@@ -197,12 +201,9 @@ namespace cv{
double
minVal
,
maxVal
;
// min-max response
Point
minLoc
,
maxLoc
;
// min-max location
Mat
img
;
Mat
img
=
image
.
clone
()
;
// check the channels of the input image, grayscale is preferred
CV_Assert
(
image
.
channels
()
==
1
||
image
.
channels
()
==
3
);
if
(
image
.
channels
()
>
1
){
cvtColor
(
image
,
img
,
CV_BGR2GRAY
);
}
else
img
=
image
;
// resize the image whenever needed
if
(
resizeImage
)
resize
(
img
,
img
,
Size
(
img
.
cols
/
2
,
img
.
rows
/
2
));
...
...
@@ -355,6 +356,20 @@ namespace cv{
copyMakeBorder
(
patch
,
patch
,
addTop
,
addBottom
,
addLeft
,
addRight
,
BORDER_REPLICATE
);
// extract the desired descriptors
switch
(
params
.
descriptor
){
case
GRAY
:
if
(
img
.
channels
()
>
1
)
cvtColor
(
patch
,
patch
,
CV_BGR2GRAY
);
break
;
case
CN
:
CV_Assert
(
img
.
channels
()
==
3
);
extractCN
(
patch
,
patch
);
break
;
default
:
if
(
patch
.
channels
()
>
1
)
cvtColor
(
patch
,
patch
,
CV_BGR2GRAY
);
break
;
}
patch
.
convertTo
(
patch
,
CV_64F
);
patch
=
patch
/
255.0
-
0.5
;
// normalize to range -0.5 .. 0.5
...
...
@@ -370,7 +385,7 @@ namespace cv{
Vec3b
&
pixel
=
_patch
.
at
<
Vec3b
>
(
0
,
0
);
unsigned
index
;
cnFeatures
=
Mat
::
zeros
(
roi
.
height
,
roi
.
width
,
CV_64FC
(
10
));
Mat
temp
=
Mat
::
zeros
(
_patch
.
rows
,
_patch
.
cols
,
CV_64FC
(
10
));
for
(
int
i
=
0
;
i
<
_patch
.
rows
;
i
++
){
for
(
int
j
=
0
;
j
<
_patch
.
cols
;
j
++
){
...
...
@@ -379,10 +394,12 @@ namespace cv{
//copy the values
for
(
int
_k
=
0
;
_k
<
10
;
_k
++
){
cnFeatures
.
at
<
Vec
<
double
,
10
>
>
(
i
,
j
)[
_k
]
=
cn
[
index
][
_k
];
temp
.
at
<
Vec
<
double
,
10
>
>
(
i
,
j
)[
_k
]
=
cn
[
index
][
_k
];
}
}
}
cnFeatures
=
temp
.
clone
();
}
/*
...
...
@@ -506,6 +523,7 @@ namespace cv{
output_sigma_factor
=
1.0
/
16.0
;
resize
=
true
;
max_patch_size
=
80
*
80
;
descriptor
=
GRAY
;
}
void
TrackerKCF
::
Params
::
read
(
const
cv
::
FileNode
&
/*fn*/
){
...
...
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