Skip to main content

Pupil, glint, and limbus detection on grayscale eye images, plus iris-texture rigid alignment of two eye images.

Project description

cheshm

PyPI version Downloads License DOI

Cheshm is a cross-platform (Linux, macOS, Windows) C++ library with Python bindings. It packages pupil, glint, and limbus detectors for grayscale eye images, plus rigid alignment of two eye images (glint, pupil, or iris-texture based) and helpers for saving the resulting visualizations to PNG.

To annotate eye images with cheshm's detectors, see EyE Annotation Tool.

cheshm GUI

Install

uv add cheshm

or with pip:

pip install cheshm

Detectors

Kind Detector Paper Licence
pupil Simple MIT
pupil Starburst Li, Winfield, Parkhurst 2005 GPL
pupil Swirski2D Świrski, Bulling, Dodgson 2012 MIT
pupil ExCuSe Fuhl et al. 2015 non-commercial
pupil ElSe Fuhl et al. 2016 non-commercial
pupil PuRe Santini, Fuhl, Kasneci 2018 non-commercial
pupil PuReST Santini, Fuhl, Kasneci 2018 non-commercial
pupil PupilLabs2D Kassner, Patera, Bulling 2014 LGPL-3.0-or-later
glint Simple MIT
limbus Daugman integro-differential Daugman 1993 MIT
limbus Daugman active contour Daugman 2007 MIT
limbus Pupil-guided active contour Daugman 2007 variant MIT

The top-level LICENSE is MIT and covers the framework code; each detector ships its own LICENSE file with the detector's terms. Installing the project from PyPI installs all detectors, but only the ones you import are loaded into your process — so the licence that governs your use is the licence of the detectors you imported:

from cheshm.pupil_detectors.Simple import detect_pupil       # MIT
from cheshm.pupil_detectors.Starburst import detect_pupil    # GPL
from cheshm.pupil_detectors.ExCuSe import detect_pupil       # non-commercial
from cheshm.pupil_detectors.ElSe import detect_pupil         # non-commercial
from cheshm.pupil_detectors.PuRe import detect_pupil         # non-commercial
from cheshm.pupil_detectors.PuReST import PuReST             # non-commercial (stateful tracker)
from cheshm.pupil_detectors.PupilLabs2D import detect_pupil  # LGPL-3.0
from cheshm.glint_detectors.Simple import detect_glints      # MIT
from cheshm.limbus_detectors.daugman.integro_differential import detect_limbus  # MIT
from cheshm.limbus_detectors.daugman.active_contour import detect_limbus        # MIT
from cheshm.limbus_detectors.daugman.pupil_guided import detect_limbus          # MIT

Single-eye contract

Every public function operates on one eye at a time — a single grayscale image. Callers with two eyes call cheshm twice and combine the results.

Alignment

cheshm.align.align_eye_images(ref_img, tgt_img, ref_det, tgt_det, *, step1, step2) registers tgt_img onto ref_img with up to a two-step rigid transform. Either step can be enabled independently:

  • Step 1 (translation) anchors on glint centroids (step1="glint"), pupil centres (step1="pupil"), or is skipped (step1=None).
  • Step 2 (iris-texture refinement, optional) refines (dx, dy, theta) by minimising mean absolute intensity difference inside an iris-barrel mask built from the limbus + pupil geometry.

Set step1="glint", step2=False for pure glint alignment, step1="pupil", step2=False for pure pupil-centre alignment, step1=None, step2=True for iris-only, or any combination.

Visualization

cheshm.viz writes PNGs that show detector and alignment outputs:

  • save_detection_overlay(out_path, img, detections, *, style, label) — draws pupil, glint, and limbus overlays on img. style is a dict keyed by element (pupil_contour, pupil_ellipse, pupil_center, pupil_mask, glint_contour, glint_ellipse, glint_center, limbus_curve, limbus_center) where each value is {show, color, thickness, alpha}.
  • save_diff_heatmap(out_path, ref, aligned) — colour-mapped |ref − aligned|.
  • save_alignment_overlay(out_path, ref, aligned) — blended reference + aligned image.
  • save_alignment_comparison(out_path, ref, target, aligned) — 4-panel: ref | aligned | diff-before | diff-after.

GUI

cheshm-gui opens a Dear PyGui workbench for tuning detector parameters interactively on a folder of images.

cheshm-gui                       # empty workbench
cheshm-gui path/to/folder        # open a folder of eye images
cheshm-gui path/to/a.png p2.png  # open specific files

