Skip to main content

Pupil Labs Camera

ci documentation uv ruff pre-commit pypi version python version

pl-camera banner

This repo contains functionality around the usage of camera intrinsics for undistorting data, projecting and unprojecting points.

It is mostly a wrapper around OpenCV's functionality, providing type hints, input validation, a more intuitive interface, and a few performance optimizations.

Installation

pip install pupil-labs-camera

or

pip install -e git+https://github.com/pupil-labs/pl-camera.git

Quick Start

The following code demonstrates how to use the library in the context of a Neon recording to undistort an image and 2D gaze points. Additional examples can be found in the example Jupyter Notebook.

import cv2

from pupil_labs import neon_recording as nr
from pupil_labs.camera import Camera

recording = nr.NeonRecording(
    "/path/to/recording"
)
camera = Camera(
    pixel_width=1600,
    pixel_height=1200,
    camera_matrix=recording.calibration.scene_camera_matrix,
    distortion_coefficients=recording.calibration.scene_distortion_coefficients,
)

data = zip(recording.scene, recording.gaze.sample(recording.scene.time))

for scene_frame, gaze_sample in data:
    distorted_image = scene_frame.bgr
    undistorted_image = camera.undistort_image(distorted_image)

    distorted_gaze = gaze_sample.point
    undistorted_gaze = camera.undistort_points(distorted_gaze)

    cv2.circle(
        distorted_image,
        tuple(map(int, distorted_gaze)),
        radius=25,
        color=(0, 0, 255),
        thickness=5,
    )

    cv2.circle(
        undistorted_image,
        tuple(map(int, undistorted_gaze)),
        radius=25,
        color=(0, 255, 0),
        thickness=5,
    )

    cv2.imshow("Distorted Image", distorted_image)
    cv2.imshow("Undistorted Image", undistorted_image)
    cv2.waitKey(30)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pupil_labs_camera-1.2.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pupil_labs_camera-1.2.1-py3-none-any.whl (185.6 kB view details)

Uploaded Python 3

File details

Details for the file pupil_labs_camera-1.2.1.tar.gz.

File metadata

  • Download URL: pupil_labs_camera-1.2.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pupil_labs_camera-1.2.1.tar.gz
Algorithm Hash digest
SHA256 29cbff5b9c7b31d7e034be8086ceeb5e71d24ed681257625ec97156981781c6f
MD5 05237ea6aa326f301081e269754f64ad
BLAKE2b-256 4c3c2dd77dc52009886dacd6edcb44da2c7cd941be60685bf55a8165fc867743

See more details on using hashes here.

Provenance

The following attestation bundles were made for pupil_labs_camera-1.2.1.tar.gz:

Publisher: on-release-main.yml on pupil-labs/pl-camera

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pupil_labs_camera-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pupil_labs_camera-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b3f66bba702ea1a029a7baace5871a9614dfa06489f5b6f9814c24c2ae32e0b0
MD5 675993894a73c102d04a2537e98ccbdf
BLAKE2b-256 7cec8fbc0895c4ecfb529d7b9b77fb436434aa50a06b13a5b2683d43ff8e0cd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pupil_labs_camera-1.2.1-py3-none-any.whl:

Publisher: on-release-main.yml on pupil-labs/pl-camera

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page