mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
feat: bitrate, fps fixes, new leap model
This commit is contained in:
parent
db78c951a6
commit
a32a08e89b
@ -658,7 +658,7 @@ def fit_pupil_ellipse_swirski(img_pupil, edges_filter):
|
||||
contours, hierarchy = cv2.findContours(edges_filter, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
|
||||
max_contour_area = 0
|
||||
max_contour = None
|
||||
print("contours: ", contours)
|
||||
#print("contours: ", contours)
|
||||
for contour in contours:
|
||||
area = cv2.contourArea(contour)
|
||||
if area > max_contour_area:
|
||||
@ -694,28 +694,6 @@ def intersect_rect(rect1, rect2):
|
||||
return x, y, w, h
|
||||
|
||||
|
||||
def draw_coarse(img_bgr, pupil_rect, outer_rect, max_response, color):
|
||||
thickness = 1
|
||||
cv2.rectangle(
|
||||
img_bgr,
|
||||
(pupil_rect[0], pupil_rect[1]),
|
||||
(pupil_rect[0] + pupil_rect[2], pupil_rect[1] + pupil_rect[3]),
|
||||
color,
|
||||
thickness,
|
||||
)
|
||||
cv2.rectangle(
|
||||
img_bgr,
|
||||
(outer_rect[0], outer_rect[1]),
|
||||
(outer_rect[0] + outer_rect[2], outer_rect[1] + outer_rect[3]),
|
||||
color,
|
||||
thickness,
|
||||
)
|
||||
center = (pupil_rect[0] + pupil_rect[2] // 2, pupil_rect[1] + pupil_rect[3] // 2)
|
||||
cv2.drawMarker(img_bgr, center, color, cv2.MARKER_CROSS, 20, thickness)
|
||||
put_number(img_bgr, max_response, center, color)
|
||||
|
||||
|
||||
|
||||
def rect_suppression(rectlist, response, rectlist_out, response_out):
|
||||
for i in range(len(rectlist)):
|
||||
flag_intersect = False
|
||||
@ -776,7 +754,7 @@ def External_Run_AHSF(frame_gray):
|
||||
"mu_outer": 200, # aprroximatly how much pupil should be in the outer rect
|
||||
"mu_inner": 50, # aprroximatly how much pupil should be in the inner rect
|
||||
"ratio_outer": 0.9, # rectangular ratio. 1 means square (LIKE REGULAR HSF)
|
||||
"kf": 2, # noise filter. May lose tracking if too high (or even never start)
|
||||
"kf": 1, # noise filter. May lose tracking if too high (or even never start)
|
||||
"width_min": 16, # Minimum width of the pupil
|
||||
"width_max": 50, # Maximum width of the pupil
|
||||
"wh_step": 5, # Pupil width and height step search size
|
||||
@ -820,13 +798,11 @@ def External_Run_AHSF(frame_gray):
|
||||
thickness,
|
||||
)
|
||||
|
||||
center = (pupil_rect_coarse[0] + pupil_rect_coarse[2] // 2, pupil_rect_coarse[1] + pupil_rect_coarse[3] // 2)
|
||||
# center = (pupil_rect_coarse[0] + pupil_rect_coarse[2] // 2, pupil_rect_coarse[1] + pupil_rect_coarse[3] // 2)
|
||||
# cv2.drawMarker(frame_gray, center, (255, 255, 255), cv2.MARKER_CROSS, 20, thickness)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Calculate the major and minor diameters
|
||||
major_diameter = math.sqrt(width**2 + height**2)
|
||||
minor_diameter = min(width, height)
|
||||
|
||||
@ -85,6 +85,7 @@ class Camera:
|
||||
camera_status_outgoing: "queue.Queue[CameraState]",
|
||||
camera_output_outgoing: "queue.Queue(maxsize=20)",
|
||||
):
|
||||
|
||||
self.camera_status = CameraState.CONNECTING
|
||||
self.config = config
|
||||
self.camera_index = camera_index
|
||||
@ -108,6 +109,8 @@ class Camera:
|
||||
self.newft = 0
|
||||
self.fl = [0]
|
||||
|
||||
|
||||
|
||||
self.error_message = f"{Fore.YELLOW}[WARN] Capture source {{}} not found, retrying...{Fore.RESET}"
|
||||
|
||||
def __del__(self):
|
||||
@ -207,25 +210,24 @@ class Camera:
|
||||
self.cv2_camera.set(cv2.CAP_PROP_POS_FRAMES, 0)
|
||||
raise RuntimeError("Problem while getting frame")
|
||||
frame_number = self.cv2_camera.get(cv2.CAP_PROP_POS_FRAMES)
|
||||
# Calculate the fps.
|
||||
current_frame_time = time.time()
|
||||
delta_time = current_frame_time - self.last_frame_time
|
||||
self.last_frame_time = current_frame_time
|
||||
if delta_time > 0:
|
||||
self.bps = len(image) / delta_time
|
||||
self.frame_number = self.frame_number + 1
|
||||
self.fps = (self.fps + self.pf_fps) / 2
|
||||
self.newft = time.time()
|
||||
self.fps = 1 / (self.newft - self.prevft)
|
||||
self.prevft = self.newft
|
||||
self.fps = int(self.fps)
|
||||
current_fps = 1 / delta_time
|
||||
else:
|
||||
current_fps = 0
|
||||
self.last_frame_time = current_frame_time
|
||||
|
||||
if len(self.fl) < 60:
|
||||
self.fl.append(self.fps)
|
||||
self.fl.append(current_fps)
|
||||
else:
|
||||
self.fl.pop(0)
|
||||
self.fl.append(self.fps)
|
||||
self.fl.append(current_fps)
|
||||
|
||||
self.fps = sum(self.fl) / len(self.fl)
|
||||
# self.bps = image.nbytes
|
||||
self.bps = image.nbytes * self.fps
|
||||
|
||||
|
||||
if should_push:
|
||||
self.push_image_to_queue(image, frame_number, self.fps)
|
||||
except:
|
||||
@ -278,8 +280,6 @@ class Camera:
|
||||
current_frame_time = time.time()
|
||||
delta_time = current_frame_time - self.last_frame_time
|
||||
self.last_frame_time = current_frame_time
|
||||
if delta_time > 0:
|
||||
self.bps = len(jpeg) / delta_time
|
||||
self.fps = (self.fps + self.pf_fps) / 2
|
||||
self.newft = time.time()
|
||||
self.fps = 1 / (self.newft - self.prevft)
|
||||
@ -291,6 +291,7 @@ class Camera:
|
||||
self.fl.pop(0)
|
||||
self.fl.append(self.fps)
|
||||
self.fps = sum(self.fl) / len(self.fl)
|
||||
self.bps = image.nbytes * self.fps
|
||||
self.frame_number = self.frame_number + 1
|
||||
if should_push:
|
||||
self.push_image_to_queue(image, self.frame_number, self.fps)
|
||||
|
||||
@ -56,7 +56,7 @@ WINDOW_NAME = "EyeTrackApp"
|
||||
|
||||
|
||||
page_url = "https://github.com/RedHawk989/EyeTrackVR/releases/latest"
|
||||
appversion = "EyeTrackApp 0.2.0 BETA 13"
|
||||
appversion = "EyeTrackApp 0.2.0 BETA 14"
|
||||
|
||||
|
||||
class KeyManager:
|
||||
@ -296,7 +296,7 @@ def main():
|
||||
|
||||
# Event loop
|
||||
while True:
|
||||
eventg, valuesg = windowg.read()
|
||||
eventg, valuesg = windowg.read(timeout=30)
|
||||
|
||||
if eventg == sg.WINDOW_CLOSED:
|
||||
config.settings.gui_disable_gui = False
|
||||
@ -314,7 +314,7 @@ def main():
|
||||
# First off, check for any events from the GUI
|
||||
window = create_window(config, settings, eyes)
|
||||
while True:
|
||||
event, values = window.read(timeout=1) # this higher timeout saves some cpu usage
|
||||
event, values = window.read(timeout=30) # this higher timeout saves some cpu usage
|
||||
|
||||
# If we're in either mode and someone hits q, quit immediately
|
||||
if event == "Exit" or event == sg.WIN_CLOSED and not config.settings.gui_disable_gui:
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import os
|
||||
|
||||
os.environ["OMP_NUM_THREADS"] = "1"
|
||||
import onnxruntime
|
||||
import numpy as np
|
||||
@ -55,7 +54,7 @@ class LEAP_C:
|
||||
onnxruntime.disable_telemetry_events()
|
||||
self.num_threads = 2
|
||||
self.queue_max_size = 1
|
||||
self.model_path = resource_path(models / "LEAP071024_E16.onnx")
|
||||
self.model_path = resource_path(models / "pfld-sim.onnx")
|
||||
|
||||
self.print_fps = False
|
||||
self.frames = 0
|
||||
@ -131,9 +130,10 @@ class LEAP_C:
|
||||
if len(self.openlist) < 2500:
|
||||
self.openlist.append(d)
|
||||
else:
|
||||
print("full")
|
||||
pass
|
||||
# print("full")
|
||||
|
||||
print(len(self.openlist))
|
||||
#print(len(self.openlist))
|
||||
# self.openlist.pop(0)
|
||||
# self.openlist.append(d)
|
||||
|
||||
|
||||
@ -36,7 +36,8 @@ import os
|
||||
import subprocess
|
||||
import math
|
||||
from utils.calibration_3d import receive_calibration_data, converge_3d
|
||||
|
||||
from utils.misc_utils import resource_path
|
||||
from pathlib import Path
|
||||
|
||||
class TimeoutError(RuntimeError):
|
||||
pass
|
||||
@ -117,11 +118,13 @@ class var:
|
||||
|
||||
@Async
|
||||
def center_overlay_calibrate(self):
|
||||
tools = Path("Tools")
|
||||
# try:
|
||||
if var.overlay_active != True:
|
||||
|
||||
dirname = os.getcwd()
|
||||
overlay_path = os.path.join(dirname, "Tools/center.bat")
|
||||
|
||||
overlay_path = resource_path(tools / "center.bat")
|
||||
os.startfile(overlay_path)
|
||||
var.overlay_active = True
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user