载入图像imread()、显示图像imshow()、保存图像imwrite().
API函数
//载入图像
Mat imread(const String& filename,//载入图像的文件路径名
int flags = IMREAD_COLOR);//标识符
//常用的标识符
//IMREAD_GRAYSCALE = 0, 转化为单通道灰度图像
//IMREAD_COLOR = 1, 默认为1,转换为3通道BGR彩色图像
//显示图像
void imshow(const String& winname, //需要显示的窗口标识名称
InputArray mat);//需要显示的图像
//保存图像
bool imwrite(const String& filename,//需要写入的文件名
InputArray img,//需要保存的图像
const std::vector<int>& params = std::vector<int>());//默认值
一、C++示例代码
包含头文件,命名空间,标配三句话
//包含头文件
#include <opencv2/opencv.hpp>
//命名空间
using namespace cv;
using namespace std;
开源代码
//包含头文件
#include <opencv2/opencv.hpp>
//命名空间
using namespace cv;
using