【问题标题】:Using remap function opencv 2.3.1使用 remap 函数 opencv 2.3.1
【发布时间】:2014-07-15 07:56:58
【问题描述】:

我正在使用OpenCV的remap函数如下图:

Mat lg,lr;
Mat *mxl = (Mat *) cvLoad("mx1.xml");
Mat *myl = (Mat *) cvLoad("my1.xml");
remap(lg, lr, mxl, myl);

mx1my1被加载为cv::Mat,但是remap需要cv::_InputArray,我该如何实现呢?

【问题讨论】:

    标签: opencv image-processing


    【解决方案1】:

    cv::_InputArray 是 OpenCV 用来接受多种数据类型(如cv::Matstd::vector)作为输入的代理类型。您无需直接创建。

    部分问题在于您试图混合使用 C 和 C++ API。不建议这样做。另一个因素是cv::Mat* 无法转换为InputArray。您可以使用cv::FileStorage 将您的文件读入cv::Mat 对象:

    cv::Mat lg, lr;
    cv::FileStorage fs1("mx1.xml", cv::FileStorage::READ);
    cv::FileStorage fs2("mx2.xml", cv::FileStorage::READ);
    
    cv::Mat mxl;
    cv::FileNode fn = fs1.getFirstTopLevelNode();
    fn >> mxl;
    
    cv::Mat myl;
    fn = fs2.getTopLevelNode();
    fn >> myl;
    
    cv::remap(lg, lr, mxl, myl, CV_INTER_LINEAR);
    

    【讨论】:

    • 使用 OpenCV 2.4.8 - getTopLevelNode 似乎已重命名为 getFirstTopLevelNode。
    猜你喜欢
    • 2014-04-18
    • 2017-06-04
    • 2018-03-23
    • 2017-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    相关资源
    最近更新 更多