首先在这边说明一下为什么要写这个,因为在网上都是使用opencv1的代码,个人感觉有点过时,现在大家基本上都是用opencv2或者opencv3,而库基本上都是用opencv2的库。
首先我们要先将环境安装好:
- 安装opencv,链接地址如下:https://opencv.org/downloads.html
- 安装qt,我个人是安装比较新的qt5.6.0,链接地址如下:http://download.qt.io/archive/
- 配置环境,这个这边不作说明,网上资料一大堆,方法也满天飞,大家自行百度
在ui界面上放两个labeltext,以及三个简单的pushbutton
编辑opencam.h文件:
#ifndef OPENCAM_H
#define OPENCAM_H
#include <QWidget>
#include <QImage>
#include <QTimer>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
namespace Ui {
class opencam;
}
class opencam : public QWidget
{
Q_OBJECT
public: