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.2.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.2.0-cp313-cp313-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.13Windows x86-64

cheshm-2.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cheshm-2.2.0-cp313-cp313-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.13macOS 15.0+ x86-64

cheshm-2.2.0-cp313-cp313-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

cheshm-2.2.0-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

cheshm-2.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cheshm-2.2.0-cp312-cp312-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.12macOS 15.0+ x86-64

cheshm-2.2.0-cp312-cp312-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

cheshm-2.2.0-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

cheshm-2.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cheshm-2.2.0-cp311-cp311-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.11macOS 15.0+ x86-64

cheshm-2.2.0-cp311-cp311-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

cheshm-2.2.0-cp310-cp310-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.10Windows x86-64

cheshm-2.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cheshm-2.2.0-cp310-cp310-macosx_15_0_x86_64.whl (33.3 MB view details)

Uploaded CPython 3.10macOS 15.0+ x86-64

cheshm-2.2.0-cp310-cp310-macosx_14_0_arm64.whl (15.8 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: cheshm-2.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 a1fd898b5ed1e63d3ce6255f1beff818823a973e617725b5b136526ee2e76c3b
MD5 c52a42578fa02707676df2223f2672e8
BLAKE2b-256 44f0211f38d5d62c082732e643106585b98cd16befbce4cad67813b378d14b94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.7 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.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6cd32c38a15fccc838231cfef010f88a8b67022d1717ddaec88c83454c315ba4
MD5 bb9d59866aedf22e9947ff9b42cc2416
BLAKE2b-256 040e4950b5e74369fe31b64e50da8047f9bdb0f6bc0feb2158bcf919e3e455e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 7dc63fde3306a1cdf6ea9123ab78b4e8a0e5f1496fa2029469e7cd5e55b6ed15
MD5 d09b9c20296b3c55633f92e8164c41e9
BLAKE2b-256 3fa1aa0f5ef8b69f86225e9be51a7092172ce0603282eb31409835ea7db8db19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp313-cp313-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 16b344bc347540fb81d796ed2146f199dcca494f670520d8949dba12bbd294bb
MD5 85b3cce6ed57a2162cdc2ec17ac20f3a
BLAKE2b-256 f07a062ea21862aedc3880ed223a4c97dc1909390a4ff2a1011f96b64c199148

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6766a52cb93e0bd0a0369d3810880b9e9b60d9c7cb94a96a0306fe453814841e
MD5 9e759e0e72df51f7f2fcc60f02abad00
BLAKE2b-256 b360d16057280b8e4dd32b6a94b8d8d862f87c7f908010b3a13042d107d53c6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.7 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.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6afd78c83e99e41e759e6f6170cef72071460846bf5fb683a7d5c8ab72e00645
MD5 c9d0f28dbaa192b240eedccd380b6d58
BLAKE2b-256 5aac363adb4c6795261feb5d09474ca5430d30be96c1918c27399b96742a60b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6d6cac1b6692fbe43b626d42a976c302d01fed815e3b6eccdebffcbe0c47d7c3
MD5 6f2e5fc251e25c05fa30254776ae788c
BLAKE2b-256 c41ed5549252fbd4c93a2038dd84bbaae8a1aa383c524901304d94cdd102de23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp312-cp312-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 ec441f549ab20d2df2fd0909cf6a577119b20207993806994c06c5720c6ee077
MD5 bd94e0b1fb4b7990ec5a0716d45b5588
BLAKE2b-256 a14649f1b687d8155f4fa26b3b62aa1fbc5875518f1ccf424a72ae9b68a7907e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0dfc79e32c7a9d82cec3df74cc063dd3c0b583ae0f7721bca717b2bdc1a92be4
MD5 9b57ab9a2f70320fd894a0f2c0b65d8d
BLAKE2b-256 a5279555660dbdf8c505c647cd7b25a10faec67bf7a457f191af454bf888bc82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.7 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.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 970091d92d0516c65346e44c901bac9a1d4e7ce09afda389ec2e1593a5ffb6d4
MD5 14c5c985c8a2a72b16b3fc6cb7808109
BLAKE2b-256 f3269637112ab29c371fadf8d58b71cf68f76a867ff303ab474383aab5743929

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 3fc4ce6101bf53f87350f2b2227827161b7a94fb26f0f49762072bc9f0617c5e
MD5 0f0bd6ac3d6677637dd2cee3cde86e71
BLAKE2b-256 b41ccffb97bd3162e33de7a9244cbf79e3671bf28ee41fbfa885f635ba616de7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp311-cp311-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 acae0f5f1f330cbb5984881a1828c629194c63e56caceb67c6ed2dcdca66c5d3
MD5 7a255284a02039939eb4da3c011f0e06
BLAKE2b-256 7a07a64b5ef628be5f5bab256f8c34dfc72b6047c2032d336621dde7670e7628

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3709197a3eebc37f692241c55c60f7396283067e9b262bfa734ac01daa72447a
MD5 04ed057aa2a64ffd7b2277d547c09b8c
BLAKE2b-256 7bbf6a52cf4d3d9a96465018ba5534645a9effe486ac15bf3587e8e5d3d0cac2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cheshm-2.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.7 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.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7414bc2f157464fc53ac22ec1c5d5bfd89811ffd69d26fd3e4e8e0d46ff8f004
MD5 e78da4c47dfa59fb8797e7b4c4f3d583
BLAKE2b-256 266977ff2b9dcecf199833e0eff0e52d14d9c781a7a9b01ab13e9854095e42aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 3e47361fc2d1f7c58f3c1742f597d70139ee9fafe2098d4ad5b7777371e33847
MD5 a3bede02d068928e63513fc267bfb6c2
BLAKE2b-256 2b66bbcbafe8677adafa2e43b6109d6603c4e80ae321e0c45f1f085badb701b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp310-cp310-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 6918849bc9a8416054aa18e9b547f2bdd6acaf35b71124371fb1a8c9cf0efb13
MD5 c43f07144e8b4b1f34f385eedff4f16e
BLAKE2b-256 0b4de3aefce93cec9865fa4f2161a87e88f0daa7ede170ed59d6d279d0b060f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cheshm-2.2.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 66bd32f512d3e7f2c9365344bea3078daace450dacbf3041153402a5127c7e2d
MD5 bc16d0f69eb8cbca6e66ea2cd916d2de
BLAKE2b-256 949b2f7fb3ef37bb09b8a5dc9bcc5a2583ec363d2bdcaef79ec39ab3e1b32de5

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