mirror of
https://github.com/ck-zhang/EyePy.git
synced 2025-12-30 15:49:48 -06:00
Unify style
This commit is contained in:
@@ -1,23 +1,20 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
import os
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
from eyetrax.utils.video import camera, fullscreen, iter_frames
|
||||
from eyetrax.gaze import GazeEstimator
|
||||
|
||||
from eyetrax.calibration import (
|
||||
run_9_point_calibration,
|
||||
run_5_point_calibration,
|
||||
run_lissajous_calibration,
|
||||
fine_tune_kalman_filter,
|
||||
)
|
||||
from eyetrax.filters import (
|
||||
make_kalman,
|
||||
KalmanSmoother,
|
||||
KDESmoother,
|
||||
NoSmoother,
|
||||
run_5_point_calibration,
|
||||
run_9_point_calibration,
|
||||
run_lissajous_calibration,
|
||||
)
|
||||
from eyetrax.cli import parse_common_args
|
||||
from eyetrax.filters import KalmanSmoother, KDESmoother, NoSmoother, make_kalman
|
||||
from eyetrax.gaze import GazeEstimator
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
from eyetrax.utils.video import camera, fullscreen, iter_frames
|
||||
|
||||
|
||||
def run_demo():
|
||||
|
||||
@@ -2,22 +2,17 @@ import cv2
|
||||
import numpy as np
|
||||
import pyvirtualcam
|
||||
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
from eyetrax.utils.video import camera, iter_frames
|
||||
from eyetrax.gaze import GazeEstimator
|
||||
from eyetrax.calibration import (
|
||||
run_9_point_calibration,
|
||||
run_5_point_calibration,
|
||||
run_lissajous_calibration,
|
||||
fine_tune_kalman_filter,
|
||||
)
|
||||
from eyetrax.filters import (
|
||||
make_kalman,
|
||||
KalmanSmoother,
|
||||
KDESmoother,
|
||||
NoSmoother,
|
||||
run_5_point_calibration,
|
||||
run_9_point_calibration,
|
||||
run_lissajous_calibration,
|
||||
)
|
||||
from eyetrax.cli import parse_common_args
|
||||
from eyetrax.filters import KalmanSmoother, KDESmoother, NoSmoother, make_kalman
|
||||
from eyetrax.gaze import GazeEstimator
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
from eyetrax.utils.video import camera, iter_frames
|
||||
|
||||
|
||||
def run_virtualcam():
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from .common import wait_for_face_and_countdown, compute_grid_points
|
||||
from .nine_point import run_9_point_calibration
|
||||
from .common import compute_grid_points, wait_for_face_and_countdown
|
||||
from .fine_tune import fine_tune_kalman_filter
|
||||
from .five_point import run_5_point_calibration
|
||||
from .lissajous import run_lissajous_calibration
|
||||
from .fine_tune import fine_tune_kalman_filter
|
||||
from .nine_point import run_9_point_calibration
|
||||
|
||||
__all__ = [
|
||||
"wait_for_face_and_countdown",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import time
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
@@ -7,7 +8,7 @@ from eyetrax.utils.screen import get_screen_size
|
||||
|
||||
def fine_tune_kalman_filter(gaze_estimator, kalman, camera_index: int = 0):
|
||||
"""
|
||||
Quick fine‑tuning pass to adjust Kalman filter's measurementNoiseCov.
|
||||
Quick fine‑tuning pass to adjust Kalman filter's measurementNoiseCov
|
||||
"""
|
||||
screen_width, screen_height = get_screen_size()
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
from eyetrax.calibration.common import (
|
||||
wait_for_face_and_countdown,
|
||||
_pulse_and_capture,
|
||||
compute_grid_points,
|
||||
wait_for_face_and_countdown,
|
||||
)
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
|
||||
|
||||
def run_5_point_calibration(gaze_estimator, camera_index: int = 0):
|
||||
"""
|
||||
Faster five-point calibration.
|
||||
Faster five-point calibration
|
||||
"""
|
||||
sw, sh = get_screen_size()
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import time
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
from eyetrax.calibration.common import wait_for_face_and_countdown
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
|
||||
|
||||
def run_lissajous_calibration(gaze_estimator, camera_index: int = 0):
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
from eyetrax.calibration.common import (
|
||||
wait_for_face_and_countdown,
|
||||
_pulse_and_capture,
|
||||
compute_grid_points,
|
||||
wait_for_face_and_countdown,
|
||||
)
|
||||
from eyetrax.utils.screen import get_screen_size
|
||||
|
||||
|
||||
def run_9_point_calibration(gaze_estimator, camera_index: int = 0):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
import numpy as np
|
||||
|
||||
from .base import BaseSmoother
|
||||
from . import make_kalman
|
||||
from .base import BaseSmoother
|
||||
|
||||
|
||||
class KalmanSmoother(BaseSmoother):
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
from pathlib import Path
|
||||
|
||||
import cv2
|
||||
import mediapipe as mp
|
||||
import numpy as np
|
||||
from collections import deque
|
||||
from pathlib import Path
|
||||
|
||||
from eyetrax.models import create_model, BaseModel
|
||||
from eyetrax.constants import (
|
||||
LEFT_EYE_INDICES,
|
||||
RIGHT_EYE_INDICES,
|
||||
MUTUAL_INDICES,
|
||||
)
|
||||
from eyetrax.constants import LEFT_EYE_INDICES, MUTUAL_INDICES, RIGHT_EYE_INDICES
|
||||
from eyetrax.models import BaseModel, create_model
|
||||
|
||||
|
||||
class GazeEstimator:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from importlib import import_module
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Dict, Type
|
||||
|
||||
from .base import BaseModel
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from __future__ import annotations
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
import pickle
|
||||
import numpy as np
|
||||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from sklearn.linear_model import Ridge
|
||||
|
||||
from .base import BaseModel
|
||||
from . import register_model
|
||||
from .base import BaseModel
|
||||
|
||||
|
||||
class RidgeModel(BaseModel):
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
import cv2
|
||||
|
||||
|
||||
@contextmanager
|
||||
def fullscreen(name: str):
|
||||
"""Open a window in full-screen mode"""
|
||||
"""
|
||||
Open a window in full-screen mode
|
||||
"""
|
||||
cv2.namedWindow(name, cv2.WND_PROP_FULLSCREEN)
|
||||
cv2.setWindowProperty(name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
|
||||
try:
|
||||
@@ -16,7 +20,9 @@ def fullscreen(name: str):
|
||||
|
||||
@contextmanager
|
||||
def camera(index: int = 0):
|
||||
"""Context manager returning an opened VideoCapture"""
|
||||
"""
|
||||
Context manager returning an opened VideoCapture
|
||||
"""
|
||||
cap = cv2.VideoCapture(index)
|
||||
if not cap.isOpened():
|
||||
raise RuntimeError(f"cannot open camera {index}")
|
||||
@@ -27,7 +33,9 @@ def camera(index: int = 0):
|
||||
|
||||
|
||||
def iter_frames(cap: cv2.VideoCapture):
|
||||
"""Infinite generator yielding successive frames"""
|
||||
"""
|
||||
Infinite generator yielding successive frames
|
||||
"""
|
||||
while True:
|
||||
ok, frame = cap.read()
|
||||
if not ok:
|
||||
|
||||
Reference in New Issue
Block a user