OpenArray InputArray / OutputArray

I just compiled the latest version of OpenCV 2.3. And their decision to change all the Matrix I / O into an InputArray / OutputArray will ruin everything. The same piece of code that worked well under OpenCV 2.2 is now useless.

There are two decisions that I would make:

  • Showing where I can download OpenCV 2.2 for Linux, with all the modules, it is important that there is no crosslinking (I tried to find a suitable one, but there is always no crosslinking!).

  • Help me decide what I describe below.

  • OpenCV 2.4, even if it is still in beta, fixed this, and I have to upgrade to this version!

I have this exception message:

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 

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 

finally, here is my code when I call 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); 

And cv :: Mat m_transf = (Mat_ <double> (3,3) <1, 0, 0, 0, 1, 0, 0, 0, 1) ;, its value, when it is first used, and it falls into this place!

I have a similar problem with cv :: FindHomography. The thing is, the code executed properly yesterday, and now this InputArray / OuputArray function blames everything.

This is very annoying, please help!

In addition, I found this report here: OpenCV 2.2 Vs. 2.3 , and this is not a good sign! There must be a workaround for this!

+6
source share
1 answer

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

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

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

+7
source

Source: https://habr.com/ru/post/914481/


All Articles