I am getting the following error on this line when it tries to draw lines on the image when rendering the 2d video.
cv2.error: OpenCV(4.10.0) :-1: error: (-5:Bad argument) in function 'line'
> Overload resolution failed:
> - img marked as output argument, but provided NumPy array marked as readonly
> - Expected Ptr<cv::UMat> for argument 'img'
This answer on stackoverflow told me it was because the image was readonly. The image is loaded by the line img = plt.imread(self.image_path.format(img_id=img_id)) which seems to load the image as readonly. This doesn't happen when using cv2.imread
>>> plt.imread(self.image_path.format(img_id=img_id)).flags
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : False
WRITEABLE : False
ALIGNED : True
WRITEBACKIFCOPY : False
>>> cv2.imread(self.image_path.format(img_id=img_id)).flags
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True
WRITEABLE : True
ALIGNED : True
WRITEBACKIFCOPY : False
Tested with:
- python 3.11.6
- opencv-python-headless 4.10.0.84
- matplotlib 3.9.1
I am getting the following error on this line when it tries to draw lines on the image when rendering the 2d video.
This answer on stackoverflow told me it was because the image was readonly. The image is loaded by the line
img = plt.imread(self.image_path.format(img_id=img_id))which seems to load the image as readonly. This doesn't happen when usingcv2.imreadTested with: