#include"opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include<iostream>
#include<fstream>
using namespace std;
//g 全局的标识
int g_slider_position = 0;//存储滑动条的位置
int g_run = 1, g_dontest = 0;//start out in single step mode
cv::VideoCapture g_cap;//帧读数结构,因回调函数需要访问,所以设置为全局
void onTrackbarSlide(int pos, void *)//回调程序
{
g_cap.set(cv::CAP_PROP_POS_FRAMES, pos);//将进度条移动到位置
if (!g_dontest)//触发滑动条事件,进入单步模式
g_run = 1;
g_dontest = 0;
}
int main()
{
cv::namedWindow("helloworld", cv::WINDOW_AUTOSIZE);
g_cap.open("F:/...");
//确定总帧数及视频的高和宽
int frames = (int)g_cap.get(cv::CAP_PROP_FRAME_COUNT);
int tmpw = (int)g_cap.get(cv::CAP_PROP_FRAME_WIDTH);
int tmph = (int)g_cap.get(cv::CAP_PROP_FRAME_HEIGHT);
cout << "video have" << frames << "frames of dimensions("
<< tmpw << "," << tmph << ")." <
一起学习opencv (2)一个带滑动条的视频播放器
最新推荐文章于 2024-07-04 10:08:55 发布