OpenCV Python QueryFrame Function Leaks Memory
I'm using the Python interface for OpenCV 2.2.0. The following code works correctly for grabbing frames from a video file: for f in range(1, frameCount): # grab the left and ri
Solution 1:
You should allocate memory for both images once: imageL = cv.CreateImageHeader(cv.GetSize(frameL), frameL.depth, frameL.channels) imageR = cv.CreateImageHeader(cv.GetSize(frameR), frameR.depth, frameR.channels)
then begin your loop and set the data:
cv.SetData(frameL, imageL)
cv.SetData(frameR, imageR)
so something like
for f in range(1, frameCount):
# grab the left and right frames
frameL = cv.QueryFrame(videoL)
frameR = cv.QueryFrame(videoR)
# create the image for the first frame
if f==1:
imageL = cv.CreateImageHeader(cv.GetSize(frameL), frameL.depth, frameL.channels)
imageR = cv.CreateImageHeader(cv.GetSize(frameR), frameR.depth, frameR.channels)
# update the images
cv.SetData(frameL, imageL)
cv.SetData(frameR, imageR)
Post a Comment for "OpenCV Python QueryFrame Function Leaks Memory"