+-

OPENCV中的许多函数都使用InputArray和OutputArray作为函数参数.例如,OPENCV中的Hough变换函数:
void HoughLines(InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn=0, double stn=0 )
在内部函数中,我们必须使用InputArray函数getMat将其赋予真正的输入数组类型.例如,Mat image = _image.getMat().同样,我们必须使用copyTo函数将真正的输出数组转换为OutputArray格式.例如,Mat(lines).copyTo(_lines).
我的问题是为什么OPENCV以这种方式设计其功能签名.以霍夫函数为例,如果我们使用以下函数签名:
void HoughLines(Mat &image, std::vector<Vec2f> &lines, double rho, double theta, int threshold, double srn=0, double stn=0 )
我希望它会更好,因为它会消除额外的不必要的复制操作.
最佳答案
从( http://docs.opencv.org/2.4/modules/core/doc/basic_structures.html?highlight=inputarray#InputArray)
When you see in the reference manual or in OpenCV source code a function that takes InputArray, it means that you can actually pass Mat, Matx, vector etc. (see above the complete list).
cv Arrays只是代理类.您可以使用cv :: Mat变量作为输入/输出数组(并且您不必自己包装它们).
点击查看更多相关文章
转载注明原文:c – 为什么OPENCV中的这么多函数使用InputArray和OutputArray作为函数参数? - 乐贴网