Memory leaking c++ w/VS12

asked 2018-06-19 16:37:03 -0600

updated 2018-06-20 00:25:52 -0600

Hello everyone,

I am trying to create a simple program to load an image (6398*1080) and have it shown the portion of monitor by defining a sub-image, and the location of sub-image will be changing regarding to time This is to create the motion of image-sliding, just like the sliding animation in power point. However, there seems to be an memory leaking and crashes at halfway of the program (the beginning part is fine), the error is "Unhandled exception at at 0x00007FFBDAB8A388 in opencv.exe: Microsoft C++ exception: cv::Exception at memory location 0x0000005E07F7F5F0.". Your help are very appreciated!! The code is here.

#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <iostream> 
using namespace cv; 
using namespace std; 

int main( ) {

       Mat image = imread("Image1.jpg", CV_LOAD_IMAGE_COLOR);   
       for(int i=0;i<4478;i++)
       {
       Mat subImage(image, cv::Rect(i, 0, 1920+i,1080));
        //DISPLAY image
       namedWindow( "window",CV_WINDOW_NORMAL);
       setWindowProperty("window", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
       moveWindow("window", 1919,0);
       imshow( "window", subImage ); 

       waitKey(1);                       
       }
       return 0;
}
edit retag flag offensive close merge delete

Comments

cv::Rect(i, 0, 1920+i,1080) <-- that looks broken. you're not only moving the window, it gets wider with every step.

berak gravatar imageberak ( 2018-06-20 00:32:11 -0600 )edit

Then could tell me how to fix it?

wenbwang gravatar imagewenbwang ( 2018-06-22 15:03:58 -0600 )edit