-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from RexWzh/rex-dev
interact with ZBar
- Loading branch information
Showing
6 changed files
with
126 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "QRCoders" | ||
uuid = "f42e9828-16f3-11ed-2883-9126170b272d" | ||
authors = ["Jérémie Gillet <[email protected]> and contributors"] | ||
version = "1.4.4" | ||
version = "1.4.5" | ||
|
||
[deps] | ||
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" | ||
|
@@ -19,13 +19,3 @@ ImageMagick = "1" | |
StatsBase = "0.33" | ||
UnicodePlots = "2.7 - 2.12" | ||
julia = "1.3" | ||
|
||
[extras] | ||
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795" | ||
QRDecoders = "d4999880-6331-4276-8b7d-7ee1f305cff8" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" | ||
|
||
[targets] | ||
test = ["ImageTransformations", "QRDecoders", "Test", "Random", "TestImages"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[deps] | ||
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" | ||
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" | ||
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795" | ||
QRDecoders = "d4999880-6331-4276-8b7d-7ee1f305cff8" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990" | ||
ZBar = "ae056753-435e-4d6b-8005-e923ff6e8938" | ||
|
||
[compat] | ||
julia = "1.6" | ||
ZBar = "0.1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# interact with ZBar.jl | ||
|
||
#= | ||
Note for ZBar.jl | ||
1. `decodeimg` works for multiple QR codes in one image(some message failed in `--xml` mode) | ||
2. `decodesingle` works for single QR code in one image(some message might be misleading in `--noxml` mode) | ||
=# | ||
|
||
testzbar = "testimages/zbar/" | ||
mkpath(testzbar) | ||
|
||
@testset "Decode mode" begin | ||
# Numeric mode | ||
txt = join(rand(0:9, 10)) | ||
exportqrcode(txt, "$testzbar/numeric.png") | ||
@test decodesingle("$testzbar/numeric.png") == txt | ||
@test decodeimg("$testzbar/numeric.png")[1] == txt | ||
txtall = join(0:9) | ||
exportqrcode(txtall, "$testzbar/allnumeric.png") | ||
@test decodesingle("$testzbar/allnumeric.png") == txtall | ||
@test decodeimg("$testzbar/allnumeric.png")[1] == txtall | ||
|
||
# Alphanumeric mode | ||
txt = join(rand(keys(alphanumeric), 10)) | ||
exportqrcode(txt, "$testzbar/alphanum.png") | ||
@test decodesingle("$testzbar/alphanum.png") == txt | ||
@test decodeimg("$testzbar/alphanum.png")[1] == txt | ||
txtall = join(keys(alphanumeric)) | ||
exportqrcode(txtall, "$testzbar/allalphanum.png") | ||
@test decodesingle("$testzbar/allalphanum.png") == txtall | ||
@test decodeimg("$testzbar/allalphanum.png")[1] == txtall | ||
|
||
# Byte mode -- ASCII | ||
txt = join(rand(Char.(0:127), 10)) | ||
exportqrcode(txt, "$testzbar/byte-ascii.png") | ||
@test decodesingle("$testzbar/byte-ascii.png") == txt | ||
## decodeimg misdecode some message | ||
@test_broken decodeimg("$testzbar/byte-ascii.png")[1] == txt | ||
|
||
txtall = join(Char.(0:127)) | ||
exportqrcode(txtall, "$testzbar/allbyte-ascii.png") | ||
@test decodesingle("$testzbar/allbyte-ascii.png") == txtall | ||
## decodeimg misdecode some message | ||
@test_broken decodeimg("$testzbar/allbyte-ascii.png")[1] == txtall | ||
|
||
# Byte mode -- 128-255 | ||
txt = "©®±²³" | ||
exportqrcode(txt, "$testzbar/byte-128-255.png") | ||
## zbar use different encoding for 0xf0-0xff | ||
@test_broken decodesingle("$testzbar/byte-128-255.png") == txt | ||
@test_broken decodeimg("$testzbar/byte-128-255.png")[1] == txt | ||
|
||
# UTF8 -- ZBar do not support UTF8 | ||
txt = "你好" | ||
exportqrcode(txt, "$testzbar/utf8.png") | ||
@test_broken decodesingle("$testzbar/utf8.png") == txt | ||
@test_broken decodeimg("$testzbar/utf8.png")[1] == txt | ||
|
||
# Kanji mode | ||
txt = "茗荷" | ||
exportqrcode(txt, "$testzbar/kanji.png") | ||
@test decodesingle("$testzbar/kanji.png") == txt | ||
## decodeimg misdecode some message | ||
@test_broken decodeimg("$testzbar/kanji.png")[1] == txt | ||
end | ||
|
||
|
||
@testset "Same message by different encoding" begin | ||
# ASCII vs 128-255 | ||
txt = "©®±²³" | ||
exportqrcode(txt, "$testzbar/ascii-128-255.png") | ||
## zbar use different encoding for 0xf0-0xff | ||
@test_broken decodesingle("$testzbar/ascii-128-255.png") == txt | ||
@test_broken decodeimg("$testzbar/ascii-128-255.png")[1] == txt | ||
|
||
# ASCII vs UTF8 | ||
txt = "你好" | ||
exportqrcode(txt, "$testzbar/ascii-utf8.png") | ||
@test_broken decodesingle("$testzbar/ascii-utf8.png") == txt | ||
@test_broken decodeimg("$testzbar/ascii-utf8.png")[1] == txt | ||
end | ||
|
||
@testset "Same message with different setting" begin | ||
message = "Hello, world!" | ||
for v in 1:5, eclevel in eclevels, mask in 0:7 | ||
exportqrcode(message, "$testzbar/v$(v)-m$(mask).png"; version=v, eclevel=eclevel, mask=mask) | ||
@test decodesingle("$testzbar/v$(v)-m$(mask).png") == message == decodeimg("$testzbar/v$(v)-m$(mask).png")[1] | ||
end | ||
for v in vcat(1:33, [35, 36, 40]) | ||
exportqrcode(message, "$testzbar/version$v.png", version=v) | ||
@test decodesingle("$testzbar/version$v.png") == message | ||
@test decodeimg("$testzbar/version$v.png")[1] == message | ||
end | ||
|
||
# ZBar fail to detect QR code when the version is too large | ||
for v in [34, 37, 38, 39] | ||
exportqrcode(message, "$testzbar/version$v.png", version=v) | ||
@test_broken decodesingle("$testzbar/version$v.png") == message | ||
@test_broken decodeimg("$testzbar/version$v.png")[1] == message | ||
end | ||
end |
fb3c3bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
fb3c3bb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/77638
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: