-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3c5bb3
commit 97ffb08
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |