fix: beta 11 ready

This commit is contained in:
Prohurtz 2024-02-19 13:27:29 -08:00
parent eb865ab544
commit db20afda69
7 changed files with 51 additions and 37 deletions

View File

@ -1087,8 +1087,8 @@ if __name__ == "__main__":
cv2.imshow("hsf_hsrac", base_img) cv2.imshow("hsf_hsrac", base_img)
if cv2.waitKey(1) & 0xFF == ord("q"): if cv2.waitKey(1) & 0xFF == ord("q"):
pass pass
if save_video: # if save_video:
video_wr.write(cv2.resize(base_img, (200, 150))) # video_wr.write(cv2.resize(base_img, (200, 150)))
else: else:
_ = hsrac.single_run() _ = hsrac.single_run()
@ -1100,7 +1100,7 @@ if __name__ == "__main__":
main_end_time = timeit.default_timer() main_end_time = timeit.default_timer()
main_total_time = main_end_time - main_start_time main_total_time = main_end_time - main_start_time
if save_img: if save_img:
cv2.imwrite(output_img_path, all_point_img) # cv2.imwrite(output_img_path, all_point_img)
logger.info("image output: {}".format(output_img_path)) logger.info("image output: {}".format(output_img_path))
if imshow_enable: if imshow_enable:
cv2.imshow("allpoint", all_point_img) cv2.imshow("allpoint", all_point_img)

View File

