Contributing to pixpick
Welcome! We are excited that you are interested in contributing to pixpick. Whether you are fixing a bug, improving documentation, or adding a new visual selector, your contributions help make interactive computer vision workflows faster and easier for everyone.
π Quickstart Development Guide
Follow these minimal architecture rules when extending pixpick:
Adding a New Selector Type (e.g. Line, Point)
- Core Data Structure: Add a point or geometry dataclass to
core/<type>.pywith necessary properties (e.g., coordinate exports like.xyxy,.sam()) and persistence methods (save(),load()). - Backend Engine: Add
select_<type>()toBaseBackendand implement its interactive drawing behavior inCV2Backend. - Selector Interface: Create
selectors/<type>_picker.pyimplementingTypeSelector. - Top-Level API: Export the selector helper function (e.g.,
pixpick.point()) in__init__.py.
Note: No other foundational files should require changes.
Adding Properties or Persistence Methods
Add properties or serialization methods directly to the targeted target class inside core/<class>.py:
# Example in core/box.py
@property
def xyxy(self) -> list[int]:
"""[x1, y1, x2, y2] β absolute pixels for each box in boxes."""
return self.boxes
π Reporting Bugs & Opening Issues
Before creating a new issue, please search existing GitHub Issues to verify it hasn't already been reported.
When opening an issue, please include:
- Clear Description: A short title and detailed description of the bug or feature request.
- Minimum Reproducible Example: A concise Python code snippet that reproduces the problem.
- Environment Details: Your OS, Python version, OpenCV version, and hardware (if GPU/display windowing issues occur).
- Expected vs. Actual Behavior: What you expected to happen versus what actually occurred (including tracebacks/error logs).
π€ How to Submit a Pull Request
- Fork & Branch: Fork the repository and create a descriptive feature branch (
git checkout -b feat-line-selector). - Keep PRs Scope-Focused: Small, modular PRs that address a single bug or component are reviewed and merged much faster.
- Test Local Changes: Ensure your changes run cleanly without breaking existing OpenCV interactive workflows.
- Submit PR: Open a Pull Request into the
mainbranch with a concise summary of what was added or changed.
βοΈ Docstring Guidelines
Use Google-style docstrings with type hints for new functions, classes, and selector methods:
def select_box(image_path: str, color: tuple[int, int, int] = (0, 255, 0)) -> list[int]:
"""Interactively select a bounding box region on an image.
Args:
image_path: Path to the target image file.
color: BGR tuple for rendering the bounding box overlay.
Returns:
Bounding box coordinates as absolute pixel values [x1, y1, x2, y2].
Examples:
>>> box = select_box("frame.jpg")
"""
...
For smaller helper methods, a single-line docstring is sufficient:
def xyxy(self) -> list[int]:
"""Returns bounding box coordinates in [x1, y1, x2, y2] format."""
...
β¨ Best Practices
- Minimize Code Duplication: Reuse shared backend utilities across selector types.
- Keep Dependencies Light:
pixpickis built to be a fast, lightweight toolkitβavoid adding heavy external dependencies unless strictly necessary. - Preserve Output Standards: Ensure bounding box and geometry outputs map cleanly into standard computer vision formats (
YOLO,SAM2,Supervision).