python-opencv
БесплатноБез исполняемых скриптовНе проверенComplete OpenCV computer vision system for Python. PROACTIVELY activate for: (1) Image loading with cv2.imread (BGR format gotcha), (2) Video capture with…
от JosiahSiegel★ 67 звёзд на GitHubОб этом скилле
Quick Reference
| 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 |
When to Use This Skill
Use for computer vision and image processing:
- Loading, displaying, and saving images
- Video capture from cameras or files
- Image filtering and transformations
- Edge and contour detection
- Object detection and template matching
- Feature detection and matching
- Deep learning inference with DNN module
Related skills:
- For NumPy arrays: see
python-fundamentals-313 - For async processing: see
python-asyncio - For type hints: see
python-type-hints
OpenCV Python Complete Guide (2025)
Overview
OpenCV (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.
Installation
# 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__)"
Key Gotchas
- OpenCV uses BGR, not RGB; convert before Matplotlib/PIL display and convert back before
cv2.imwrite. - Image shape is
(height, width, channels), NumPy indexing isimg[row, col], but OpenCV drawing functions use(x, y). cv2.imreadreturnsNoneon missing or undecodable files; always check before using the image.VideoCaptureand GUI windows must be released/closed infinallyor context-manager cleanup paths.- NumPy arithmetic can overflow on
uint8; use OpenCV arithmetic or explicit float normalization when needed.
Read references/opencv-critical-gotchas.md for the full preserved examples and safe patterns.
Reference Map
The detailed API patterns and code recipes have been split into focused references. Load the file that matches the user's task.
Critical Gotchas -> references/opencv-critical-gotchas.md
Read this for full examples of the most common OpenCV failure modes:
- BGR/RGB conversion: Matplotlib and PIL integration, correct
cv2.imwriteusage - Coordinate ordering: shape, NumPy indexing, drawing functions, ROI slicing
- Failed image loads:
cv2.imreadNonechecks and pathlib validation - Video cleanup:
VideoCapturerelease patterns and context-manager wrapper - Dtype safety:
uint8overflow,cv2.add, float normalization, Canny dtype expectations
Core Operations -> references/opencv-core-operations.md
Read this for everyday OpenCV work:
- Image I/O:
cv2.imreadflags, loading from URLs,cv2.imwritequality params, multi-image batch loading - Video Capture and Writing: camera/file capture,
VideoWritercodecs (mp4v, XVID, H264), FPS/resolution probing - Color Space Conversions: BGR/RGB/HSV/Gray/Lab, HSV color detection (red/green/blue ranges with dual-range red), white-balance helpers
- Image Filtering: GaussianBlur, medianBlur, bilateralFilter, Sobel/Laplacian/Canny edge detection, morphological ops (erode, dilate, open, close, gradient, tophat)
- Contour Detection:
findContours, area/perimeter, bounding boxes, contour approximation, hierarchy - Image Resizing and Transformations: aspect-ratio-preserving resize, rotation, affine/perspective transforms, warpAffine vs warpPerspective
- Template Matching:
cv2.matchTemplate, multi-scale
Установить python-opencv в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл python-opencv?
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.
Как установить скилл python-opencv?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл python-opencv запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic