template<typename _Tp> class Point_
{
public:
...
_Tp x, y; //< the point coordinates
};
typedef Point_<int> point2i;
typedef Point_<int64> point2l;
typedef Point_<float> point2f;
typedef Point_<double> point2d;
typedef point2i Point;
template<typename _Tp> class Size_
{
public:
...
_Tp width, height; //< the width and the height
};
typedef Size_<int> Size2i;
typedef Size_<int64> Size2l;
typedef Size_<float> Size2f;
typedef Size_<double> Size2d;
typedef Size2i Size;
template<typename _Tp> class Rect_
{
public:
...
_Tp x, y, width, height; //< the width and the height
};
typedef Rect_<int> Rect2i;
typedef Rect_<float> Rect2f;
typedef Rect_<double> Rect2d;
typedef Rect2i Rect;
class Range
{
public:
Range();
Range(int _start, int _end);
int size() const;
bool empty() const;
static Range all();
int start, end;
};
typedef Rect_<int> Rect2i;
typedef Rect_<float> Rect2f;
typedef Rect_<double> Rect2d;
typedef Rect2i Rect;
typedef std::string cv::String;
String str1 = "Hello";
String str2 = std::string("world");
String str3 = str1 + " " + str2;
Mat imgs[3];
for(int i=0;i<3;i++)
{
String filename = format("test%02d.bmp", i+1);
imgs[i] = imread(filename);
}
template<typename _Tp, int m, int n> class Matx
{
public:
...
_Tp val[m*n]; //< matrix elements
};
template<typename _Tp, int cn> class Vec : public Matx<_Tp, cn, 1>
{
public:
...
const _Tp& operator [](int i) const;
_Tp& operator[](int i);
};
VEC<num-of-data>{b|s|w|i|f|d}
class Scalar{
public:
double val[4];
...
};
Scalar gray = 128;
cout<< "gray: " << gray << endl;
Scalar yellow(0,255,255);
cout<< "yellow: " << yellow << endl;
for (int i=0; i < 4; i++)
cout << yellow.val[i] << "," <<yellow[i] <<endl; // 서로 동일하다
Mat::copyTo()
또는 Mat::clone()
함수 사용Mat::at<typename>(int y, int x)
또는 Mat::ptr<typename>(int y)
함수 사용을 권장class Mat
{
public:
Mat();
Mat(int rows, int cols, int type);
...
void create(int rows, int cols, int type);
Mat& operator = (const Mat& m);
Mat clone() const;
void copyTo(OutputArray m) const;
template<typename _Tp> _Tp* ptr(int i0 = 0);
template<typename _TP> _Tp& at(int row, int col);
...
int dims; // 행렬의 차원. 일반적인 영상은 항상 2
int rows, cols; // 행렬의 행(세로) 크기, 열(가로) 크기, 주로 이 두개의 멤버변수 사용
// dims==2 인 경우에만 유효
uchar* data; // 동적 할당된 메모리 영역 주소
...
}
CV_<bit-depth>{U|S|F}