Image matching with real-time video

please make it a habit to check the output from imread() or cap.read() like:

if (np.shape(img)==())
     break # read fail, invalid data