我如何使用 Kivy (Python) 相机

2023-06-07Python开发问题
68

本文介绍了我如何使用 Kivy (Python) 相机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我尝试使用 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) 相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

pandas 有从特定日期开始的按月分组的方式吗?
Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)...
2024-08-22 Python开发问题
10

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10