Joe Verbout
/
main
opencv on mbed
opencv2/core/cvstd.inl.hpp@0:ea44dc9ed014, 2016-03-31 (annotated)
- Committer:
- joeverbout
- Date:
- Thu Mar 31 21:16:38 2016 +0000
- Revision:
- 0:ea44dc9ed014
OpenCV on mbed attempt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joeverbout | 0:ea44dc9ed014 | 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
joeverbout | 0:ea44dc9ed014 | 2 | // |
joeverbout | 0:ea44dc9ed014 | 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
joeverbout | 0:ea44dc9ed014 | 4 | // |
joeverbout | 0:ea44dc9ed014 | 5 | // By downloading, copying, installing or using the software you agree to this license. |
joeverbout | 0:ea44dc9ed014 | 6 | // If you do not agree to this license, do not download, install, |
joeverbout | 0:ea44dc9ed014 | 7 | // copy or use the software. |
joeverbout | 0:ea44dc9ed014 | 8 | // |
joeverbout | 0:ea44dc9ed014 | 9 | // |
joeverbout | 0:ea44dc9ed014 | 10 | // License Agreement |
joeverbout | 0:ea44dc9ed014 | 11 | // For Open Source Computer Vision Library |
joeverbout | 0:ea44dc9ed014 | 12 | // |
joeverbout | 0:ea44dc9ed014 | 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
joeverbout | 0:ea44dc9ed014 | 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
joeverbout | 0:ea44dc9ed014 | 15 | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. |
joeverbout | 0:ea44dc9ed014 | 16 | // Third party copyrights are property of their respective owners. |
joeverbout | 0:ea44dc9ed014 | 17 | // |
joeverbout | 0:ea44dc9ed014 | 18 | // Redistribution and use in source and binary forms, with or without modification, |
joeverbout | 0:ea44dc9ed014 | 19 | // are permitted provided that the following conditions are met: |
joeverbout | 0:ea44dc9ed014 | 20 | // |
joeverbout | 0:ea44dc9ed014 | 21 | // * Redistribution's of source code must retain the above copyright notice, |
joeverbout | 0:ea44dc9ed014 | 22 | // this list of conditions and the following disclaimer. |
joeverbout | 0:ea44dc9ed014 | 23 | // |
joeverbout | 0:ea44dc9ed014 | 24 | // * Redistribution's in binary form must reproduce the above copyright notice, |
joeverbout | 0:ea44dc9ed014 | 25 | // this list of conditions and the following disclaimer in the documentation |
joeverbout | 0:ea44dc9ed014 | 26 | // and/or other materials provided with the distribution. |
joeverbout | 0:ea44dc9ed014 | 27 | // |
joeverbout | 0:ea44dc9ed014 | 28 | // * The name of the copyright holders may not be used to endorse or promote products |
joeverbout | 0:ea44dc9ed014 | 29 | // derived from this software without specific prior written permission. |
joeverbout | 0:ea44dc9ed014 | 30 | // |
joeverbout | 0:ea44dc9ed014 | 31 | // This software is provided by the copyright holders and contributors "as is" and |
joeverbout | 0:ea44dc9ed014 | 32 | // any express or implied warranties, including, but not limited to, the implied |
joeverbout | 0:ea44dc9ed014 | 33 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
joeverbout | 0:ea44dc9ed014 | 34 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
joeverbout | 0:ea44dc9ed014 | 35 | // indirect, incidental, special, exemplary, or consequential damages |
joeverbout | 0:ea44dc9ed014 | 36 | // (including, but not limited to, procurement of substitute goods or services; |
joeverbout | 0:ea44dc9ed014 | 37 | // loss of use, data, or profits; or business interruption) however caused |
joeverbout | 0:ea44dc9ed014 | 38 | // and on any theory of liability, whether in contract, strict liability, |
joeverbout | 0:ea44dc9ed014 | 39 | // or tort (including negligence or otherwise) arising in any way out of |
joeverbout | 0:ea44dc9ed014 | 40 | // the use of this software, even if advised of the possibility of such damage. |
joeverbout | 0:ea44dc9ed014 | 41 | // |
joeverbout | 0:ea44dc9ed014 | 42 | //M*/ |
joeverbout | 0:ea44dc9ed014 | 43 | |
joeverbout | 0:ea44dc9ed014 | 44 | #ifndef __OPENCV_CORE_CVSTDINL_HPP__ |
joeverbout | 0:ea44dc9ed014 | 45 | #define __OPENCV_CORE_CVSTDINL_HPP__ |
joeverbout | 0:ea44dc9ed014 | 46 | |
joeverbout | 0:ea44dc9ed014 | 47 | #ifndef OPENCV_NOSTL |
joeverbout | 0:ea44dc9ed014 | 48 | # include <complex> |
joeverbout | 0:ea44dc9ed014 | 49 | # include <ostream> |
joeverbout | 0:ea44dc9ed014 | 50 | #endif |
joeverbout | 0:ea44dc9ed014 | 51 | |
joeverbout | 0:ea44dc9ed014 | 52 | //! @cond IGNORED |
joeverbout | 0:ea44dc9ed014 | 53 | |
joeverbout | 0:ea44dc9ed014 | 54 | namespace cv |
joeverbout | 0:ea44dc9ed014 | 55 | { |
joeverbout | 0:ea44dc9ed014 | 56 | #ifndef OPENCV_NOSTL |
joeverbout | 0:ea44dc9ed014 | 57 | |
joeverbout | 0:ea44dc9ed014 | 58 | template<typename _Tp> class DataType< std::complex<_Tp> > |
joeverbout | 0:ea44dc9ed014 | 59 | { |
joeverbout | 0:ea44dc9ed014 | 60 | public: |
joeverbout | 0:ea44dc9ed014 | 61 | typedef std::complex<_Tp> value_type; |
joeverbout | 0:ea44dc9ed014 | 62 | typedef value_type work_type; |
joeverbout | 0:ea44dc9ed014 | 63 | typedef _Tp channel_type; |
joeverbout | 0:ea44dc9ed014 | 64 | |
joeverbout | 0:ea44dc9ed014 | 65 | enum { generic_type = 0, |
joeverbout | 0:ea44dc9ed014 | 66 | depth = DataType<channel_type>::depth, |
joeverbout | 0:ea44dc9ed014 | 67 | channels = 2, |
joeverbout | 0:ea44dc9ed014 | 68 | fmt = DataType<channel_type>::fmt + ((channels - 1) << 8), |
joeverbout | 0:ea44dc9ed014 | 69 | type = CV_MAKETYPE(depth, channels) }; |
joeverbout | 0:ea44dc9ed014 | 70 | |
joeverbout | 0:ea44dc9ed014 | 71 | typedef Vec<channel_type, channels> vec_type; |
joeverbout | 0:ea44dc9ed014 | 72 | }; |
joeverbout | 0:ea44dc9ed014 | 73 | |
joeverbout | 0:ea44dc9ed014 | 74 | inline |
joeverbout | 0:ea44dc9ed014 | 75 | String::String(const std::string& str) |
joeverbout | 0:ea44dc9ed014 | 76 | : cstr_(0), len_(0) |
joeverbout | 0:ea44dc9ed014 | 77 | { |
joeverbout | 0:ea44dc9ed014 | 78 | if (!str.empty()) |
joeverbout | 0:ea44dc9ed014 | 79 | { |
joeverbout | 0:ea44dc9ed014 | 80 | size_t len = str.size(); |
joeverbout | 0:ea44dc9ed014 | 81 | std::memcpy(allocate(len), str.c_str(), len); |
joeverbout | 0:ea44dc9ed014 | 82 | } |
joeverbout | 0:ea44dc9ed014 | 83 | } |
joeverbout | 0:ea44dc9ed014 | 84 | |
joeverbout | 0:ea44dc9ed014 | 85 | inline |
joeverbout | 0:ea44dc9ed014 | 86 | String::String(const std::string& str, size_t pos, size_t len) |
joeverbout | 0:ea44dc9ed014 | 87 | : cstr_(0), len_(0) |
joeverbout | 0:ea44dc9ed014 | 88 | { |
joeverbout | 0:ea44dc9ed014 | 89 | size_t strlen = str.size(); |
joeverbout | 0:ea44dc9ed014 | 90 | pos = min(pos, strlen); |
joeverbout | 0:ea44dc9ed014 | 91 | len = min(strlen - pos, len); |
joeverbout | 0:ea44dc9ed014 | 92 | if (!len) return; |
joeverbout | 0:ea44dc9ed014 | 93 | std::memcpy(allocate(len), str.c_str() + pos, len); |
joeverbout | 0:ea44dc9ed014 | 94 | } |
joeverbout | 0:ea44dc9ed014 | 95 | |
joeverbout | 0:ea44dc9ed014 | 96 | inline |
joeverbout | 0:ea44dc9ed014 | 97 | String& String::operator = (const std::string& str) |
joeverbout | 0:ea44dc9ed014 | 98 | { |
joeverbout | 0:ea44dc9ed014 | 99 | deallocate(); |
joeverbout | 0:ea44dc9ed014 | 100 | if (!str.empty()) |
joeverbout | 0:ea44dc9ed014 | 101 | { |
joeverbout | 0:ea44dc9ed014 | 102 | size_t len = str.size(); |
joeverbout | 0:ea44dc9ed014 | 103 | std::memcpy(allocate(len), str.c_str(), len); |
joeverbout | 0:ea44dc9ed014 | 104 | } |
joeverbout | 0:ea44dc9ed014 | 105 | return *this; |
joeverbout | 0:ea44dc9ed014 | 106 | } |
joeverbout | 0:ea44dc9ed014 | 107 | |
joeverbout | 0:ea44dc9ed014 | 108 | inline |
joeverbout | 0:ea44dc9ed014 | 109 | String& String::operator += (const std::string& str) |
joeverbout | 0:ea44dc9ed014 | 110 | { |
joeverbout | 0:ea44dc9ed014 | 111 | *this = *this + str; |
joeverbout | 0:ea44dc9ed014 | 112 | return *this; |
joeverbout | 0:ea44dc9ed014 | 113 | } |
joeverbout | 0:ea44dc9ed014 | 114 | |
joeverbout | 0:ea44dc9ed014 | 115 | inline |
joeverbout | 0:ea44dc9ed014 | 116 | String::operator std::string() const |
joeverbout | 0:ea44dc9ed014 | 117 | { |
joeverbout | 0:ea44dc9ed014 | 118 | return std::string(cstr_, len_); |
joeverbout | 0:ea44dc9ed014 | 119 | } |
joeverbout | 0:ea44dc9ed014 | 120 | |
joeverbout | 0:ea44dc9ed014 | 121 | inline |
joeverbout | 0:ea44dc9ed014 | 122 | String operator + (const String& lhs, const std::string& rhs) |
joeverbout | 0:ea44dc9ed014 | 123 | { |
joeverbout | 0:ea44dc9ed014 | 124 | String s; |
joeverbout | 0:ea44dc9ed014 | 125 | size_t rhslen = rhs.size(); |
joeverbout | 0:ea44dc9ed014 | 126 | s.allocate(lhs.len_ + rhslen); |
joeverbout | 0:ea44dc9ed014 | 127 | std::memcpy(s.cstr_, lhs.cstr_, lhs.len_); |
joeverbout | 0:ea44dc9ed014 | 128 | memcpy(s.cstr_ + lhs.len_, rhs.c_str(), rhslen); |
joeverbout | 0:ea44dc9ed014 | 129 | return s; |
joeverbout | 0:ea44dc9ed014 | 130 | } |
joeverbout | 0:ea44dc9ed014 | 131 | |
joeverbout | 0:ea44dc9ed014 | 132 | inline |
joeverbout | 0:ea44dc9ed014 | 133 | String operator + (const std::string& lhs, const String& rhs) |
joeverbout | 0:ea44dc9ed014 | 134 | { |
joeverbout | 0:ea44dc9ed014 | 135 | String s; |
joeverbout | 0:ea44dc9ed014 | 136 | size_t lhslen = lhs.size(); |
joeverbout | 0:ea44dc9ed014 | 137 | s.allocate(lhslen + rhs.len_); |
joeverbout | 0:ea44dc9ed014 | 138 | std::memcpy(s.cstr_, lhs.c_str(), lhslen); |
joeverbout | 0:ea44dc9ed014 | 139 | memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_); |
joeverbout | 0:ea44dc9ed014 | 140 | return s; |
joeverbout | 0:ea44dc9ed014 | 141 | } |
joeverbout | 0:ea44dc9ed014 | 142 | |
joeverbout | 0:ea44dc9ed014 | 143 | inline |
joeverbout | 0:ea44dc9ed014 | 144 | FileNode::operator std::string() const |
joeverbout | 0:ea44dc9ed014 | 145 | { |
joeverbout | 0:ea44dc9ed014 | 146 | String value; |
joeverbout | 0:ea44dc9ed014 | 147 | read(*this, value, value); |
joeverbout | 0:ea44dc9ed014 | 148 | return value; |
joeverbout | 0:ea44dc9ed014 | 149 | } |
joeverbout | 0:ea44dc9ed014 | 150 | |
joeverbout | 0:ea44dc9ed014 | 151 | template<> inline |
joeverbout | 0:ea44dc9ed014 | 152 | void operator >> (const FileNode& n, std::string& value) |
joeverbout | 0:ea44dc9ed014 | 153 | { |
joeverbout | 0:ea44dc9ed014 | 154 | String val; |
joeverbout | 0:ea44dc9ed014 | 155 | read(n, val, val); |
joeverbout | 0:ea44dc9ed014 | 156 | value = val; |
joeverbout | 0:ea44dc9ed014 | 157 | } |
joeverbout | 0:ea44dc9ed014 | 158 | |
joeverbout | 0:ea44dc9ed014 | 159 | template<> inline |
joeverbout | 0:ea44dc9ed014 | 160 | FileStorage& operator << (FileStorage& fs, const std::string& value) |
joeverbout | 0:ea44dc9ed014 | 161 | { |
joeverbout | 0:ea44dc9ed014 | 162 | return fs << cv::String(value); |
joeverbout | 0:ea44dc9ed014 | 163 | } |
joeverbout | 0:ea44dc9ed014 | 164 | |
joeverbout | 0:ea44dc9ed014 | 165 | static inline |
joeverbout | 0:ea44dc9ed014 | 166 | std::ostream& operator << (std::ostream& os, const String& str) |
joeverbout | 0:ea44dc9ed014 | 167 | { |
joeverbout | 0:ea44dc9ed014 | 168 | return os << str.c_str(); |
joeverbout | 0:ea44dc9ed014 | 169 | } |
joeverbout | 0:ea44dc9ed014 | 170 | |
joeverbout | 0:ea44dc9ed014 | 171 | static inline |
joeverbout | 0:ea44dc9ed014 | 172 | std::ostream& operator << (std::ostream& out, Ptr<Formatted> fmtd) |
joeverbout | 0:ea44dc9ed014 | 173 | { |
joeverbout | 0:ea44dc9ed014 | 174 | fmtd->reset(); |
joeverbout | 0:ea44dc9ed014 | 175 | for(const char* str = fmtd->next(); str; str = fmtd->next()) |
joeverbout | 0:ea44dc9ed014 | 176 | out << str; |
joeverbout | 0:ea44dc9ed014 | 177 | return out; |
joeverbout | 0:ea44dc9ed014 | 178 | } |
joeverbout | 0:ea44dc9ed014 | 179 | |
joeverbout | 0:ea44dc9ed014 | 180 | static inline |
joeverbout | 0:ea44dc9ed014 | 181 | std::ostream& operator << (std::ostream& out, const Mat& mtx) |
joeverbout | 0:ea44dc9ed014 | 182 | { |
joeverbout | 0:ea44dc9ed014 | 183 | return out << Formatter::get()->format(mtx); |
joeverbout | 0:ea44dc9ed014 | 184 | } |
joeverbout | 0:ea44dc9ed014 | 185 | |
joeverbout | 0:ea44dc9ed014 | 186 | template<typename _Tp> static inline |
joeverbout | 0:ea44dc9ed014 | 187 | std::ostream& operator << (std::ostream& out, const std::vector<Point_<_Tp> >& vec) |
joeverbout | 0:ea44dc9ed014 | 188 | { |
joeverbout | 0:ea44dc9ed014 | 189 | return out << Formatter::get()->format(Mat(vec)); |
joeverbout | 0:ea44dc9ed014 | 190 | } |
joeverbout | 0:ea44dc9ed014 | 191 | |
joeverbout | 0:ea44dc9ed014 | 192 | |
joeverbout | 0:ea44dc9ed014 | 193 | template<typename _Tp> static inline |
joeverbout | 0:ea44dc9ed014 | 194 | std::ostream& operator << (std::ostream& out, const std::vector<Point3_<_Tp> >& vec) |
joeverbout | 0:ea44dc9ed014 | 195 | { |
joeverbout | 0:ea44dc9ed014 | 196 | return out << Formatter::get()->format(Mat(vec)); |
joeverbout | 0:ea44dc9ed014 | 197 | } |
joeverbout | 0:ea44dc9ed014 | 198 | |
joeverbout | 0:ea44dc9ed014 | 199 | |
joeverbout | 0:ea44dc9ed014 | 200 | template<typename _Tp, int m, int n> static inline |
joeverbout | 0:ea44dc9ed014 | 201 | std::ostream& operator << (std::ostream& out, const Matx<_Tp, m, n>& matx) |
joeverbout | 0:ea44dc9ed014 | 202 | { |
joeverbout | 0:ea44dc9ed014 | 203 | return out << Formatter::get()->format(Mat(matx)); |
joeverbout | 0:ea44dc9ed014 | 204 | } |
joeverbout | 0:ea44dc9ed014 | 205 | |
joeverbout | 0:ea44dc9ed014 | 206 | template<typename _Tp> static inline |
joeverbout | 0:ea44dc9ed014 | 207 | std::ostream& operator << (std::ostream& out, const Point_<_Tp>& p) |
joeverbout | 0:ea44dc9ed014 | 208 | { |
joeverbout | 0:ea44dc9ed014 | 209 | out << "[" << p.x << ", " << p.y << "]"; |
joeverbout | 0:ea44dc9ed014 | 210 | return out; |
joeverbout | 0:ea44dc9ed014 | 211 | } |
joeverbout | 0:ea44dc9ed014 | 212 | |
joeverbout | 0:ea44dc9ed014 | 213 | template<typename _Tp> static inline |
joeverbout | 0:ea44dc9ed014 | 214 | std::ostream& operator << (std::ostream& out, const Point3_<_Tp>& p) |
joeverbout | 0:ea44dc9ed014 | 215 | { |
joeverbout | 0:ea44dc9ed014 | 216 | out << "[" << p.x << ", " << p.y << ", " << p.z << "]"; |
joeverbout | 0:ea44dc9ed014 | 217 | return out; |
joeverbout | 0:ea44dc9ed014 | 218 | } |
joeverbout | 0:ea44dc9ed014 | 219 | |
joeverbout | 0:ea44dc9ed014 | 220 | template<typename _Tp, int n> static inline |
joeverbout | 0:ea44dc9ed014 | 221 | std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec) |
joeverbout | 0:ea44dc9ed014 | 222 | { |
joeverbout | 0:ea44dc9ed014 | 223 | out << "["; |
joeverbout | 0:ea44dc9ed014 | 224 | #ifdef _MSC_VER |
joeverbout | 0:ea44dc9ed014 | 225 | #pragma warning( push ) |
joeverbout | 0:ea44dc9ed014 | 226 | #pragma warning( disable: 4127 ) |
joeverbout | 0:ea44dc9ed014 | 227 | #endif |
joeverbout | 0:ea44dc9ed014 | 228 | if(Vec<_Tp, n>::depth < CV_32F) |
joeverbout | 0:ea44dc9ed014 | 229 | #ifdef _MSC_VER |
joeverbout | 0:ea44dc9ed014 | 230 | #pragma warning( pop ) |
joeverbout | 0:ea44dc9ed014 | 231 | #endif |
joeverbout | 0:ea44dc9ed014 | 232 | { |
joeverbout | 0:ea44dc9ed014 | 233 | for (int i = 0; i < n - 1; ++i) { |
joeverbout | 0:ea44dc9ed014 | 234 | out << (int)vec[i] << ", "; |
joeverbout | 0:ea44dc9ed014 | 235 | } |
joeverbout | 0:ea44dc9ed014 | 236 | out << (int)vec[n-1] << "]"; |
joeverbout | 0:ea44dc9ed014 | 237 | } |
joeverbout | 0:ea44dc9ed014 | 238 | else |
joeverbout | 0:ea44dc9ed014 | 239 | { |
joeverbout | 0:ea44dc9ed014 | 240 | for (int i = 0; i < n - 1; ++i) { |
joeverbout | 0:ea44dc9ed014 | 241 | out << vec[i] << ", "; |
joeverbout | 0:ea44dc9ed014 | 242 | } |
joeverbout | 0:ea44dc9ed014 | 243 | out << vec[n-1] << "]"; |
joeverbout | 0:ea44dc9ed014 | 244 | } |
joeverbout | 0:ea44dc9ed014 | 245 | |
joeverbout | 0:ea44dc9ed014 | 246 | return out; |
joeverbout | 0:ea44dc9ed014 | 247 | } |
joeverbout | 0:ea44dc9ed014 | 248 | |
joeverbout | 0:ea44dc9ed014 | 249 | template<typename _Tp> static inline |
joeverbout | 0:ea44dc9ed014 | 250 | std::ostream& operator << (std::ostream& out, const Size_<_Tp>& size) |
joeverbout | 0:ea44dc9ed014 | 251 | { |
joeverbout | 0:ea44dc9ed014 | 252 | return out << "[" << size.width << " x " << size.height << "]"; |
joeverbout | 0:ea44dc9ed014 | 253 | } |
joeverbout | 0:ea44dc9ed014 | 254 | |
joeverbout | 0:ea44dc9ed014 | 255 | template<typename _Tp> static inline |
joeverbout | 0:ea44dc9ed014 | 256 | std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect) |
joeverbout | 0:ea44dc9ed014 | 257 | { |
joeverbout | 0:ea44dc9ed014 | 258 | return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]"; |
joeverbout | 0:ea44dc9ed014 | 259 | } |
joeverbout | 0:ea44dc9ed014 | 260 | |
joeverbout | 0:ea44dc9ed014 | 261 | |
joeverbout | 0:ea44dc9ed014 | 262 | #endif // OPENCV_NOSTL |
joeverbout | 0:ea44dc9ed014 | 263 | } // cv |
joeverbout | 0:ea44dc9ed014 | 264 | |
joeverbout | 0:ea44dc9ed014 | 265 | //! @endcond |
joeverbout | 0:ea44dc9ed014 | 266 | |
joeverbout | 0:ea44dc9ed014 | 267 | #endif // __OPENCV_CORE_CVSTDINL_HPP__ |
joeverbout | 0:ea44dc9ed014 | 268 |