What's the difference between cvtype values in OPENCV?

The naming sheme for the types is CV_<bit-depth>{U|S|F}C<number_of_channels>.

So CV_8UC4 translates to: four channels of unsigned char and CV_16S translates to: 1 channel of signed 2-byte integer.

Of course the topic is handled in the documentation. Here you can find more information.


CV_8U - 8-bit unsigned integers ( 0..255 )

CV_8S - 8-bit signed integers ( -128..127 )

CV_16U - 16-bit unsigned integers ( 0..65535 )

CV_16S - 16-bit signed integers ( -32768..32767 )

CV_32S - 32-bit signed integers ( -2147483648..2147483647 )

CV_32F - 32-bit floating-point numbers ( -FLT_MAX..FLT_MAX, INF, NAN )

CV_64F - 64-bit floating-point numbers ( -DBL_MAX..DBL_MAX, INF, NAN )


8-bit unsigned integer (uchar)

8-bit signed integer (schar)

16-bit unsigned integer (ushort)

16-bit signed integer (short)

32-bit signed integer (int)

32-bit floating-point number (float)

64-bit floating-point number (double)

enum { CV_8U=0, CV_8S=1, CV_16U=2, CV_16S=3, CV_32S=4, CV_32F=5, CV_64F=6 };


To complete the answer of Farshid PirahanSiah,

A Mapping of Type to Numbers in OpenCV: in a table format


or in long text:

Unsigned 8bits uchar 0~255

Mat: CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4

Signed 8bits char -128~127

Mat: CV_8SC1,CV_8SC2,CV_8SC3,CV_8SC4

Unsigned 16bits ushort 0~65535

Mat: CV_16UC1,CV_16UC2,CV_16UC3,CV_16UC4

Signed 16bits short -32768~32767

Mat: CV_16SC1,CV_16SC2,CV_16SC3,CV_16SC4

Signed 32bits int -2147483648~2147483647

Mat: CV_32SC1,CV_32SC2,CV_32SC3,CV_32SC4

Float 32bits float -1.18*10-38~3.40*10-38

Mat: CV_32FC1,CV_32FC2,CV_32FC3,CV_32FC4

Double 64bits double

Mat: CV_64FC1,CV_64FC2,CV_64FC3,CV_64FC4

Tags:

Opencv