【问题标题】:Pyzbar doesn't recognize qrcode, but works with barcodesPyzbar 无法识别 qrcode,但可以使用条形码
【发布时间】:2021-12-18 16:45:45
【问题描述】:

我正在开发一款 Android 应用。这是一个 QRCodeScanner,带有 Kivy 和 python。该代码在 Windows 上运行良好,但是当我编译到 Android 时,它不能识别 QRCodes,但它只能识别 Barcodes。 这是我的代码

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

我也尝试使用 cv2,但它在启动时会因“与 android 不兼容”之类的原因而崩溃

Buildozer.spec 文件

requirements =python3,kivy,pyzbar,Pillow,numpy

fullscreen = 1

android.permissions = INTERNET,CAMERA

这就是我改变的全部

此外,相机在 Android 上旋转了 90°,但在 Windows 上工作正常

你有什么想法要解决吗? 提前致谢

【问题讨论】:

    标签: android python-3.x kivy zbar


    【解决方案1】:

    我在另一个post 中解决了这个问题。我也需要旋转 90º,您可能错过了镜像图像。我希望它能解决你的问题。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-16
    • 2018-12-19
    • 1970-01-01
    • 2017-02-20
    相关资源
    最近更新 更多