title: attributeError:'numpy.ndarray' object has no attribute 'read'
body: <p>i have been written a program in python for first averaging a video and then perform background subtraction to detect an unattended object in the video.but it shows some error.is there anybody to help me to solve this problem by correcting my program.i posted my program here.or anybody have any other codes for doing the same problem,please send me the code.my mail id is vishnuke143@gmail.com.thank you.</p>
  
  <p>program:-</p>
  
  <pre><code>import numpy as np
  import cv2
  
  cap = cv2.VideoCapture(0)
  _,f=cap.read()
  avg=np.float32(f)
  
  count=1
  while 1:
          _,f=cap.read()
          cv2.accumulateWeighted(f,avg,0.01)
          res=cv2.convertScaleAbs(avg)
          cv2.imshow('img',f)
          cv2.imshow('avg',res)
          cv2.waitKey(0)
          _, frame =res.read()
  
          gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
          pix = np.array(gray);
  
          #cv2.imshow('gray',gray)
          #cv2.waitKey(0)
          #cv2.destroyAllWindows()
          if count==1:
              bckgnd=gray
              count=0
  
          change=abs(np.double(gray)-np.double(bckgnd))
          ch=abs(gray-bckgnd)
          pix = np.array(change)
          maxval=np.amax(pix)
          #print maxval
          #cv2.imshow('gray',ch)
          #cv2.waitKey(0)
          #cv2.destroyAllWindows()
          if maxval&gt;100:
              thresh=maxval/2
          else:
              thresh=255
          ret,thresh4 = cv2.threshold(ch,thresh,255,cv2.THRESH_BINARY)    
  
          cv2.imshow('gray',thresh4)
  
          output = cv2.connectedComponentsWithStats(thresh4, 4, cv2.CV_32S)
          num_labels=output[0]
          labels=output[1]
          stats=output[2]
          centroids=output[3]
          print num_labels
          k = cv2.waitKey(30) &amp; 0xff
          if k == 27:
              break   
  </code></pre>