Ali
Ali

Reputation: 303

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 it should work with cv2.imread(), but i get the following error: 'TypeError: bad argument type for built-in operation'.

What gives?

Upvotes: 1

Views: 9096

Answers (2)

Rajath Bharadwaj
Rajath Bharadwaj

Reputation: 21

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 that TypeError: bad argument type for built-in operation

Upvotes: 0

nidhi vaishnav
nidhi vaishnav

Reputation: 158

  • cv2.imread() is used to load an image. It takes the image path as a string argument. Which is the reason of this error.

Upvotes: 6

Related Questions