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.0.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.0-py3-none-any.whl (186.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pupil_labs_camera-1.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 d3b1b0359025caf13525cbe13b75b08254bf67d88ba0943d5b353c95ee1a8151
MD5 d8c450c0d7dcde2a36227e8af435d346
BLAKE2b-256 9e9d11182d5958573afe9f806496f555201b7f099187c920de364937e2e62cf4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pupil_labs_camera-1.2.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pupil_labs_camera-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95837f5a87c502176fa4d96d518485ce5eddaa50b4bf02bcb084b6241c72575f
MD5 cfa5142aee4343d3c50809a56e272bd7
BLAKE2b-256 41dec763ed1769be9863b9899fa4d2719e6e616c8ea226ae011b1f1cd1eef0d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pupil_labs_camera-1.2.0-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

1.2.1

2 files

This release

1.2.0 This release

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