Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
a1b4aa5e
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 大约 1 年
通知
1005
Star
71102
Fork
55580
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a1b4aa5e
编写于
2月 18, 2023
作者:
G
Genci Berisha
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added QR_Code data flip support, flip and retry after first EEC failure
Added regression test for the flipped images
上级
c4226f04
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
0 deletion
+55
-0
3rdparty/quirc/include/quirc.h
3rdparty/quirc/include/quirc.h
+2
-0
3rdparty/quirc/src/decode.c
3rdparty/quirc/src/decode.c
+15
-0
modules/objdetect/src/qrcode.cpp
modules/objdetect/src/qrcode.cpp
+6
-0
modules/objdetect/test/test_qrcode.cpp
modules/objdetect/test/test_qrcode.cpp
+32
-0
未找到文件。
3rdparty/quirc/include/quirc.h
浏览文件 @
a1b4aa5e
...
...
@@ -165,6 +165,8 @@ void quirc_extract(const struct quirc *q, int index,
/* Decode a QR-code, returning the payload data. */
quirc_decode_error_t
quirc_decode
(
const
struct
quirc_code
*
code
,
struct
quirc_data
*
data
);
/* flip the QR code horizontaly (mirror flip) */
void
quirc_flip
(
struct
quirc_code
*
code
);
#ifdef __cplusplus
}
...
...
3rdparty/quirc/src/decode.c
浏览文件 @
a1b4aa5e
...
...
@@ -917,3 +917,18 @@ quirc_decode_error_t quirc_decode(const struct quirc_code *code,
return
QUIRC_SUCCESS
;
}
void
quirc_flip
(
struct
quirc_code
*
code
)
{
struct
quirc_code
flipped
=
{
0
};
unsigned
int
offset
=
0
;
for
(
int
y
=
0
;
y
<
code
->
size
;
y
++
)
{
for
(
int
x
=
0
;
x
<
code
->
size
;
x
++
)
{
if
(
grid_bit
(
code
,
y
,
x
))
{
flipped
.
cell_bitmap
[
offset
>>
3u
]
|=
(
1u
<<
(
offset
&
7u
));
}
offset
++
;
}
}
memcpy
(
&
code
->
cell_bitmap
,
&
flipped
.
cell_bitmap
,
sizeof
(
flipped
.
cell_bitmap
));
}
modules/objdetect/src/qrcode.cpp
浏览文件 @
a1b4aa5e
...
...
@@ -2732,6 +2732,12 @@ bool QRDecode::decodingProcess()
quirc_data
qr_code_data
;
quirc_decode_error_t
errorCode
=
quirc_decode
(
&
qr_code
,
&
qr_code_data
);
if
(
errorCode
==
QUIRC_ERROR_DATA_ECC
){
quirc_flip
(
&
qr_code
);
errorCode
=
quirc_decode
(
&
qr_code
,
&
qr_code_data
);
}
if
(
errorCode
!=
0
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
qr_code_data
.
payload_len
;
i
++
)
...
...
modules/objdetect/test/test_qrcode.cpp
浏览文件 @
a1b4aa5e
...
...
@@ -708,6 +708,38 @@ TEST(Objdetect_QRCode_detect, detect_regression_21287)
#endif
}
TEST
(
Objdetect_QRCode_detect_flipped
,
regression_23249
)
{
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
flipped_images
=
// image name , expected result
{{
"flipped_1.png"
,
"The key is /qrcod_OMevpf"
},
{
"flipped_2.png"
,
"A26"
}};
const
std
::
string
root
=
"qrcode/flipped/"
;
for
(
const
auto
&
flipped_image
:
flipped_images
){
const
std
::
string
&
image_name
=
flipped_image
.
first
;
const
std
::
string
&
expect_msg
=
flipped_image
.
second
;
std
::
string
image_path
=
findDataFile
(
root
+
image_name
);
Mat
src
=
imread
(
image_path
);
ASSERT_FALSE
(
src
.
empty
())
<<
"Can't read image: "
<<
image_path
;
QRCodeDetector
qrcode
;
std
::
vector
<
Point
>
corners
;
Mat
straight_barcode
;
cv
::
String
decoded_info
;
EXPECT_TRUE
(
qrcode
.
detect
(
src
,
corners
));
EXPECT_TRUE
(
!
corners
.
empty
());
std
::
string
decoded_msg
;
#ifdef HAVE_QUIRC
EXPECT_NO_THROW
(
decoded_msg
=
qrcode
.
decode
(
src
,
corners
,
straight_barcode
));
ASSERT_FALSE
(
straight_barcode
.
empty
())
<<
"Can't decode qrimage."
;
EXPECT_EQ
(
expect_msg
,
decoded_msg
);
#endif
}
}
// @author Kumataro, https://github.com/Kumataro
TEST
(
Objdetect_QRCode_decode
,
decode_regression_21929
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录