Ask Your Question
1

cvCvtColor Memory usage

asked 2012-08-08 04:38:00 -0600

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-08-08 05:16:35 -0600

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?

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-08 04:38:00 -0600

Seen: 1,842 times

Last updated: Aug 08 '12