OpenCV - numpy数组是cv2.imread的'坏参数类型'吗? [英] OpenCV - numpy array is 'bad argument type' for cv2.imread?
本文介绍了OpenCV - numpy数组是cv2.imread的'坏参数类型'吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用cv2.imread(image)读取图像。 'image'是对numpy数组列表元素的引用。控制台告诉我,我的参数 - 图像 - 是类型的,所以它应该与cv2.imread()一起使用,但是我得到以下错误:'TypeError:内置操作的错误参数类型'。
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'.
给出了什么?
推荐答案
- cv2。 imread()用于加载图像。它将图像路径作为字符串参数。这是错误的原因。
- 如果您使用numpy数组创建了一个图像,则不需要再次读取它,因为cv2接受一个numpy数组作为图像。
- 有关详细信息,这可能很有用:
如何使用Opencv 2.4将python numpy数组转换为RGB图像? - 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?
这篇关于OpenCV - numpy数组是cv2.imread的'坏参数类型'吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文