Development

Cheshm ships precompiled wheels on PyPI for Linux, macOS, and Windows on Python 3.10–3.13, so end users never need to build anything. This section is for users who want to build from source. Building from source needs CMake, a C++20 compiler, OpenCV, and (for PupilLabs2D) Eigen3.

The project uses uv for environment management and scikit-build-core to drive CMake. First-time setup:

cd path/to/cheshm
uv sync

This creates .venv/, installs runtime + build deps, and builds the C++ extensions in editable mode (per [tool.scikit-build] in pyproject.toml).

After changing any C/C++ source, force a recompile:

uv sync --reinstall-package cheshm

Plain uv sync will not notice C/C++ source edits — only pyproject.toml changes.

After changing a binding's signature (a core.cpp under bindings/python/src/), regenerate the matching _core.pyi:

./scripts/regen_stubs.sh

Commit the updated .pyi alongside the .cpp. CI verifies the committed stubs match what stubgen would emit and fails the PR if they drift.

Repo layout

include/cheshm/         public C++ headers (libcheshm_cpp)
  helpers/              shared image-processing helpers (edges, ellipses, image, shape)
  pupil/<Det>/          per-pupil-detector headers
  glint/Simple/         per-glint-detector headers
  limbus/Daugman/       Daugman family (active_contour, integro_differential, pupil_guided)
  align/                rigid alignment headers
  viz/                  visualization headers
src/                    C++ algorithm implementations
bindings/python/
  cheshm/               Python package (PyPI)
  src/                  nanobind C++ glue, one CMake per detector
third_party/poolstl/    vendored parallel-STL backend

Name

In Persian (Farsi), Cheshm (چشم) literally means "eye".

Logo

The nazar / cheshm amulet image is from pngegg.

Acknowledgments

This work received funding from the European Union's Horizon Europe research and innovation funding program under grant agreement No 101072410, Eyes4ICU project.

Funded by EU Eyes4ICU

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

cheshm-2.5.0.tar.gz (3.3 MB view details)

Uploaded Source

Built Distributions

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

cheshm-2.5.0-cp313-cp313-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.13Windows x86-64

