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

QR code orientation will be up for both 45-degree angle and -45-degree angle #146

Open
CMSITAssist opened this issue Jun 21, 2023 · 0 comments

Comments

@CMSITAssist
Copy link

Hi,
If a QR code is rotated for both 45-degree angle or -45-degree angle, it will be treated as "UP" which causing difficulty in correctly distinguish the two situation since a QR code is a square.

Is it possible to make -45-degree angle been treated as "LEFT" so we can get the top left corner position of the QR-code by calculating the min-distance between the polygon point to the Rect point?

I tried this by generating a QR code and rotate it with GIMP.

45-degree clockwise (to right)

45

-45-degree counter-clockwise (to left)

-45

46-degree clockwise (to right)

46

Here are some code for testing

    pil_image = PIL.Image.open("-45.png")


    opencv_image = numpy.array(pil_image)
    opencv_image = cv2.cvtColor(opencv_image, cv2.COLOR_RGB2BGR)

    codes = pyzbar.pyzbar.decode(pil_image, symbols=[pyzbar.pyzbar.ZBarSymbol.QRCODE])
    if codes[0].orientation == "UP":
        top_left_of_QR_code = codes[0].polygon[0]
        opencv_image = cv2.circle(opencv_image, top_left_of_QR_code, radius=10, color=(0, 0, 255), thickness=5)
    cv2.imshow("UP", opencv_image)
    cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant