Skip to content

Instantly share code, notes, and snippets.

@stokasto
Created February 9, 2012 10:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokasto/1779208 to your computer and use it in GitHub Desktop.
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)
@saquibntt
Copy link

Hi,

I have tried to show the frames using matplotlib but facing issues with the size. Is there a better way to display the frames?

Thanks

@Joejnth
Copy link

Joejnth commented Jan 6, 2023

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