Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
f95a411b
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f95a411b
编写于
8月 05, 2018
作者:
A
Alexander Nesterov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update binarization
上级
ac4a6aad
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
14 deletion
+14
-14
modules/objdetect/src/qrcode.cpp
modules/objdetect/src/qrcode.cpp
+14
-14
未找到文件。
modules/objdetect/src/qrcode.cpp
浏览文件 @
f95a411b
...
...
@@ -7,7 +7,6 @@
#include "precomp.hpp"
#include "opencv2/objdetect.hpp"
// #include "opencv2/calib3d.hpp"
#include <limits>
#include <cmath>
...
...
@@ -21,7 +20,6 @@ class QRDecode
{
public:
void
init
(
Mat
src
,
double
eps_vertical_
=
0.2
,
double
eps_horizontal_
=
0.1
);
void
binarization
();
bool
localization
();
bool
transformation
();
Mat
getBinBarcode
()
{
return
bin_barcode
;
}
...
...
@@ -61,13 +59,7 @@ void QRDecode::init(Mat src, double eps_vertical_, double eps_horizontal_)
}
eps_vertical
=
eps_vertical_
;
eps_horizontal
=
eps_horizontal_
;
}
void
QRDecode
::
binarization
()
{
Mat
filter_barcode
;
GaussianBlur
(
barcode
,
filter_barcode
,
Size
(
3
,
3
),
0
);
threshold
(
filter_barcode
,
bin_barcode
,
100
,
255
,
THRESH_BINARY
+
THRESH_OTSU
);
adaptiveThreshold
(
barcode
,
bin_barcode
,
255
,
ADAPTIVE_THRESH_GAUSSIAN_C
,
THRESH_BINARY
,
71
,
2
);
}
vector
<
Vec3d
>
QRDecode
::
searchVerticalLines
()
...
...
@@ -343,11 +335,14 @@ bool QRDecode::computeTransformationPoints()
}
}
}
if
(
down_left_edge_point
==
Point2f
(
0
,
0
)
||
up_right_edge_point
==
Point2f
(
0
,
0
))
{
return
false
;
}
up_right_edge_point
==
Point2f
(
0
,
0
)
||
new_non_zero_elem
[
0
].
size
()
==
0
)
{
return
false
;
}
double
max_area
=
-
1
;
up_left_edge_point
=
new_non_zero_elem
[
0
][
0
];
for
(
size_t
i
=
0
;
i
<
new_non_zero_elem
[
0
].
size
();
i
++
)
{
vector
<
Point2f
>
list_edge_points
;
...
...
@@ -355,7 +350,7 @@ bool QRDecode::computeTransformationPoints()
list_edge_points
.
push_back
(
down_left_edge_point
);
list_edge_points
.
push_back
(
up_right_edge_point
);
double
temp_area
=
contourArea
(
list_edge_points
);
double
temp_area
=
fabs
(
contourArea
(
list_edge_points
)
);
if
(
max_area
<
temp_area
)
{
...
...
@@ -377,6 +372,7 @@ bool QRDecode::computeTransformationPoints()
}
}
for
(
size_t
i
=
0
;
i
<
new_non_zero_elem
[
2
].
size
();
i
++
)
{
double
temp_norm_delta
=
norm
(
up_left_edge_point
-
new_non_zero_elem
[
2
][
i
])
...
...
@@ -487,7 +483,7 @@ vector<Point2f> QRDecode::getQuadrilateral(vector<Point2f> angle_list)
hull
[
i
]
=
Point2f
(
x
,
y
);
}
const
double
experimental_area
=
contourArea
(
hull
);
const
double
experimental_area
=
fabs
(
contourArea
(
hull
)
);
vector
<
Point2f
>
result_hull_point
(
angle_size
);
double
min_norm
;
...
...
@@ -641,7 +637,7 @@ vector<Point2f> QRDecode::getQuadrilateral(vector<Point2f> angle_list)
=
intersectionLines
(
hull
[
index_hull
],
hull
[
next_index_hull
],
result_side_begin
[
0
],
result_side_end
[
0
]);
test_diff_area
=
fabs
(
contourArea
(
test_result_angle_list
)
-
experimental_area
);
test_diff_area
=
fabs
(
fabs
(
contourArea
(
test_result_angle_list
)
)
-
experimental_area
);
if
(
min_diff_area
>
test_diff_area
)
{
min_diff_area
=
test_diff_area
;
...
...
@@ -658,6 +654,11 @@ vector<Point2f> QRDecode::getQuadrilateral(vector<Point2f> angle_list)
index_hull
=
next_index_hull
;
}
while
(
index_hull
!=
unstable_pnt
);
if
(
norm
(
result_angle_list
[
0
]
-
angle_list
[
1
])
>
2
)
{
result_angle_list
[
0
]
=
angle_list
[
1
];
}
if
(
norm
(
result_angle_list
[
1
]
-
angle_list
[
0
])
>
2
)
{
result_angle_list
[
1
]
=
angle_list
[
0
];
}
if
(
norm
(
result_angle_list
[
3
]
-
angle_list
[
2
])
>
2
)
{
result_angle_list
[
3
]
=
angle_list
[
2
];
}
return
result_angle_list
;
}
...
...
@@ -730,7 +731,6 @@ bool QRCodeDetector::detect(InputArray in, OutputArray points) const
CV_Assert
(
inarr
.
type
()
==
CV_8UC1
);
QRDecode
qrdec
;
qrdec
.
init
(
inarr
,
p
->
epsX
,
p
->
epsY
);
qrdec
.
binarization
();
if
(
!
qrdec
.
localization
())
{
return
false
;
}
if
(
!
qrdec
.
transformation
())
{
return
false
;
}
vector
<
Point2f
>
pnts2f
=
qrdec
.
getTransformationPoints
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录