Skip to content

Add apriltag in kornia-py#565

Merged
edgarriba merged 15 commits intomainfrom
as1100k/apriltag-py
Nov 30, 2025
Merged

Add apriltag in kornia-py#565
edgarriba merged 15 commits intomainfrom
as1100k/apriltag-py

Conversation

@AS1100K
Copy link
Copy Markdown
Member

@AS1100K AS1100K commented Nov 17, 2025

This pull request introduces AprilTag detection support to the Python bindings by adding a new kornia-apriltag crate, implementing Python wrappers for AprilTag-related types and functionality, and exposing them in the Python module. It also adds comprehensive tests for the new features.

AprilTag detection Python bindings:

  • Added the kornia-apriltag crate as a dependency in kornia-py/Cargo.toml to enable AprilTag functionality.
  • Implemented AprilTag Python bindings in kornia-py/src/apriltag.rs, including classes for configuration, decoding, tag families, and detection results. This provides a full API for AprilTag detection in Python.

Python module integration:

  • Registered all AprilTag classes and submodules in the Python module initialization in kornia-py/src/lib.rs, making them available under K.apriltag and K.apriltag.family. [1] [2]

Testing and CI:

  • Added a new test suite for AprilTag detection in kornia-py/tests/test_apriltag.py, covering tag family kinds, custom families, and actual detection from images.
  • Updated the GitHub Actions workflow to recursively fetch submodules, ensuring the test data for AprilTag images is available during CI runs. (.github/workflows/python_test.yml)

Adjust tests to call TF.all(); import Py for Python object handling and
remove the module-level function registration in the apriltag family
module.
Introduce PyTagFamily, PyQuickDecode and PySharpeningBuffer and
implement into_family_kind to create TagFamilyKind::Custom from a
PyTagFamily. Update TagFamilyKind.name to return the custom family's
name and add tests covering the new conversion.
Expose decoder and related types to Python: PyDecodeTagsConfig,
PyFitQuadConfig, PyAprilTagDecoder, PyDetection and PyQuad. Add
conversions between Rust and Python tag family types and map decoder
errors to PyException.
Comment thread kornia-py/src/apriltag.rs Outdated
@edgarriba
Copy link
Copy Markdown
Member

@haixuanTao are you guys interested in a dora node including this ? this is a quite crucial part for camera calibration

@haixuanTao
Copy link
Copy Markdown

@haixuanTao are you guys interested in a dora node including this ? this is a quite crucial part for camera calibration

I think it would definitely be interesting but I'm not familiar enough with the work to be able to give a precise feedback. And so we can wait for now if it requires a lot of work

@cjpurackal cjpurackal marked this pull request as ready for review November 20, 2025 11:49
@cjpurackal
Copy link
Copy Markdown
Member

@haixuanTao are you guys interested in a dora node including this ? this is a quite crucial part for camera calibration

I think it would definitely be interesting but I'm not familiar enough with the work to be able to give a precise feedback. And so we can wait for now if it requires a lot of work

We can try and come up with some demos with this and dora if you're interested :)
More info on apriltags: https://april.eecs.umich.edu/software/apriltag

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread kornia-py/src/apriltag.rs Outdated
Copy link
Copy Markdown
Member

@edgarriba edgarriba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are in the latest main ? weird that the C++ binding s are breaking while in main seems fine

Comment thread kornia-py/src/apriltag.rs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive AprilTag detection support to the kornia-py Python bindings by creating new Rust-Python wrappers for the kornia-apriltag crate. The implementation provides a complete API for configuring tag families, detecting tags in images, and accessing detection results including quad corners and homographies.

Key Changes:

  • Added Python bindings for AprilTag detection with support for 9 predefined tag families and custom tag definitions
  • Implemented configuration classes for detection parameters (decode config, quad fitting)
  • Added structured detection results with tag metadata and geometric information
  • Updated CI to recursively fetch test data submodules

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
kornia-py/Cargo.toml Adds kornia-apriltag crate dependency
kornia-py/src/lib.rs Registers AprilTag module and submodules in Python package
kornia-py/src/apriltag.rs Implements Python bindings for AprilTag detection classes and family management
kornia-py/tests/test_apriltag.py Adds comprehensive tests for tag families and detection functionality
.github/workflows/python_test.yml Enables recursive submodule checkout for test data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kornia-py/src/apriltag.rs
Comment thread kornia-py/src/apriltag.rs
Comment thread kornia-py/src/apriltag.rs
Comment thread kornia-py/src/apriltag.rs Outdated
Comment thread kornia-py/src/apriltag.rs
Comment thread kornia-py/src/apriltag.rs
def test_all_tag_family_kind():
all = TagFamilyKind.all()
all_expected = [
TagFamilyKind("tag16_h5"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could we have exposed as normal python enums ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem would arise with data carrying enum variants i.e. ::Custom(...). The python doesn't support it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@edgarriba edgarriba merged commit 66a24e5 into main Nov 30, 2025
19 checks passed
@edgarriba edgarriba deleted the as1100k/apriltag-py branch November 30, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants