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
e51e00ac
Commit
e51e00ac
authored
Jul 12, 2013
by
Daniel Angelov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added LSD accuracy tests.
parent
5350a2f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
217 additions
and
11 deletions
+217
-11
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+1
-1
lsd.cpp
modules/imgproc/src/lsd.cpp
+4
-10
test_lsd.cpp
modules/imgproc/test/test_lsd.cpp
+212
-0
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
e51e00ac
...
...
@@ -844,7 +844,7 @@ public:
* Create an LSD object. Specifying scale, number of subdivisions for the image, should the lines be refined and other constants as follows:
*
* @param _refine How should the lines found be refined?
*
NO_REFINE
- No refinement applied.
*
REFINE_NONE
- No refinement applied.
* REFINE_STD - Standard refinement is applied. E.g. breaking arches into smaller line approximations.
* REFINE_ADV - Advanced refinement. Number of false alarms is calculated,
* lines are refined through increase of precision, decrement in size, etc.
...
...
modules/imgproc/src/lsd.cpp
View file @
e51e00ac
/*///////////////////////////////////////////////////////////////////////////////////////
/*
M
///////////////////////////////////////////////////////////////////////////////////////
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
...
...
@@ -37,13 +37,8 @@
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//*/
//
M
*/
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include "precomp.hpp"
...
...
@@ -61,13 +56,12 @@ using namespace cv;
// PI
#ifndef M_PI
#define M_PI CV_PI // 3.14159265358979323846
#define M_PI CV_PI
// 3.14159265358979323846
#endif
#define M_3_2_PI (3 * CV_PI) / 2 // 4.71238898038 // 3/2 pi
#define M_2__PI 2 * CV_PI // 6.28318530718 // 2 pi
// Label for pixels with undefined gradient.
#define NOTDEF double(-1024.0)
#define NOTDEF double(-1024.0) // Label for pixels with undefined gradient.
#define NOTUSED 0 // Label for pixels not used in yet.
#define USED 1 // Label for pixels already used in detection.
...
...
modules/imgproc/test/test_lsd.cpp
0 → 100644
View file @
e51e00ac
#include "test_precomp.hpp"
#include <vector>
using
namespace
cv
;
using
namespace
std
;
const
Size
img_size
(
640
,
480
);
class
LSDBase
:
public
testing
::
Test
{
public
:
LSDBase
()
{};
protected
:
Mat
test_image
;
vector
<
Vec4i
>
lines
;
void
GenerateWhiteNoise
(
Mat
&
image
);
void
GenerateConstColor
(
Mat
&
image
);
void
GenerateLines
(
Mat
&
image
,
const
unsigned
int
numLines
);
void
GenerateRotatedRect
(
Mat
&
image
);
virtual
void
SetUp
();
};
class
LSD_ADV
:
public
LSDBase
{
public
:
LSD_ADV
()
{};
protected
:
};
class
LSD_STD
:
public
LSDBase
{
public
:
LSD_STD
()
{};
protected
:
};
class
LSD_NONE
:
public
LSDBase
{
public
:
LSD_NONE
()
{};
protected
:
};
void
LSDBase
::
GenerateWhiteNoise
(
Mat
&
image
)
{
image
=
Mat
(
img_size
,
CV_8UC1
);
RNG
rng
(
getTickCount
());
rng
.
fill
(
image
,
RNG
::
UNIFORM
,
0
,
256
);
}
void
LSDBase
::
GenerateConstColor
(
Mat
&
image
)
{
RNG
rng
(
getTickCount
());
image
=
Mat
(
img_size
,
CV_8UC1
,
Scalar
::
all
(
rng
.
uniform
(
0
,
256
)));
}
void
LSDBase
::
GenerateLines
(
Mat
&
image
,
const
unsigned
int
numLines
)
{
RNG
rng
(
getTickCount
());
image
=
Mat
(
img_size
,
CV_8UC1
,
Scalar
::
all
(
rng
.
uniform
(
0
,
128
)));
for
(
unsigned
int
i
=
0
;
i
<
numLines
;
++
i
)
{
int
y
=
rng
.
uniform
(
10
,
img_size
.
width
-
10
);
Point
p1
(
y
,
10
);
Point
p2
(
y
,
img_size
.
height
-
10
);
line
(
image
,
p1
,
p2
,
Scalar
(
255
),
1
);
}
}
void
LSDBase
::
GenerateRotatedRect
(
Mat
&
image
)
{
RNG
rng
(
getTickCount
());
image
=
Mat
::
zeros
(
img_size
,
CV_8UC1
);
Point
center
(
rng
.
uniform
(
img_size
.
width
/
4
,
img_size
.
width
*
3
/
4
),
rng
.
uniform
(
img_size
.
height
/
4
,
img_size
.
height
*
3
/
4
));
Size
rect_size
(
rng
.
uniform
(
img_size
.
width
/
8
,
img_size
.
width
/
6
),
rng
.
uniform
(
img_size
.
height
/
8
,
img_size
.
height
/
6
));
float
angle
=
rng
.
uniform
(
0
,
360
);
Point2f
vertices
[
4
];
RotatedRect
rRect
=
RotatedRect
(
center
,
rect_size
,
angle
);
rRect
.
points
(
vertices
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
line
(
image
,
vertices
[
i
],
vertices
[(
i
+
1
)
%
4
],
Scalar
(
255
));
}
}
void
LSDBase
::
SetUp
()
{
lines
.
clear
();
test_image
=
Mat
();
}
TEST_F
(
LSD_ADV
,
whiteNoise
)
{
GenerateWhiteNoise
(
test_image
);
LSD
detector
(
LSD_REFINE_ADV
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_GE
(
40
,
lines
.
size
());
}
TEST_F
(
LSD_ADV
,
constColor
)
{
GenerateConstColor
(
test_image
);
LSD
detector
(
LSD_REFINE_ADV
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
0
,
lines
.
size
());
}
TEST_F
(
LSD_ADV
,
lines
)
{
const
int
numOfLines
=
3
;
GenerateLines
(
test_image
,
numOfLines
);
LSD
detector
(
LSD_REFINE_ADV
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
numOfLines
*
2
,
lines
.
size
());
// * 2 because of Gibbs effect
}
TEST_F
(
LSD_ADV
,
rotatedRect
)
{
GenerateRotatedRect
(
test_image
);
LSD
detector
(
LSD_REFINE_ADV
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_LE
(
4
,
lines
.
size
());
}
TEST_F
(
LSD_STD
,
whiteNoise
)
{
GenerateWhiteNoise
(
test_image
);
LSD
detector
(
LSD_REFINE_STD
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_GE
(
50
,
lines
.
size
());
}
TEST_F
(
LSD_STD
,
constColor
)
{
GenerateConstColor
(
test_image
);
LSD
detector
(
LSD_REFINE_STD
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
0
,
lines
.
size
());
}
TEST_F
(
LSD_STD
,
lines
)
{
const
int
numOfLines
=
3
;
//1
GenerateLines
(
test_image
,
numOfLines
);
LSD
detector
(
LSD_REFINE_STD
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
numOfLines
*
2
,
lines
.
size
());
// * 2 because of Gibbs effect
}
TEST_F
(
LSD_STD
,
rotatedRect
)
{
GenerateRotatedRect
(
test_image
);
LSD
detector
(
LSD_REFINE_STD
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
8
,
lines
.
size
());
}
TEST_F
(
LSD_NONE
,
whiteNoise
)
{
GenerateWhiteNoise
(
test_image
);
LSD
detector
(
LSD_REFINE_NONE
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_GE
(
50
,
lines
.
size
());
}
TEST_F
(
LSD_NONE
,
constColor
)
{
GenerateConstColor
(
test_image
);
LSD
detector
(
LSD_REFINE_NONE
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
0
,
lines
.
size
());
}
TEST_F
(
LSD_NONE
,
lines
)
{
const
int
numOfLines
=
3
;
//1
GenerateLines
(
test_image
,
numOfLines
);
LSD
detector
(
LSD_REFINE_NONE
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
numOfLines
*
2
,
lines
.
size
());
// * 2 because of Gibbs effect
}
TEST_F
(
LSD_NONE
,
rotatedRect
)
{
GenerateRotatedRect
(
test_image
);
LSD
detector
(
LSD_REFINE_NONE
);
detector
.
detect
(
test_image
,
lines
);
ASSERT_EQ
(
8
,
lines
.
size
());
}
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