Unhandled exception from opencv_core249.dll when returning main end
Hi. I've created a recognition system's stages and it's fine until I load an image which has different width of the others (first ones have small width than 1000 pixels with no error but last three ones have bigger width than 1000 pixels) then I faced a problem and I've opened a topic on stackoverflow (here is link). I thought it was about std::vector
problem but now I'm confused because I've solved (I think) std::vector
problem with pointerrs but now unhandled exception is occuring when whole process is trying to end with end of main
returning. The error is occuring at system.cpp
in int _interlockedExchangeAdd(int* addr, int delta){...}
and the code is some big. I don't know which part of code cause this and I don't know again how can I handle this exception with try/catch
or any other method. If anyone give any advice I'm here. Thanks.
Unhandled exception at 0x0F2EE189 (opencv_core249d.dll) in pt_dll_deneme.exe: 0xC0000005: Access violation writing location 0x000006BA.
Edit:
1. Small code sample
struct ExtremumPoints_t
{
std::vector<int> maxPoints;
std::vector<int> minPoints;
unsigned int maxCnt;
unsigned int minCnt;
};
struct ImageClipping_t
{
int bm;
int b0;
int b1;
cv::Mat ROI;
};
ExtremumPoints_t *exPoints;
ImageClipping_t *vecClippingB;
ImageClipping_t *vecClippingP;
myClass::myClass()
{
exPoints = new ExtremumPoints_t();
vecClippingB = new ImageClippint_t();
vecClippingP = new ImageClippint_t();
}
myClass::~myClass()
{
delete exPoints;
delete vecClippingB;
delete vecClippingP;
}
void myClass::findExtremums(cv::Mat &pr)
{
// using wite exPoints..
// some if else statements to find extremum points in a one dimensional cv::Mat array
// these can be seen at link at details
}
void myClass::processExtremums(cv::Mat &im, cv::Mat &pr)
{
// using exPoints and clippingB finding some ROI's or full image
findExtremums(pr);
// these are if .. else statements again
// extremum points no longer needed so can be cleared
exPoints->minPoints.clear();
exPoints->maxPoints.clear();
}
void myClass::processClippingB(cv::Mat &im)
{
// using new ROI's in clippingP from clippingB
// some process about finding actual object pixel points
// finding new extremum points from created new ROIs
// exPoints, clippingB and clippingP are no longer needed
exPoints->minPoints.clear();
exPoints->minPoints.clear();
clippingB->clear();
clippingP->clear();
}
Processes are not complex just find min or max value then save the pixel index and find roi of image. All processes simple and working. First there was a vector problem and I've write it to stackoverflow now unhandled exception occuring last return 0; line in main function
2. Resizing images to 800x600 solved the problem but still I don't know why. Thanks..
things to look out for:
vector<Mat*>
? or raw pointer to something, that should be acv::Ptr<something>
- all of it a terrible idea.Thanks. I'm not using pointers with
cv::Mat
or any other container fromcv::
but I've got a struct namedImageClipping_t
it contains acv::Mat ROI;
this struct created in vectorstd::vector<ImageClipping_t> *clipping;
and instancing in constructor. I'm editing the question about that, and I was configured project debug libs for debug and release libs with release. Can you explain your first advice 'work my way up the callstack'?unfortunately, i can't write you a tutorial on how to use vs' debugger.
_interlockedExchangeAdd is mainly used in opencv, to increase/decrease refcounts with cv::Mat cv::Algorithm and such. (in a threadsafe way)
msvcr110d.dll!doexit(int code, int quick, int retcaller) Line 585 C
This is the last call stack value before going unhandled exception.ah, good, you found the callstack !
but look around a bit more, until you find something familiar (some code of yours). then inspect the situation there. do some Mat's look invalid/broken ? values, that don't make sense ?
I'm watching all processes with looking images and image values. I didn't find anything else. I'm changing the image sizes.