这是我的情况:
- 我正在尝试使用 opencv 从一些 png 图像生成 avi 电影
- 在 Mac OSX 上使用 OpenCV 2.3.4、Python 2.7
- 程序没有错误结束,生成文件。但是不能玩。
这是代码:
    import cv 
    def make_video(nFrames):
        isColor = 1
        fps     = 1  #25 or 30, frames per second
        size = cv.GetSize(cv.LoadImage("canvas.png"))
        writer=cv.CreateVideoWriter("~/Documents/Workspace/Brief/video.avi",cv.CV_FOURCC('D','I','V','X'), fps,size,isColor)
#-----------------------------#Writing the video file:#-----------------------------
        for i in range(nFrames):    
            img = cv.LoadImage("canvas%d.png"%i) #specify filename and the extension
        cv.WriteFrame(writer,img) # add the frame to the video