2015-01-30 17:45:57 +00:00
|
|
|
'''
|
|
|
|
Camera Example
|
|
|
|
==============
|
|
|
|
|
2015-02-02 01:09:20 +00:00
|
|
|
This example demonstrates a simple use of the camera. It shows a window with
|
|
|
|
a buttoned labelled 'play' to turn the camera on and off. Note that
|
2015-01-30 17:45:57 +00:00
|
|
|
not finding a camera, perhaps because gstreamer is not installed, will
|
|
|
|
throw an exception during the kv language processing.
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Uncomment these lines to see all the messages
|
2016-12-14 15:30:46 +00:00
|
|
|
# from kivy.logger import Logger
|
|
|
|
# import logging
|
|
|
|
# Logger.setLevel(logging.TRACE)
|
2015-01-30 17:45:57 +00:00
|
|
|
|
2014-02-27 17:17:04 +00:00
|
|
|
from kivy.app import App
|
|
|
|
from kivy.lang import Builder
|
|
|
|
|
|
|
|
kv = '''
|
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
|
|
|
Camera:
|
|
|
|
id: camera
|
|
|
|
resolution: (640, 480)
|
|
|
|
play: False
|
|
|
|
ToggleButton:
|
|
|
|
text: 'Play'
|
|
|
|
on_press: camera.play = not camera.play
|
|
|
|
size_hint_y: None
|
|
|
|
height: '48dp'
|
|
|
|
'''
|
|
|
|
|
2015-01-30 17:45:57 +00:00
|
|
|
|
2014-02-27 17:17:04 +00:00
|
|
|
class TestCamera(App):
|
|
|
|
def build(self):
|
|
|
|
return Builder.load_string(kv)
|
|
|
|
|
|
|
|
TestCamera().run()
|