meyelens.online
Online recording helpers.
This module re-exports the canonical recorders from meyelens.meye to keep
the public API stable while avoiding duplicate implementations.
- class meyelens.online.MeyeRecorder(cam_ind=0, model=None, show_preview=False, filename='meye', folder_path='Data', sep=';')[source]
Bases:
objectSynchronous frame-by-frame recorder using
MeyeandFileWriter.This recorder captures frames from a
Camera, runs pupil detection, and writes one line per frame to a semicolon-separated text file.The output columns are:
time (seconds since start)
x, y (centroid coordinates; written as col, row)
pupil (mask area in pixels)
major_diameter, minor_diameter, orientation (ellipse fit; may be NaN)
trg1 … trg9 (user-defined trigger values)
- Parameters:
cam_ind (int, optional) – Camera index passed to
Camera.model (str or pathlib.Path or None, optional) – Path to the Keras model file. If
None, the packaged model is used.show_preview (bool, optional) – If
True, display an overlay window during recording.filename (str, optional) – Base filename used by
FileWriter(timestamp is added automatically).folder_path (str, optional) – Output folder where the text file is created.
sep (str, optional) – Column separator used in the output file.
Notes
This recorder writes synchronously to disk at each
save_frame()call.- save_frame(trg1=0, trg2=0, trg3=0, trg4=0, trg5=0, trg6=0, trg7=0, trg8=0, trg9=0) None[source]
Capture one frame, run pupil detection, and append a row to the output file.
- Parameters:
trg1 (int, optional) – Trigger values to save alongside the measurements.
trg2 (int, optional) – Trigger values to save alongside the measurements.
trg3 (int, optional) – Trigger values to save alongside the measurements.
trg4 (int, optional) – Trigger values to save alongside the measurements.
trg5 (int, optional) – Trigger values to save alongside the measurements.
trg6 (int, optional) – Trigger values to save alongside the measurements.
trg7 (int, optional) – Trigger values to save alongside the measurements.
trg8 (int, optional) – Trigger values to save alongside the measurements.
trg9 (int, optional) – Trigger values to save alongside the measurements.
- Return type:
None
- get_data()[source]
Capture one frame and return instantaneous pupil metrics.
- Returns:
Dictionary containing:
centroid: (x, y) as (col, row)size: pupil mask area in pixelsmajor_diameter: ellipse major axis in pixels (or NaN)minor_diameter: ellipse minor axis in pixels (or NaN)orientation: ellipse angle (degrees) (or NaN)
- Return type:
dict
- class meyelens.online.MeyeAsyncRecorder(cam_ind=0, model=None, show_preview=False, path_to_file='Data', filename='meye', buffer_size=100, sep=';', cam_crop=None)[source]
Bases:
objectAsynchronous frame-by-frame recorder using
MeyeandBufferedFileWriter.This recorder is similar to
MeyeRecorder, but data rows are queued in memory and written to disk by a background thread, reducing I/O latency inside tight loops.- Parameters:
cam_ind (int, optional) – Camera index passed to
Camera.model (str or pathlib.Path or None, optional) – Path to the Keras model file. If
None, the packaged model is used.show_preview (bool, optional) – If
True, display an overlay window during recording.path_to_file (str, optional) – Output folder where the text file is created.
filename (str, optional) – Base filename used by
BufferedFileWriter(timestamp is added automatically).buffer_size (int, optional) – Queue size for
BufferedFileWriter. When full, new rows are discarded and a warning is printed by the writer (no logging).sep (str, optional) – Column separator used in the output file.
cam_crop (list[int] or tuple[int, int, int, int] or None, optional) – Crop passed to
Camera(implementation-dependent).
Notes
You must call
stop()(orclose_all()) to flush remaining queued data.- start(metadata=None) None[source]
Start recording and initialize the asynchronous output writer.
- Parameters:
metadata (dict or None, optional) – Metadata passed to
BufferedFileWriterand written as comment lines at the top of the file.- Return type:
None
- save_frame(trg1=0, trg2=0, trg3=0, trg4=0, trg5=0, trg6=0, trg7=0, trg8=0, trg9=0) None[source]
Capture one frame, run pupil detection, and queue a row for disk writing.
- Parameters:
trg1 (int, optional) – Trigger values to save alongside the measurements.
trg2 (int, optional) – Trigger values to save alongside the measurements.
trg3 (int, optional) – Trigger values to save alongside the measurements.
trg4 (int, optional) – Trigger values to save alongside the measurements.
trg5 (int, optional) – Trigger values to save alongside the measurements.
trg6 (int, optional) – Trigger values to save alongside the measurements.
trg7 (int, optional) – Trigger values to save alongside the measurements.
trg8 (int, optional) – Trigger values to save alongside the measurements.
trg9 (int, optional) – Trigger values to save alongside the measurements.
- Return type:
None
- get_data()[source]
Capture one frame and return instantaneous pupil metrics.
- Returns:
Dictionary containing:
centroid: (x, y) as (col, row)size: pupil mask area in pixelsmajor_diameter: ellipse major axis in pixels (or NaN)minor_diameter: ellipse minor axis in pixels (or NaN)orientation: ellipse angle (degrees) (or NaN)
- Return type:
dict