OpenCV Mat element types and their sizes

后端 未结 6 1780
滥情空心
滥情空心 2020-12-05 10:08

I\'m confused by the OpenCV Mat element types. This is from the docs:

There is a limited fixed set of primitive data types the library can operate on.
That i         


        
6条回答
  •  无人及你
    2020-12-05 10:13

    In short the table you provided is correct. If you want to directly access a pixel, you typecast it to the specifier to the right, for example CV_32S is a signed 32-bit. The S always means a signed integral number (signed char, signed short, signed int) The F always means a floating point number (float, double) The U always means an unsigned integral number.

    The enumeration is used only when creating or converting a Mat. It's a way of telling the mat which is the desired type, as I understand it it's the C predecessor to when templates were not used.

    I use the C functionality exclusively, and in order to create an image, it would be an error to pass the following:

    cvCreateImage(mySize,char, nChannels);
    

    Instead, I pass the following:

    cvCreateImage(mySize, IPL_DEPTH_8U, nChannels);
    

    Here, the IPL_DEPTH_8U is a flag that is used by the function. The function itself has a switch-type statement that checks the flag. The actual value of the flag is most often meaningless as it's most often controlled by conditional, not algebraic statements.

提交回复
热议问题