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
c8cbab68
Commit
c8cbab68
authored
Jun 30, 2014
by
Alex Leontiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vadim
parent
470a8221
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
67 deletions
+28
-67
TLD.cpp
modules/tracking/src/TLD.cpp
+22
-59
trackerTLD.cpp
modules/tracking/src/trackerTLD.cpp
+6
-8
No files found.
modules/tracking/src/TLD.cpp
View file @
c8cbab68
...
...
@@ -45,9 +45,12 @@
#include "time.h"
#include <algorithm>
#include <limits.h>
#include <math.h>
#include <opencv2/highgui.hpp>
#include "TLD.hpp"
#define PI 3.14159265
using
namespace
cv
;
namespace
cv
{
namespace
tld
...
...
@@ -211,15 +214,6 @@ double NCC(Mat_<uchar> patch1,Mat_<uchar> patch2){
double
sq1
=
sqrt
(
MAX
(
0.0
,
n1
*
n1
-
s1
*
s1
/
N
)),
sq2
=
sqrt
(
MAX
(
0.0
,
n2
*
n2
-
s2
*
s2
/
N
));
double
ares
=
(
sq2
==
0
)
?
sq1
/
abs
(
sq1
)
:
(
prod
-
s1
*
s2
/
N
)
/
sq1
/
sq2
;
return
ares
;
/*Mat_<uchar> p1(80,80),p2(80,80);
dprintf(("NCC\n"));
resample(patch1,Rect2d(Point2d(0,0),patch1.size()),p1);
resample(patch2,Rect2d(Point2d(0,0),patch2.size()),p2);
imshow("patch1",p1);
imshow("patch2",p2);
dprintf(("NCC=%f\n",ncc));
waitKey();*/
}
unsigned
int
getMedian
(
const
std
::
vector
<
unsigned
int
>&
values
,
int
size
){
if
(
size
==-
1
){
...
...
@@ -240,57 +234,26 @@ double overlap(const Rect2d& r1,const Rect2d& r2){
}
void
resample
(
const
Mat
&
img
,
const
RotatedRect
&
r2
,
Mat_
<
uchar
>&
samples
){
Point2f
vertices
[
4
];
r2
.
points
(
vertices
);
int
ref
=
0
;
double
minx
=
vertices
[
0
].
x
,
miny
=
vertices
[
0
].
y
;
for
(
int
i
=
1
;
i
<
4
;
i
++
){
if
(
vertices
[
i
].
x
<
minx
||
(
vertices
[
i
].
x
==
minx
&&
vertices
[
i
].
y
<
miny
)){
minx
=
vertices
[
i
].
x
;
miny
=
vertices
[
i
].
y
;
ref
=
i
;
}
}
double
dx1
=
vertices
[(
ref
+
1
)
%
4
].
x
-
vertices
[
ref
].
x
,
dy1
=
vertices
[(
ref
+
1
)
%
4
].
y
-
vertices
[
ref
].
y
,
dx2
=
vertices
[(
ref
+
3
)
%
4
].
x
-
vertices
[
ref
].
x
,
dy2
=
vertices
[(
ref
+
3
)
%
4
].
y
-
vertices
[
ref
].
y
;
for
(
int
i
=
0
;
i
<
samples
.
rows
;
i
++
){
for
(
int
j
=
0
;
j
<
samples
.
cols
;
j
++
){
double
x
=
vertices
[
ref
].
x
+
dx1
*
j
/
samples
.
cols
+
dx2
*
i
/
samples
.
rows
,
y
=
vertices
[
ref
].
y
+
dy1
*
j
/
samples
.
cols
+
dy2
*
i
/
samples
.
rows
;
int
ix
=
cvFloor
(
x
),
iy
=
cvFloor
(
y
);
double
tx
=
x
-
ix
,
ty
=
y
-
iy
;
double
a
=
img
.
at
<
uchar
>
(
CLIP
(
iy
,
0
,
img
.
rows
-
1
),
CLIP
(
ix
,
0
,
img
.
cols
-
1
))
*
(
1.0
-
tx
)
+
img
.
at
<
uchar
>
(
CLIP
(
iy
,
0
,
img
.
rows
-
1
),
CLIP
(
ix
+
1
,
0
,
img
.
cols
-
1
))
*
tx
;
double
b
=
img
.
at
<
uchar
>
(
CLIP
(
iy
+
1
,
0
,
img
.
rows
-
1
),
CLIP
(
ix
,
0
,
img
.
cols
-
1
))
*
(
1.0
-
tx
)
+
img
.
at
<
uchar
>
(
CLIP
(
iy
+
1
,
0
,
img
.
rows
-
1
),
CLIP
(
ix
+
1
,
0
,
img
.
cols
-
1
))
*
tx
;
samples
(
i
,
j
)
=
(
uchar
)(
a
*
(
1.0
-
ty
)
+
b
*
ty
);
}
}
Mat_
<
float
>
M
(
2
,
3
),
R
(
2
,
2
),
Si
(
2
,
2
),
s
(
2
,
1
),
o
(
2
,
1
);
R
(
0
,
0
)
=
(
float
)
cos
(
r2
.
angle
*
PI
/
180
);
R
(
0
,
1
)
=
(
float
)(
-
sin
(
r2
.
angle
*
PI
/
180
));
R
(
1
,
0
)
=
(
float
)
sin
(
r2
.
angle
*
PI
/
180
);
R
(
1
,
1
)
=
(
float
)
cos
(
r2
.
angle
*
PI
/
180
);
Si
(
0
,
0
)
=
(
float
)(
samples
.
cols
/
r2
.
size
.
width
);
Si
(
0
,
1
)
=
0.0
f
;
Si
(
1
,
0
)
=
0.0
f
;
Si
(
1
,
1
)
=
(
float
)(
samples
.
rows
/
r2
.
size
.
height
);
s
(
0
,
0
)
=
(
float
)
samples
.
cols
;
s
(
1
,
0
)
=
(
float
)
samples
.
rows
;
o
(
0
,
0
)
=
r2
.
center
.
x
;
o
(
1
,
0
)
=
r2
.
center
.
y
;
Mat_
<
float
>
A
(
2
,
2
),
b
(
2
,
1
);
A
=
Si
*
R
;
b
=
s
/
2.0
-
Si
*
R
*
o
;
A
.
copyTo
(
M
.
colRange
(
Range
(
0
,
2
)));
b
.
copyTo
(
M
.
colRange
(
Range
(
2
,
3
)));
warpAffine
(
img
,
samples
,
M
,
samples
.
size
());
}
void
resample
(
const
Mat
&
img
,
const
Rect2d
&
r2
,
Mat_
<
uchar
>&
samples
){
#if 1
double
x
,
y
,
a
,
b
,
tx
,
ty
;
int
ix
,
iy
;
for
(
int
i
=
0
;
i
<
samples
.
rows
;
i
++
){
y
=
r2
.
y
+
i
*
r2
.
height
/
samples
.
rows
;
iy
=
cvFloor
(
y
);
ty
=
y
-
iy
;
for
(
int
j
=
0
;
j
<
samples
.
cols
;
j
++
){
x
=
r2
.
x
+
j
*
r2
.
width
/
samples
.
cols
;
ix
=
cvFloor
(
x
);
tx
=
x
-
ix
;
a
=
img
.
at
<
uchar
>
(
CLIP
(
iy
,
0
,
img
.
cols
-
1
),
CLIP
(
ix
,
0
,
img
.
rows
-
1
))
*
(
1.0
-
tx
)
+
img
.
at
<
uchar
>
(
CLIP
(
iy
,
0
,
img
.
cols
-
1
),
CLIP
(
ix
+
1
,
0
,
img
.
rows
-
1
))
*
tx
;
b
=
img
.
at
<
uchar
>
(
CLIP
(
iy
+
1
,
0
,
img
.
cols
-
1
),
CLIP
(
ix
,
0
,
img
.
rows
-
1
))
*
(
1.0
-
tx
)
+
img
.
at
<
uchar
>
(
CLIP
(
iy
+
1
,
0
,
img
.
cols
-
1
),
CLIP
(
ix
+
1
,
0
,
img
.
rows
-
1
))
*
tx
;
samples
(
i
,
j
)
=
(
uchar
)(
a
*
(
1.0
-
ty
)
+
b
*
ty
);
}
}
#else
Point2f
center
((
float
)(
r2
.
x
+
r2
.
width
/
2
),(
float
)(
r2
.
y
+
r2
.
height
/
2
));
return
resample
(
img
,
RotatedRect
(
center
,
Size2f
((
float
)
r2
.
width
,(
float
)
r2
.
height
),
0.0
f
),
samples
);
#endif
Mat_
<
float
>
M
(
2
,
3
);
M
(
0
,
0
)
=
(
float
)(
samples
.
cols
/
r2
.
width
);
M
(
0
,
1
)
=
0.0
f
;
M
(
0
,
2
)
=
(
float
)(
-
r2
.
x
*
samples
.
cols
/
r2
.
width
);
M
(
1
,
0
)
=
0.0
f
;
M
(
1
,
1
)
=
(
float
)(
samples
.
rows
/
r2
.
height
);
M
(
1
,
2
)
=
(
float
)(
-
r2
.
y
*
samples
.
rows
/
r2
.
height
);
warpAffine
(
img
,
samples
,
M
,
samples
.
size
());
}
//other stuff
...
...
@@ -352,13 +315,13 @@ unsigned short int TLDEnsembleClassifier::code(const uchar* data,int rowstep)con
unsigned
short
int
position
=
0
;
//char codeS[20];
for
(
int
i
=
0
;
i
<
(
int
)(
sizeof
(
x1
)
/
sizeof
(
x1
[
0
]));
i
++
){
position
=
position
<<
1
;
if
(
*
(
data
+
rowstep
*
y1
[
i
]
+
x1
[
i
])
<*
(
data
+
rowstep
*
y2
[
i
]
+
x2
[
i
])){
position
++
;
//codeS[i]='o';
}
else
{
//codeS[i]='x';
}
position
=
position
<<
1
;
}
//codeS[13]='\0';
//dprintf(("integrate with code %s\n",codeS));
...
...
modules/tracking/src/trackerTLD.cpp
View file @
c8cbab68
...
...
@@ -48,7 +48,7 @@
#include "TLD.hpp"
#include "opencv2/highgui.hpp"
#define THETA_NN 0.5
5
#define THETA_NN 0.5
#define CORE_THRESHOLD 0.5
#define NEG_EXAMPLES_IN_INIT_MODEL 300
#define MAX_EXAMPLES_IN_MODEL 500
...
...
@@ -60,22 +60,20 @@ using namespace tld;
/*
* FIXME(optimize):
* no median
* direct formula in resamples
* FIXME(issues)
* THETA_NN 0.5<->0.6 dramatic change vs video 6
* THETA_NN 0.5<->0.6 dramatic change vs video 6
!!
* TODO:
* schoolPC: codec, libopencv-dev
* fix pushbot ->pick commits -> compare_branches->all in 1
* ||video(
vadim random, better?
) --> debug if box size is less than 20 --> (remove ensemble self-loop) --> (try inter_area)
* ||video(
0.5<->0.6
) --> debug if box size is less than 20 --> (remove ensemble self-loop) --> (try inter_area)
* perfect PN
*
* vadim:
*
* variance outside
* standard patch out (403)
* pos by 2 in code()
* private members
*
* resize
* warpAffine
* warpAffine -- ?
* cv::integral
*
* 13 as enum
...
...
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