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
1eefc699
Commit
1eefc699
authored
Aug 14, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added accuracy and performance tests
parent
3703722a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
1 deletion
+156
-1
perf_imgproc.cpp
modules/gpu/perf/perf_imgproc.cpp
+41
-0
perf_imgproc.cpp
modules/gpu/perf_cpu/perf_imgproc.cpp
+37
-0
hough.cpp
modules/gpu/src/hough.cpp
+16
-1
test_imgproc.cpp
modules/gpu/test/test_imgproc.cpp
+62
-0
No files found.
modules/gpu/perf/perf_imgproc.cpp
View file @
1eefc699
...
...
@@ -1331,4 +1331,45 @@ INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_getLayer, testing::Combine(
MatType
(
CV_16UC1
),
MatType
(
CV_16UC3
),
MatType
(
CV_16UC4
),
MatType
(
CV_32FC1
),
MatType
(
CV_32FC3
),
MatType
(
CV_32FC4
))));
//////////////////////////////////////////////////////////////////////
// HoughLines
GPU_PERF_TEST
(
HoughLines
,
cv
::
gpu
::
DeviceInfo
,
std
::
string
)
{
const
cv
::
gpu
::
DeviceInfo
devInfo
=
GET_PARAM
(
0
);
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
const
std
::
string
fileName
=
GET_PARAM
(
1
);
const
float
rho
=
1.0
f
;
const
float
theta
=
CV_PI
/
180.0
f
;
const
int
threshold
=
300
;
cv
::
Mat
img_base
=
readImage
(
fileName
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
img_base
.
empty
());
cv
::
Mat
img
;
cv
::
resize
(
img_base
,
img
,
cv
::
Size
(
1920
,
1080
));
cv
::
Mat
edges
;
cv
::
Canny
(
img
,
edges
,
50
,
200
);
cv
::
gpu
::
GpuMat
d_edges
(
edges
);
cv
::
gpu
::
GpuMat
d_lines
;
cv
::
gpu
::
GpuMat
d_accum
;
cv
::
gpu
::
HoughLines
(
d_edges
,
d_lines
,
d_accum
,
rho
,
theta
,
threshold
);
TEST_CYCLE
()
{
cv
::
gpu
::
HoughLines
(
d_edges
,
d_lines
,
d_accum
,
rho
,
theta
,
threshold
);
}
}
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
HoughLines
,
testing
::
Combine
(
ALL_DEVICES
,
testing
::
Values
(
std
::
string
(
"cv/shared/pic1.png"
),
std
::
string
(
"cv/shared/pic3.png"
),
std
::
string
(
"cv/shared/pic4.png"
),
std
::
string
(
"cv/shared/pic5.png"
),
std
::
string
(
"cv/shared/pic6.png"
))));
#endif
modules/gpu/perf_cpu/perf_imgproc.cpp
View file @
1eefc699
...
...
@@ -727,4 +727,41 @@ INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine(
CvtColorInfo
(
1
,
3
,
cv
::
COLOR_BayerGR2BGR
),
CvtColorInfo
(
4
,
4
,
cv
::
COLOR_RGBA2mRGBA
))));
//////////////////////////////////////////////////////////////////////
// HoughLines
GPU_PERF_TEST
(
HoughLines
,
cv
::
gpu
::
DeviceInfo
,
std
::
string
)
{
const
std
::
string
fileName
=
GET_PARAM
(
1
);
const
float
rho
=
1.0
f
;
const
float
theta
=
CV_PI
/
180.0
f
;
const
int
threshold
=
300
;
cv
::
Mat
img_base
=
readImage
(
fileName
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
img_base
.
empty
());
cv
::
Mat
img
;
cv
::
resize
(
img_base
,
img
,
cv
::
Size
(
1920
,
1080
));
cv
::
Mat
edges
;
cv
::
Canny
(
img
,
edges
,
50
,
200
);
std
::
vector
<
cv
::
Vec2f
>
lines
;
cv
::
HoughLines
(
edges
,
lines
,
rho
,
theta
,
threshold
);
TEST_CYCLE
()
{
cv
::
HoughLines
(
edges
,
lines
,
rho
,
theta
,
threshold
);
}
}
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
HoughLines
,
testing
::
Combine
(
ALL_DEVICES
,
testing
::
Values
(
std
::
string
(
"cv/shared/pic1.png"
),
std
::
string
(
"cv/shared/pic3.png"
),
std
::
string
(
"cv/shared/pic4.png"
),
std
::
string
(
"cv/shared/pic5.png"
),
std
::
string
(
"cv/shared/pic6.png"
))));
#endif
modules/gpu/src/hough.cpp
View file @
1eefc699
...
...
@@ -74,7 +74,12 @@ void cv::gpu::HoughLinesGet(const GpuMat& accum, GpuMat& lines, float rho, float
CV_Assert
(
accum
.
type
()
==
CV_32SC1
);
lines
.
create
(
2
,
maxLines
,
CV_32FC2
);
lines
.
cols
=
hough
::
linesGetResult_gpu
(
accum
,
lines
.
ptr
<
float2
>
(
0
),
lines
.
ptr
<
int
>
(
1
),
maxLines
,
threshold
,
theta
,
rho
,
doSort
);
int
count
=
hough
::
linesGetResult_gpu
(
accum
,
lines
.
ptr
<
float2
>
(
0
),
lines
.
ptr
<
int
>
(
1
),
maxLines
,
threshold
,
theta
,
rho
,
doSort
);
if
(
count
>
0
)
lines
.
cols
=
std
::
min
(
count
,
maxLines
);
else
lines
.
release
();
}
void
cv
::
gpu
::
HoughLines
(
const
GpuMat
&
src
,
GpuMat
&
lines
,
float
rho
,
float
theta
,
int
threshold
,
bool
doSort
,
int
maxLines
)
...
...
@@ -91,6 +96,16 @@ void cv::gpu::HoughLines(const GpuMat& src, GpuMat& lines, GpuMat& accum, float
void
cv
::
gpu
::
HoughLinesDownload
(
const
GpuMat
&
d_lines
,
OutputArray
h_lines_
,
OutputArray
h_voices_
)
{
if
(
d_lines
.
empty
())
{
h_lines_
.
release
();
if
(
h_voices_
.
needed
())
h_voices_
.
release
();
return
;
}
CV_Assert
(
d_lines
.
rows
==
2
&&
d_lines
.
type
()
==
CV_32FC2
);
h_lines_
.
create
(
1
,
d_lines
.
cols
,
CV_32FC2
);
cv
::
Mat
h_lines
=
h_lines_
.
getMat
();
d_lines
.
row
(
0
).
download
(
h_lines
);
...
...
modules/gpu/test/test_imgproc.cpp
View file @
1eefc699
...
...
@@ -1124,4 +1124,66 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CornerMinEigen, testing::Combine(
testing
::
Values
(
BlockSize
(
3
),
BlockSize
(
5
),
BlockSize
(
7
)),
testing
::
Values
(
ApertureSize
(
0
),
ApertureSize
(
3
),
ApertureSize
(
5
),
ApertureSize
(
7
))));
///////////////////////////////////////////////////////////////////////////////////////////////////////
// HoughLines
PARAM_TEST_CASE
(
HoughLines
,
cv
::
gpu
::
DeviceInfo
,
std
::
string
)
{
};
void
drawLines
(
cv
::
Mat
&
dst
,
const
std
::
vector
<
cv
::
Vec2f
>&
lines
)
{
for
(
size_t
i
=
0
;
i
<
lines
.
size
();
++
i
)
{
float
rho
=
lines
[
i
][
0
],
theta
=
lines
[
i
][
1
];
cv
::
Point
pt1
,
pt2
;
double
a
=
std
::
cos
(
theta
),
b
=
std
::
sin
(
theta
);
double
x0
=
a
*
rho
,
y0
=
b
*
rho
;
pt1
.
x
=
cvRound
(
x0
+
1000
*
(
-
b
));
pt1
.
y
=
cvRound
(
y0
+
1000
*
(
a
));
pt2
.
x
=
cvRound
(
x0
-
1000
*
(
-
b
));
pt2
.
y
=
cvRound
(
y0
-
1000
*
(
a
));
cv
::
line
(
dst
,
pt1
,
pt2
,
cv
::
Scalar
::
all
(
255
));
}
}
TEST_P
(
HoughLines
,
Accuracy
)
{
const
cv
::
gpu
::
DeviceInfo
devInfo
=
GET_PARAM
(
0
);
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
const
std
::
string
fileName
=
GET_PARAM
(
1
);
const
float
rho
=
1.0
f
;
const
float
theta
=
CV_PI
/
180.0
f
;
const
int
threshold
=
300
;
cv
::
Mat
img
=
readImage
(
fileName
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
img
.
empty
());
cv
::
Mat
edges
;
cv
::
Canny
(
img
,
edges
,
50
,
200
);
cv
::
gpu
::
GpuMat
d_lines
;
cv
::
gpu
::
HoughLines
(
loadMat
(
edges
),
d_lines
,
rho
,
theta
,
threshold
);
std
::
vector
<
cv
::
Vec2f
>
lines
;
cv
::
gpu
::
HoughLinesDownload
(
d_lines
,
lines
);
cv
::
Mat
dst
(
img
.
size
(),
CV_8UC1
,
cv
::
Scalar
::
all
(
0
));
drawLines
(
dst
,
lines
);
std
::
vector
<
cv
::
Vec2f
>
lines_gold
;
cv
::
HoughLines
(
edges
,
lines_gold
,
rho
,
theta
,
threshold
);
cv
::
Mat
dst_gold
(
img
.
size
(),
CV_8UC1
,
cv
::
Scalar
::
all
(
0
));
drawLines
(
dst_gold
,
lines_gold
);
ASSERT_MAT_NEAR
(
dst_gold
,
dst
,
0.0
);
}
INSTANTIATE_TEST_CASE_P
(
GPU_ImgProc
,
HoughLines
,
testing
::
Combine
(
ALL_DEVICES
,
testing
::
Values
(
std
::
string
(
"../cv/shared/pic1.png"
),
std
::
string
(
"../cv/shared/pic3.png"
),
std
::
string
(
"../cv/shared/pic4.png"
),
std
::
string
(
"../cv/shared/pic5.png"
),
std
::
string
(
"../cv/shared/pic6.png"
))));
}
// namespace
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