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;
}
when using UMat's you should not do operations in-place. please use a new UMat header for the results
i would like to known that if i am doing some inplace operation in UMat, will that result into some intermediate outputs , that will be there in the memory but not accessible??
don't use the same UMat for src and dst.
and the same is valid for Mat also??