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

Unable to set version of microQR encoder #25

Open
simon-staal opened this issue Jun 15, 2023 · 4 comments
Open

Unable to set version of microQR encoder #25

simon-staal opened this issue Jun 15, 2023 · 4 comments
Assignees
Labels
Fixed in Java It has been fixed in the Java code but the latest Python wrapper doesn't have it.

Comments

@simon-staal
Copy link

simon-staal commented Jun 15, 2023

The following snippet generates an error:

import pyboof as pb

generator = pb.MicroQrCodeGenerator(pixels_per_module=5)
generator.set_version('M4') 
Traceback (most recent call last):
  File "/home/ubuntu/imperial/testing/tile/pyboof_benchmark.py", line 18, in <module>
    generator.set_version('M4')
  File "/home/ubuntu/imperial/testing/.venv/lib/python3.10/site-packages/pyboof/recognition.py", line 869, in set_version
    self.java_encoder.setVersion(version)
  File "/home/ubuntu/imperial/testing/.venv/lib/python3.10/site-packages/py4j/java_gateway.py", line 1322, in __call__
    return_value = get_return_value(
  File "/home/ubuntu/imperial/testing/.venv/lib/python3.10/site-packages/py4j/protocol.py", line 330, in get_return_value
    raise Py4JError(
py4j.protocol.Py4JError: An error occurred while calling o43.setVersion. Trace:
py4j.Py4JException: Method setVersion([class java.lang.String]) does not exist
        at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:321)
        at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:329)
        at py4j.Gateway.invoke(Gateway.java:274)
        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:829)

I've had a quick poke through the code, and it looks like the appropriate conversion to the expected java object is missing (for both the QR and microQR generators), similar to how this method is done for set_error().

It also looks like there's a bug in the set_mask() method for both of these classes, it's calling string_to_qrcode_error() on the input parameter rather than string_to_qrcode_mask(), which I assume is the intended function, see here and here.

@simon-staal
Copy link
Author

I've just noticed another error, although I'm not sure why this one occurs:

generator = pb.MicroQrCodeGenerator(pixels_per_module=5)
generator.set_error('Q')
generator.set_message("TEST")
generator.generate() # Breaks here

Causes the following error:

  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/imperial/testing/.venv/lib/python3.10/site-packages/pyboof/recognition.py", line 890, in generate
    qr = self.java_encoder.fixate()
  File "/home/ubuntu/imperial/testing/.venv/lib/python3.10/site-packages/py4j/java_gateway.py", line 1322, in __call__
    return_value = get_return_value(
  File "/home/ubuntu/imperial/testing/.venv/lib/python3.10/site-packages/py4j/protocol.py", line 326, in get_return_value
    raise Py4JJavaError(
py4j.protocol.Py4JJavaError: An error occurred while calling o46.fixate.
: java.lang.NullPointerException
        at java.base/java.util.Objects.requireNonNull(Objects.java:221)
        at boofcv.alg.fiducial.microqr.MicroQrCode$VersionInfo.levels(MicroQrCode.java:404)
        at boofcv.alg.fiducial.microqr.MicroQrCode.maxDataBits(MicroQrCode.java:301)
        at boofcv.alg.fiducial.microqr.MicroQrCodeEncoder.autoSelectVersionAndError(MicroQrCodeEncoder.java:433)
        at boofcv.alg.fiducial.microqr.MicroQrCodeEncoder.fixate(MicroQrCodeEncoder.java:260)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:374)
        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:829)

This only happens if set_error() is called before calling generate()

@lessthanoptimal
Copy link
Owner

I've reproduced the problem. Investigating now.

@lessthanoptimal
Copy link
Owner

Fixed in the latest Java SNAPSHOT. How critical is this that it gets fixed on the Python side quickly? Like in the next 2 weeks?

@lessthanoptimal lessthanoptimal added Fixed in Java It has been fixed in the Java code but the latest Python wrapper doesn't have it. and removed under investigation labels Jul 3, 2023
@simon-staal
Copy link
Author

It's not pressing at all on my end, feel free to get it solved whenever you have time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in Java It has been fixed in the Java code but the latest Python wrapper doesn't have it.
Projects
None yet
Development

No branches or pull requests

2 participants