limit image size to 480 to prevent issues

macos fixes
This commit is contained in:
Prohurtz 2023-09-23 14:47:58 -05:00
parent 916967c560
commit 0b7b1bed07
2 changed files with 15 additions and 4 deletions

View File

@ -5,7 +5,7 @@ import serial
import serial.tools.list_ports
import threading
import time
import platform
from colorama import Fore
from config import EyeTrackConfig
from enum import Enum
@ -113,7 +113,10 @@ class Camera:
self.cv2_camera = cv2.VideoCapture()
self.cv2_camera.setExceptionMode(True)
# https://github.com/opencv/opencv/blob/4.8.0/modules/videoio/include/opencv2/videoio.hpp#L803
self.cv2_camera.open(self.current_capture_source, cv2.CAP_FFMPEG, params=OPENCV_PARAMS)
if platform.system() == "Darwin":
self.cv2_camera.open(self.current_capture_source) #MacOS
else:
self.cv2_camera.open(self.current_capture_source, cv2.CAP_FFMPEG, params=OPENCV_PARAMS)
should_push = False
else:
# We don't have a capture source to try yet, wait for one to show up in the GUI.
@ -137,6 +140,11 @@ class Camera:
def get_cv2_camera_picture(self, should_push):
try:
ret, image = self.cv2_camera.read()
height, width = image.shape[:2] # Calculate the aspect ratio
aspect_ratio = float(width) / float(height) # Determine the new height based on the desired maximum width
new_height = int(680 / aspect_ratio)
image = cv2.resize(image, (680, new_height))
# image = cv2.resize(image, (480, 480))
if not ret:
self.cv2_camera.set(cv2.CAP_PROP_POS_FRAMES, 0)
raise RuntimeError("Problem while getting frame")

View File

@ -39,7 +39,7 @@ from one_euro_filter import OneEuroFilter
import psutil, os
import sys
from utils.misc_utils import resource_path
import platform
frames = 0
def run_model(input_queue, output_queue, session):
@ -77,7 +77,10 @@ class LEAP_C(object):
# 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.queue_max_size = 1 # Optimize for best CPU usage, Memory, and Latency. A maxsize is needed to not create a potential memory leak.
self.model_path = resource_path('Models/mommy072623.onnx')
if platform.system() == "Darwin":
self.model_path = resource_path('EyeTrackApp/Models/mommy072623.onnx') # funny MacOS files issues :P
else:
self.model_path = resource_path('Models/mommy072623.onnx')
self.interval = 1 # FPS print update rate
self.low_priority = True # set process priority to low
self.print_fps = True