-
-
Notifications
You must be signed in to change notification settings - Fork 464
Add TryHarder and MinLineCount hints for python wrapper #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added 2 hints to the python wrapper, MinLineCount and TryHarder
Thanks for your offer to improve the code. I'm hesitant to merge your PR, though. I deliberately did not include the The same question generally applies to the |
I use kinda real time implementation on android through the NDK, yes. The reason is in my project, I have a unit test in python and I have to pass the same settings of the cpp implementation to check that is the same. I use MinLineCount to 1 and try harder false |
So you run the same images through your cpp and your python implementation to see if both return the same results? Those can only be different if the two are based on different versions of the code base and I'm not convinced that this justifies the bloating of the python API, especially not the addition of the |
We use in production the cpp with android NDK and iOS. While python in a separate module to test barcodes joined with other pre-processing routine. Maybe it's ok about tryHarder, but at least MinLineCount? The latter is crucial for some barcodes in our project, and we want to test using the old behaviour of v1.2.0 when was setted to 1 |
|
I think that the iterative rotation emulates the real-time detection with frames, that's why it works always when previous attempts fail |
I have a question without digging in the math formula, your GlobalHistogram is doing the same type of thresholding of Otsu's method, why alone is not enough? Is GlobalHistogram "less" accurate than Otsu? Shouldn't be the same? In the above code I'm doing Otsu to read the barcode, without it would fail |
I'm a bit low on time but just to give you a quick update:
|
Thank you! I didn't notice that are wide and the aspect ratio is not correct. I'm gonna fix |
I don't know what you mean by 'aspect ratio not correct'. There is nothing wrong with that. What I meant is that the image is somewhat underexposed, which makes the black bars wider compared to the white ones, but I personally would like to see the library being capable of dealing with that as is and I am hopeful that it will in some not-too-far-away-future. |
I want to clarify what I said before, ignoring the exposure situation (because even fixing that is not enough): so the aspect ratio is modified in my project, the original barcode has thin black lines because the height is 15% of the width, but for some problem after doing a warp, the height becomes the 10.9% of the width, so it's like stretched out(wider), after resizing with opencv multiply for a factor of 1.375 the "Impossible" barcode is detected at first attempt . I think that stretching out barcodes, for mistake, make more difficult the detection sometimes. Therefore I'm trying to fix the warp function that I use in my project |
Don't worry about the aspect ratio of the image, it is irrelevant for the detection of 1D barcodes like Code128 here (completely different situation for 2D symbologies, of course). Important for the detection is the relative widths of the black vs. the white bars. If you made all of them twice as wide, the result would be the same. The reason why your symbol might still be detected after this rescaling is basically noise, same as your tiny rotation operations you mentioned earlier. Random minor changes might make the difference between 1 or 2 detected lines while this input should actually be found with 100 lines (or whatever the height of the symbol is in pixels). |
This improves the reliability in situations with under/over exposed images. It basically adopts the reference algorithm from the specification. This 'fixes' the image discussed in #444.
The linked commit fixes your issue with the above images. They are now both detected with 40+ lines. I decided to trust my work and put this into the next release, even if it is very last minute ;). |
Thank you very much! |
I confirm, now is absolutely perfect with my "difficult" 100 barcode datasets. Could you explain what was exactly the cause of the issue and how you addressed it? Just to keep in my mind, even in short words. The black lines "too thick", right? |
Say you have a b/w pattern (in widths) as follows: bwwwbwww (so 1, 3, 1, 3). now if you capture that slightly blurred and underexposed, then threshold it, you can end up with the pattern bbwwbbww (or 2, 2, 2, 2) and they will not match. If you count from edge-to-edge (start of black to next start of black), though, then both patterns are the same (4, 4, 4). That is basically the idea.
That is very good to hear. They are all Code128? |
Yes all code128, do you want the archive? |
No thanks. |
Added 2 hints to the python wrapper, MinLineCount and TryHarder