cheshm-2.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cheshm-2.5.0-cp313-cp313-macosx_15_0_x86_64.whl (33.4 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

cheshm-2.5.0-cp313-cp313-macosx_14_0_arm64.whl (15.9 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

cheshm-2.5.0-cp312-cp312-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.12Windows x86-64

cheshm-2.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cheshm-2.5.0-cp312-cp312-macosx_15_0_x86_64.whl (33.4 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

cheshm-2.5.0-cp312-cp312-macosx_14_0_arm64.whl (15.9 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

cheshm-2.5.0-cp311-cp311-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.11Windows x86-64

cheshm-2.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cheshm-2.5.0-cp311-cp311-macosx_15_0_x86_64.whl (33.4 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

cheshm-2.5.0-cp311-cp311-macosx_14_0_arm64.whl (15.9 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

cheshm-2.5.0-cp310-cp310-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.10Windows x86-64

cheshm-2.5.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cheshm-2.5.0-cp310-cp310-macosx_15_0_x86_64.whl (33.4 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.5.0-cp310-cp310-macosx_14_0_arm64.whl (15.9 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file cheshm-2.5.0.tar.gz.

File metadata

  • Download URL: cheshm-2.5.0.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cheshm-2.5.0.tar.gz
Algorithm Hash digest
SHA256 3c07a2c3234fc6e0ddefc7e298041030951d42ff19a19d5c50d526000c25974a
MD5 bea02dd316bddd53e2a952a5c6db0201
BLAKE2b-256 a38000098811bc6cfa92012e13a5d7174e4e7436ac4267e8194f3812363efaa1

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.5.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cheshm-2.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b5dd27f4c74656c4cfefd0ae78babe931e615d023b6d9406890c0aa1b043f7a2
MD5 3ed5da79d8883423e58181fff29c42c1
BLAKE2b-256 c15716ffb6da89f88787c65b5b9a792bed3261882bd226b4726b7b54970fc780

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0d885f02bc187c97543417a1f7ecbd06d9d854407cf2fe629d73c570ccc753a5
MD5 bc220c973b9c2e6ab4d8b773867dc93a
BLAKE2b-256 5962b10492cb399221be9cd1d46676e6b17e1a327ea5f750d0488f942693db09

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp313-cp313-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 f51b14cfc2e0724feff479d982dae9f6310f5597a92dc7dbfa32ef91434b67f2
MD5 24eda14bcfdbc90e1ea759fd9cee43f6
BLAKE2b-256 9490a27502cf25abc360da9e4a66fe25f4b970f54187536944e006b0efcaca2f

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 12da5217a8a7c21b0a4cd6543cc53238e018855387cfd0eb0893aca0034348aa
MD5 8a0ccd134d81c3bcf551e722de4d5eea
BLAKE2b-256 f8d0d674ea3b6550e8ae09b8e6243838c75f4e44cf11dde06fc22fab963833d1

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.5.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cheshm-2.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dc2fb668554078639d8867159351f8f082cab62379da780081b2dba80e676b20
MD5 f167372aa3153a3ad68cdfc0dd30802a
BLAKE2b-256 1ab1e35b282162c745fe35283f2c96ebe52885b31829eed1d7062ab0980827c3

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 502a6c858fcf9a42107ede422168c61a6886be5c0586c8291b156a2690ffc716
MD5 21196eec0edf687b9dc8f3adfa2a6453
BLAKE2b-256 b88d62d8a181b08f044da67e1692464491486a0b140137c394a6fe7ab730312c

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp312-cp312-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 5d71713d5bcff65faee97d22bb8ee70e8e3d99f644c669e314ab34259ada2f0d
MD5 76f7ecb470f0677c8debc77cfdc1d69f
BLAKE2b-256 176764f4473ecf6476975e20802e8111ee162c1430f20ca048e05e26eca94d11

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 61c68df31861ff16e724ebe81acce36caf3067b9e7e165d830bc12d204158fe6
MD5 c22e41ebe1585e5f0e23838e95a3911f
BLAKE2b-256 4080cc4127e8a513105748562a43995c08c5d028d50a51b389b3c90d3b419bb1

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.5.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cheshm-2.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8f08ae94d57fa729b577c258414bb54c8bf4a65a1e85752e069c855c2d6c0898
MD5 7ea8733c787f1e5265752abbb964fbdf
BLAKE2b-256 af20f4d2664a452222e35a2f1a7aff51d732f9bbd5224ef88eb349b088e89047

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d21e5c85d8e7000b8cbc116b91b3b8e56ad9cc76452fe448feb913f7f115c5ff
MD5 beb50ff59f027f882734115d6021c800
BLAKE2b-256 7eec3ca6413f656a3ea8a0ba3637d8761b3289d5cff955ebb498cb823cd74594

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp311-cp311-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 0a2e8e8e2965a4b9bd2d3ea92d1c5a996c531b096407017ef8c1fa5a3939a7cd
MD5 325b420002735987f26d6c9991df8571
BLAKE2b-256 f7d1c177bd641e6a9e7e2b1f6c87de614be75da4a0f30a1e51053d163a1168d0

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 754b06c201b3cf9e29509cfda26fea818aff6e2d8502fdb0d4f1f958f5aec764
MD5 b7ebc61000b61c9333c2721da6ab4c00
BLAKE2b-256 b96b079b46ce22b629331d74915fd3e027a6619fa07f785ef860da43b397a894

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: cheshm-2.5.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cheshm-2.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 01f697c2983d614adea5f29dd70b754928bc46378d647a93a6cc67d2a10983ab
MD5 d620965d64f22855402f7eed8945ad06
BLAKE2b-256 1fcee63d150dc8c3e92f0f3c368028d5402a67bac5899773dc497260735028f5

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0361a6e52e1495e9d11206baf8cd33e0934523ab52def0ad5f169735d93d9c45
MD5 8b1da4a81856050a0ed25ecc7d154ee3
BLAKE2b-256 7a56515997d5125c1d5ef61235f4385342e9b04b21de57ed3b5680fcc08f45c8

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp310-cp310-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 60f91ed9515ebd3b96386f8b150c1059e15e615177a843f35c74ac7a356d8a12
MD5 a87241c787b5f47588a4dcde3cf7b0a5
BLAKE2b-256 85ee1e13ba24e36b309399443002c7c871781be278ef0083ed4c5ff8da5c7e45

See more details on using hashes here.

File details

Details for the file cheshm-2.5.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for cheshm-2.5.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 391a90b2a8fff74c52d980d377b106182c3661c921271bbce8bfaae653b67f7c
MD5 97822cba815d52581964ac433522092c
BLAKE2b-256 cf585180407c22c7a9897047cc60a662d0ad35155782d72e3e94a181dbe423ad

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