Skip to content

Instantly share code, notes, and snippets.

@marc-tonsen
marc-tonsen / README.md
Last active January 5, 2023 08:27
This script extends blink, fixation and gaze data by adding an additional column "world_frame_index" to every CSV file. This column indicates the closest available world video frame for each data sample.

This script extends blink, fixation and gaze data by adding an additional column "world_frame_index" to every CSV file. This column indicates the closest available world video frame for each data sample.

To install the dependencies, run the following

pip install numpy pandas

Before executing the file, customize the file paths in the beginning of the file. If you do not want one of the files to be edited, e.g. the fixations file, then set the according path to "None", i.e. fixations_path = None.

@marc-tonsen
marc-tonsen / video_undistortion.py
Last active February 14, 2022 08:35
This code undistorts the scene video of a Pupil Invisible recording in raw binary format. The camera intrinisics used for the undistortion are downloaded from Pupil Cloud, so a connection to the internet is necessary.
import av
import cv2
import json
import struct
import pathlib
import argparse
import requests
import itertools
import numpy as np
from tqdm import tqdm
@marc-tonsen
marc-tonsen / README.md
Last active April 11, 2022 07:47
Written by @dourvaris

Scanpath Visualization

This Python script reads the Pupil Cloud raw data export and renders the subject's scanpath into the scene video.

Installation

  1. To install the requirements run pip install more_itertools pandas numpy tqdm av opencv-python
  2. Download the scanpathvis.py file to your computer
@marc-tonsen
marc-tonsen / ndsi_example.py
Created January 8, 2021 12:53
This gist demonstrates how to receive Pupil Invisible data over the local network in real-time for a simple visualization.
import time
import cv2
import numpy as np
# https://github.com/pupil-labs/pyndsi/tree/v1.0
import ndsi # Main requirement
SENSOR_TYPES = ["video", "gaze"]
SENSORS = {} # Will store connected sensors
import numpy as np
# Opening `*.time` files
time = np.fromfile(path_time, dtype="<u8")
# Opening `gaze ps*.raw` files
gaze = np.fromfile(path_gaze, dtype="<f4")
# Reshaping to (N, 2)
gaze.shape = (-1, 2)
@marc-tonsen
marc-tonsen / Pupil_Detection_Example.ipynb
Created October 11, 2017 07:37
Pupil Detection Example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.