Skip to content
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

RuntimeException when decoding specific files #375

Open
ruimelodev opened this issue Sep 24, 2022 · 4 comments
Open

RuntimeException when decoding specific files #375

ruimelodev opened this issue Sep 24, 2022 · 4 comments

Comments

@ruimelodev
Copy link

I'm using BoofCV to decode QR codes.
When I run the decoder on specific files, I get a RuntimeException with error "An error occurred while calling o40.process":

py4j.protocol.Py4JJavaError: An error occurred while calling o40.process.
: java.lang.RuntimeException: Value out of range. value=54
        at boofcv.alg.fiducial.qrcode.QrCodeCodecBitsUtils.valueToAlphanumeric(QrCodeCodecBitsUtils.java:338)
        at boofcv.alg.fiducial.qrcode.QrCodeCodecBitsUtils.decodeAlphanumeric(QrCodeCodecBitsUtils.java:164)
        at boofcv.alg.fiducial.qrcode.QrCodeDecoderBits.decodeAlphanumeric(QrCodeDecoderBits.java:265)
        at boofcv.alg.fiducial.qrcode.QrCodeDecoderBits.decodeMessage(QrCodeDecoderBits.java:157)
        at boofcv.alg.fiducial.qrcode.QrCodeDecoderImage.decode(QrCodeDecoderImage.java:253)
        at boofcv.alg.fiducial.qrcode.QrCodeDecoderImage.process(QrCodeDecoderImage.java:100)
        at boofcv.abst.fiducial.QrCodePreciseDetector.process(QrCodePreciseDetector.java:89)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:282)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:238)
        at java.base/java.lang.Thread.run(Thread.java:832)

Here is an example of a file that throws exception:
pdf_invalid_2.pdf

@lessthanoptimal
Copy link
Owner

There are two things going on. 1) this appears to be an incorrectly encoded QR code. 2) This failure mode was not handled inside the decoder.

The reason I believe the QR code to be invalid is that after adding more debug logic it was discovered that it's specifying an Alphanumeric value of 54, which is outside the allowed range. As a sanity check I used my phone to try to read the QR code and tried 4 different apps and they all failed. At this point I think it's unlikely to be a logic error in the message decoder.

#376

There's the PR. It's going to under go a bit more testing before the updated logic is released.

@ruimelodev
Copy link
Author

I'm aware it's an invalid QR code, sorry I didn't mention that before. The reason why I opened up an issue for it was because I was expecting the detector to return an empty result instead of throwing an exception.

I have another file where another exception is thrown with error An error occurred while calling o767.process.:

    raise Py4JJavaError(
    py4j.protocol.Py4JJavaError: An error occurred while calling o767.process.
: java.lang.NullPointerException: Cannot read field \"width\" because \"gray\" is null
    at boofcv.abst.fiducial.QrCodePreciseDetector.process(QrCodePreciseDetector.java:67)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:282)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.base/java.lang.Thread.run(Thread.java:832)

@lessthanoptimal
Copy link
Owner

Could you share the image so I can verify that it has been fixed? I'll do a small release in the next week or so to get these bug fixes out.

@ruimelodev
Copy link
Author

Unfortunately, I can't replicate the second error, I only have that stack trace from my logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants