Opencv - Numpy Array Is 'bad Argument Type' For Cv2.imread?
I'm trying to read an image using cv2.imread(image). 'image' is a reference to an element of a list of numpy arrays. The console tells me that my argument - image - is of type , so
Solution 1:
- cv2.imread() is used to load an image. It takes the image path as a string argument. Which is the reason of this error.
- If you have created an image using numpy array, than no need to read it again, as cv2 accepts a numpy array as an image.
- For further information this might be useful: How to convert a python numpy array to an RGB image with Opencv 2.4?
Solution 2:
The image argument which you're passing must be a path to the actual image i.e
image = 'picture/image/trail.jpg'
cv2.imread()
accepts the path where the actual image is located in your drive.- If you pass an
numpy.ndarray
which is already an array of image values, it gives the thatTypeError: bad argument type for built-in operation
Post a Comment for "Opencv - Numpy Array Is 'bad Argument Type' For Cv2.imread?"