資源簡介
【核心代碼】
#include <iostream>
#include "cv.h"
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
// 描述:將視頻幀轉成圖片輸出
int main()
{
// 獲取視頻文件
VideoCapture cap("D:\\qt\\opencv_example\\mouse_detection_sysu\\mouse_detection\\5-20190731_170216.mp4");
// 獲取視頻總幀數
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");
// 設置每30幀獲取一次幀
if (currentFrame % 50 == 0){
// 將幀轉成圖片輸出
imwrite("D:\\qt\\opencv_example\\untitled2\\images\\" str.str(), frame);
num ;
}
// 結束條件
if (currentFrame >= totalFrameNumber){
flags = false;
}
currentFrame ;
}
return 0;
}
代碼片段和文件信息
#include?
#include?“cv.h“
#include?“opencv2/opencv.hpp“
using?namespace?std;
using?namespace?cv;
//?描述:將視頻幀轉成圖片輸出
int?main()
{
????//?獲取視頻文件
????VideoCapture?cap(“D:\\qt\\opencv_example\\mouse_detection_sysu\\mouse_detection\\5-20190731_170216.mp4“);
????//?獲取視頻總幀數
????long?totalframeNumber?=?cap.get(CV_CAP_PROP_frame_COUNT);
????cout?<“total?frames:?“?<ameNumber?<
????Mat?frame;
????bool?flags?=?true;
????long?currentframe?=?0;
????int?num=201;
????while?(flags){
????????//?讀取視
- 上一篇:qt源碼ftp文件上傳
- 下一篇:qt寫掃雷程序
評論
共有 條評論
相關資源
- 藍牙串口通信(源碼+視頻)
- directx實現正方體圖片映射
- 將音視頻文件轉換為rtsp流(live555 媒
- 音視頻開發進階指南:基于Android與
- 基于Qt Phonon實現的視頻播放器,簡單
- opencv:視頻圖片相互轉換程序
- VC++圖片控件(Picture Control)顯示資源
- 用opencv處理RTSP視頻流,其中視頻流的
- ffmpeg視頻生成jpg圖片
- 圖片位深度轉換
- MFC圖片操作(PRO5_PNGDlg.cpp)
- C++實戰源碼-圖片的平滑縮放
- C++實戰源碼-圖片縮放
- C++實戰源碼-圖片剪切
- C++實戰源碼-向Word文檔中插入圖片
- C++實戰源碼-提取圖片中的對象
- C++實戰源碼-瀏覽大幅BMP圖片
- C++實戰源碼-管理計算機內圖片文件的
- C++實戰源碼-成組瀏覽圖片
- C++實戰源碼-圖片自動預覽程序
- C++實戰源碼-根據圖片大小顯示的窗體
- C++實戰源碼-可以顯示圖片預覽的“打
- C++實戰源碼-去除橢圓下圖片內容
- C++實戰源碼-垂直百葉窗顯示圖片
- C++實戰源碼-在視圖中拖動圖片
- C++實戰源碼-在編輯框中插入圖片數據
- C++實戰源碼-水平百葉窗顯示圖片
- C++實戰源碼-屏保方式瀏覽圖片
- C++實戰源碼-如何在圖片上平滑移動文
- C++ 顯示剪貼板中的圖片數據