Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
5779c0ed
Commit
5779c0ed
authored
Nov 17, 2016
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #855 from sovrasov:line_descr_fix
parents
dd55064f
d7427cc6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
10 deletions
+30
-10
LSDDetector.cpp
modules/line_descriptor/src/LSDDetector.cpp
+3
-3
binary_descriptor.cpp
modules/line_descriptor/src/binary_descriptor.cpp
+12
-7
test_descriptors_regression.cpp
modules/line_descriptor/test/test_descriptors_regression.cpp
+15
-0
No files found.
modules/line_descriptor/src/LSDDetector.cpp
View file @
5779c0ed
...
@@ -104,7 +104,7 @@ inline void checkLineExtremes( cv::Vec4f& extremes, cv::Size imageSize )
...
@@ -104,7 +104,7 @@ inline void checkLineExtremes( cv::Vec4f& extremes, cv::Size imageSize )
void
LSDDetector
::
detect
(
const
Mat
&
image
,
CV_OUT
std
::
vector
<
KeyLine
>&
keylines
,
int
scale
,
int
numOctaves
,
const
Mat
&
mask
)
void
LSDDetector
::
detect
(
const
Mat
&
image
,
CV_OUT
std
::
vector
<
KeyLine
>&
keylines
,
int
scale
,
int
numOctaves
,
const
Mat
&
mask
)
{
{
if
(
mask
.
data
!=
NULL
&&
(
mask
.
size
()
!=
image
.
size
()
||
mask
.
type
()
!=
CV_8UC1
)
)
if
(
mask
.
data
!=
NULL
&&
(
mask
.
size
()
!=
image
.
size
()
||
mask
.
type
()
!=
CV_8UC1
)
)
throw
std
::
runtime_error
(
"Mask error while detecting lines: please check its dimensions and that data type is CV_8UC1"
);
CV_Error
(
Error
::
StsBadArg
,
"Mask error while detecting lines: please check its dimensions and that data type is CV_8UC1"
);
else
else
detectImpl
(
image
,
keylines
,
numOctaves
,
scale
,
mask
);
detectImpl
(
image
,
keylines
,
numOctaves
,
scale
,
mask
);
...
@@ -118,7 +118,7 @@ void LSDDetector::detect( const std::vector<Mat>& images, std::vector<std::vecto
...
@@ -118,7 +118,7 @@ void LSDDetector::detect( const std::vector<Mat>& images, std::vector<std::vecto
for
(
size_t
counter
=
0
;
counter
<
images
.
size
();
counter
++
)
for
(
size_t
counter
=
0
;
counter
<
images
.
size
();
counter
++
)
{
{
if
(
masks
[
counter
].
data
!=
NULL
&&
(
masks
[
counter
].
size
()
!=
images
[
counter
].
size
()
||
masks
[
counter
].
type
()
!=
CV_8UC1
)
)
if
(
masks
[
counter
].
data
!=
NULL
&&
(
masks
[
counter
].
size
()
!=
images
[
counter
].
size
()
||
masks
[
counter
].
type
()
!=
CV_8UC1
)
)
throw
std
::
runtime_error
(
"Masks error while detecting lines: please check their dimensions and that data types are CV_8UC1"
);
CV_Error
(
Error
::
StsBadArg
,
"Masks error while detecting lines: please check their dimensions and that data types are CV_8UC1"
);
else
else
detectImpl
(
images
[
counter
],
keylines
[
counter
],
numOctaves
,
scale
,
masks
[
counter
]
);
detectImpl
(
images
[
counter
],
keylines
[
counter
],
numOctaves
,
scale
,
masks
[
counter
]
);
...
@@ -136,7 +136,7 @@ void LSDDetector::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& keyline
...
@@ -136,7 +136,7 @@ void LSDDetector::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& keyline
/*check whether image depth is different from 0 */
/*check whether image depth is different from 0 */
if
(
image
.
depth
()
!=
0
)
if
(
image
.
depth
()
!=
0
)
throw
std
::
runtime_error
(
"Error, depth image!= 0"
);
CV_Error
(
Error
::
BadDepth
,
"Error, depth image!= 0"
);
/* create a pointer to self */
/* create a pointer to self */
LSDDetector
*
lsd
=
const_cast
<
LSDDetector
*>
(
this
);
LSDDetector
*
lsd
=
const_cast
<
LSDDetector
*>
(
this
);
...
...
modules/line_descriptor/src/binary_descriptor.cpp
View file @
5779c0ed
...
@@ -338,11 +338,11 @@ int BinaryDescriptor::descriptorSize() const
...
@@ -338,11 +338,11 @@ int BinaryDescriptor::descriptorSize() const
static
inline
int
get2Pow
(
int
i
)
static
inline
int
get2Pow
(
int
i
)
{
{
if
(
i
>=
0
&&
i
<=
7
)
if
(
i
>=
0
&&
i
<=
7
)
return
(
int
)
pow
(
2
,
(
double
)
i
);
return
1
<<
i
;
else
else
{
{
throw
std
::
runtime_error
(
"Invalid power argument"
);
CV_Error
(
Error
::
StsBadArg
,
"Invalid power argument"
);
return
-
1
;
}
}
}
}
...
@@ -421,7 +421,7 @@ void BinaryDescriptor::detect( const Mat& image, CV_OUT std::vector<KeyLine>& ke
...
@@ -421,7 +421,7 @@ void BinaryDescriptor::detect( const Mat& image, CV_OUT std::vector<KeyLine>& ke
}
}
if
(
mask
.
data
!=
NULL
&&
(
mask
.
size
()
!=
image
.
size
()
||
mask
.
type
()
!=
CV_8UC1
)
)
if
(
mask
.
data
!=
NULL
&&
(
mask
.
size
()
!=
image
.
size
()
||
mask
.
type
()
!=
CV_8UC1
)
)
throw
std
::
runtime_error
(
"Mask error while detecting lines: please check its dimensions and that data type is CV_8UC1"
);
CV_Error
(
Error
::
StsBadArg
,
"Mask error while detecting lines: please check its dimensions and that data type is CV_8UC1"
);
else
else
detectImpl
(
image
,
keylines
,
mask
);
detectImpl
(
image
,
keylines
,
mask
);
...
@@ -441,7 +441,7 @@ void BinaryDescriptor::detect( const std::vector<Mat>& images, std::vector<std::
...
@@ -441,7 +441,7 @@ void BinaryDescriptor::detect( const std::vector<Mat>& images, std::vector<std::
for
(
size_t
counter
=
0
;
counter
<
images
.
size
();
counter
++
)
for
(
size_t
counter
=
0
;
counter
<
images
.
size
();
counter
++
)
{
{
if
(
masks
[
counter
].
data
!=
NULL
&&
(
masks
[
counter
].
size
()
!=
images
[
counter
].
size
()
||
masks
[
counter
].
type
()
!=
CV_8UC1
)
)
if
(
masks
[
counter
].
data
!=
NULL
&&
(
masks
[
counter
].
size
()
!=
images
[
counter
].
size
()
||
masks
[
counter
].
type
()
!=
CV_8UC1
)
)
throw
std
::
runtime_error
(
"Masks error while detecting lines: please check their dimensions and that data types are
CV_8UC1"
);
CV_Error
(
Error
::
StsBadArg
,
"Mask error while detecting lines: please check its dimensions and that data type is
CV_8UC1"
);
else
else
detectImpl
(
images
[
counter
],
keylines
[
counter
],
masks
[
counter
]
);
detectImpl
(
images
[
counter
],
keylines
[
counter
],
masks
[
counter
]
);
...
@@ -461,7 +461,7 @@ void BinaryDescriptor::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& ke
...
@@ -461,7 +461,7 @@ void BinaryDescriptor::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& ke
/*check whether image depth is different from 0 */
/*check whether image depth is different from 0 */
if
(
image
.
depth
()
!=
0
)
if
(
image
.
depth
()
!=
0
)
throw
std
::
runtime_error
(
"Warning, depth image!= 0"
);
CV_Error
(
Error
::
BadDepth
,
"Warning, depth image!= 0"
);
/* create a pointer to self */
/* create a pointer to self */
BinaryDescriptor
*
bn
=
const_cast
<
BinaryDescriptor
*>
(
this
);
BinaryDescriptor
*
bn
=
const_cast
<
BinaryDescriptor
*>
(
this
);
...
@@ -547,7 +547,7 @@ void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& k
...
@@ -547,7 +547,7 @@ void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& k
/*check whether image's depth is different from 0 */
/*check whether image's depth is different from 0 */
if
(
image
.
depth
()
!=
0
)
if
(
image
.
depth
()
!=
0
)
throw
std
::
runtime_error
(
"Error, depth of image != 0"
);
CV_Error
(
Error
::
BadDepth
,
"Error, depth of image != 0"
);
/* keypoints list can't be empty */
/* keypoints list can't be empty */
if
(
keylines
.
size
()
==
0
)
if
(
keylines
.
size
()
==
0
)
...
@@ -2196,6 +2196,11 @@ int BinaryDescriptor::EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &e
...
@@ -2196,6 +2196,11 @@ int BinaryDescriptor::EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &e
"numofedgePixel1 = "
<<
offsetPFirst
<<
", numofedgePixel2 = "
<<
offsetPSecond
<<
", MaxNumOfEdgePixel="
<<
edgePixelArraySize
<<
std
::
endl
;
"numofedgePixel1 = "
<<
offsetPFirst
<<
", numofedgePixel2 = "
<<
offsetPSecond
<<
", MaxNumOfEdgePixel="
<<
edgePixelArraySize
<<
std
::
endl
;
return
-
1
;
return
-
1
;
}
}
if
(
!
(
offsetPFirst
&&
offsetPSecond
)
)
{
std
::
cout
<<
"Edge drawing Error: lines not found"
<<
std
::
endl
;
return
-
1
;
}
/*now all the edge information are stored in pFirstPartEdgeX_, pFirstPartEdgeY_,
/*now all the edge information are stored in pFirstPartEdgeX_, pFirstPartEdgeY_,
*pFirstPartEdgeS_, pSecondPartEdgeX_, pSecondPartEdgeY_, pSecondPartEdgeS_;
*pFirstPartEdgeS_, pSecondPartEdgeX_, pSecondPartEdgeY_, pSecondPartEdgeS_;
...
...
modules/line_descriptor/test/test_descriptors_regression.cpp
View file @
5779c0ed
...
@@ -372,3 +372,18 @@ TEST( BinaryDescriptor_Descriptors, regression )
...
@@ -372,3 +372,18 @@ TEST( BinaryDescriptor_Descriptors, regression )
CV_BD_DescriptorsTest
<
Hamming
>
test
(
std
::
string
(
"lbd_descriptors_cameraman"
),
1
);
CV_BD_DescriptorsTest
<
Hamming
>
test
(
std
::
string
(
"lbd_descriptors_cameraman"
),
1
);
test
.
safe_run
();
test
.
safe_run
();
}
}
/****************************************************************************************\
* Other tests *
\****************************************************************************************/
TEST
(
BinaryDescriptor
,
no_lines_found
)
{
Mat
Image
=
Mat
::
zeros
(
100
,
100
,
CV_8U
);
Ptr
<
line_descriptor
::
BinaryDescriptor
>
binDescriptor
=
line_descriptor
::
BinaryDescriptor
::
createBinaryDescriptor
();
std
::
vector
<
cv
::
line_descriptor
::
KeyLine
>
keyLines
;
binDescriptor
->
detect
(
Image
,
keyLines
);
ASSERT_EQ
(
keyLines
.
size
(),
0u
);
}
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