使用开源库(OpenCV)实现视频的倒播

直接上代码:

#include "opencv2/core/utility.hpp"
#include "opencv2/core/ocl.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"

#include 
#include 
using namespace cv;

int main(int argc, char* argv[])
{
	CvCapture* cap = cvCreateFileCapture("E:\\mycode\\LiveCompile\\x64\\Release\\Titanic.mkv");

	cvNamedWindow("image", 1);
	int nCount = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_COUNT);
	int staticCount = nCount;
	IplImage *pImg;
	while (1)
	{
		cvSetCaptureProperty(cap, CV_CAP_PROP_POS_FRAMES, nCount--);//指定当前帧的位置,每次都是上一帧
		pImg = cvQueryFrame(cap);

		cvShowImage("image", pImg);
		cv::waitKey(1000/25);
		if (nCount == 0)
			nCount = staticCount;
	}

	return 0;
}
加QQ群一起交流学习音视频开发:476513431

你可能感兴趣的:(C++探究,C++探究,OpenCV,图片合成,图像识别)