.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/online/5_map_gaze.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_online_5_map_gaze.py: Run gaze mapping ================ This example shows how to run gaze mapping with a connected Pupil Core headset. .. note:: This example requires the dependencies for :ref:`streaming` and :ref:`pupil detection`. .. GENERATED FROM PYTHON SOURCE LINES 15-21 .. code-block:: default import sys import logging import pupil_recording_interface as pri .. GENERATED FROM PYTHON SOURCE LINES 22-26 Set Pupil Core generation ------------------------- Set the generation of your Pupil Core device (1, 2 or 3) .. GENERATED FROM PYTHON SOURCE LINES 26-28 .. code-block:: default pupil_gen = 2 .. GENERATED FROM PYTHON SOURCE LINES 29-31 Set folder containing calibration --------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 31-34 .. code-block:: default folder = "~/pupil_capture_settings" .. GENERATED FROM PYTHON SOURCE LINES 35-37 Set up stream configurations ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 37-69 .. code-block:: default configs = [ pri.VideoStream.Config( device_type="uvc", device_uid=f"Pupil Cam{pupil_gen} ID2", name="world", resolution=(1280, 720), fps=30, pipeline=[pri.GazeMapper.Config(), pri.VideoDisplay.Config()], ), pri.VideoStream.Config( device_type="uvc", device_uid=f"Pupil Cam{pupil_gen} ID0", name="eye0", resolution=(320, 240) if pupil_gen == 1 else (192, 192), fps=120, color_format="gray", pipeline=[ pri.PupilDetector.Config(), pri.VideoDisplay.Config(flip=True), ], ), pri.VideoStream.Config( device_type="uvc", device_uid=f"Pupil Cam{pupil_gen} ID1", name="eye1", resolution=(320, 240) if pupil_gen == 1 else (192, 192), fps=120, color_format="gray", pipeline=[pri.PupilDetector.Config(), pri.VideoDisplay.Config()], ), ] .. GENERATED FROM PYTHON SOURCE LINES 70-72 Set up logger ------------- .. GENERATED FROM PYTHON SOURCE LINES 72-76 .. code-block:: default logging.basicConfig( stream=sys.stdout, level=logging.INFO, format="%(message)s" ) .. GENERATED FROM PYTHON SOURCE LINES 77-85 Run manager ----------- .. note:: When running the script from the command line, press 'Ctrl+C' to stop the manager. When running from a Jupyter notebook, interrupt the kernel (*Kernel > Interrupt Kernel* or press 'Esc' and then twice 'i'). .. GENERATED FROM PYTHON SOURCE LINES 85-94 .. code-block:: default with pri.StreamManager(configs, folder=folder) as manager: while not manager.stopped: if manager.all_streams_running: status = manager.format_status( "pupil.confidence", max_cols=72, sleep=0.1, nan_format=None, ) print("\r" + status, end="") print("\nStopped") .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_online_5_map_gaze.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 5_map_gaze.py <5_map_gaze.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 5_map_gaze.ipynb <5_map_gaze.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_