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
110351d3
Commit
110351d3
authored
Apr 08, 2011
by
Valentina Kustikova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugs in the test for LatentSVM were fixed.
parent
ef066947
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
14 deletions
+56
-14
latentsvm.cpp
modules/objdetect/src/latentsvm.cpp
+12
-1
latentsvmdetector.cpp
modules/objdetect/src/latentsvmdetector.cpp
+10
-4
test_latentsvmdetector.cpp
modules/objdetect/test/test_latentsvmdetector.cpp
+18
-4
latentsvmdetector.cpp
tests/cv/src/latentsvmdetector.cpp
+16
-5
No files found.
modules/objdetect/src/latentsvm.cpp
View file @
110351d3
...
...
@@ -576,10 +576,21 @@ int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramid *H,
for
(
i
=
0
;
i
<
kComponents
;
i
++
)
{
#ifdef HAVE_TBB
searchObjectThreshold
(
H
,
&
(
filters
[
componentIndex
]),
kPartFilters
[
i
],
error
=
searchObjectThreshold
(
H
,
&
(
filters
[
componentIndex
]),
kPartFilters
[
i
],
b
[
i
],
maxXBorder
,
maxYBorder
,
scoreThreshold
,
&
(
pointsArr
[
i
]),
&
(
levelsArr
[
i
]),
&
(
kPointsArr
[
i
]),
&
(
scoreArr
[
i
]),
&
(
partsDisplacementArr
[
i
]),
numThreads
);
if
(
error
!=
LATENT_SVM_OK
)
{
// Release allocated memory
free
(
pointsArr
);
free
(
oppPointsArr
);
free
(
scoreArr
);
free
(
kPointsArr
);
free
(
levelsArr
);
free
(
partsDisplacementArr
);
return
LATENT_SVM_SEARCH_OBJECT_FAILED
;
}
#else
searchObjectThreshold
(
H
,
&
(
filters
[
componentIndex
]),
kPartFilters
[
i
],
b
[
i
],
maxXBorder
,
maxYBorder
,
scoreThreshold
,
...
...
modules/objdetect/src/latentsvmdetector.cpp
View file @
110351d3
...
...
@@ -95,16 +95,22 @@ CvSeq* cvLatentSvmDetectObjects(IplImage* image,
CvPoint
*
oppPointsOut
=
0
;
float
*
scoreOut
=
0
;
CvSeq
*
result_seq
=
0
;
int
error
=
0
;
cvConvertImage
(
image
,
image
,
CV_CVTIMG_SWAP_RB
);
// Getting maximum filter dimensions
getMaxFilterDims
((
const
CvLSVMFilterObject
**
)(
detector
->
filters
),
detector
->
num_components
,
detector
->
num_part_filters
,
&
maxXBorder
,
&
maxYBorder
);
getMaxFilterDims
((
const
CvLSVMFilterObject
**
)(
detector
->
filters
),
detector
->
num_components
,
detector
->
num_part_filters
,
&
maxXBorder
,
&
maxYBorder
);
// Create feature pyramid with nullable border
H
=
createFeaturePyramidWithBorder
(
image
,
maxXBorder
,
maxYBorder
);
// Search object
searchObjectThresholdSomeComponents
(
H
,
(
const
CvLSVMFilterObject
**
)(
detector
->
filters
),
detector
->
num_components
,
detector
->
num_part_filters
,
detector
->
b
,
detector
->
score_threshold
,
&
points
,
&
oppPoints
,
&
score
,
&
kPoints
,
numThreads
);
error
=
searchObjectThresholdSomeComponents
(
H
,
(
const
CvLSVMFilterObject
**
)(
detector
->
filters
),
detector
->
num_components
,
detector
->
num_part_filters
,
detector
->
b
,
detector
->
score_threshold
,
&
points
,
&
oppPoints
,
&
score
,
&
kPoints
,
numThreads
);
if
(
error
!=
LATENT_SVM_OK
)
{
return
NULL
;
}
// Clipping boxes
clippingBoxes
(
image
->
width
,
image
->
height
,
points
,
kPoints
);
clippingBoxes
(
image
->
width
,
image
->
height
,
oppPoints
,
kPoints
);
...
...
modules/objdetect/test/test_latentsvmdetector.cpp
View file @
110351d3
...
...
@@ -44,6 +44,14 @@
#include <string>
#ifdef HAVE_CONFIG_H
#include <cvconfig.h>
#endif
#ifdef HAVE_TBB
#include "tbb/task_scheduler_init.h"
#endif
using
namespace
cv
;
const
int
num_detections
=
3
;
...
...
@@ -77,7 +85,12 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
{
string
img_path
=
string
(
ts
->
get_data_path
())
+
"latentsvmdetector/cat.jpg"
;
string
model_path
=
string
(
ts
->
get_data_path
())
+
"latentsvmdetector/cat.xml"
;
int
numThreads
=
-
1
;
#ifdef HAVE_TBB
numThreads
=
2
;
tbb
::
task_scheduler_init
init
(
tbb
::
task_scheduler_init
::
deferred
);
init
.
initialize
(
numThreads
);
#endif
IplImage
*
image
=
cvLoadImage
(
img_path
.
c_str
());
if
(
!
image
)
{
...
...
@@ -95,8 +108,7 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
CvMemStorage
*
storage
=
cvCreateMemStorage
(
0
);
CvSeq
*
detections
=
0
;
detections
=
cvLatentSvmDetectObjects
(
image
,
detector
,
storage
);
detections
=
cvLatentSvmDetectObjects
(
image
,
detector
,
storage
,
0.5
f
,
numThreads
);
if
(
detections
->
total
!=
num_detections
)
{
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
...
...
@@ -116,7 +128,9 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
}
}
}
#ifdef HAVE_TBB
init
.
terminate
();
#endif
cvReleaseMemStorage
(
&
storage
);
cvReleaseLatentSvmDetector
(
&
detector
);
cvReleaseImage
(
&
image
);
...
...
tests/cv/src/latentsvmdetector.cpp
View file @
110351d3
...
...
@@ -43,6 +43,10 @@
#include "cvtest.h"
#include <string>
#ifdef HAVE_TBB
#include "tbb/task_scheduler_init.h"
#endif
using
namespace
cv
;
const
int
num_detections
=
3
;
...
...
@@ -75,27 +79,31 @@ bool CV_LatentSVMDetectorTest::isEqual(CvRect r1, CvRect r2)
void
CV_LatentSVMDetectorTest
::
run
(
int
/* start_from */
)
{
string
img_path
=
string
(
ts
->
get_data_path
())
+
"latentsvmdetector/cat.jpg"
;
string
model_path
=
string
(
ts
->
get_data_path
())
+
"latentsvmdetector/cat.xml"
;
int
numThreads
=
-
1
;
#ifdef HAVE_TBB
numThreads
=
2
;
tbb
::
task_scheduler_init
init
(
tbb
::
task_scheduler_init
::
deferred
);
init
.
initialize
(
numThreads
);
#endif
IplImage
*
image
=
cvLoadImage
(
img_path
.
c_str
());
if
(
!
image
)
{
ts
->
set_failed_test_info
(
Cv
TS
::
FAIL_INVALID_TEST_DATA
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
return
;
}
CvLatentSvmDetector
*
detector
=
cvLoadLatentSvmDetector
(
model_path
.
c_str
());
if
(
!
detector
)
{
ts
->
set_failed_test_info
(
Cv
TS
::
FAIL_INVALID_TEST_DATA
);
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_INVALID_TEST_DATA
);
cvReleaseImage
(
&
image
);
return
;
}
CvMemStorage
*
storage
=
cvCreateMemStorage
(
0
);
CvSeq
*
detections
=
0
;
detections
=
cvLatentSvmDetectObjects
(
image
,
detector
,
storage
);
detections
=
cvLatentSvmDetectObjects
(
image
,
detector
,
storage
,
0.5
f
,
numThreads
);
if
(
detections
->
total
!=
num_detections
)
{
...
...
@@ -117,6 +125,9 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
}
}
#ifdef HAVE_TBB
init
.
terminate
();
#endif
cvReleaseMemStorage
(
&
storage
);
cvReleaseLatentSvmDetector
(
&
detector
);
cvReleaseImage
(
&
image
);
...
...
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