Ask Your Question
0

TypeError: UMat() missing required argument 'ranges' (pos 2)

asked 2019-12-02 22:49:16 -0500

lokeshn gravatar image

updated 2019-12-03 00:57:21 -0500

berak gravatar image

My code is in Python

import cv2
import numpy as np


image=cv2.imread('WIN_20191122_15_19_57_Pro')
lane_image=np.copy(image)

gray = cv2.cvtColor(cv2.UMat(lane_image), cv2.COLOR_RGB2GRAY)
cv2.imshow("result",gray)
cv2.waitKey(0)
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2019-12-03 04:10:17 -0500

supra56 gravatar image

updated 2019-12-03 04:36:09 -0500

I noticed you left out extension png, jpg or bmp, etc. Change this:

image=cv2.imread('WIN_20191122_15_19_57_Pro')

to: image=cv2.imread('WIN_20191122_15_19_57_Pro.x') ==> x denoted jpg, png or bmp, etc. Example:

import cv2

image = cv2.imread('filename.png')

cv2.imshow('img', image)
cv2.waitKey(0)
edit flag offensive delete link more
0

answered 2019-12-03 01:06:15 -0500

berak gravatar image

updated 2019-12-03 01:07:21 -0500

your image was never read correctly.

cv2.imread() does NOT throw an exception if your image could not be read, but returrns None instead.

you MUST check on your own here, else the next operations will fail

(also, using np.copy or even cv2.UMat does not make any sense here.)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-12-02 22:49:16 -0500

Seen: 39 times

Last updated: Dec 03