91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.11KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-02-23
  • 標簽: 視頻??圖片??

資源簡介

【實例簡介】使用opencv將視頻轉(zhuǎn)圖片

【核心代碼】

#include <iostream>
#include "cv.h"
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

// 描述:將視頻幀轉(zhuǎn)成圖片輸出
int main()
{
    // 獲取視頻文件
    VideoCapture cap("D:\\qt\\opencv_example\\mouse_detection_sysu\\mouse_detection\\5-20190731_170216.mp4");

    // 獲取視頻總幀數(shù)
    long totalFrameNumber = cap.get(CV_CAP_PROP_FRAME_COUNT);
    cout << "total frames: " << totalFrameNumber << endl;

    Mat frame;
    bool flags = true;
    long currentFrame = 0;
    int num=201;
    while (flags){
        // 讀取視頻每一幀
        cap.read(frame);

        stringstream str;
        str << num << ".jpg";
        cout << "正在處理第" << currentFrame << "幀" << endl;
        printf("\n");

        // 設(shè)置每30幀獲取一次幀
        if (currentFrame % 50 == 0){
            // 將幀轉(zhuǎn)成圖片輸出
            imwrite("D:\\qt\\opencv_example\\untitled2\\images\\" str.str(), frame);
            num ;
        }
        // 結(jié)束條件
        if (currentFrame >= totalFrameNumber){
            flags = false;
        }
        currentFrame ;

    }

    return 0;
}


資源截圖

代碼片段和文件信息

#include?
#include?“cv.h“
#include?“opencv2/opencv.hpp“

using?namespace?std;
using?namespace?cv;

//?描述:將視頻幀轉(zhuǎn)成圖片輸出
int?main()
{
????//?獲取視頻文件
????VideoCapture?cap(“D:\\qt\\opencv_example\\mouse_detection_sysu\\mouse_detection\\5-20190731_170216.mp4“);

????//?獲取視頻總幀數(shù)
????long?totalframeNumber?=?cap.get(CV_CAP_PROP_frame_COUNT);
????cout?<ames:?“?<ameNumber?<
????Mat?frame;
????bool?flags?=?true;
????long?currentframe?=?0;
????int?num=201;
????while?(flags){
????????//?讀取視

評論

共有 條評論