import cv2 ram_frames=30 cam = cv2.VideoCapture(0) def get_image(): cap = cam.read() return cap for i in xrange(ramp_frames):
if np.any( initial == None): #your code It will definitely work for you. The error in this code because initial is treated as a numpy array.
I initialized initial with None in my program