dlbeer / quirc Goto Github PK
View Code? Open in Web Editor NEWQR decoder library
License: Other
QR decoder library
License: Other
For compiling c code which utilizing function defined in "dbgutil.h".Like
void dump_data(const struct quirc_data *data);
void dump_cells(const struct quirc_code *code);
int load_jpeg(struct quirc *q, const char *filename);
int check_if_png(const char *filename);
int load_png(struct quirc *q, const char *filename);
I have to include dbgutil.c file in my compiling process.Like
gcc test.c dbgutil.c -o test -lquirc -lpng -ljpeg (compiling test.c code)
otherwise it throwing error related to these functions defined in dbgutil.h file.
Is these function is not part of libquirc.so librray?
Hi,
Thanks for your library first, it helps me a lot.
In normal case, this library should work on below steps,
Is it right?
When first time call quirc_resize(), it will allocates a memory for q->pixels.
But in quirc_end() -> pixels_setup(), it has a chance be replace with q->image without release.
(q->pixels = (quirc_pixel_t *)q->image;)
I think that may cause a memory leak, but I am not sure, so I come to here and try to report it to you.
Anyway, thanks for your project.
if version >= 35, ap_count in fitness_all function will out of range, because apat in version_db.c in not end with 0
Hello, I am trying to use this library on a ESP32 (with esp32-camera), but quirc_end seems to not work properly.
Platform: ESP32 (esp-idf)
quirc version: june 30 master
(but also tried an older version with same results)
Using 320x240 grayscale images
[ .... code that creates 'fb' with 'fb->buf' being image data, and uses quirc resize ]
int buf_w, buf_h;
image = quirc_begin(q, &buf_w, &buf_h);
// Fill image buffer
assert fb->len == buf_w * buf_h
memcpy(image, fb->buf, fb->len);
// End
printf("quirc_end\n");
quirc_end(q);
printf("quirc_count\n");
int id_count = quirc_count(q);
[ .... rest, but never reached ]
The code crashes somewhere is quirc_end in the 'finder_scan' part of it.
(which I know because I edited (the middle of) it like this:
pixels_setup(q, threshold);
printf("Pixel setup finished\n");
for (i = 0; i < q->h; i++)
finder_scan(q, i);
printf("Finder Scan finished\n");
Running this code does not work, but surprisingly has 2 possible crashes:
Either:
[ startup and other output ]
quirc_end
Pixel setup finished
??╔╔f79ba24b1b7a80baad9b3f8917a3b7d4aef4185de9f8cf9ef7c4eedaf23aa610╔??╔lC?PY??╔3ffcd9dcPY??╔3ffb0140lC?PY??╔4008789dPY??╔3ffb0200lC?PY??╔40087ae5PY??╔3ffb0220lC?PY??╔40084d0dPY??╔
3ffb0240lC?PY??╔40084e41PY??╔3ffb0270lC?PY??╔400da452PY??╔3ffb0290lC?PY??╔400d584dPY??╔3ffb0550lC?PY??╔400d57e8PY??╔3ffb05a0lC?PY??╔4008a6cePY??╔3ffb05d0lC?PY??╔4008ae9dPY?
?╔3ffb0600lC?PY??╔4008b75bPY??╔3ffb0620lC?PY??╔4008c64dPY??╔3ffb0640lC?PY??╔4008466aPY??╔3ffb0650lC?PY??╔400e603dPY??╔3ffb2090lC?PY??╔400e6cf4PY??╔3ffb20e0lC?PY??╔400d56b9PY
??╔3ffb2100lC?PY??╔400d54e8PY??╔3ffb5380lC?PY??╔400d1200PY??╔3ffb53a0lC?PY??╔4008b66dPY??╔3ffb53c0╔╔Rebootin╔
[ ESP32 reboots ]
Or:
[ startup and other output ]
quirc_end
Pixel setup finished
h@?i 1p?? ╔assertion "%s" failed: file "%s", line %d%s%s
)& 1 reg*h@?i 1p?? ╔h@?i 1p?? ╔h@?i 1p?? ╔h@?i 1p?? ╔assertion "%s" failed: file "%s", line %d%s%s
)& 1 reg*h@?i 1p?? ╔assertion "%s" failed: file "%s", line %d%s%s
)& 1 reg*h@?i 1p?? ╔assertion "%s" failed: file "%s", line %d%s%s
[ ... last line keeps repeating about 500 times ]
)& 1 reg*h@?i 1p?? ╔assertion "%s" failed: file "%s", line %d%s%s
)& 1 reg*h@?i 1p?? ╔assertion "%s" failed: file "%s", line %d%s%s
)& 1 reg*╔h@?i 1p?? ╔╔╔╔P ?P ?P ?P ?P ?P ?P ?@p ? ?@?|? 1p?? ╔@p ? ?@?|? 1p?? ╔
[ ESP32 stops giving output (but does not restart or anything) ]
Notice how "Pixel setup finished" is always outputted, while "Finder Scan finished" is not.
I would greatly appreciate any help
Hello, I've tried to use the code provided just like in the readme file to test the application.
here's my main
`struct quirc *qr;
qr = quirc_new();
if (!qr) {
cout << "Failed to allocate memory" << endl;
abort();
}
Mat frame = imread("A.jpg");
namedWindow("Display window", WINDOW_AUTOSIZE);
//imshow("Display window", frame);
//waitKey(0);
if (quirc_resize(qr, frame.cols, frame.rows) < 0) {
cout << "Failed to allocate video memory" << endl;
abort();
}
uint8_t *image;
int w, h;
image = quirc_begin(qr, &w, &h);
quirc_end(qr);
int num_codes=0;
int i=0;
num_codes = quirc_count(qr);
for (i = 0; i < num_codes; i++) {
struct quirc_code code;
struct quirc_data data;
quirc_decode_error_t err;
quirc_extract(qr, i, &code);
/* Decoding stage */
err = quirc_decode(&code, &data);
if (err)
cout << "DECODE FAILED: " << quirc_strerror(err) << endl;
else
cout << "Data: " << data.payload << endl;
}
quirc_destroy(qr);
return 0;`
the num_codes is returning a zero for a valid QR image, did I implement anything wrong?
I have an example of a QR code which Quirc is not able do decode. It can locate it within the image but fails later with an ECC error when decoding the data. I checked the code with the Quirc inspect tool and the pixels appear to have been read correctly. I wonder if the problem is related to the small overlayed image in the center (it's required by the Swiss QR bill standard). Other QR code readers such as ZXing or the built-in QR code reader on iOS are able to decode the image correctly. boofcv on the other hand also fails to decode the QR code data.
The QR-code example image has been intentionally removed.
Looking forward to seeing inspect, qrtest and quirc-demo are compatible with SDL2.
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));
}
memcpy(&code->cell_bitmap, &flipped.cell_bitmap, sizeof(flipped.cell_bitmap));
memcpy(code->cell_bitmap, flipped.cell_bitmap, sizeof(flipped.cell_bitmap));
Hi,
I'm working on code-words error correction algorithm as part of my thesis. I need to show a demo but didn't find any good pure python qrcode reader and my understanding with C is limited. I just want to quickly know how to get detected code words. Can somebody point me in this library to get detected codewords, preferably as an array, before feeding them for error correction.
Thanks!
Hey sorry for this novice question but I think im just missing something obvious... Would be very happy with the some guidance 🥇
code getting framebuffer
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
fb = esp_camera_fb_get(); // framebuffer in grayscale
and feed it somehow to quirc?
int w, h;
int i, count;
uint8_t *buf = quirc_begin(qr, &w, &h);
//
//Feed 'fb' into 'buf' somehow?
//
quirc_end(qr);
I've looked through the code, source files etc, but as i'm a novice ive no clue how to merge or copy the two buffers.
from esp32 code:
//replace this with your own function
display_image(fb->width, fb->height, fb->pixformat, fb->buf, fb->len);
Hello,
I'm implementing a small qrcode parser function based on this function but I can't parse on of the test image I have.
The first image is correctly parsed, but the second it's not.
$ qrtest ../test1.png
quirc test program
Copyright (C) 2010-2012 Daniel Beer <[email protected]>
Library version: 1.0
Time (ms) Count
Filename Load ID Total ID Dec
-------------------------------------------------------------------------------
test1.png : 1 3 4 1 1
$ qrtest ../test2.png
quirc test program
Copyright (C) 2010-2012 Daniel Beer <[email protected]>
Library version: 1.0
Time (ms) Count
Filename Load ID Total ID Dec
-------------------------------------------------------------------------------
test2.png : 0 1 1 0 0
I have tried with zbarimg
and both are correctly parsed, so it doesn't seem to be an issue with the 2nd image.
I tried on Fedora 27 x64, using latest master.
Hi ,
Thanks for this qr code decoding library.
I'm trying quirc-scanner example, it can work with VGA frame.
But it cant work using quirc_resize(qr, 1920, 1080), will cause segmentation fault.
Can we use others resolution besides VGA ?
Thanks.
This webapp https://qrcodereader.glitch.me/ I wrote using https://github.com/cozmo/jsQR when run on a phone can find all 4 by just showing the image on the screen of a computer and then having the phone capture it.
NOTE I'm porting quirc to WASM. I already got the the compilation to WASM working and its running a lot faster than jsQR. On my PC it runs a scan within 1-2ms. Will share that when I cleaned it up a bit
TKS
Not so much a bug report than a feature request.
Could 'inspect' be modified to attempt to mirror a reversed QR code & report it (as incompliant, it that is the case)?
Background:
In debugging an "unscannable" batch of QR codes this week (about a 50% success rate between physical and Android-based barcode scanners as well as online web decoders) - I attempted to use quirc "inspect" to try to get more info on the faulty code.
quirc returns an error (internally "QUIRC_ERROR_FORMAT_ECC") for the bad QR code, not much else - and some useful info on the "good" series. It turns out, as testing with an actual physical mirror shows, that our bad QR codes were printed mirrored; which I assume is an error and probably not compliant QR code (http://qrcode.meetheed.com/question2.php).
However, it appears that some QR decoding libraries attempt to mirror the image and retry the decoding; this also includes a few of the tested Android implementations I have tested, and at least 1 java library (I would have to check on Monday which).
The fact that multiple implementations accept and decode these mirrored QR codes, means that unfortunately these types of codes will probably continue to propagate (due to incomplete understanding of the spec, and bad/or quality control processes due, I suppose, to using incompliant devices for testing).
Perhaps there are also actual real-life situations where scanning a QR code through a mirror is useful (that, though, being outside the scope of this bugreport :-))
It would be great if the binaries/libs for all platforms were released.
I want to use this decoder in my android app. How to compile it in android studio?
Do you have any support for java or android?
Hello,
I'm new to C and I want to use quirc both as a command line utility and in my own projects. I'm on macOS Sierra. I've taken the following steps to attempt to run it
$ git clone https://github.com/dlbeer/quirc
$ brew install jpeg
$ make install
This results in
demo/camera.c:29:10: fatal error: 'linux/videodev2.h' file not found
#include <linux/videodev2.h>
^
1 error generated.
make: *** [demo/camera.o] Error 1
which is expected since the README says that the camera demo is only supported on Linux.
I'm not sure where to proceed from here. I tried creating
lib/test.c
#include "quirc.h"
$ gcc test.c
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Apologies in advance for such basic questions but I am unable to find resources that teach how to use "non standard" C libraries in my projects.
This issue is really a false positive in the Coverity static analyzer, but proposing the following patch to make it happy:
diff --git a/functional/libquirc/lib/identify.c b/functional/libquirc/lib/identify.c
index 3651ff2..8d4a511 100644
--- a/functional/libquirc/lib/identify.c
+++ b/functional/libquirc/lib/identify.c
@@ -1011,7 +1011,7 @@ static void test_neighbours(struct quirc *q, int i,
}
}
- if (best_h < 0)
+ if (best_h < 0 || best_v < 0)
return;
record_qr_grid(q, best_h, i, best_v);
It complains that best_v
could possibly be passed to record_qr_grid
while negative, where it will be used as an index into an array. Looking at how test_neighbours
is called, I think that is not correct, but I think the fix is not too intrusive, so I hope it's acceptable to you.
There's a off-by one error which can cause quirc_strerror to do an out of bounds read, changing the <=
to <
in the test should fix the issue:
diff --git a/functional/libquirc/lib/quirc.c b/functional/libquirc/lib/quirc.c
index 9abbc6c..e0ffef4 100644
--- a/functional/libquirc/lib/quirc.c
+++ b/functional/libquirc/lib/quirc.c
@@ -74,7 +74,7 @@ static const char *const error_table[] = {
const char *quirc_strerror(quirc_decode_error_t err)
{
- if (err >= 0 && err <= sizeof(error_table) / sizeof(error_table[0]))
+ if (err >= 0 && err < sizeof(error_table) / sizeof(error_table[0]))
return error_table[err];
return "Unknown error";
I have a rgb picture,this lib can scan qrcode from picture and how?thanks
I wrote a small C program at https://github.com/kAworu/node-quirc/blob/master/test/data/generated/qrgen.c to generate QR images of all combinations of {version,eclevel,mode}.
This has yield several issues, here is the output of qrtest
when 88774dc is compiled with CFLAGS="-O3 -DQUIRC_MAX_REGIONS=65534 -fPIC"
:
https://gist.github.com/kAworu/0e9774f1b29784241b7180c7096d3eef
I am decoding qr code using quirc library and getting this message.DECODE FAILED: ECC failure what does that mean.The same qr-code I am able to decode using another library.
Iam using the quirctest application to decode the QR codes coming in snapshot images from a wifi camera. Iam using a image resolution of 1920 x 1080. Iam running the application on a X86_64 machine. Application seems to detect the presence of QR code in the image but unable to decode it.
quirc test program
Copyright (C) 2010-2012 Daniel Beer <[email protected]>
Library version: 1.0
Time (ms) Count
Filename Load ID Total ID Dec
-------------------------------------------------------------------------------
/media/narayana/Hari/images:
0.jpeg : 36 10 46 0 0
1.jpeg : 15 9 24 0 0
2.jpeg : 15 9 24 0 0
3.jpeg : 15 9 24 0 0
4.jpeg : 15 12 27 0 0
5.jpeg : 16 10 26 0 0
6.jpeg : 18 11 29 0 0
QR code decode failed due to ECC failure
7.jpeg : 15 15 30 1 0
8.jpeg : 16 11 27 0 0
9.jpeg : 16 11 27 0 0
10.jpeg : 16 11 27 0 0
11.jpeg : 16 11 27 0 0
12.jpeg : 15 10 25 0 0
13.jpeg : 22 10 32 0 0
14.jpeg : 15 11 26 0 0
15.jpeg : 16 11 27 0 0
16.jpeg : 18 12 30 0 0
17.jpeg : 16 11 27 0 0
18.jpeg : 13 11 24 0 0
19.jpeg : 16 13 29 0 0
QR code decode failed due to Format data ECC failure
20.jpeg : 17 22 39 1 0
QR code decode failed due to Format data ECC failure
21.jpeg : 20 14 34 1 0
QR code decode failed due to Format data ECC failure
22.jpeg : 20 14 34 1 0
QR code decode failed due to ECC failure
23.jpeg : 21 16 37 1 0
QR code decode failed due to Format data ECC failure
24.jpeg : 22 18 40 1 0
QR code decode failed due to Format data ECC failure
25.jpeg : 22 21 43 1 0
QR code decode failed due to Format data ECC failure
26.jpeg : 23 24 48 1 0
QR code decode failed due to Format data ECC failure
27.jpeg : 19 23 42 1 0
QR code decode failed due to Format data ECC failure
28.jpeg : 22 21 43 1 0
QR code decode failed due to Format data ECC failure
29.jpeg : 20 14 34 1 0
QR code decode failed due to Format data ECC failure
30.jpeg : 18 18 36 1 0
31.jpeg : 20 18 38 0 0
32.jpeg : 27 12 39 0 0
QR code decode failed due to ECC failure
33.jpeg : 18 14 32 1 0
QR code decode failed due to Format data ECC failure
34.jpeg : 17 14 31 1 0
35.jpeg : 19 11 30 0 0
QR code decode failed due to Format data ECC failure
36.jpeg : 17 14 31 1 0
QR code decode failed due to ECC failure
37.jpeg : 17 14 31 1 0
QR code decode failed due to Format data ECC failure
38.jpeg : 25 14 39 1 0
QR code decode failed due to Format data ECC failure
39.jpeg : 23 14 37 1 0
QR code decode failed due to Format data ECC failure
40.jpeg : 22 13 35 1 0
QR code decode failed due to ECC failure
41.jpeg : 23 16 40 1 0
QR code decode failed due to ECC failure
42.jpeg : 17 15 32 1 0
QR code decode failed due to ECC failure
43.jpeg : 18 14 32 1 0
QR code decode failed due to ECC failure
44.jpeg : 18 14 33 1 0
QR code decode failed due to ECC failure
45.jpeg : 16 15 31 1 0
QR code decode failed due to ECC failure
46.jpeg : 18 14 32 1 0
QR code decode failed due to ECC failure
47.jpeg : 17 15 32 1 0
QR code decode failed due to Format data ECC failure
48.jpeg : 17 15 32 1 0
QR code decode failed due to ECC failure
49.jpeg : 17 14 31 1 0
QR code decode failed due to ECC failure
50.jpeg : 17 14 32 1 0
QR code decode failed due to Format data ECC failure
51.jpeg : 17 14 32 1 0
QR code decode failed due to Format data ECC failure
52.jpeg : 17 14 32 1 0
QR code decode failed due to ECC failure
53.jpeg : 17 15 32 1 0
QR code decode failed due to ECC failure
54.jpeg : 18 15 33 1 0
QR code decode failed due to Format data ECC failure
55.jpeg : 17 15 32 1 0
56.jpeg : 18 12 30 0 0
57.jpeg : 17 12 29 0 0
58.jpeg : 18 12 30 0 0
QR code decode failed due to Format data ECC failure
59.jpeg : 17 16 33 1 0
60.jpeg : 18 13 31 0 0
61.jpeg : 17 12 29 0 0
QR code decode failed due to Format data ECC failure
62.jpeg : 18 15 33 1 0
63.jpeg : 18 13 31 0 0
64.jpeg : 18 13 31 0 0
65.jpeg : 16 12 28 0 0
66.jpeg : 18 13 31 0 0
67.jpeg : 17 13 30 0 0
68.jpeg : 17 13 30 0 0
69.jpeg : 19 12 31 0 0
70.jpeg : 19 12 31 0 0
71.jpeg : 22 13 35 0 0
QR code decode failed due to Format data ECC failure
72.jpeg : 16 14 30 1 0
QR code decode failed due to ECC failure
73.jpeg : 18 14 32 1 0
QR code decode failed due to Format data ECC failure
74.jpeg : 16 15 31 1 0
QR code decode failed due to ECC failure
75.jpeg : 16 15 31 1 0
QR code decode failed due to ECC failure
76.jpeg : 16 14 31 1 0
QR code decode failed due to ECC failure
77.jpeg : 16 14 30 1 0
QR code decode failed due to ECC failure
78.jpeg : 17 14 31 1 0
QR code decode failed due to Format data ECC failure
79.jpeg : 16 14 30 1 0
QR code decode failed due to ECC failure
80.jpeg : 17 14 31 1 0
QR code decode failed due to Format data ECC failure
81.jpeg : 16 14 30 1 0
82.jpeg : 17 11 28 0 0
QR code decode failed due to ECC failure
83.jpeg : 17 14 31 1 0
QR code decode failed due to ECC failure
84.jpeg : 17 15 32 1 0
QR code decode failed due to ECC failure
85.jpeg : 17 14 32 1 0
QR code decode failed due to ECC failure
86.jpeg : 16 15 31 1 0
QR code decode failed due to Format data ECC failure
87.jpeg : 17 14 31 1 0
QR code decode failed due to ECC failure
88.jpeg : 17 14 31 1 0
QR code decode failed due to ECC failure
89.jpeg : 16 15 31 1 0
QR code decode failed due to Format data ECC failure
90.jpeg : 16 15 31 1 0
QR code decode failed due to Format data ECC failure
91.jpeg : 16 16 32 1 0
QR code decode failed due to ECC failure
92.jpeg : 16 15 31 1 0
QR code decode failed due to ECC failure
93.jpeg : 17 14 31 1 0
QR code decode failed due to Format data ECC failure
94.jpeg : 17 14 31 1 0
QR code decode failed due to ECC failure
95.jpeg : 18 14 33 1 0
QR code decode failed due to ECC failure
96.jpeg : 16 15 31 1 0
QR code decode failed due to Format data ECC failure
97.jpeg : 17 14 32 1 0
QR code decode failed due to ECC failure
98.jpeg : 16 15 31 1 0
JPEG error: Premature end of JPEG file
QR code decode failed due to ECC failure
99.jpeg : 13 18 31 1 0
-------------------------------------------------------------------------------
images: 100 files, 63 codes, 0 decoded (63 failures), 0% success rate
Total time [load: 1780, identify: 1390, total: 3180]
Average time [load: 17, identify: 13, total: 31]
Iam attaching one of the image i used for testing.
I need help in getting the application to scan the QR code.
I want to know what is wrong and what needs to be improved.
Hi
I'm working on porting the quirc library on embedded system, and try to refer the quirc-scanner example to scan qrcode.
However my device support the video format is YUV420 ,
Is it suitable for scanning qrcode ? and how to extract luma channel from yuv420 image?
I 'm not have much experience on qrcode scan , but if any suggestions would be helpful.
Thanks.
Nick
Hi, I'm packaging this lib for conan: conan-io/conan-center-index#944
Would it be possible to create a new release as you did 3 years ago for homebrew?
Below are some images of a binary QR code that segfault deep in quirclib during a decode.
A trivial 'test.c' utility decode-c.txt is used for this test.
Fairly easy to reeproduce by doing:
openssl rand 400 > rnd.raw
qrencode -l H -8 -s 8 -r rnd.raw -o qr.png
decode qr.raw > rnd.raw.2 && openssl sha256 rnd.raw.*
a few times (1 in 10 or so fails). Below QR codes segfault on OSX, Linux and FreeBSD; SHA256 of the raw binary shown next to each.
160c8cc11f06d0bd11519c53a5f62ec15cd98cf5dc763dfff5e07a13d1e2797c
75daa67b1aa3ebc67570d8c82ac712bd43eb450a83aeced21ee5236ee261628b
95d1ce7eee8f24f7b4892747c287be3b2825899f84b817e6c0c0e88ee9de5384
It seems both q->image and q-> pixels are pointers to dynamically allocated arrays. The sizeof() operator have no way of knowing the actual size of the malloc array. This expression will always be true and the first branch will always taken, which makes the if statement useless.
Line 1079 in 307473d
Hello, first off thanks for quirc :)
I am working in a somewhat unique build environment. I will pushing a cmake branch to my fork soon, and I would like to know if you are interested by it? A build system is usually a very subjective and personal subject, I fully understand if you do not want a PR for this.
Reasons I needed cmake include compiling on windows. Cmake automagically generates VS projects. VS2015 doesn't support C99 and C11, but they have added the LLVM toolchain. So by issuing cmake .. -G "Visual Studio 14 2015 Win64" -T "LLVM-vs2014"
you can generate a Visual Studio project that compiles fine. I now have a windows lib (yay!).
If you are at all interested, I could spend the time to add cmake installation steps, so other users could use the builtin find_package(quirc) cmake function.
Good day
With Centos 3.10.0-693.17.1.el7.x86_64 and GNU Make 3.82, make error
Makefile:18: *** missing separator. Stop.
but with Mac os and GNU Make 3.81, there is no such error.
Line 18 is SDL_CFLAGS != pkg-config --cflags sdl
Can anyone help me? Thanks
Hi,
in identify.c :
int row_average[q->w];
It seems some C99 extensions are used (and that are not supported by some compilers :-/
For example VSC++ 2015
I was using quirc lib in ROS simulation and everything goes smoothly excepts that it cannot detect any qr code I put in the gazebo simulation environment. I don't know if it's because the conversion between ROS sensor_msgs/Image topic and quirc image goes wrong or because the gazebo simulated image is not "real" enough. Any idea?
The gazebo image looks as follows:
For software selection purposes, can you be a little bit more specific in the README.md about what QR code standards/variants the library is supposed to support?
In function otsu in identify.c file:
unsigned int histogram[HISTOGRAM_SIZE]
is a vla for Visual Studio, so it can't compile.This simple patch fix these issues:
--- a/lib/identify.c
+++ b/lib/identify.c
@@ -180,7 +180,7 @@ static uint8_t otsu(const struct quirc *q)
int numPixels = q->w * q->h;
// Calculate histogram
- const int HISTOGRAM_SIZE = 256;
+ #define HISTOGRAM_SIZE 256
unsigned int histogram[HISTOGRAM_SIZE];
memset(histogram, 0, (HISTOGRAM_SIZE) * sizeof(unsigned int));
uint8_t* ptr = q->image;
@@ -192,7 +192,8 @@ static uint8_t otsu(const struct quirc *q)
// Calculate weighted sum of histogram values
int sum = 0;
- for (int i = 0; i < HISTOGRAM_SIZE; ++i) {
+ int i;
+ for (i = 0; i < HISTOGRAM_SIZE; ++i) {
sum += i * histogram[i];
}
@@ -201,7 +202,7 @@ static uint8_t otsu(const struct quirc *q)
int q1 = 0;
double max = 0;
uint8_t threshold = 0;
- for (int i = 0; i < HISTOGRAM_SIZE; ++i) {
+ for (i = 0; i < HISTOGRAM_SIZE; ++i) {
// Weighted background
q1 += histogram[i];
if (q1 == 0)
Hi, I'm looking for a program that is capable of finding qr codes within a video file. Can Quirc do this?
Thanks.
I got quirc running on a small embedded target quite easily (nice job on the example code!), but at the moment I am only able to scan smaller QR codes because I don't have enough memory to allocate two copies of the image buffer.
My data is already in the same format that quirc requires, and looking at the code it seems like it would be easy to pass an extra (optional) parameter to quirc_resize(q,w,h,data)
and use that buffer instead of calling malloc()
. The onus is then on the caller to make sure the w
, h
, data
match up, and to not call quirc_resize()
again or to call it with a data
parameter again, and be responsible for freeing the old one.
Does this seem like something you'd consider adding (or accept a PR for)?
Thanks!
If a QR code is computer generated and has purely 0x00 and 0xff values, the OTSU thresholding fails. This could be due to two things, fixing any of which seems to solve the issue:
otsu()
method, the max check is incorrectly implemented at line 219 (identify.c).if (variance > max) {
threshold = i;
max = variance;
}
The check should be variance >= max
, specifically as per the wikipedia on otsu thresholding.
*dest++ = (value < threshold) ? QUIRC_PIXEL_BLACK : QUIRC_PIXEL_WHITE;
checks for a strictly less than value. This means that if the threshold is zero, the entire image appears white, which shouldn't be the case for an image that has no internal gray noise and is purely black and white (already thresholded).The issue goes away after fixing the first bullet here and the threshold gets set to 0xfe
, as should be. However, I don't know enough about the thresholding to give an educated answer about which is the correct method to solve this issue.
I've got a patch to add quirc to Homebrew, but they really like to avoid having libraries that have no tagged releases.
Would it be possible to tag a release for quirc? Even if it's just a simple version string like 0.1 or 0.0.1.
I am utilizing libquirc for decoding QR codes from a smartphone's screen with a camera. The library has been working really well so far. However, I just discovered that there is a case where having the phone in a very specific orientation causes the library to find the QR code corner markers in invalid locations, and then fails to read the data with an ECC failure. An example image where the decoding fails is shown below:
The interesting part is, that if I rotate the image 90 degrees clockwise, the QR code is detected correctly. Also, if I photoshop away the text that is visible in the phone's display, the detection is successful.
Any ideas on how to fix or work around this?
Hi,
I've been testing quirc using a number of ways of degrading QR codes to see how it performs.
I found this case, where i think there might be an issue with the thresholding:
Works:
Fails:
The central grey areas have the same contrast, i think this could be a problem with the big difference in contrast in the white border making the row averaging unreliable.
Any ideas how to improve this?
Ed
Compiled with afl-clang-fast on Debian 8 x64. Triggered with 5174ba7
.
quirc inspection program
Copyright (C) 2010-2012 Daniel Beer <[email protected]>
Library version: 1.0
JPEG error: Invalid SOS parameters for sequential JPEGJPEG error: Unsupported marker type 0x30=================================================================
==32096==ERROR: AddressSanitizer: attempting double-free on 0x61600000f980 in thread T0:
#0 0x4a0d9b in free (/root/quirc/inspect+0x4a0d9b)
#1 0x7f0e97f65734 in fclose /build/glibc-KShDyh/glibc-2.19/libio/iofclose.c:85
#2 0x4bf587 in load_jpeg /root/quirc/tests/dbgutil.c:160:2
#3 0x4c1487 in main /root/quirc/tests/inspect.c:243:12
#4 0x7f0e97f1db44 in __libc_start_main /build/glibc-KShDyh/glibc-2.19/csu/libc-start.c:287
#5 0x4be69c in _start (/root/quirc/inspect+0x4be69c)
0x61600000f980 is located 0 bytes inside of 568-byte region [0x61600000f980,0x61600000fbb8)
freed by thread T0 here:
==32096==AddressSanitizer CHECK failed: /tmp/buildd/llvm-toolchain-3.5-3.5/projects/compiler-rt/lib/asan/asan_allocator2.cc:203 "((id)) != (0)" (0x0, 0x0)
#0 0x4a8473 in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/root/quirc/inspect+0x4a8473)
#1 0x4aeec1 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/root/quirc/inspect+0x4aeec1)
#2 0x43a519 in __asan::AsanChunkView::GetFreeStack(__sanitizer::StackTrace*) (/root/quirc/inspect+0x43a519)
#3 0x4a44dd in __asan::DescribeHeapAddress(unsigned long, unsigned long) (/root/quirc/inspect+0x4a44dd)
#4 0x4a4d9a in __asan::ReportDoubleFree(unsigned long, __sanitizer::StackTrace*) (/root/quirc/inspect+0x4a4d9a)
#5 0x43ce8d in __asan::ReportInvalidFree(void*, unsigned char, __sanitizer::StackTrace*) (/root/quirc/inspect+0x43ce8d)
#6 0x43b845 in __asan::Deallocate(void*, __sanitizer::StackTrace*, __asan::AllocType) (/root/quirc/inspect+0x43b845)
#7 0x4a0e5c in free (/root/quirc/inspect+0x4a0e5c)
#8 0x7f0e97f65734 in fclose /build/glibc-KShDyh/glibc-2.19/libio/iofclose.c:85
#9 0x4bf587 in load_jpeg /root/quirc/tests/dbgutil.c:160:2
#10 0x4c1487 in main /root/quirc/tests/inspect.c:243:12
#11 0x7f0e97f1db44 in __libc_start_main /build/glibc-KShDyh/glibc-2.19/csu/libc-start.c:287
#12 0x4be69c in _start (/root/quirc/inspect+0x4be69c)
We are using qrcodejs to generate qr codes on our server, and the problem is that, the codes generated are not decoded properly.
Open the index.html
from qrcodejs with Chrome or any browser, save the qr code to a file and inspect
will tell you that "0 QR-codes found".
I did find out a workaround to this issue: adding a border to the generated code as follows:
auto mat = cv::imread("qrcode.png", cv::IMREAD_GRAYSCALE);
auto size = mat.size();
cv::Mat vm(5, size.width, mat.type(), 255);
cv::vconcat(vm, mat, mat);
cv::vconcat(mat, vm, mat);
size = mat.size();
cv::Mat hm(size.height, 5, mat.type(), 255);
cv::hconcat(hm, mat, mat);
cv::hconcat(mat, hm, mat);
Then I'm able to decode the mat
properly.
Any ideas why the border is mandatory for it to be decoded properly?
when ever i feed an image to the quirc decoder it return an QUIRC_ERROR_DATA_ECC Error i have checked the bar-codes and they are readable.
can you help me what i am messing? I have followed the implementation as described in the read me file
qrtest couldn't find any codes in the examples of custom qr codes on the wikipedia page:
https://en.wikipedia.org/wiki/QR_code#Variants
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.