简体   繁体   English

Pyzbar 无法识别 qrcode,但可以使用条形码

[英]Pyzbar doesn't recognize qrcode, but works with barcodes

I'm working on an Android app.我正在开发一个 Android 应用程序。 It's a QRCodeScanner, with Kivy and python.这是一个 QRCodeScanner,带有 Kivy 和 python。 The code works fine on windows, but when I compile to Android, it doesn't recognize QRCodes, but it recognize only Barcodes.该代码在 windows 上运行良好,但是当我编译到 Android 时,它不能识别 QRCodes,但它只能识别 Barcodes。 Here is my code这是我的代码

label = Label(text="", halign='left', valign='bottom', size_hint=(.5,.2))
x = Camera(play=True, index=0)
class MyCamera(App):
    def build(self):
        self.window = GridLayout()
        self.window.cols = 1
        Window.size = (360, 640)
        self.window.add_widget(x)
        self.window.add_widget(label)
        Clock.schedule_interval(self.update, 1.0 / 33.0)
        return self.window
    def update(self, dt):
        texture = x.texture
        size = texture.size
        pixels = texture.pixels
        pil_image = Image.frombytes(mode="RGBA", size=size, data=pixels)
        numpypicture = numpy.array(pil_image)
        decoded = pyzbar.pyzbar.decode(numpypicture)
        label.text = str(decoded)
        if len(str(decoded)) > 2:
            # do something

I also tried to use cv2, but it crashes at startup for something like "not compatible with android"我也尝试使用 cv2,但它在启动时因“与 android 不兼容”之类的原因而崩溃

Buildozer.spec file Buildozer.spec 文件

requirements =python3,kivy,pyzbar,Pillow,numpy

fullscreen = 1

android.permissions = INTERNET,CAMERA

this is all what I changed这就是我改变的一切

Also, the camera is rotated by 90° on Android, but on windows works fine此外,相机在 Android 上旋转了 90°,但在 windows 上工作正常

Have you got any idea to solve?你有什么想法要解决吗? Thanks in advance提前致谢

I solved this issue in another post .我在另一篇文章中解决了这个问题。 I too needed to rotate by 90º and you are probably missing that the image is being mirrored.我也需要旋转 90º,您可能错过了镜像图像。 I hope it fixes your problem.我希望它能解决你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM