I have an image opened with Image.open(). I make some changes, reassigning pixel RGV values,and try to save.
When I try to save, I get:
Trace back (most recent call last):
File "./shimmer", line 97, in <module>
cv2.imwrite('/home/christos/portrait-out.jpg', result)
TypeError: Expected Pre<cv::UMat> for argument 'img'
This happens when the image has been created, baseline = Image.open('/home/christos/portrait-new-mini.jpg')
.
In searching I have found similar reported errors but no clear articulation of "Here’s what works and how’s why."
I have also seen pages in which similar work is done without similar recorded difficulties.
I can post my code if that is requested, but I am guessing that the problem is narrowly defined by the cv2.imwrite()
call and something I want to be feeding the invocation.
Seems that you open the Image in Pillow and try to save the Pillow Image with OpenCV. OpenCV expect a numpy array. You should first convert your image before write in file with opencv.
Check this post : https://stackoverflow.com/a/14140796/13103631
I think, it will solve your issue