最近在学Opencv,但是图像算法实在是把我爆出翔来了,以前数学不差,但是也忘得差不多了,恶补中,闲暇之余突然发现OpenCV的视频播放功能,支持格式很多啊,不防做一个学习版的纯视频播放软件,还可以顺便练手opencv,哈哈那么下面直接上效果图。源码下载: http://download.youkuaiyun.com/detail/lightspear/9761702
说下这个工程的注意点吧。
1:opencv 2.4.10默认已编译的版本是vc10,vc11,vc12,没有vc9也就是VS2008的版本,所以首先得编译源码。当然为了避免大家麻烦我已经编译好了这个windows版本的适用VS2008版本的opencv库,放在源码工程旁边。
2:这里面用到了一些mfc的插件也就是进度条那个,有兴趣可以看看。
3:主要实现了倍速播放,进度条拖动啊之类
4:如果编译不过,最好自行检查一下库还有lib的引用入境
贴一下关键点代码吧,利用opencv的VideoCapture类的
5:opencv里面其实用到了ffmpeg所以这个opencv_ffmepg.dll一定要考过去
read //读取视频流一次帧
open //打开播放文件
set //设置播放进度
class CV_EXPORTS_W VideoCapture
{
public:
CV_WRAP VideoCapture();
CV_WRAP VideoCapture(const string& filename);
CV_WRAP VideoCapture(int device);
virtual ~VideoCapture();
CV_WRAP virtual bool open(const string& filename);
CV_WRAP virtual bool open(int device);
CV_WRAP virtual bool isOpened() const;
CV_WRAP virtual void release();
CV_WRAP virtual bool grab();
CV_WRAP virtual bool retrieve(CV_OUT Mat& image, int channel=0);
virtual VideoCapture& operator >> (CV_OUT Mat& image);
CV_WRAP virtual bool read(CV_OUT Mat& image);
CV_WRAP virtual bool set(int propId, double value);
CV_WRAP virtual double get(int propId);
protected:
Ptr<CvCapture> cap;
};