縮寫(uchar、ushort、Vec)
這邊介紹OpenCV常見的三種縮寫,分別是uchar、ushort、Vec。
typedef unsigned char uchar
typedef unsigned short ushort
OpenCV使用Vec簡化vector,數字表示這個vector有幾個元素,英文字母表示元素的資料結構,通常用於影像像素。
以最常見的8位元無負號3通道圖來說,我們可用Vec3b表示單獨的像素資料結構,3表示有3個元素,b表示每個元素的資料結構是uchar,假設我們想要取第1通道的值,後面加[0]。
以下為幾種縮寫方式,其他縮寫依此類推:
typedef Vec< uchar, 2 > Vec2b
typedef Vec< uchar, 3 > Vec3b
typedef Vec< short, 2 > Vec2s
typedef Vec< short, 3 > Vec3s
typedef Vec< int, 2 > Vec2i
typedef Vec< int, 3 > Vec3i
typedef Vec< float, 2 > Vec2f
typedef Vec< float, 3 > Vec3f
typedef Vec< double, 2 > Vec2d
typedef Vec< double, 3 > Vec3d
source: http://monkeycoding.com/?p=544