opencv基本操作-视频帧提取

Opencv的图像和视频处理基本用法

http://www.coin163.com/it/x3344589589105965142/python3.4-opencv3.0

视频或者avi使用   :OpenCV-Python:摄像头/视频文件的读取、播放和保存

http://blog.topspeedsnail.com/archives/2068

c++(OpenCV学习笔记(四十七)——VideoWriter生成视频流highgui)

http://blog.csdn.net/yang_xian521/article/details/7440190

Python数据cv2.cv_fourcc与videowriter不工作


http://www.91r.net/ask/15814980.html

python-opencv将图片 / 视频帧写为视频

import cv2

fps = 24   #视频帧率
fourcc = cv2.cv.CV_FOURCC('M','J','P','G')  
videoWriter = cv2.VideoWriter('D:/testResults/match/flower2.avi', fourcc, fps, (1360,480))   #(1360,480)为视频大小
for i in range(1,300):
    p1=0
    p2=i
    img12 = cv2.imread('D:/testResults/img_'+str(p1)+'_'+str(p2)+'.jpg')
#    cv2.imshow('img', img12)
#    cv2.waitKey(1000/int(fps))
    videoWriter.write(img12)
videoWriter.release()


视频批量提取帧保存

#coding=utf-8
import cv2


vc = cv2.VideoCapture('test.avi')  # 读入视频文件
c=1
if vc.isOpened():  # 判断是否正常打开
    rval, frame = vc.read()
else:
    rval = False

timeF = 100  # 视频帧计数间隔频率

while rval:
    # 循环读取视频帧
    rval, frame = vc.read()
    #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Display the resulting frame
    cv2.imshow('frame', frame)

    if (c % timeF == 0):
        # 每隔timeF帧进行存储操作

            cv2.imwrite('image' + str(c) + '.jpg', frame)  # 存储为图像

    c = c + 1
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

vc.release()
cv2.destroyAllWindows()


你可能感兴趣的:(opencv基本操作-视频帧提取)