AttributeError: 'NoneType' object has no attribute 'blit_buffer' opencv and kivy android

151 views
Skip to first unread message

husamal...@gmail.com

unread,
Dec 27, 2021, 7:20:39 AM12/27/21
to Kivy users support
I'm facing this error when run the below code on android 

File "/content/.buildozer/android/app/main.py", line 112, in on_tex 12-26 22:34:30.641 17922 19122 I python : File "/content/.buildozer/android/app/main.py", line 128, in frame_to_screen 12-26 22:34:30.642 17922 19122 I python : AttributeError: 'NoneType' object has no attribute 'blit_buffer'
it looks like _on_load method does not work

from
kivy import platform from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.graphics.texture import Texture from kivy.uix.camera import Camera from kivy.lang import Builder import numpy as np import cv2 Builder.load_file("main.kv") class AndroidCamera(Camera): camera_resolution = (640, 480) counter = 0 def _camera_loaded(self, *largs): self.texture = Texture.create(size=np.flip(self.camera_resolution), colorfmt='rgb') self.texture_size = list(self.texture.size) def on_tex(self, *l): if self._camera._buffer is None: return None frame = self.frame_from_buf() self.frame_to_screen(frame) super(AndroidCamera, self).on_tex(*l) def process_frame(self, frame): r, g, b = cv2.split(frame) frame = cv2.merge((b, g, r)) rows, cols, channel = frame.shape M = cv2.getRotationMatrix2D((cols / 2, rows / 2), 90, 1) dst = cv2.warpAffine(frame, M, (cols, rows)) frame = cv2.flip(dst, 1) if self.index == 1: frame = cv2.flip(dst, -1) return frame class MyLayout(BoxLayout): pass class MyApp(App): def build(self): if platform == 'android': from android.permissions import request_permissions, check_permission, Permission if not check_permission(Permission.CAMERA): request_permissions([Permission.CAMERA]) return MyLayout() if __name__ == '__main__': MyApp().run()


2019BTEEL00076 Umer Mansoor Ali Bijapure

unread,
Dec 27, 2021, 8:37:43 AM12/27/21
to kivy-...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/1d5726c1-6c2d-4258-ab8f-912e86b7cbf2n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages