Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can use Kivy (Python) 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\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()
like image 425
Velidan Avatar asked Jul 03 '16 17:07

Velidan


People also ask

How do I access my camera on kivy?

Just import that file https://github.com/kivy/plyer/blob/master/plyer/platforms/android/camera.py Also, don't forget to add CAMERA permissions to manifest.

Does OpenCV work with kivy?

I've done heavy computation using OpenCV within Kivy. No issues, it just works.

Can I run kivy on Jupyter notebook?

It was possible to use Kivy in Jupyter Notebook since Kivy version 1.3. 0 using InteractiveLauncher (see documentation). However, this has been deprecated since version 1.10.


1 Answers

You need to specify resolution. In my case, I also needed to specify index=1, that is the second camera plugged in my computer.

Example:

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()
like image 194
Thiago Falcao Avatar answered Oct 05 '22 22:10

Thiago Falcao