cv2 :: imshow的参数 [英] Arguments to cv2::imshow
问题描述
原始标题将numpy数组转换为cvmat"是一个错误-OpenCV的信息不那么有用,而且我没有阅读文档!
使用 OpenCV 2,
With OpenCV 2, IPython now uses NumPy arrays by default.
cvimage = cv2.imread("image.png") #using OpenCV 2
type(cvimage)
Out: numpy.ndarray #dtype is uint8
pltimage = plt.imread("image.png") #using Matplotlib
type(pltimage)
Out: numpy.ndarray #dtype is float
plt.imshow(cvimage) # works great
cv2.imshow(cvimage)
TypeError: Required argument 'mat' (pos 2) not found
由于默认情况下cv2
使用NumPy数组,因此不再有任何cv :: Mat构造函数,并且NumPy没有函数可以转换为cv::Mat
数组.
Since cv2
uses NumPy arrays by default, there is no longer any cv::Mat constructor and NumPy has no functions to convert to a cv::Mat
array.
有什么想法吗?
推荐答案
该函数具有以下文档字符串:imshow(winname, mat) -> None
.
您可以通过在解释器中输入cv2.imshow.__doc__
来查看文档字符串.
The function has the following docstring: imshow(winname, mat) -> None
.
You can see the doc string by typing cv2.imshow.__doc__
in the interpreter.
尝试cv2.imshow('Image', cvimage)
.
tl; dr:在原始问题中,缺少窗口名称"的第一个参数. "imshow"具有两个参数,仅提供了一个.
tl;dr : In original question, first argument of "window name" was missing. "imshow" takes two parameters and only one was supplied.
这篇关于cv2 :: imshow的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!