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
1652540a
Commit
1652540a
authored
Apr 30, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored HoughLines (converted it into Algorithm)
parent
48fb8c4f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
19 deletions
+92
-19
main.cpp
modules/gpu/perf4au/main.cpp
+4
-3
gpuimgproc.hpp
modules/gpuimgproc/include/opencv2/gpuimgproc.hpp
+74
-7
perf_hough.cpp
modules/gpuimgproc/perf/perf_hough.cpp
+6
-4
hough.cpp
modules/gpuimgproc/src/hough.cpp
+0
-0
test_hough.cpp
modules/gpuimgproc/test/test_hough.cpp
+4
-2
houghlines.cpp
samples/gpu/houghlines.cpp
+4
-3
No files found.
modules/gpu/perf4au/main.cpp
View file @
1652540a
...
...
@@ -86,13 +86,14 @@ PERF_TEST_P(Image, HoughLinesP, testing::Values(std::string("im1_1280x800.jpg"))
{
cv
::
gpu
::
GpuMat
d_image
(
image
);
cv
::
gpu
::
GpuMat
d_lines
;
cv
::
gpu
::
HoughLinesBuf
d_buf
;
cv
::
gpu
::
HoughLinesP
(
d_image
,
d_lines
,
d_buf
,
rho
,
theta
,
minLineLenght
,
maxLineGap
);
cv
::
Ptr
<
cv
::
gpu
::
HoughSegmentDetector
>
hough
=
cv
::
gpu
::
createHoughSegmentDetector
(
rho
,
theta
,
minLineLenght
,
maxLineGap
);
hough
->
detect
(
d_image
,
d_lines
);
TEST_CYCLE
()
{
cv
::
gpu
::
HoughLinesP
(
d_image
,
d_lines
,
d_buf
,
rho
,
theta
,
minLineLenght
,
maxLineGap
);
hough
->
detect
(
d_image
,
d_lines
);
}
}
else
...
...
modules/gpuimgproc/include/opencv2/gpuimgproc.hpp
View file @
1652540a
...
...
@@ -220,18 +220,82 @@ inline void Canny(InputArray dx, InputArray dy, OutputArray edges, double low_th
/////////////////////////// Hough Transform ////////////////////////////
struct
HoughLinesBuf
//////////////////////////////////////
// HoughLines
class
CV_EXPORTS
HoughLinesDetector
:
public
Algorithm
{
GpuMat
accum
;
GpuMat
list
;
public
:
virtual
void
detect
(
InputArray
src
,
OutputArray
lines
)
=
0
;
virtual
void
downloadResults
(
InputArray
d_lines
,
OutputArray
h_lines
,
OutputArray
h_votes
=
noArray
())
=
0
;
virtual
void
setRho
(
float
rho
)
=
0
;
virtual
float
getRho
()
const
=
0
;
virtual
void
setTheta
(
float
theta
)
=
0
;
virtual
float
getTheta
()
const
=
0
;
virtual
void
setThreshold
(
int
threshold
)
=
0
;
virtual
int
getThreshold
()
const
=
0
;
virtual
void
setDoSort
(
bool
doSort
)
=
0
;
virtual
bool
getDoSort
()
const
=
0
;
virtual
void
setMaxLines
(
int
maxLines
)
=
0
;
virtual
int
getMaxLines
()
const
=
0
;
};
CV_EXPORTS
void
HoughLines
(
const
GpuMat
&
src
,
GpuMat
&
lines
,
float
rho
,
float
theta
,
int
threshold
,
bool
doSort
=
false
,
int
maxLines
=
4096
);
CV_EXPORTS
void
HoughLines
(
const
GpuMat
&
src
,
GpuMat
&
lines
,
HoughLinesBuf
&
buf
,
float
rho
,
float
theta
,
int
threshold
,
bool
doSort
=
false
,
int
maxLines
=
4096
);
CV_EXPORTS
void
HoughLinesDownload
(
const
GpuMat
&
d_lines
,
OutputArray
h_lines
,
OutputArray
h_votes
=
noArray
());
CV_EXPORTS
Ptr
<
HoughLinesDetector
>
createHoughLinesDetector
(
float
rho
,
float
theta
,
int
threshold
,
bool
doSort
=
false
,
int
maxLines
=
4096
);
// obsolete
__OPENCV_GPUIMGPROC_DEPR_BEFORE__
void
HoughLines
(
InputArray
src
,
OutputArray
lines
,
float
rho
,
float
theta
,
int
threshold
,
bool
doSort
=
false
,
int
maxLines
=
4096
)
__OPENCV_GPUIMGPROC_DEPR_AFTER__
;
inline
void
HoughLines
(
InputArray
src
,
OutputArray
lines
,
float
rho
,
float
theta
,
int
threshold
,
bool
doSort
,
int
maxLines
)
{
gpu
::
createHoughLinesDetector
(
rho
,
theta
,
threshold
,
doSort
,
maxLines
)
->
detect
(
src
,
lines
);
}
//////////////////////////////////////
// HoughLinesP
//! finds line segments in the black-n-white image using probabalistic Hough transform
CV_EXPORTS
void
HoughLinesP
(
const
GpuMat
&
image
,
GpuMat
&
lines
,
HoughLinesBuf
&
buf
,
float
rho
,
float
theta
,
int
minLineLength
,
int
maxLineGap
,
int
maxLines
=
4096
);
class
CV_EXPORTS
HoughSegmentDetector
:
public
Algorithm
{
public
:
virtual
void
detect
(
InputArray
src
,
OutputArray
lines
)
=
0
;
virtual
void
setRho
(
float
rho
)
=
0
;
virtual
float
getRho
()
const
=
0
;
virtual
void
setTheta
(
float
theta
)
=
0
;
virtual
float
getTheta
()
const
=
0
;
virtual
void
setMinLineLength
(
int
minLineLength
)
=
0
;
virtual
int
getMinLineLength
()
const
=
0
;
virtual
void
setMaxLineGap
(
int
maxLineGap
)
=
0
;
virtual
int
getMaxLineGap
()
const
=
0
;
virtual
void
setMaxLines
(
int
maxLines
)
=
0
;
virtual
int
getMaxLines
()
const
=
0
;
};
CV_EXPORTS
Ptr
<
HoughSegmentDetector
>
createHoughSegmentDetector
(
float
rho
,
float
theta
,
int
minLineLength
,
int
maxLineGap
,
int
maxLines
=
4096
);
// obsolete
__OPENCV_GPUIMGPROC_DEPR_BEFORE__
void
HoughLinesP
(
InputArray
src
,
OutputArray
lines
,
float
rho
,
float
theta
,
int
minLineLength
,
int
maxLineGap
,
int
maxLines
=
4096
)
__OPENCV_GPUIMGPROC_DEPR_AFTER__
;
inline
void
HoughLinesP
(
InputArray
src
,
OutputArray
lines
,
float
rho
,
float
theta
,
int
minLineLength
,
int
maxLineGap
,
int
maxLines
)
{
gpu
::
createHoughSegmentDetector
(
rho
,
theta
,
minLineLength
,
maxLineGap
,
maxLines
)
->
detect
(
src
,
lines
);
}
//////////////////////////////////////
// HoughCircles
struct
HoughCirclesBuf
{
...
...
@@ -245,6 +309,9 @@ CV_EXPORTS void HoughCircles(const GpuMat& src, GpuMat& circles, int method, flo
CV_EXPORTS
void
HoughCircles
(
const
GpuMat
&
src
,
GpuMat
&
circles
,
HoughCirclesBuf
&
buf
,
int
method
,
float
dp
,
float
minDist
,
int
cannyThreshold
,
int
votesThreshold
,
int
minRadius
,
int
maxRadius
,
int
maxCircles
=
4096
);
CV_EXPORTS
void
HoughCirclesDownload
(
const
GpuMat
&
d_circles
,
OutputArray
h_circles
);
//////////////////////////////////////
// GeneralizedHough
//! finds arbitrary template in the grayscale image using Generalized Hough Transform
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
...
...
modules/gpuimgproc/perf/perf_hough.cpp
View file @
1652540a
...
...
@@ -103,9 +103,10 @@ PERF_TEST_P(Sz, HoughLines,
{
const
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
d_lines
;
cv
::
gpu
::
HoughLinesBuf
d_buf
;
TEST_CYCLE
()
cv
::
gpu
::
HoughLines
(
d_src
,
d_lines
,
d_buf
,
rho
,
theta
,
threshold
);
cv
::
Ptr
<
cv
::
gpu
::
HoughLinesDetector
>
hough
=
cv
::
gpu
::
createHoughLinesDetector
(
rho
,
theta
,
threshold
);
TEST_CYCLE
()
hough
->
detect
(
d_src
,
d_lines
);
cv
::
Mat
gpu_lines
(
d_lines
.
row
(
0
));
cv
::
Vec2f
*
begin
=
gpu_lines
.
ptr
<
cv
::
Vec2f
>
(
0
);
...
...
@@ -151,9 +152,10 @@ PERF_TEST_P(Image, HoughLinesP,
{
const
cv
::
gpu
::
GpuMat
d_mask
(
mask
);
cv
::
gpu
::
GpuMat
d_lines
;
cv
::
gpu
::
HoughLinesBuf
d_buf
;
TEST_CYCLE
()
cv
::
gpu
::
HoughLinesP
(
d_mask
,
d_lines
,
d_buf
,
rho
,
theta
,
minLineLenght
,
maxLineGap
);
cv
::
Ptr
<
cv
::
gpu
::
HoughSegmentDetector
>
hough
=
cv
::
gpu
::
createHoughSegmentDetector
(
rho
,
theta
,
minLineLenght
,
maxLineGap
);
TEST_CYCLE
()
hough
->
detect
(
d_mask
,
d_lines
);
cv
::
Mat
gpu_lines
(
d_lines
);
cv
::
Vec4i
*
begin
=
gpu_lines
.
ptr
<
cv
::
Vec4i
>
();
...
...
modules/gpuimgproc/src/hough.cpp
View file @
1652540a
This diff is collapsed.
Click to expand it.
modules/gpuimgproc/test/test_hough.cpp
View file @
1652540a
...
...
@@ -94,11 +94,13 @@ GPU_TEST_P(HoughLines, Accuracy)
cv
::
Mat
src
(
size
,
CV_8UC1
);
generateLines
(
src
);
cv
::
Ptr
<
cv
::
gpu
::
HoughLinesDetector
>
hough
=
cv
::
gpu
::
createHoughLinesDetector
(
rho
,
theta
,
threshold
);
cv
::
gpu
::
GpuMat
d_lines
;
cv
::
gpu
::
HoughLines
(
loadMat
(
src
,
useRoi
),
d_lines
,
rho
,
theta
,
threshold
);
hough
->
detect
(
loadMat
(
src
,
useRoi
),
d_lines
);
std
::
vector
<
cv
::
Vec2f
>
lines
;
cv
::
gpu
::
HoughLinesDownload
(
d_lines
,
lines
);
hough
->
downloadResults
(
d_lines
,
lines
);
cv
::
Mat
dst
(
size
,
CV_8UC1
);
drawLines
(
dst
,
lines
);
...
...
samples/gpu/houghlines.cpp
View file @
1652540a
...
...
@@ -41,7 +41,7 @@ int main(int argc, const char* argv[])
{
const
int64
start
=
getTickCount
();
HoughLinesP
(
mask
,
lines_cpu
,
1
,
CV_PI
/
180
,
50
,
60
,
5
);
cv
::
HoughLinesP
(
mask
,
lines_cpu
,
1
,
CV_PI
/
180
,
50
,
60
,
5
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"CPU Time : "
<<
timeSec
*
1000
<<
" ms"
<<
endl
;
...
...
@@ -56,11 +56,12 @@ int main(int argc, const char* argv[])
GpuMat
d_src
(
mask
);
GpuMat
d_lines
;
HoughLinesBuf
d_buf
;
{
const
int64
start
=
getTickCount
();
gpu
::
HoughLinesP
(
d_src
,
d_lines
,
d_buf
,
1.0
f
,
(
float
)
(
CV_PI
/
180.0
f
),
50
,
5
);
Ptr
<
gpu
::
HoughSegmentDetector
>
hough
=
gpu
::
createHoughSegmentDetector
(
1.0
f
,
(
float
)
(
CV_PI
/
180.0
f
),
50
,
5
);
hough
->
detect
(
d_src
,
d_lines
);
const
double
timeSec
=
(
getTickCount
()
-
start
)
/
getTickFrequency
();
cout
<<
"GPU Time : "
<<
timeSec
*
1000
<<
" ms"
<<
endl
;
...
...
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