OpenCV2 python storing frames memory leak?

asked 2014-06-28 22:13:25 -0600

bw4sz gravatar image

Hi all,

I'm doing some motion detection using the accumulated averaging technique using opencv2 and python. My script reads in a frame, compares it to the background and if there has been a threshold of movement, stores the frame to a list. I'm finding that the memory usage on storing each image seems disproportionately large, such that to hold on to 100 images, is taking 1 gb of memory. This makes little sense since written to file each image is about 120 kb.

What is the best way to store a list of images, is there a numpy approach that someone can suggest?

edit retag flag offensive close merge delete

Comments

This seems to be an ongoing issue. It would appear that the memory is not being dropped from cap.grab(). My goal using cap.grab() and not cap.read() was to skip some frames.

bw4sz gravatar imagebw4sz ( 2014-06-28 22:23:36 -0600 )edit

"since written to file each image is about 120 kb." - that's compressed, right ?

the frames you store in the array are not.100*640*480*3 = 92160000 // yea, that's a lot. with HD frames, you easily get a gigabyte there

berak gravatar imageberak ( 2014-06-29 06:54:24 -0600 )edit