# Revision history [back]

### how can i save the processed video as image sequence exactly as seen after processing

I used averaging algo to remove foreground. Now i want to save the output as the image sequence exactly as seen in #cv2.imshow('window_name',res2). i tried but not getting any result

   c= cv2.VideoCapture("p3.avi")

avg1 = np.float32(f)
avg2 = np.float32(f)

try:
if not os.path.exists('data2'):
os.makedirs('data2')
except OSError:
print ('Error: Creating directory of data')

currentFrame = 0

while(1):

cv2.accumulateWeighted(f,avg1,0.1)
cv2.accumulateWeighted(f,avg2,0.01)

res1 = cv2.convertScaleAbs(avg1)
res2 = cv2.convertScaleAbs(avg2)

#cv2.imshow('img',f)

#cv2.imshow('avg1',res1)
#cv2.imshow('avg2',res2)

name = './data/frame' + str(currentFrame) + '.jpg'
cv2.imwrite(name, res2)

#frame_no=7800
#c.set(1,frame_no); # Where frame_no is the frame you want