cv::Mat经常用到的信息
来源:互联网 发布:工商局网络与合同监管 编辑:程序博客网 时间:2024/06/07 12:43
//cv::Mat中获取图像中某一点的值是比较麻烦的,一一来探秘
//预备知识
/*
/*\typedef
access individual elements using [] operator etc.
Shorter aliases for the most popular specializations of Vec<T,n>
typedef Vec<uchar, 2> Vec2b;
typedef Vec<uchar, 3> Vec3b;
typedef Vec<uchar, 4> Vec4b;
typedef Vec<short, 2> Vec2s;
typedef Vec<short, 3> Vec3s;
typedef Vec<short, 4> Vec4s;
typedef Vec<ushort, 2> Vec2w;
typedef Vec<ushort, 3> Vec3w;
typedef Vec<ushort, 4> Vec4w;
typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<int, 4> Vec4i;
typedef Vec<int, 6> Vec6i;
typedef Vec<int, 8> Vec8i;
typedef Vec<float, 2> Vec2f;
typedef Vec<float, 3> Vec3f;
typedef Vec<float, 4> Vec4f;
typedef Vec<float, 6> Vec6f;
typedef Vec<double, 2> Vec2d;
typedef Vec<double, 3> Vec3d;
typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d;
----------------------imread,第二个参数------------------------
enum
{
// 8bit, color or not
IMREAD_UNCHANGED =-1,
// 8bit, gray
IMREAD_GRAYSCALE =0,
// ?, color
IMREAD_COLOR =1,//默认
// any depth, ?
IMREAD_ANYDEPTH =2,
// ?, any color
IMREAD_ANYCOLOR =4
};
------------------------Mat 常用信息------------------------------
//! returns element type, similar to CV_MAT_TYPE(cvmat->type)
//! returns element type, similar to CV_MAT_CN(cvmat->type)
int channels() const; //1,2,3
//! the matrix dimensionality, >= 2
int dims;
//! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
int rows, cols;
//! pointer to the data
uchar* data;
------------------------------------
#define CV_8U 0
#define CV_8S 1
#define CV_16U 2
#define CV_16S 3
#define CV_32S 4
#define CV_32F 5
#define CV_64F 6
#define CV_USRTYPE1 7
CV_[The number of bits per item][Signed or Unsigned][Type Prefix]C[The channel number]
//预备知识
/*
/*\typedef
access individual elements using [] operator etc.
Shorter aliases for the most popular specializations of Vec<T,n>
typedef Vec<uchar, 2> Vec2b;
typedef Vec<uchar, 3> Vec3b;
typedef Vec<uchar, 4> Vec4b;
typedef Vec<short, 2> Vec2s;
typedef Vec<short, 3> Vec3s;
typedef Vec<short, 4> Vec4s;
typedef Vec<ushort, 2> Vec2w;
typedef Vec<ushort, 3> Vec3w;
typedef Vec<ushort, 4> Vec4w;
typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<int, 4> Vec4i;
typedef Vec<int, 6> Vec6i;
typedef Vec<int, 8> Vec8i;
typedef Vec<float, 2> Vec2f;
typedef Vec<float, 3> Vec3f;
typedef Vec<float, 4> Vec4f;
typedef Vec<float, 6> Vec6f;
typedef Vec<double, 2> Vec2d;
typedef Vec<double, 3> Vec3d;
typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d;
----------------------imread,第二个参数------------------------
enum
{
// 8bit, color or not
IMREAD_UNCHANGED =-1,
// 8bit, gray
IMREAD_GRAYSCALE =0,
// ?, color
IMREAD_COLOR =1,//默认
// any depth, ?
IMREAD_ANYDEPTH =2,
// ?, any color
IMREAD_ANYCOLOR =4
};
------------------------Mat 常用信息------------------------------
//! returns element type, similar to CV_MAT_TYPE(cvmat->type)
int type() const; //0,1,2,。。。,6
//! returns element type, similar to CV_MAT_DEPTH(cvmat->type)
int depth() const;
常见的有:
CV_8U :
CV_8S :
CV_16U :
CV_16S :
CV_32S :
CV_32F :
CV_64F :
//! returns element type, similar to CV_MAT_CN(cvmat->type)
int channels() const; //1,2,3
//! the matrix dimensionality, >= 2
int dims;
//! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
int rows, cols;
//! pointer to the data
uchar* data;
------------------------------------
#define CV_8U 0
#define CV_8S 1
#define CV_16U 2
#define CV_16S 3
#define CV_32S 4
#define CV_32F 5
#define CV_64F 6
#define CV_USRTYPE1 7
CV_[The number of bits per item][Signed or Unsigned][Type Prefix]C[The channel number]
string show_Mat_type( Mat mat_input ){string mat_type_name = "";//detect depthswitch ( mat_input.depth() ) {case CV_8U :mat_type_name = "CV_8U";break;case CV_8S :mat_type_name = "CV_8S";break;case CV_16U :mat_type_name = "CV_16U";break;case CV_16S :mat_type_name = "CV_16S";break;case CV_32S :mat_type_name = "CV_32S";break;case CV_32F :mat_type_name = "CV_32F";break;case CV_64F :mat_type_name = "CV_64F";break;default:cout << "switch ( mat_input.depth() ) error!" << endl ;}//detect channelsswitch( mat_input.channels() ) {case 1 :mat_type_name += "C1";break;case 2 :mat_type_name += "C2";break;case 3 :mat_type_name += "C3";break;default:cout << "switch( mat_input.channels() ) error!" << endl ;}//uchar char short switch( mat_input.type() % 8 ) { case 0: //cout<< int( ((uchar*)mat.data + Cols*i+Chns*j )[k] )<<" "; mat_type_name += " uchar"; break; case 1: //cout<< int( ( (char*)mat.data + Cols*i+Chns*j)[k] )<<" "; mat_type_name += " char"; break; case 2: //cout<< ( (unsigned short*)mat.data + Cols*i+Chns*j)[k] <<" "; mat_type_name += " ushort"; break; case 3: //cout<< ( (short*)mat.data + Cols*i+Chns*j)[k] <<" "; mat_type_name += " short"; break; case 4: //cout<< ( (int*)mat.data + Cols*i+Chns*j)[k] <<" "; mat_type_name += " int"; break; case 5: //cout<< ( (float*)mat.data + Cols*i+Chns*j)[k] <<" "; mat_type_name += " float"; break; case 6: //cout<< ( (double*)mat.data + Cols*i+Chns*j)[k] <<" "; mat_type_name += " double"; break; default: break; }cout << "\n" << mat_type_name << endl ;return mat_type_name;}
- cv::Mat经常用到的信息
- cv::Mat经常用到的信息
- cv::Mat的介绍
- cv::Mat 的数据拷贝
- cv::mat的基本操作
- opencv cv::Mat的用法
- cv::mat的基本操作 ***** **
- 经常用到的SQL
- 经常用到的DML
- CSS 经常用到的
- 经常用到的网址
- 经常用到的sql
- 经常用到的命令
- 经常用到的方法
- 经常用到的快捷键
- cv...Mat...
- cv:Mat
- cv::mat
- javaScript与asp_net-clientid用法
- C++ primer 这本书上有这么两句话“派生类虚函数调用基类版本时,必须显式使用作用域操作符。如果派生类函数忽略了这样做,则函数调用会在运行时确定并且将是一个自身调用,从而导致无穷递归。”
- JSP动作元素
- JDBC,java数据库的连接
- 简要分析Uboot是如何启动内核!
- cv::Mat经常用到的信息
- 【受欢迎的牛】解题报告
- 一个简单的Python类实现
- SMARTY(二)
- 三级联动方法写地址
- protect your eyes - 豆绿色
- 怎么样取得数组长度
- 对FPC各种不会用的同志们看过来
- Ubuntu Apache+SubVersion+Trac 配置