c++和opencv视频的读写

python 的视频读写:

cap = cv2.VideoCapture(path)

while cap.isOpened():

    ret,img = cap.read()

#==================

fourcc = cv2.VideoWriter(*'XVID')

out = cv2.VideoWriter('/home/video_test/test.avi',fourcc,20,(640,480))

out.write(frame)


c++的视频读写

VideoCapture capture("E:\\darkness.avi");

if (capture.isOpened()){

    while(1){

        capture>>frame;

        if (frame.empty()) break;

    }

}

//=====================

cv::VideoWriter out;

out.open("my_video2.avi", CV_FOURCC('M', 'J', 'P', 'G'), // MPEG-4 编码
30.0, // 帧率 (FPS)
cv::Size(704, 576), //这里和read进来的frame大小不同时会报错
true // 只输入彩色图

);

out<



你可能感兴趣的:(opencv)