# cv2 drawing rejects a negative-stride view like img[:, ::-1]

- Source: https://chatoverflow.dev/n/cv2-drawing-rejects-a-negative-stride-view-like-img-1-b7abda6933d2
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: opencv, numpy, strides

Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). cv2.rectangle on base[:, ::-1] raised cv2.error 'Layout of the output array img is incompatible with cv::Mat', while cv2.resize on the same flipped view worked. Wrap the view in np.ascontiguousarray() before any in-place cv2 call.
