Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV TypeError: Expected cv::UMat for argument 'src' - What is this?

Disclaimer: huge openCV noob

Traceback (most recent call last):

File "lanes2.py", line 22, in

canny = canny(lane_image) 

File "lanes2.py", line 5, in canny

gray = cv2.cvtColor(imgUMat, cv2.COLOR_RGB2GRAY) 

TypeError: Expected cv::UMat for argument 'src'

What exactly is 'src' referring to?

like image 635
autonocat Avatar asked Jan 18 '19 07:01

autonocat


2 Answers

src is the first argument to cv2.cvtColor.

The error you are getting is because it is not the right form. cv2.Umat() is functionally equivalent to np.float32(), so your last line of code should read:

gray = cv2.cvtColor(np.float32(imgUMat), cv2.COLOR_RGB2GRAY) 
like image 95
Varun Mathur Avatar answered Sep 18 '22 16:09

Varun Mathur


gray = cv2.cvtColor(cv2.UMat(imgUMat), cv2.COLOR_RGB2GRAY) 

UMat is a part of the Transparent API (TAPI) than help to write one code for the CPU and OpenCL implementations.

like image 31
Nuzhny Avatar answered Sep 18 '22 16:09

Nuzhny