Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
6d2cfac3
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
6d2cfac3
编写于
10月 15, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
objdetect: validate QRdecode inputs
- drop unnecessary matrix initialization
上级
f8a27d26
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
17 addition
and
13 deletion
+17
-13
modules/objdetect/src/qrcode.cpp
modules/objdetect/src/qrcode.cpp
+16
-12
modules/objdetect/test/test_qrcode.cpp
modules/objdetect/test/test_qrcode.cpp
+1
-1
未找到文件。
modules/objdetect/src/qrcode.cpp
浏览文件 @
6d2cfac3
...
@@ -332,7 +332,7 @@ bool QRDetect::localization()
...
@@ -332,7 +332,7 @@ bool QRDetect::localization()
const
int
width
=
cvRound
(
bin_barcode
.
size
().
width
/
coeff_expansion
);
const
int
width
=
cvRound
(
bin_barcode
.
size
().
width
/
coeff_expansion
);
const
int
height
=
cvRound
(
bin_barcode
.
size
().
height
/
coeff_expansion
);
const
int
height
=
cvRound
(
bin_barcode
.
size
().
height
/
coeff_expansion
);
Size
new_size
(
width
,
height
);
Size
new_size
(
width
,
height
);
Mat
intermediate
=
Mat
::
zeros
(
new_size
,
CV_8UC1
)
;
Mat
intermediate
;
resize
(
bin_barcode
,
intermediate
,
new_size
,
0
,
0
,
INTER_LINEAR
);
resize
(
bin_barcode
,
intermediate
,
new_size
,
0
,
0
,
INTER_LINEAR
);
bin_barcode
=
intermediate
.
clone
();
bin_barcode
=
intermediate
.
clone
();
for
(
size_t
i
=
0
;
i
<
localization_points
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
localization_points
.
size
();
i
++
)
...
@@ -833,26 +833,29 @@ void QRDecode::init(const Mat &src, const vector<Point2f> &points)
...
@@ -833,26 +833,29 @@ void QRDecode::init(const Mat &src, const vector<Point2f> &points)
bool
QRDecode
::
updatePerspective
()
bool
QRDecode
::
updatePerspective
()
{
{
const
Point2f
centerPt
=
QRDetect
::
intersectionLines
(
original_points
[
0
],
original_points
[
2
],
original_points
[
1
],
original_points
[
3
]);
if
(
cvIsNaN
(
centerPt
.
x
)
||
cvIsNaN
(
centerPt
.
y
))
return
false
;
const
Size
temporary_size
(
cvRound
(
test_perspective_size
),
cvRound
(
test_perspective_size
));
const
Size
temporary_size
(
cvRound
(
test_perspective_size
),
cvRound
(
test_perspective_size
));
vector
<
Point2f
>
perspective_points
;
vector
<
Point2f
>
perspective_points
;
perspective_points
.
push_back
(
Point2f
(
0.
f
,
0.
f
));
perspective_points
.
push_back
(
Point2f
(
0.
f
,
0.
f
));
perspective_points
.
push_back
(
Point2f
(
test_perspective_size
,
0.
f
));
perspective_points
.
push_back
(
Point2f
(
test_perspective_size
,
0.
f
));
perspective_points
.
push_back
(
Point2f
(
static_cast
<
float
>
(
test_perspective_size
*
0.5
),
static_cast
<
float
>
(
test_perspective_size
*
0.5
)));
original_points
.
insert
(
original_points
.
begin
()
+
2
,
QRDetect
::
intersectionLines
(
original_points
[
0
],
original_points
[
2
],
original_points
[
1
],
original_points
[
3
]));
perspective_points
.
push_back
(
Point2f
(
test_perspective_size
,
test_perspective_size
));
perspective_points
.
push_back
(
Point2f
(
test_perspective_size
,
test_perspective_size
));
perspective_points
.
push_back
(
Point2f
(
0.
f
,
test_perspective_size
));
perspective_points
.
push_back
(
Point2f
(
0.
f
,
test_perspective_size
));
Mat
H
=
findHomography
(
original_points
,
perspective_points
);
perspective_points
.
push_back
(
Point2f
(
test_perspective_size
*
0.5
f
,
test_perspective_size
*
0.5
f
));
Mat
bin_original
=
Mat
::
zeros
(
original
.
size
(),
CV_8UC1
);
vector
<
Point2f
>
pts
=
original_points
;
pts
.
push_back
(
centerPt
);
Mat
H
=
findHomography
(
pts
,
perspective_points
);
Mat
bin_original
;
adaptiveThreshold
(
original
,
bin_original
,
255
,
ADAPTIVE_THRESH_GAUSSIAN_C
,
THRESH_BINARY
,
83
,
2
);
adaptiveThreshold
(
original
,
bin_original
,
255
,
ADAPTIVE_THRESH_GAUSSIAN_C
,
THRESH_BINARY
,
83
,
2
);
Mat
temp_intermediate
=
Mat
::
zeros
(
temporary_size
,
CV_8UC1
)
;
Mat
temp_intermediate
;
warpPerspective
(
bin_original
,
temp_intermediate
,
H
,
temporary_size
,
INTER_NEAREST
);
warpPerspective
(
bin_original
,
temp_intermediate
,
H
,
temporary_size
,
INTER_NEAREST
);
no_border_intermediate
=
temp_intermediate
(
Range
(
1
,
temp_intermediate
.
rows
),
Range
(
1
,
temp_intermediate
.
cols
));
no_border_intermediate
=
temp_intermediate
(
Range
(
1
,
temp_intermediate
.
rows
),
Range
(
1
,
temp_intermediate
.
cols
));
...
@@ -1054,6 +1057,7 @@ CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &deco
...
@@ -1054,6 +1057,7 @@ CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &deco
vector
<
Point2f
>
src_points
;
vector
<
Point2f
>
src_points
;
points
.
copyTo
(
src_points
);
points
.
copyTo
(
src_points
);
CV_Assert
(
src_points
.
size
()
==
4
);
CV_Assert
(
src_points
.
size
()
==
4
);
CV_CheckGT
(
contourArea
(
src_points
),
0.0
,
"Invalid QR code source points"
);
QRDecode
qrdec
;
QRDecode
qrdec
;
qrdec
.
init
(
inarr
,
src_points
);
qrdec
.
init
(
inarr
,
src_points
);
...
@@ -1061,7 +1065,7 @@ CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &deco
...
@@ -1061,7 +1065,7 @@ CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &deco
decoded_info
=
qrdec
.
getDecodeInformation
();
decoded_info
=
qrdec
.
getDecodeInformation
();
if
(
straight_qrcode
.
needed
())
if
(
exit_flag
&&
straight_qrcode
.
needed
())
{
{
qrdec
.
getStraightBarcode
().
convertTo
(
straight_qrcode
,
qrdec
.
getStraightBarcode
().
convertTo
(
straight_qrcode
,
straight_qrcode
.
fixedType
()
?
straight_qrcode
.
fixedType
()
?
...
...
modules/objdetect/test/test_qrcode.cpp
浏览文件 @
6d2cfac3
...
@@ -121,7 +121,7 @@ TEST(Objdetect_QRCode_basic, not_found_qrcode)
...
@@ -121,7 +121,7 @@ TEST(Objdetect_QRCode_basic, not_found_qrcode)
EXPECT_FALSE
(
detectQRCode
(
zero_image
,
corners
));
EXPECT_FALSE
(
detectQRCode
(
zero_image
,
corners
));
#ifdef HAVE_QUIRC
#ifdef HAVE_QUIRC
corners
=
std
::
vector
<
Point
>
(
4
);
corners
=
std
::
vector
<
Point
>
(
4
);
EXPECT_
FALSE
(
decodeQRCode
(
zero_image
,
corners
,
decoded_info
,
straight_barcode
));
EXPECT_
ANY_THROW
(
decodeQRCode
(
zero_image
,
corners
,
decoded_info
,
straight_barcode
));
#endif
#endif
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录