kivy xcamera:error#01无法使用xcamera().texture.pixels

t1qtbnec  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(235)

当我试图获取图像数据时,应用程序正在崩溃( self.camera.texture.pixels )

import requests
from kivy.clock import Clock
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy_garden.xcamera import XCamera
from android.permissions import request_permissions, Permission

try:
    request_permissions([Permission.INTERNET,
                         Permission.READ_EXTERNAL_STORAGE,
                         Permission.WRITE_EXTERNAL_STORAGE,
                         Permission.CAMERA])
except Exception as e:
    print("Like it's gonna work after this ! XD")
    print(e)
KV = """

# :import XCamera kivy_garden.xcamera.XCamera

BoxLayout:
    orientation: 'vertical'
    BoxLayout:
        id: camera_layout
        canvas.before:
            PushMatrix
            Rotate:
                angle: -90
                origin: self.center
        canvas.after:
            PopMatrix
"""

class uiApp(MDApp):

    def on_picture_taken(self, filename):
        print("trying to register camera texture pixels.")
        data = self.camera.texture.pixels
        print(type(data))
        print(data)
        print("End here")

    def my_callback(self, dt):
        print("Taking picture...")
        self.camera.shoot()
        print("picture taken !")

    def build(self):
        self.screen = Builder.load_string(KV)

        self.camera = XCamera()
        self.camera.on_picture_taken = self.on_picture_taken
        self.screen.ids['camera_layout'].add_widget(self.camera)

        self.event = Clock.schedule_once(self.my_callback, 5)
        return self.screen

uiApp().run()

错误: #01 pc 0000000000078e34 /data/app/~~kbl3-K_BRVZZ1FbmhJ83fQ==/org.test.cam.testcam-ZAOmIpkByRXrLbKrJ5V7YA==/lib/arm64/libpython3.7m.so (PyBytes_FromStringAndSize+300) 如果我拆下线路,一切都正常 self.camera.texture.pixels .

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题