Skip to content

kevinconka/nextcv

Repository files navigation

NextCV

Python's ease, C++'s speed. Finally. ⚑

License: Apache-2.0 Python 3.8+ C++17 Build Status


For those who want the full story, read the docs. For everyone else, here's the gist.


What is this? πŸ€”

It's a computer vision library. You write Python, because you're not a masochist. But when your code inevitably becomes a bottleneck, you need speed. That's where this library can help.

The philosophy is simple:

Write Python. When it's slow, make it fast with C++.


Does it actually work? πŸš€

Yes. Here's a Non-Maximum Suppression (NMS) benchmark. We pitted our C++ implementation against a standard NumPy version.

import time
import numpy as np
from nextcv.postprocessing import nms_cpp, nms_np

# A respectable amount of data
N = 10000
rng = np.random.default_rng(42)
bboxes = rng.uniform(0, 100, (N, 4)).astype(np.float32)
scores = rng.uniform(0.1, 1, N).astype(np.float32)

# Time the C++ version
start_time = time.perf_counter()
result_cpp = nms_cpp(bboxes, scores, 0.5)
cpp_time = time.perf_counter() - start_time

# Time the NumPy version
start_time = time.perf_counter()
result_np = nms_np(bboxes, scores, 0.5)
np_time = time.perf_counter() - start_time

print("NMS Timing Comparison:")
print(f"   Dataset: {len(bboxes)} bounding boxes")
print(f"   nms_cpp(): {len(result_cpp)} boxes kept in {cpp_time * 1000:.2f}ms")
print(f"   nms_np(): {len(result_np)} boxes kept in {np_time * 1000:.2f}ms")

Fingers' crossed, the C++ version is significantly faster. 🎯


How do I use it? πŸ› οΈ

Prerequisites

# Ubuntu/Debian
sudo apt-get install libeigen3-dev cmake

# MacOS
brew install eigen cmake

Installation πŸ“¦

pip install nextcv

# or from git
pip install git+https://github.com/kevinconka/nextcv.git

# uv
uv add nextcv

Check it's working βœ…

uv run python -c "import nextcv; print(nextcv.__version__)"

Building from source πŸ”¨

This project uses a dual-configuration approach to support both modern development and legacy compatibility:

  • Modern builds (Python 3.9+): Uses scikit-build-core with pyproject.toml
  • Legacy builds (Python 3.6...3.8): Uses scikit-build with pyproject.legacy.toml + setup.py

For development:

# create a virtual environment
python -m venv .venv
source .venv/bin/activate
pip install -e .

# or let uv handle it for you
uv sync

For legacy builds (Python 3.6...3.8):

# Copy legacy config and build
cp pyproject.legacy.toml pyproject.toml
pip install -e .

Contributing 🀝

If you think you can make this better, feel free. Just don't break anything.

  1. Fork it.

  2. Create a branch. (git checkout -b my-brilliant-idea)

  3. Install UV (if you don't have it yet).

    curl -LsSf https://astral.sh/uv/install.sh | sh
  4. Install C++ tools.

    # macOS
    brew install clang-format llvm
    # Add LLVM to PATH (add to ~/.zshrc or ~/.bash_profile)
    echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc
    
    # Ubuntu/Debian
    sudo apt-get install clang-format clang-tidy
  5. Set up the environment.

    uv sync
    uvx pre-commit install
  6. Write code. And tests. Don't forget the tests.

  7. Run the checks.

    uv run pytest
    uvx pre-commit run --all-files
  8. Open a pull request. Make it a good one.


That's it. Now you know. πŸŽ‰

About

NextCV πŸ‘οΈ an OpenCV-style library reimagined with modern tools.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors