Skip to content

Instantly share code, notes, and snippets.

View papr's full-sized avatar
🏠
Working from home

Pablo Prietz papr

🏠
Working from home
View GitHub Profile
@papr
papr / extract_diameter.py
Last active December 10, 2019 22:25
Extract 2d and 3d (if available) pupil diameters for a set of given recordings. The resulting csv file will be saved within its according recording.
import argparse
import csv
import logging
import os
import traceback as tb
import numpy as np
import msgpack
import logging
import time
from pyglui import ui
from plugin import Plugin
from background_helper import IPC_Logging_Task_Proxy
logger = logging.getLogger(__name__)
@papr
papr / marker_verification.py
Created April 2, 2019 14:11
Pupil Capture plugin gives feedback on the detection of circle markers
import cv2
from pyglui import ui
from pyglui.cygl.utils import draw_polyline, RGBA
from OpenGL.GL import GL_POLYGON
from circle_detector import CircleTracker
from plugin import Plugin
@papr
papr / launch.json
Created May 6, 2019 12:20
VS Code launch files for Pupil Capture and Player
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Pupil Capture",
"type": "python",
"request": "launch",
@papr
papr / README.md
Last active September 23, 2022 09:13
Create a Pupil Player compatible recording from a single world video file

NOTE: Out-dated gist. Use this one instead.

import msgpack
ref_file_path = "reference_locations.msgpack"
with open(ref_file_path, "rb") as fh:
ref_locs = msgpack.unpack(fh, raw=False)
print("Reference location data format:", ref_locs["version"])
# Reference locations
@papr
papr / clock.py
Last active October 21, 2019 10:38
import logging
from pathlib import Path
import cv2
from datetime import datetime
from pupil_recording import PupilRecording
from plugin import Plugin
logger = logging.getLogger(__name__)
fixations_on_surface_magazine_concord_caption_1487539793.5600355.csv
Maximum difference:
norm_pos_x 4.635625e-12
norm_pos_y 3.622880e-12
x_scaled 4.932872e-10
y_scaled 3.086825e-09
dtype: float64
fixations_on_surface_magazine_concord_image_1487539724.7831304.csv
Maximum difference:
# Part 1: Load file and visualize/transform single reference locations
# Requires https://pypi.org/project/msgpack/
import sys
import msgpack
# Adjust the following variables to your recording
world_video_resolution = (1280, 720)
path_to_reference_locations = "/Volumes/32TB/users/ppr/recordings/2019_09_04/000/offline_data/reference_locations.msgpack"

Third-Party Camera Requirements for Pupil Capture

Third-party cameras - Pupil Capture supports third-party USB cameras that fulfill the following criteria:

  1. UVC compatible (Chapters below refer to this document)
  2. Support Video Interface Class Code 0x0E CC_VIDEO (see A.1)
  3. Support Video Subclass Code 0x02 SC_VIDEOSTREAMING (see A.2)
  4. Support for the UVC_VS_FRAME_MJPEG (0x07) video streaming interface descriptor subtype (A.6)
  5. Support UVC_FRAME_FORMAT_COMPRESSED frame format

Access Pupil cameras via libuvc These are the steps that pyuvc uses to access Pupil cameras: