Skip to content

Instantly share code, notes, and snippets.

@stokasto
Created February 9, 2012 10:44
Show Gist options
  • Select an option

  • Save stokasto/1779208 to your computer and use it in GitHub Desktop.

Select an option

Save stokasto/1779208 to your computer and use it in GitHub Desktop.
convert video to numpy array
from numpy import *
import cv
capture = cv.CaptureFromFile('video.mov')
frames = []
for i in range(100):
img = cv.QueryFrame(capture)
tmp = cv.CreateImage(cv.GetSize(img),8,3)
cv.CvtColor(img,tmp,cv.CV_BGR2RGB)
frames.append(asarray(cv.GetMat(tmp)))
frames = array(frames)
@Joejnth
Copy link
Copy Markdown

Joejnth commented Jan 6, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment