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: object

Synchronous frame-by-frame recorder using Meye and FileWriter.

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.

start() None[source]

Start recording and initialize the output file.

Return type:

None

preview() None[source]

Open a live preview window (segmentation overlay).

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 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 pixels

  • major_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

stop() None[source]

Stop recording and close the output file.

Return type:

None

close() None[source]

Release the camera resource.

Return type:

None

close_all() None[source]

Stop recording and release all resources (file + camera).

Return type:

None

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: object

Asynchronous frame-by-frame recorder using Meye and BufferedFileWriter.

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() (or close_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 BufferedFileWriter and written as comment lines at the top of the file.

Return type:

None

preview() None[source]

Open a live preview window (segmentation overlay).

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 pixels

  • major_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

stop() None[source]

Stop recording and close the output file (flushes queued data).

Return type:

None

close() None[source]

Release the camera resource.

Return type:

None

close_all() None[source]

Stop recording and release all resources (writer + camera).

Return type:

None