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
b179e2dd
Commit
b179e2dd
authored
Feb 01, 2013
by
Andrey Kamaev
Committed by
OpenCV Buildbot
Feb 01, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #396 from vpisarev:facedetect_fixes
parents
992d47e9
638c0d1b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
24 deletions
+81
-24
haar.cpp
modules/objdetect/src/haar.cpp
+4
-4
test_cascadeandhog.cpp
modules/objdetect/test/test_cascadeandhog.cpp
+77
-20
No files found.
modules/objdetect/src/haar.cpp
View file @
b179e2dd
...
...
@@ -45,20 +45,20 @@
#include <stdio.h>
#include "opencv2/core/internal.hpp"
#if CV_SSE2
|| CV_SSE3
# if
!CV_SSE4_1 && !CV_SSE4_2
#if CV_SSE2
# if
1
/*!CV_SSE4_1 && !CV_SSE4_2*/
# define _mm_blendv_pd(a, b, m) _mm_xor_pd(a, _mm_and_pd(_mm_xor_pd(b, a), m))
# define _mm_blendv_ps(a, b, m) _mm_xor_ps(a, _mm_and_ps(_mm_xor_ps(b, a), m))
# endif
#endif
#if
CV_AVX
#if
0 /*CV_AVX*/
# define CV_HAAR_USE_AVX 1
# if defined _MSC_VER
# pragma warning( disable : 4752 )
# endif
#else
# if CV_SSE2
|| CV_SSE3
# if CV_SSE2
# define CV_HAAR_USE_SSE 1
# endif
#endif
...
...
modules/objdetect/test/test_cascadeandhog.cpp
View file @
b179e2dd
...
...
@@ -87,11 +87,15 @@ protected:
vector
<
string
>
imageFilenames
;
vector
<
Mat
>
images
;
string
validationFilename
;
string
configFilename
;
FileStorage
validationFS
;
bool
write_results
;
};
CV_DetectorTest
::
CV_DetectorTest
()
{
configFilename
=
"dummy"
;
write_results
=
false
;
}
string
&
CV_DetectorTest
::
getValidationFilename
()
...
...
@@ -146,25 +150,37 @@ int CV_DetectorTest::prepareData( FileStorage& _fs )
void
CV_DetectorTest
::
run
(
int
)
{
string
dataPath
=
ts
->
get_data_path
();
validationFS
.
open
(
dataPath
+
getValidationFilename
(),
FileStorage
::
READ
);
int
code
=
prepareData
(
validationFS
);
string
vs_filename
=
dataPath
+
getValidationFilename
();
write_results
=
!
validationFS
.
open
(
vs_filename
,
FileStorage
::
READ
);
int
code
;
if
(
!
write_results
)
{
code
=
prepareData
(
validationFS
);
}
else
{
FileStorage
fs0
(
dataPath
+
configFilename
,
FileStorage
::
READ
);
code
=
prepareData
(
fs0
);
}
if
(
code
<
0
)
{
ts
->
set_failed_test_info
(
code
);
return
;
}
#ifdef GET_STAT
if
(
write_results
)
{
validationFS
.
release
();
string
filename
=
ts
->
get_data_path
();
filename
+=
getValidationFilename
();
validationFS
.
open
(
filename
,
FileStorage
::
WRITE
);
validationFS
.
open
(
vs_filename
,
FileStorage
::
WRITE
);
validationFS
<<
FileStorage
::
getDefaultObjectName
(
validationFilename
)
<<
"{"
;
validationFS
<<
DIST_E
<<
eps
.
dist
;
validationFS
<<
S_E
<<
eps
.
s
;
validationFS
<<
NO_PAIR_E
<<
eps
.
noPair
;
// validationFS << TOTAL_NO_PAIR_E << eps.totalNoPair;
// validationFS << TOTAL_NO_PAIR_E << eps.totalNoPair;
// write detector names
validationFS
<<
DETECTOR_NAMES
<<
"["
;
...
...
@@ -179,7 +195,7 @@ void CV_DetectorTest::run( int )
validationFS
<<
DETECTORS
<<
"{"
;
assert
(
detectorNames
.
size
()
==
detectorFilenames
.
size
()
);
nit
=
detectorNames
.
begin
();
for
(
int
di
=
0
;
di
<
detectorNames
.
size
(),
nit
!=
detectorNames
.
end
();
++
nit
,
di
++
)
for
(
int
di
=
0
;
nit
!=
detectorNames
.
end
();
++
nit
,
di
++
)
{
validationFS
<<
*
nit
<<
"{"
;
writeDetector
(
validationFS
,
di
);
...
...
@@ -200,32 +216,33 @@ void CV_DetectorTest::run( int )
validationFS
<<
"]"
;
// IMAGE_FILENAMES
validationFS
<<
VALIDATION
<<
"{"
;
#endif
}
int
progress
=
0
;
for
(
int
di
=
0
;
di
<
test_case_count
;
di
++
)
{
progress
=
update_progress
(
progress
,
di
,
test_case_count
,
0
);
#ifdef GET_STAT
if
(
write_results
)
validationFS
<<
detectorNames
[
di
]
<<
"{"
;
#endif
vector
<
vector
<
Rect
>
>
objects
;
int
temp_code
=
runTestCase
(
di
,
objects
);
#ifndef GET_STAT
if
(
temp_code
==
cvtest
::
TS
::
OK
)
if
(
!
write_results
&&
temp_code
==
cvtest
::
TS
::
OK
)
temp_code
=
validate
(
di
,
objects
);
#endif
if
(
temp_code
!=
cvtest
::
TS
::
OK
)
code
=
temp_code
;
#ifdef GET_STAT
if
(
write_results
)
validationFS
<<
"}"
;
// detectorNames[di]
#endif
}
#ifdef GET_STAT
if
(
write_results
)
{
validationFS
<<
"}"
;
// VALIDATION
validationFS
<<
"}"
;
// getDefaultObjectName
#endif
}
if
(
test_case_count
<=
0
||
imageFilenames
.
size
()
<=
0
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"validation file is not determined or not correct"
);
...
...
@@ -257,7 +274,8 @@ int CV_DetectorTest::runTestCase( int detectorIdx, vector<vector<Rect> >& object
objects
.
push_back
(
imgObjects
);
#ifdef GET_STAT
if
(
write_results
)
{
char
buf
[
10
];
sprintf
(
buf
,
"%s%d"
,
"img_"
,
ii
);
string
imageIdxStr
=
buf
;
...
...
@@ -268,7 +286,7 @@ int CV_DetectorTest::runTestCase( int detectorIdx, vector<vector<Rect> >& object
validationFS
<<
it
->
x
<<
it
->
y
<<
it
->
width
<<
it
->
height
;
}
validationFS
<<
"]"
;
// imageIdxStr
#endif
}
}
return
cvtest
::
TS
::
OK
;
}
...
...
@@ -374,12 +392,14 @@ protected:
virtual
void
readDetector
(
const
FileNode
&
fn
);
virtual
void
writeDetector
(
FileStorage
&
fs
,
int
di
);
virtual
int
detectMultiScale
(
int
di
,
const
Mat
&
img
,
vector
<
Rect
>&
objects
);
virtual
int
detectMultiScale_C
(
const
string
&
filename
,
int
di
,
const
Mat
&
img
,
vector
<
Rect
>&
objects
);
vector
<
int
>
flags
;
};
CV_CascadeDetectorTest
::
CV_CascadeDetectorTest
()
{
validationFilename
=
"cascadeandhog/cascade.xml"
;
configFilename
=
"cascadeandhog/_cascade.xml"
;
}
void
CV_CascadeDetectorTest
::
readDetector
(
const
FileNode
&
fn
)
...
...
@@ -402,11 +422,48 @@ void CV_CascadeDetectorTest::writeDetector( FileStorage& fs, int di )
fs
<<
C_SCALE_CASCADE
<<
sc
;
}
int
CV_CascadeDetectorTest
::
detectMultiScale_C
(
const
string
&
filename
,
int
di
,
const
Mat
&
img
,
vector
<
Rect
>&
objects
)
{
Ptr
<
CvHaarClassifierCascade
>
c_cascade
=
cvLoadHaarClassifierCascade
(
filename
.
c_str
(),
cvSize
(
0
,
0
));
Ptr
<
CvMemStorage
>
storage
=
cvCreateMemStorage
();
if
(
c_cascade
.
empty
()
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"cascade %s can not be opened"
);
return
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
;
}
Mat
grayImg
;
cvtColor
(
img
,
grayImg
,
CV_BGR2GRAY
);
equalizeHist
(
grayImg
,
grayImg
);
CvMat
c_gray
=
grayImg
;
CvSeq
*
rs
=
cvHaarDetectObjects
(
&
c_gray
,
c_cascade
,
storage
,
1.1
,
3
,
flags
[
di
]
);
objects
.
clear
();
for
(
int
i
=
0
;
i
<
rs
->
total
;
i
++
)
{
Rect
r
=
*
(
Rect
*
)
cvGetSeqElem
(
rs
,
i
);
objects
.
push_back
(
r
);
}
return
cvtest
::
TS
::
OK
;
}
int
CV_CascadeDetectorTest
::
detectMultiScale
(
int
di
,
const
Mat
&
img
,
vector
<
Rect
>&
objects
)
{
string
dataPath
=
ts
->
get_data_path
(),
filename
;
filename
=
dataPath
+
detectorFilenames
[
di
];
const
string
pattern
=
"haarcascade_frontalface_default.xml"
;
if
(
filename
.
size
()
>=
pattern
.
size
()
&&
strcmp
(
filename
.
c_str
()
+
(
filename
.
size
()
-
pattern
.
size
()),
pattern
.
c_str
())
==
0
)
return
detectMultiScale_C
(
filename
,
di
,
img
,
objects
);
CascadeClassifier
cascade
(
filename
);
if
(
cascade
.
empty
()
)
{
...
...
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