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.0.1.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.0.1-cp313-cp313-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.13Windows x86-64

cheshm-2.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cheshm-2.0.1-cp313-cp313-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

cheshm-2.0.1-cp313-cp313-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

cheshm-2.0.1-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

cheshm-2.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cheshm-2.0.1-cp312-cp312-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

cheshm-2.0.1-cp312-cp312-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

cheshm-2.0.1-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

cheshm-2.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cheshm-2.0.1-cp311-cp311-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

cheshm-2.0.1-cp311-cp311-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

cheshm-2.0.1-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

cheshm-2.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cheshm-2.0.1-cp310-cp310-macosx_15_0_x86_64.whl (33.2 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.0.1-cp310-cp310-macosx_14_0_arm64.whl (15.7 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: cheshm-2.0.1.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.0.1.tar.gz
Algorithm Hash digest
SHA256 c315b0f1a1dfb97a047c6e74295bc265cb456008e9307dcc0f8b3e772ba0d2a0
MD5 29f6aeb67d0384add11ff98935c8b0ac
BLAKE2b-256 9e2c13aa9fdd1b521c8e096a7c5cc8a94e0f9345e7ebf945d16d36e14c9f79f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.0.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f0283a2ce137f34932919d6d7b2a4fdcafc3df505c895b82bcce69dbd7dfe9ec
MD5 83820642d20bfd303a4884f43e62011c
BLAKE2b-256 bb8b0b72b1d4457cb250cf911de9c4914eb7c1f5ca29f85c6b1f0d3587e025e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 89c7e009ad6f06eef37f403fa7c7c8cde8b445a6807c24773da391fe358e4d84
MD5 420b3f70ae220eae5438453ecc2ecce0
BLAKE2b-256 88f6a07d6ebf251843b8b8b349b511a090bd38161aa129a9e0b18be66bd3e590

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 d1aa79c1a74e59d59e455266f21c29979e0a02a264a427e5c1d1c8a650b3b3db
MD5 0f13bb68513e126f69882c9b96c77618
BLAKE2b-256 ff3c51581257c28a3b13c20bee4f27f6a1306fc07258814f6a19380837a09a24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 29a89416090bf99e8e0e6cf4fcc578a797decdeff2df6c8e9e1c42266d827980
MD5 d0f017a2fd6cf8024aadb82c0d203035
BLAKE2b-256 f7194fc200e7af635c9768ca4f05a35887f51b49bdf479cc48ac1ab30311f378

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0094c872e2840a2b7225de5d44bbc5c43d2c7241065d34940e03af25e6b5191f
MD5 98430f057e30f8c8cc16a3c7d301714b
BLAKE2b-256 3c1afa12217ef34807890400a82cc82f54252fb0a11b007480f37507399df2b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0859c41373051c979c5fc47a83bb5d2fd853597b5c0bdde9e483991e5ee3070f
MD5 dc07ce6cd64e69e65adb673bae328f5d
BLAKE2b-256 3362f0a4e64ec7d9a39f6c0771fa361d479783453950b223f31cd2597e66326d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 ad2ff610c2a17473982a9b36b41dd7a837833c7b1647294cadbf0e956efd0e6c
MD5 b0b7e61c0381400b6146b73b6b999925
BLAKE2b-256 c13749521956ce42db56f16ede669e895198535ac1a0ac67f082a5a2127f4020

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 39b24879feadced2e09aeaab59521a1c3f626cc91e6ff9bc736647d727c9d1f3
MD5 cf459550c90e2ca854cb56b1ac402d06
BLAKE2b-256 c821e02914add5aad96ab2807eb4077599481a7b9972289c4e0bfd127bba5cc5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.0.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 860ec7000774918b17203c7bce4aa68490f93c14c1b8683eb0b03889be5042e8
MD5 027fc9c4f1d711857bc23be9ea414005
BLAKE2b-256 f293a0f84e69106ffaa23588da678c7f650836a248d02a8c76bdaca9beaebc40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8104f7270d0ebd2fce21a60285001fe33ae1ae4c69346cf5456a3f1265f870ea
MD5 00d185ad1eb9c044528ac5c1271d7274
BLAKE2b-256 1ef29d1dff51d0363ce371034a197f28bfe26e4a170f1fb6717316dc3d8eb8d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 8f9e81ad070b59d5c9e45346ec5bffb81e611b8e330d57ff5a49b6a2b2c1140d
MD5 30f606af09750da714f590d1533b8e70
BLAKE2b-256 d0d6b07d755e42018c1dc8c215a73a34cd341aadfab2d16e19b63d8f49cfae3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8de3945d8c7cb2818a3b199ddd0d4a3784ac56881bee90efbe1d9bc57bd3fb38
MD5 4bc07315c77fca335913243d08972a5a
BLAKE2b-256 f1c81ed64abc30753b055b2644762cc21ed56a557a163e5262ad475d6d748f91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.0.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.6 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.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 87d4e55a62c9aee1bb6083113884e313fe045f854d6fef39c964e90d452b36f7
MD5 4b31497390dded4cec2d13a80751d064
BLAKE2b-256 f02ce561a8b5538132197e19540c8a3d843adda535c5fe08ec2c52d8208c88eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 87e4f2c4b49c7b0b858a7aeed1eaa0d2e92e53a9ab141d7c02e38bab2910b84b
MD5 f5da28a85ed8f32d62f44f2f3af256ba
BLAKE2b-256 2270c9043ff0ece7343da11ec0010b237b4cfce71d62805fa0126c703e4b3013

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 0943fec39f1480c9f8b4653ece300b4dacef054447da796480c8dffd69d0abd1
MD5 8cec22eb44b43fe47539921d47bcc825
BLAKE2b-256 5f93dec3052324c83db9ac4d7776e9a63cb6c3d06c6f97034acbfd344f68b5a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.0.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 408e845a5b80fb65d69c6d47d3bb4c718c1574de1e0eb04c3650e5ed26c9a8b6
MD5 8ad4a758496e78330ba94c30df7e67c9
BLAKE2b-256 b66fa3db3e25cb893f4e7524fc9df6a4e2589f5a6d0ac4e12ab17d3ee686c132

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