openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

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?

UserRevisionLine numberNew 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_CVSTDINL_HPP
RyoheiHagimoto 0:0e0631af0305 45 #define OPENCV_CORE_CVSTDINL_HPP
RyoheiHagimoto 0:0e0631af0305 46
RyoheiHagimoto 0:0e0631af0305 47 #ifndef OPENCV_NOSTL
RyoheiHagimoto 0:0e0631af0305 48 # include <complex>
RyoheiHagimoto 0:0e0631af0305 49 # include <ostream>
RyoheiHagimoto 0:0e0631af0305 50 #endif
RyoheiHagimoto 0:0e0631af0305 51
RyoheiHagimoto 0:0e0631af0305 52 //! @cond IGNORED
RyoheiHagimoto 0:0e0631af0305 53
RyoheiHagimoto 0:0e0631af0305 54 namespace cv
RyoheiHagimoto 0:0e0631af0305 55 {
RyoheiHagimoto 0:0e0631af0305 56 #ifndef OPENCV_NOSTL
RyoheiHagimoto 0:0e0631af0305 57
RyoheiHagimoto 0:0e0631af0305 58 template<typename _Tp> class DataType< std::complex<_Tp> >
RyoheiHagimoto 0:0e0631af0305 59 {
RyoheiHagimoto 0:0e0631af0305 60 public:
RyoheiHagimoto 0:0e0631af0305 61 typedef std::complex<_Tp> value_type;
RyoheiHagimoto 0:0e0631af0305 62 typedef value_type work_type;
RyoheiHagimoto 0:0e0631af0305 63 typedef _Tp channel_type;
RyoheiHagimoto 0:0e0631af0305 64
RyoheiHagimoto 0:0e0631af0305 65 enum { generic_type = 0,
RyoheiHagimoto 0:0e0631af0305 66 depth = DataType<channel_type>::depth,
RyoheiHagimoto 0:0e0631af0305 67 channels = 2,
RyoheiHagimoto 0:0e0631af0305 68 fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
RyoheiHagimoto 0:0e0631af0305 69 type = CV_MAKETYPE(depth, channels) };
RyoheiHagimoto 0:0e0631af0305 70
RyoheiHagimoto 0:0e0631af0305 71 typedef Vec<channel_type, channels> vec_type;
RyoheiHagimoto 0:0e0631af0305 72 };
RyoheiHagimoto 0:0e0631af0305 73
RyoheiHagimoto 0:0e0631af0305 74 inline
RyoheiHagimoto 0:0e0631af0305 75 String::String(const std::string& str)
RyoheiHagimoto 0:0e0631af0305 76 : cstr_(0), len_(0)
RyoheiHagimoto 0:0e0631af0305 77 {
RyoheiHagimoto 0:0e0631af0305 78 if (!str.empty())
RyoheiHagimoto 0:0e0631af0305 79 {
RyoheiHagimoto 0:0e0631af0305 80 size_t len = str.size();
RyoheiHagimoto 0:0e0631af0305 81 memcpy(allocate(len), str.c_str(), len);
RyoheiHagimoto 0:0e0631af0305 82 }
RyoheiHagimoto 0:0e0631af0305 83 }
RyoheiHagimoto 0:0e0631af0305 84
RyoheiHagimoto 0:0e0631af0305 85 inline
RyoheiHagimoto 0:0e0631af0305 86 String::String(const std::string& str, size_t pos, size_t len)
RyoheiHagimoto 0:0e0631af0305 87 : cstr_(0), len_(0)
RyoheiHagimoto 0:0e0631af0305 88 {
RyoheiHagimoto 0:0e0631af0305 89 size_t strlen = str.size();
RyoheiHagimoto 0:0e0631af0305 90 pos = min(pos, strlen);
RyoheiHagimoto 0:0e0631af0305 91 len = min(strlen - pos, len);
RyoheiHagimoto 0:0e0631af0305 92 if (!len) return;
RyoheiHagimoto 0:0e0631af0305 93 memcpy(allocate(len), str.c_str() + pos, len);
RyoheiHagimoto 0:0e0631af0305 94 }
RyoheiHagimoto 0:0e0631af0305 95
RyoheiHagimoto 0:0e0631af0305 96 inline
RyoheiHagimoto 0:0e0631af0305 97 String& String::operator = (const std::string& str)
RyoheiHagimoto 0:0e0631af0305 98 {
RyoheiHagimoto 0:0e0631af0305 99 deallocate();
RyoheiHagimoto 0:0e0631af0305 100 if (!str.empty())
RyoheiHagimoto 0:0e0631af0305 101 {
RyoheiHagimoto 0:0e0631af0305 102 size_t len = str.size();
RyoheiHagimoto 0:0e0631af0305 103 memcpy(allocate(len), str.c_str(), len);
RyoheiHagimoto 0:0e0631af0305 104 }
RyoheiHagimoto 0:0e0631af0305 105 return *this;
RyoheiHagimoto 0:0e0631af0305 106 }
RyoheiHagimoto 0:0e0631af0305 107
RyoheiHagimoto 0:0e0631af0305 108 inline
RyoheiHagimoto 0:0e0631af0305 109 String& String::operator += (const std::string& str)
RyoheiHagimoto 0:0e0631af0305 110 {
RyoheiHagimoto 0:0e0631af0305 111 *this = *this + str;
RyoheiHagimoto 0:0e0631af0305 112 return *this;
RyoheiHagimoto 0:0e0631af0305 113 }
RyoheiHagimoto 0:0e0631af0305 114
RyoheiHagimoto 0:0e0631af0305 115 inline
RyoheiHagimoto 0:0e0631af0305 116 String::operator std::string() const
RyoheiHagimoto 0:0e0631af0305 117 {
RyoheiHagimoto 0:0e0631af0305 118 return std::string(cstr_, len_);
RyoheiHagimoto 0:0e0631af0305 119 }
RyoheiHagimoto 0:0e0631af0305 120
RyoheiHagimoto 0:0e0631af0305 121 inline
RyoheiHagimoto 0:0e0631af0305 122 String operator + (const String& lhs, const std::string& rhs)
RyoheiHagimoto 0:0e0631af0305 123 {
RyoheiHagimoto 0:0e0631af0305 124 String s;
RyoheiHagimoto 0:0e0631af0305 125 size_t rhslen = rhs.size();
RyoheiHagimoto 0:0e0631af0305 126 s.allocate(lhs.len_ + rhslen);
RyoheiHagimoto 0:0e0631af0305 127 memcpy(s.cstr_, lhs.cstr_, lhs.len_);
RyoheiHagimoto 0:0e0631af0305 128 memcpy(s.cstr_ + lhs.len_, rhs.c_str(), rhslen);
RyoheiHagimoto 0:0e0631af0305 129 return s;
RyoheiHagimoto 0:0e0631af0305 130 }
RyoheiHagimoto 0:0e0631af0305 131
RyoheiHagimoto 0:0e0631af0305 132 inline
RyoheiHagimoto 0:0e0631af0305 133 String operator + (const std::string& lhs, const String& rhs)
RyoheiHagimoto 0:0e0631af0305 134 {
RyoheiHagimoto 0:0e0631af0305 135 String s;
RyoheiHagimoto 0:0e0631af0305 136 size_t lhslen = lhs.size();
RyoheiHagimoto 0:0e0631af0305 137 s.allocate(lhslen + rhs.len_);
RyoheiHagimoto 0:0e0631af0305 138 memcpy(s.cstr_, lhs.c_str(), lhslen);
RyoheiHagimoto 0:0e0631af0305 139 memcpy(s.cstr_ + lhslen, rhs.cstr_, rhs.len_);
RyoheiHagimoto 0:0e0631af0305 140 return s;
RyoheiHagimoto 0:0e0631af0305 141 }
RyoheiHagimoto 0:0e0631af0305 142
RyoheiHagimoto 0:0e0631af0305 143 inline
RyoheiHagimoto 0:0e0631af0305 144 FileNode::operator std::string() const
RyoheiHagimoto 0:0e0631af0305 145 {
RyoheiHagimoto 0:0e0631af0305 146 String value;
RyoheiHagimoto 0:0e0631af0305 147 read(*this, value, value);
RyoheiHagimoto 0:0e0631af0305 148 return value;
RyoheiHagimoto 0:0e0631af0305 149 }
RyoheiHagimoto 0:0e0631af0305 150
RyoheiHagimoto 0:0e0631af0305 151 template<> inline
RyoheiHagimoto 0:0e0631af0305 152 void operator >> (const FileNode& n, std::string& value)
RyoheiHagimoto 0:0e0631af0305 153 {
RyoheiHagimoto 0:0e0631af0305 154 String val;
RyoheiHagimoto 0:0e0631af0305 155 read(n, val, val);
RyoheiHagimoto 0:0e0631af0305 156 value = val;
RyoheiHagimoto 0:0e0631af0305 157 }
RyoheiHagimoto 0:0e0631af0305 158
RyoheiHagimoto 0:0e0631af0305 159 template<> inline
RyoheiHagimoto 0:0e0631af0305 160 FileStorage& operator << (FileStorage& fs, const std::string& value)
RyoheiHagimoto 0:0e0631af0305 161 {
RyoheiHagimoto 0:0e0631af0305 162 return fs << cv::String(value);
RyoheiHagimoto 0:0e0631af0305 163 }
RyoheiHagimoto 0:0e0631af0305 164
RyoheiHagimoto 0:0e0631af0305 165 static inline
RyoheiHagimoto 0:0e0631af0305 166 std::ostream& operator << (std::ostream& os, const String& str)
RyoheiHagimoto 0:0e0631af0305 167 {
RyoheiHagimoto 0:0e0631af0305 168 return os << str.c_str();
RyoheiHagimoto 0:0e0631af0305 169 }
RyoheiHagimoto 0:0e0631af0305 170
RyoheiHagimoto 0:0e0631af0305 171 static inline
RyoheiHagimoto 0:0e0631af0305 172 std::ostream& operator << (std::ostream& out, Ptr<Formatted> fmtd)
RyoheiHagimoto 0:0e0631af0305 173 {
RyoheiHagimoto 0:0e0631af0305 174 fmtd->reset();
RyoheiHagimoto 0:0e0631af0305 175 for(const char* str = fmtd->next(); str; str = fmtd->next())
RyoheiHagimoto 0:0e0631af0305 176 out << str;
RyoheiHagimoto 0:0e0631af0305 177 return out;
RyoheiHagimoto 0:0e0631af0305 178 }
RyoheiHagimoto 0:0e0631af0305 179
RyoheiHagimoto 0:0e0631af0305 180 static inline
RyoheiHagimoto 0:0e0631af0305 181 std::ostream& operator << (std::ostream& out, const Mat& mtx)
RyoheiHagimoto 0:0e0631af0305 182 {
RyoheiHagimoto 0:0e0631af0305 183 return out << Formatter::get()->format(mtx);
RyoheiHagimoto 0:0e0631af0305 184 }
RyoheiHagimoto 0:0e0631af0305 185
RyoheiHagimoto 0:0e0631af0305 186 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 187 std::ostream& operator << (std::ostream& out, const std::vector<Point_<_Tp> >& vec)
RyoheiHagimoto 0:0e0631af0305 188 {
RyoheiHagimoto 0:0e0631af0305 189 return out << Formatter::get()->format(Mat(vec));
RyoheiHagimoto 0:0e0631af0305 190 }
RyoheiHagimoto 0:0e0631af0305 191
RyoheiHagimoto 0:0e0631af0305 192
RyoheiHagimoto 0:0e0631af0305 193 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 194 std::ostream& operator << (std::ostream& out, const std::vector<Point3_<_Tp> >& vec)
RyoheiHagimoto 0:0e0631af0305 195 {
RyoheiHagimoto 0:0e0631af0305 196 return out << Formatter::get()->format(Mat(vec));
RyoheiHagimoto 0:0e0631af0305 197 }
RyoheiHagimoto 0:0e0631af0305 198
RyoheiHagimoto 0:0e0631af0305 199
RyoheiHagimoto 0:0e0631af0305 200 template<typename _Tp, int m, int n> static inline
RyoheiHagimoto 0:0e0631af0305 201 std::ostream& operator << (std::ostream& out, const Matx<_Tp, m, n>& matx)
RyoheiHagimoto 0:0e0631af0305 202 {
RyoheiHagimoto 0:0e0631af0305 203 return out << Formatter::get()->format(Mat(matx));
RyoheiHagimoto 0:0e0631af0305 204 }
RyoheiHagimoto 0:0e0631af0305 205
RyoheiHagimoto 0:0e0631af0305 206 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 207 std::ostream& operator << (std::ostream& out, const Point_<_Tp>& p)
RyoheiHagimoto 0:0e0631af0305 208 {
RyoheiHagimoto 0:0e0631af0305 209 out << "[" << p.x << ", " << p.y << "]";
RyoheiHagimoto 0:0e0631af0305 210 return out;
RyoheiHagimoto 0:0e0631af0305 211 }
RyoheiHagimoto 0:0e0631af0305 212
RyoheiHagimoto 0:0e0631af0305 213 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 214 std::ostream& operator << (std::ostream& out, const Point3_<_Tp>& p)
RyoheiHagimoto 0:0e0631af0305 215 {
RyoheiHagimoto 0:0e0631af0305 216 out << "[" << p.x << ", " << p.y << ", " << p.z << "]";
RyoheiHagimoto 0:0e0631af0305 217 return out;
RyoheiHagimoto 0:0e0631af0305 218 }
RyoheiHagimoto 0:0e0631af0305 219
RyoheiHagimoto 0:0e0631af0305 220 template<typename _Tp, int n> static inline
RyoheiHagimoto 0:0e0631af0305 221 std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec)
RyoheiHagimoto 0:0e0631af0305 222 {
RyoheiHagimoto 0:0e0631af0305 223 out << "[";
RyoheiHagimoto 0:0e0631af0305 224 #ifdef _MSC_VER
RyoheiHagimoto 0:0e0631af0305 225 #pragma warning( push )
RyoheiHagimoto 0:0e0631af0305 226 #pragma warning( disable: 4127 )
RyoheiHagimoto 0:0e0631af0305 227 #endif
RyoheiHagimoto 0:0e0631af0305 228 if(Vec<_Tp, n>::depth < CV_32F)
RyoheiHagimoto 0:0e0631af0305 229 #ifdef _MSC_VER
RyoheiHagimoto 0:0e0631af0305 230 #pragma warning( pop )
RyoheiHagimoto 0:0e0631af0305 231 #endif
RyoheiHagimoto 0:0e0631af0305 232 {
RyoheiHagimoto 0:0e0631af0305 233 for (int i = 0; i < n - 1; ++i) {
RyoheiHagimoto 0:0e0631af0305 234 out << (int)vec[i] << ", ";
RyoheiHagimoto 0:0e0631af0305 235 }
RyoheiHagimoto 0:0e0631af0305 236 out << (int)vec[n-1] << "]";
RyoheiHagimoto 0:0e0631af0305 237 }
RyoheiHagimoto 0:0e0631af0305 238 else
RyoheiHagimoto 0:0e0631af0305 239 {
RyoheiHagimoto 0:0e0631af0305 240 for (int i = 0; i < n - 1; ++i) {
RyoheiHagimoto 0:0e0631af0305 241 out << vec[i] << ", ";
RyoheiHagimoto 0:0e0631af0305 242 }
RyoheiHagimoto 0:0e0631af0305 243 out << vec[n-1] << "]";
RyoheiHagimoto 0:0e0631af0305 244 }
RyoheiHagimoto 0:0e0631af0305 245
RyoheiHagimoto 0:0e0631af0305 246 return out;
RyoheiHagimoto 0:0e0631af0305 247 }
RyoheiHagimoto 0:0e0631af0305 248
RyoheiHagimoto 0:0e0631af0305 249 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 250 std::ostream& operator << (std::ostream& out, const Size_<_Tp>& size)
RyoheiHagimoto 0:0e0631af0305 251 {
RyoheiHagimoto 0:0e0631af0305 252 return out << "[" << size.width << " x " << size.height << "]";
RyoheiHagimoto 0:0e0631af0305 253 }
RyoheiHagimoto 0:0e0631af0305 254
RyoheiHagimoto 0:0e0631af0305 255 template<typename _Tp> static inline
RyoheiHagimoto 0:0e0631af0305 256 std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect)
RyoheiHagimoto 0:0e0631af0305 257 {
RyoheiHagimoto 0:0e0631af0305 258 return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
RyoheiHagimoto 0:0e0631af0305 259 }
RyoheiHagimoto 0:0e0631af0305 260
RyoheiHagimoto 0:0e0631af0305 261
RyoheiHagimoto 0:0e0631af0305 262 #endif // OPENCV_NOSTL
RyoheiHagimoto 0:0e0631af0305 263 } // cv
RyoheiHagimoto 0:0e0631af0305 264
RyoheiHagimoto 0:0e0631af0305 265 //! @endcond
RyoheiHagimoto 0:0e0631af0305 266
RyoheiHagimoto 0:0e0631af0305 267 #endif // OPENCV_CORE_CVSTDINL_HPP