Commit graph

170 commits

Author SHA1 Message Date
ynggny
61cee01a22 Add Dockerfile for Alpine Linux and update README 2023-08-02 17:05:47 +00:00
Daniel Beer
542848dd6b Version 1.2. 2023-03-22 20:09:03 +13:00
Alexandre Perrin
c8e77ce1d6
Merge pull request #134 from igrr/feature/customize_fp_type
Add an option to use single-precision floating point in calculations
2023-03-21 10:08:36 +01:00
Ivan Grokhotkov
cc67312433
Add an option to use single-precision floating point in calculations
On some platforms, such as microcontrollers with a single-precision
FPU, operations on double type can be significantly slower compared
to the float type. For example, on ESP32-S3 microcontroller, decoding
a QR code of a certain size may take 1700ms when 'double' is used and
just 250ms when 'float' is used.

This commit adds two options to allow for such optimizations:

- QUIRC_FLOAT_TYPE: if defined, it is the type name to use in floating
  point calculations. Can be set, for example, using:
    CFLAGS += -DQUIRC_FLOAT_TYPE=float

- QUIRC_USE_TGMATH: if defined, Quirc will internally use <tgmath.h>
  header, instead of <math.h>. This C99-or-later header allows the
  program to call type-generic functions, such as 'sqrt', and the
  calls will be dispatched to the correct implementation (sqrtf, sqrt,
  sqrtl) depending on the actual argument type. Without setting this
  option, the benefit of -DQUIRC_FLOAT_TYPE=float would be limited as
  the double-precision versions of math functions would still be used.

The change is backwards compatible with existing applications. If
these macros are not defined, the behavior is the same as before.
2023-03-21 02:04:39 +01:00
Daniel Beer
516d91a94d Fix stack corruption on oversized QR codes.
Issue reported by dswetz on Github:
https://github.com/dlbeer/quirc/issues/119
2021-10-08 19:40:36 +13:00
Daniel Beer
00d5e968b6
Merge pull request #115 from yamt/inspect-opencv-tweak
inspect-opencv: Make the display similar to the SDL version
2021-08-27 13:37:05 +12:00
Daniel Beer
937b93a805
Merge pull request #114 from yamt/separate-target
Makefile: separate targets for platform dependent stuff
2021-08-27 13:35:36 +12:00
Daniel Beer
dd7d1ab9dd
Merge pull request #113 from JaapHaitsma/master
Fixes issue #122
2021-08-27 13:34:24 +12:00
YAMAMOTO Takashi
9cee399e37 inspect-opencv: Make the display similar to the SDL version
* fix color conversion bugs

