plugins/python-master/skills/python-opencv/SKILL.md
Complete OpenCV computer vision system for Python. PROACTIVELY activate for: (1) Image loading with cv2.imread (BGR format gotcha), (2) Video capture with cv2.VideoCapture, (3) Color space conversion (BGR to RGB, HSV, grayscale), (4) Image filtering (GaussianBlur, medianBlur, bilateralFilter), (5) Edge detection (Canny), (6) Contour detection with cv2.findContours, (7) Image resizing with interpolation methods, (8) Template matching, (9) Feature detection (SIFT, ORB, AKAZE), (10) Drawing functions (rectangle, circle, text), (11) Video writing with cv2.VideoWriter, (12) Morphological operations, (13) Deep learning with cv2.dnn module, (14) GPU acceleration with cv2.cuda, (15) Coordinate system (x,y vs row,col) gotchas. Provides: Image processing patterns, video capture/writing, memory management, performance optimization, Jupyter notebook workarounds. Ensures correct BGR handling and memory-safe OpenCV usage.
npx skillsauth add JosiahSiegel/claude-plugin-marketplace python-opencvInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| Function | Purpose | Gotcha |
|----------|---------|--------|
| cv2.imread(path) | Load image | Returns None if path invalid (no error!) |
| cv2.imwrite(path, img) | Save image | Expects BGR, not RGB |
| cv2.cvtColor(img, code) | Color conversion | BGR is default, not RGB |
| cv2.VideoCapture(src) | Video/camera input | Always check isOpened() and release() |
| cv2.VideoWriter(...) | Save video | Expects BGR frames, codec matters |
| cv2.resize(img, (w, h)) | Resize image | Size is (width, height), not (height, width) |
| Coordinate System | Order | Usage |
|-------------------|-------|-------|
| NumPy indexing | img[row, col] = img[y, x] | Pixel access |
| Image shape | (height, width, channels) | Shape is (rows, cols, ch) |
| OpenCV functions | (x, y) | Drawing functions |
| Resize/ROI | (width, height) | Size parameters |
| Color Conversion | Code | Note |
|------------------|------|------|
| BGR to RGB | cv2.COLOR_BGR2RGB | For Matplotlib display |
| BGR to Gray | cv2.COLOR_BGR2GRAY | Single channel output |
| BGR to HSV | cv2.COLOR_BGR2HSV | H: 0-179, S/V: 0-255 |
| Interpolation | Best For | Speed |
|---------------|----------|-------|
| INTER_NEAREST | Speed, pixelated OK | Fastest |
| INTER_LINEAR | General purpose (default) | Fast |
| INTER_AREA | Downscaling | Medium |
| INTER_CUBIC | Upscaling quality | Slow |
| INTER_LANCZOS4 | Best upscaling | Slowest |
Use for computer vision and image processing:
Related skills:
python-fundamentals-313python-asynciopython-type-hintsOpenCV (Open Source Computer Vision Library) is the most popular computer vision library. Python bindings (opencv-python) provide access to all functionality through NumPy arrays. OpenCV uses BGR color format by default, which is a critical gotcha.
# CPU-only (most common)
pip install opencv-python
# With contrib modules (SIFT, SURF, extra features)
pip install opencv-contrib-python
# Headless (no GUI, for servers)
pip install opencv-python-headless
# Verify installation
python -c "import cv2; print(cv2.__version__)"
cv2.imwrite.(height, width, channels), NumPy indexing is img[row, col], but OpenCV drawing functions use (x, y).cv2.imread returns None on missing or undecodable files; always check before using the image.VideoCapture and GUI windows must be released/closed in finally or context-manager cleanup paths.uint8; use OpenCV arithmetic or explicit float normalization when needed.Read references/opencv-critical-gotchas.md for the full preserved examples and safe patterns.
The detailed API patterns and code recipes have been split into focused references. Load the file that matches the user's task.
Read this for full examples of the most common OpenCV failure modes:
cv2.imwrite usagecv2.imread None checks and pathlib validationVideoCapture release patterns and context-manager wrapperuint8 overflow, cv2.add, float normalization, Canny dtype expectationsRead this for everyday OpenCV work:
cv2.imread flags, loading from URLs, cv2.imwrite quality params, multi-image batch loadingVideoWriter codecs (mp4v, XVID, H264), FPS/resolution probingfindContours, area/perimeter, bounding boxes, contour approximation, hierarchycv2.matchTemplate, multi-scale matching, TM_CCOEFF_NORMED thresholdingcv2.dnn.readNet for ONNX/TF/Caffe, blob preprocessing, YOLO/MobileNet inferencecv2.imshow + waitKey loops, Jupyter cv2.imshow workaround with Matplotlibcv2.UMat for OpenCL, cv2.cuda GPU operationsRead this for specialized computer-vision pipelines:
undistortcv2.Stitcher panorama assemblyThis skill should activate when the user mentions any of: OpenCV, cv2, BGR, image processing, contours, Canny, Hough transform, template matching, ORB/SIFT/AKAZE, VideoCapture, VideoWriter, cv2.dnn, cv2.cuda, computer vision in Python.
development
This skill should be used when the user asks to train, debug, scale, or improve ML models. PROACTIVELY activate for: (1) PyTorch, TensorFlow/Keras, JAX, Flax, Hugging Face Trainer/Accelerate training loops, (2) distributed training, DDP/FSDP/DeepSpeed, TPU/GPU setup, (3) mixed precision AMP/bf16, gradient accumulation, checkpointing, seeding, (4) overfitting, imbalance, loss functions, regularization, LR schedules, warmup, (5) memory optimization, gradient checkpointing, offloading, quantization-aware training. Provides: reproducible training best practices across deep learning and classical ML.
development
This skill should be used when the user asks to productionize, track, version, govern, monitor, or automate ML systems. PROACTIVELY activate for: (1) MLflow, Weights & Biases, Neptune, Comet, ClearML experiment tracking, (2) model registry, model versioning, artifact lineage, reproducibility, (3) Kubeflow, SageMaker Pipelines, Vertex AI Pipelines, Azure ML pipelines, Databricks workflows, (4) CI/CD, continuous training/evaluation, A/B tests, canary/shadow deployments, (5) drift detection, model monitoring, data validation, responsible AI governance. Provides: end-to-end MLOps architecture and operational safeguards.
development
This skill should be used when the user asks to optimize, export, serve, compress, or accelerate ML inference. PROACTIVELY activate for: (1) latency, throughput, p95/p99, batching, concurrency, KV cache, memory, or cost issues, (2) quantization INT8/INT4, GPTQ, AWQ, bitsandbytes, pruning, sparsity, distillation, (3) ONNX export, ONNX Runtime, TensorRT, TorchScript, torch.compile, XLA, OpenVINO, Core ML, TFLite, (4) Triton, TorchServe, TF Serving, BentoML, Seldon, KServe configuration, (5) edge deployment, CPU/GPU/TPU/Inferentia serving. Provides: hardware-aware inference optimization and safe benchmarking.
testing
This skill should be used when the user asks to tune hyperparameters, run sweeps, optimize search spaces, or use AutoML. PROACTIVELY activate for: (1) Optuna, Ray Tune, FLAML, AutoGluon, Hyperopt, Nevergrad, KerasTuner, W&B sweeps, (2) grid search, random search, Bayesian optimization, TPE, Gaussian processes, evolutionary search, (3) ASHA, Hyperband, successive halving, multi-fidelity optimization, population-based training, (4) learning-rate finder, batch-size search, early stopping, pruning, (5) reproducible sweep design and experiment analysis. Provides: budget-aware hyperparameter search strategy.