Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv 3.4.2 user memory leak

i am using opencv 3.4.2, i wanted to know that if in an infinite for loop i keep on capturing images using a Mat variable frame, and after that if I do some other stuffs with that frame (like adding gaussian blur or canny filter) and save ultimately in frame, will that result into some uninitilalized memory ??

using namespace std; using namespace cv;

int main(int argc, char** argv ) {

UMat frame,gray;
VideoCapture cap(0);
if(!cap.isOpened()) 
    return -1;
for(;;) //////////////////////////////////////////////////////////////////////////
{
 cap >> frame; // get a new frame from camera

cvtColor(frame, gray, COLOR_BGR2GRAY);
GaussianBlur(gray, frame,Size(3, 3), 1.5);/////////////////////////////////////////
Canny(frame, frame, 0, 50);///// here the frame containing gaussianblur will be replaced by canny (i.e in the same memory location there will be canny frame) or the frame will be now pointing to another memory location(for canny frame), but the gaussianblur will be still there in heap memory?? 

imshow("canny", frame);
//imshow("frame", frame);
if (waitKey(30) == 27) 
   {
        cout << "esc key is pressed by user" << endl;
        break; 
   }

}//////////////////////////////////////////////////////////////////////////////

return 0;

}