滑块处理
通过调用函数接口实现视频播放的快进和倒退,源码如下:
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<iostream>
#include<fstream>
int gsliderPosition = 0;
int grun = 1;
int gdontset = 0;
cv::VideoCapture gcap;
void onTrackSlider(int pos,void*)
{
gcap.set(cv::CAP_PROP_POS_FRAMES, pos);
if (!gdontset)
grun = 1;
gdontset = 1;
}
int main(int argc, char** argv)
{
std::string windowName("Example4");
cv::namedWindow(windowName, cv::WINDOW_AUTOSIZE);
gcap.open(std::string(argv[1]));
int frames = (int)gcap.get(cv::CAP_PROP_FRAME_COUNT);
int tmpw = (int)gcap.get(cv::CAP_PROP_FRAME_WIDTH);
int tmph = (int)gcap.get(cv::CAP_PROP_FRAME_HEIGHT);
std::cout << "videos has" << frames << "frames of dimension(" << tmpw <<
"," << tmph << ")." << std::endl;
cv::createTrackbar("posi