@ -34,7 +34,9 @@ from enums import EyeLR
from one_euro_filter import OneEuroFilter from one_euro_filter import OneEuroFilter
from utils.img_utils import safe_crop from utils.img_utils import safe_crop
from enum import IntEnum from enum import IntEnum
import os
os.environ["OMP_NUM_THREADS"] = "1"
class EyeId(IntEnum): class EyeId(IntEnum):
RIGHT = 0 RIGHT = 0
@ -78,6 +80,7 @@ def data2csv(data_u32, filepath):
with open(filepath, "w", encoding="utf-8") as out_f: with open(filepath, "w", encoding="utf-8") as out_f:
out_f.write("x,y,eyedilation\n") out_f.write("x,y,eyedilation\n")
out_f.writelines(datalines) out_f.writelines(datalines)
print('file write')
return return
@ -204,6 +207,7 @@ class EllipseBasedPupilDilation:
self.data[0, -1] = self.maxval self.data[0, -1] = self.maxval
self.data[1:4, -1] = self.now_roi self.data[1:4, -1] = self.now_roi
cv2.imwrite(self.imgfile, u32_1ch_to_u16_3ch(self.data)) cv2.imwrite(self.imgfile, u32_1ch_to_u16_3ch(self.data))
print('file write')
# print("SAVED: {}".format(self.imgfile)) # print("SAVED: {}".format(self.imgfile))
def change_roi(self, roiinfo: dict): def change_roi(self, roiinfo: dict):
@ -372,7 +376,7 @@ class EllipseBasedPupilDilation:
eyedilation = 0.0 eyedilation = 0.0
if changed and ( if changed and (
(time.time() - self.lct) > 5 (time.time() - self.lct) > 15
): # save every 5 seconds if something changed to save disk usage ): # save every 5 seconds if something changed to save disk usage
self.save() self.save()
self.lct = time.time() self.lct = time.time()

View File

@ -34,7 +34,9 @@ from operator import truth
from dataclasses import dataclass from dataclasses import dataclass
import sys import sys
import asyncio import asyncio
import os
os.environ["OMP_NUM_THREADS"] = "1"
sys.path.append(".") sys.path.append(".")
from config import EyeTrackCameraConfig from config import EyeTrackCameraConfig
from config import EyeTrackSettingsConfig from config import EyeTrackSettingsConfig

View File

@ -15,6 +15,7 @@ if is_nt:
from winotify import Notification from winotify import Notification
os.system("color") # init ANSI color os.system("color") # init ANSI color
os.environ["OMP_NUM_THREADS"] = "1"
# Random environment variable to speed up webcam opening on the MSMF backend. # Random environment variable to speed up webcam opening on the MSMF backend.
# https://github.com/opencv/opencv/issues/17687 # https://github.com/opencv/opencv/issues/17687
os.environ["OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS"] = "0" os.environ["OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS"] = "0"
@ -30,7 +31,7 @@ SETTINGS_RADIO_NAME = "-SETTINGSRADIO-"
ALGO_SETTINGS_RADIO_NAME = "-ALGOSETTINGSRADIO-" ALGO_SETTINGS_RADIO_NAME = "-ALGOSETTINGSRADIO-"
page_url = "https://github.com/RedHawk989/EyeTrackVR/releases/latest" page_url = "https://github.com/RedHawk989/EyeTrackVR/releases/latest"
appversion = "EyeTrackApp 0.2.0 BETA 10.1" appversion = "EyeTrackApp 0.2.0 BETA 11"
def main(): def main():
@ -43,37 +44,40 @@ def main():
# Check to see if we can connect to our video source first. If not, bring up camera finding # Check to see if we can connect to our video source first. If not, bring up camera finding
# dialog. # dialog.
if config.settings.gui_update_check: try:
response = requests.get( if config.settings.gui_update_check:
"https://api.github.com/repos/RedHawk989/EyeTrackVR/releases/latest" response = requests.get(
) "https://api.github.com/repos/EyeTrackVR/EyeTrackVR/releases/latest"
latestversion = response.json()["name"]
if (
appversion == latestversion
): # If what we scraped and hardcoded versions are same, assume we are up to date.
print(f"\033[92m[INFO] App is the latest version! [{latestversion}]\033[0m")
else:
print(
f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m"
) )
try: latestversion = response.json()["name"]
if is_nt: if (
cwd = os.getcwd() appversion == latestversion
# icon = cwd + "\Images\logo.ico" ): # If what we scraped and hardcoded versions are same, assume we are up to date.
icon = resource_path("Images/logo.ico") print(f"\033[92m[INFO] App is the latest version! [{latestversion}]\033[0m")
toast = Notification( else:
app_id="EyeTrackApp", print(
title="New Update Available!", f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m"
msg=f"Please update to {latestversion}", )
icon=r"{}".format(icon), try:
) if is_nt:
toast.add_actions( cwd = os.getcwd()
label="Download Page", # icon = cwd + "\Images\logo.ico"
launch="https://github.com/RedHawk989/EyeTrackVR/releases/latest", icon = resource_path("Images/logo.ico")
) toast = Notification(
toast.show() app_id="EyeTrackApp",
except Exception as e: title="New Update Available!",
print("[INFO] Toast notifications not supported") msg=f"Please update to {latestversion}",
icon=r"{}".format(icon),
)
toast.add_actions(
label="Download Page",
launch="https://github.com/RedHawk989/EyeTrackVR/releases/latest",
)
toast.show()
except Exception as e:
print("[INFO] Toast notifications not supported")
except:
print("\033[91m[INFO] Could not check for updates. Please try again later.\033[0m")
# Check to see if we have an ROI. If not, bring up ROI finder GUI. # Check to see if we have an ROI. If not, bring up ROI finder GUI.

View File

@ -101,6 +101,7 @@ def data2csv(data_u32, filepath):
with open(filepath, "w", encoding="utf-8") as out_f: with open(filepath, "w", encoding="utf-8") as out_f:
out_f.write("x,y,intensity\n") out_f.write("x,y,intensity\n")
out_f.writelines(datalines) out_f.writelines(datalines)
print('file write')
return return
@ -225,6 +226,7 @@ class IntensityBasedOpeness:
self.data[0, -1] = self.maxval self.data[0, -1] = self.maxval
self.data[1:4, -1] = self.now_roi self.data[1:4, -1] = self.now_roi
cv2.imwrite(self.imgfile, u32_1ch_to_u16_3ch(self.data)) cv2.imwrite(self.imgfile, u32_1ch_to_u16_3ch(self.data))
print('file write')
# print("SAVED: {}".format(self.imgfile)) # print("SAVED: {}".format(self.imgfile))
def change_roi(self, roiinfo: dict): def change_roi(self, roiinfo: dict):
@ -384,7 +386,7 @@ class IntensityBasedOpeness:
eyeopen = 0.0 eyeopen = 0.0
if changed and ( if changed and (
(time.time() - self.lct) > 5 (time.time() - self.lct) > 11
): # save every 5 seconds if something changed to save disk usage ): # save every 5 seconds if something changed to save disk usage
self.save() self.save()
self.lct = time.time() self.lct = time.time()

View File

@ -67,7 +67,7 @@ class LEAP_C(object):
def __init__(self): def __init__(self):
onnxruntime.disable_telemetry_events() onnxruntime.disable_telemetry_events()
# Config variables # Config variables
self.num_threads = 3 # Number of python threads to use (using ~1 more than needed to achieve wanted fps yields lower cpu usage) self.num_threads = 4 # Number of python threads to use (using ~1 more than needed to achieve wanted fps yields lower cpu usage)
self.queue_max_size = 1 # Optimize for best CPU usage, Memory, and Latency. A maxsize is needed to not create a potential memory leak. self.queue_max_size = 1 # Optimize for best CPU usage, Memory, and Latency. A maxsize is needed to not create a potential memory leak.
if platform.system() == "Darwin": if platform.system() == "Darwin":
self.model_path = resource_path("Models/leap123023.onnx") # funny MacOS files issues :P self.model_path = resource_path("Models/leap123023.onnx") # funny MacOS files issues :P

View File

@ -428,11 +428,13 @@ def RANSAC3D(self, hsrac_en):
with open("RANSAC_BLINK_LEFT.cfg", "w") as file: with open("RANSAC_BLINK_LEFT.cfg", "w") as file:
for item in self.blink_list: for item in self.blink_list:
file.write(str(item) + "\n") file.write(str(item) + "\n")
print('file write')
if self.eye_id in [EyeId.RIGHT]: if self.eye_id in [EyeId.RIGHT]:
with open("RANSAC_BLINK_RIGHT.cfg", "w") as file: with open("RANSAC_BLINK_RIGHT.cfg", "w") as file:
for item in self.blink_list: for item in self.blink_list:
file.write(str(item) + "\n") file.write(str(item) + "\n")
print('file write')
# print("SAVE") # print("SAVE")
# self.blink_list.pop(0) # self.blink_list.pop(0)