OpenCV Mat element types and their sizes

后端 未结 6 1781
滥情空心
滥情空心 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:23

    In core.hpp you can find the following:

    /*!
      A helper class for cv::DataType
    
      The class is specialized for each fundamental numerical data type supported by OpenCV.
      It provides DataDepth::value constant.
    */
    template class DataDepth {};
    
    template<> class DataDepth { public: enum { value = CV_8U, fmt=(int)'u' }; };
    template<> class DataDepth { public: enum { value = CV_8U, fmt=(int)'u' }; };
    template<> class DataDepth { public: enum { value = CV_8S, fmt=(int)'c' }; };
    template<> class DataDepth { public: enum { value = CV_8S, fmt=(int)'c' }; };
    template<> class DataDepth { public: enum { value = CV_16U, fmt=(int)'w' }; };
    template<> class DataDepth { public: enum { value = CV_16S, fmt=(int)'s' }; };
    template<> class DataDepth { public: enum { value = CV_32S, fmt=(int)'i' }; };
    // this is temporary solution to support 32-bit unsigned integers
    template<> class DataDepth { public: enum { value = CV_32S, fmt=(int)'i' }; };
    template<> class DataDepth { public: enum { value = CV_32F, fmt=(int)'f' }; };
    template<> class DataDepth { public: enum { value = CV_64F, fmt=(int)'d' }; };
    template class DataDepth<_Tp*> { public: enum { value = CV_USRTYPE1, fmt=(int)'r' }; };
    

    You can see that CV_32S is the value for the type int, not int32_t.

提交回复
热议问题