-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcameraib4.py
More file actions
43 lines (26 loc) · 907 Bytes
/
cameraib4.py
File metadata and controls
43 lines (26 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from kivy.app import App
from kivy.uix.camera import Camera
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
class CameraApp(App):
def build(self):
'''
:return:
'''
self.camera_obj = Camera()
self.camera_obj.resolution = (800,800)
#button
button_obj = Button(text = "Capture!")
button_obj.size_hint= (.5, .2)
button_obj.pos_hint = {'x':.25, 'y':.25}
button_obj.bind(on_press = self.take_image)
#Layout
layout = BoxLayout()
layout.add_widget(self.camera_obj)
layout.add_widget(button_obj)
return layout
def take_image(self, *args):
print("Picture is being captured!")
self.camera_obj.export_to_png("./selfie.png")
if __name__=='__main__':
CameraApp().run()