【问题标题】:OpenCV InputArray/OutputArrayOpenCV 输入数组/输出数组
【发布时间】:2016-02-19 08:55:44
【问题描述】:

我刚刚编译了 OpenCV 2.3 的最后一个版本。他们决定将所有 Matrix 输入/输出更改为 InputArray/OutputArray 将一切都搞砸了。在 OpenCV 2.2 下运行良好的同一段代码现在一文不值。

我会接受两种解决方案:

  1. 告诉我在哪里可以下载适用于 Linux 的 OpenCV 2.2,包含所有模块,重要的是不要缺少拼接(我试图找到一个合适的,但总是缺少拼接!)。

  2. 帮我解决我在下面描述的问题。

  3. OpenCV 2.4,即使仍然是测试版,已经修复了这个问题,我应该改用这个版本!

我收到这条异常消息:

OpenCV Error: Assertion failed (k == STD_VECTOR_MAT) in getMat, file /home/widgg/opencv/trunk/modules/core/src/matrix.cpp, line 928
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/widgg/opencv/trunk/modules/core/src/matrix.cpp:928: error: (-215) k == STD_VECTOR_MAT in function getMat

在 gdb 中,这是堆栈:

#0  0x00007ffff5df3445 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff5df6bab in __GI_abort () at abort.c:91
#2  0x00007ffff674169d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff673f846 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff673f873 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff673f96e in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff77fca51 in cv::error(cv::Exception const&) () from /usr/local/lib/libopencv_core.so.2.3
#7  0x00007ffff791306d in cv::_InputArray::getMat(int) const () from /usr/local/lib/libopencv_core.so.2.3
#8  0x00007ffff796064c in cv::perspectiveTransform(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&) () from /usr/local/lib/libopencv_core.so.2.3

最后,这是我调用 cv::perspectiveTransform 时的代码:

std::vector<cv::Point2f> corners(4);

cv::Mat cur_image = imread("my_image.jpg");

std::vector<cv::Point2f> img_corners(4);

img_corners[0] = cv::Point2f(0, 0);

img_corners[1] = cv::Point2f(cur_image.cols, 0);

img_corners[2] = cv::Point2f(cur_image.cols, cur_image.rows);

img_corners[3] = cv::Point2f(0, cur_image.rows);

cur_image.release();

cv::perspectiveTransform(img_corners, corners, m_transf);

而cv::Mat m_transf = (Mat_ (3,3)

我对 cv::FindHomography 也有类似的问题。问题是代码昨天和现在都正常执行,这个 InputArray/OuputArray 搞砸了一切。

非常烦人,请帮忙!

另外,我在这里找到了这份报告:OpenCV 2.2 Vs. 2.3,这不是一个好兆头!应该有解决方法!

【问题讨论】:

    标签: opencv


    【解决方案1】:

    您似乎安装了两个版本的 OpenCV,并且链接器尝试使用与用于编译代码的版本不同的版本进行链接。

    最简单的方法是删除所有其他 OpenCV 版本,然后可能的错误库路径将更加明确(缺少 somelib.so)

    或者,检查所有设置 PATH、链接器标志和包含文件夹,以确保您通过包含/编译/链接步骤使用相同的版本

    【讨论】:

    • 谢谢,它解决了图书馆的问题!我删除了我拥有的所有 OpenCV 实例,然后进行了 make install 以放入我想要的版本!
    • 这不是完整的答案,我将不得不再次重新发布该问题!但是你有什么想法可以解决这个问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 2012-12-14
    • 2014-01-22
    • 1970-01-01
    相关资源
    最近更新 更多