Mat对象 自动分配内存 不会泄露数据 分 头部和数据部
ipllmage早期对象 需要自行分配与管理内存 导致内存泄漏
Mat对象构造函数与常用方法
常用方法:
**Mat()
Mat (int rows, int cols, int type)
Mat(ize size, in type)
Mat (int rows, int cols, int type, const Scalar 8S)
Mat (Size size, int type, const Scalar &S)
Mat (int ndims, const int ies, int type)
Mat (int ndims, const int sizes, int type, const Scalar &S)
常用方法
**
void copyTo(Mat mat) 完全复制一份
void convertTo(Mat dst, int type) 数据类型转换
Mat clone()完全复制一份
int chanels() 通道
int depth) 深度
bool empty(); 是否为空
uchar* ptr[i=0) 可不可以获取这个i(行)的指针**
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <iostream>//iostream没有后缀
#include <math.h>
using namespace cv;
using namespace std;
int main()
{
Mat src;
src = imread("D:/实验台/机器视觉/测试图片/机器人正面.jpg");
if (src.empty())//如果src这个数据库属性为空
{
cout << "无法打开" << endl;
return -1;
}
namedWindow(