Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Dielmar #1850

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Dielmar
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.image import Image
from kivy.uix.boxlayout import BoxLayout
from kivy.graphics.texture import Texture
import cv2

class DielmarApp(App):
def build(self):
self.camera = cv2.VideoCapture(0)
layout = BoxLayout(orientation='vertical')

self.img1 = Image()
layout.add_widget(self.img1)

capture_button = Button(text="Capture Selfie", size_hint=(1, 0.1))
capture_button.bind(on_press=self.capture_selfie)
layout.add_widget(capture_button)

return layout

def capture_selfie(self, *args):
ret, frame = self.camera.read()
if ret:
buffer = cv2.flip(frame, 0).tobytes()
texture = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
texture.blit_buffer(buffer, colorfmt='bgr', bufferfmt='ubyte')
self.img1.texture = texture

def on_stop(self):
self.camera.release()

if __name__ == '__main__':
DielmarApp().run()
def apply_filter(self, image):
# Convert to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Apply GaussianBlur
filtered = cv2.GaussianBlur(gray, (15, 15), 0)
return filtered