openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/core/traits.hpp@0:0e0631af0305, 2021-01-29 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Fri Jan 29 04:53:38 2021 +0000
- Revision:
- 0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto | 0:0e0631af0305 | 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2 | // |
RyoheiHagimoto | 0:0e0631af0305 | 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
RyoheiHagimoto | 0:0e0631af0305 | 4 | // |
RyoheiHagimoto | 0:0e0631af0305 | 5 | // By downloading, copying, installing or using the software you agree to this license. |
RyoheiHagimoto | 0:0e0631af0305 | 6 | // If you do not agree to this license, do not download, install, |
RyoheiHagimoto | 0:0e0631af0305 | 7 | // copy or use the software. |
RyoheiHagimoto | 0:0e0631af0305 | 8 | // |
RyoheiHagimoto | 0:0e0631af0305 | 9 | // |
RyoheiHagimoto | 0:0e0631af0305 | 10 | // License Agreement |
RyoheiHagimoto | 0:0e0631af0305 | 11 | // For Open Source Computer Vision Library |
RyoheiHagimoto | 0:0e0631af0305 | 12 | // |
RyoheiHagimoto | 0:0e0631af0305 | 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 15 | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 16 | // Third party copyrights are property of their respective owners. |
RyoheiHagimoto | 0:0e0631af0305 | 17 | // |
RyoheiHagimoto | 0:0e0631af0305 | 18 | // Redistribution and use in source and binary forms, with or without modification, |
RyoheiHagimoto | 0:0e0631af0305 | 19 | // are permitted provided that the following conditions are met: |
RyoheiHagimoto | 0:0e0631af0305 | 20 | // |
RyoheiHagimoto | 0:0e0631af0305 | 21 | // * Redistribution's of source code must retain the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 22 | // this list of conditions and the following disclaimer. |
RyoheiHagimoto | 0:0e0631af0305 | 23 | // |
RyoheiHagimoto | 0:0e0631af0305 | 24 | // * Redistribution's in binary form must reproduce the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 25 | // this list of conditions and the following disclaimer in the documentation |
RyoheiHagimoto | 0:0e0631af0305 | 26 | // and/or other materials provided with the distribution. |
RyoheiHagimoto | 0:0e0631af0305 | 27 | // |
RyoheiHagimoto | 0:0e0631af0305 | 28 | // * The name of the copyright holders may not be used to endorse or promote products |
RyoheiHagimoto | 0:0e0631af0305 | 29 | // derived from this software without specific prior written permission. |
RyoheiHagimoto | 0:0e0631af0305 | 30 | // |
RyoheiHagimoto | 0:0e0631af0305 | 31 | // This software is provided by the copyright holders and contributors "as is" and |
RyoheiHagimoto | 0:0e0631af0305 | 32 | // any express or implied warranties, including, but not limited to, the implied |
RyoheiHagimoto | 0:0e0631af0305 | 33 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
RyoheiHagimoto | 0:0e0631af0305 | 34 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
RyoheiHagimoto | 0:0e0631af0305 | 35 | // indirect, incidental, special, exemplary, or consequential damages |
RyoheiHagimoto | 0:0e0631af0305 | 36 | // (including, but not limited to, procurement of substitute goods or services; |
RyoheiHagimoto | 0:0e0631af0305 | 37 | // loss of use, data, or profits; or business interruption) however caused |
RyoheiHagimoto | 0:0e0631af0305 | 38 | // and on any theory of liability, whether in contract, strict liability, |
RyoheiHagimoto | 0:0e0631af0305 | 39 | // or tort (including negligence or otherwise) arising in any way out of |
RyoheiHagimoto | 0:0e0631af0305 | 40 | // the use of this software, even if advised of the possibility of such damage. |
RyoheiHagimoto | 0:0e0631af0305 | 41 | // |
RyoheiHagimoto | 0:0e0631af0305 | 42 | //M*/ |
RyoheiHagimoto | 0:0e0631af0305 | 43 | |
RyoheiHagimoto | 0:0e0631af0305 | 44 | #ifndef OPENCV_CORE_TRAITS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 45 | #define OPENCV_CORE_TRAITS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 46 | |
RyoheiHagimoto | 0:0e0631af0305 | 47 | #include "opencv2/core/cvdef.h" |
RyoheiHagimoto | 0:0e0631af0305 | 48 | |
RyoheiHagimoto | 0:0e0631af0305 | 49 | namespace cv |
RyoheiHagimoto | 0:0e0631af0305 | 50 | { |
RyoheiHagimoto | 0:0e0631af0305 | 51 | |
RyoheiHagimoto | 0:0e0631af0305 | 52 | //! @addtogroup core_basic |
RyoheiHagimoto | 0:0e0631af0305 | 53 | //! @{ |
RyoheiHagimoto | 0:0e0631af0305 | 54 | |
RyoheiHagimoto | 0:0e0631af0305 | 55 | /** @brief Template "trait" class for OpenCV primitive data types. |
RyoheiHagimoto | 0:0e0631af0305 | 56 | |
RyoheiHagimoto | 0:0e0631af0305 | 57 | A primitive OpenCV data type is one of unsigned char, bool, signed char, unsigned short, signed |
RyoheiHagimoto | 0:0e0631af0305 | 58 | short, int, float, double, or a tuple of values of one of these types, where all the values in the |
RyoheiHagimoto | 0:0e0631af0305 | 59 | tuple have the same type. Any primitive type from the list can be defined by an identifier in the |
RyoheiHagimoto | 0:0e0631af0305 | 60 | form CV_\<bit-depth\>{U|S|F}C(\<number_of_channels\>), for example: uchar \~ CV_8UC1, 3-element |
RyoheiHagimoto | 0:0e0631af0305 | 61 | floating-point tuple \~ CV_32FC3, and so on. A universal OpenCV structure that is able to store a |
RyoheiHagimoto | 0:0e0631af0305 | 62 | single instance of such a primitive data type is Vec. Multiple instances of such a type can be |
RyoheiHagimoto | 0:0e0631af0305 | 63 | stored in a std::vector, Mat, Mat_, SparseMat, SparseMat_, or any other container that is able to |
RyoheiHagimoto | 0:0e0631af0305 | 64 | store Vec instances. |
RyoheiHagimoto | 0:0e0631af0305 | 65 | |
RyoheiHagimoto | 0:0e0631af0305 | 66 | The DataType class is basically used to provide a description of such primitive data types without |
RyoheiHagimoto | 0:0e0631af0305 | 67 | adding any fields or methods to the corresponding classes (and it is actually impossible to add |
RyoheiHagimoto | 0:0e0631af0305 | 68 | anything to primitive C/C++ data types). This technique is known in C++ as class traits. It is not |
RyoheiHagimoto | 0:0e0631af0305 | 69 | DataType itself that is used but its specialized versions, such as: |
RyoheiHagimoto | 0:0e0631af0305 | 70 | @code |
RyoheiHagimoto | 0:0e0631af0305 | 71 | template<> class DataType<uchar> |
RyoheiHagimoto | 0:0e0631af0305 | 72 | { |
RyoheiHagimoto | 0:0e0631af0305 | 73 | typedef uchar value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 74 | typedef int work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 75 | typedef uchar channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 76 | enum { channel_type = CV_8U, channels = 1, fmt='u', type = CV_8U }; |
RyoheiHagimoto | 0:0e0631af0305 | 77 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 78 | ... |
RyoheiHagimoto | 0:0e0631af0305 | 79 | template<typename _Tp> DataType<std::complex<_Tp> > |
RyoheiHagimoto | 0:0e0631af0305 | 80 | { |
RyoheiHagimoto | 0:0e0631af0305 | 81 | typedef std::complex<_Tp> value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 82 | typedef std::complex<_Tp> work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 83 | typedef _Tp channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 84 | // DataDepth is another helper trait class |
RyoheiHagimoto | 0:0e0631af0305 | 85 | enum { depth = DataDepth<_Tp>::value, channels=2, |
RyoheiHagimoto | 0:0e0631af0305 | 86 | fmt=(channels-1)*256+DataDepth<_Tp>::fmt, |
RyoheiHagimoto | 0:0e0631af0305 | 87 | type=CV_MAKETYPE(depth, channels) }; |
RyoheiHagimoto | 0:0e0631af0305 | 88 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 89 | ... |
RyoheiHagimoto | 0:0e0631af0305 | 90 | @endcode |
RyoheiHagimoto | 0:0e0631af0305 | 91 | The main purpose of this class is to convert compilation-time type information to an |
RyoheiHagimoto | 0:0e0631af0305 | 92 | OpenCV-compatible data type identifier, for example: |
RyoheiHagimoto | 0:0e0631af0305 | 93 | @code |
RyoheiHagimoto | 0:0e0631af0305 | 94 | // allocates a 30x40 floating-point matrix |
RyoheiHagimoto | 0:0e0631af0305 | 95 | Mat A(30, 40, DataType<float>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 96 | |
RyoheiHagimoto | 0:0e0631af0305 | 97 | Mat B = Mat_<std::complex<double> >(3, 3); |
RyoheiHagimoto | 0:0e0631af0305 | 98 | // the statement below will print 6, 2 , that is depth == CV_64F, channels == 2 |
RyoheiHagimoto | 0:0e0631af0305 | 99 | cout << B.depth() << ", " << B.channels() << endl; |
RyoheiHagimoto | 0:0e0631af0305 | 100 | @endcode |
RyoheiHagimoto | 0:0e0631af0305 | 101 | So, such traits are used to tell OpenCV which data type you are working with, even if such a type is |
RyoheiHagimoto | 0:0e0631af0305 | 102 | not native to OpenCV. For example, the matrix B initialization above is compiled because OpenCV |
RyoheiHagimoto | 0:0e0631af0305 | 103 | defines the proper specialized template class DataType\<complex\<_Tp\> \> . This mechanism is also |
RyoheiHagimoto | 0:0e0631af0305 | 104 | useful (and used in OpenCV this way) for generic algorithms implementations. |
RyoheiHagimoto | 0:0e0631af0305 | 105 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 106 | template<typename _Tp> class DataType |
RyoheiHagimoto | 0:0e0631af0305 | 107 | { |
RyoheiHagimoto | 0:0e0631af0305 | 108 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 109 | typedef _Tp value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 110 | typedef value_type work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 111 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 112 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 113 | enum { generic_type = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 114 | depth = -1, |
RyoheiHagimoto | 0:0e0631af0305 | 115 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 116 | fmt = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 117 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 118 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 119 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 120 | |
RyoheiHagimoto | 0:0e0631af0305 | 121 | template<> class DataType<bool> |
RyoheiHagimoto | 0:0e0631af0305 | 122 | { |
RyoheiHagimoto | 0:0e0631af0305 | 123 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 124 | typedef bool value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 125 | typedef int work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 126 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 127 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 128 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 129 | depth = CV_8U, |
RyoheiHagimoto | 0:0e0631af0305 | 130 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 131 | fmt = (int)'u', |
RyoheiHagimoto | 0:0e0631af0305 | 132 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 133 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 134 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 135 | |
RyoheiHagimoto | 0:0e0631af0305 | 136 | template<> class DataType<uchar> |
RyoheiHagimoto | 0:0e0631af0305 | 137 | { |
RyoheiHagimoto | 0:0e0631af0305 | 138 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 139 | typedef uchar value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 140 | typedef int work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 141 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 142 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 143 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 144 | depth = CV_8U, |
RyoheiHagimoto | 0:0e0631af0305 | 145 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 146 | fmt = (int)'u', |
RyoheiHagimoto | 0:0e0631af0305 | 147 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 148 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 149 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 150 | |
RyoheiHagimoto | 0:0e0631af0305 | 151 | template<> class DataType<schar> |
RyoheiHagimoto | 0:0e0631af0305 | 152 | { |
RyoheiHagimoto | 0:0e0631af0305 | 153 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 154 | typedef schar value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 155 | typedef int work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 156 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 157 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 158 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 159 | depth = CV_8S, |
RyoheiHagimoto | 0:0e0631af0305 | 160 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 161 | fmt = (int)'c', |
RyoheiHagimoto | 0:0e0631af0305 | 162 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 163 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 164 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 165 | |
RyoheiHagimoto | 0:0e0631af0305 | 166 | template<> class DataType<char> |
RyoheiHagimoto | 0:0e0631af0305 | 167 | { |
RyoheiHagimoto | 0:0e0631af0305 | 168 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 169 | typedef schar value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 170 | typedef int work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 171 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 172 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 173 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 174 | depth = CV_8S, |
RyoheiHagimoto | 0:0e0631af0305 | 175 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 176 | fmt = (int)'c', |
RyoheiHagimoto | 0:0e0631af0305 | 177 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 178 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 179 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 180 | |
RyoheiHagimoto | 0:0e0631af0305 | 181 | template<> class DataType<ushort> |
RyoheiHagimoto | 0:0e0631af0305 | 182 | { |
RyoheiHagimoto | 0:0e0631af0305 | 183 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 184 | typedef ushort value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 185 | typedef int work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 186 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 187 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 188 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 189 | depth = CV_16U, |
RyoheiHagimoto | 0:0e0631af0305 | 190 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 191 | fmt = (int)'w', |
RyoheiHagimoto | 0:0e0631af0305 | 192 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 193 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 194 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 195 | |
RyoheiHagimoto | 0:0e0631af0305 | 196 | template<> class DataType<short> |
RyoheiHagimoto | 0:0e0631af0305 | 197 | { |
RyoheiHagimoto | 0:0e0631af0305 | 198 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 199 | typedef short value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 200 | typedef int work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 201 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 202 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 203 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 204 | depth = CV_16S, |
RyoheiHagimoto | 0:0e0631af0305 | 205 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 206 | fmt = (int)'s', |
RyoheiHagimoto | 0:0e0631af0305 | 207 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 208 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 209 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 210 | |
RyoheiHagimoto | 0:0e0631af0305 | 211 | template<> class DataType<int> |
RyoheiHagimoto | 0:0e0631af0305 | 212 | { |
RyoheiHagimoto | 0:0e0631af0305 | 213 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 214 | typedef int value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 215 | typedef value_type work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 216 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 217 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 218 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 219 | depth = CV_32S, |
RyoheiHagimoto | 0:0e0631af0305 | 220 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 221 | fmt = (int)'i', |
RyoheiHagimoto | 0:0e0631af0305 | 222 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 223 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 224 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 225 | |
RyoheiHagimoto | 0:0e0631af0305 | 226 | template<> class DataType<float> |
RyoheiHagimoto | 0:0e0631af0305 | 227 | { |
RyoheiHagimoto | 0:0e0631af0305 | 228 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 229 | typedef float value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 230 | typedef value_type work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 231 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 232 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 233 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 234 | depth = CV_32F, |
RyoheiHagimoto | 0:0e0631af0305 | 235 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 236 | fmt = (int)'f', |
RyoheiHagimoto | 0:0e0631af0305 | 237 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 238 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 239 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 240 | |
RyoheiHagimoto | 0:0e0631af0305 | 241 | template<> class DataType<double> |
RyoheiHagimoto | 0:0e0631af0305 | 242 | { |
RyoheiHagimoto | 0:0e0631af0305 | 243 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 244 | typedef double value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 245 | typedef value_type work_type; |
RyoheiHagimoto | 0:0e0631af0305 | 246 | typedef value_type channel_type; |
RyoheiHagimoto | 0:0e0631af0305 | 247 | typedef value_type vec_type; |
RyoheiHagimoto | 0:0e0631af0305 | 248 | enum { generic_type = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 249 | depth = CV_64F, |
RyoheiHagimoto | 0:0e0631af0305 | 250 | channels = 1, |
RyoheiHagimoto | 0:0e0631af0305 | 251 | fmt = (int)'d', |
RyoheiHagimoto | 0:0e0631af0305 | 252 | type = CV_MAKETYPE(depth, channels) |
RyoheiHagimoto | 0:0e0631af0305 | 253 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 254 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 255 | |
RyoheiHagimoto | 0:0e0631af0305 | 256 | |
RyoheiHagimoto | 0:0e0631af0305 | 257 | /** @brief A helper class for cv::DataType |
RyoheiHagimoto | 0:0e0631af0305 | 258 | |
RyoheiHagimoto | 0:0e0631af0305 | 259 | The class is specialized for each fundamental numerical data type supported by OpenCV. It provides |
RyoheiHagimoto | 0:0e0631af0305 | 260 | DataDepth<T>::value constant. |
RyoheiHagimoto | 0:0e0631af0305 | 261 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 262 | template<typename _Tp> class DataDepth |
RyoheiHagimoto | 0:0e0631af0305 | 263 | { |
RyoheiHagimoto | 0:0e0631af0305 | 264 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 265 | enum |
RyoheiHagimoto | 0:0e0631af0305 | 266 | { |
RyoheiHagimoto | 0:0e0631af0305 | 267 | value = DataType<_Tp>::depth, |
RyoheiHagimoto | 0:0e0631af0305 | 268 | fmt = DataType<_Tp>::fmt |
RyoheiHagimoto | 0:0e0631af0305 | 269 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 270 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 271 | |
RyoheiHagimoto | 0:0e0631af0305 | 272 | |
RyoheiHagimoto | 0:0e0631af0305 | 273 | |
RyoheiHagimoto | 0:0e0631af0305 | 274 | template<int _depth> class TypeDepth |
RyoheiHagimoto | 0:0e0631af0305 | 275 | { |
RyoheiHagimoto | 0:0e0631af0305 | 276 | enum { depth = CV_USRTYPE1 }; |
RyoheiHagimoto | 0:0e0631af0305 | 277 | typedef void value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 278 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 279 | |
RyoheiHagimoto | 0:0e0631af0305 | 280 | template<> class TypeDepth<CV_8U> |
RyoheiHagimoto | 0:0e0631af0305 | 281 | { |
RyoheiHagimoto | 0:0e0631af0305 | 282 | enum { depth = CV_8U }; |
RyoheiHagimoto | 0:0e0631af0305 | 283 | typedef uchar value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 284 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 285 | |
RyoheiHagimoto | 0:0e0631af0305 | 286 | template<> class TypeDepth<CV_8S> |
RyoheiHagimoto | 0:0e0631af0305 | 287 | { |
RyoheiHagimoto | 0:0e0631af0305 | 288 | enum { depth = CV_8S }; |
RyoheiHagimoto | 0:0e0631af0305 | 289 | typedef schar value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 290 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 291 | |
RyoheiHagimoto | 0:0e0631af0305 | 292 | template<> class TypeDepth<CV_16U> |
RyoheiHagimoto | 0:0e0631af0305 | 293 | { |
RyoheiHagimoto | 0:0e0631af0305 | 294 | enum { depth = CV_16U }; |
RyoheiHagimoto | 0:0e0631af0305 | 295 | typedef ushort value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 296 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 297 | |
RyoheiHagimoto | 0:0e0631af0305 | 298 | template<> class TypeDepth<CV_16S> |
RyoheiHagimoto | 0:0e0631af0305 | 299 | { |
RyoheiHagimoto | 0:0e0631af0305 | 300 | enum { depth = CV_16S }; |
RyoheiHagimoto | 0:0e0631af0305 | 301 | typedef short value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 302 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 303 | |
RyoheiHagimoto | 0:0e0631af0305 | 304 | template<> class TypeDepth<CV_32S> |
RyoheiHagimoto | 0:0e0631af0305 | 305 | { |
RyoheiHagimoto | 0:0e0631af0305 | 306 | enum { depth = CV_32S }; |
RyoheiHagimoto | 0:0e0631af0305 | 307 | typedef int value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 308 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 309 | |
RyoheiHagimoto | 0:0e0631af0305 | 310 | template<> class TypeDepth<CV_32F> |
RyoheiHagimoto | 0:0e0631af0305 | 311 | { |
RyoheiHagimoto | 0:0e0631af0305 | 312 | enum { depth = CV_32F }; |
RyoheiHagimoto | 0:0e0631af0305 | 313 | typedef float value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 314 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 315 | |
RyoheiHagimoto | 0:0e0631af0305 | 316 | template<> class TypeDepth<CV_64F> |
RyoheiHagimoto | 0:0e0631af0305 | 317 | { |
RyoheiHagimoto | 0:0e0631af0305 | 318 | enum { depth = CV_64F }; |
RyoheiHagimoto | 0:0e0631af0305 | 319 | typedef double value_type; |
RyoheiHagimoto | 0:0e0631af0305 | 320 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 321 | |
RyoheiHagimoto | 0:0e0631af0305 | 322 | //! @} |
RyoheiHagimoto | 0:0e0631af0305 | 323 | |
RyoheiHagimoto | 0:0e0631af0305 | 324 | } // cv |
RyoheiHagimoto | 0:0e0631af0305 | 325 | |
RyoheiHagimoto | 0:0e0631af0305 | 326 | #endif // OPENCV_CORE_TRAITS_HPP |