cygwin_exception::open_stackdumpfile: Dumping stack trace to myfile.exe.stackdump [closed]

asked 2017-09-15 13:43:07 -0500

baravunuw gravatar image

when I tried to src->release(), I have an error, src->deallocate() is ok, src->deallocate() trow error too. Whats wrong?

int w::getAScreenshotAndFindAPicture(int x, int y, int x2, int y2, const char* c){
    cv::Mat* src = this->getScreenshot(x, y, x2, y2);
    cv::cvtColor(*src, *src, cv::COLOR_RGBA2RGB, 0);
    IplImage* img = new _IplImage(*src);
    IplImage* imgTemplates = cvLoadImage(c, 1);
    IplImage* imgResult = cvCreateImage(cvSize(img->width - imgTemplates->width + 1, img->height - imgTemplates->height + 1), 32, 1);
    cvMatchTemplate(img, imgTemplates, imgResult, 1);
    double minval, maxval;
    CvPoint minLoc, maxLoc;
    cvMinMaxLoc(imgResult, &minval, &maxval, &minLoc, &maxLoc);
//  src->deallocate();
//  delete src;

    std::cout <<"k" <<std::endl;;
    return maxval - minval;

cv::Mat* w::getScreenshot(int x, int y, int width, int height){
    HDC hwindowDC,hwindowCompatibleDC;
    HBITMAP hbwindow;
    cv::Mat* src = new cv::Mat();



    // create a bitmap
    hbwindow = CreateCompatibleBitmap( hwindowDC, width, height);
    bi.biSize = sizeof(BITMAPINFOHEADER);    //
    bi.biWidth = width;
    bi.biHeight = -height;  //this is the line that makes it draw upside down or not
    bi.biPlanes = 1;
    bi.biBitCount = 32;
    bi.biCompression = BI_RGB;
    bi.biSizeImage = 0;
    bi.biXPelsPerMeter = 0;
    bi.biYPelsPerMeter = 0;
    bi.biClrUsed = 0;
    bi.biClrImportant = 0;

    // use the previously created device context with the bitmap
    SelectObject(hwindowCompatibleDC, hbwindow);
    // copy from the window device context to the bitmap device context
    StretchBlt( hwindowCompatibleDC, 0, 0, width, height, hwindowDC, x, y, width, height, SRCCOPY); //change SRCCOPY to NOTSRCCOPY for wacky colors !
    GetDIBits(hwindowCompatibleDC,hbwindow,0,height,src->data,(BITMAPINFO *)&bi,DIB_RGB_COLORS);  //copy from hwindowCompatibleDC to hbwindow

    DeleteObject (hbwindow);
    ReleaseDC(this->hwnd, hwindowDC);
    return src;
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by berak
close date 2017-09-16 03:59:16.909886


oh mercy, not opencv's dead c-api !

berak gravatar imageberak ( 2017-09-15 13:46:27 -0500 )edit

Can you help me to re-write cote to c++ api?

baravunuw gravatar imagebaravunuw ( 2017-09-15 13:51:01 -0500 )edit

most tutorial use c-api, so most of my code is writed in this style

baravunuw gravatar imagebaravunuw ( 2017-09-15 13:52:00 -0500 )edit

Maybe it is deprecated, but it works, and new c++ api does not. The problem is new cv::Mat class.

baravunuw gravatar imagebaravunuw ( 2017-09-15 14:09:30 -0500 )edit

the c-api died in 2010. please use more recent tutorials

all your problems will go away, once you drop the silly IplImage*

also, please do not use new on cv::Mat, and pass it via reference not as a pointer

berak gravatar imageberak ( 2017-09-16 03:54:00 -0500 )edit

I do not know how, but you was right, problems was solved, when I refused IplImage.

baravunuw gravatar imagebaravunuw ( 2017-09-19 12:14:36 -0500 )edit