dlbeer / quirc

QR decoder library
Other
865 stars 285 forks source link

Add quirc_end_with_workarea() #96

Closed yamt closed 3 years ago

yamt commented 3 years ago
yamt commented 3 years ago

btw, i'm not quite happy with the name quirc_end_with_workarea. suggestions are welcome.

kaworu commented 3 years ago

Hello @yamt and thank you for the contribution! I'll defer to @dlbeer about the flood-fill related changes and possible impact on embedded.

dlbeer commented 3 years ago

How big does a workarea need to be for the library to behave well on typical images? I'm guessing it's of the order of a thousand-ish entries?

I'm very much in favour of removing the recursion, but I wonder if the workarea could just be allocated with a static fixed (or #define'd) size in struct quirc? We already have a static buffer for grid decoding, and I'm guessing this wouldn't add significantly to the size.

yamt commented 3 years ago

How big does a workarea need to be for the library to behave well on typical images? I'm guessing it's of the order of a thousand-ish entries?

i was assuming that FLOOD_FILL_MAX_DEPTH was the value for the typical images. wasn't it?

I'm very much in favour of removing the recursion, but I wonder if the workarea could just be allocated with a static fixed (or #define'd) size in struct quirc? We already have a static buffer for grid decoding, and I'm guessing this wouldn't add significantly to the size.

depends on the typical size, it might make sense.

dlbeer commented 3 years ago

FLOOD_FILL_MAX_DEPTH is probably an overestimate, and was there to prevent stack overflow with the recursive flood-fill. I suspect you can probably get away with less, since the flood-fill really only needs to work well enough to distinguish features like rings and capstones. Happy for you to experiment with this and pick out what you think is a reasonable value.

yamt commented 3 years ago

FLOOD_FILL_MAX_DEPTH is probably an overestimate, and was there to prevent stack overflow with the recursive flood-fill.

ok.

I suspect you can probably get away with less, since the flood-fill really only needs to work well enough to distinguish features like rings and capstones. Happy for you to experiment with this and pick out what you think is a reasonable value.

some of my colleagues might have some experiment results about this. let me ask them.

yamt commented 3 years ago

I suspect you can probably get away with less, since the flood-fill really only needs to work well enough to distinguish features like rings and capstones. Happy for you to experiment with this and pick out what you think is a reasonable value.

some of my colleagues might have some experiment results about this. let me ask them.

unfortunately, they don't seem to have much info to share.

yamt commented 3 years ago

@dlbeer

reading at the code, i think that the max depth should be something like (image_height_in_pixels / 3 * 2).

as it's a proportion to the image resolution, i guess there's no one-size-fit-all value of the max depth. how do you think?

yamt commented 3 years ago

reading at the code, i think that the max depth should be something like (image_height_in_pixels / 3 * 2).

i did quick experiments around this value and it seems working as i expected. (in my case image_height_in_pixels=720)

i guess it makes sense to make quirc_resize() allocate the buffer with this size automatically using malloc(). how do you think?

yamt commented 3 years ago

i guess it makes sense to make quirc_resize() allocate the buffer with this size automatically using malloc().

i submitted an alternative version which do this. https://github.com/dlbeer/quirc/pull/100

yamt commented 3 years ago

i haven't noticed any issues with the alternative (https://github.com/dlbeer/quirc/pull/100) so far. let me close this one.