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
1909978f
Commit
1909978f
authored
Apr 23, 2014
by
Alexander Karsakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ippiHoughProbLine to cv::HoughLinesP
parent
f3d1001c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
35 deletions
+57
-35
perf_houghLines.cpp
modules/imgproc/perf/perf_houghLines.cpp
+3
-8
hough.cpp
modules/imgproc/src/hough.cpp
+30
-2
test_houghLines.cpp
modules/imgproc/test/test_houghLines.cpp
+24
-25
No files found.
modules/imgproc/perf/perf_houghLines.cpp
View file @
1909978f
...
@@ -8,11 +8,6 @@ using namespace perf;
...
@@ -8,11 +8,6 @@ using namespace perf;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
get
;
using
std
::
tr1
::
get
;
bool
polarComp
(
Vec2f
a
,
Vec2f
b
)
{
return
a
[
1
]
>
b
[
1
]
||
(
a
[
1
]
==
b
[
1
]
&&
a
[
0
]
<
b
[
0
]);
}
typedef
std
::
tr1
::
tuple
<
string
,
double
,
double
,
int
>
Image_RhoStep_ThetaStep_Threshold_t
;
typedef
std
::
tr1
::
tuple
<
string
,
double
,
double
,
int
>
Image_RhoStep_ThetaStep_Threshold_t
;
typedef
perf
::
TestBaseWithParam
<
Image_RhoStep_ThetaStep_Threshold_t
>
Image_RhoStep_ThetaStep_Threshold
;
typedef
perf
::
TestBaseWithParam
<
Image_RhoStep_ThetaStep_Threshold_t
>
Image_RhoStep_ThetaStep_Threshold
;
...
@@ -20,8 +15,8 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
...
@@ -20,8 +15,8 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
testing
::
Combine
(
testing
::
Combine
(
testing
::
Values
(
"cv/shared/pic5.png"
,
"stitching/a1.png"
),
testing
::
Values
(
"cv/shared/pic5.png"
,
"stitching/a1.png"
),
testing
::
Values
(
1
,
10
),
testing
::
Values
(
1
,
10
),
testing
::
Values
(
0.0
1
,
0.1
),
testing
::
Values
(
0.0
5
,
0.1
),
testing
::
Values
(
300
,
50
0
)
testing
::
Values
(
80
,
15
0
)
)
)
)
)
{
{
...
@@ -34,7 +29,7 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
...
@@ -34,7 +29,7 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
if
(
image
.
empty
())
if
(
image
.
empty
())
FAIL
()
<<
"Unable to load source image"
<<
filename
;
FAIL
()
<<
"Unable to load source image"
<<
filename
;
Canny
(
image
,
image
,
0
,
0
);
Canny
(
image
,
image
,
100
,
150
,
3
);
Mat
lines
;
Mat
lines
;
declare
.
time
(
60
);
declare
.
time
(
60
);
...
...
modules/imgproc/src/hough.cpp
View file @
1909978f
...
@@ -103,11 +103,12 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
...
@@ -103,11 +103,12 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
IppPointPolar
delta
=
{
rho
,
theta
};
IppPointPolar
delta
=
{
rho
,
theta
};
IppPointPolar
dstRoi
[
2
]
=
{{(
Ipp32f
)
-
(
width
+
height
),
(
Ipp32f
)
min_theta
},{(
Ipp32f
)
(
width
+
height
),
(
Ipp32f
)
max_theta
}};
IppPointPolar
dstRoi
[
2
]
=
{{(
Ipp32f
)
-
(
width
+
height
),
(
Ipp32f
)
min_theta
},{(
Ipp32f
)
(
width
+
height
),
(
Ipp32f
)
max_theta
}};
int
bufferSize
;
int
bufferSize
;
int
ipp_linesMax
=
std
::
min
(
linesMax
,
numangle
*
numrho
);
int
nz
=
countNonZero
(
img
);
int
ipp_linesMax
=
std
::
min
(
linesMax
,
nz
*
numangle
/
threshold
);
int
linesCount
=
0
;
int
linesCount
=
0
;
lines
.
resize
(
ipp_linesMax
);
lines
.
resize
(
ipp_linesMax
);
IppStatus
ok
=
ippiHoughLineGetSize_8u_C1R
(
srcSize
,
delta
,
ipp_linesMax
,
&
bufferSize
);
IppStatus
ok
=
ippiHoughLineGetSize_8u_C1R
(
srcSize
,
delta
,
ipp_linesMax
,
&
bufferSize
);
Ipp8u
*
buffer
=
ippsMalloc_8u
(
bufferSize
);
Ipp8u
*
buffer
=
ippsMalloc_8u
(
bufferSize
);
if
(
ok
>=
0
)
ok
=
ippiHoughLine_Region_8u32f_C1R
(
image
,
step
,
srcSize
,
(
IppPointPolar
*
)
&
lines
[
0
],
dstRoi
,
ipp_linesMax
,
&
linesCount
,
delta
,
threshold
,
buffer
);
if
(
ok
>=
0
)
ok
=
ippiHoughLine_Region_8u32f_C1R
(
image
,
step
,
srcSize
,
(
IppPointPolar
*
)
&
lines
[
0
],
dstRoi
,
ipp_linesMax
,
&
linesCount
,
delta
,
threshold
,
buffer
);
ippsFree
(
buffer
);
ippsFree
(
buffer
);
if
(
ok
>=
0
)
if
(
ok
>=
0
)
...
@@ -115,6 +116,8 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
...
@@ -115,6 +116,8 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
lines
.
resize
(
linesCount
);
lines
.
resize
(
linesCount
);
return
;
return
;
}
}
lines
.
clear
();
setIppErrorStatus
();
#endif
#endif
AutoBuffer
<
int
>
_accum
((
numangle
+
2
)
*
(
numrho
+
2
));
AutoBuffer
<
int
>
_accum
((
numangle
+
2
)
*
(
numrho
+
2
));
...
@@ -424,6 +427,31 @@ HoughLinesProbabilistic( Mat& image,
...
@@ -424,6 +427,31 @@ HoughLinesProbabilistic( Mat& image,
int
numangle
=
cvRound
(
CV_PI
/
theta
);
int
numangle
=
cvRound
(
CV_PI
/
theta
);
int
numrho
=
cvRound
(((
width
+
height
)
*
2
+
1
)
/
rho
);
int
numrho
=
cvRound
(((
width
+
height
)
*
2
+
1
)
/
rho
);
#if (defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 801 && 0)
IppiSize
srcSize
=
{
width
,
height
};
IppPointPolar
delta
=
{
rho
,
theta
};
IppiHoughProbSpec
*
pSpec
;
int
bufferSize
,
specSize
;
int
ipp_linesMax
=
std
::
min
(
linesMax
,
numangle
*
numrho
);
int
linesCount
=
0
;
lines
.
resize
(
ipp_linesMax
);
IppStatus
ok
=
ippiHoughProbLineGetSize_8u_C1R
(
srcSize
,
delta
,
&
specSize
,
&
bufferSize
);
Ipp8u
*
buffer
=
ippsMalloc_8u
(
bufferSize
);
pSpec
=
(
IppiHoughProbSpec
*
)
malloc
(
specSize
);
if
(
ok
>=
0
)
ok
=
ippiHoughProbLineInit_8u32f_C1R
(
srcSize
,
delta
,
ippAlgHintNone
,
pSpec
);
if
(
ok
>=
0
)
ok
=
ippiHoughProbLine_8u32f_C1R
(
image
.
data
,
image
.
step
,
srcSize
,
threshold
,
lineLength
,
lineGap
,
(
IppiPoint
*
)
&
lines
[
0
],
ipp_linesMax
,
&
linesCount
,
buffer
,
pSpec
);
free
(
pSpec
);
ippsFree
(
buffer
);
if
(
ok
>=
0
)
{
lines
.
resize
(
linesCount
);
return
;
}
lines
.
clear
();
setIppErrorStatus
();
#endif
Mat
accum
=
Mat
::
zeros
(
numangle
,
numrho
,
CV_32SC1
);
Mat
accum
=
Mat
::
zeros
(
numangle
,
numrho
,
CV_32SC1
);
Mat
mask
(
height
,
width
,
CV_8UC1
);
Mat
mask
(
height
,
width
,
CV_8UC1
);
std
::
vector
<
float
>
trigtab
(
numangle
*
2
);
std
::
vector
<
float
>
trigtab
(
numangle
*
2
);
...
...
modules/imgproc/test/test_houghLines.cpp
View file @
1909978f
...
@@ -50,26 +50,26 @@ template<typename T>
...
@@ -50,26 +50,26 @@ template<typename T>
struct
SimilarWith
struct
SimilarWith
{
{
T
value
;
T
value
;
double
eps
;
float
theta_
eps
;
double
rho_eps
;
float
rho_eps
;
SimilarWith
<
T
>
(
T
val
,
double
e
,
double
r_e
)
:
value
(
val
),
eps
(
e
),
rho_eps
(
r_e
)
{
};
SimilarWith
<
T
>
(
T
val
,
float
e
,
float
r_e
)
:
value
(
val
),
theta_
eps
(
e
),
rho_eps
(
r_e
)
{
};
bool
operator
()(
T
other
);
bool
operator
()(
T
other
);
};
};
template
<>
template
<>
bool
SimilarWith
<
Vec2f
>::
operator
()(
Vec2f
other
)
bool
SimilarWith
<
Vec2f
>::
operator
()(
Vec2f
other
)
{
{
return
abs
(
other
[
0
]
-
value
[
0
])
<
rho_eps
&&
abs
(
other
[
1
]
-
value
[
1
])
<
eps
;
return
abs
(
other
[
0
]
-
value
[
0
])
<
rho_eps
&&
abs
(
other
[
1
]
-
value
[
1
])
<
theta_
eps
;
}
}
template
<>
template
<>
bool
SimilarWith
<
Vec4i
>::
operator
()(
Vec4i
other
)
bool
SimilarWith
<
Vec4i
>::
operator
()(
Vec4i
other
)
{
{
return
abs
(
other
[
0
]
-
value
[
0
])
<
eps
&&
abs
(
other
[
1
]
-
value
[
1
])
<
eps
&&
abs
(
other
[
2
]
-
value
[
2
])
<
eps
&&
abs
(
other
[
2
]
-
value
[
2
])
<
eps
;
return
norm
(
value
,
other
)
<
theta_
eps
;
}
}
template
<
typename
T
>
template
<
typename
T
>
int
countMatIntersection
(
Mat
expect
,
Mat
actual
,
double
eps
,
double
rho_eps
)
int
countMatIntersection
(
Mat
expect
,
Mat
actual
,
float
eps
,
float
rho_eps
)
{
{
int
count
=
0
;
int
count
=
0
;
if
(
!
expect
.
empty
()
&&
!
actual
.
empty
())
if
(
!
expect
.
empty
()
&&
!
actual
.
empty
())
...
@@ -116,27 +116,27 @@ class StandartHoughLinesTest : public BaseHoughLineTest, public testing::TestWit
...
@@ -116,27 +116,27 @@ class StandartHoughLinesTest : public BaseHoughLineTest, public testing::TestWit
public
:
public
:
StandartHoughLinesTest
()
StandartHoughLinesTest
()
{
{
picture_name
=
get
<
0
>
(
GetParam
());
picture_name
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
rhoStep
=
get
<
1
>
(
GetParam
());
rhoStep
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
thetaStep
=
get
<
2
>
(
GetParam
());
thetaStep
=
std
::
tr1
::
get
<
2
>
(
GetParam
());
threshold
=
get
<
3
>
(
GetParam
());
threshold
=
std
::
tr1
::
get
<
3
>
(
GetParam
());
minLineLength
=
0
;
minLineLength
=
0
;
maxGap
=
0
;
maxGap
=
0
;
}
}
};
};
typedef
std
::
tr1
::
tuple
<
string
,
double
,
double
,
int
,
int
,
int
>
Image_RhoStep_ThetaStep_Threshold_MinLine_MaxGap_t
;
typedef
std
::
tr1
::
tuple
<
string
,
double
,
double
,
int
,
int
,
int
>
Image_RhoStep_ThetaStep_Threshold_MinLine_MaxGap_t
;
class
ProbabilisticHoughLinesTest
:
public
BaseHoughLineTest
,
public
testing
::
TestWithParam
<
Image_RhoStep_ThetaStep_Threshold_MinLine_MaxGap_t
>
class
ProbabilisticHoughLinesTest
:
public
BaseHoughLineTest
,
public
testing
::
TestWithParam
<
Image_RhoStep_ThetaStep_Threshold_MinLine_MaxGap_t
>
{
{
public
:
public
:
ProbabilisticHoughLinesTest
()
ProbabilisticHoughLinesTest
()
{
{
picture_name
=
get
<
0
>
(
GetParam
());
picture_name
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
rhoStep
=
get
<
1
>
(
GetParam
());
rhoStep
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
thetaStep
=
get
<
2
>
(
GetParam
());
thetaStep
=
std
::
tr1
::
get
<
2
>
(
GetParam
());
threshold
=
get
<
3
>
(
GetParam
());
threshold
=
std
::
tr1
::
get
<
3
>
(
GetParam
());
minLineLength
=
get
<
4
>
(
GetParam
());
minLineLength
=
std
::
tr1
::
get
<
4
>
(
GetParam
());
maxGap
=
get
<
5
>
(
GetParam
());
maxGap
=
std
::
tr1
::
get
<
5
>
(
GetParam
());
}
}
};
};
...
@@ -153,7 +153,7 @@ void BaseHoughLineTest::run_test(int type)
...
@@ -153,7 +153,7 @@ void BaseHoughLineTest::run_test(int type)
xml
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"imgproc/HoughLinesP.xml"
;
xml
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"imgproc/HoughLinesP.xml"
;
Mat
dst
;
Mat
dst
;
Canny
(
src
,
dst
,
50
,
20
0
,
3
);
Canny
(
src
,
dst
,
100
,
15
0
,
3
);
EXPECT_FALSE
(
dst
.
empty
())
<<
"Failed Canny edge detector"
;
EXPECT_FALSE
(
dst
.
empty
())
<<
"Failed Canny edge detector"
;
Mat
lines
;
Mat
lines
;
...
@@ -162,7 +162,7 @@ void BaseHoughLineTest::run_test(int type)
...
@@ -162,7 +162,7 @@ void BaseHoughLineTest::run_test(int type)
else
if
(
type
==
PROBABILISTIC
)
else
if
(
type
==
PROBABILISTIC
)
HoughLinesP
(
dst
,
lines
,
rhoStep
,
thetaStep
,
threshold
,
minLineLength
,
maxGap
);
HoughLinesP
(
dst
,
lines
,
rhoStep
,
thetaStep
,
threshold
,
minLineLength
,
maxGap
);
String
test_case_name
=
format
(
"lines_%s_%.0f_%.2f_%d_%d_%d"
,
picture_name
.
c_str
(),
rhoStep
,
thetaStep
,
String
test_case_name
=
format
(
"lines_%s_%.0f_%.2f_%d_%d_%d"
,
picture_name
.
c_str
(),
rhoStep
,
thetaStep
,
threshold
,
minLineLength
,
maxGap
);
threshold
,
minLineLength
,
maxGap
);
test_case_name
=
getTestCaseName
(
test_case_name
);
test_case_name
=
getTestCaseName
(
test_case_name
);
...
@@ -183,12 +183,11 @@ void BaseHoughLineTest::run_test(int type)
...
@@ -183,12 +183,11 @@ void BaseHoughLineTest::run_test(int type)
read
(
fs
[
test_case_name
],
exp_lines
,
Mat
()
);
read
(
fs
[
test_case_name
],
exp_lines
,
Mat
()
);
fs
.
release
();
fs
.
release
();
float
eps
=
1e-2
f
;
int
count
=
-
1
;
int
count
=
-
1
;
if
(
type
==
STANDART
)
if
(
type
==
STANDART
)
count
=
countMatIntersection
<
Vec2f
>
(
exp_lines
,
lines
,
thetaStep
+
FLT_EPSILON
,
rhoStep
+
FLT_EPSILON
);
count
=
countMatIntersection
<
Vec2f
>
(
exp_lines
,
lines
,
(
float
)
thetaStep
+
FLT_EPSILON
,
(
float
)
rhoStep
+
FLT_EPSILON
);
else
if
(
type
==
PROBABILISTIC
)
else
if
(
type
==
PROBABILISTIC
)
count
=
countMatIntersection
<
Vec4i
>
(
exp_lines
,
lines
,
thetaStep
,
0.0
);
count
=
countMatIntersection
<
Vec4i
>
(
exp_lines
,
lines
,
1e-4
f
,
0.
f
);
EXPECT_GE
(
count
,
(
int
)
(
exp_lines
.
total
()
*
0.8
)
);
EXPECT_GE
(
count
,
(
int
)
(
exp_lines
.
total
()
*
0.8
)
);
}
}
...
@@ -205,13 +204,13 @@ TEST_P(ProbabilisticHoughLinesTest, regression)
...
@@ -205,13 +204,13 @@ TEST_P(ProbabilisticHoughLinesTest, regression)
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
StandartHoughLinesTest
,
testing
::
Combine
(
testing
::
Values
(
"shared/pic5.png"
,
"../stitching/a1.png"
),
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
StandartHoughLinesTest
,
testing
::
Combine
(
testing
::
Values
(
"shared/pic5.png"
,
"../stitching/a1.png"
),
testing
::
Values
(
1
,
10
),
testing
::
Values
(
1
,
10
),
testing
::
Values
(
0.0
1
,
0.1
),
testing
::
Values
(
0.0
5
,
0.1
),
testing
::
Values
(
100
,
20
0
)
testing
::
Values
(
80
,
15
0
)
));
));
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
ProbabilisticHoughLinesTest
,
testing
::
Combine
(
testing
::
Values
(
"shared/pic5.png"
,
"shared/pic1.png"
),
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
ProbabilisticHoughLinesTest
,
testing
::
Combine
(
testing
::
Values
(
"shared/pic5.png"
,
"shared/pic1.png"
),
testing
::
Values
(
5
,
10
),
testing
::
Values
(
5
,
10
),
testing
::
Values
(
0.0
1
,
0.1
),
testing
::
Values
(
0.0
5
,
0.1
),
testing
::
Values
(
75
,
150
),
testing
::
Values
(
75
,
150
),
testing
::
Values
(
0
,
10
),
testing
::
Values
(
0
,
10
),
testing
::
Values
(
0
,
4
)
testing
::
Values
(
0
,
4
)
...
...
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