打开使用kivy创建的apk时出错



我正在尝试使用mediapipe,但每次出现此错误时:

ImportError:dlopen失败:"data/data.org/test.myapp/files/app/_python_bbundle/site packages/mediapipe/python/_framework_bindings.so";具有意外的e_machine:62(EM_X86_64(

我创建了其他应用程序,它们运行良好。但是在使用mediapipe时,它会导致错误。

设备:诺基亚6安卓版本:9

代码:

from kivymd.app import MDApp
from kivymd.uix.screen import Screen
from kivy.uix.image import Image
from kivymd.uix.label import MDLabel
from kivy.clock import Clock
from kivymd.uix.button import MDFlatButton
from kivy.graphics.texture import Texture
from kivy import platform
from kivymd.uix.dialog import MDDialog
import cv2
import mediapipe as mp
if platform == "android":
from android.permissions import Permission, request_permissions
request_permissions([Permission.CAMERA])
mp_hands = mp.solutions.hands
mp_drawing = mp.solutions.drawing_utils

class MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "Orange"
screen = Screen()
self.label = MDLabel(text="Initializing...", halign="left", pos_hint={"center_y": 0.95},
theme_text_color="Custom", text_color=(0, 1, 0, 1),
font_style="Subtitle1")
screen.add_widget(self.label)
self.img1 = Image()
screen.add_widget(self.img1)
self.capture = cv2.VideoCapture(0)
Clock.schedule_interval(self.update, 1.0 / 30.0)
return screen
def update(self, dt):
cap = self.capture
with mp_hands.Hands(model_complexity=0, min_detection_confidence=0.5, min_tracking_confidence=0.5) as hand:
succ, frame = cap.read()
if (not succ):
close_btn = MDFlatButton(text="Close", on_release=self.close_dialog)
self.dialog = MDDialog(title="User Detail", text="Something went wrong", size_hint=(0.7, 1),
buttons=[close_btn])
self.dialog.open()
return
img, res = self.mediapipe_detection(frame, hand)
if (res.multi_hand_landmarks):
for landmarks in res.multi_hand_landmarks:
for co in landmarks.landmark:
self.label.text = str(co.x) + "_" + str(co.y) + "_" + str(co.z)
self.draw_landmarks(img, res)
img = cv2.flip(img, 0)
buf = img.tostring()
texture1 = Texture.create(size=(img.shape[1], img.shape[0]), colorfmt="bgr")
texture1.blit_buffer(buf, colorfmt="bgr", bufferfmt="ubyte")
self.img1.texture = texture1
def close_dialog(self, obj):
self.dialog.dismiss()
def mediapipe_detection(self, img, model):
img = cv2.flip(img, 1)  # flip around y axis
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)  # converts image from BGR to RGB
img.flags.writeable = False
res = model.process(img)  # predicts
img.flags.writeable = True
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)  # converts image from RGB to BGR
return img, res
def draw_landmarks(self, img, res):
# draw hand landmarks
if (res.multi_hand_landmarks):
for landmarks in res.multi_hand_landmarks:
mp_drawing.draw_landmarks(img, landmarks, mp_hands.HAND_CONNECTIONS)

MainApp().run()

Buildozer.spec需求:python3,kivy,kivymd,mediapipe,numpy,opencv

许可:INTERNET,CAMERA

我看到您的需求中缺少枕头,请添加枕头并尝试。

最新更新