Skip to content

Commit

Permalink
Updating app to being able to make release
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterWaIIace committed Apr 15, 2024
1 parent 8a566f5 commit dfbd832
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dist/*
venv
*.pyc
dist/*
*.csv
*.csv
data/*
4 changes: 4 additions & 0 deletions apps/appUtils/ActivationZone.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ def show(self):
print(f"showing: {self.rois[key]}")
self.rois[key].show()

def close_event(self):
if self.t != None and self.root != None:
self.stop_painting()

def rectangle_class():
app = QApplication(sys.argv)
RM = RoIMan()
Expand Down
9 changes: 6 additions & 3 deletions apps/appUtils/data_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ def __send_screenshot(self, filename, screenshot):
def __save_screenshots(self):
while self.screenshots_enable:
if self.ipc.not_empty:
print("saving screenshots")
filename, screenshot = self.ipc.get()
screenshot.save(filename)
try:
filename, screenshot = self.ipc.get(True,0.2)
screenshot.save(filename)
except:
print("no item available")
print("exiting saving")

def add_frame(self,directory,gevent,rois_to_save):
timestamp = datetime.datetime.now().timestamp()
Expand Down
48 changes: 41 additions & 7 deletions apps/app_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pyautogui
from screeninfo import get_monitors
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QObject, QThread

dir_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(f'{dir_path}\\..')
Expand All @@ -14,7 +15,6 @@
from eyeGestures.eyegestures import EyeGestures
from appUtils.EyeGestureWidget import EyeGestureWidget
from appUtils.CalibrationWidget import CalibrationWidget
from lab.pupillab import Worker
from appUtils.dot_windows import WindowsCursor
from appUtils.data_saver import DataManager

Expand All @@ -24,6 +24,35 @@ class CalibrationTypes:
TOP = "top"
BOTTOM = "bottom"


class Worker(QObject):

def __init__(self,thread):
super().__init__()

self.__displayPool = dict()
self.__thread = thread

self.__run = True

self.thread = QThread()
self.moveToThread(self.thread)

self.thread.started.connect(self.run)
self.thread.start()

def on_quit(self):
if self.__run == True:
self.__run = False
self.thread.quit()
self.thread.wait()
print("worker quitted")

def run(self):
while self.__run:
self.__thread()
print("exiting worker")

class Calibrator:

def __init__(self,width,height,start_x, start_y, show, disappear):
Expand Down Expand Up @@ -168,7 +197,7 @@ def clear_up(self):

class Lab:

def __init__(self):
def __init__(self,main_quit):
self.step = 10
self.monitor = list(filter(lambda monitor: monitor.is_primary == True ,get_monitors()))[0]

Expand All @@ -192,10 +221,11 @@ def __init__(self):

self.cap = VideoCapture(0)

self.eyegesture_widget.add_close_event(self.calibration_widget.close_event)
self.eyegesture_widget.add_close_event(self.on_quit)
self.eyegesture_widget.add_close_event(self.cap.close)
self.eyegesture_widget.add_close_event(self.dot_widget.close_event)
self.eyegesture_widget.add_close_event(self.calibration_widget.close_event)
self.eyegesture_widget.add_close_event(self.on_quit)
self.eyegesture_widget.add_close_event(main_quit)

self.__run = False
self.power_off = False
Expand All @@ -219,7 +249,8 @@ def start(self):
def stop(self):
self.dataSavingMan.disable_screenshots()
self.__run = False
self.calibrator.clear_up()
if self.calibrator:
self.calibrator.clear_up()
pass

def cursor_visible(self):
Expand Down Expand Up @@ -247,8 +278,11 @@ def update_radius(self,radius):
self.radius = radius

def on_quit(self):
self.stop()
self.__run = False
self.power_off = True
self.worker.on_quit()
print("main on quit finished")

def save_data(self,event,rois_to_save):
filename = f"{self.eyegesture_widget.get_text()}"
Expand Down Expand Up @@ -301,9 +335,9 @@ def run(self):
self.__display_eye(frame)
except Exception as e:
print(f"crashed in debug {e}")

print("Exiting main loop.")

if __name__ == '__main__':
app = QApplication(sys.argv)
lab = Lab()
lab = Lab(app.quit)
sys.exit(app.exec_())
7 changes: 4 additions & 3 deletions apps/app_win.spec
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# -*- mode: python ; coding: utf-8 -*-
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['app_win.py'],
pathex=[],
binaries=[],
datas=[('./venv/Lib/site-packages/mediapipe/modules', 'mediapipe/modules'),],
datas=[
('../venv/Lib/site-packages/mediapipe/modules', 'mediapipe/modules'),
('../lab', '.'),
],
hiddenimports=[],
hookspath=[],
hooksconfig={},
Expand Down
6 changes: 3 additions & 3 deletions pybuild.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
./venv/Scripts/activate;
pyinstaller app_win.spec;
deactivate;
@REM .\venv\Scripts\activate
pyinstaller ./apps/app_win.spec
@REM deactivate;
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = [

[project]
name = "eyeGestures"
version = "1.3.3"
version = "1.3.4"
authors = [
{ name="Piotr Walas", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ scikit_learn==1.3.2
scipy==1.12.0
screeninfo==0.8.1
setuptools==69.0.2
skimage==0.0
scikit-image==0.23.1
xlwt==1.3.0

0 comments on commit dfbd832

Please sign in to comment.