Skip to content

Commit

Permalink
no error when closing
Browse files Browse the repository at this point in the history
  • Loading branch information
physics-coder committed Dec 17, 2022
1 parent eae859d commit 09cd0b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
.DS_Store
*.png
*.jpg
*.xml
.idea/
venv/
__pycache__/
7 changes: 5 additions & 2 deletions graphics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
from tkinter import *

import sys
import cv2
from PIL import Image, ImageTk

Expand Down Expand Up @@ -49,7 +49,10 @@ def __init__(self):
self.button_1.grid(row=1, column=0)
self.button_2.grid(row=1, column=1)
self.button_3.grid(row=1, column=2)

self.win.protocol("WM_DELETE_WINDOW", self.close_window)
self.running = True
def close_window(self):
self.running = False
def high(self):
self.selected_sensitivity = 2
self.then()
Expand Down
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def dist(a, b, c, d):
return math.sqrt((a - c) ** 2 + (b - d) ** 2)



detected = False
upright = False
cap = cv2.VideoCapture(0)
Expand All @@ -27,6 +28,8 @@ def dist(a, b, c, d):

# main loop
while cap.isOpened():
if not graphics.running:
break
# updating the tkinter window and text
graphics.update(detected, upright)
ret, img_orig = cap.read()
Expand Down Expand Up @@ -149,4 +152,5 @@ def dist(a, b, c, d):
else:
print("No camera input")


cap.release()

0 comments on commit 09cd0b0

Please sign in to comment.