Skip to content

Instantly share code, notes, and snippets.

View mikelgg93's full-sized avatar
🥽

Miguel García García mikelgg93

🥽
View GitHub Profile
@mikelgg93
mikelgg93 / fixated_aois.py
Created March 25, 2024 17:58
Get the AOI fixated as a column to your fixations and gaze csv files.
import base64
import logging
import os
import tempfile
import zipfile
from pathlib import Path
import cv2
import numpy as np
import pandas as pd
@mikelgg93
mikelgg93 / neon_az_el_RT.py
Created March 12, 2024 11:25
Get azimuth and elevation from Neon's scene camera using the realtime API.
import cv2
import numpy as np
from pupil_labs.realtime_api.simple import Device
def unproject_points(points_2d, camera_matrix, distortion_coefs, normalize=False):
"""
Undistorts points according to the camera model.
:param pts_2d, shape: Nx2
:return: Array of unprojected 3d points, shape: Nx3
@mikelgg93
mikelgg93 / ipc_core.py
Created February 29, 2024 10:46
Start a rec, calibrate and validate using IPC backbone messages for Pupil Core
import logging
import queue
import socket
import sys
import threading
import time
from typing import Any, Dict, Optional, Tuple
import msgpack as serializer
@mikelgg93
mikelgg93 / test_zmq_gaze3d.py
Created November 28, 2023 16:38
Core subscribe to gaze.3d.1
import msgpack
import zmq
ctx = zmq.Context()
pupil_remote = ctx.socket(zmq.REQ)
ip = "localhost"
port = 50020
pupil_remote.connect(f"tcp://{ip}:{port}")
@mikelgg93
mikelgg93 / README.md
Last active June 25, 2024 08:31
GPT4-eyes

Install it and run it:

  1. Set up your Python environment and API key using OpenAI's quick start guide
  2. Clone this gist or download it
  3. pip install -r requirements.txt
  4. python assistant.py

Using it

If you have your computer and Companion Device (Neon or Pupil Invisible) connected to the same network, it will be automatically linked and start streaming the scene camera with the gaze circle overlay.

@mikelgg93
mikelgg93 / cloud_api_v2.py
Created October 11, 2023 06:58
Cloud API utilities
import glob
import logging
import os
import shutil
from pathlib import Path
import pandas as pd
import requests
API_URL = "https://api.cloud.pupil-labs.com/v2"
@mikelgg93
mikelgg93 / get_events_from_Cloud.py
Last active April 16, 2024 06:20
A script to download events from Cloud using the API.
import glob
import logging
import os
import shutil
from pathlib import Path
import pandas as pd
import requests
API_URL = "https://api.cloud.pupil-labs.com/v2"
@mikelgg93
mikelgg93 / README.md
Created March 28, 2023 07:33
Customise the recent gaze points vis in Pupil Capture

This Gist provides instructions on how to use a custom plugin that replaces the default Display Recent Gaze plugin in Pupil Capture.

Installation and Use

Like any other plugin, place it pupil_capture_settings > plugins and restart Pupil Capture, you should see a new plugin on the plugin menu named Custom Display Recent Gaze, this will allow you change the size, color and transparency of the circle drawn with the latest gaze points after calibration.

@mikelgg93
mikelgg93 / README.md
Created March 20, 2023 10:16
Read number of frames

To install it:

pip install -r requirements.txt

To execute it:

python read_video.py path/to/video.mp4
@mikelgg93
mikelgg93 / blinkrate_PI.py
Last active January 13, 2023 07:28
Python snippet example on how to compute blink rate per minute.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
events_df = pd.read_csv("path/events.csv")
blinks_df = pd.read_csv("path/blinks.csv")
# filter blinks only occurring between event name A and B
event_name_A = "recording.begin"
event_name_B = "recording.end"