I am trying to stitch some images taken from my OpenMV H7 camera using OpenCV's stitching algorithm. I ran into the problem that I cannot write or read these images, which made me think that there are some compatibility issues.
To be more exact, I got this error when using the method (cv2.imwrite) itself:
File "main_script_test.py", line 141, in <module>
cv2.imwrite("/Documents/Cam/Images/image_" + str(images_To_Be_Taken), img)
TypeError: Expected Ptr<cv::UMat> for argument 'img'
I have been thinking that maybe there is a way I can turn the image into a NumPy array to make it compatible, but I am not quite sure.
Any suggestions?
OpenCV's imwrite is expecting a Mat object, which is an "n-dimensional dense array class". Passing in a
numpy
array of the image data in place of Mat objects, in the case of imwrite() at least, will yield the correct result.From the documentation linked above:
For your code: