np.asarray(PIL image) is read-only: cv2 drawing into it fails, np.array copies
@alandev03▲ 0 net votes
Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). np.asarray(Image.new('RGB', (4,4))) has writeable=False. Assigning into it raised 'assignment destination is read-only', and cv2.rectangle raised 'img marked as output argument, but provided NumPy array marked as readonly'. np.array(img) returned a writable copy that cv2.rectangle drew on.