Skip to main content

Pupil detectors

Project description

pupil-detectors

PyPI

This Python package contains the standalone 2D pupil detectors for the Pupil-Labs software stack.

Installation

macOS and Linux

This package has a couple of non-python dependencies that you will have to install yourself before you can install pupil-detectors. We are working on clean setup instructions, but until then you can just install all dependencies from the Pupil software stack. You can find installation guides on the Pupil GitHub page (section: Installing Dependencies).

Then you can install pupil-detectors with pip:

pip install pupil-detectors

Windows

Since the dependency setup is very complex on Windows, we provide prebuilt-wheels. This means you don't have to install any dependencies and can just install pupil-detectors:

pip install pupil-detectors

If you don't want to use our prebuilt versions, see the section Building from Source further below.

Usage

Here's a quick example on how to detect and draw an ellipse.

import cv2
from pupil_detectors import Detector2D

detector = Detector2D()

# read image as numpy array from somewhere, e.g. here from a file
img = cv2.imread("pupil.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

result = detector.detect(gray)
ellipse = result["ellipse"]

# draw the ellipse outline onto the input image
# note that cv2.ellipse() cannot deal with float values
# also it expects the axes to be semi-axes (half the size)
cv2.ellipse(
    img,
    tuple(int(v) for v in ellipse["center"]),
    tuple(int(v / 2) for v in ellipse["axes"]),
    ellipse["angle"],
    0, 360, # start/end angle for drawing
    (0, 0, 255) # color (BGR): red
)
cv2.imshow("Image", img)
cv2.waitKey(0)

Developers

Building from Source

You can install this package locally from source. Make sure you have all necessary dependencies setup (see Installation section above).

NOTE: When using a Python virtual environment, it should be created without the --system-site-packages flag; otherwise building might fail.

NOTE: For Windows the dependency setup is quite complex. Until we have clean instructions, please follow the guide for setting up Windows dependencies for Pupil.

NOTE: When building the package on your own, you can experience severe performance differences when not having setup your dependencies correctly. Make sure to compare performance to prebuilt wheels or to bundled versions of Pupil.

# Clone repository
git clone git@github.com:pupil-labs/pupil-detectors.git
cd pupil-detectors

# Install from source with development extras
pip install ".[dev]"

# Run tests
pytest tests

Maintainers

Distribution

This project does not currently support automated distribution. Steps for a new release:

  1. Make sure the code works.
  2. Install dependencies
pip install bump2version twine
  1. Create new tag with bump2version.

    • Decide on type of version bump: major/minor/patch

    • Make sure the working directory is clean! (git status)

    • Modify CHANGELOG.md to include newest version notes.

    • Stage changelog (don't commit):

      git add CHANGELOG.md

    • Run the appropriate bump2version. This will create a new commit with all necessary changes (including the staged changelog) and a new tag!

      # ONLY ONE OF THOSE!
      bump2version major --allow-dirty
      # or
      bump2version minor --allow-dirty
      # or
      bump2version patch --allow-dirty
      
  2. Push the new commit and (all) tags.

git push
git push --tags
  1. Build the source distribution and wheel (Windows). Use the internal bundle-machine for Pupil for the correct dependency setup!
python setup.py sdist
pip wheel --no-deps . -w dist
  1. Test installing from wheel and from sdist!

  2. Upload wheel and sdist to PyPI.

twine upload ./dist/*

Changelog

2.0.1 (2020-12-03)

Removed all remaining Ceres references. Eigen3 remains a dependency.

2.0.0 (2020-12-02)

Removed Detector3D - #17

In favor of our new pye3d detector, we have removed the previous Detector3D class. This allows us to remove Ceres as a dependency and to cleanup the detector class interface.

Specifically, getting and setting properties has been simplified by removing property namespaces.

- NamespacedProperties = T.Dict[str, T.Dict[str, T.Any]]
+ DetectorProperties = T.Dict[str, T.Any]

- def get_property_namespaces(self) -> T.Iterable[str]

- def get_properties(self) -> NamespacedProperties:
+ def get_properties(self) -> DetectorProperties:

- def update_properties(self, properties: NamespacedProperties) -> None
+ def update_properties(self, properties: DetectorProperties) -> None

The Roi class has been moved from pupil_detectors.utils to pupil_detectors.roi.

1.1.1 (2020-08-26)

Improvements

  • Added default lookup paths for OpenCV on Ubuntu 20.04, enabling building from source out of the box there.
  • Added parameter to specify the focal length of the camera supplying the eye images for a more accurate 3D model.

1.1.0 (2020-05-04)

Changed

  • Changed the default 2D detector properties to be the same as the default overrides that the 3D detector applies.

1.0.5 (2020-04-20)

Added

  • Added option to run 3D detector without internal 2D detector, but from serialized data of external 2D detector

1.0.4 (2020-01-13)

Fixed

  • Fixed crash when installing from source distribution package

1.0.3 (2020-01-07)

Fixed

  • Wrong Roi.rect() computation.

1.0.2 (2019-12-03)

  • Initial release.

Project details


Download files

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

Source Distribution

pupil-detectors-2.0.1.tar.gz (238.0 kB view details)

Uploaded Source

Built Distribution

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

pupil_detectors-2.0.1-cp36-cp36m-win_amd64.whl (14.0 MB view details)

Uploaded CPython 3.6mWindows x86-64

File details

Details for the file pupil-detectors-2.0.1.tar.gz.

File metadata

  • Download URL: pupil-detectors-2.0.1.tar.gz
  • Upload date:
  • Size: 238.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.8

File hashes

Hashes for pupil-detectors-2.0.1.tar.gz
Algorithm Hash digest
SHA256 6a051f6e4bf53aa447b734796ced5ce6d7f09168a89d03c5a822943e61252b8c
MD5 d0fbc40ecffe0dd788bbae3dd0e79544
BLAKE2b-256 84c6502c76e3cbcae59542c55c0c65fe1bb1a90133e579d89bcf1e2ebd8e295d

See more details on using hashes here.

File details

Details for the file pupil_detectors-2.0.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pupil_detectors-2.0.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 14.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.8

File hashes

Hashes for pupil_detectors-2.0.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 bb6e35c42b9d6b310d0a8e86add7920d0af1463133ab69fc106cdd1d7d9e84c9
MD5 1f192aaf5e71c59be562e5e44ff9f17f
BLAKE2b-256 4518d1cc0137244e24479553ca2ce1805b929c125e2eaadca747edba08989201

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page