Unhandled exception from opencv_core249.dll when returning main end

asked 2015-09-09 03:46:40 -0500

OrkunK gravatar image

updated 2015-09-09 16:45:35 -0500

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..

edit retag flag offensive close merge delete

Comments

1

things to look out for:

  • debug it. let it crash, and work your way up the callstack.
  • are you using pointers to Mat, eg. a vector<Mat*> ? or raw pointer to something, that should be a cv::Ptr<something> - all of it a terrible idea.
  • check , which opencv libs you link. stay strictly with debu libs for debug build an release libs with release.
berak gravatar imageberak ( 2015-09-09 05:41:44 -0500 )edit

Thanks. I'm not using pointers with cv::Mat or any other container from cv:: but I've got a struct named ImageClipping_t it contains a cv::Mat ROI; this struct created in vector std::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'?

OrkunK gravatar imageOrkunK ( 2015-09-09 06:31:06 -0500 )edit

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)

berak gravatar imageberak ( 2015-09-09 06:44:40 -0500 )edit

msvcr110d.dll!doexit(int code, int quick, int retcaller) Line 585 C This is the last call stack value before going unhandled exception.

OrkunK gravatar imageOrkunK ( 2015-09-09 16:33:26 -0500 )edit

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 ?

berak gravatar imageberak ( 2015-09-10 00:54:38 -0500 )edit

I'm watching all processes with looking images and image values. I didn't find anything else. I'm changing the image sizes.

OrkunK gravatar imageOrkunK ( 2015-09-19 07:49:14 -0500 )edit