Expected cv::UMat for argument 'src'
I'm trying to apply the canny function on an image and here's the full code but it shows the error only if i put the steps within a function, but doesn't show when leaving all the code outside of any functions. Code:
import cv2
import numpy as np
def canny(image):
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(gray, (5,5), 0)
canny = cv2.Canny(blur, 50, 150) #sick
return canny
sourceimage = cv2.imread('lane.jpg')
img = np.copy(sourceimage)
canny = canny(img)
cv2.imshow("result", canny)
cv2.waitKey(0)
And here is the error i get: (python 3.6.8)
Traceback (most recent call last):
File "lane.py", line 12, in <module>
canny = canny(img)
File "lane.py", line 5, in canny
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
TypeError: Expected cv::UMat for argument 'src'
cv2.__version__
? how did you install that ?i think, you found a bug here.
though, as with any python noob, you fall into the
image-not-loaded-and-you-never-check
pit,the weird thing here is, that
np.copy(None)
triggers a different codepath than a plainNone
I can do this :
pi is not compatible with UMat please check your data
cv2.cvtColor("helo, there !",...)