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
2848831c
Commit
2848831c
authored
Jul 31, 2014
by
Alex Leontiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vadim 12, 20, 22
parent
449eb346
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
16 deletions
+22
-16
tld_tracker.cpp
modules/tracking/src/tld_tracker.cpp
+0
-0
tld_tracker.hpp
modules/tracking/src/tld_tracker.hpp
+2
-2
tld_utils.cpp
modules/tracking/src/tld_utils.cpp
+20
-14
No files found.
modules/tracking/src/tld_tracker.cpp
View file @
2848831c
This diff is collapsed.
Click to expand it.
modules/tracking/src/tld_tracker.hpp
View file @
2848831c
...
...
@@ -99,8 +99,8 @@ public:
private
:
TLDEnsembleClassifier
(
std
::
vector
<
Vec4b
>
meas
,
int
beg
,
int
end
);
static
void
stepPrefSuff
(
std
::
vector
<
Vec4b
>&
arr
,
int
pos
,
int
len
,
int
gridSize
);
unsigned
short
int
code
(
const
uchar
*
data
,
int
rowstep
)
const
;
std
::
vector
<
unsigned
int
>
pos
,
n
eg
;
int
code
(
const
uchar
*
data
,
int
rowstep
)
const
;
std
::
vector
<
Point2i
>
posAndN
eg
;
std
::
vector
<
Vec4b
>
measurements
;
};
...
...
modules/tracking/src/tld_utils.cpp
View file @
2848831c
...
...
@@ -136,7 +136,8 @@ void getClosestN(std::vector<Rect2d>& scanGrid,Rect2d bBox,int n,std::vector<Rec
res
.
assign
(
scanGrid
.
begin
(),
scanGrid
.
end
());
return
;
}
std
::
vector
<
double
>
overlaps
(
n
,
0.0
);
std
::
vector
<
double
>
overlaps
;
overlaps
.
assign
(
n
,
0.0
);
res
.
assign
(
scanGrid
.
begin
(),
scanGrid
.
begin
()
+
n
);
for
(
int
i
=
0
;
i
<
n
;
i
++
){
overlaps
[
i
]
=
overlap
(
res
[
i
],
bBox
);
...
...
@@ -183,10 +184,16 @@ double NCC(const Mat_<uchar>& patch1,const Mat_<uchar>& patch2){
CV_Assert
(
patch1
.
cols
==
patch2
.
cols
);
int
N
=
patch1
.
rows
*
patch1
.
cols
;
double
s1
=
sum
(
patch1
)(
0
),
s2
=
sum
(
patch2
)(
0
);
double
n1
=
norm
(
patch1
),
n2
=
norm
(
patch2
);
double
prod
=
patch1
.
dot
(
patch2
);
double
sq1
=
sqrt
(
std
::
max
(
0.0
,
n1
*
n1
-
s1
*
s1
/
N
)),
sq2
=
sqrt
(
std
::
max
(
0.0
,
n2
*
n2
-
s2
*
s2
/
N
));
int
s1
=
0
,
s2
=
0
,
n1
=
0
,
n2
=
0
,
prod
=
0
;
for
(
int
i
=
0
;
i
<
patch1
.
rows
;
i
++
){
for
(
int
j
=
0
;
j
<
patch1
.
cols
;
j
++
){
int
p1
=
patch1
(
i
,
j
),
p2
=
patch2
(
i
,
j
);
s1
+=
p1
;
s2
+=
p2
;
n1
+=
(
p1
*
p1
);
n2
+=
(
p2
*
p2
);
prod
+=
(
p1
*
p2
);
}
}
double
sq1
=
sqrt
(
std
::
max
(
0.0
,
n1
-
1.0
*
s1
*
s1
/
N
)),
sq2
=
sqrt
(
std
::
max
(
0.0
,
n2
-
1.0
*
s2
*
s2
/
N
));
double
ares
=
(
sq2
==
0
)
?
sq1
/
abs
(
sq1
)
:
(
prod
-
s1
*
s2
/
N
)
/
sq1
/
sq2
;
return
ares
;
}
...
...
@@ -264,29 +271,28 @@ void TLDEnsembleClassifier::stepPrefSuff(std::vector<Vec4b>& arr,int pos,int len
TLDEnsembleClassifier
::
TLDEnsembleClassifier
(
std
::
vector
<
Vec4b
>
meas
,
int
beg
,
int
end
){
int
posSize
=
1
;
for
(
int
i
=
0
,
mpc
=
end
-
beg
;
i
<
mpc
;
i
++
)
posSize
*=
2
;
pos
=
std
::
vector
<
unsigned
int
>
(
posSize
,
0
);
neg
=
std
::
vector
<
unsigned
int
>
(
posSize
,
0
);
posAndNeg
.
assign
(
posSize
,
Point2i
(
0
,
0
));
measurements
.
assign
(
meas
.
begin
()
+
beg
,
meas
.
begin
()
+
end
);
}
void
TLDEnsembleClassifier
::
integrate
(
const
Mat_
<
uchar
>&
patch
,
bool
isPositive
){
unsigned
short
int
position
=
code
(
patch
.
data
,(
int
)
patch
.
step
[
0
]);
int
position
=
code
(
patch
.
data
,(
int
)
patch
.
step
[
0
]);
if
(
isPositive
){
pos
[
position
]
++
;
pos
AndNeg
[
position
].
x
++
;
}
else
{
neg
[
position
]
++
;
posAndNeg
[
position
].
y
++
;
}
}
double
TLDEnsembleClassifier
::
posteriorProbability
(
const
uchar
*
data
,
int
rowstep
)
const
{
unsigned
short
int
position
=
code
(
data
,
rowstep
);
double
posNum
=
(
double
)
pos
[
position
],
negNum
=
(
double
)
neg
[
position
]
;
int
position
=
code
(
data
,
rowstep
);
double
posNum
=
(
double
)
pos
AndNeg
[
position
].
x
,
negNum
=
(
double
)
posAndNeg
[
position
].
y
;
if
(
posNum
==
0.0
&&
negNum
==
0.0
){
return
0.0
;
}
else
{
return
posNum
/
(
posNum
+
negNum
);
}
}
unsigned
short
int
TLDEnsembleClassifier
::
code
(
const
uchar
*
data
,
int
rowstep
)
const
{
unsigned
short
int
position
=
0
;
//TODO: this --> encapsule
int
TLDEnsembleClassifier
::
code
(
const
uchar
*
data
,
int
rowstep
)
const
{
unsigned
short
int
position
=
0
;
for
(
int
i
=
0
;
i
<
(
int
)
measurements
.
size
();
i
++
){
position
=
position
<<
1
;
if
(
*
(
data
+
rowstep
*
measurements
[
i
].
val
[
0
]
+
measurements
[
i
].
val
[
1
])
<*
(
data
+
rowstep
*
measurements
[
i
].
val
[
2
]
+
measurements
[
i
].
val
[
3
])){
...
...
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