0

VideoReader is very convenient for reading and playing videos. But, I haven't found something equivalent for Python yet though I have tried using OpenCV for this purpose.

import cv2

cap = cv2.VideoCapture('F:/OpenWorm/Omega_data/videos/super_orange/super_orange.avi')

while(cap.isOpened()):
    ret, frame = cap.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

2 Answers2

2

You should really look at the openCV framework. It is the standard library for video and image processing (written in C++ but has good python support), and is much faster than Matlab's VideoReader.

blue_note
  • 27,712
  • 9
  • 72
  • 90
1

I found the answer here:OpenCV 2.4 VideoCapture not working on Windows

As I was using OpenCV 3.00 I thought that I had to copy the opencv_ffmpeg.dll from
C:\OpenCV\3rdparty\ffmpeg\ to C:\Python27. But, this wasn't enough.

I had to rename the dll to opencv_ffmpeg3.dll

Community
  • 1
  • 1