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
f5a0b226
Commit
f5a0b226
authored
Sep 18, 2016
by
Francisco Facioni
Committed by
Francisco Facioni
Sep 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LSD: Optimization, avoid converting the image to double
parent
31bd84de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
lsd.cpp
modules/imgproc/src/lsd.cpp
+10
-13
No files found.
modules/imgproc/src/lsd.cpp
View file @
f5a0b226
...
...
@@ -230,8 +230,8 @@ public:
private
:
Mat
image
;
Mat
_
<
double
>
scaled_image
;
double
*
scaled_image_data
;
Mat
scaled_image
;
uchar
*
scaled_image_data
;
Mat_
<
double
>
angles
;
// in rads
double
*
angles_data
;
Mat_
<
double
>
modgrad
;
...
...
@@ -414,11 +414,8 @@ void LineSegmentDetectorImpl::detect(InputArray _image, OutputArray _lines,
{
CV_INSTRUMENT_REGION
()
Mat_
<
double
>
img
=
_image
.
getMat
();
CV_Assert
(
!
img
.
empty
()
&&
img
.
channels
()
==
1
);
// Convert image to double
img
.
convertTo
(
image
,
CV_64FC1
);
image
=
_image
.
getMat
();
CV_Assert
(
!
image
.
empty
()
&&
image
.
type
()
==
CV_8UC1
);
std
::
vector
<
Vec4f
>
lines
;
std
::
vector
<
double
>
w
,
p
,
n
;
...
...
@@ -536,7 +533,7 @@ void LineSegmentDetectorImpl::ll_angle(const double& threshold,
angles_data
=
angles
.
ptr
<
double
>
(
0
);
modgrad_data
=
modgrad
.
ptr
<
double
>
(
0
);
scaled_image_data
=
scaled_image
.
ptr
<
double
>
(
0
);
scaled_image_data
=
scaled_image
.
ptr
<
uchar
>
(
0
);
img_width
=
scaled_image
.
cols
;
img_height
=
scaled_image
.
rows
;
...
...
@@ -555,11 +552,11 @@ void LineSegmentDetectorImpl::ll_angle(const double& threshold,
{
for
(
int
addr
=
y
*
img_width
,
addr_end
=
addr
+
img_width
-
1
;
addr
<
addr_end
;
++
addr
)
{
double
DA
=
scaled_image_data
[
addr
+
img_width
+
1
]
-
scaled_image_data
[
addr
];
double
BC
=
scaled_image_data
[
addr
+
1
]
-
scaled_image_data
[
addr
+
img_width
];
double
gx
=
DA
+
BC
;
// gradient x component
double
gy
=
DA
-
BC
;
// gradient y component
double
norm
=
std
::
sqrt
((
gx
*
gx
+
gy
*
gy
)
/
4
);
// gradient norm
int
DA
=
scaled_image_data
[
addr
+
img_width
+
1
]
-
scaled_image_data
[
addr
];
int
BC
=
scaled_image_data
[
addr
+
1
]
-
scaled_image_data
[
addr
+
img_width
];
int
gx
=
DA
+
BC
;
// gradient x component
int
gy
=
DA
-
BC
;
// gradient y component
double
norm
=
std
::
sqrt
((
gx
*
gx
+
gy
*
gy
)
/
4
.0
);
// gradient norm
modgrad_data
[
addr
]
=
norm
;
// store gradient
...
...
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