Hello
Thanks for the great work.
It's nice how you can turn the camera on and off with camera4kivy.
So i only switch on when barcode-reading is needed.
Tested with windows and android.
I am using it this way, maybe old-fashioned:
self.ids.camera.connect_camera()
self.clockrun1 = Clock.schedule_once(self.wait_for_camera, 3)
def wait_for_camera(self,*args):
self.clockrun2 = Clock.schedule_interval(self.read_barcode, 0.05)
def read_barcode(self,*args):
cam_image = self.ids.camera.export_as_image() # done in my kv-file
texture = cam_image.texture # Preview:
size = texture.size # id: camera
pixels = texture.pixels
pil_image = Image.frombytes(mode="RGBA", size=size, data=pixels)
barcode = pyzbar.decode(pil_image)
if len(barcode) > 0:
self.captext = str(barcode[0].data.decode("utf-8"))
self.stop_scanning()
def stop_scanning(self):
self.clockrun2.cancel()
self.ids.camera.disconnect_camera()
When i start barcode-reading for second time and later, at first there is the old image visible until the camera realy works. Same happens with "analyze_pixels_callback", wich i could not handle on second run ( i am a beginner ).
My two questions are:
1) Is it possible to clear the camera screen or cache on every start, so i don't have to use clock.schedule_once for 3 seconds (to be sure for every device)?
Otherwise the previous barcode is shown.
2) In this case i don't need no gestures4kivy (buildozer is asking) and
microphone-permissions.
Is it possible to delete this functions?
Again, thank you very much.