Commit 351fdff
authored
Fix OpenCV 4.12 cv2.rectangle error due to non-contiguous arrays (#510)
OpenCV 4.12 requires C-contiguous arrays for in-place drawing
operations. The image from rasterio (via np.transpose) and the blended
array from float arithmetic were non-contiguous, causing cv2.rectangle
to fail with "Layout of the output array img is incompatible with
cv::Mat".
- Ensure self.image is C-contiguous after set_image()
- Copy blended array before OpenCV drawing in _render_anns_opencv()1 parent 04f5ed7 commit 351fdff
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
347 | 351 | | |
348 | 352 | | |
349 | 353 | | |
| |||
2821 | 2825 | | |
2822 | 2826 | | |
2823 | 2827 | | |
| 2828 | + | |
2824 | 2829 | | |
2825 | 2830 | | |
2826 | 2831 | | |
| |||
0 commit comments