OpenCV example code for find contours: vector deallocation issue

后端 未结 3 1618
你的背包
你的背包 2020-12-14 22:50

I\'m trying to get started with contour detection in OpenCV 2.4.2. To this end, I set up a project for OpenCV and copied the whole example code found in the documentation. F

相关标签:
3条回答
  • 2020-12-14 23:19

    You're building your application in debug mode and linking against the Multithreaded Debug DLL CRT. Do you know which CRT the OpenCV DLL(s) are linked against? If it's linked against a static CRT it'll fill up the vector with data allocated from a separate heap, which causes an assertion in the Debug CRT you're using.

    If you build your application in Release mode you should no longer see the assert, but you might end up leaking memory. The best thing would be to ensure that both your application and the OpenCV DLL(s) are linked against the same Multithreaded DLL CRT.

    EDIT: If you can't rebuild OpenCV to use the same CRT as your application you could try telling the linker to use the same CRT version as OpenCV for your application by modifying the application manifest. See How to Enforce C++ compiler to use specific CRT version? for more information on how to do that.

    0 讨论(0)
  • 2020-12-14 23:29

    Go into your solution-options, there the c-runtime (CRT) settings and check the linking (CRT as mentioned above)... if your project was/is (once) created with VS10 and you use a newer version, just edit the links not to be 10, but 11 or 12 ..

    0 讨论(0)
  • 2020-12-14 23:36

    Add to System Path (as an example): H:\Source\opencv_v2_4_13_2\output\bin\Debug

    where directory: "H:\Source\opencv_v2_4_13_2\output" is used from CMake as destination directory for visual Studio 14 (2015) opencv projects.

    Your project uses opencv dll files, but is not find: opencv_core2413d.dll

    0 讨论(0)
提交回复
热议问题