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
b76a7a3d
Commit
b76a7a3d
authored
Jul 23, 2014
by
Alex Leontiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vadim 7, 8
parent
4b5c8412
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
tld_tracker.cpp
modules/tracking/src/tld_tracker.cpp
+9
-9
tld_tracker.hpp
modules/tracking/src/tld_tracker.hpp
+13
-4
tld_utils.cpp
modules/tracking/src/tld_utils.cpp
+3
-3
No files found.
modules/tracking/src/tld_tracker.cpp
View file @
b76a7a3d
...
...
@@ -191,8 +191,8 @@ class TrackerTLDModel : public TrackerModel{
void
setBoudingBox
(
Rect2d
boundingBox
){
boundingBox_
=
boundingBox
;}
double
getOriginalVariance
(){
return
originalVariance_
;}
std
::
vector
<
TLDEnsembleClassifier
>*
getClassifiers
(){
return
&
classifiers
;}
double
Sr
(
const
Mat_
<
uchar
>
patch
);
double
Sc
(
const
Mat_
<
uchar
>
patch
);
double
Sr
(
const
Mat_
<
uchar
>
&
patch
);
double
Sc
(
const
Mat_
<
uchar
>
&
patch
);
void
integrateRelabeled
(
Mat
&
img
,
Mat
&
imgBlurred
,
const
std
::
vector
<
Rect2d
>&
box
,
const
std
::
vector
<
bool
>&
isPositive
,
const
std
::
vector
<
bool
>&
alsoIntoModel
);
void
integrateAdditional
(
const
std
::
vector
<
Mat_
<
uchar
>
>&
eForModel
,
const
std
::
vector
<
Mat_
<
uchar
>
>&
eForEnsemble
,
bool
isPositive
);
...
...
@@ -588,14 +588,14 @@ double TLDDetector::ensembleClassifierNum(const uchar* data,int rowstep){
return
p
;
}
double
TrackerTLDModel
::
Sr
(
const
Mat_
<
uchar
>
patch
){
double
TrackerTLDModel
::
Sr
(
const
Mat_
<
uchar
>
&
patch
){
double
splus
=
0.0
;
for
(
int
i
=
0
;
i
<
(
int
)
positiveExamples
.
size
();
i
++
){
splus
=
MAX
(
splus
,
0.5
*
(
NCC
(
positiveExamples
[
i
],
patch
)
+
1.0
));
splus
=
std
::
max
(
splus
,
0.5
*
(
NCC
(
positiveExamples
[
i
],
patch
)
+
1.0
));
}
double
sminus
=
0.0
;
for
(
int
i
=
0
;
i
<
(
int
)
negativeExamples
.
size
();
i
++
){
sminus
=
MAX
(
sminus
,
0.5
*
(
NCC
(
negativeExamples
[
i
],
patch
)
+
1.0
));
sminus
=
std
::
max
(
sminus
,
0.5
*
(
NCC
(
negativeExamples
[
i
],
patch
)
+
1.0
));
}
if
(
splus
+
sminus
==
0.0
){
return
0.0
;
...
...
@@ -603,17 +603,17 @@ double TrackerTLDModel::Sr(const Mat_<uchar> patch){
return
splus
/
(
sminus
+
splus
);
}
double
TrackerTLDModel
::
Sc
(
const
Mat_
<
uchar
>
patch
){
double
TrackerTLDModel
::
Sc
(
const
Mat_
<
uchar
>
&
patch
){
double
splus
=
0.0
;
int
med
=
getMedian
(
timeStampsPositive
);
for
(
int
i
=
0
;
i
<
(
int
)
positiveExamples
.
size
();
i
++
){
if
((
int
)
timeStampsPositive
[
i
]
<=
med
){
splus
=
MAX
(
splus
,
0.5
*
(
NCC
(
positiveExamples
[
i
],
patch
)
+
1.0
));
splus
=
std
::
max
(
splus
,
0.5
*
(
NCC
(
positiveExamples
[
i
],
patch
)
+
1.0
));
}
}
double
sminus
=
0.0
;
for
(
int
i
=
0
;
i
<
(
int
)
negativeExamples
.
size
();
i
++
){
sminus
=
MAX
(
sminus
,
0.5
*
(
NCC
(
negativeExamples
[
i
],
patch
)
+
1.0
));
sminus
=
std
::
max
(
sminus
,
0.5
*
(
NCC
(
negativeExamples
[
i
],
patch
)
+
1.0
));
}
if
(
splus
+
sminus
==
0.0
){
return
0.0
;
...
...
@@ -753,7 +753,7 @@ bool Nexpert::operator()(Rect2d box){
}
Data
::
Data
(
Rect2d
initBox
){
double
minDim
=
MIN
(
initBox
.
width
,
initBox
.
height
);
double
minDim
=
std
::
min
(
initBox
.
width
,
initBox
.
height
);
scale
=
20.0
/
minDim
;
minSize
.
width
=
(
int
)(
initBox
.
width
*
20.0
/
minDim
);
minSize
.
height
=
(
int
)(
initBox
.
height
*
20.0
/
minDim
);
...
...
modules/tracking/src/tld_tracker.hpp
View file @
b76a7a3d
...
...
@@ -73,14 +73,23 @@ void drawWithRects(const Mat& img,std::vector<Rect2d>& blackOnes,Rect2d whiteOne
void
drawWithRects
(
const
Mat
&
img
,
std
::
vector
<
Rect2d
>&
blackOnes
,
std
::
vector
<
Rect2d
>&
whiteOnes
);
//aux functions and variables
//#define CLIP(x,a,b) MIN(MAX((x),(a)),(b))
template
<
typename
T
>
inline
T
CLIP
(
T
x
,
T
a
,
T
b
){
return
MIN
(
MAX
(
x
,
a
),
b
);}
//#define CLIP(x,a,b) std::min(std::max((x),(a)),(b))
template
<
typename
T
>
inline
T
CLIP
(
T
x
,
T
a
,
T
b
){
return
std
::
min
(
std
::
max
(
x
,
a
),
b
);}
/** Computes overlap between the two given rectangles. Overlap is computed as ratio of rectangles' intersection to that
* of their union.*/
double
overlap
(
const
Rect2d
&
r1
,
const
Rect2d
&
r2
);
/** Resamples the area surrounded by r2 in img so it matches the size of samples, where it is written.*/
void
resample
(
const
Mat
&
img
,
const
RotatedRect
&
r2
,
Mat_
<
uchar
>&
samples
);
/** Specialization of resample() for rectangles without retation for better performance and simplicity.*/
void
resample
(
const
Mat
&
img
,
const
Rect2d
&
r2
,
Mat_
<
uchar
>&
samples
);
/** Computes the variance of single given image.*/
double
variance
(
const
Mat
&
img
);
/** Computes the variance of subimage given by box, with the help of two integral
* images intImgP and intImgP2 (sum of squares), which should be also provided.*/
double
variance
(
Mat_
<
double
>&
intImgP
,
Mat_
<
double
>&
intImgP2
,
Rect
box
);
double
NCC
(
Mat_
<
uchar
>
patch1
,
Mat_
<
uchar
>
patch2
);
/** Computes normalized corellation coefficient between the two patches (they should be
* of the same size).*/
double
NCC
(
const
Mat_
<
uchar
>&
patch1
,
const
Mat_
<
uchar
>&
patch2
);
void
getClosestN
(
std
::
vector
<
Rect2d
>&
scanGrid
,
Rect2d
bBox
,
int
n
,
std
::
vector
<
Rect2d
>&
res
);
double
scaleAndBlur
(
const
Mat
&
originalImg
,
int
scale
,
Mat
&
scaledImg
,
Mat
&
blurredImg
,
Size
GaussBlurKernelSize
);
unsigned
int
getMedian
(
const
std
::
vector
<
unsigned
int
>&
values
,
int
size
=-
1
);
...
...
@@ -88,7 +97,7 @@ unsigned int getMedian(const std::vector<unsigned int>& values, int size=-1);
class
TLDEnsembleClassifier
{
public
:
TLDEnsembleClassifier
(
int
ordinal
,
Size
size
,
int
measurePerClassifier
);
void
integrate
(
Mat_
<
uchar
>
patch
,
bool
isPositive
);
void
integrate
(
const
Mat_
<
uchar
>&
patch
,
bool
isPositive
);
double
posteriorProbability
(
const
uchar
*
data
,
int
rowstep
)
const
;
static
int
getMaxOrdinal
();
private
:
...
...
modules/tracking/src/tld_utils.cpp
View file @
b76a7a3d
...
...
@@ -199,7 +199,7 @@ double variance(Mat_<double>& intImgP,Mat_<double>& intImgP2,Rect box){
return
p2
-
p
*
p
;
}
double
NCC
(
Mat_
<
uchar
>
patch1
,
Mat_
<
uchar
>
patch2
){
double
NCC
(
const
Mat_
<
uchar
>&
patch1
,
const
Mat_
<
uchar
>&
patch2
){
CV_Assert
(
patch1
.
rows
==
patch2
.
rows
);
CV_Assert
(
patch1
.
cols
==
patch2
.
cols
);
...
...
@@ -207,7 +207,7 @@ double NCC(Mat_<uchar> patch1,Mat_<uchar> patch2){
double
s1
=
sum
(
patch1
)(
0
),
s2
=
sum
(
patch2
)(
0
);
double
n1
=
norm
(
patch1
),
n2
=
norm
(
patch2
);
double
prod
=
patch1
.
dot
(
patch2
);
double
sq1
=
sqrt
(
MAX
(
0.0
,
n1
*
n1
-
s1
*
s1
/
N
)),
sq2
=
sqrt
(
MAX
(
0.0
,
n2
*
n2
-
s2
*
s2
/
N
));
double
sq1
=
sqrt
(
std
::
max
(
0.0
,
n1
*
n1
-
s1
*
s1
/
N
)),
sq2
=
sqrt
(
std
::
max
(
0.0
,
n2
*
n2
-
s2
*
s2
/
N
));
double
ares
=
(
sq2
==
0
)
?
sq1
/
abs
(
sq1
)
:
(
prod
-
s1
*
s2
/
N
)
/
sq1
/
sq2
;
return
ares
;
}
...
...
@@ -300,7 +300,7 @@ TLDEnsembleClassifier::TLDEnsembleClassifier(int ordinal,Size size,int measurePe
pos
=
std
::
vector
<
unsigned
int
>
(
posSize
,
0
);
neg
=
std
::
vector
<
unsigned
int
>
(
posSize
,
0
);
}
void
TLDEnsembleClassifier
::
integrate
(
Mat_
<
uchar
>
patch
,
bool
isPositive
){
void
TLDEnsembleClassifier
::
integrate
(
const
Mat_
<
uchar
>&
patch
,
bool
isPositive
){
unsigned
short
int
position
=
code
(
patch
.
data
,(
int
)
patch
.
step
[
0
]);
if
(
isPositive
){
pos
[
position
]
++
;
...
...
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