Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
4a996111
Commit
4a996111
authored
Mar 27, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Android build warnings
parent
6412e17d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
17 deletions
+17
-17
colormap.cpp
modules/contrib/src/colormap.cpp
+1
-1
facerec.cpp
modules/contrib/src/facerec.cpp
+6
-6
lda.cpp
modules/contrib/src/lda.cpp
+10
-10
No files found.
modules/contrib/src/colormap.cpp
View file @
4a996111
...
@@ -45,7 +45,7 @@ static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, Output
...
@@ -45,7 +45,7 @@ static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, Output
vector
<
int
>
indices
=
_indices
.
getMat
();
vector
<
int
>
indices
=
_indices
.
getMat
();
_dst
.
create
(
src
.
rows
,
src
.
cols
,
src
.
type
());
_dst
.
create
(
src
.
rows
,
src
.
cols
,
src
.
type
());
Mat
dst
=
_dst
.
getMat
();
Mat
dst
=
_dst
.
getMat
();
for
(
in
t
idx
=
0
;
idx
<
indices
.
size
();
idx
++
)
{
for
(
size_
t
idx
=
0
;
idx
<
indices
.
size
();
idx
++
)
{
Mat
originalRow
=
src
.
row
(
indices
[
idx
]);
Mat
originalRow
=
src
.
row
(
indices
[
idx
]);
Mat
sortedRow
=
dst
.
row
(
idx
);
Mat
sortedRow
=
dst
.
row
(
idx
);
originalRow
.
copyTo
(
sortedRow
);
originalRow
.
copyTo
(
sortedRow
);
...
...
modules/contrib/src/facerec.cpp
View file @
4a996111
...
@@ -310,7 +310,7 @@ void Eigenfaces::train(InputArray src, InputArray _lbls) {
...
@@ -310,7 +310,7 @@ void Eigenfaces::train(InputArray src, InputArray _lbls) {
// dimensionality of data
// dimensionality of data
//int d = data.cols;
//int d = data.cols;
// assert there are as much samples as labels
// assert there are as much samples as labels
if
(
n
!=
labels
.
size
())
if
(
(
size_t
)
n
!=
labels
.
size
())
CV_Error
(
CV_StsBadArg
,
"The number of samples must equal the number of labels!"
);
CV_Error
(
CV_StsBadArg
,
"The number of samples must equal the number of labels!"
);
// clip number of components to be valid
// clip number of components to be valid
if
((
_num_components
<=
0
)
||
(
_num_components
>
n
))
if
((
_num_components
<=
0
)
||
(
_num_components
>
n
))
...
@@ -336,7 +336,7 @@ int Eigenfaces::predict(InputArray _src) const {
...
@@ -336,7 +336,7 @@ int Eigenfaces::predict(InputArray _src) const {
Mat
q
=
subspaceProject
(
_eigenvectors
,
_mean
,
src
.
reshape
(
1
,
1
));
Mat
q
=
subspaceProject
(
_eigenvectors
,
_mean
,
src
.
reshape
(
1
,
1
));
double
minDist
=
DBL_MAX
;
double
minDist
=
DBL_MAX
;
int
minClass
=
-
1
;
int
minClass
=
-
1
;
for
(
in
t
sampleIdx
=
0
;
sampleIdx
<
_projections
.
size
();
sampleIdx
++
)
{
for
(
size_
t
sampleIdx
=
0
;
sampleIdx
<
_projections
.
size
();
sampleIdx
++
)
{
double
dist
=
norm
(
_projections
[
sampleIdx
],
q
,
NORM_L2
);
double
dist
=
norm
(
_projections
[
sampleIdx
],
q
,
NORM_L2
);
if
(
dist
<
minDist
)
{
if
(
dist
<
minDist
)
{
minDist
=
dist
;
minDist
=
dist
;
...
@@ -381,7 +381,7 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) {
...
@@ -381,7 +381,7 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) {
int
N
=
data
.
rows
;
// number of samples
int
N
=
data
.
rows
;
// number of samples
//int D = data.cols; // dimension of samples
//int D = data.cols; // dimension of samples
// assert correct data alignment
// assert correct data alignment
if
(
labels
.
size
()
!=
N
)
if
(
labels
.
size
()
!=
(
size_t
)
N
)
CV_Error
(
CV_StsUnsupportedFormat
,
"Labels must be given as integer (CV_32SC1)."
);
CV_Error
(
CV_StsUnsupportedFormat
,
"Labels must be given as integer (CV_32SC1)."
);
// compute the Fisherfaces
// compute the Fisherfaces
int
C
=
remove_dups
(
labels
).
size
();
// number of unique classes
int
C
=
remove_dups
(
labels
).
size
();
// number of unique classes
...
@@ -415,7 +415,7 @@ int Fisherfaces::predict(InputArray _src) const {
...
@@ -415,7 +415,7 @@ int Fisherfaces::predict(InputArray _src) const {
// find 1-nearest neighbor
// find 1-nearest neighbor
double
minDist
=
DBL_MAX
;
double
minDist
=
DBL_MAX
;
int
minClass
=
-
1
;
int
minClass
=
-
1
;
for
(
in
t
sampleIdx
=
0
;
sampleIdx
<
_projections
.
size
();
sampleIdx
++
)
{
for
(
size_
t
sampleIdx
=
0
;
sampleIdx
<
_projections
.
size
();
sampleIdx
++
)
{
double
dist
=
norm
(
_projections
[
sampleIdx
],
q
,
NORM_L2
);
double
dist
=
norm
(
_projections
[
sampleIdx
],
q
,
NORM_L2
);
if
(
dist
<
minDist
)
{
if
(
dist
<
minDist
)
{
minDist
=
dist
;
minDist
=
dist
;
...
@@ -657,7 +657,7 @@ void LBPH::train(InputArray _src, InputArray _lbls) {
...
@@ -657,7 +657,7 @@ void LBPH::train(InputArray _src, InputArray _lbls) {
// store given labels
// store given labels
_labels
=
labels
;
_labels
=
labels
;
// store the spatial histograms of the original data
// store the spatial histograms of the original data
for
(
in
t
sampleIdx
=
0
;
sampleIdx
<
src
.
size
();
sampleIdx
++
)
{
for
(
size_
t
sampleIdx
=
0
;
sampleIdx
<
src
.
size
();
sampleIdx
++
)
{
// calculate lbp image
// calculate lbp image
Mat
lbp_image
=
elbp
(
src
[
sampleIdx
],
_radius
,
_neighbors
);
Mat
lbp_image
=
elbp
(
src
[
sampleIdx
],
_radius
,
_neighbors
);
// get spatial histogram from this lbp image
// get spatial histogram from this lbp image
...
@@ -686,7 +686,7 @@ int LBPH::predict(InputArray _src) const {
...
@@ -686,7 +686,7 @@ int LBPH::predict(InputArray _src) const {
// find 1-nearest neighbor
// find 1-nearest neighbor
double
minDist
=
DBL_MAX
;
double
minDist
=
DBL_MAX
;
int
minClass
=
-
1
;
int
minClass
=
-
1
;
for
(
in
t
sampleIdx
=
0
;
sampleIdx
<
_histograms
.
size
();
sampleIdx
++
)
{
for
(
size_
t
sampleIdx
=
0
;
sampleIdx
<
_histograms
.
size
();
sampleIdx
++
)
{
double
dist
=
compareHist
(
_histograms
[
sampleIdx
],
query
,
CV_COMP_CHISQR
);
double
dist
=
compareHist
(
_histograms
[
sampleIdx
],
query
,
CV_COMP_CHISQR
);
if
(
dist
<
minDist
)
{
if
(
dist
<
minDist
)
{
minDist
=
dist
;
minDist
=
dist
;
...
...
modules/contrib/src/lda.cpp
View file @
4a996111
...
@@ -80,7 +80,7 @@ void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArra
...
@@ -80,7 +80,7 @@ void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArra
vector
<
int
>
indices
=
_indices
.
getMat
();
vector
<
int
>
indices
=
_indices
.
getMat
();
_dst
.
create
(
src
.
rows
,
src
.
cols
,
src
.
type
());
_dst
.
create
(
src
.
rows
,
src
.
cols
,
src
.
type
());
Mat
dst
=
_dst
.
getMat
();
Mat
dst
=
_dst
.
getMat
();
for
(
in
t
idx
=
0
;
idx
<
indices
.
size
();
idx
++
)
{
for
(
size_
t
idx
=
0
;
idx
<
indices
.
size
();
idx
++
)
{
Mat
originalCol
=
src
.
col
(
indices
[
idx
]);
Mat
originalCol
=
src
.
col
(
indices
[
idx
]);
Mat
sortedCol
=
dst
.
col
(
idx
);
Mat
sortedCol
=
dst
.
col
(
idx
);
originalCol
.
copyTo
(
sortedCol
);
originalCol
.
copyTo
(
sortedCol
);
...
@@ -169,7 +169,7 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src)
...
@@ -169,7 +169,7 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src)
int
n
=
X
.
rows
;
int
n
=
X
.
rows
;
int
d
=
X
.
cols
;
int
d
=
X
.
cols
;
// center the data if correct aligned sample mean is given
// center the data if correct aligned sample mean is given
if
(
mean
.
total
()
==
d
)
if
(
mean
.
total
()
==
(
size_t
)
d
)
subtract
(
X
,
repeat
(
mean
.
reshape
(
1
,
1
),
n
,
1
),
X
);
subtract
(
X
,
repeat
(
mean
.
reshape
(
1
,
1
),
n
,
1
),
X
);
// finally calculate projection as Y = (X-mean)*W
// finally calculate projection as Y = (X-mean)*W
gemm
(
X
,
W
,
1.0
,
Mat
(),
0.0
,
Y
);
gemm
(
X
,
W
,
1.0
,
Mat
(),
0.0
,
Y
);
...
@@ -196,8 +196,8 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src)
...
@@ -196,8 +196,8 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src)
gemm
(
Y
,
gemm
(
Y
,
W
,
W
,
1.0
,
1.0
,
(
d
==
mean
.
total
())
?
repeat
(
mean
.
reshape
(
1
,
1
),
n
,
1
)
:
Mat
(),
(
(
size_t
)
d
==
mean
.
total
())
?
repeat
(
mean
.
reshape
(
1
,
1
),
n
,
1
)
:
Mat
(),
(
d
==
mean
.
total
())
?
1.0
:
0.0
,
(
(
size_t
)
d
==
mean
.
total
())
?
1.0
:
0.0
,
X
,
X
,
GEMM_2_T
);
GEMM_2_T
);
return
X
;
return
X
;
...
@@ -296,7 +296,7 @@ private:
...
@@ -296,7 +296,7 @@ private:
double
norm
=
0.0
;
double
norm
=
0.0
;
for
(
int
i
=
0
;
i
<
nn
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nn
;
i
++
)
{
if
(
i
<
low
|
i
>
high
)
{
if
(
i
<
low
|
|
i
>
high
)
{
d
[
i
]
=
H
[
i
][
i
];
d
[
i
]
=
H
[
i
][
i
];
e
[
i
]
=
0.0
;
e
[
i
]
=
0.0
;
}
}
...
@@ -658,7 +658,7 @@ private:
...
@@ -658,7 +658,7 @@ private:
y
=
H
[
i
+
1
][
i
];
y
=
H
[
i
+
1
][
i
];
vr
=
(
d
[
i
]
-
p
)
*
(
d
[
i
]
-
p
)
+
e
[
i
]
*
e
[
i
]
-
q
*
q
;
vr
=
(
d
[
i
]
-
p
)
*
(
d
[
i
]
-
p
)
+
e
[
i
]
*
e
[
i
]
-
q
*
q
;
vi
=
(
d
[
i
]
-
p
)
*
2.0
*
q
;
vi
=
(
d
[
i
]
-
p
)
*
2.0
*
q
;
if
(
vr
==
0.0
&
vi
==
0.0
)
{
if
(
vr
==
0.0
&
&
vi
==
0.0
)
{
vr
=
eps
*
norm
*
(
std
::
abs
(
w
)
+
std
::
abs
(
q
)
+
std
::
abs
(
x
)
vr
=
eps
*
norm
*
(
std
::
abs
(
w
)
+
std
::
abs
(
q
)
+
std
::
abs
(
x
)
+
std
::
abs
(
y
)
+
std
::
abs
(
z
));
+
std
::
abs
(
y
)
+
std
::
abs
(
z
));
}
}
...
@@ -696,7 +696,7 @@ private:
...
@@ -696,7 +696,7 @@ private:
// Vectors of isolated roots
// Vectors of isolated roots
for
(
int
i
=
0
;
i
<
nn
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nn
;
i
++
)
{
if
(
i
<
low
|
i
>
high
)
{
if
(
i
<
low
|
|
i
>
high
)
{
for
(
int
j
=
i
;
j
<
nn
;
j
++
)
{
for
(
int
j
=
i
;
j
<
nn
;
j
++
)
{
V
[
i
][
j
]
=
H
[
i
][
j
];
V
[
i
][
j
]
=
H
[
i
][
j
];
}
}
...
@@ -946,9 +946,9 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
...
@@ -946,9 +946,9 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
vector
<
int
>
mapped_labels
(
labels
.
size
());
vector
<
int
>
mapped_labels
(
labels
.
size
());
vector
<
int
>
num2label
=
remove_dups
(
labels
);
vector
<
int
>
num2label
=
remove_dups
(
labels
);
map
<
int
,
int
>
label2num
;
map
<
int
,
int
>
label2num
;
for
(
in
t
i
=
0
;
i
<
num2label
.
size
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
num2label
.
size
();
i
++
)
label2num
[
num2label
[
i
]]
=
i
;
label2num
[
num2label
[
i
]]
=
i
;
for
(
in
t
i
=
0
;
i
<
labels
.
size
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
labels
.
size
();
i
++
)
mapped_labels
[
i
]
=
label2num
[
labels
[
i
]];
mapped_labels
[
i
]
=
label2num
[
labels
[
i
]];
// get sample size, dimension
// get sample size, dimension
int
N
=
data
.
rows
;
int
N
=
data
.
rows
;
...
@@ -956,7 +956,7 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
...
@@ -956,7 +956,7 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
// number of unique labels
// number of unique labels
int
C
=
num2label
.
size
();
int
C
=
num2label
.
size
();
// throw error if less labels, than samples
// throw error if less labels, than samples
if
(
labels
.
size
()
!=
N
)
if
(
labels
.
size
()
!=
(
size_t
)
N
)
CV_Error
(
CV_StsBadArg
,
"Error: The number of samples must equal the number of labels."
);
CV_Error
(
CV_StsBadArg
,
"Error: The number of samples must equal the number of labels."
);
// warn if within-classes scatter matrix becomes singular
// warn if within-classes scatter matrix becomes singular
if
(
N
<
D
)
if
(
N
<
D
)
...
...
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