Git Product home page Git Product logo

Comments (11)

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

Hello.
As I think, what is really counterintuitive - if code outside of frame rect will be recognized.
Btw, I see another soulution, make real recognition area a bit larger than viewfinder frame.
I'll implement something like this in next version.

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

Seems like the problem isn't in frame or scanning area. It is in ZXing library itself. Because when you scan from small distance from screen, phone's camera sees different subpixels (RGB) and the library can't decode such images well.

Example in attached screenshot.

screenshot_20180309-174500

from code-scanner.

hkmushtaq avatar hkmushtaq commented on May 28, 2024

Hello.
As I think, what is really counterintuitive - if code outside of frame rect will be recognized.
Btw, I see another soulution, make real recognition area a bit larger than viewfinder frame.
I'll implement something like this in next version.

The solution you mentioned is what I was proposing in the original post albeit it could have a different approach to do it. Apologies if I wasn't clear enough on that. I am willing to discuss and do the implementation if you agree with the solution we arrive at

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

I've already implemented this, and it got no result even with 20% larger area (on Galaxy S7). See my last comment. I'll get Pxel 2 XL in a couple of weeks and test library.
Anyways, completely ignore the frame is bad idea.

return new Rect(Math.max(Math.round(left - left * FRAME_THRESHOLD), 0),

Or, the promlem can be in preview image size. I never tested library at 2:1 screens before.

from code-scanner.

hkmushtaq avatar hkmushtaq commented on May 28, 2024

Just some more info

I have not been able to reproduce this issue on Samsung Galaxy S8 which I believe also has the same screen aspect ratio. The issue seems to just be for Pixel 2 and Pixel 2 XL Devices. (AFAIK based on my testing)

Edit:
I tested on S7 Edge Running Nougat and didn't encounter this issue. Let me get a screenshot of how far the Pixel 2 has to be before recognizing.

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

So, this problem should be investigated deeper. I'll kep this issue open.
What parameters of scanner view are you using? (full screen or not, viewfinder aspect ration, etc)
Portrait or landscape orientation?

from code-scanner.

hkmushtaq avatar hkmushtaq commented on May 28, 2024

Just off the top of my head, do you think it would improve the reliability of the decoder if we did a high contrast filter on the frame before decoding it? Edit: Now that I think about it, they could be doing that in the Zxing library internally as well

Edit: My Config (Orientation Portrait), Full Screen, Aspect Ratio 1:1
codeScanner = CodeScanner(it, codeScannerView)
codeScanner?.isFlashEnabled = false
codeScanner?.isAutoFocusEnabled = true
codeScanner?.setFormats(CodeScanner.ALL_FORMATS)
codeScanner?.setDecodeCallback(this@QRFragment)
codeScanner?.setErrorCallback(this@QRFragment)
codeScanner?.setScanMode(ScanMode.CONTINUOUS)

from code-scanner.

hkmushtaq avatar hkmushtaq commented on May 28, 2024

I was able to resolve this issue by reapplying your threshold changes and also utilizing a smaller frameSize (was added in my previous PR). Now it scans perfectly for me. I've made it so that the threshold is configurable and is 0 by default (existing behavior) and opened a PR so you can take a look at the code

from code-scanner.

hkmushtaq avatar hkmushtaq commented on May 28, 2024

So I investigated this issue some more. I thought I had resolved the issue with the changes mentioned above but then on a different monitor, it did not work (most likely due to the subpixels issue you mentioned briefly above)

The next thing I tried was changing the LuminanceSource from PlanarYUV to RGB and that actually ended up resolving that issue. I will test on various devices and monitors/screens to ensure it works consistently and then make a PR.

One thing to note. I think that not all devices actually support RGB mode for the Camera so I am currently converting the cropped frame ONLY to RGB and creating a RGBLuminanceSource

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

Hm, I don't think that such conversions is the best way to resolve this issue.
And it's really wired how changing color format helps recognition.

from code-scanner.

yuriy-budiyev avatar yuriy-budiyev commented on May 28, 2024

Seems like the promlem is in subpixel and/or noise. For now, this can't be fixed in my library. However, I'll keep by library up to date with ZXing.

from code-scanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.