Unhandled exception (msvcr120.dll) using imwrite()
I'm developing a software that has a few threads writing 10 to 50 bitmap files per second and sometimes I'm getting this exception.Each thread writes its bitmap files into different folders.
I tried cloning the cv::Mat just before imwrite(), or getting a lock before calling imwrite() but those didn't help.
Each threads uses this code to write bitmap files.
cv::Mat source_image; // UINT8, 1x128x130
// do some processing to the source_image;
cv::Mat cloned_image = source_image.clone();
if ((cloned_image.rows > 0) && (cloned_image.cols >0)) {
cv::String file_name = ""; // somewhere
cv::imwrite(file_name, cloned_image); // THIS IS WHERE I GET THE EXCEPTION
}
I also checked the mini dump file (*.dmp) and the exception code was 0xC0000409.
Here is the stack info from the mini dump file.
msvcr120.dll!_invoke_watson(const wchar_t * pszExpression, const wchar_t * pszFunction, const wchar_t * pszFile, unsigned int nLine, unsigned __int64 pReserved) 行 132 C++
msvcr120.dll!_invalid_parameter(const wchar_t * pszExpression, const wchar_t * pszFunction, const wchar_t * pszFile, unsigned int nLine, unsigned __int64 pReserved) 行 85 C++
msvcr120.dll!_invalid_parameter_noinfo() 行 97 C++
msvcr120.dll!_write(int fh, const void * buf, unsigned int cnt) 行 66 C
msvcr120.dll!_fwrite_nolock(const void * buffer, unsigned __int64 size, unsigned __int64 num, _iobuf * stream) 行 166 C
msvcr120.dll!fwrite(const void * buffer, unsigned __int64 size, unsigned __int64 count, _iobuf * stream) 行 83 C
opencv_world300.dll!00007ffc0e265373() unknown
opencv_world300.dll!00007ffc0e264745() unknown
opencv_world300.dll!00007ffc0e256899() unknown
opencv_world300.dll!00007ffc0e2532bb() unknown
opencv_world300.dll!00007ffc0e252f36() unknown
cv::imwrite(file_name, cloned_image);
Thank you.