I'm very interested in this code below taken from[this page] (http://opencvpython.blogspot.in/2012/07/background-extraction-using-running.html)
I try and run it but get the error:
cv2.accumulateWeighted(f,avg1,0.1)
TypeError: dst is not a numpy array, neither a scalar
1) I'm running opencv2 but is this code only for open cv3?
I go to this page to find out if individual lines are opencv 2 or 3, but it doesn't tell me.
2) If this code is for opencv3 is there something similar for opencv 2 or a good examples page for opencv2?
3) Is there any documentation that would enable me to check if individual lines of code are 2 or 3, because I don't want to debug code that will never work on my system, because I have the wrong version of opencv installed.
4) can I have opencv2 and 3 installed on my machine, or if I have opencv3 do I need opencv2 at all?
import cv2
import numpy as np
c = cv2.VideoCapture(0)
_,f = c.read()
avg1 = np.float32(f)
avg2 = np.float32(f)
while(1):
_,f = c.read()
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)
k = cv2.waitKey(20)
if k == 27:
break