0

I am trying to build a simple kivy android app that decodes a datamatrix image.

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.button import Button
import cv2
import pylibdmtx.pylibdmtx as dmtx


class DmtxDecoder(BoxLayout):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.orientation = 'vertical'
        self.add_widget(Image(source="download.png"))
        self.decode_button = Button(text='Decode', size_hint_y=0.1)
        self.decode_button.bind(on_press=self.decode)
        self.add_widget(self.decode_button)

    def decode(self, instance):
        img = cv2.imread("download.png", cv2.IMREAD_GRAYSCALE)
        img=cv2.copyMakeBorder(img,1,1,1,1,cv2.BORDER_CONSTANT, value=[255,255,255])

        data = dmtx.decode(img)
        if data:
            print('Decoded data:', data[0].data.decode())
        else:
            print('No Data Matrix code found.')


class DmtxApp(App):

    def build(self):
        return DmtxDecoder()


if __name__ == '__main__':
    DmtxApp().run()

I have the following requirements in buildozer.spec:
requirements = kivy==2.1.0, sdl2, opencv, plyer, pyinstaller==5.1,pylibdmtx

The build was successful, but the app does not run on android(works on linux and windows)
while debugging I encountered the following error
04-14 12:01:17.000 19342 26077 I python : File "/home/wannabuildanapp/dmtx_test/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/TESTDMTX/arm64-v8a/pylibdmtx/dmtx_library.py", line 47, in load

04-14 12:01:17.001 19342 26077 I python : ImportError: Unable to find dmtx shared library

04-14 12:01:17.001 19342 26077 I python : Python for android ended.

I fooled around with chatgpt and it suggested that I build a receipe for libdmtx0b?
can someone please direct me how to do that or any tutorials on the matter ? is it even correct to build a receipe ?

Thanks in advance!

0 Answers0