I tried a lot of constant values but I cannot find any difference between cvtype values.
What is it used for?
I tried values like CV_8UC4
and CV_16S
.
I did not find this information in references.

- 17,937
- 7
- 41
- 43

- 2,198
- 2
- 23
- 23
3 Answers
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.

- 37,556
- 9
- 94
- 102

- 1,059
- 9
- 9
-
1Finally I understand! – Michele Jun 06 '14 at 13:49
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 };

- 761
- 6
- 22
-
1May I ask that I'm using this function: " Imgproc.Laplacian(srcMat, dstMat, CvType.CV_64F)", what's the difference if I pass CvType.CV_32F instead of CvType.CV64F? – Chinese Cat Feb 27 '23 at 02:16
-
CvType.CV_32F is float in C++ CvType.CV64F is double in C++ (more precision) – Farshid PirahanSiah Mar 01 '23 at 16:12
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

- 61
- 2
- 3