1,imread函数:图片读取
CV_EXPORTS_W Mat imread( const String& filename, int flags = IMREAD_COLOR );//参数1(filename):文件地址
//参数2(flags):读取标志
注:ImreadModes,参数2(flags)枚举定义
enum ImreadModes {IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single .........};
2,imwrite函数:图片保存
CV_EXPORTS_W bool imwrite( const String& filename, InputArray img,const std::vector<int>& params = std::vector<int>());//参数1(filename):文件地址
//参数2(img):图片数据
//参数3(params ):为特定格式保存的参数编码
注:ImwriteFlags ,参数3(params)枚举定义
enum ImwriteFlags {IMWRITE_JPEG_QUALITY = 1, //!< For JPEG, it can be a quality from 0 to 100 (the higher is the better). Default value is 95.IMWRITE_JPEG_PROGRESSIVE = 2, //!< Enable JPEG features, 0 or 1, default is False........};
3,imshow函数:图片显示
CV_EXPORTS_W void imshow(const String& winname, InputArray mat);//参数1(winname):窗口名称
//参数2(img):图片数据
4,cvtColor函数:颜色空间转换
实现RGB颜色空间转HSV/HSI/灰度等颜色空间。
CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn = 0 );//参数1(src):原图
//参数2(dst):处理后的图
//参数3(code):颜色空间转换标识符
//参数4(dstCn):处理后图片的通道数,=0,则和原图相同。
注:ColorConversionCodes ,参数3(code)对应枚举定义
enum ColorConversionCodes {COLOR_BGR2BGRA = 0, //!< add alpha channel to RGB or BGR imageCOLOR_RGB2RGBA = COLOR_BGR2BGRA,......
};
5,ellipse函数:画椭圆
两个重载函数
函数1:
CV_EXPORTS_W void ellipse(InputOutputArray img, Point center, Size axes,double angle, double startAngle, double endAngle,const Scalar& color, int thickness = 1,int lineType = LINE_8, int shift = 0);//参数1(img):待绘制的图像
//参数2(center):椭圆中心点
//参数3(axes):长短轴尺寸
//参数4(angle):角度
//参数5(startAngle) :弧度段起始角度
//参数6(endAngle) :弧度段结束角度
//参数7(color):椭圆颜色
//参数8(thickness ):画笔线宽
//参数9(lineType ):画笔线类型
//参数10(shift ):绘制精度,默认为0(单精度)
注:startAngle=0,endAngle=360,整个椭圆
函数2:
CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color,int thickness = 1, int lineType = LINE_8);//参数1(img):待绘制的图像
//参数2(center):椭圆的形状,RotatedRect,有三个属性:angle center size
//参数3(color):椭圆颜色
//参数4(thickness ):线宽
//参数5(lineType ):线类型
注:LineTypes 线类型枚举定义
enum LineTypes {FILLED = -1,LINE_4 = 4, //!< 4-connected lineLINE_8 = 8, //!< 8-connected lineLINE_AA = 16 //!< antialiased line
};
6,circle函数:画圆
CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius,const Scalar& color, int thickness = 1,int lineType = LINE_8, int shift = 0);//参数1(img):待绘制的图像
//参数2(center):圆心坐标
//参数3(color):圆的半径
//参数4(color):椭圆颜色
//参数5(thickness ):画笔线宽
//参数6(lineType ):画笔线类型
//参数7(shift ):绘制精度,默认为0(单精度)
注:thickness =-1,为实心圆
7,fillPoly函数:画多边形
两个重载函数
函数1:
CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts,const Scalar& color, int lineType = LINE_8, int shift = 0,Point offset = Point() );//参数1(img):待绘制的图像
//参数2(pts):顶点集
//参数3(color):椭圆颜色
//参数4(lineType ):画笔线类型
//参数5(shift ):绘制精度,默认为0(单精度)
//参数6(offset ):绘制的偏移量,默认为(0,0)
函数2:
CV_EXPORTS void fillPoly(InputOutputArray img, const Point** pts,const int* npts, int ncontours,const Scalar& color, int lineType = LINE_8, int shift = 0,Point offset = Point() );//参数1(img):待绘制的图像
//参数2(pts):顶点集
//参数3(npts):多边形顶点数
//参数4(ncontours):多边形数量
//参数5(color):椭圆颜色
//参数6(lineType ):画笔线类型
//参数7(shift ):绘制精度,默认为0(单精度)
//参数8(offset ):绘制的偏移量,默认为(0,0)
8,line函数:画线
CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,int thickness = 1, int lineType = LINE_8, int shift = 0);
//参数1(img):待绘制的图像
//参数2(pt1):线起点
//参数3(pt2):线终点
//参数4(color):线颜色
//参数5(thickness ):画笔线宽
//参数6(lineType ):画笔线类型
//参数7(shift ):绘制精度,默认为0(单精度)
9,LUT函数:查表
查表变换,用于大数据图像的图元进行批量操作,牺牲空间换取时间
CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);
//参数1(src):原图
//参数2(lut):表
//参数3(dst):处理后的图
10,getTickCount函数:获取电脑当前时钟数
CV_EXPORTS_W int64 getTickCount();
11,getTickFrequency函数:获取CPU,1秒的走过的时钟周期
CV_EXPORTS_W double getTickFrequency();//double start = cv::getTickCount();
//double interval = cv::getTickCount() - start;
//double second=interval / cv::getTickFrequency(); // 结果单位:秒
12,addWeighted函数:图像混合
CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2,double beta, double gamma, OutputArray dst, int dtype = -1);
//参数1(src1):图像1
//参数2(alpha):图像1权重
//参数3(src2):图像2
//参数4(beta):图像2权重
//参数5(gamma):加到权重总和上的值
//参数6(dst):处理后图像
//参数7(dtype ):图像深度,-1和图像1的深度相同
//输出图像图元i,dst[i] = src1[i] * alpha + src2[i ] * beta + gamma;
注:图像1(src1)和图像2(src2)类型和尺寸需要相同
13,split函数:通道分离
CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv);//参数1(m):多通道图像
//参数2(mv):单通道图像数组
14,merge函数:通道合并
CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst)//参数1(mv):单通道图像数组
//参数2(m):多通道图像