findContours: Assertion failed [closed]

asked 2017-03-09 04:34:18 -0500

Julius gravatar image

Hi, I am using the latest OpenCV 3 Version with Visual Studio 2017. x64, Compiled using CMake and opencv_contrib.

My program crashes when I call findContours. I saw that some people have problemes with this function, but I wasn't able to fix my problem with theire solutions... Hopefully I did something wrong with my Includes etc...

C/C++ -> General-> Additional Include Directories: build\install\include

Linker -> General -> Additional Library Directories: build\install\x64\vc15\lib

Linker -> Input -> Additional Dependencies: everything from the directorie above

Exception:

include\xmemory0

template<class _alloc,="" class="" _ptr="typename" _wrap_alloc<_alloc="">::pointer> inline
    void _Destroy_range1(_Ptr _First, _Ptr _Last, _Wrap_alloc<_Alloc>& _Al, false_type)
    {   // destroy [_First, _Last), no special optimization
    for (; _First != _Last; ++_First)
        _Al.destroy(_Unfancy(_First)); //Exception thrown: read access violation.

    }

Call Stack

opencv_core320.dll!std::_Destroy_range1<std::allocator<std::vector<unsigned char,std::allocator<unsigned="" char=""> > >,std::vector<unsigned char,std::allocator<unsigned="" char=""> > * __ptr64>(std::vector<unsigned char,std::allocator<unsigned="" char=""> > * _First, std::vector<unsigned char,std::allocator<unsigned="" char=""> > * _Last, std::_Wrap_alloc<std::allocator<std::vector<unsigned char,std::allocator<unsigned="" char=""> > > > & _Al, std::integral_constant<bool,0> __formal) Line 1201  C++
[Inline Frame] opencv_core320.dll!std::_Destroy_range(std::vector<unsigned char,std::allocator<unsigned="" char=""> > *) Line 1218 C++
[Inline Frame] opencv_core320.dll!std::vector<std::vector<unsigned char,std::allocator<unsigned="" char=""> >,std::allocator<std::vector<unsigned char,std::allocator<unsigned="" char=""> > > >::_Destroy(std::vector<unsigned char,std::allocator<unsigned="" char=""> > *) Line 1885 C++
opencv_core320.dll!std::vector<std::vector<unsigned char,std::allocator<unsigned="" char=""> >,std::allocator<std::vector<unsigned char,std::allocator<unsigned="" char=""> > > >::_Resize<<lambda_b962d82acf8d40dd69d8706383060581> >(const unsigned __int64 _Newsize, std::vector<std::vector<unsigned char,std::allocator<unsigned="" char=""> >,std::allocator<std::vector<unsigned char,std::allocator<unsigned="" char=""> > > >::resize::__l2::<lambda_b962d82acf8d40dd69d8706383060581> _Udefault_or_fill) Line 1484 C++
[Inline Frame] opencv_core320.dll!std::vector<std::vector<unsigned char,std::allocator<unsigned="" char=""> >,std::allocator<std::vector<unsigned char,std::allocator<unsigned="" char=""> > > >::resize(const unsigned __int64) Line 1496 C++
opencv_core320.dll!cv::_OutputArray::create(int d, const int * sizes, int mtype, int i, bool allowTransposed, int fixedDepthMask) Line 2421 C++
opencv_core320.dll!cv::_OutputArray::create(int _rows, int _cols, int mtype, int i, bool allowTransposed, int fixedDepthMask) Line 2322 C++
opencv_imgproc320.dll!cv::findContours(const cv::_InputOutputArray & _image, const cv::_OutputArray & _contours, const cv::_OutputArray & _hierarchy, int mode, int method, cv::Point_<int> offset) Line 1922 C++
Tracker.exe!getMainContour(cv::Mat mask) Line 33 C++

Thank you really much for your help! Greetings!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Julius
close date 2017-03-09 06:50:44.201495

Comments

" everything from the directorie above"

please make sure to strictly use only release libs for release build and debug libs for debug.

berak gravatar imageberak ( 2017-03-09 05:29:03 -0500 )edit

Thank you for your input. So for debug purposes I should use the libs ending with "d", right? However in this path: "build\install\x64\vc15\lib" there aren't those files. I guess I should use the files from build\lib\Debug and build\lib\Release?

Julius gravatar imageJulius ( 2017-03-09 05:48:26 -0500 )edit

yes, exactly. with d for debug, without for release

(if those files arent there, you probably only built the release libs. have to go back to your opencv sln, and select DEBUG mode, and build libs again.)

berak gravatar imageberak ( 2017-03-09 05:54:43 -0500 )edit

Just to make sure: Additional Library Directories: build/lib/Debug (directory contains several libs) and Additional Dependencies: *d.lib files that are present in build/lib/Debug?

Alright, I forgot to use INSTALL for Debug in the VS Solution... Thank you!

Julius gravatar imageJulius ( 2017-03-09 06:13:19 -0500 )edit

Thanks for information. It is very benefit.

caner gravatar imagecaner ( 2017-04-08 10:32:55 -0500 )edit