ofxCV - Video processing. When allocating images

Hi,

I’m using openCv on of for do some video processing. In the openCv example all images used for background subtraction are allocated at setup. I was wondering if in terms of speed - memory if it’s better to allocate all images needed at startup or doing it locally each time a frame is new.

thanks

leo

at setup

fast and effective:)

the problem arose since I needed many images for a color based detection, so involving a mask for each hue saturation and value channels, so no matter how many are needed it’s always better to declare them an setup right?

thanks!

I wouldn’t say “always” as it depends on how much RAM you have, other processes you are doing, etc. Another approach is Object Pooling (I would think in your case it would be a vector of CvImages) where you allocate a bunch of them but still have the option of creating more later if necessary.

Here is a good starter thread weighing some benefits:
http://stackoverflow.com/questions/1250983/object-pool-vs-dynamic-allocation

many thanks! I’ll check it out

Leo