我正在尝试编写一个简单的应用程序,通过在ubuntu上使用kivy在应用程序窗口(实时流)上显示相机视图。我使用了这个网站的代码http://karanbalkar.com/2012/10/tutorial-6-working-with-camera-in-kivy/。编译器显示如下错误:GError:没有元素“v4l2src”
我在Ubuntu和Python编程方面很完全,并且根本不明白错误:D
有完整的代码:
import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.camera import Camera
from kivy.uix.button import Button
from kivy.core.window import Window
class MyApp(App):
def doscreenshot(self,*largs):
Window.screenshot(name='screenshot%(counter)04d.jpg')
def build(self):
camwidget = Widget()
cam = Camera()
cam = Camera(resolution=(640,480),size=(500,500))
cam.play=True
camwidget.add_widget(cam)
button = Button(text='screenshot',size_hint=(0.12,0.12))
button.bind(on_press=self.doscreenshot)
camwidget.add_widget(button)
return camwidget
if __name__ == '__main__':`enter code here`
MyApp().run()
IDLE调试器:
[INFO ] [Logger ] Record log in /home/maciek/.kivy/logs/kivy_16-03-01_13.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Camera ] Provider: pygst
[INFO ] [Text ] Provider: sdl2
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] [GL ] OpenGL version <3.0 Mesa 11.0.2>
[INFO ] [GL ] OpenGL vendor <Intel Open Source Technology Center>
[INFO ] [GL ] OpenGL renderer <Mesa DRI Intel(R) Ivybridge Mobile >
[INFO ] [GL ] OpenGL parsed version: 3, 0
[INFO ] [GL ] Shading version <1.30>
[INFO ] [GL ] Texture max size <8192>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
Traceback (most recent call last):
File "/home/maciek/testcamera.py", line 27, in <module>
MyApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 802, in run
root = self.build()
File "/home/maciek/testcamera.py", line 16, in build
cam = Camera(resolution=(640,480),size=(500,500))
File "/usr/lib/python2.7/dist-packages/kivy/uix/camera.py", line 91, in __init__
on_index()
File "/usr/lib/python2.7/dist-packages/kivy/uix/camera.py", line 103, in _on_index
resolution=self.resolution, stopped=True)
File "/usr/lib/python2.7/dist-packages/kivy/core/camera/camera_pygst.py", line 46, in __init__
super(CameraPyGst, self).__init__(**kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/core/camera/__init__.py", line 70, in __init__
self.init_camera()
File "/usr/lib/python2.7/dist-packages/kivy/core/camera/camera_pygst.py", line 64, in init_camera
self._pipeline = gst.parse_launch(pl % (video_src, GL_CAPS))
GError: no element "v4l2src"