OpenCV InputArray/输出数组 [英] OpenCV InputArray/OutputArray

查看:626
本文介绍了OpenCV InputArray/输出数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚编译了OpenCV 2.3的最新版本.他们决定将所有Matrix输入/输出更改为InputArray/OutputArray,使一切变得混乱.在OpenCV 2.2下运行良好的同一段代码现在已一文不值.

I had just compile the last version of OpenCV 2.3. And their decision to change all Matrix input/output into InputArray/OutputArray messes everything up. The same piece of code that was working well under OpenCV 2.2 is now worthless.

我可以接受两种解决方案:

There's two solutions I would accept:

  1. 告诉我可以在哪里下载适用于Linux的OpenCV 2.2(包括所有模块),重要的一点是,不要缺少针脚(我试图找到合适的针脚,但是针脚总是会丢失!).

  1. Showing me where I can download OpenCV 2.2 for Linux, with all modules, it's important that stitching is not missing (I tried to find a suitable one, but stitching is always missing!).

帮我解决下面要描述的问题.

Help me solve what I'm describing below.

OpenCV 2.4(即使仍为beta版)已修复此问题,我应该改用此版本!

OpenCV 2.4, even if still beta, has fixed this and I should move to this version instead!

我收到此异常消息:

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中,这是堆栈:

In gdb, this is the stack:

#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时的代码:

finally, here's my code when I'm calling 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_< double>(3,3)< 1,0,0,0,1,0,0,0,1);那就是它的值第一次使用,它在那个地方崩溃了!

And cv::Mat m_transf = (Mat_ < double > (3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1);, that's its value when it's first used, and it crashes at that place!

我对cv :: FindHomography有类似的问题.问题是代码在昨天和现在正确执行,而这InputArray/OuputArray事情搞砸了一切.

I have a similar problem with cv::FindHomography. The thing is that code was executing properly yesterday and now, this InputArray/OuputArray thing screw everything up.

这很烦人,请帮忙!

此外,我在这里找到此报告:

Also, I found this report here: OpenCV 2.2 Vs. 2.3 and it's not a good sign! There should be a workaround for this!

推荐答案

似乎您已经安装了两个版本的OpenCV,并且链接程序尝试使用的链接版本与用于编译代码的链接版本不同.

It seems you have two versions of OpenCV installed, and the linker tries to use a different one for linking than the one used to compile your code.

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

The simplest way is to remove all the other OpenCV versions, and then a possible wrong library path will be more explicit (somelib.so missing)

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

Or, check all the settings PATH, linker flags and include folders to make sure you are using the same version through the include/complile/link steps

这篇关于OpenCV InputArray/输出数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