简体   繁体   English

OpenCV-numpy数组是cv2.imread的``错误参数类型''?

[英]OpenCV - numpy array is 'bad argument type' for cv2.imread?

I'm trying to read an image using cv2.imread(image). 我正在尝试使用cv2.imread(image)读取图像。 'image' is a reference to an element of a list of numpy arrays. “图像”是对numpy数组列表的元素的引用。 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'. 控制台告诉我,我的参数-image-是type,因此它应与cv2.imread()一起使用,但出现以下错误:'TypeError:内置操作的错误参数类型'。

What gives? 是什么赋予了?

  • cv2.imread() is used to load an image. cv2.imread()用于加载图像。 It takes the image path as a string argument. 它以图像路径作为字符串参数。 Which is the reason of this error. 这是此错误的原因。

The image argument which you're passing must be a path to the actual image ie 您要传递的图像参数必须是实际图像的路径,即

image = 'picture/image/trail.jpg'
  • cv2.imread() accepts the path where the actual image is located in your drive. cv2.imread()接受驱动器中实际映像所在的路径。
  • 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 如果传递一个已经是图像值数组的numpy.ndarray ,它将TypeError: bad argument type for built-in operation提供该TypeError: bad argument type for built-in operation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM