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



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

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

这就是我更改的全部内容

此外,相机在安卓系统上旋转了90°,但在windows上运行良好

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

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

相关内容

最新更新