OpenCV 2.4.2 findContours raises an error (with CV prog example)

I got Ubuntu 12.04 32bit working in VMware. After that, I installed OpenCV 2.4.2 ( http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/ ).

When I try to run the example for findContours from the CV page ( http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html ), it compiles, but crashes to "findContours".

OpenCV Error: Assertion failed (k == STD_VECTOR_MAT) in release, file /build/build /opencv-2.3.1/modules/core/src/matrix.cpp, line 1364 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.3.1/modules/core/src/matrix.cpp:1364: error: (-215) k == STD_VECTOR_MAT in function release 

I do not know what's the problem...

I am running the code in Eclipse using. CDT Build Console says:

 make all Building file: ../src/FrameTest.cpp Invoking: Cross G++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/FrameTest.d" -MT"src/FrameTest.d" -o "src/FrameTest.o" "../src/FrameTest.cpp" ../src/FrameTest.cpp:26:2: warning: "/*" within comment [-Wcomment] ../src/FrameTest.cpp: In function 'int main()': ../src/FrameTest.cpp:319:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings] ../src/FrameTest.cpp: In function 'void thresh_callback(int, void*)': ../src/FrameTest.cpp:345:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] Finished building: ../src/FrameTest.cpp Building target: FrameTest Invoking: Cross G++ Linker g++ -L/home/ubu/workspace/opencv -L/usr/share -L/usr/share/doc/libcv-dev -L/lib -L/lib/i386-linux-gnu -L/home/ubu/OpenCV-2.4.2/include/opencv -L/home/ubu/OpenCV-2.4.2/include/opencv2 -o "FrameTest" ./src/FrameTest.o -lopencv_core -lopencv_highgui -lpthread -lopencv_imgproc Finished building target: FrameTestenter code here 

Anyone got an idea? I have another code from an old project working with CV2.2 on Windows with VS2010, and it works ... Where is the difference between VStudio with Win vs. Eclipse and Ubuntu?

Thanks.

+4
source share
1 answer

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

The easiest way is to remove all other old versions of OpenCV, and then the possible wrong library path will be more explicit. check all PATH settings, linker flags and include folders to make sure that you are using the same version with include / complile / link options

+4
source

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


All Articles