Ask Your Question

Bob H's profile - activity

2016-11-09 12:45:12 -0600 commented question imread problem

I am doing a debug build. Linking the debug OpenCV libraries with the debug build results in the memory leaks. Linking the release OpenCV libraries with the debug build does not result in memory leaks. But then the imread function does not return an image that way, and cvLoadImage does return an image and no memory leaks.

2016-11-09 12:15:30 -0600 commented question imread problem

Just to add a little more. I went back and used the C Version (cvLoadImage with IplImage). It loaded the image, but had the same memory leaks with the debug libraries. Changed back to the release libraries, and it still loads the image just fine but doesn't have the memory leaks. Also tried cvLoadImageM with CvMat. Same result as the cvLoadImage. Things now work. So imread and the debug libraries seem to be the problems.

2016-11-09 11:39:04 -0600 commented question imread problem

I first tried the tutorial with a console application. With the debug libraries it worked. Same code embedded in an MFC application resulted in numerous memory leaks. Don't know what you have against MFC. I have programmed with it for many years quite successfully. I have developed a number of successful Image and video processing codes that way using Intel's IPP. When I started with video processing, OpenCV didn't have much functionality. But I thought I'd give it another try. However, even things that should be easy, seem to be not so easy.

2016-11-09 01:41:56 -0600 asked a question imread problem

Having problem with imread. So I tried the code from the tutorial. Still didn't work. (Image was empty) Changed the libraries to the debug version. Now the tutorial version worked. Using VisualStudio 2012. Tried to embed the same code in an MFC application. Seems to work with the debug libraries. But when I close the program, I get a huge number of memory leaks. Commented out the imread, and the number of memory leaks decreased substantially. Commented out the Mat declaration for the image, and all the memory leaks go away. Just having the Mat declared gives me memory leaks. Using it causes even more memory leaks. There must be some way to destruct the Mat image at program termination to not have any memory leaks. Anybody have any ideas?

2016-11-04 16:07:02 -0600 commented question I am having trouble deleting a video capture object in C++.

btw: I was doing serious scientific programming before C was anything other than just another letter in the alphabet, yet alone C++. Yes you can pass by reference, but most parameter passing that I have seen in various libraries is done by passing pointers for anything other that a simple variable.

2016-11-04 16:03:26 -0600 commented question I am having trouble deleting a video capture object in C++.

The code was developed in Visual Studio 2012 using MFC and the document/view architecture. So there is probably too much extraneous code to include here. But here are the relevant bits. In Doc.h the video object is declared as a pointer VideoCapture* capture; Mat* Image; In the Doc.cpp constructor capture=NULL; Image=NULL; in Doc.cpp ::Initialize capture=new VideoCapture; Image=new Mat; inL=capture->open(0); if(capture->isOpened() { Width=(int)capture->get(CV_CAP_PROP_FRAME_WIDTH); ... } In Doc.cpp ::ProcessFrame() capture->read(*Image); In Doc.cpp destructor if(capture->isOpened()) { capture->release(); } if(capture) { delete capture; } There are a couple of other classes where capture->isOpened() is checked, but that is it.

2016-11-04 13:52:51 -0600 commented question I am having trouble deleting a video capture object in C++.

Don't use pointers in C++??? How do you pass objects between different methods and classes? Passing a pointer is a whole lot more efficient than passing the complete object. I want to use the VideoCapture object in several of the methods. I would much rather pass a pointer than the object itself. If you can't create a new object, use it and then delete it, it would seem there is a bug in OpenCV.

2016-11-04 00:49:42 -0600 asked a question I am having trouble deleting a video capture object in C++.

I define the video capture as a pointer VideoCapture* capture; I then initialize the pointer to null in the constructor capture=NULL; When ready to use it i initialize it capture=new VideoCapture; I can then use it and read a camera just fine. When I am ready to close out the program I release it If(capture->IsOpened) capture->release; This works.
However when I go to delete the capture object, I doesn't work, and I get an error if(capture) delete capture; If I don't try to delete it, I get a memory leak If I try to delete it without releasing it, I get errors If I don't try to release it or delete it, I get errors. Does anybody have an idea of how to release it and delete it without getting a bunch of errors?