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
d3560120
Commit
d3560120
authored
Jul 14, 2013
by
Daniel Angelov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added define guard for ln10. Fixed some warnings.
parent
22c8010b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+1
-1
lsd.cpp
modules/imgproc/src/lsd.cpp
+20
-15
test_lsd.cpp
modules/imgproc/test/test_lsd.cpp
+1
-1
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
d3560120
...
...
@@ -974,7 +974,7 @@ private:
* Finds the angles and the gradients of the image. Generates a list of pseudo ordered points.
*
* @param threshold The minimum value of the angle that is considered defined, otherwise NOTDEF
* @param n_bins The number of bins with which gradients are ordered by, using bucket sort.
* @param n_bins The number of bins with which gradients are ordered by, using bucket sort.
* @param list Return: Vector of coordinate points that are pseudo ordered by magnitude.
* Pixels would be ordered by norm value, up to a precision given by max_grad/n_bins.
*/
...
...
modules/imgproc/src/lsd.cpp
View file @
d3560120
...
...
@@ -56,10 +56,14 @@ using namespace cv;
// PI
#ifndef M_PI
#define M_PI CV_PI // 3.14159265358979323846
#define M_PI CV_PI
#endif
#define M_3_2_PI (3 * CV_PI) / 2 // 3/2 pi
#define M_2__PI (2 * CV_PI) // 2 pi
#ifndef M_LN10
#define M_LN10 2.30258509299404568402
#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
#define NOTDEF double(-1024.0) // Label for pixels with undefined gradient.
...
...
@@ -298,7 +302,7 @@ void LSD::flsd(std::vector<Vec4i>& lines,
}
//Store the relevant data
lines
.
push_back
(
Vec4i
(
rec
.
x1
,
rec
.
y1
,
rec
.
x2
,
rec
.
y2
));
lines
.
push_back
(
Vec4i
(
int
(
rec
.
x1
),
int
(
rec
.
y1
),
int
(
rec
.
x2
),
int
(
rec
.
y2
)
));
if
(
widths
)
widths
->
push_back
(
rec
.
width
);
if
(
precisions
)
precisions
->
push_back
(
rec
.
p
);
if
(
nfas
&&
doRefine
>=
LSD_REFINE_ADV
)
nfas
->
push_back
(
log_nfa
);
...
...
@@ -353,7 +357,7 @@ void LSD::ll_angle(const double& threshold, const unsigned int& n_bins, std::vec
}
else
{
angles_data
[
addr
]
=
cv
::
fastAtan2
(
gx
,
-
gy
)
*
DEG_TO_RADS
;
// gradient angle computation
angles_data
[
addr
]
=
double
(
cv
::
fastAtan2
(
gx
,
-
gy
)
)
*
DEG_TO_RADS
;
// gradient angle computation
if
(
norm
>
max_grad
)
{
max_grad
=
norm
;
}
}
...
...
@@ -422,8 +426,8 @@ void LSD::region_grow(const cv::Point2i& s, std::vector<RegionPoint>& reg,
reg
[
0
].
angle
=
reg_angle
;
reg
[
0
].
modgrad
=
modgrad_data
[
addr
];
float
sumdx
=
cos
(
reg_angle
);
float
sumdy
=
sin
(
reg_angle
);
float
sumdx
=
float
(
std
::
cos
(
reg_angle
)
);
float
sumdy
=
float
(
std
::
sin
(
reg_angle
)
);
*
reg
[
0
].
used
=
USED
;
//Try neighboring regions
...
...
@@ -548,7 +552,8 @@ double LSD::get_theta(const std::vector<RegionPoint>& reg, const int& reg_size,
// Compute angle
double
theta
=
(
fabs
(
Ixx
)
>
fabs
(
Iyy
))
?
cv
::
fastAtan2
(
lambda
-
Ixx
,
Ixy
)
:
cv
::
fastAtan2
(
Ixy
,
lambda
-
Iyy
);
// in degs
double
(
cv
::
fastAtan2
(
float
(
lambda
-
Ixx
),
float
(
Ixy
)))
:
double
(
cv
::
fastAtan2
(
float
(
Ixy
),
float
(
lambda
-
Iyy
)));
// in degs
theta
*=
DEG_TO_RADS
;
// Correct angle by 180 deg if necessary
...
...
@@ -758,10 +763,10 @@ double LSD::rect_nfa(const rect& rec) const
edge
*
min_y
=
&
ordered_x
[
0
];
edge
*
max_y
=
&
ordered_x
[
0
];
// Will be used for loop range
ordered_x
[
0
].
p
.
x
=
rec
.
x1
-
dyhw
;
ordered_x
[
0
].
p
.
y
=
rec
.
y1
+
dxhw
;
ordered_x
[
0
].
taken
=
false
;
ordered_x
[
1
].
p
.
x
=
rec
.
x2
-
dyhw
;
ordered_x
[
1
].
p
.
y
=
rec
.
y2
+
dxhw
;
ordered_x
[
1
].
taken
=
false
;
ordered_x
[
2
].
p
.
x
=
rec
.
x2
+
dyhw
;
ordered_x
[
2
].
p
.
y
=
rec
.
y2
-
dxhw
;
ordered_x
[
2
].
taken
=
false
;
ordered_x
[
3
].
p
.
x
=
rec
.
x1
+
dyhw
;
ordered_x
[
3
].
p
.
y
=
rec
.
y1
-
dxhw
;
ordered_x
[
3
].
taken
=
false
;
ordered_x
[
0
].
p
.
x
=
int
(
rec
.
x1
-
dyhw
);
ordered_x
[
0
].
p
.
y
=
int
(
rec
.
y1
+
dxhw
)
;
ordered_x
[
0
].
taken
=
false
;
ordered_x
[
1
].
p
.
x
=
int
(
rec
.
x2
-
dyhw
);
ordered_x
[
1
].
p
.
y
=
int
(
rec
.
y2
+
dxhw
)
;
ordered_x
[
1
].
taken
=
false
;
ordered_x
[
2
].
p
.
x
=
int
(
rec
.
x2
+
dyhw
);
ordered_x
[
2
].
p
.
y
=
int
(
rec
.
y2
-
dxhw
)
;
ordered_x
[
2
].
taken
=
false
;
ordered_x
[
3
].
p
.
x
=
int
(
rec
.
x1
+
dyhw
);
ordered_x
[
3
].
p
.
y
=
int
(
rec
.
y1
-
dxhw
)
;
ordered_x
[
3
].
taken
=
false
;
std
::
sort
(
ordered_x
.
begin
(),
ordered_x
.
end
(),
AsmallerB_XoverY
);
...
...
@@ -839,15 +844,15 @@ double LSD::rect_nfa(const rect& rec) const
double
lstep
=
flstep
,
rstep
=
frstep
;
int
left_x
=
min_y
->
p
.
x
,
right_x
=
min_y
->
p
.
x
;
double
left_x
=
min_y
->
p
.
x
,
right_x
=
min_y
->
p
.
x
;
// Loop around all points in the region and count those that are aligned.
int
min_iter
=
std
::
max
(
min_y
->
p
.
y
,
0
);
int
max_iter
=
std
::
min
(
max_y
->
p
.
y
,
img_height
-
1
);
for
(
int
y
=
min_iter
;
y
<=
max_iter
;
++
y
)
{
int
adx
=
y
*
img_width
+
left_x
;
for
(
int
x
=
left_x
;
x
<=
right_x
;
++
x
,
++
adx
)
int
adx
=
y
*
img_width
+
int
(
left_x
)
;
for
(
int
x
=
int
(
left_x
);
x
<=
int
(
right_x
)
;
++
x
,
++
adx
)
{
++
total_pts
;
if
(
isAligned
(
adx
,
rec
.
theta
,
rec
.
prec
))
...
...
modules/imgproc/test/test_lsd.cpp
View file @
d3560120
...
...
@@ -83,7 +83,7 @@ void LSDBase::GenerateRotatedRect(Mat& image)
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
);
float
angle
=
rng
.
uniform
(
0
.
f
,
360.
f
);
Point2f
vertices
[
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