Ask Your Question
1

cvCvtColor Memory usage

asked Aug 8 '12

ocli5568 gravatar image

Hello,

I am running a program that requires continuous usage of the cvCvtColor() method, however only once per iteration (approximately 100 hz). The usage is simple, I have two IplImage* variables, imageBGR and imageHSV where the BGR is converted to HSV by;

IplImage* imageBGR,imageHSV;
imageBGR = imread("blah.jpeg",3);
cvCvtColor(imageBGR, imageHSV, CV_BGR2HSV);

When I run the program, with nothing else in the background, cvCvtColor() continuously consumes about 10 MB every 5 seconds, accruing memory.

Does anyone know a solution, or heard of this problem before?

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Aug 8 '12

Michael Burdinov gravatar image

cvtColor itself don't need temporary memory. The only memory it may allocate is the memory for output image, if it is not allocated (or it is allocated, but has different size). From what I see in your code that is the case. Do you release the memory used by those images when they are not needed anymore? If no, that is the source for your memory leak. Then you should release this memory yourself or use Mat instead of IplImage* (Mat has reference counting and will release the memory when it is not needed anymore). I recommened second option.

Just out of curiosity, why do you use value '3' in your imread function?

Preview: (hide)

Question Tools

Stats

Asked: Aug 8 '12

Seen: 1,992 times

Last updated: Aug 08 '12