我尝试使用 uix.camera 小部件并从我的网络摄像头中显示一些宽幅图像.我查看了文档并尝试使用这个简单的代码.但它只是给我看一个没有任何视频的白色屏幕(我启用了播放).我做错了什么?也许存在一些有用的文档教程(因为从官方文档中我了解了很多).感谢您的帮助.
I try to use uix.camera widget and show some wideo from my web-camera. I looked into the documentation and try to use this simply code. But it's just show me a white creen withoud any video (I enabled playing). What I'm doing wrong? Maybe some useful docs utorial exist (because from official documentation I understanding a little from many). Thanks for any help.
import kivy
kivy.require('1.9.1')
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.camera import Camera
class MainApp(App):
def build(self):
return Camera(play=True)
if __name__== "__main__":
MainApp().run()
需要指定分辨率.就我而言,我还需要指定 index=1,即插入我计算机的第二个摄像头.
You need to specify resolution. In my case, I also needed to specify index=1, that is the second camera plugged in my computer.
例子:
import kivy
kivy.require('1.9.1')
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.camera import Camera
class MainApp(App):
def build(self):
return Camera(play=True, index=1, resolution=(640,480))
if __name__== "__main__":
MainApp().run()
这篇关于我如何使用 Kivy (Python) 相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!