I'm working on an Android app. It's a QRCodeScanner, with Kivy and python. The code works fine on windows, but when I compile to Android, it doesn't recognize QRCodes, but it recognize only 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"
Buildozer.spec file
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
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. I hope it fixes your problem.