RepoPilotOpen in app →

opencv/opencv_contrib

Repository for OpenCV's extra modules

Healthy

Healthy across the board

Use as dependencyHealthy

Permissive license, no critical CVEs, actively maintained — safe to depend on.

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • Last commit 2d ago
  • 30+ active contributors
  • Apache-2.0 licensed
Show 3 more →
  • CI configured
  • Tests present
  • Concentrated ownership — top contributor handles 54% of recent commits

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Healthy" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Healthy
[![RepoPilot: Healthy](https://repopilot.app/api/badge/opencv/opencv_contrib)](https://repopilot.app/r/opencv/opencv_contrib)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/opencv/opencv_contrib on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: opencv/opencv_contrib

Generated by RepoPilot · 2026-05-09 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/opencv/opencv_contrib shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

GO — Healthy across the board

  • Last commit 2d ago
  • 30+ active contributors
  • Apache-2.0 licensed
  • CI configured
  • Tests present
  • ⚠ Concentrated ownership — top contributor handles 54% of recent commits

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live opencv/opencv_contrib repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/opencv/opencv_contrib.

What it runs against: a local clone of opencv/opencv_contrib — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in opencv/opencv_contrib | Confirms the artifact applies here, not a fork | | 2 | License is still Apache-2.0 | Catches relicense before you depend on it | | 3 | Default branch 4.x exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 32 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>opencv/opencv_contrib</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of opencv/opencv_contrib. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/opencv/opencv_contrib.git
#   cd opencv_contrib
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of opencv/opencv_contrib and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "opencv/opencv_contrib(\\.git)?\\b" \\
  && ok "origin remote is opencv/opencv_contrib" \\
  || miss "origin remote is not opencv/opencv_contrib (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(Apache-2\\.0)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"Apache-2\\.0\"" package.json 2>/dev/null) \\
  && ok "license is Apache-2.0" \\
  || miss "license drift — was Apache-2.0 at generation time"

# 3. Default branch
git rev-parse --verify 4.x >/dev/null 2>&1 \\
  && ok "default branch 4.x exists" \\
  || miss "default branch 4.x no longer exists"

# 4. Critical files exist
test -f "modules/README.md" \\
  && ok "modules/README.md" \\
  || miss "missing critical file: modules/README.md"
test -f "README.md" \\
  && ok "README.md" \\
  || miss "missing critical file: README.md"
test -f ".github/workflows/PR-4.x.yaml" \\
  && ok ".github/workflows/PR-4.x.yaml" \\
  || miss "missing critical file: .github/workflows/PR-4.x.yaml"
test -f "CONTRIBUTING.md" \\
  && ok "CONTRIBUTING.md" \\
  || miss "missing critical file: CONTRIBUTING.md"
test -f "modules/aruco/CMakeLists.txt" \\
  && ok "modules/aruco/CMakeLists.txt" \\
  || miss "missing critical file: modules/aruco/CMakeLists.txt"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 32 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~2d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/opencv/opencv_contrib"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

opencv_contrib is a repository hosting OpenCV's experimental and community-contributed modules that lack stable APIs or sufficient maturity for the core library. It includes advanced algorithms for bioinspired vision (retina models), extended image processing (ximgproc), visual debugging (cvv), and aruco marker detection—letting contributors iterate rapidly without destabilizing OpenCV's binary compatibility guarantee. Modular monorepo: modules/ directory contains 40+ independent modules (bioinspired/, cvv/, ximgproc/, aruco/, etc.), each with its own CMakeLists.txt, source code structure, and samples/. doc/tutorials/ holds per-module documentation. Build system is entirely CMake-driven; SWIG bindings provide Python/Java/MATLAB wrappers. No single entry point—integration happens at build time via OPENCV_EXTRA_MODULES_PATH injection into core OpenCV build.

👥Who it's for

Computer vision researchers and engineers building bleeding-edge applications (real-time retina simulation, advanced image filtering, marker-based AR) who need cutting-edge algorithms before they mature into the official OpenCV release, plus OpenCV contributors looking to prototype new modules under a lighter stability burden.

🌱Maturity & risk

Actively developed but inherently experimental: the repo exists precisely because modules here are unstable and under-tested compared to core OpenCV. CI present (.github/workflows/PR-4.x.yaml suggests GitHub Actions), but by design this is a staging ground—modules graduate to core when they mature. The split repo model means expect API volatility and sparse documentation relative to main OpenCV.

High volatility by design: modules have no stability guarantees and APIs change frequently during development. Dependency on core OpenCV version alignment (build requires passing OPENCV_EXTRA_MODULES_PATH to cmake) creates version-lock risk. The repo's purpose is to house unstable code, so production use of any single contrib module carries architectural risk until it graduates to core. No comprehensive test suite guarantees across all modules.

Active areas of work

Ongoing development tracked via .github/workflows/PR-4.x.yaml (PR gating on main branch). Recent activity evident from CONTRIBUTING.md and PULL_REQUEST_TEMPLATE.md (standardized review process). The repo maintains parallel development with core OpenCV; modules are continuously matured, refactored, or deprecated based on adoption. No specific version roadmap visible in file list, but workflow CI suggests active pull request iteration.

🚀Get running

git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
# Then integrate into OpenCV build:
cd <opencv_source_directory> && mkdir build && cd build
cmake -DOPENCV_EXTRA_MODULES_PATH=<path_to_opencv_contrib>/modules -DBUILD_EXAMPLES=ON ..
make -j$(nproc)
make install

No standalone build; modules require core OpenCV present.

Daily commands: No runtime server. To use a module: compile with cmake -DOPENCV_EXTRA_MODULES_PATH=..., then link in your C++ code with -lopencv_<modulename> (e.g., -lopencv_aruco). Python: import cv2.aruco after installation. Samples in each module's samples/ directory demonstrate usage (compile with -DBUILD_EXAMPLES=ON).

🗺️Map of the codebase

  • modules/README.md — Central index explaining the module architecture and how contrib modules are organized—essential reading for understanding the repo's philosophy.
  • README.md — Build instructions and repository charter explaining when modules move from contrib to core OpenCV—defines the project's maturity model.
  • .github/workflows/PR-4.x.yaml — CI/CD pipeline definition for the 4.x branch—controls how all PRs are validated and merged.
  • CONTRIBUTING.md — Contribution guidelines and code standards—mandatory reading for all new contributors to this repository.
  • modules/aruco/CMakeLists.txt — Example module build configuration showing the template pattern all contrib modules must follow.
  • modules/alphamat/include/opencv2/alphamat.hpp — Canonical public API header example demonstrating how contrib modules expose their interface to users.
  • .editorconfig — Code style and formatting standards enforced across all modules in the repository.

🛠️How to make changes

Add a New Contrib Module

  1. Create module directory under modules/ following the standard layout: include/, src/, samples/, doc/, tutorials/ (modules/alphamat)
  2. Create CMakeLists.txt at module root defining sources, dependencies, and install rules (modules/alphamat/CMakeLists.txt)
  3. Write public header file in include/opencv2/{modulename}/ with C++ API declarations (modules/alphamat/include/opencv2/alphamat.hpp)
  4. Implement algorithms in src/ directory, use precomp.hpp for common includes (modules/alphamat/src/precomp.hpp)
  5. Add sample program in samples/ demonstrating the module's core functionality (modules/alphamat/samples/information_flow_matting.cpp)
  6. Write markdown tutorial in modules/{modulename}/tutorials/ with theory and usage examples (modules/alphamat/tutorials/alphamat_tutorial.markdown)
  7. Create doc/{tutorials}/{modulename} with images and detailed walkthrough (doc/tutorials/bioinspired)

Integrate Module into Build System

  1. Add module directory path to cmake invocation via -DOPENCV_EXTRA_MODULES_PATH (README.md)
  2. Ensure CMakeLists.txt follows OpenCV conventions: find_package(OpenCV), set(SOURCE_FILES), add_library() (modules/aruco/CMakeLists.txt)
  3. Verify module builds against the default 4.x branch by checking CI pipeline (.github/workflows/PR-4.x.yaml)

Promote Module from Contrib to Core OpenCV

  1. Ensure module passes all tests and has comprehensive documentation in doc/tutorials (modules/README.md)
  2. Get API review and stability approval as described in CONTRIBUTING.md (CONTRIBUTING.md)
  3. Once approved, module is moved from opencv_contrib to opencv main repository on a new release (README.md)

Add Dependencies or Utilities to Module

  1. For header-only external libraries, place in src/3rdparty/ following the nanoflann pattern (modules/alphamat/src/3rdparty/nanoflann.hpp)
  2. Create adaptor headers to integrate 3rdparty code with module implementation (modules/alphamat/src/3rdparty/KDTreeVectorOfVectorsAdaptor.h)
  3. Reference 3rdparty includes from implementation files with proper copyright attribution (modules/alphamat/src/local_info.cpp)

🔧Why these technologies

  • C++ with OpenCV core dependency — Contrib modules extend OpenCV's image processing capabilities and must maintain ABI compatibility with the main library
  • CMake build system — Matches OpenCV's primary build tool; allows modular compilation and discovery via -DOPENCV_EXTRA_MODULES_PATH
  • GitHub Actions CI/CD (PR-4.x.yaml) — Automated validation of every PR against the 4.x branch ensures modules don't break existing functionality before merge
  • Markdown documentation in doc/tutorials/ — Provides human-readable algorithm explanations and usage patterns alongside API headers
  • Header-only 3rdparty libraries (nanoflann, KDTree) — Reduces external dependencies and simplifies distribution; spatial indexing is needed by multiple modules

⚖️Trade-offs already made

  • Modules stay in contrib until mature and stable rather than in core OpenCV

    • Why: Core OpenCV maintains strict binary compatibility and support guarantees
    • Consequence: Contrib modules can evolve rapidly but users accept API instability; successful modules eventually graduate to core
  • Each module is self-contained with its own CMakeLists.txt, include/, src/, samples/, doc/

    • Why: Enables independent development and reduces cross-module coupling
    • Consequence: Slight duplication of boilerplate (CMake patterns, header guards) but greater modularity and testability
  • Public API defined in include/opencv2/{modulename}/ headers only

    • Why: Enforces clean separation between internal implementation and user-facing API
    • Consequence: Implementation details in src/ are never exposed; easier refactoring without breaking users
  • CI only validates compilation and basic tests on PR; does not require ABI stability tests

    • Why: Contrib is explicitly unstable; full compatibility testing would slow down iteration
    • Consequence: Breaking changes are allowed; users must explicitly opt-in to contrib and accept this risk

🚫Non-goals (don't propose these)

  • Not a standalone computer vision library—always requires OpenCV core to build and run
  • Does not provide real-time performance guarantees—modules prioritize correctness and flexibility over speed
  • No backwards compatibility promise—API and behavior can change between 4.x releases

🪤Traps & gotchas

  1. Version lock: Modules compiled against specific OpenCV core version; no guarantee of forward/backward compatibility. Always match contrib checkout to core version. 2. Build dependency: Modules do NOT build standalone; require full core OpenCV source and build environment. 3. API churn: No stability guarantee—code targeting contrib modules may break on next pull. 4. Documentation scatter: Some modules (e.g., bioinspired/retina) heavily documented, others sparse; check doc/tutorials/ before assuming docs exist. 5. SWIG bindings lag: Python/Java bindings may be missing for newer modules; check module's swig/ directory for coverage.

🏗️Architecture

💡Concepts to learn

  • Retina (Lateral Geniculate Nucleus) Model — opencv_contrib's bioinspired module implements biological retina simulation; understanding magnocellular (motion) and parvocellular (detail) pathways is essential to using the retina preprocessing correctly for motion detection or low-light enhancement.
  • Structured Edge Detection — ximgproc module includes structured edge detection algorithms; used throughout for edge-aware filtering and image segmentation in contributed modules.
  • ArUco Marker Detection (Augmented Reality Quick Response) — aruco module is one of the most popular opencv_contrib features, enabling fiducial marker-based pose estimation for AR applications; core to many real-world deployments.
  • SWIG (Simplified Wrapper and Interface Generator) — opencv_contrib uses SWIG to auto-generate Python, Java, and MATLAB bindings from C++ headers; understanding .i file syntax is required to expose new modules to non-C++ users.
  • CMake Module Discovery & FIND_PACKAGE — Each contrib module has CMakeLists.txt with custom find_package() rules; understanding how CMake discovers and links modules is critical for integrating contrib into your build pipeline without breaking version locks.
  • Binary Compatibility (ABI Stability) — opencv_contrib exists to avoid breaking OpenCV's ABI guarantees in core; understanding why modules live here (unstable API) vs. core (stable) informs expectations about deprecation and API churn.
  • Graph-Based Image Segmentation — ximgproc and graph-based segmentation algorithms in contrib modules use edge-weighted graphs; understanding spectral methods and superpixel generation is key to image partitioning tasks.
  • opencv/opencv — Core OpenCV repository; opencv_contrib modules are built alongside and integrate with this. Required dependency for building contrib.
  • opencv/opencv_python — Official Python bindings for OpenCV; contrib modules expose Python APIs through the same build pipeline and documentation.
  • opencv/opencv_android — Android-specific OpenCV build; some contrib modules (e.g., aruco) are used in mobile computer vision and compiled for this platform.
  • opencv/opencv_attic — Historical repository for deprecated OpenCV modules; provides precedent for module lifecycle (unstable → stable → deprecated or graduated to core).
  • detectron2/detectron2 — Deep learning-based detection framework; often used downstream of opencv_contrib modules like aruco for robust marker-based AR pipelines.

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add unit tests for alphamat module's information_flow_matting sample

The alphamat module exists with a sample implementation (modules/alphamat/samples/information_flow_matting.cpp) but there are no corresponding unit tests in the repository. Adding comprehensive tests would validate the alpha matting algorithm, ensure compatibility across platforms, and prevent regressions. This is particularly important for a contrib module that may eventually graduate to the main OpenCV repo.

  • [ ] Create modules/alphamat/test directory if it doesn't exist
  • [ ] Write unit tests in modules/alphamat/test/test_alphamat.cpp covering core functionality from information_flow_matting.cpp
  • [ ] Add test image fixtures (reference outputs) to modules/alphamat/test/data/
  • [ ] Integrate tests into modules/alphamat/CMakeLists.txt
  • [ ] Verify tests run in the existing CI pipeline (PR-4.x.yaml)

Create comprehensive tutorial documentation for alphamat module

While doc/tutorials exists for other modules (bioinspired, cvv, ximgproc), there is no corresponding tutorial directory for alphamat despite it being a featured module. Creating a tutorial with markdown documentation and sample images would improve discoverability and usability for contributors and end-users.

  • [ ] Create doc/tutorials/alphamat/ directory structure
  • [ ] Create doc/tutorials/alphamat/table_of_content_alphamat/ with overview and images/
  • [ ] Write doc/tutorials/alphamat/alpha_matting_tutorial/ with detailed markdown explaining the algorithm and use cases
  • [ ] Add sample input/output images to doc/tutorials/alphamat/alpha_matting_tutorial/images/
  • [ ] Link the new tutorial in the main documentation index

Add Python binding tests for contrib modules in CI

The PR-4.x.yaml workflow exists but there's no evidence of Python binding tests for contrib modules. Given that many users interact with OpenCV via Python, adding CI checks to ensure Python bindings work correctly for modules like alphamat would catch binding generation issues early and improve overall quality.

  • [ ] Review .github/workflows/PR-4.x.yaml for current Python testing coverage
  • [ ] Create a new test job that compiles OpenCV with contrib modules and Python bindings enabled
  • [ ] Add Python test scripts (modules/<module_name>/test/test_<module_name>_python.py) for key modules like alphamat and ximgproc
  • [ ] Integrate Python binding tests into the CI workflow to run alongside C++ tests
  • [ ] Document the testing process in CONTRIBUTING.md

🌿Good first issues

  • Add missing doc/tutorials/ entries for modules without tutorials (e.g., check which modules in modules/ lack corresponding doc/tutorials/<modulename> folders) and create .rst documentation files following the pattern used in bioinspired/ and ximgproc/.
  • Audit and complete Python SWIG bindings: scan modules/ for .i (SWIG) files; identify modules with C++ .hpp headers but no corresponding SWIG stubs, then generate .i binding files using existing module patterns.
  • Extend test coverage: identify modules in modules/ with minimal or no test/ subdirectories (compare against aruco or bioinspired which have rich test suites), then write basic unit tests for core functions in those modules' test/ folders.

Top contributors

Click to expand

📝Recent commits

Click to expand
  • 1d28ba6 — Merge pull request #4084 from 727724euit202-hub:fix/cvv-automoc-opencv-world (727724euit202-hub)
  • 464bed7 — Merge pull request #4105 from Nikhil-jaiswal007:fix/reg-python-sample (asmorkalov)
  • cf50aed — Merge pull request #4114 from vrabaud:c_headers (asmorkalov)
  • e334508 — Do not use CV_Error(int (vrabaud)
  • 7ab3e17 — reg: fix broken Python sample - use dot notation and fix segfault (Nikhil-jaiswal007)
  • 115e941 — Merge pull request #4081 from krishnavasnani07:4.x (asmorkalov)
  • d568359 — Merge pull request #4098 from asmorkalov:as/cuda_warn_fix (asmorkalov)
  • 2ac61cd — Merge pull request #4090 from troelsy:4.x (asmorkalov)
  • 86ff885 — Fixed build warnings in CUDA. (asmorkalov)
  • f2854f4 — Merge pull request #4097 from JohnZhang-Tetra:use_different_namespace_for_cuda_13.2 (JohnZhang-Tetra)

🔒Security observations

The opencv_contrib repository demonstrates reasonable security baseline as a community-driven C++ project. Key concerns are around third-party dependency management, lack of formal security policy, and absence of explicit security contribution guidelines. The codebase appears to be primarily documentation, images, and source code without obvious injection vulnerabilities, hardcoded credentials, or misconfigurations in the visible file structure. However, the embedded third-party libraries require regular auditing. The project would benefit from establishing a formal security.md policy and version-pinning strategy for dependencies. No critical vulnerabilities were identified in the provided file structure analysis.

  • Medium · Third-party dependencies without version pinning — modules/alphamat/src/3rdparty/. The repository includes third-party libraries (nanoflann.hpp, KDTreeVectorOfVectorsAdaptor.h) in modules/alphamat/src/3rdparty without clear version information or dependency tracking. These embedded dependencies may contain unpatched vulnerabilities and lack proper version control. Fix: Maintain a DEPENDENCIES.md or use a package manager to track third-party library versions. Regularly audit and update embedded third-party code. Consider using git submodules or package managers instead of vendoring code.
  • Low · Missing security documentation — Repository root. The repository lacks a SECURITY.md file or security policy document that would help contributors and users understand how to report security vulnerabilities responsibly. Fix: Create a SECURITY.md file documenting the security disclosure process and vulnerability reporting guidelines, following the GitHub security advisory format.
  • Low · CI/CD workflow security consideration — .github/workflows/PR-4.x.yaml. The PR workflow file (.github/workflows/PR-4.x.yaml) exists but contents are not provided for review. GitHub Actions workflows can pose security risks if they use untrusted actions or have overly permissive permissions. Fix: Review workflow file to ensure: 1) All actions are from trusted sources, 2) Permissions are minimized (use 'permissions: read-only' by default), 3) No secrets are logged, 4) Branch protection rules are enforced.
  • Low · No BUILD.md or compilation security guidelines — CONTRIBUTING.md. While CONTRIBUTING.md exists, there are no explicit security guidelines for contributors regarding secure coding practices or security testing requirements for new modules. Fix: Add security section to CONTRIBUTING.md covering: secure coding practices, mandatory security testing, input validation requirements, and buffer overflow prevention for C++ code.

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Healthy signals · opencv/opencv_contrib — RepoPilot