tgoop.com/python2day/7021
Create:
Last Update:
Last Update:
EyeGestures β ΠΏΡΠ΅Π΄ΡΡΠ°Π²Ρ: ΡΡ ΡΠΏΡΠ°Π²Π»ΡΠ΅ΡΡ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠΎΠΌ ΠΎΠ΄Π½ΠΈΠΌΠΈ Π³Π»Π°Π·Π°ΠΌΠΈ, Π±Π΅Π· ΠΌΡΡΠΊΠΈ ΠΈ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ. ΠΡΠΎ Π½Π΅ ΡΠ°Π½ΡΠ°ΡΡΠΈΠΊΠ° β ΡΡΠΎ EyeGestures: open-source Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠ°, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΡΠ΅Π²ΡΠ°ΡΠ°Π΅Ρ ΡΠ²ΠΎΡ Π²Π΅Π±ΠΊΡ ΠΈΠ»ΠΈ ΠΊΠ°ΠΌΠ΅ΡΡ ΡΠ΅Π»Π΅ΡΠΎΠ½Π° Π² eye-tracker.
Π‘ Π΅Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΌΠΎΠΆΠ½ΠΎ ΡΡΡΠΎΠΈΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π΄Π»Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ Π²Π·Π³Π»ΡΠ΄ΠΎΠΌ, ΠΈΡΡΠ»Π΅Π΄ΠΎΠ²Π°Π½ΠΈΡ ΠΈΠ»ΠΈ ΠΏΡΠΎΡΡΠΎ ΡΠ°Π½Π°.
pip install eyeGestures
python3 examples/simple_example_v2.py
ΠΡΠΈΠΌΠ΅Ρ ΠΊΠΎΠ΄Π°:
from typing import Tuple, Optional
from eyeGestures.utils import VideoCapture
from eyeGestures import EyeGestures_v3
def run_eye_tracker(screen_width: int = 500, screen_height: int = 500) -> None:
"""
ΠΠ°ΠΏΡΡΠΊΠ°Π΅Ρ eye-tracking Ρ ΠΏΠΎΠΌΠΎΡΡΡ EyeGestures.
:param screen_width: ΡΠΈΡΠΈΠ½Π° ΡΠΊΡΠ°Π½Π° Π² ΠΏΠΈΠΊΡΠ΅Π»ΡΡ
:param screen_height: Π²ΡΡΠΎΡΠ° ΡΠΊΡΠ°Π½Π° Π² ΠΏΠΈΠΊΡΠ΅Π»ΡΡ
"""
gestures = EyeGestures_v3()
cap = VideoCapture(0)
calibrate: bool = True
while True:
ret, frame = cap.read()
if not ret:
break
event, cevent = gestures.step(
frame,
calibrate,
screen_width,
screen_height,
context="my_context"
)
if event:
cursor_x, cursor_y = event.point[0], event.point[1]
fixation: Optional[bool] = event.fixation
saccades: Optional[bool] = event.saccadess # Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΠ΅ Π³Π»Π°Π·
print(f"X: {cursor_x}, Y: {cursor_y}, Fixation: {fixation}, Saccades: {saccades}")
if __name__ == "__main__":
run_eye_tracker()
Π‘ΠΎΡ ΡΠ°Π½ΠΈ ΠΏΠΎΡΡ, ΡΡΠΎΠ±Ρ Π½Π΅ ΠΏΠΎΡΠ΅ΡΡΡΡ. ΠΡΠΎ ΡΠΎΡ ΡΠ°ΠΌΡΠΉ ΡΠ»ΡΡΠ°ΠΉ, ΠΊΠΎΠ³Π΄Π° Python Π²ΡΠ³Π»ΡΠ΄ΠΈΡ ΠΊΠ°ΠΊ ΠΌΠ°Π³ΠΈΡ
#python #soft #github

