Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OPENCV+;KIVY+;ANDROID手机上的BUILDOZER_Python_Android_Opencv_Kivy_Buildozer - Fatal编程技术网

Python OPENCV+;KIVY+;ANDROID手机上的BUILDOZER

Python OPENCV+;KIVY+;ANDROID手机上的BUILDOZER,python,android,opencv,kivy,buildozer,Python,Android,Opencv,Kivy,Buildozer,我正在尝试使用opencv、kivy和buildzer在我的android手机上构建一个应用程序。我可以成功地调试该应用程序并构建到android手机。但当我打开应用程序时,相机不工作。 但在使用android版buildozer构建代码后,当我打开应用程序时,它会显示一个黑色屏幕,屏幕左角有一个小正方形。有人能帮我吗?我相信没有人接近摄像机 如果你有任何建议或其他方法,请让我知道 谢谢大家! 以下是我正在使用的代码: # coding:utf-8 from kivy.app import Ap

我正在尝试使用opencv、kivy和buildzer在我的android手机上构建一个应用程序。我可以成功地调试该应用程序并构建到android手机。但当我打开应用程序时,相机不工作。 但在使用android版buildozer构建代码后,当我打开应用程序时,它会显示一个黑色屏幕,屏幕左角有一个小正方形。有人能帮我吗?我相信没有人接近摄像机

如果你有任何建议或其他方法,请让我知道

谢谢大家!

以下是我正在使用的代码:

# coding:utf-8
from kivy.app import App
from kivy.uix.image import Image
from kivy.clock import Clock
from kivy.graphics.texture import Texture
import cv2


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 CamApp(App):
    def build(self):
        self.capture = cv2.VideoCapture(1)
        self.my_camera = KivyCamera(capture=self.capture, fps=30)
        return self.my_camera

    def on_stop(self):
        #without this, app will not exit even if the window is closed
        self.capture.release()


if __name__ == '__main__':
    CamApp().run()