Memory leak while using Mat [closed]
Hi all,
I'm new to OpenCV and I'm using OpenCV 2.49 libraries in my application. The objective of my application is to run in background, take pictures using web cam and save it as a BMP image in HDD. I've implemented it with openCV as follows,
VideoCapture camera(nCamera);
Mat frame;
bool bSuccess = camera.read(frame);
camera.set(CV_CAP_PROP_FRAME_WIDTH, m_nX);
camera.set(CV_CAP_PROP_FRAME_HEIGHT, m_nY);
bSuccess = camera.read(frame);
IplImage *img = new IplImage(frame);
//Convert to HBITMAP and write timestamp on the image
HBITMAP hbitmap = IplImage2DIB(img);
// Draw the timestamp
//Save the image as BMP
delete img;
I have following queries,
The memory profile of my application increases at every picture taken. With the initial analysis shows that the memory leaks at openCV structure. Kindly help me resolve this.
Always the picture captured comes darker, if i take consecutive pictures only first picture is darker and the other comes normal. Why it is like this. Is there any setting i need to configure to correct it?
Are there any built in functions available in openCV to draw/write on the image taken?
Is it possible to save the frame as JPEG or BMP using OpenCV?
With the hope that some expert in openCV wil help me.
Thanks, RMK
I don't know opencv 2.4.9 (i'm not an expert only I have read the documentation only) but after a quick reading of doc 2.4.11 may be you can use
About memory leaks I haven't got any idea
Your biggest problem is 2.4.9. We have moved on and so should you, because 2.4.11 because tons of extra fixes. As long as your problem of memory leaks does not happen there, people will not try to fix old versions of the library. Also using
IplImage *img = new IplImage(frame);
is just horrible in the 2.4.9 interface. Please use the corresponding C++ functions.