python-opencv
Installation
SKILL.md
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 |