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

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

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

  1. import requests
  2. from kivy.clock import Clock
  3. from kivymd.app import MDApp
  4. from kivy.lang import Builder
  5. from kivy_garden.xcamera import XCamera
  6. from android.permissions import request_permissions, Permission
  7. try:
  8. request_permissions([Permission.INTERNET,
  9. Permission.READ_EXTERNAL_STORAGE,
  10. Permission.WRITE_EXTERNAL_STORAGE,
  11. Permission.CAMERA])
  12. except Exception as e:
  13. print("Like it's gonna work after this ! XD")
  14. print(e)
  15. KV = """
  16. # :import XCamera kivy_garden.xcamera.XCamera
  17. BoxLayout:
  18. orientation: 'vertical'
  19. BoxLayout:
  20. id: camera_layout
  21. canvas.before:
  22. PushMatrix
  23. Rotate:
  24. angle: -90
  25. origin: self.center
  26. canvas.after:
  27. PopMatrix
  28. """
  29. class uiApp(MDApp):
  30. def on_picture_taken(self, filename):
  31. print("trying to register camera texture pixels.")
  32. data = self.camera.texture.pixels
  33. print(type(data))
  34. print(data)
  35. print("End here")
  36. def my_callback(self, dt):
  37. print("Taking picture...")
  38. self.camera.shoot()
  39. print("picture taken !")
  40. def build(self):
  41. self.screen = Builder.load_string(KV)
  42. self.camera = XCamera()
  43. self.camera.on_picture_taken = self.on_picture_taken
  44. self.screen.ids['camera_layout'].add_widget(self.camera)
  45. self.event = Clock.schedule_once(self.my_callback, 5)
  46. return self.screen
  47. 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 .

暂无答案!

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

相关问题