TypeError: Expected cv::UMat for argument 'src'
I try to pull out the outline of the object contours from the photo, but I get an error:
Ret,thresh = cv2.threshold(img, 245,255,0)
TypeError: Expected cv::UMat for argument 'src'
Tried cv2. UMat but it didn't help, what's the problem?
if not img:
async with plugin.session.get(photo) as response:
img = Image.open(io.BytesIO(await response.read())).convert('L')
if not img:
return await env.reply('К сожалению, ваше фото исчезло!')
ret,thresh = cv2.threshold(img, 245,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_NONE)
tam = 0
for contorno in contours:
if len(contorno) > tam:
contornoGrande = contorno
tam = len(contorno)
cv2.drawContours(img,contornoGrande.astype('int'),-1,(0,255,0),2)
cv2.waitKey()
cv2.destroyAllWindows()
0
1 answers
UMat indicates that the Transparent API/OpenCL is involved.
Did it happen without your knowledge?
If not, just give the type
ret,thresh = cv2.threshold(cv2.UMat(img)...
Or copy the img to UMat
UMat um;
im.copyTo(um);
1
Author: MBo, 2019-08-26 08:23:33