* use smaller text and thinner lines
2021-08-26 15:33:57 +09:00
YAMAMOTO Takashi
50e2899ea8 Makefile: separate targets for platform dependent stuff (v4l, sdl, opencv) 2021-08-26 14:11:12 +09:00
Jaap Haitsma
7bd87c32dd Use abs instead of fabs to please compiler 2021-08-25 14:50:45 -04:00
Jaap Haitsma
064ebd5b87 Estimate gridsize better. Fixes #112 2021-08-25 14:40:31 -04:00
Daniel Beer
891550cd82
Merge pull request #105 from yamt/inspect-opencv
Add OpenCV version of inspect
2021-08-24 13:16:04 +12:00
Daniel Beer
0aa5e2ac27
Merge pull request #109 from JaapHaitsma/master
Fix issue #72 grouping and make gridsize determination more robust.
2021-06-21 11:48:10 +12:00
Jaap Haitsma
2ff513b0b4 merge upstream 2021-06-16 23:52:51 -04:00
Jaap Haitsma
c266adbc11 Merge branch 'master' of https://github.com/dlbeer/quirc 2021-06-16 23:36:18 -04:00
Jaap Haitsma
f22a89aefd do not store .vscode 2021-06-16 23:34:31 -04:00
Jaap Haitsma
0c766593bf Merge branch 'fix-grouping' of github.com:JaapHaitsma/quirc into fix-grouping 2021-06-16 23:25:54 -04:00
Jaap Haitsma
00f187d94a Remove unused functions 2021-06-16 22:18:15 -04:00
YAMAMOTO Takashi
4d6675ac17 README.md: Update for inspect-opencv 2021-05-17 08:44:08 +09:00
YAMAMOTO Takashi
003e1d98f1 inspect_opencv.cxx: Adapt to OpenCV 2021-05-17 08:44:08 +09:00
YAMAMOTO Takashi
85d4a7db29 Makefile: Add inspect-opencv target 2021-05-17 08:34:18 +09:00
YAMAMOTO Takashi
633ed29ad9 dbgutil.h: extern "C" for C++ 2021-05-17 08:34:18 +09:00
YAMAMOTO Takashi
058d7ab1da cp inspect.c inspect_opencv.cxx 2021-05-17 08:34:18 +09:00
Daniel Beer
5adb7597c1
Merge pull request #100 from yamt/flood-fill2
Improve stack usage for flood filling
2021-05-12 10:30:49 +12:00
YAMAMOTO Takashi
6b3575cd59 flood_fill_seed: Add comments on exit conditions 2021-05-11 15:03:09 +09:00
YAMAMOTO Takashi
22269c9a43 flood_fill_seed: initialize left_up and left_down together
Just for readability.
2021-05-11 14:59:22 +09:00
YAMAMOTO Takashi
87ca2b6c2d flood_fill_seed: Switch from goto to while 2021-05-11 14:57:53 +09:00
YAMAMOTO Takashi
a436fde8a0 flood_fill_seed: Reduce code duplicatino
This is also a preparation to eliminate the uses of goto.
2021-05-11 14:54:19 +09:00
YAMAMOTO Takashi
eadbc2caca flood_fill_seed: Move flood_fill_line to the "caller"
This restructure allows us to unify "call" and "return_from_call".
2021-05-11 14:09:24 +09:00
YAMAMOTO Takashi
0b69940876 flood_fill_line: call user callback as well 2021-05-11 14:05:02 +09:00
YAMAMOTO Takashi
38f882b3d6 flood_fill_seed: Simplify the flow by having a single "return point". 2021-05-11 13:46:31 +09:00
YAMAMOTO Takashi
1fa9b0c109 flood_fill_seed: Add assertions 2021-05-11 13:26:59 +09:00
YAMAMOTO Takashi
dd6c64cafe Add QUIRC_ASSERT 2021-05-11 13:26:47 +09:00
YAMAMOTO Takashi
40def012e7 flood_fill_seed: Unify "left" and "x" vars
This reduces the memory usage a bit.
2021-05-11 13:04:02 +09:00
YAMAMOTO Takashi
aad3fc63b6 flood_fill_seed: separate a logic to fill a line 2021-05-11 12:55:44 +09:00
YAMAMOTO Takashi
f1dd37fbdb quirc_resize: Make this a bit more careful about integer overflows
Also, avoid malloc(0), which is not too portable.
2021-05-11 11:05:58 +09:00
YAMAMOTO Takashi
772cd3e73f Improve stack usage for flood filling
* Make flood filling logic iterative (vs recursive)
  I basically tried one-to-one conversions here to avoid mistakes.
  probably it has a room for later optimizations.

* Use explicit malloc (vs variables on stack) to allocate the work area.

* Estimate the amount of memory for the work area dynamically
  from the image size, instead of using a constant FLOOD_FILL_MAX_DEPTH,
  which is too big in the most cases.
2021-05-11 11:05:58 +09:00
Daniel Beer
c6fc67088a
Merge pull request #103 from yamt/otsu
Fix possible overflows in otsu()
2021-05-11 13:24:56 +12:00
Daniel Beer
e43a33bbc4 Add name of license to LICENSE file. 2021-05-11 10:34:42 +12:00
Daniel Beer
db49540f36
Merge pull request #107 from yamt/shrink-datastream
Shrink struct datastream by borrowing the user buffer
2021-05-11 10:30:58 +12:00
Daniel Beer
fd7792177e
Merge pull request #106 from yamt/finder_scan
finder_scan: Improve capstone detection on small images
2021-05-11 10:28:03 +12:00
Alexandre Perrin
121d685617
Merge pull request #101 from yamt/doc-make
README.md: document requirement on make command
2021-05-02 21:53:32 +02:00
YAMAMOTO Takashi
21b7581b04 Shrink struct datastream by borrowing the user buffer 2021-04-23 13:40:37 +09:00
YAMAMOTO Takashi
65379a7c39 finder_scan: Improve capstone detection on small images
When using small captured images, I somehow frequently see failures
to recognize a capstone due to rounding errors.
eg. when pb[] = {2 3 8 3 2}.

This commit tries to improve it by using fixed-point arithmetics.
The scaling factor was chosen somehow arbitrary. A moderate scaling
should be enough.
2021-04-23 10:36:22 +09:00
YAMAMOTO Takashi
734258c775 finder_scan: constify the "check" array 2021-04-23 10:36:22 +09:00
YAMAMOTO Takashi
02ed1066ba test_grouping: use unsigned variables where it makes more sense 2021-04-23 10:36:22 +09:00
YAMAMOTO Takashi
6fb24d26c8 README.md: document requirement on make command 2021-04-17 22:35:46 +09:00
Alexandre Perrin
ed455904f3
Merge pull request #102 from yamt/readme-quirc-demo-opencv
Update for quirc-demo-opencv and dependencies
2021-04-16 20:38:38 +02:00
YAMAMOTO Takashi
ea9b6ee5ef otsu: Use unsigned for the pixel numbers
Because singed numbers don't make sense here.
2021-04-08 13:38:30 +09:00