本文介绍了我如何使用Kivy(Python)相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用uix.camera小部件,并从网络摄像头中显示一些Wideo.我查看了文档,并尝试使用此简单代码.但这只是给我看一个白色的屏幕,没有任何视频(我已启用播放功能).我做错了什么?也许存在一些有用的文档\教程(因为从很多官方文档中我了解得很少).感谢您的帮助.
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\tutorial 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)相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!