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
c849492d
Commit
c849492d
authored
Mar 02, 2015
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests for gpu HOG
initialize HOG after CUDA device switch
parent
2c9547e3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
26 deletions
+43
-26
test_objdetect.cpp
modules/gpu/test/test_objdetect.cpp
+43
-26
No files found.
modules/gpu/test/test_objdetect.cpp
View file @
c849492d
...
...
@@ -48,9 +48,24 @@ using namespace cvtest;
//#define DUMP
struct
HOG
:
testing
::
TestWithParam
<
cv
::
gpu
::
DeviceInfo
>
,
cv
::
gpu
::
HOGDescriptor
class
HogForTest
:
public
cv
::
gpu
::
HOGDescriptor
{
public
:
cv
::
gpu
::
GpuMat
getBlockHists
()
const
{
return
block_hists
;
}
void
computeBlockHistograms
(
const
cv
::
gpu
::
GpuMat
&
img
)
{
cv
::
gpu
::
HOGDescriptor
::
computeBlockHistograms
(
img
);
}
};
struct
HOG
:
testing
::
TestWithParam
<
cv
::
gpu
::
DeviceInfo
>
{
cv
::
gpu
::
DeviceInfo
devInfo
;
cv
::
Ptr
<
HogForTest
>
hog
;
#ifdef DUMP
std
::
ofstream
f
;
...
...
@@ -69,6 +84,8 @@ struct HOG : testing::TestWithParam<cv::gpu::DeviceInfo>, cv::gpu::HOGDescriptor
devInfo
=
GetParam
();
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
hog
=
new
HogForTest
;
}
#ifdef DUMP
...
...
@@ -126,39 +143,39 @@ struct HOG : testing::TestWithParam<cv::gpu::DeviceInfo>, cv::gpu::HOGDescriptor
void
testDetect
(
const
cv
::
Mat
&
img
)
{
gamma_correction
=
false
;
setSVMDetector
(
cv
::
gpu
::
HOGDescriptor
::
getDefaultPeopleDetector
());
hog
->
gamma_correction
=
false
;
hog
->
setSVMDetector
(
cv
::
gpu
::
HOGDescriptor
::
getDefaultPeopleDetector
());
std
::
vector
<
cv
::
Point
>
locations
;
// Test detect
detect
(
loadMat
(
img
),
locations
,
0
);
hog
->
detect
(
loadMat
(
img
),
locations
,
0
);
#ifdef DUMP
dump
(
cv
::
Mat
(
block_hists
),
locations
);
dump
(
cv
::
Mat
(
hog
->
getBlockHist
()
),
locations
);
#else
compare
(
cv
::
Mat
(
block_hists
),
locations
);
compare
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
locations
);
#endif
// Test detect on smaller image
cv
::
Mat
img2
;
cv
::
resize
(
img
,
img2
,
cv
::
Size
(
img
.
cols
/
2
,
img
.
rows
/
2
));
detect
(
loadMat
(
img2
),
locations
,
0
);
hog
->
detect
(
loadMat
(
img2
),
locations
,
0
);
#ifdef DUMP
dump
(
cv
::
Mat
(
block_hists
),
locations
);
dump
(
cv
::
Mat
(
hog
->
getBlockHist
()
),
locations
);
#else
compare
(
cv
::
Mat
(
block_hists
),
locations
);
compare
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
locations
);
#endif
// Test detect on greater image
cv
::
resize
(
img
,
img2
,
cv
::
Size
(
img
.
cols
*
2
,
img
.
rows
*
2
));
detect
(
loadMat
(
img2
),
locations
,
0
);
hog
->
detect
(
loadMat
(
img2
),
locations
,
0
);
#ifdef DUMP
dump
(
cv
::
Mat
(
block_hists
),
locations
);
dump
(
cv
::
Mat
(
hog
->
getBlockHist
()
),
locations
);
#else
compare
(
cv
::
Mat
(
block_hists
),
locations
);
compare
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
locations
);
#endif
}
...
...
@@ -216,8 +233,8 @@ GPU_TEST_P(HOG, GetDescriptors)
// Convert train images into feature vectors (train table)
cv
::
gpu
::
GpuMat
descriptors
,
descriptors_by_cols
;
getDescriptors
(
d_img
,
win_size
,
descriptors
,
DESCR_FORMAT_ROW_BY_ROW
);
getDescriptors
(
d_img
,
win_size
,
descriptors_by_cols
,
DESCR_FORMAT_COL_BY_COL
);
hog
->
getDescriptors
(
d_img
,
hog
->
win_size
,
descriptors
,
cv
::
gpu
::
HOGDescriptor
::
DESCR_FORMAT_ROW_BY_ROW
);
hog
->
getDescriptors
(
d_img
,
hog
->
win_size
,
descriptors_by_cols
,
cv
::
gpu
::
HOGDescriptor
::
DESCR_FORMAT_COL_BY_COL
);
// Check size of the result train table
wins_per_img_x
=
3
;
...
...
@@ -251,39 +268,39 @@ GPU_TEST_P(HOG, GetDescriptors)
img_rgb
=
readImage
(
"hog/positive1.png"
);
ASSERT_TRUE
(
!
img_rgb
.
empty
());
cv
::
cvtColor
(
img_rgb
,
img
,
CV_BGR2BGRA
);
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
hog
->
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
// Everything is fine with interpolation for left top subimage
ASSERT_EQ
(
0.0
,
cv
::
norm
(
(
cv
::
Mat
)
block_hists
,
(
cv
::
Mat
)
descriptors
.
rowRange
(
0
,
1
)));
ASSERT_EQ
(
0.0
,
cv
::
norm
(
cv
::
Mat
(
hog
->
getBlockHists
())
,
(
cv
::
Mat
)
descriptors
.
rowRange
(
0
,
1
)));
img_rgb
=
readImage
(
"hog/positive2.png"
);
ASSERT_TRUE
(
!
img_rgb
.
empty
());
cv
::
cvtColor
(
img_rgb
,
img
,
CV_BGR2BGRA
);
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
block_hists
),
cv
::
Mat
(
descriptors
.
rowRange
(
1
,
2
)));
hog
->
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
cv
::
Mat
(
descriptors
.
rowRange
(
1
,
2
)));
img_rgb
=
readImage
(
"hog/negative1.png"
);
ASSERT_TRUE
(
!
img_rgb
.
empty
());
cv
::
cvtColor
(
img_rgb
,
img
,
CV_BGR2BGRA
);
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
block_hists
),
cv
::
Mat
(
descriptors
.
rowRange
(
2
,
3
)));
hog
->
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
cv
::
Mat
(
descriptors
.
rowRange
(
2
,
3
)));
img_rgb
=
readImage
(
"hog/negative2.png"
);
ASSERT_TRUE
(
!
img_rgb
.
empty
());
cv
::
cvtColor
(
img_rgb
,
img
,
CV_BGR2BGRA
);
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
block_hists
),
cv
::
Mat
(
descriptors
.
rowRange
(
3
,
4
)));
hog
->
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
cv
::
Mat
(
descriptors
.
rowRange
(
3
,
4
)));
img_rgb
=
readImage
(
"hog/positive3.png"
);
ASSERT_TRUE
(
!
img_rgb
.
empty
());
cv
::
cvtColor
(
img_rgb
,
img
,
CV_BGR2BGRA
);
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
block_hists
),
cv
::
Mat
(
descriptors
.
rowRange
(
4
,
5
)));
hog
->
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
cv
::
Mat
(
descriptors
.
rowRange
(
4
,
5
)));
img_rgb
=
readImage
(
"hog/negative3.png"
);
ASSERT_TRUE
(
!
img_rgb
.
empty
());
cv
::
cvtColor
(
img_rgb
,
img
,
CV_BGR2BGRA
);
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
block_hists
),
cv
::
Mat
(
descriptors
.
rowRange
(
5
,
6
)));
hog
->
computeBlockHistograms
(
cv
::
gpu
::
GpuMat
(
img
));
compare_inner_parts
(
cv
::
Mat
(
hog
->
getBlockHists
()
),
cv
::
Mat
(
descriptors
.
rowRange
(
5
,
6
)));
}
INSTANTIATE_TEST_CASE_P
(
GPU_ObjDetect
,
HOG
,
ALL_DEVICES
);
...
...
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