import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.camera import Camera
import cv2
from kivy.uix.image import Image
from kivy.clock import Clock
from kivy.graphics.texture import Texture
import numpy as np
class KivyCamera(Image):
def __init__(self, capture, fps, **kwargs):
super(KivyCamera, self).__init__(**kwargs)
self.capture = capture
Clock.schedule_interval(self.update, 1.0 / fps)
def update(self, dt):
ret, frame = self.capture.read()
if ret:
# convert it to texture
buf1 = cv2.flip(frame, 0)
buf = buf1.tostring()
image_texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
# display image from the texture
self.texture = image_texture
class MainApp(App):
def build(self):
self.capture = cv2.VideoCapture(0)
self.camera = KivyCamera(capture=self.capture, fps=30)
return self.camera
if __name__== "__main__":
MainApp().run()And my buildozer.spec is;
[app] title = Test_app package.name = myapp package.domain = org.test source.dir = . source.include_exts = py,png,jpg,kv,atlas,xml version = 0.1 requirements = python3,kivy,numpy,opencv orientation = portrait # Android specific fullscreen = 0 android.permissions = INTERNET, ACCESS_FINE_LOCATION, WRITE_EXTERNAL_STORAGE, CAMERA android.arch = armeabi-v7a [buildozer] log_level = 2 warn_on_root = 1Code works successfully in windows. Then i have build the the code with buildozer for android, when I open the Android App it shows a black screen with a small square in the left corner of the screen. I think the cv2.VideoCapture() is not working properly.So I change cv2.VideoCapture(0) to cv2.VideoCapture(-1) and to cv2.VideoCapture(1). But both doesn't work.
Can anyone help me out with this ?
--
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/e60ee916-a47c-49da-b080-a49b390eb51e%40googlegroups.com.
As shown by, this is always the case:Â Â Â video_capture.isOpened()Â == False
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
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/45515057-0004-4cca-8294-13692d061fd2%40googlegroups.com.
My problem is, opencv can not read the camera device properly.
As shown by, this is always the case:Â Â Â video_capture.isOpened()Â == False
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/45515057-0004-4cca-8294-13692d061fd2%40googlegroups.com.