在我的程序崩溃时,Visual Studio给了我下面的调用堆栈,它没有对我编写的任何代码或者源代码中的任何代码的引用,这是否表明OpenCV库中存在错误?
我认为仍然可以在我的程序中找到触发崩溃的源操作/函数,通常就是这种情况。
opencv_imgproc243d.dll!cv::RGB2RGB<unsigned char>::operator()(const unsigned char * src=0x00000000, unsigned char * dst=0x0f010050, int n=1920) Line 208 + 0x6 bytes C++
> opencv_imgproc243d.dll!cv::CvtColorLoop_Invoker<cv::RGB2RGB<unsigned char> >::operator()(const cv::Range & range={...}) Line 176 + 0x1d bytes C++
opencv_core243d.dll!`anonymous namespace'::ParallelLoopBodyWrapper::operator()(const cv::Range & sr={...}) Line 134 + 0x17 bytes C++
opencv_core243d.dll!`anonymous namespace'::ProxyLoopBody::operator()(int i=0) Line 177 C++
opencv_core243d.dll!Concurrency::_Parallel_chunk_helper_invoke<int,unsigned int,`anonymous namespace'::ProxyLoopBody,0>::_Invoke(const int & _First=0, unsigned int & _Index=0, const `anonymous-namespace'::ProxyLoopBody & _Func={...}) Line 1445 C++
opencv_core243d.dll!Concurrency::_Parallel_chunk_helper<int,unsigned int,`anonymous namespace'::ProxyLoopBody,0>::operator()() Line 1833 + 0x16 bytes C++
opencv_core243d.dll!Concurrency::task_handle<Concurrency::_Parallel_chunk_helper<int,unsigned int,`anonymous namespace'::ProxyLoopBody,0> >::operator()() Line 116 C++
opencv_core243d.dll!Concurrency::details::_UnrealizedChore::_InvokeBridge<Concurrency::task_handle<Concurrency::_Parallel_chunk_helper<int,unsigned int,`anonymous namespace'::ProxyLoopBody,0> > >(Concurrency::task_handle<Concurrency::_Parallel_chunk_helper<int,unsigned int,`anonymous namespace'::ProxyLoopBody,0> > * _PChore=0x036fb148 {_M_first=0 _M_step=1 _M_function={...} ...}) Line 3495 C++
msvcr100d.dll!Concurrency::details::_UnrealizedChore::_StructuredChoreWrapper(Concurrency::details::_UnrealizedChore * pChore=0x036fb148 {_M_first=0 _M_step=1 _M_function={...} ...}) Line 99 + 0xc bytes C++
msvcr100d.dll!Concurrency::details::_UnrealizedChore::_Invoke() Line 3454 + 0xc bytes C++
msvcr100d.dll!Concurrency::details::WorkItem::Invoke() Line 75 C++
msvcr100d.dll!Concurrency::details::InternalContextBase::ExecuteChoreInline(Concurrency::details::WorkItem * pWork=0x0fb8f7dc) Line 1385 C++
msvcr100d.dll!Concurrency::details::InternalContextBase::Dispatch(Concurrency::DispatchState * pDispatchState=0x0fb8f7fc) Line 1478 C++
msvcr100d.dll!Concurrency::details::FreeThreadProxy::Dispatch() Line 157 C++
msvcr100d.dll!Concurrency::details::ThreadProxy::ThreadProxyMain(void * lpParameter=0x029c2160) Line 162 C++
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes
由于函数接收到已损坏的Mat,因此在崩溃时将其输出到控制台,因此看起来断言失败。
答案 0 :(得分:2)
我猜想在你的代码中调用方法cvtColor()时opencv会在自己的线程中运行它。
您可以看到opencv源here,它显示在Color.cpp文件中调用此方法。
RGB2RGB格式类似于从一个色彩空间转换到另一个色彩空间时使用的格式,我猜这可能是创建一个副本。
因此,我可能会在您的代码中查找以下命令作为原因。
cvtColor(src, dst, CV_RGB2RGB);
or
Mat A = Mat(...);
Mat B = A.clone();
I don't think this will cause it as this just copies header information.
Mat B(A);
or
A.copyTo(B);
您可以排除Mat将您转换为BGR或GRAY的位置。事实上,正如我所理解的那样,opencv在BGR色彩空间中工作,你很可能已经将Mat转换为RGB,这可能是一个很好的搜索起点。
修改强>
断言还表明你试图将一个空的Mat克隆()给另一个。
Asset( y==0 )
如果只是偶尔发生这种情况,那么我会查找if()语句,或者发生克隆或转换的条件情况。