openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/core/mat.inl.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 | // Copyright (C) 2015, Itseez Inc., all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 17 | // Third party copyrights are property of their respective owners. |
RyoheiHagimoto | 0:0e0631af0305 | 18 | // |
RyoheiHagimoto | 0:0e0631af0305 | 19 | // Redistribution and use in source and binary forms, with or without modification, |
RyoheiHagimoto | 0:0e0631af0305 | 20 | // are permitted provided that the following conditions are met: |
RyoheiHagimoto | 0:0e0631af0305 | 21 | // |
RyoheiHagimoto | 0:0e0631af0305 | 22 | // * Redistribution's of source code must retain the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 23 | // this list of conditions and the following disclaimer. |
RyoheiHagimoto | 0:0e0631af0305 | 24 | // |
RyoheiHagimoto | 0:0e0631af0305 | 25 | // * Redistribution's in binary form must reproduce the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 26 | // this list of conditions and the following disclaimer in the documentation |
RyoheiHagimoto | 0:0e0631af0305 | 27 | // and/or other materials provided with the distribution. |
RyoheiHagimoto | 0:0e0631af0305 | 28 | // |
RyoheiHagimoto | 0:0e0631af0305 | 29 | // * The name of the copyright holders may not be used to endorse or promote products |
RyoheiHagimoto | 0:0e0631af0305 | 30 | // derived from this software without specific prior written permission. |
RyoheiHagimoto | 0:0e0631af0305 | 31 | // |
RyoheiHagimoto | 0:0e0631af0305 | 32 | // This software is provided by the copyright holders and contributors "as is" and |
RyoheiHagimoto | 0:0e0631af0305 | 33 | // any express or implied warranties, including, but not limited to, the implied |
RyoheiHagimoto | 0:0e0631af0305 | 34 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
RyoheiHagimoto | 0:0e0631af0305 | 35 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
RyoheiHagimoto | 0:0e0631af0305 | 36 | // indirect, incidental, special, exemplary, or consequential damages |
RyoheiHagimoto | 0:0e0631af0305 | 37 | // (including, but not limited to, procurement of substitute goods or services; |
RyoheiHagimoto | 0:0e0631af0305 | 38 | // loss of use, data, or profits; or business interruption) however caused |
RyoheiHagimoto | 0:0e0631af0305 | 39 | // and on any theory of liability, whether in contract, strict liability, |
RyoheiHagimoto | 0:0e0631af0305 | 40 | // or tort (including negligence or otherwise) arising in any way out of |
RyoheiHagimoto | 0:0e0631af0305 | 41 | // the use of this software, even if advised of the possibility of such damage. |
RyoheiHagimoto | 0:0e0631af0305 | 42 | // |
RyoheiHagimoto | 0:0e0631af0305 | 43 | //M*/ |
RyoheiHagimoto | 0:0e0631af0305 | 44 | |
RyoheiHagimoto | 0:0e0631af0305 | 45 | #ifndef OPENCV_CORE_MATRIX_OPERATIONS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 46 | #define OPENCV_CORE_MATRIX_OPERATIONS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 47 | |
RyoheiHagimoto | 0:0e0631af0305 | 48 | #ifndef __cplusplus |
RyoheiHagimoto | 0:0e0631af0305 | 49 | # error mat.inl.hpp header must be compiled as C++ |
RyoheiHagimoto | 0:0e0631af0305 | 50 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 51 | |
RyoheiHagimoto | 0:0e0631af0305 | 52 | namespace cv |
RyoheiHagimoto | 0:0e0631af0305 | 53 | { |
RyoheiHagimoto | 0:0e0631af0305 | 54 | |
RyoheiHagimoto | 0:0e0631af0305 | 55 | //! @cond IGNORED |
RyoheiHagimoto | 0:0e0631af0305 | 56 | |
RyoheiHagimoto | 0:0e0631af0305 | 57 | //////////////////////// Input/Output Arrays //////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 58 | |
RyoheiHagimoto | 0:0e0631af0305 | 59 | inline void _InputArray::init(int _flags, const void* _obj) |
RyoheiHagimoto | 0:0e0631af0305 | 60 | { flags = _flags; obj = (void*)_obj; } |
RyoheiHagimoto | 0:0e0631af0305 | 61 | |
RyoheiHagimoto | 0:0e0631af0305 | 62 | inline void _InputArray::init(int _flags, const void* _obj, Size _sz) |
RyoheiHagimoto | 0:0e0631af0305 | 63 | { flags = _flags; obj = (void*)_obj; sz = _sz; } |
RyoheiHagimoto | 0:0e0631af0305 | 64 | |
RyoheiHagimoto | 0:0e0631af0305 | 65 | inline void* _InputArray::getObj() const { return obj; } |
RyoheiHagimoto | 0:0e0631af0305 | 66 | inline int _InputArray::getFlags() const { return flags; } |
RyoheiHagimoto | 0:0e0631af0305 | 67 | inline Size _InputArray::getSz() const { return sz; } |
RyoheiHagimoto | 0:0e0631af0305 | 68 | |
RyoheiHagimoto | 0:0e0631af0305 | 69 | inline _InputArray::_InputArray() { init(NONE, 0); } |
RyoheiHagimoto | 0:0e0631af0305 | 70 | inline _InputArray::_InputArray(int _flags, void* _obj) { init(_flags, _obj); } |
RyoheiHagimoto | 0:0e0631af0305 | 71 | inline _InputArray::_InputArray(const Mat& m) { init(MAT+ACCESS_READ, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 72 | inline _InputArray::_InputArray(const std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_READ, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 73 | inline _InputArray::_InputArray(const UMat& m) { init(UMAT+ACCESS_READ, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 74 | inline _InputArray::_InputArray(const std::vector<UMat>& vec) { init(STD_VECTOR_UMAT+ACCESS_READ, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 75 | |
RyoheiHagimoto | 0:0e0631af0305 | 76 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 77 | _InputArray::_InputArray(const std::vector<_Tp>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 78 | { init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_READ, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 79 | |
RyoheiHagimoto | 0:0e0631af0305 | 80 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 81 | _InputArray::_InputArray(const std::vector<bool>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 82 | { init(FIXED_TYPE + STD_BOOL_VECTOR + DataType<bool>::type + ACCESS_READ, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 83 | |
RyoheiHagimoto | 0:0e0631af0305 | 84 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 85 | _InputArray::_InputArray(const std::vector<std::vector<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 86 | { init(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_READ, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 87 | |
RyoheiHagimoto | 0:0e0631af0305 | 88 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 89 | _InputArray::_InputArray(const std::vector<Mat_<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 90 | { init(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_READ, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 91 | |
RyoheiHagimoto | 0:0e0631af0305 | 92 | template<typename _Tp, int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 93 | _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx) |
RyoheiHagimoto | 0:0e0631af0305 | 94 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_READ, &mtx, Size(n, m)); } |
RyoheiHagimoto | 0:0e0631af0305 | 95 | |
RyoheiHagimoto | 0:0e0631af0305 | 96 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 97 | _InputArray::_InputArray(const _Tp* vec, int n) |
RyoheiHagimoto | 0:0e0631af0305 | 98 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_READ, vec, Size(n, 1)); } |
RyoheiHagimoto | 0:0e0631af0305 | 99 | |
RyoheiHagimoto | 0:0e0631af0305 | 100 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 101 | _InputArray::_InputArray(const Mat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 102 | { init(FIXED_TYPE + MAT + DataType<_Tp>::type + ACCESS_READ, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 103 | |
RyoheiHagimoto | 0:0e0631af0305 | 104 | inline _InputArray::_InputArray(const double& val) |
RyoheiHagimoto | 0:0e0631af0305 | 105 | { init(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F + ACCESS_READ, &val, Size(1,1)); } |
RyoheiHagimoto | 0:0e0631af0305 | 106 | |
RyoheiHagimoto | 0:0e0631af0305 | 107 | inline _InputArray::_InputArray(const MatExpr& expr) |
RyoheiHagimoto | 0:0e0631af0305 | 108 | { init(FIXED_TYPE + FIXED_SIZE + EXPR + ACCESS_READ, &expr); } |
RyoheiHagimoto | 0:0e0631af0305 | 109 | |
RyoheiHagimoto | 0:0e0631af0305 | 110 | inline _InputArray::_InputArray(const cuda::GpuMat& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 111 | { init(CUDA_GPU_MAT + ACCESS_READ, &d_mat); } |
RyoheiHagimoto | 0:0e0631af0305 | 112 | |
RyoheiHagimoto | 0:0e0631af0305 | 113 | inline _InputArray::_InputArray(const std::vector<cuda::GpuMat>& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 114 | { init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_READ, &d_mat);} |
RyoheiHagimoto | 0:0e0631af0305 | 115 | |
RyoheiHagimoto | 0:0e0631af0305 | 116 | inline _InputArray::_InputArray(const ogl::Buffer& buf) |
RyoheiHagimoto | 0:0e0631af0305 | 117 | { init(OPENGL_BUFFER + ACCESS_READ, &buf); } |
RyoheiHagimoto | 0:0e0631af0305 | 118 | |
RyoheiHagimoto | 0:0e0631af0305 | 119 | inline _InputArray::_InputArray(const cuda::HostMem& cuda_mem) |
RyoheiHagimoto | 0:0e0631af0305 | 120 | { init(CUDA_HOST_MEM + ACCESS_READ, &cuda_mem); } |
RyoheiHagimoto | 0:0e0631af0305 | 121 | |
RyoheiHagimoto | 0:0e0631af0305 | 122 | inline _InputArray::~_InputArray() {} |
RyoheiHagimoto | 0:0e0631af0305 | 123 | |
RyoheiHagimoto | 0:0e0631af0305 | 124 | inline Mat _InputArray::getMat(int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 125 | { |
RyoheiHagimoto | 0:0e0631af0305 | 126 | if( kind() == MAT && i < 0 ) |
RyoheiHagimoto | 0:0e0631af0305 | 127 | return *(const Mat*)obj; |
RyoheiHagimoto | 0:0e0631af0305 | 128 | return getMat_(i); |
RyoheiHagimoto | 0:0e0631af0305 | 129 | } |
RyoheiHagimoto | 0:0e0631af0305 | 130 | |
RyoheiHagimoto | 0:0e0631af0305 | 131 | inline bool _InputArray::isMat() const { return kind() == _InputArray::MAT; } |
RyoheiHagimoto | 0:0e0631af0305 | 132 | inline bool _InputArray::isUMat() const { return kind() == _InputArray::UMAT; } |
RyoheiHagimoto | 0:0e0631af0305 | 133 | inline bool _InputArray::isMatVector() const { return kind() == _InputArray::STD_VECTOR_MAT; } |
RyoheiHagimoto | 0:0e0631af0305 | 134 | inline bool _InputArray::isUMatVector() const { return kind() == _InputArray::STD_VECTOR_UMAT; } |
RyoheiHagimoto | 0:0e0631af0305 | 135 | inline bool _InputArray::isMatx() const { return kind() == _InputArray::MATX; } |
RyoheiHagimoto | 0:0e0631af0305 | 136 | inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR || kind() == _InputArray::STD_BOOL_VECTOR; } |
RyoheiHagimoto | 0:0e0631af0305 | 137 | inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray::STD_VECTOR_CUDA_GPU_MAT; } |
RyoheiHagimoto | 0:0e0631af0305 | 138 | |
RyoheiHagimoto | 0:0e0631af0305 | 139 | //////////////////////////////////////////////////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 140 | |
RyoheiHagimoto | 0:0e0631af0305 | 141 | inline _OutputArray::_OutputArray() { init(ACCESS_WRITE, 0); } |
RyoheiHagimoto | 0:0e0631af0305 | 142 | inline _OutputArray::_OutputArray(int _flags, void* _obj) { init(_flags|ACCESS_WRITE, _obj); } |
RyoheiHagimoto | 0:0e0631af0305 | 143 | inline _OutputArray::_OutputArray(Mat& m) { init(MAT+ACCESS_WRITE, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 144 | inline _OutputArray::_OutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 145 | inline _OutputArray::_OutputArray(UMat& m) { init(UMAT+ACCESS_WRITE, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 146 | inline _OutputArray::_OutputArray(std::vector<UMat>& vec) { init(STD_VECTOR_UMAT+ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 147 | |
RyoheiHagimoto | 0:0e0631af0305 | 148 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 149 | _OutputArray::_OutputArray(std::vector<_Tp>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 150 | { init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 151 | |
RyoheiHagimoto | 0:0e0631af0305 | 152 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 153 | _OutputArray::_OutputArray(std::vector<bool>&) |
RyoheiHagimoto | 0:0e0631af0305 | 154 | { CV_Error(Error::StsUnsupportedFormat, "std::vector<bool> cannot be an output array\n"); } |
RyoheiHagimoto | 0:0e0631af0305 | 155 | |
RyoheiHagimoto | 0:0e0631af0305 | 156 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 157 | _OutputArray::_OutputArray(std::vector<std::vector<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 158 | { init(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 159 | |
RyoheiHagimoto | 0:0e0631af0305 | 160 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 161 | _OutputArray::_OutputArray(std::vector<Mat_<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 162 | { init(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 163 | |
RyoheiHagimoto | 0:0e0631af0305 | 164 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 165 | _OutputArray::_OutputArray(Mat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 166 | { init(FIXED_TYPE + MAT + DataType<_Tp>::type + ACCESS_WRITE, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 167 | |
RyoheiHagimoto | 0:0e0631af0305 | 168 | template<typename _Tp, int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 169 | _OutputArray::_OutputArray(Matx<_Tp, m, n>& mtx) |
RyoheiHagimoto | 0:0e0631af0305 | 170 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_WRITE, &mtx, Size(n, m)); } |
RyoheiHagimoto | 0:0e0631af0305 | 171 | |
RyoheiHagimoto | 0:0e0631af0305 | 172 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 173 | _OutputArray::_OutputArray(_Tp* vec, int n) |
RyoheiHagimoto | 0:0e0631af0305 | 174 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_WRITE, vec, Size(n, 1)); } |
RyoheiHagimoto | 0:0e0631af0305 | 175 | |
RyoheiHagimoto | 0:0e0631af0305 | 176 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 177 | _OutputArray::_OutputArray(const std::vector<_Tp>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 178 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 179 | |
RyoheiHagimoto | 0:0e0631af0305 | 180 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 181 | _OutputArray::_OutputArray(const std::vector<std::vector<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 182 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 183 | |
RyoheiHagimoto | 0:0e0631af0305 | 184 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 185 | _OutputArray::_OutputArray(const std::vector<Mat_<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 186 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 187 | |
RyoheiHagimoto | 0:0e0631af0305 | 188 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 189 | _OutputArray::_OutputArray(const Mat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 190 | { init(FIXED_TYPE + FIXED_SIZE + MAT + DataType<_Tp>::type + ACCESS_WRITE, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 191 | |
RyoheiHagimoto | 0:0e0631af0305 | 192 | template<typename _Tp, int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 193 | _OutputArray::_OutputArray(const Matx<_Tp, m, n>& mtx) |
RyoheiHagimoto | 0:0e0631af0305 | 194 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_WRITE, &mtx, Size(n, m)); } |
RyoheiHagimoto | 0:0e0631af0305 | 195 | |
RyoheiHagimoto | 0:0e0631af0305 | 196 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 197 | _OutputArray::_OutputArray(const _Tp* vec, int n) |
RyoheiHagimoto | 0:0e0631af0305 | 198 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_WRITE, vec, Size(n, 1)); } |
RyoheiHagimoto | 0:0e0631af0305 | 199 | |
RyoheiHagimoto | 0:0e0631af0305 | 200 | inline _OutputArray::_OutputArray(cuda::GpuMat& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 201 | { init(CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } |
RyoheiHagimoto | 0:0e0631af0305 | 202 | |
RyoheiHagimoto | 0:0e0631af0305 | 203 | inline _OutputArray::_OutputArray(std::vector<cuda::GpuMat>& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 204 | { init(STD_VECTOR_CUDA_GPU_MAT + ACCESS_WRITE, &d_mat);} |
RyoheiHagimoto | 0:0e0631af0305 | 205 | |
RyoheiHagimoto | 0:0e0631af0305 | 206 | inline _OutputArray::_OutputArray(ogl::Buffer& buf) |
RyoheiHagimoto | 0:0e0631af0305 | 207 | { init(OPENGL_BUFFER + ACCESS_WRITE, &buf); } |
RyoheiHagimoto | 0:0e0631af0305 | 208 | |
RyoheiHagimoto | 0:0e0631af0305 | 209 | inline _OutputArray::_OutputArray(cuda::HostMem& cuda_mem) |
RyoheiHagimoto | 0:0e0631af0305 | 210 | { init(CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } |
RyoheiHagimoto | 0:0e0631af0305 | 211 | |
RyoheiHagimoto | 0:0e0631af0305 | 212 | inline _OutputArray::_OutputArray(const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 213 | { init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_WRITE, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 214 | |
RyoheiHagimoto | 0:0e0631af0305 | 215 | inline _OutputArray::_OutputArray(const std::vector<Mat>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 216 | { init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 217 | |
RyoheiHagimoto | 0:0e0631af0305 | 218 | inline _OutputArray::_OutputArray(const UMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 219 | { init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_WRITE, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 220 | |
RyoheiHagimoto | 0:0e0631af0305 | 221 | inline _OutputArray::_OutputArray(const std::vector<UMat>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 222 | { init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_WRITE, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 223 | |
RyoheiHagimoto | 0:0e0631af0305 | 224 | inline _OutputArray::_OutputArray(const cuda::GpuMat& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 225 | { init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_WRITE, &d_mat); } |
RyoheiHagimoto | 0:0e0631af0305 | 226 | |
RyoheiHagimoto | 0:0e0631af0305 | 227 | |
RyoheiHagimoto | 0:0e0631af0305 | 228 | inline _OutputArray::_OutputArray(const ogl::Buffer& buf) |
RyoheiHagimoto | 0:0e0631af0305 | 229 | { init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_WRITE, &buf); } |
RyoheiHagimoto | 0:0e0631af0305 | 230 | |
RyoheiHagimoto | 0:0e0631af0305 | 231 | inline _OutputArray::_OutputArray(const cuda::HostMem& cuda_mem) |
RyoheiHagimoto | 0:0e0631af0305 | 232 | { init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_WRITE, &cuda_mem); } |
RyoheiHagimoto | 0:0e0631af0305 | 233 | |
RyoheiHagimoto | 0:0e0631af0305 | 234 | /////////////////////////////////////////////////////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 235 | |
RyoheiHagimoto | 0:0e0631af0305 | 236 | inline _InputOutputArray::_InputOutputArray() { init(ACCESS_RW, 0); } |
RyoheiHagimoto | 0:0e0631af0305 | 237 | inline _InputOutputArray::_InputOutputArray(int _flags, void* _obj) { init(_flags|ACCESS_RW, _obj); } |
RyoheiHagimoto | 0:0e0631af0305 | 238 | inline _InputOutputArray::_InputOutputArray(Mat& m) { init(MAT+ACCESS_RW, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 239 | inline _InputOutputArray::_InputOutputArray(std::vector<Mat>& vec) { init(STD_VECTOR_MAT+ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 240 | inline _InputOutputArray::_InputOutputArray(UMat& m) { init(UMAT+ACCESS_RW, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 241 | inline _InputOutputArray::_InputOutputArray(std::vector<UMat>& vec) { init(STD_VECTOR_UMAT+ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 242 | |
RyoheiHagimoto | 0:0e0631af0305 | 243 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 244 | _InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 245 | { init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 246 | |
RyoheiHagimoto | 0:0e0631af0305 | 247 | inline _InputOutputArray::_InputOutputArray(std::vector<bool>&) |
RyoheiHagimoto | 0:0e0631af0305 | 248 | { CV_Error(Error::StsUnsupportedFormat, "std::vector<bool> cannot be an input/output array\n"); } |
RyoheiHagimoto | 0:0e0631af0305 | 249 | |
RyoheiHagimoto | 0:0e0631af0305 | 250 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 251 | _InputOutputArray::_InputOutputArray(std::vector<std::vector<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 252 | { init(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 253 | |
RyoheiHagimoto | 0:0e0631af0305 | 254 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 255 | _InputOutputArray::_InputOutputArray(std::vector<Mat_<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 256 | { init(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 257 | |
RyoheiHagimoto | 0:0e0631af0305 | 258 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 259 | _InputOutputArray::_InputOutputArray(Mat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 260 | { init(FIXED_TYPE + MAT + DataType<_Tp>::type + ACCESS_RW, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 261 | |
RyoheiHagimoto | 0:0e0631af0305 | 262 | template<typename _Tp, int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 263 | _InputOutputArray::_InputOutputArray(Matx<_Tp, m, n>& mtx) |
RyoheiHagimoto | 0:0e0631af0305 | 264 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_RW, &mtx, Size(n, m)); } |
RyoheiHagimoto | 0:0e0631af0305 | 265 | |
RyoheiHagimoto | 0:0e0631af0305 | 266 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 267 | _InputOutputArray::_InputOutputArray(_Tp* vec, int n) |
RyoheiHagimoto | 0:0e0631af0305 | 268 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_RW, vec, Size(n, 1)); } |
RyoheiHagimoto | 0:0e0631af0305 | 269 | |
RyoheiHagimoto | 0:0e0631af0305 | 270 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 271 | _InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 272 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 273 | |
RyoheiHagimoto | 0:0e0631af0305 | 274 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 275 | _InputOutputArray::_InputOutputArray(const std::vector<std::vector<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 276 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 277 | |
RyoheiHagimoto | 0:0e0631af0305 | 278 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 279 | _InputOutputArray::_InputOutputArray(const std::vector<Mat_<_Tp> >& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 280 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 281 | |
RyoheiHagimoto | 0:0e0631af0305 | 282 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 283 | _InputOutputArray::_InputOutputArray(const Mat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 284 | { init(FIXED_TYPE + FIXED_SIZE + MAT + DataType<_Tp>::type + ACCESS_RW, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 285 | |
RyoheiHagimoto | 0:0e0631af0305 | 286 | template<typename _Tp, int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 287 | _InputOutputArray::_InputOutputArray(const Matx<_Tp, m, n>& mtx) |
RyoheiHagimoto | 0:0e0631af0305 | 288 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_RW, &mtx, Size(n, m)); } |
RyoheiHagimoto | 0:0e0631af0305 | 289 | |
RyoheiHagimoto | 0:0e0631af0305 | 290 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 291 | _InputOutputArray::_InputOutputArray(const _Tp* vec, int n) |
RyoheiHagimoto | 0:0e0631af0305 | 292 | { init(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type + ACCESS_RW, vec, Size(n, 1)); } |
RyoheiHagimoto | 0:0e0631af0305 | 293 | |
RyoheiHagimoto | 0:0e0631af0305 | 294 | inline _InputOutputArray::_InputOutputArray(cuda::GpuMat& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 295 | { init(CUDA_GPU_MAT + ACCESS_RW, &d_mat); } |
RyoheiHagimoto | 0:0e0631af0305 | 296 | |
RyoheiHagimoto | 0:0e0631af0305 | 297 | inline _InputOutputArray::_InputOutputArray(ogl::Buffer& buf) |
RyoheiHagimoto | 0:0e0631af0305 | 298 | { init(OPENGL_BUFFER + ACCESS_RW, &buf); } |
RyoheiHagimoto | 0:0e0631af0305 | 299 | |
RyoheiHagimoto | 0:0e0631af0305 | 300 | inline _InputOutputArray::_InputOutputArray(cuda::HostMem& cuda_mem) |
RyoheiHagimoto | 0:0e0631af0305 | 301 | { init(CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } |
RyoheiHagimoto | 0:0e0631af0305 | 302 | |
RyoheiHagimoto | 0:0e0631af0305 | 303 | inline _InputOutputArray::_InputOutputArray(const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 304 | { init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_RW, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 305 | |
RyoheiHagimoto | 0:0e0631af0305 | 306 | inline _InputOutputArray::_InputOutputArray(const std::vector<Mat>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 307 | { init(FIXED_SIZE + STD_VECTOR_MAT + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 308 | |
RyoheiHagimoto | 0:0e0631af0305 | 309 | inline _InputOutputArray::_InputOutputArray(const UMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 310 | { init(FIXED_TYPE + FIXED_SIZE + UMAT + ACCESS_RW, &m); } |
RyoheiHagimoto | 0:0e0631af0305 | 311 | |
RyoheiHagimoto | 0:0e0631af0305 | 312 | inline _InputOutputArray::_InputOutputArray(const std::vector<UMat>& vec) |
RyoheiHagimoto | 0:0e0631af0305 | 313 | { init(FIXED_SIZE + STD_VECTOR_UMAT + ACCESS_RW, &vec); } |
RyoheiHagimoto | 0:0e0631af0305 | 314 | |
RyoheiHagimoto | 0:0e0631af0305 | 315 | inline _InputOutputArray::_InputOutputArray(const cuda::GpuMat& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 316 | { init(FIXED_TYPE + FIXED_SIZE + CUDA_GPU_MAT + ACCESS_RW, &d_mat); } |
RyoheiHagimoto | 0:0e0631af0305 | 317 | |
RyoheiHagimoto | 0:0e0631af0305 | 318 | inline _InputOutputArray::_InputOutputArray(const std::vector<cuda::GpuMat>& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 319 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} |
RyoheiHagimoto | 0:0e0631af0305 | 320 | |
RyoheiHagimoto | 0:0e0631af0305 | 321 | template<> inline _InputOutputArray::_InputOutputArray(std::vector<cuda::GpuMat>& d_mat) |
RyoheiHagimoto | 0:0e0631af0305 | 322 | { init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_CUDA_GPU_MAT + ACCESS_RW, &d_mat);} |
RyoheiHagimoto | 0:0e0631af0305 | 323 | |
RyoheiHagimoto | 0:0e0631af0305 | 324 | inline _InputOutputArray::_InputOutputArray(const ogl::Buffer& buf) |
RyoheiHagimoto | 0:0e0631af0305 | 325 | { init(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER + ACCESS_RW, &buf); } |
RyoheiHagimoto | 0:0e0631af0305 | 326 | |
RyoheiHagimoto | 0:0e0631af0305 | 327 | inline _InputOutputArray::_InputOutputArray(const cuda::HostMem& cuda_mem) |
RyoheiHagimoto | 0:0e0631af0305 | 328 | { init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); } |
RyoheiHagimoto | 0:0e0631af0305 | 329 | |
RyoheiHagimoto | 0:0e0631af0305 | 330 | //////////////////////////////////////////// Mat ////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 331 | |
RyoheiHagimoto | 0:0e0631af0305 | 332 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 333 | Mat::Mat() |
RyoheiHagimoto | 0:0e0631af0305 | 334 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 335 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 336 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 337 | |
RyoheiHagimoto | 0:0e0631af0305 | 338 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 339 | Mat::Mat(int _rows, int _cols, int _type) |
RyoheiHagimoto | 0:0e0631af0305 | 340 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 341 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 342 | { |
RyoheiHagimoto | 0:0e0631af0305 | 343 | create(_rows, _cols, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 344 | } |
RyoheiHagimoto | 0:0e0631af0305 | 345 | |
RyoheiHagimoto | 0:0e0631af0305 | 346 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 347 | Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) |
RyoheiHagimoto | 0:0e0631af0305 | 348 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 349 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 350 | { |
RyoheiHagimoto | 0:0e0631af0305 | 351 | create(_rows, _cols, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 352 | *this = _s; |
RyoheiHagimoto | 0:0e0631af0305 | 353 | } |
RyoheiHagimoto | 0:0e0631af0305 | 354 | |
RyoheiHagimoto | 0:0e0631af0305 | 355 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 356 | Mat::Mat(Size _sz, int _type) |
RyoheiHagimoto | 0:0e0631af0305 | 357 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 358 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 359 | { |
RyoheiHagimoto | 0:0e0631af0305 | 360 | create( _sz.height, _sz.width, _type ); |
RyoheiHagimoto | 0:0e0631af0305 | 361 | } |
RyoheiHagimoto | 0:0e0631af0305 | 362 | |
RyoheiHagimoto | 0:0e0631af0305 | 363 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 364 | Mat::Mat(Size _sz, int _type, const Scalar& _s) |
RyoheiHagimoto | 0:0e0631af0305 | 365 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 366 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 367 | { |
RyoheiHagimoto | 0:0e0631af0305 | 368 | create(_sz.height, _sz.width, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 369 | *this = _s; |
RyoheiHagimoto | 0:0e0631af0305 | 370 | } |
RyoheiHagimoto | 0:0e0631af0305 | 371 | |
RyoheiHagimoto | 0:0e0631af0305 | 372 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 373 | Mat::Mat(int _dims, const int* _sz, int _type) |
RyoheiHagimoto | 0:0e0631af0305 | 374 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 375 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 376 | { |
RyoheiHagimoto | 0:0e0631af0305 | 377 | create(_dims, _sz, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 378 | } |
RyoheiHagimoto | 0:0e0631af0305 | 379 | |
RyoheiHagimoto | 0:0e0631af0305 | 380 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 381 | Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) |
RyoheiHagimoto | 0:0e0631af0305 | 382 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 383 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 384 | { |
RyoheiHagimoto | 0:0e0631af0305 | 385 | create(_dims, _sz, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 386 | *this = _s; |
RyoheiHagimoto | 0:0e0631af0305 | 387 | } |
RyoheiHagimoto | 0:0e0631af0305 | 388 | |
RyoheiHagimoto | 0:0e0631af0305 | 389 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 390 | Mat::Mat(const std::vector<int>& _sz, int _type) |
RyoheiHagimoto | 0:0e0631af0305 | 391 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 392 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 393 | { |
RyoheiHagimoto | 0:0e0631af0305 | 394 | create(_sz, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 395 | } |
RyoheiHagimoto | 0:0e0631af0305 | 396 | |
RyoheiHagimoto | 0:0e0631af0305 | 397 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 398 | Mat::Mat(const std::vector<int>& _sz, int _type, const Scalar& _s) |
RyoheiHagimoto | 0:0e0631af0305 | 399 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
RyoheiHagimoto | 0:0e0631af0305 | 400 | datalimit(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 401 | { |
RyoheiHagimoto | 0:0e0631af0305 | 402 | create(_sz, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 403 | *this = _s; |
RyoheiHagimoto | 0:0e0631af0305 | 404 | } |
RyoheiHagimoto | 0:0e0631af0305 | 405 | |
RyoheiHagimoto | 0:0e0631af0305 | 406 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 407 | Mat::Mat(const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 408 | : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data), |
RyoheiHagimoto | 0:0e0631af0305 | 409 | datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator), |
RyoheiHagimoto | 0:0e0631af0305 | 410 | u(m.u), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 411 | { |
RyoheiHagimoto | 0:0e0631af0305 | 412 | if( u ) |
RyoheiHagimoto | 0:0e0631af0305 | 413 | CV_XADD(&u->refcount, 1); |
RyoheiHagimoto | 0:0e0631af0305 | 414 | if( m.dims <= 2 ) |
RyoheiHagimoto | 0:0e0631af0305 | 415 | { |
RyoheiHagimoto | 0:0e0631af0305 | 416 | step[0] = m.step[0]; step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 417 | } |
RyoheiHagimoto | 0:0e0631af0305 | 418 | else |
RyoheiHagimoto | 0:0e0631af0305 | 419 | { |
RyoheiHagimoto | 0:0e0631af0305 | 420 | dims = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 421 | copySize(m); |
RyoheiHagimoto | 0:0e0631af0305 | 422 | } |
RyoheiHagimoto | 0:0e0631af0305 | 423 | } |
RyoheiHagimoto | 0:0e0631af0305 | 424 | |
RyoheiHagimoto | 0:0e0631af0305 | 425 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 426 | Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step) |
RyoheiHagimoto | 0:0e0631af0305 | 427 | : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols), |
RyoheiHagimoto | 0:0e0631af0305 | 428 | data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), |
RyoheiHagimoto | 0:0e0631af0305 | 429 | allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 430 | { |
RyoheiHagimoto | 0:0e0631af0305 | 431 | CV_Assert(total() == 0 || data != NULL); |
RyoheiHagimoto | 0:0e0631af0305 | 432 | |
RyoheiHagimoto | 0:0e0631af0305 | 433 | size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type); |
RyoheiHagimoto | 0:0e0631af0305 | 434 | size_t minstep = cols * esz; |
RyoheiHagimoto | 0:0e0631af0305 | 435 | if( _step == AUTO_STEP ) |
RyoheiHagimoto | 0:0e0631af0305 | 436 | { |
RyoheiHagimoto | 0:0e0631af0305 | 437 | _step = minstep; |
RyoheiHagimoto | 0:0e0631af0305 | 438 | flags |= CONTINUOUS_FLAG; |
RyoheiHagimoto | 0:0e0631af0305 | 439 | } |
RyoheiHagimoto | 0:0e0631af0305 | 440 | else |
RyoheiHagimoto | 0:0e0631af0305 | 441 | { |
RyoheiHagimoto | 0:0e0631af0305 | 442 | if( rows == 1 ) _step = minstep; |
RyoheiHagimoto | 0:0e0631af0305 | 443 | CV_DbgAssert( _step >= minstep ); |
RyoheiHagimoto | 0:0e0631af0305 | 444 | |
RyoheiHagimoto | 0:0e0631af0305 | 445 | if (_step % esz1 != 0) |
RyoheiHagimoto | 0:0e0631af0305 | 446 | { |
RyoheiHagimoto | 0:0e0631af0305 | 447 | CV_Error(Error::BadStep, "Step must be a multiple of esz1"); |
RyoheiHagimoto | 0:0e0631af0305 | 448 | } |
RyoheiHagimoto | 0:0e0631af0305 | 449 | |
RyoheiHagimoto | 0:0e0631af0305 | 450 | flags |= _step == minstep ? CONTINUOUS_FLAG : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 451 | } |
RyoheiHagimoto | 0:0e0631af0305 | 452 | step[0] = _step; |
RyoheiHagimoto | 0:0e0631af0305 | 453 | step[1] = esz; |
RyoheiHagimoto | 0:0e0631af0305 | 454 | datalimit = datastart + _step * rows; |
RyoheiHagimoto | 0:0e0631af0305 | 455 | dataend = datalimit - _step + minstep; |
RyoheiHagimoto | 0:0e0631af0305 | 456 | } |
RyoheiHagimoto | 0:0e0631af0305 | 457 | |
RyoheiHagimoto | 0:0e0631af0305 | 458 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 459 | Mat::Mat(Size _sz, int _type, void* _data, size_t _step) |
RyoheiHagimoto | 0:0e0631af0305 | 460 | : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width), |
RyoheiHagimoto | 0:0e0631af0305 | 461 | data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), |
RyoheiHagimoto | 0:0e0631af0305 | 462 | allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 463 | { |
RyoheiHagimoto | 0:0e0631af0305 | 464 | CV_Assert(total() == 0 || data != NULL); |
RyoheiHagimoto | 0:0e0631af0305 | 465 | |
RyoheiHagimoto | 0:0e0631af0305 | 466 | size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type); |
RyoheiHagimoto | 0:0e0631af0305 | 467 | size_t minstep = cols*esz; |
RyoheiHagimoto | 0:0e0631af0305 | 468 | if( _step == AUTO_STEP ) |
RyoheiHagimoto | 0:0e0631af0305 | 469 | { |
RyoheiHagimoto | 0:0e0631af0305 | 470 | _step = minstep; |
RyoheiHagimoto | 0:0e0631af0305 | 471 | flags |= CONTINUOUS_FLAG; |
RyoheiHagimoto | 0:0e0631af0305 | 472 | } |
RyoheiHagimoto | 0:0e0631af0305 | 473 | else |
RyoheiHagimoto | 0:0e0631af0305 | 474 | { |
RyoheiHagimoto | 0:0e0631af0305 | 475 | if( rows == 1 ) _step = minstep; |
RyoheiHagimoto | 0:0e0631af0305 | 476 | CV_DbgAssert( _step >= minstep ); |
RyoheiHagimoto | 0:0e0631af0305 | 477 | |
RyoheiHagimoto | 0:0e0631af0305 | 478 | if (_step % esz1 != 0) |
RyoheiHagimoto | 0:0e0631af0305 | 479 | { |
RyoheiHagimoto | 0:0e0631af0305 | 480 | CV_Error(Error::BadStep, "Step must be a multiple of esz1"); |
RyoheiHagimoto | 0:0e0631af0305 | 481 | } |
RyoheiHagimoto | 0:0e0631af0305 | 482 | |
RyoheiHagimoto | 0:0e0631af0305 | 483 | flags |= _step == minstep ? CONTINUOUS_FLAG : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 484 | } |
RyoheiHagimoto | 0:0e0631af0305 | 485 | step[0] = _step; |
RyoheiHagimoto | 0:0e0631af0305 | 486 | step[1] = esz; |
RyoheiHagimoto | 0:0e0631af0305 | 487 | datalimit = datastart + _step*rows; |
RyoheiHagimoto | 0:0e0631af0305 | 488 | dataend = datalimit - _step + minstep; |
RyoheiHagimoto | 0:0e0631af0305 | 489 | } |
RyoheiHagimoto | 0:0e0631af0305 | 490 | |
RyoheiHagimoto | 0:0e0631af0305 | 491 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 492 | Mat::Mat(const std::vector<_Tp>& vec, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 493 | : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), |
RyoheiHagimoto | 0:0e0631af0305 | 494 | cols(1), data(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 495 | { |
RyoheiHagimoto | 0:0e0631af0305 | 496 | if(vec.empty()) |
RyoheiHagimoto | 0:0e0631af0305 | 497 | return; |
RyoheiHagimoto | 0:0e0631af0305 | 498 | if( !copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 499 | { |
RyoheiHagimoto | 0:0e0631af0305 | 500 | step[0] = step[1] = sizeof(_Tp); |
RyoheiHagimoto | 0:0e0631af0305 | 501 | datastart = data = (uchar*)&vec[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 502 | datalimit = dataend = datastart + rows * step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 503 | } |
RyoheiHagimoto | 0:0e0631af0305 | 504 | else |
RyoheiHagimoto | 0:0e0631af0305 | 505 | Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this); |
RyoheiHagimoto | 0:0e0631af0305 | 506 | } |
RyoheiHagimoto | 0:0e0631af0305 | 507 | |
RyoheiHagimoto | 0:0e0631af0305 | 508 | template<typename _Tp, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 509 | Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 510 | : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0), |
RyoheiHagimoto | 0:0e0631af0305 | 511 | datastart(0), dataend(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 512 | { |
RyoheiHagimoto | 0:0e0631af0305 | 513 | if( !copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 514 | { |
RyoheiHagimoto | 0:0e0631af0305 | 515 | step[0] = step[1] = sizeof(_Tp); |
RyoheiHagimoto | 0:0e0631af0305 | 516 | datastart = data = (uchar*)vec.val; |
RyoheiHagimoto | 0:0e0631af0305 | 517 | datalimit = dataend = datastart + rows * step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 518 | } |
RyoheiHagimoto | 0:0e0631af0305 | 519 | else |
RyoheiHagimoto | 0:0e0631af0305 | 520 | Mat(n, 1, DataType<_Tp>::type, (void*)vec.val).copyTo(*this); |
RyoheiHagimoto | 0:0e0631af0305 | 521 | } |
RyoheiHagimoto | 0:0e0631af0305 | 522 | |
RyoheiHagimoto | 0:0e0631af0305 | 523 | |
RyoheiHagimoto | 0:0e0631af0305 | 524 | template<typename _Tp, int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 525 | Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 526 | : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0), |
RyoheiHagimoto | 0:0e0631af0305 | 527 | datastart(0), dataend(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 528 | { |
RyoheiHagimoto | 0:0e0631af0305 | 529 | if( !copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 530 | { |
RyoheiHagimoto | 0:0e0631af0305 | 531 | step[0] = cols * sizeof(_Tp); |
RyoheiHagimoto | 0:0e0631af0305 | 532 | step[1] = sizeof(_Tp); |
RyoheiHagimoto | 0:0e0631af0305 | 533 | datastart = data = (uchar*)M.val; |
RyoheiHagimoto | 0:0e0631af0305 | 534 | datalimit = dataend = datastart + rows * step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 535 | } |
RyoheiHagimoto | 0:0e0631af0305 | 536 | else |
RyoheiHagimoto | 0:0e0631af0305 | 537 | Mat(m, n, DataType<_Tp>::type, (uchar*)M.val).copyTo(*this); |
RyoheiHagimoto | 0:0e0631af0305 | 538 | } |
RyoheiHagimoto | 0:0e0631af0305 | 539 | |
RyoheiHagimoto | 0:0e0631af0305 | 540 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 541 | Mat::Mat(const Point_<_Tp>& pt, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 542 | : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0), |
RyoheiHagimoto | 0:0e0631af0305 | 543 | datastart(0), dataend(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 544 | { |
RyoheiHagimoto | 0:0e0631af0305 | 545 | if( !copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 546 | { |
RyoheiHagimoto | 0:0e0631af0305 | 547 | step[0] = step[1] = sizeof(_Tp); |
RyoheiHagimoto | 0:0e0631af0305 | 548 | datastart = data = (uchar*)&pt.x; |
RyoheiHagimoto | 0:0e0631af0305 | 549 | datalimit = dataend = datastart + rows * step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 550 | } |
RyoheiHagimoto | 0:0e0631af0305 | 551 | else |
RyoheiHagimoto | 0:0e0631af0305 | 552 | { |
RyoheiHagimoto | 0:0e0631af0305 | 553 | create(2, 1, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 554 | ((_Tp*)data)[0] = pt.x; |
RyoheiHagimoto | 0:0e0631af0305 | 555 | ((_Tp*)data)[1] = pt.y; |
RyoheiHagimoto | 0:0e0631af0305 | 556 | } |
RyoheiHagimoto | 0:0e0631af0305 | 557 | } |
RyoheiHagimoto | 0:0e0631af0305 | 558 | |
RyoheiHagimoto | 0:0e0631af0305 | 559 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 560 | Mat::Mat(const Point3_<_Tp>& pt, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 561 | : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0), |
RyoheiHagimoto | 0:0e0631af0305 | 562 | datastart(0), dataend(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 563 | { |
RyoheiHagimoto | 0:0e0631af0305 | 564 | if( !copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 565 | { |
RyoheiHagimoto | 0:0e0631af0305 | 566 | step[0] = step[1] = sizeof(_Tp); |
RyoheiHagimoto | 0:0e0631af0305 | 567 | datastart = data = (uchar*)&pt.x; |
RyoheiHagimoto | 0:0e0631af0305 | 568 | datalimit = dataend = datastart + rows * step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 569 | } |
RyoheiHagimoto | 0:0e0631af0305 | 570 | else |
RyoheiHagimoto | 0:0e0631af0305 | 571 | { |
RyoheiHagimoto | 0:0e0631af0305 | 572 | create(3, 1, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 573 | ((_Tp*)data)[0] = pt.x; |
RyoheiHagimoto | 0:0e0631af0305 | 574 | ((_Tp*)data)[1] = pt.y; |
RyoheiHagimoto | 0:0e0631af0305 | 575 | ((_Tp*)data)[2] = pt.z; |
RyoheiHagimoto | 0:0e0631af0305 | 576 | } |
RyoheiHagimoto | 0:0e0631af0305 | 577 | } |
RyoheiHagimoto | 0:0e0631af0305 | 578 | |
RyoheiHagimoto | 0:0e0631af0305 | 579 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 580 | Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) |
RyoheiHagimoto | 0:0e0631af0305 | 581 | : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0), |
RyoheiHagimoto | 0:0e0631af0305 | 582 | datastart(0), dataend(0), allocator(0), u(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 583 | { |
RyoheiHagimoto | 0:0e0631af0305 | 584 | *this = commaInitializer.operator Mat_<_Tp>(); |
RyoheiHagimoto | 0:0e0631af0305 | 585 | } |
RyoheiHagimoto | 0:0e0631af0305 | 586 | |
RyoheiHagimoto | 0:0e0631af0305 | 587 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 588 | Mat::~Mat() |
RyoheiHagimoto | 0:0e0631af0305 | 589 | { |
RyoheiHagimoto | 0:0e0631af0305 | 590 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 591 | if( step.p != step.buf ) |
RyoheiHagimoto | 0:0e0631af0305 | 592 | fastFree(step.p); |
RyoheiHagimoto | 0:0e0631af0305 | 593 | } |
RyoheiHagimoto | 0:0e0631af0305 | 594 | |
RyoheiHagimoto | 0:0e0631af0305 | 595 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 596 | Mat& Mat::operator = (const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 597 | { |
RyoheiHagimoto | 0:0e0631af0305 | 598 | if( this != &m ) |
RyoheiHagimoto | 0:0e0631af0305 | 599 | { |
RyoheiHagimoto | 0:0e0631af0305 | 600 | if( m.u ) |
RyoheiHagimoto | 0:0e0631af0305 | 601 | CV_XADD(&m.u->refcount, 1); |
RyoheiHagimoto | 0:0e0631af0305 | 602 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 603 | flags = m.flags; |
RyoheiHagimoto | 0:0e0631af0305 | 604 | if( dims <= 2 && m.dims <= 2 ) |
RyoheiHagimoto | 0:0e0631af0305 | 605 | { |
RyoheiHagimoto | 0:0e0631af0305 | 606 | dims = m.dims; |
RyoheiHagimoto | 0:0e0631af0305 | 607 | rows = m.rows; |
RyoheiHagimoto | 0:0e0631af0305 | 608 | cols = m.cols; |
RyoheiHagimoto | 0:0e0631af0305 | 609 | step[0] = m.step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 610 | step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 611 | } |
RyoheiHagimoto | 0:0e0631af0305 | 612 | else |
RyoheiHagimoto | 0:0e0631af0305 | 613 | copySize(m); |
RyoheiHagimoto | 0:0e0631af0305 | 614 | data = m.data; |
RyoheiHagimoto | 0:0e0631af0305 | 615 | datastart = m.datastart; |
RyoheiHagimoto | 0:0e0631af0305 | 616 | dataend = m.dataend; |
RyoheiHagimoto | 0:0e0631af0305 | 617 | datalimit = m.datalimit; |
RyoheiHagimoto | 0:0e0631af0305 | 618 | allocator = m.allocator; |
RyoheiHagimoto | 0:0e0631af0305 | 619 | u = m.u; |
RyoheiHagimoto | 0:0e0631af0305 | 620 | } |
RyoheiHagimoto | 0:0e0631af0305 | 621 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 622 | } |
RyoheiHagimoto | 0:0e0631af0305 | 623 | |
RyoheiHagimoto | 0:0e0631af0305 | 624 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 625 | Mat Mat::row(int y) const |
RyoheiHagimoto | 0:0e0631af0305 | 626 | { |
RyoheiHagimoto | 0:0e0631af0305 | 627 | return Mat(*this, Range(y, y + 1), Range::all()); |
RyoheiHagimoto | 0:0e0631af0305 | 628 | } |
RyoheiHagimoto | 0:0e0631af0305 | 629 | |
RyoheiHagimoto | 0:0e0631af0305 | 630 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 631 | Mat Mat::col(int x) const |
RyoheiHagimoto | 0:0e0631af0305 | 632 | { |
RyoheiHagimoto | 0:0e0631af0305 | 633 | return Mat(*this, Range::all(), Range(x, x + 1)); |
RyoheiHagimoto | 0:0e0631af0305 | 634 | } |
RyoheiHagimoto | 0:0e0631af0305 | 635 | |
RyoheiHagimoto | 0:0e0631af0305 | 636 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 637 | Mat Mat::rowRange(int startrow, int endrow) const |
RyoheiHagimoto | 0:0e0631af0305 | 638 | { |
RyoheiHagimoto | 0:0e0631af0305 | 639 | return Mat(*this, Range(startrow, endrow), Range::all()); |
RyoheiHagimoto | 0:0e0631af0305 | 640 | } |
RyoheiHagimoto | 0:0e0631af0305 | 641 | |
RyoheiHagimoto | 0:0e0631af0305 | 642 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 643 | Mat Mat::rowRange(const Range& r) const |
RyoheiHagimoto | 0:0e0631af0305 | 644 | { |
RyoheiHagimoto | 0:0e0631af0305 | 645 | return Mat(*this, r, Range::all()); |
RyoheiHagimoto | 0:0e0631af0305 | 646 | } |
RyoheiHagimoto | 0:0e0631af0305 | 647 | |
RyoheiHagimoto | 0:0e0631af0305 | 648 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 649 | Mat Mat::colRange(int startcol, int endcol) const |
RyoheiHagimoto | 0:0e0631af0305 | 650 | { |
RyoheiHagimoto | 0:0e0631af0305 | 651 | return Mat(*this, Range::all(), Range(startcol, endcol)); |
RyoheiHagimoto | 0:0e0631af0305 | 652 | } |
RyoheiHagimoto | 0:0e0631af0305 | 653 | |
RyoheiHagimoto | 0:0e0631af0305 | 654 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 655 | Mat Mat::colRange(const Range& r) const |
RyoheiHagimoto | 0:0e0631af0305 | 656 | { |
RyoheiHagimoto | 0:0e0631af0305 | 657 | return Mat(*this, Range::all(), r); |
RyoheiHagimoto | 0:0e0631af0305 | 658 | } |
RyoheiHagimoto | 0:0e0631af0305 | 659 | |
RyoheiHagimoto | 0:0e0631af0305 | 660 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 661 | Mat Mat::clone() const |
RyoheiHagimoto | 0:0e0631af0305 | 662 | { |
RyoheiHagimoto | 0:0e0631af0305 | 663 | Mat m; |
RyoheiHagimoto | 0:0e0631af0305 | 664 | copyTo(m); |
RyoheiHagimoto | 0:0e0631af0305 | 665 | return m; |
RyoheiHagimoto | 0:0e0631af0305 | 666 | } |
RyoheiHagimoto | 0:0e0631af0305 | 667 | |
RyoheiHagimoto | 0:0e0631af0305 | 668 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 669 | void Mat::assignTo( Mat& m, int _type ) const |
RyoheiHagimoto | 0:0e0631af0305 | 670 | { |
RyoheiHagimoto | 0:0e0631af0305 | 671 | if( _type < 0 ) |
RyoheiHagimoto | 0:0e0631af0305 | 672 | m = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 673 | else |
RyoheiHagimoto | 0:0e0631af0305 | 674 | convertTo(m, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 675 | } |
RyoheiHagimoto | 0:0e0631af0305 | 676 | |
RyoheiHagimoto | 0:0e0631af0305 | 677 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 678 | void Mat::create(int _rows, int _cols, int _type) |
RyoheiHagimoto | 0:0e0631af0305 | 679 | { |
RyoheiHagimoto | 0:0e0631af0305 | 680 | _type &= TYPE_MASK; |
RyoheiHagimoto | 0:0e0631af0305 | 681 | if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data ) |
RyoheiHagimoto | 0:0e0631af0305 | 682 | return; |
RyoheiHagimoto | 0:0e0631af0305 | 683 | int sz[] = {_rows, _cols}; |
RyoheiHagimoto | 0:0e0631af0305 | 684 | create(2, sz, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 685 | } |
RyoheiHagimoto | 0:0e0631af0305 | 686 | |
RyoheiHagimoto | 0:0e0631af0305 | 687 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 688 | void Mat::create(Size _sz, int _type) |
RyoheiHagimoto | 0:0e0631af0305 | 689 | { |
RyoheiHagimoto | 0:0e0631af0305 | 690 | create(_sz.height, _sz.width, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 691 | } |
RyoheiHagimoto | 0:0e0631af0305 | 692 | |
RyoheiHagimoto | 0:0e0631af0305 | 693 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 694 | void Mat::addref() |
RyoheiHagimoto | 0:0e0631af0305 | 695 | { |
RyoheiHagimoto | 0:0e0631af0305 | 696 | if( u ) |
RyoheiHagimoto | 0:0e0631af0305 | 697 | CV_XADD(&u->refcount, 1); |
RyoheiHagimoto | 0:0e0631af0305 | 698 | } |
RyoheiHagimoto | 0:0e0631af0305 | 699 | |
RyoheiHagimoto | 0:0e0631af0305 | 700 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 701 | void Mat::release() |
RyoheiHagimoto | 0:0e0631af0305 | 702 | { |
RyoheiHagimoto | 0:0e0631af0305 | 703 | if( u && CV_XADD(&u->refcount, -1) == 1 ) |
RyoheiHagimoto | 0:0e0631af0305 | 704 | deallocate(); |
RyoheiHagimoto | 0:0e0631af0305 | 705 | u = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 706 | datastart = dataend = datalimit = data = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 707 | for(int i = 0; i < dims; i++) |
RyoheiHagimoto | 0:0e0631af0305 | 708 | size.p[i] = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 709 | #ifdef _DEBUG |
RyoheiHagimoto | 0:0e0631af0305 | 710 | flags = MAGIC_VAL; |
RyoheiHagimoto | 0:0e0631af0305 | 711 | dims = rows = cols = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 712 | if(step.p != step.buf) |
RyoheiHagimoto | 0:0e0631af0305 | 713 | { |
RyoheiHagimoto | 0:0e0631af0305 | 714 | fastFree(step.p); |
RyoheiHagimoto | 0:0e0631af0305 | 715 | step.p = step.buf; |
RyoheiHagimoto | 0:0e0631af0305 | 716 | size.p = &rows; |
RyoheiHagimoto | 0:0e0631af0305 | 717 | } |
RyoheiHagimoto | 0:0e0631af0305 | 718 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 719 | } |
RyoheiHagimoto | 0:0e0631af0305 | 720 | |
RyoheiHagimoto | 0:0e0631af0305 | 721 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 722 | Mat Mat::operator()( Range _rowRange, Range _colRange ) const |
RyoheiHagimoto | 0:0e0631af0305 | 723 | { |
RyoheiHagimoto | 0:0e0631af0305 | 724 | return Mat(*this, _rowRange, _colRange); |
RyoheiHagimoto | 0:0e0631af0305 | 725 | } |
RyoheiHagimoto | 0:0e0631af0305 | 726 | |
RyoheiHagimoto | 0:0e0631af0305 | 727 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 728 | Mat Mat::operator()( const Rect& roi ) const |
RyoheiHagimoto | 0:0e0631af0305 | 729 | { |
RyoheiHagimoto | 0:0e0631af0305 | 730 | return Mat(*this, roi); |
RyoheiHagimoto | 0:0e0631af0305 | 731 | } |
RyoheiHagimoto | 0:0e0631af0305 | 732 | |
RyoheiHagimoto | 0:0e0631af0305 | 733 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 734 | Mat Mat::operator()(const Range* ranges) const |
RyoheiHagimoto | 0:0e0631af0305 | 735 | { |
RyoheiHagimoto | 0:0e0631af0305 | 736 | return Mat(*this, ranges); |
RyoheiHagimoto | 0:0e0631af0305 | 737 | } |
RyoheiHagimoto | 0:0e0631af0305 | 738 | |
RyoheiHagimoto | 0:0e0631af0305 | 739 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 740 | Mat Mat::operator()(const std::vector<Range>& ranges) const |
RyoheiHagimoto | 0:0e0631af0305 | 741 | { |
RyoheiHagimoto | 0:0e0631af0305 | 742 | return Mat(*this, ranges); |
RyoheiHagimoto | 0:0e0631af0305 | 743 | } |
RyoheiHagimoto | 0:0e0631af0305 | 744 | |
RyoheiHagimoto | 0:0e0631af0305 | 745 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 746 | bool Mat::isContinuous() const |
RyoheiHagimoto | 0:0e0631af0305 | 747 | { |
RyoheiHagimoto | 0:0e0631af0305 | 748 | return (flags & CONTINUOUS_FLAG) != 0; |
RyoheiHagimoto | 0:0e0631af0305 | 749 | } |
RyoheiHagimoto | 0:0e0631af0305 | 750 | |
RyoheiHagimoto | 0:0e0631af0305 | 751 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 752 | bool Mat::isSubmatrix() const |
RyoheiHagimoto | 0:0e0631af0305 | 753 | { |
RyoheiHagimoto | 0:0e0631af0305 | 754 | return (flags & SUBMATRIX_FLAG) != 0; |
RyoheiHagimoto | 0:0e0631af0305 | 755 | } |
RyoheiHagimoto | 0:0e0631af0305 | 756 | |
RyoheiHagimoto | 0:0e0631af0305 | 757 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 758 | size_t Mat::elemSize() const |
RyoheiHagimoto | 0:0e0631af0305 | 759 | { |
RyoheiHagimoto | 0:0e0631af0305 | 760 | return dims > 0 ? step.p[dims - 1] : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 761 | } |
RyoheiHagimoto | 0:0e0631af0305 | 762 | |
RyoheiHagimoto | 0:0e0631af0305 | 763 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 764 | size_t Mat::elemSize1() const |
RyoheiHagimoto | 0:0e0631af0305 | 765 | { |
RyoheiHagimoto | 0:0e0631af0305 | 766 | return CV_ELEM_SIZE1(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 767 | } |
RyoheiHagimoto | 0:0e0631af0305 | 768 | |
RyoheiHagimoto | 0:0e0631af0305 | 769 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 770 | int Mat::type() const |
RyoheiHagimoto | 0:0e0631af0305 | 771 | { |
RyoheiHagimoto | 0:0e0631af0305 | 772 | return CV_MAT_TYPE(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 773 | } |
RyoheiHagimoto | 0:0e0631af0305 | 774 | |
RyoheiHagimoto | 0:0e0631af0305 | 775 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 776 | int Mat::depth() const |
RyoheiHagimoto | 0:0e0631af0305 | 777 | { |
RyoheiHagimoto | 0:0e0631af0305 | 778 | return CV_MAT_DEPTH(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 779 | } |
RyoheiHagimoto | 0:0e0631af0305 | 780 | |
RyoheiHagimoto | 0:0e0631af0305 | 781 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 782 | int Mat::channels() const |
RyoheiHagimoto | 0:0e0631af0305 | 783 | { |
RyoheiHagimoto | 0:0e0631af0305 | 784 | return CV_MAT_CN(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 785 | } |
RyoheiHagimoto | 0:0e0631af0305 | 786 | |
RyoheiHagimoto | 0:0e0631af0305 | 787 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 788 | size_t Mat::step1(int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 789 | { |
RyoheiHagimoto | 0:0e0631af0305 | 790 | return step.p[i] / elemSize1(); |
RyoheiHagimoto | 0:0e0631af0305 | 791 | } |
RyoheiHagimoto | 0:0e0631af0305 | 792 | |
RyoheiHagimoto | 0:0e0631af0305 | 793 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 794 | bool Mat::empty() const |
RyoheiHagimoto | 0:0e0631af0305 | 795 | { |
RyoheiHagimoto | 0:0e0631af0305 | 796 | return data == 0 || total() == 0; |
RyoheiHagimoto | 0:0e0631af0305 | 797 | } |
RyoheiHagimoto | 0:0e0631af0305 | 798 | |
RyoheiHagimoto | 0:0e0631af0305 | 799 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 800 | size_t Mat::total() const |
RyoheiHagimoto | 0:0e0631af0305 | 801 | { |
RyoheiHagimoto | 0:0e0631af0305 | 802 | if( dims <= 2 ) |
RyoheiHagimoto | 0:0e0631af0305 | 803 | return (size_t)rows * cols; |
RyoheiHagimoto | 0:0e0631af0305 | 804 | size_t p = 1; |
RyoheiHagimoto | 0:0e0631af0305 | 805 | for( int i = 0; i < dims; i++ ) |
RyoheiHagimoto | 0:0e0631af0305 | 806 | p *= size[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 807 | return p; |
RyoheiHagimoto | 0:0e0631af0305 | 808 | } |
RyoheiHagimoto | 0:0e0631af0305 | 809 | |
RyoheiHagimoto | 0:0e0631af0305 | 810 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 811 | uchar* Mat::ptr(int y) |
RyoheiHagimoto | 0:0e0631af0305 | 812 | { |
RyoheiHagimoto | 0:0e0631af0305 | 813 | CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); |
RyoheiHagimoto | 0:0e0631af0305 | 814 | return data + step.p[0] * y; |
RyoheiHagimoto | 0:0e0631af0305 | 815 | } |
RyoheiHagimoto | 0:0e0631af0305 | 816 | |
RyoheiHagimoto | 0:0e0631af0305 | 817 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 818 | const uchar* Mat::ptr(int y) const |
RyoheiHagimoto | 0:0e0631af0305 | 819 | { |
RyoheiHagimoto | 0:0e0631af0305 | 820 | CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); |
RyoheiHagimoto | 0:0e0631af0305 | 821 | return data + step.p[0] * y; |
RyoheiHagimoto | 0:0e0631af0305 | 822 | } |
RyoheiHagimoto | 0:0e0631af0305 | 823 | |
RyoheiHagimoto | 0:0e0631af0305 | 824 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 825 | _Tp* Mat::ptr(int y) |
RyoheiHagimoto | 0:0e0631af0305 | 826 | { |
RyoheiHagimoto | 0:0e0631af0305 | 827 | CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); |
RyoheiHagimoto | 0:0e0631af0305 | 828 | return (_Tp*)(data + step.p[0] * y); |
RyoheiHagimoto | 0:0e0631af0305 | 829 | } |
RyoheiHagimoto | 0:0e0631af0305 | 830 | |
RyoheiHagimoto | 0:0e0631af0305 | 831 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 832 | const _Tp* Mat::ptr(int y) const |
RyoheiHagimoto | 0:0e0631af0305 | 833 | { |
RyoheiHagimoto | 0:0e0631af0305 | 834 | CV_DbgAssert( y == 0 || (data && dims >= 1 && data && (unsigned)y < (unsigned)size.p[0]) ); |
RyoheiHagimoto | 0:0e0631af0305 | 835 | return (const _Tp*)(data + step.p[0] * y); |
RyoheiHagimoto | 0:0e0631af0305 | 836 | } |
RyoheiHagimoto | 0:0e0631af0305 | 837 | |
RyoheiHagimoto | 0:0e0631af0305 | 838 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 839 | uchar* Mat::ptr(int i0, int i1) |
RyoheiHagimoto | 0:0e0631af0305 | 840 | { |
RyoheiHagimoto | 0:0e0631af0305 | 841 | CV_DbgAssert(dims >= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 842 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 843 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 844 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 845 | return data + i0 * step.p[0] + i1 * step.p[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 846 | } |
RyoheiHagimoto | 0:0e0631af0305 | 847 | |
RyoheiHagimoto | 0:0e0631af0305 | 848 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 849 | const uchar* Mat::ptr(int i0, int i1) const |
RyoheiHagimoto | 0:0e0631af0305 | 850 | { |
RyoheiHagimoto | 0:0e0631af0305 | 851 | CV_DbgAssert(dims >= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 852 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 853 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 854 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 855 | return data + i0 * step.p[0] + i1 * step.p[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 856 | } |
RyoheiHagimoto | 0:0e0631af0305 | 857 | |
RyoheiHagimoto | 0:0e0631af0305 | 858 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 859 | _Tp* Mat::ptr(int i0, int i1) |
RyoheiHagimoto | 0:0e0631af0305 | 860 | { |
RyoheiHagimoto | 0:0e0631af0305 | 861 | CV_DbgAssert(dims >= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 862 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 863 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 864 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 865 | return (_Tp*)(data + i0 * step.p[0] + i1 * step.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 866 | } |
RyoheiHagimoto | 0:0e0631af0305 | 867 | |
RyoheiHagimoto | 0:0e0631af0305 | 868 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 869 | const _Tp* Mat::ptr(int i0, int i1) const |
RyoheiHagimoto | 0:0e0631af0305 | 870 | { |
RyoheiHagimoto | 0:0e0631af0305 | 871 | CV_DbgAssert(dims >= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 872 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 873 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 874 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 875 | return (const _Tp*)(data + i0 * step.p[0] + i1 * step.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 876 | } |
RyoheiHagimoto | 0:0e0631af0305 | 877 | |
RyoheiHagimoto | 0:0e0631af0305 | 878 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 879 | uchar* Mat::ptr(int i0, int i1, int i2) |
RyoheiHagimoto | 0:0e0631af0305 | 880 | { |
RyoheiHagimoto | 0:0e0631af0305 | 881 | CV_DbgAssert(dims >= 3); |
RyoheiHagimoto | 0:0e0631af0305 | 882 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 883 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 884 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 885 | CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); |
RyoheiHagimoto | 0:0e0631af0305 | 886 | return data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]; |
RyoheiHagimoto | 0:0e0631af0305 | 887 | } |
RyoheiHagimoto | 0:0e0631af0305 | 888 | |
RyoheiHagimoto | 0:0e0631af0305 | 889 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 890 | const uchar* Mat::ptr(int i0, int i1, int i2) const |
RyoheiHagimoto | 0:0e0631af0305 | 891 | { |
RyoheiHagimoto | 0:0e0631af0305 | 892 | CV_DbgAssert(dims >= 3); |
RyoheiHagimoto | 0:0e0631af0305 | 893 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 894 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 895 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 896 | CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); |
RyoheiHagimoto | 0:0e0631af0305 | 897 | return data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]; |
RyoheiHagimoto | 0:0e0631af0305 | 898 | } |
RyoheiHagimoto | 0:0e0631af0305 | 899 | |
RyoheiHagimoto | 0:0e0631af0305 | 900 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 901 | _Tp* Mat::ptr(int i0, int i1, int i2) |
RyoheiHagimoto | 0:0e0631af0305 | 902 | { |
RyoheiHagimoto | 0:0e0631af0305 | 903 | CV_DbgAssert(dims >= 3); |
RyoheiHagimoto | 0:0e0631af0305 | 904 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 905 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 906 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 907 | CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); |
RyoheiHagimoto | 0:0e0631af0305 | 908 | return (_Tp*)(data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]); |
RyoheiHagimoto | 0:0e0631af0305 | 909 | } |
RyoheiHagimoto | 0:0e0631af0305 | 910 | |
RyoheiHagimoto | 0:0e0631af0305 | 911 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 912 | const _Tp* Mat::ptr(int i0, int i1, int i2) const |
RyoheiHagimoto | 0:0e0631af0305 | 913 | { |
RyoheiHagimoto | 0:0e0631af0305 | 914 | CV_DbgAssert(dims >= 3); |
RyoheiHagimoto | 0:0e0631af0305 | 915 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 916 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 917 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 918 | CV_DbgAssert((unsigned)i2 < (unsigned)size.p[2]); |
RyoheiHagimoto | 0:0e0631af0305 | 919 | return (const _Tp*)(data + i0 * step.p[0] + i1 * step.p[1] + i2 * step.p[2]); |
RyoheiHagimoto | 0:0e0631af0305 | 920 | } |
RyoheiHagimoto | 0:0e0631af0305 | 921 | |
RyoheiHagimoto | 0:0e0631af0305 | 922 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 923 | uchar* Mat::ptr(const int* idx) |
RyoheiHagimoto | 0:0e0631af0305 | 924 | { |
RyoheiHagimoto | 0:0e0631af0305 | 925 | int i, d = dims; |
RyoheiHagimoto | 0:0e0631af0305 | 926 | uchar* p = data; |
RyoheiHagimoto | 0:0e0631af0305 | 927 | CV_DbgAssert( d >= 1 && p ); |
RyoheiHagimoto | 0:0e0631af0305 | 928 | for( i = 0; i < d; i++ ) |
RyoheiHagimoto | 0:0e0631af0305 | 929 | { |
RyoheiHagimoto | 0:0e0631af0305 | 930 | CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); |
RyoheiHagimoto | 0:0e0631af0305 | 931 | p += idx[i] * step.p[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 932 | } |
RyoheiHagimoto | 0:0e0631af0305 | 933 | return p; |
RyoheiHagimoto | 0:0e0631af0305 | 934 | } |
RyoheiHagimoto | 0:0e0631af0305 | 935 | |
RyoheiHagimoto | 0:0e0631af0305 | 936 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 937 | const uchar* Mat::ptr(const int* idx) const |
RyoheiHagimoto | 0:0e0631af0305 | 938 | { |
RyoheiHagimoto | 0:0e0631af0305 | 939 | int i, d = dims; |
RyoheiHagimoto | 0:0e0631af0305 | 940 | uchar* p = data; |
RyoheiHagimoto | 0:0e0631af0305 | 941 | CV_DbgAssert( d >= 1 && p ); |
RyoheiHagimoto | 0:0e0631af0305 | 942 | for( i = 0; i < d; i++ ) |
RyoheiHagimoto | 0:0e0631af0305 | 943 | { |
RyoheiHagimoto | 0:0e0631af0305 | 944 | CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); |
RyoheiHagimoto | 0:0e0631af0305 | 945 | p += idx[i] * step.p[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 946 | } |
RyoheiHagimoto | 0:0e0631af0305 | 947 | return p; |
RyoheiHagimoto | 0:0e0631af0305 | 948 | } |
RyoheiHagimoto | 0:0e0631af0305 | 949 | |
RyoheiHagimoto | 0:0e0631af0305 | 950 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 951 | _Tp& Mat::at(int i0, int i1) |
RyoheiHagimoto | 0:0e0631af0305 | 952 | { |
RyoheiHagimoto | 0:0e0631af0305 | 953 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 954 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 955 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 956 | CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); |
RyoheiHagimoto | 0:0e0631af0305 | 957 | CV_DbgAssert(CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); |
RyoheiHagimoto | 0:0e0631af0305 | 958 | return ((_Tp*)(data + step.p[0] * i0))[i1]; |
RyoheiHagimoto | 0:0e0631af0305 | 959 | } |
RyoheiHagimoto | 0:0e0631af0305 | 960 | |
RyoheiHagimoto | 0:0e0631af0305 | 961 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 962 | const _Tp& Mat::at(int i0, int i1) const |
RyoheiHagimoto | 0:0e0631af0305 | 963 | { |
RyoheiHagimoto | 0:0e0631af0305 | 964 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 965 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 966 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 967 | CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); |
RyoheiHagimoto | 0:0e0631af0305 | 968 | CV_DbgAssert(CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); |
RyoheiHagimoto | 0:0e0631af0305 | 969 | return ((const _Tp*)(data + step.p[0] * i0))[i1]; |
RyoheiHagimoto | 0:0e0631af0305 | 970 | } |
RyoheiHagimoto | 0:0e0631af0305 | 971 | |
RyoheiHagimoto | 0:0e0631af0305 | 972 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 973 | _Tp& Mat::at(Point pt) |
RyoheiHagimoto | 0:0e0631af0305 | 974 | { |
RyoheiHagimoto | 0:0e0631af0305 | 975 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 976 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 977 | CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 978 | CV_DbgAssert((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); |
RyoheiHagimoto | 0:0e0631af0305 | 979 | CV_DbgAssert(CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); |
RyoheiHagimoto | 0:0e0631af0305 | 980 | return ((_Tp*)(data + step.p[0] * pt.y))[pt.x]; |
RyoheiHagimoto | 0:0e0631af0305 | 981 | } |
RyoheiHagimoto | 0:0e0631af0305 | 982 | |
RyoheiHagimoto | 0:0e0631af0305 | 983 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 984 | const _Tp& Mat::at(Point pt) const |
RyoheiHagimoto | 0:0e0631af0305 | 985 | { |
RyoheiHagimoto | 0:0e0631af0305 | 986 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 987 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 988 | CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 989 | CV_DbgAssert((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); |
RyoheiHagimoto | 0:0e0631af0305 | 990 | CV_DbgAssert(CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); |
RyoheiHagimoto | 0:0e0631af0305 | 991 | return ((const _Tp*)(data + step.p[0] * pt.y))[pt.x]; |
RyoheiHagimoto | 0:0e0631af0305 | 992 | } |
RyoheiHagimoto | 0:0e0631af0305 | 993 | |
RyoheiHagimoto | 0:0e0631af0305 | 994 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 995 | _Tp& Mat::at(int i0) |
RyoheiHagimoto | 0:0e0631af0305 | 996 | { |
RyoheiHagimoto | 0:0e0631af0305 | 997 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 998 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 999 | CV_DbgAssert((unsigned)i0 < (unsigned)(size.p[0] * size.p[1])); |
RyoheiHagimoto | 0:0e0631af0305 | 1000 | CV_DbgAssert(elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type)); |
RyoheiHagimoto | 0:0e0631af0305 | 1001 | if( isContinuous() || size.p[0] == 1 ) |
RyoheiHagimoto | 0:0e0631af0305 | 1002 | return ((_Tp*)data)[i0]; |
RyoheiHagimoto | 0:0e0631af0305 | 1003 | if( size.p[1] == 1 ) |
RyoheiHagimoto | 0:0e0631af0305 | 1004 | return *(_Tp*)(data + step.p[0] * i0); |
RyoheiHagimoto | 0:0e0631af0305 | 1005 | int i = i0 / cols, j = i0 - i * cols; |
RyoheiHagimoto | 0:0e0631af0305 | 1006 | return ((_Tp*)(data + step.p[0] * i))[j]; |
RyoheiHagimoto | 0:0e0631af0305 | 1007 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1008 | |
RyoheiHagimoto | 0:0e0631af0305 | 1009 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1010 | const _Tp& Mat::at(int i0) const |
RyoheiHagimoto | 0:0e0631af0305 | 1011 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1012 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 1013 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 1014 | CV_DbgAssert((unsigned)i0 < (unsigned)(size.p[0] * size.p[1])); |
RyoheiHagimoto | 0:0e0631af0305 | 1015 | CV_DbgAssert(elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type)); |
RyoheiHagimoto | 0:0e0631af0305 | 1016 | if( isContinuous() || size.p[0] == 1 ) |
RyoheiHagimoto | 0:0e0631af0305 | 1017 | return ((const _Tp*)data)[i0]; |
RyoheiHagimoto | 0:0e0631af0305 | 1018 | if( size.p[1] == 1 ) |
RyoheiHagimoto | 0:0e0631af0305 | 1019 | return *(const _Tp*)(data + step.p[0] * i0); |
RyoheiHagimoto | 0:0e0631af0305 | 1020 | int i = i0 / cols, j = i0 - i * cols; |
RyoheiHagimoto | 0:0e0631af0305 | 1021 | return ((const _Tp*)(data + step.p[0] * i))[j]; |
RyoheiHagimoto | 0:0e0631af0305 | 1022 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1023 | |
RyoheiHagimoto | 0:0e0631af0305 | 1024 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1025 | _Tp& Mat::at(int i0, int i1, int i2) |
RyoheiHagimoto | 0:0e0631af0305 | 1026 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1027 | CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1028 | return *(_Tp*)ptr(i0, i1, i2); |
RyoheiHagimoto | 0:0e0631af0305 | 1029 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1030 | |
RyoheiHagimoto | 0:0e0631af0305 | 1031 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1032 | const _Tp& Mat::at(int i0, int i1, int i2) const |
RyoheiHagimoto | 0:0e0631af0305 | 1033 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1034 | CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1035 | return *(const _Tp*)ptr(i0, i1, i2); |
RyoheiHagimoto | 0:0e0631af0305 | 1036 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1037 | |
RyoheiHagimoto | 0:0e0631af0305 | 1038 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1039 | _Tp& Mat::at(const int* idx) |
RyoheiHagimoto | 0:0e0631af0305 | 1040 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1041 | CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1042 | return *(_Tp*)ptr(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 1043 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1044 | |
RyoheiHagimoto | 0:0e0631af0305 | 1045 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1046 | const _Tp& Mat::at(const int* idx) const |
RyoheiHagimoto | 0:0e0631af0305 | 1047 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1048 | CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1049 | return *(const _Tp*)ptr(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 1050 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1051 | |
RyoheiHagimoto | 0:0e0631af0305 | 1052 | template<typename _Tp, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1053 | _Tp& Mat::at(const Vec<int, n>& idx) |
RyoheiHagimoto | 0:0e0631af0305 | 1054 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1055 | CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1056 | return *(_Tp*)ptr(idx.val); |
RyoheiHagimoto | 0:0e0631af0305 | 1057 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1058 | |
RyoheiHagimoto | 0:0e0631af0305 | 1059 | template<typename _Tp, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1060 | const _Tp& Mat::at(const Vec<int, n>& idx) const |
RyoheiHagimoto | 0:0e0631af0305 | 1061 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1062 | CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1063 | return *(const _Tp*)ptr(idx.val); |
RyoheiHagimoto | 0:0e0631af0305 | 1064 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1065 | |
RyoheiHagimoto | 0:0e0631af0305 | 1066 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1067 | MatConstIterator_<_Tp> Mat::begin() const |
RyoheiHagimoto | 0:0e0631af0305 | 1068 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1069 | CV_DbgAssert( elemSize() == sizeof(_Tp) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1070 | return MatConstIterator_<_Tp>((const Mat_<_Tp>*)this); |
RyoheiHagimoto | 0:0e0631af0305 | 1071 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1072 | |
RyoheiHagimoto | 0:0e0631af0305 | 1073 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1074 | MatConstIterator_<_Tp> Mat::end() const |
RyoheiHagimoto | 0:0e0631af0305 | 1075 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1076 | CV_DbgAssert( elemSize() == sizeof(_Tp) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1077 | MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this); |
RyoheiHagimoto | 0:0e0631af0305 | 1078 | it += total(); |
RyoheiHagimoto | 0:0e0631af0305 | 1079 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 1080 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1081 | |
RyoheiHagimoto | 0:0e0631af0305 | 1082 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1083 | MatIterator_<_Tp> Mat::begin() |
RyoheiHagimoto | 0:0e0631af0305 | 1084 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1085 | CV_DbgAssert( elemSize() == sizeof(_Tp) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1086 | return MatIterator_<_Tp>((Mat_<_Tp>*)this); |
RyoheiHagimoto | 0:0e0631af0305 | 1087 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1088 | |
RyoheiHagimoto | 0:0e0631af0305 | 1089 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1090 | MatIterator_<_Tp> Mat::end() |
RyoheiHagimoto | 0:0e0631af0305 | 1091 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1092 | CV_DbgAssert( elemSize() == sizeof(_Tp) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1093 | MatIterator_<_Tp> it((Mat_<_Tp>*)this); |
RyoheiHagimoto | 0:0e0631af0305 | 1094 | it += total(); |
RyoheiHagimoto | 0:0e0631af0305 | 1095 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 1096 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1097 | |
RyoheiHagimoto | 0:0e0631af0305 | 1098 | template<typename _Tp, typename Functor> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1099 | void Mat::forEach(const Functor& operation) { |
RyoheiHagimoto | 0:0e0631af0305 | 1100 | this->forEach_impl<_Tp>(operation); |
RyoheiHagimoto | 0:0e0631af0305 | 1101 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1102 | |
RyoheiHagimoto | 0:0e0631af0305 | 1103 | template<typename _Tp, typename Functor> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1104 | void Mat::forEach(const Functor& operation) const { |
RyoheiHagimoto | 0:0e0631af0305 | 1105 | // call as not const |
RyoheiHagimoto | 0:0e0631af0305 | 1106 | (const_cast<Mat*>(this))->forEach<const _Tp>(operation); |
RyoheiHagimoto | 0:0e0631af0305 | 1107 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1108 | |
RyoheiHagimoto | 0:0e0631af0305 | 1109 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1110 | Mat::operator std::vector<_Tp>() const |
RyoheiHagimoto | 0:0e0631af0305 | 1111 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1112 | std::vector<_Tp> v; |
RyoheiHagimoto | 0:0e0631af0305 | 1113 | copyTo(v); |
RyoheiHagimoto | 0:0e0631af0305 | 1114 | return v; |
RyoheiHagimoto | 0:0e0631af0305 | 1115 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1116 | |
RyoheiHagimoto | 0:0e0631af0305 | 1117 | template<typename _Tp, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1118 | Mat::operator Vec<_Tp, n>() const |
RyoheiHagimoto | 0:0e0631af0305 | 1119 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1120 | CV_Assert( data && dims <= 2 && (rows == 1 || cols == 1) && |
RyoheiHagimoto | 0:0e0631af0305 | 1121 | rows + cols - 1 == n && channels() == 1 ); |
RyoheiHagimoto | 0:0e0631af0305 | 1122 | |
RyoheiHagimoto | 0:0e0631af0305 | 1123 | if( isContinuous() && type() == DataType<_Tp>::type ) |
RyoheiHagimoto | 0:0e0631af0305 | 1124 | return Vec<_Tp, n>((_Tp*)data); |
RyoheiHagimoto | 0:0e0631af0305 | 1125 | Vec<_Tp, n> v; |
RyoheiHagimoto | 0:0e0631af0305 | 1126 | Mat tmp(rows, cols, DataType<_Tp>::type, v.val); |
RyoheiHagimoto | 0:0e0631af0305 | 1127 | convertTo(tmp, tmp.type()); |
RyoheiHagimoto | 0:0e0631af0305 | 1128 | return v; |
RyoheiHagimoto | 0:0e0631af0305 | 1129 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1130 | |
RyoheiHagimoto | 0:0e0631af0305 | 1131 | template<typename _Tp, int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1132 | Mat::operator Matx<_Tp, m, n>() const |
RyoheiHagimoto | 0:0e0631af0305 | 1133 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1134 | CV_Assert( data && dims <= 2 && rows == m && cols == n && channels() == 1 ); |
RyoheiHagimoto | 0:0e0631af0305 | 1135 | |
RyoheiHagimoto | 0:0e0631af0305 | 1136 | if( isContinuous() && type() == DataType<_Tp>::type ) |
RyoheiHagimoto | 0:0e0631af0305 | 1137 | return Matx<_Tp, m, n>((_Tp*)data); |
RyoheiHagimoto | 0:0e0631af0305 | 1138 | Matx<_Tp, m, n> mtx; |
RyoheiHagimoto | 0:0e0631af0305 | 1139 | Mat tmp(rows, cols, DataType<_Tp>::type, mtx.val); |
RyoheiHagimoto | 0:0e0631af0305 | 1140 | convertTo(tmp, tmp.type()); |
RyoheiHagimoto | 0:0e0631af0305 | 1141 | return mtx; |
RyoheiHagimoto | 0:0e0631af0305 | 1142 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1143 | |
RyoheiHagimoto | 0:0e0631af0305 | 1144 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1145 | void Mat::push_back(const _Tp& elem) |
RyoheiHagimoto | 0:0e0631af0305 | 1146 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1147 | if( !data ) |
RyoheiHagimoto | 0:0e0631af0305 | 1148 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1149 | *this = Mat(1, 1, DataType<_Tp>::type, (void*)&elem).clone(); |
RyoheiHagimoto | 0:0e0631af0305 | 1150 | return; |
RyoheiHagimoto | 0:0e0631af0305 | 1151 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1152 | CV_Assert(DataType<_Tp>::type == type() && cols == 1 |
RyoheiHagimoto | 0:0e0631af0305 | 1153 | /* && dims == 2 (cols == 1 implies dims == 2) */); |
RyoheiHagimoto | 0:0e0631af0305 | 1154 | const uchar* tmp = dataend + step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 1155 | if( !isSubmatrix() && isContinuous() && tmp <= datalimit ) |
RyoheiHagimoto | 0:0e0631af0305 | 1156 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1157 | *(_Tp*)(data + (size.p[0]++) * step.p[0]) = elem; |
RyoheiHagimoto | 0:0e0631af0305 | 1158 | dataend = tmp; |
RyoheiHagimoto | 0:0e0631af0305 | 1159 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1160 | else |
RyoheiHagimoto | 0:0e0631af0305 | 1161 | push_back_(&elem); |
RyoheiHagimoto | 0:0e0631af0305 | 1162 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1163 | |
RyoheiHagimoto | 0:0e0631af0305 | 1164 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1165 | void Mat::push_back(const Mat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1166 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1167 | push_back((const Mat&)m); |
RyoheiHagimoto | 0:0e0631af0305 | 1168 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1169 | |
RyoheiHagimoto | 0:0e0631af0305 | 1170 | template<> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1171 | void Mat::push_back(const MatExpr& expr) |
RyoheiHagimoto | 0:0e0631af0305 | 1172 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1173 | push_back(static_cast<Mat>(expr)); |
RyoheiHagimoto | 0:0e0631af0305 | 1174 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1175 | |
RyoheiHagimoto | 0:0e0631af0305 | 1176 | #ifdef CV_CXX_MOVE_SEMANTICS |
RyoheiHagimoto | 0:0e0631af0305 | 1177 | |
RyoheiHagimoto | 0:0e0631af0305 | 1178 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1179 | Mat::Mat(Mat&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1180 | : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data), |
RyoheiHagimoto | 0:0e0631af0305 | 1181 | datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator), |
RyoheiHagimoto | 0:0e0631af0305 | 1182 | u(m.u), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 1183 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1184 | if (m.dims <= 2) // move new step/size info |
RyoheiHagimoto | 0:0e0631af0305 | 1185 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1186 | step[0] = m.step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 1187 | step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 1188 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1189 | else |
RyoheiHagimoto | 0:0e0631af0305 | 1190 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1191 | CV_DbgAssert(m.step.p != m.step.buf); |
RyoheiHagimoto | 0:0e0631af0305 | 1192 | step.p = m.step.p; |
RyoheiHagimoto | 0:0e0631af0305 | 1193 | size.p = m.size.p; |
RyoheiHagimoto | 0:0e0631af0305 | 1194 | m.step.p = m.step.buf; |
RyoheiHagimoto | 0:0e0631af0305 | 1195 | m.size.p = &m.rows; |
RyoheiHagimoto | 0:0e0631af0305 | 1196 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1197 | m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1198 | m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 1199 | m.allocator = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 1200 | m.u = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 1201 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1202 | |
RyoheiHagimoto | 0:0e0631af0305 | 1203 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1204 | Mat& Mat::operator = (Mat&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1205 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1206 | if (this == &m) |
RyoheiHagimoto | 0:0e0631af0305 | 1207 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1208 | |
RyoheiHagimoto | 0:0e0631af0305 | 1209 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 1210 | flags = m.flags; dims = m.dims; rows = m.rows; cols = m.cols; data = m.data; |
RyoheiHagimoto | 0:0e0631af0305 | 1211 | datastart = m.datastart; dataend = m.dataend; datalimit = m.datalimit; allocator = m.allocator; |
RyoheiHagimoto | 0:0e0631af0305 | 1212 | u = m.u; |
RyoheiHagimoto | 0:0e0631af0305 | 1213 | if (step.p != step.buf) // release self step/size |
RyoheiHagimoto | 0:0e0631af0305 | 1214 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1215 | fastFree(step.p); |
RyoheiHagimoto | 0:0e0631af0305 | 1216 | step.p = step.buf; |
RyoheiHagimoto | 0:0e0631af0305 | 1217 | size.p = &rows; |
RyoheiHagimoto | 0:0e0631af0305 | 1218 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1219 | if (m.dims <= 2) // move new step/size info |
RyoheiHagimoto | 0:0e0631af0305 | 1220 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1221 | step[0] = m.step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 1222 | step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 1223 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1224 | else |
RyoheiHagimoto | 0:0e0631af0305 | 1225 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1226 | CV_DbgAssert(m.step.p != m.step.buf); |
RyoheiHagimoto | 0:0e0631af0305 | 1227 | step.p = m.step.p; |
RyoheiHagimoto | 0:0e0631af0305 | 1228 | size.p = m.size.p; |
RyoheiHagimoto | 0:0e0631af0305 | 1229 | m.step.p = m.step.buf; |
RyoheiHagimoto | 0:0e0631af0305 | 1230 | m.size.p = &m.rows; |
RyoheiHagimoto | 0:0e0631af0305 | 1231 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1232 | m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1233 | m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 1234 | m.allocator = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 1235 | m.u = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 1236 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1237 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1238 | |
RyoheiHagimoto | 0:0e0631af0305 | 1239 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 1240 | |
RyoheiHagimoto | 0:0e0631af0305 | 1241 | |
RyoheiHagimoto | 0:0e0631af0305 | 1242 | ///////////////////////////// MatSize //////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 1243 | |
RyoheiHagimoto | 0:0e0631af0305 | 1244 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1245 | MatSize::MatSize(int* _p) |
RyoheiHagimoto | 0:0e0631af0305 | 1246 | : p(_p) {} |
RyoheiHagimoto | 0:0e0631af0305 | 1247 | |
RyoheiHagimoto | 0:0e0631af0305 | 1248 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1249 | Size MatSize::operator()() const |
RyoheiHagimoto | 0:0e0631af0305 | 1250 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1251 | CV_DbgAssert(p[-1] <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 1252 | return Size(p[1], p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 1253 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1254 | |
RyoheiHagimoto | 0:0e0631af0305 | 1255 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1256 | const int& MatSize::operator[](int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 1257 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1258 | return p[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 1259 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1260 | |
RyoheiHagimoto | 0:0e0631af0305 | 1261 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1262 | int& MatSize::operator[](int i) |
RyoheiHagimoto | 0:0e0631af0305 | 1263 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1264 | return p[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 1265 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1266 | |
RyoheiHagimoto | 0:0e0631af0305 | 1267 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1268 | MatSize::operator const int*() const |
RyoheiHagimoto | 0:0e0631af0305 | 1269 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1270 | return p; |
RyoheiHagimoto | 0:0e0631af0305 | 1271 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1272 | |
RyoheiHagimoto | 0:0e0631af0305 | 1273 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1274 | bool MatSize::operator == (const MatSize& sz) const |
RyoheiHagimoto | 0:0e0631af0305 | 1275 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1276 | int d = p[-1]; |
RyoheiHagimoto | 0:0e0631af0305 | 1277 | int dsz = sz.p[-1]; |
RyoheiHagimoto | 0:0e0631af0305 | 1278 | if( d != dsz ) |
RyoheiHagimoto | 0:0e0631af0305 | 1279 | return false; |
RyoheiHagimoto | 0:0e0631af0305 | 1280 | if( d == 2 ) |
RyoheiHagimoto | 0:0e0631af0305 | 1281 | return p[0] == sz.p[0] && p[1] == sz.p[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 1282 | |
RyoheiHagimoto | 0:0e0631af0305 | 1283 | for( int i = 0; i < d; i++ ) |
RyoheiHagimoto | 0:0e0631af0305 | 1284 | if( p[i] != sz.p[i] ) |
RyoheiHagimoto | 0:0e0631af0305 | 1285 | return false; |
RyoheiHagimoto | 0:0e0631af0305 | 1286 | return true; |
RyoheiHagimoto | 0:0e0631af0305 | 1287 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1288 | |
RyoheiHagimoto | 0:0e0631af0305 | 1289 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1290 | bool MatSize::operator != (const MatSize& sz) const |
RyoheiHagimoto | 0:0e0631af0305 | 1291 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1292 | return !(*this == sz); |
RyoheiHagimoto | 0:0e0631af0305 | 1293 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1294 | |
RyoheiHagimoto | 0:0e0631af0305 | 1295 | |
RyoheiHagimoto | 0:0e0631af0305 | 1296 | |
RyoheiHagimoto | 0:0e0631af0305 | 1297 | ///////////////////////////// MatStep //////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 1298 | |
RyoheiHagimoto | 0:0e0631af0305 | 1299 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1300 | MatStep::MatStep() |
RyoheiHagimoto | 0:0e0631af0305 | 1301 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1302 | p = buf; p[0] = p[1] = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1303 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1304 | |
RyoheiHagimoto | 0:0e0631af0305 | 1305 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1306 | MatStep::MatStep(size_t s) |
RyoheiHagimoto | 0:0e0631af0305 | 1307 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1308 | p = buf; p[0] = s; p[1] = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1309 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1310 | |
RyoheiHagimoto | 0:0e0631af0305 | 1311 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1312 | const size_t& MatStep::operator[](int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 1313 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1314 | return p[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 1315 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1316 | |
RyoheiHagimoto | 0:0e0631af0305 | 1317 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1318 | size_t& MatStep::operator[](int i) |
RyoheiHagimoto | 0:0e0631af0305 | 1319 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1320 | return p[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 1321 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1322 | |
RyoheiHagimoto | 0:0e0631af0305 | 1323 | inline MatStep::operator size_t() const |
RyoheiHagimoto | 0:0e0631af0305 | 1324 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1325 | CV_DbgAssert( p == buf ); |
RyoheiHagimoto | 0:0e0631af0305 | 1326 | return buf[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 1327 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1328 | |
RyoheiHagimoto | 0:0e0631af0305 | 1329 | inline MatStep& MatStep::operator = (size_t s) |
RyoheiHagimoto | 0:0e0631af0305 | 1330 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1331 | CV_DbgAssert( p == buf ); |
RyoheiHagimoto | 0:0e0631af0305 | 1332 | buf[0] = s; |
RyoheiHagimoto | 0:0e0631af0305 | 1333 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1334 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1335 | |
RyoheiHagimoto | 0:0e0631af0305 | 1336 | |
RyoheiHagimoto | 0:0e0631af0305 | 1337 | |
RyoheiHagimoto | 0:0e0631af0305 | 1338 | ////////////////////////////// Mat_<_Tp> //////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 1339 | |
RyoheiHagimoto | 0:0e0631af0305 | 1340 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1341 | Mat_<_Tp>::Mat_() |
RyoheiHagimoto | 0:0e0631af0305 | 1342 | : Mat() |
RyoheiHagimoto | 0:0e0631af0305 | 1343 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1344 | flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; |
RyoheiHagimoto | 0:0e0631af0305 | 1345 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1346 | |
RyoheiHagimoto | 0:0e0631af0305 | 1347 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1348 | Mat_<_Tp>::Mat_(int _rows, int _cols) |
RyoheiHagimoto | 0:0e0631af0305 | 1349 | : Mat(_rows, _cols, DataType<_Tp>::type) |
RyoheiHagimoto | 0:0e0631af0305 | 1350 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1351 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1352 | |
RyoheiHagimoto | 0:0e0631af0305 | 1353 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1354 | Mat_<_Tp>::Mat_(int _rows, int _cols, const _Tp& value) |
RyoheiHagimoto | 0:0e0631af0305 | 1355 | : Mat(_rows, _cols, DataType<_Tp>::type) |
RyoheiHagimoto | 0:0e0631af0305 | 1356 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1357 | *this = value; |
RyoheiHagimoto | 0:0e0631af0305 | 1358 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1359 | |
RyoheiHagimoto | 0:0e0631af0305 | 1360 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1361 | Mat_<_Tp>::Mat_(Size _sz) |
RyoheiHagimoto | 0:0e0631af0305 | 1362 | : Mat(_sz.height, _sz.width, DataType<_Tp>::type) |
RyoheiHagimoto | 0:0e0631af0305 | 1363 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1364 | |
RyoheiHagimoto | 0:0e0631af0305 | 1365 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1366 | Mat_<_Tp>::Mat_(Size _sz, const _Tp& value) |
RyoheiHagimoto | 0:0e0631af0305 | 1367 | : Mat(_sz.height, _sz.width, DataType<_Tp>::type) |
RyoheiHagimoto | 0:0e0631af0305 | 1368 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1369 | *this = value; |
RyoheiHagimoto | 0:0e0631af0305 | 1370 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1371 | |
RyoheiHagimoto | 0:0e0631af0305 | 1372 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1373 | Mat_<_Tp>::Mat_(int _dims, const int* _sz) |
RyoheiHagimoto | 0:0e0631af0305 | 1374 | : Mat(_dims, _sz, DataType<_Tp>::type) |
RyoheiHagimoto | 0:0e0631af0305 | 1375 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1376 | |
RyoheiHagimoto | 0:0e0631af0305 | 1377 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1378 | Mat_<_Tp>::Mat_(int _dims, const int* _sz, const _Tp& _s) |
RyoheiHagimoto | 0:0e0631af0305 | 1379 | : Mat(_dims, _sz, DataType<_Tp>::type, Scalar(_s)) |
RyoheiHagimoto | 0:0e0631af0305 | 1380 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1381 | |
RyoheiHagimoto | 0:0e0631af0305 | 1382 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1383 | Mat_<_Tp>::Mat_(int _dims, const int* _sz, _Tp* _data, const size_t* _steps) |
RyoheiHagimoto | 0:0e0631af0305 | 1384 | : Mat(_dims, _sz, DataType<_Tp>::type, _data, _steps) |
RyoheiHagimoto | 0:0e0631af0305 | 1385 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1386 | |
RyoheiHagimoto | 0:0e0631af0305 | 1387 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1388 | Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const Range* ranges) |
RyoheiHagimoto | 0:0e0631af0305 | 1389 | : Mat(m, ranges) |
RyoheiHagimoto | 0:0e0631af0305 | 1390 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1391 | |
RyoheiHagimoto | 0:0e0631af0305 | 1392 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1393 | Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const std::vector<Range>& ranges) |
RyoheiHagimoto | 0:0e0631af0305 | 1394 | : Mat(m, ranges) |
RyoheiHagimoto | 0:0e0631af0305 | 1395 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1396 | |
RyoheiHagimoto | 0:0e0631af0305 | 1397 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1398 | Mat_<_Tp>::Mat_(const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1399 | : Mat() |
RyoheiHagimoto | 0:0e0631af0305 | 1400 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1401 | flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; |
RyoheiHagimoto | 0:0e0631af0305 | 1402 | *this = m; |
RyoheiHagimoto | 0:0e0631af0305 | 1403 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1404 | |
RyoheiHagimoto | 0:0e0631af0305 | 1405 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1406 | Mat_<_Tp>::Mat_(const Mat_& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1407 | : Mat(m) |
RyoheiHagimoto | 0:0e0631af0305 | 1408 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1409 | |
RyoheiHagimoto | 0:0e0631af0305 | 1410 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1411 | Mat_<_Tp>::Mat_(int _rows, int _cols, _Tp* _data, size_t steps) |
RyoheiHagimoto | 0:0e0631af0305 | 1412 | : Mat(_rows, _cols, DataType<_Tp>::type, _data, steps) |
RyoheiHagimoto | 0:0e0631af0305 | 1413 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1414 | |
RyoheiHagimoto | 0:0e0631af0305 | 1415 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1416 | Mat_<_Tp>::Mat_(const Mat_& m, const Range& _rowRange, const Range& _colRange) |
RyoheiHagimoto | 0:0e0631af0305 | 1417 | : Mat(m, _rowRange, _colRange) |
RyoheiHagimoto | 0:0e0631af0305 | 1418 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1419 | |
RyoheiHagimoto | 0:0e0631af0305 | 1420 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1421 | Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi) |
RyoheiHagimoto | 0:0e0631af0305 | 1422 | : Mat(m, roi) |
RyoheiHagimoto | 0:0e0631af0305 | 1423 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1424 | |
RyoheiHagimoto | 0:0e0631af0305 | 1425 | template<typename _Tp> template<int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1426 | Mat_<_Tp>::Mat_(const Vec<typename DataType<_Tp>::channel_type, n>& vec, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 1427 | : Mat(n / DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&vec) |
RyoheiHagimoto | 0:0e0631af0305 | 1428 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1429 | CV_Assert(n%DataType<_Tp>::channels == 0); |
RyoheiHagimoto | 0:0e0631af0305 | 1430 | if( copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 1431 | *this = clone(); |
RyoheiHagimoto | 0:0e0631af0305 | 1432 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1433 | |
RyoheiHagimoto | 0:0e0631af0305 | 1434 | template<typename _Tp> template<int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1435 | Mat_<_Tp>::Mat_(const Matx<typename DataType<_Tp>::channel_type, m, n>& M, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 1436 | : Mat(m, n / DataType<_Tp>::channels, DataType<_Tp>::type, (void*)&M) |
RyoheiHagimoto | 0:0e0631af0305 | 1437 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1438 | CV_Assert(n % DataType<_Tp>::channels == 0); |
RyoheiHagimoto | 0:0e0631af0305 | 1439 | if( copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 1440 | *this = clone(); |
RyoheiHagimoto | 0:0e0631af0305 | 1441 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1442 | |
RyoheiHagimoto | 0:0e0631af0305 | 1443 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1444 | Mat_<_Tp>::Mat_(const Point_<typename DataType<_Tp>::channel_type>& pt, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 1445 | : Mat(2 / DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&pt) |
RyoheiHagimoto | 0:0e0631af0305 | 1446 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1447 | CV_Assert(2 % DataType<_Tp>::channels == 0); |
RyoheiHagimoto | 0:0e0631af0305 | 1448 | if( copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 1449 | *this = clone(); |
RyoheiHagimoto | 0:0e0631af0305 | 1450 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1451 | |
RyoheiHagimoto | 0:0e0631af0305 | 1452 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1453 | Mat_<_Tp>::Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 1454 | : Mat(3 / DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&pt) |
RyoheiHagimoto | 0:0e0631af0305 | 1455 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1456 | CV_Assert(3 % DataType<_Tp>::channels == 0); |
RyoheiHagimoto | 0:0e0631af0305 | 1457 | if( copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 1458 | *this = clone(); |
RyoheiHagimoto | 0:0e0631af0305 | 1459 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1460 | |
RyoheiHagimoto | 0:0e0631af0305 | 1461 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1462 | Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer) |
RyoheiHagimoto | 0:0e0631af0305 | 1463 | : Mat(commaInitializer) |
RyoheiHagimoto | 0:0e0631af0305 | 1464 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1465 | |
RyoheiHagimoto | 0:0e0631af0305 | 1466 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1467 | Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 1468 | : Mat(vec, copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 1469 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1470 | |
RyoheiHagimoto | 0:0e0631af0305 | 1471 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1472 | Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1473 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1474 | if( DataType<_Tp>::type == m.type() ) |
RyoheiHagimoto | 0:0e0631af0305 | 1475 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1476 | Mat::operator = (m); |
RyoheiHagimoto | 0:0e0631af0305 | 1477 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1478 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1479 | if( DataType<_Tp>::depth == m.depth() ) |
RyoheiHagimoto | 0:0e0631af0305 | 1480 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1481 | return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0)); |
RyoheiHagimoto | 0:0e0631af0305 | 1482 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1483 | CV_DbgAssert(DataType<_Tp>::channels == m.channels()); |
RyoheiHagimoto | 0:0e0631af0305 | 1484 | m.convertTo(*this, type()); |
RyoheiHagimoto | 0:0e0631af0305 | 1485 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1486 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1487 | |
RyoheiHagimoto | 0:0e0631af0305 | 1488 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1489 | Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat_& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1490 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1491 | Mat::operator=(m); |
RyoheiHagimoto | 0:0e0631af0305 | 1492 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1493 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1494 | |
RyoheiHagimoto | 0:0e0631af0305 | 1495 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1496 | Mat_<_Tp>& Mat_<_Tp>::operator = (const _Tp& s) |
RyoheiHagimoto | 0:0e0631af0305 | 1497 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1498 | typedef typename DataType<_Tp>::vec_type VT; |
RyoheiHagimoto | 0:0e0631af0305 | 1499 | Mat::operator=(Scalar((const VT&)s)); |
RyoheiHagimoto | 0:0e0631af0305 | 1500 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1501 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1502 | |
RyoheiHagimoto | 0:0e0631af0305 | 1503 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1504 | void Mat_<_Tp>::create(int _rows, int _cols) |
RyoheiHagimoto | 0:0e0631af0305 | 1505 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1506 | Mat::create(_rows, _cols, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 1507 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1508 | |
RyoheiHagimoto | 0:0e0631af0305 | 1509 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1510 | void Mat_<_Tp>::create(Size _sz) |
RyoheiHagimoto | 0:0e0631af0305 | 1511 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1512 | Mat::create(_sz, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 1513 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1514 | |
RyoheiHagimoto | 0:0e0631af0305 | 1515 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1516 | void Mat_<_Tp>::create(int _dims, const int* _sz) |
RyoheiHagimoto | 0:0e0631af0305 | 1517 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1518 | Mat::create(_dims, _sz, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 1519 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1520 | |
RyoheiHagimoto | 0:0e0631af0305 | 1521 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1522 | Mat_<_Tp> Mat_<_Tp>::cross(const Mat_& m) const |
RyoheiHagimoto | 0:0e0631af0305 | 1523 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1524 | return Mat_<_Tp>(Mat::cross(m)); |
RyoheiHagimoto | 0:0e0631af0305 | 1525 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1526 | |
RyoheiHagimoto | 0:0e0631af0305 | 1527 | template<typename _Tp> template<typename T2> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1528 | Mat_<_Tp>::operator Mat_<T2>() const |
RyoheiHagimoto | 0:0e0631af0305 | 1529 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1530 | return Mat_<T2>(*this); |
RyoheiHagimoto | 0:0e0631af0305 | 1531 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1532 | |
RyoheiHagimoto | 0:0e0631af0305 | 1533 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1534 | Mat_<_Tp> Mat_<_Tp>::row(int y) const |
RyoheiHagimoto | 0:0e0631af0305 | 1535 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1536 | return Mat_(*this, Range(y, y+1), Range::all()); |
RyoheiHagimoto | 0:0e0631af0305 | 1537 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1538 | |
RyoheiHagimoto | 0:0e0631af0305 | 1539 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1540 | Mat_<_Tp> Mat_<_Tp>::col(int x) const |
RyoheiHagimoto | 0:0e0631af0305 | 1541 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1542 | return Mat_(*this, Range::all(), Range(x, x+1)); |
RyoheiHagimoto | 0:0e0631af0305 | 1543 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1544 | |
RyoheiHagimoto | 0:0e0631af0305 | 1545 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1546 | Mat_<_Tp> Mat_<_Tp>::diag(int d) const |
RyoheiHagimoto | 0:0e0631af0305 | 1547 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1548 | return Mat_(Mat::diag(d)); |
RyoheiHagimoto | 0:0e0631af0305 | 1549 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1550 | |
RyoheiHagimoto | 0:0e0631af0305 | 1551 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1552 | Mat_<_Tp> Mat_<_Tp>::clone() const |
RyoheiHagimoto | 0:0e0631af0305 | 1553 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1554 | return Mat_(Mat::clone()); |
RyoheiHagimoto | 0:0e0631af0305 | 1555 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1556 | |
RyoheiHagimoto | 0:0e0631af0305 | 1557 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1558 | size_t Mat_<_Tp>::elemSize() const |
RyoheiHagimoto | 0:0e0631af0305 | 1559 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1560 | CV_DbgAssert( Mat::elemSize() == sizeof(_Tp) ); |
RyoheiHagimoto | 0:0e0631af0305 | 1561 | return sizeof(_Tp); |
RyoheiHagimoto | 0:0e0631af0305 | 1562 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1563 | |
RyoheiHagimoto | 0:0e0631af0305 | 1564 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1565 | size_t Mat_<_Tp>::elemSize1() const |
RyoheiHagimoto | 0:0e0631af0305 | 1566 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1567 | CV_DbgAssert( Mat::elemSize1() == sizeof(_Tp) / DataType<_Tp>::channels ); |
RyoheiHagimoto | 0:0e0631af0305 | 1568 | return sizeof(_Tp) / DataType<_Tp>::channels; |
RyoheiHagimoto | 0:0e0631af0305 | 1569 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1570 | |
RyoheiHagimoto | 0:0e0631af0305 | 1571 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1572 | int Mat_<_Tp>::type() const |
RyoheiHagimoto | 0:0e0631af0305 | 1573 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1574 | CV_DbgAssert( Mat::type() == DataType<_Tp>::type ); |
RyoheiHagimoto | 0:0e0631af0305 | 1575 | return DataType<_Tp>::type; |
RyoheiHagimoto | 0:0e0631af0305 | 1576 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1577 | |
RyoheiHagimoto | 0:0e0631af0305 | 1578 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1579 | int Mat_<_Tp>::depth() const |
RyoheiHagimoto | 0:0e0631af0305 | 1580 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1581 | CV_DbgAssert( Mat::depth() == DataType<_Tp>::depth ); |
RyoheiHagimoto | 0:0e0631af0305 | 1582 | return DataType<_Tp>::depth; |
RyoheiHagimoto | 0:0e0631af0305 | 1583 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1584 | |
RyoheiHagimoto | 0:0e0631af0305 | 1585 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1586 | int Mat_<_Tp>::channels() const |
RyoheiHagimoto | 0:0e0631af0305 | 1587 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1588 | CV_DbgAssert( Mat::channels() == DataType<_Tp>::channels ); |
RyoheiHagimoto | 0:0e0631af0305 | 1589 | return DataType<_Tp>::channels; |
RyoheiHagimoto | 0:0e0631af0305 | 1590 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1591 | |
RyoheiHagimoto | 0:0e0631af0305 | 1592 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1593 | size_t Mat_<_Tp>::stepT(int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 1594 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1595 | return step.p[i] / elemSize(); |
RyoheiHagimoto | 0:0e0631af0305 | 1596 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1597 | |
RyoheiHagimoto | 0:0e0631af0305 | 1598 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1599 | size_t Mat_<_Tp>::step1(int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 1600 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1601 | return step.p[i] / elemSize1(); |
RyoheiHagimoto | 0:0e0631af0305 | 1602 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1603 | |
RyoheiHagimoto | 0:0e0631af0305 | 1604 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1605 | Mat_<_Tp>& Mat_<_Tp>::adjustROI( int dtop, int dbottom, int dleft, int dright ) |
RyoheiHagimoto | 0:0e0631af0305 | 1606 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1607 | return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright)); |
RyoheiHagimoto | 0:0e0631af0305 | 1608 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1609 | |
RyoheiHagimoto | 0:0e0631af0305 | 1610 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1611 | Mat_<_Tp> Mat_<_Tp>::operator()( const Range& _rowRange, const Range& _colRange ) const |
RyoheiHagimoto | 0:0e0631af0305 | 1612 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1613 | return Mat_<_Tp>(*this, _rowRange, _colRange); |
RyoheiHagimoto | 0:0e0631af0305 | 1614 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1615 | |
RyoheiHagimoto | 0:0e0631af0305 | 1616 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1617 | Mat_<_Tp> Mat_<_Tp>::operator()( const Rect& roi ) const |
RyoheiHagimoto | 0:0e0631af0305 | 1618 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1619 | return Mat_<_Tp>(*this, roi); |
RyoheiHagimoto | 0:0e0631af0305 | 1620 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1621 | |
RyoheiHagimoto | 0:0e0631af0305 | 1622 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1623 | Mat_<_Tp> Mat_<_Tp>::operator()( const Range* ranges ) const |
RyoheiHagimoto | 0:0e0631af0305 | 1624 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1625 | return Mat_<_Tp>(*this, ranges); |
RyoheiHagimoto | 0:0e0631af0305 | 1626 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1627 | |
RyoheiHagimoto | 0:0e0631af0305 | 1628 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1629 | Mat_<_Tp> Mat_<_Tp>::operator()(const std::vector<Range>& ranges) const |
RyoheiHagimoto | 0:0e0631af0305 | 1630 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1631 | return Mat_<_Tp>(*this, ranges); |
RyoheiHagimoto | 0:0e0631af0305 | 1632 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1633 | |
RyoheiHagimoto | 0:0e0631af0305 | 1634 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1635 | _Tp* Mat_<_Tp>::operator [](int y) |
RyoheiHagimoto | 0:0e0631af0305 | 1636 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1637 | CV_DbgAssert( 0 <= y && y < rows ); |
RyoheiHagimoto | 0:0e0631af0305 | 1638 | return (_Tp*)(data + y*step.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 1639 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1640 | |
RyoheiHagimoto | 0:0e0631af0305 | 1641 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1642 | const _Tp* Mat_<_Tp>::operator [](int y) const |
RyoheiHagimoto | 0:0e0631af0305 | 1643 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1644 | CV_DbgAssert( 0 <= y && y < rows ); |
RyoheiHagimoto | 0:0e0631af0305 | 1645 | return (const _Tp*)(data + y*step.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 1646 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1647 | |
RyoheiHagimoto | 0:0e0631af0305 | 1648 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1649 | _Tp& Mat_<_Tp>::operator ()(int i0, int i1) |
RyoheiHagimoto | 0:0e0631af0305 | 1650 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1651 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 1652 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 1653 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 1654 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 1655 | CV_DbgAssert(type() == DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 1656 | return ((_Tp*)(data + step.p[0] * i0))[i1]; |
RyoheiHagimoto | 0:0e0631af0305 | 1657 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1658 | |
RyoheiHagimoto | 0:0e0631af0305 | 1659 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1660 | const _Tp& Mat_<_Tp>::operator ()(int i0, int i1) const |
RyoheiHagimoto | 0:0e0631af0305 | 1661 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1662 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 1663 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 1664 | CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 1665 | CV_DbgAssert((unsigned)i1 < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 1666 | CV_DbgAssert(type() == DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 1667 | return ((const _Tp*)(data + step.p[0] * i0))[i1]; |
RyoheiHagimoto | 0:0e0631af0305 | 1668 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1669 | |
RyoheiHagimoto | 0:0e0631af0305 | 1670 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1671 | _Tp& Mat_<_Tp>::operator ()(Point pt) |
RyoheiHagimoto | 0:0e0631af0305 | 1672 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1673 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 1674 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 1675 | CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 1676 | CV_DbgAssert((unsigned)pt.x < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 1677 | CV_DbgAssert(type() == DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 1678 | return ((_Tp*)(data + step.p[0] * pt.y))[pt.x]; |
RyoheiHagimoto | 0:0e0631af0305 | 1679 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1680 | |
RyoheiHagimoto | 0:0e0631af0305 | 1681 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1682 | const _Tp& Mat_<_Tp>::operator ()(Point pt) const |
RyoheiHagimoto | 0:0e0631af0305 | 1683 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1684 | CV_DbgAssert(dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 1685 | CV_DbgAssert(data); |
RyoheiHagimoto | 0:0e0631af0305 | 1686 | CV_DbgAssert((unsigned)pt.y < (unsigned)size.p[0]); |
RyoheiHagimoto | 0:0e0631af0305 | 1687 | CV_DbgAssert((unsigned)pt.x < (unsigned)size.p[1]); |
RyoheiHagimoto | 0:0e0631af0305 | 1688 | CV_DbgAssert(type() == DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 1689 | return ((const _Tp*)(data + step.p[0] * pt.y))[pt.x]; |
RyoheiHagimoto | 0:0e0631af0305 | 1690 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1691 | |
RyoheiHagimoto | 0:0e0631af0305 | 1692 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1693 | _Tp& Mat_<_Tp>::operator ()(const int* idx) |
RyoheiHagimoto | 0:0e0631af0305 | 1694 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1695 | return Mat::at<_Tp>(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 1696 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1697 | |
RyoheiHagimoto | 0:0e0631af0305 | 1698 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1699 | const _Tp& Mat_<_Tp>::operator ()(const int* idx) const |
RyoheiHagimoto | 0:0e0631af0305 | 1700 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1701 | return Mat::at<_Tp>(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 1702 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1703 | |
RyoheiHagimoto | 0:0e0631af0305 | 1704 | template<typename _Tp> template<int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1705 | _Tp& Mat_<_Tp>::operator ()(const Vec<int, n>& idx) |
RyoheiHagimoto | 0:0e0631af0305 | 1706 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1707 | return Mat::at<_Tp>(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 1708 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1709 | |
RyoheiHagimoto | 0:0e0631af0305 | 1710 | template<typename _Tp> template<int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1711 | const _Tp& Mat_<_Tp>::operator ()(const Vec<int, n>& idx) const |
RyoheiHagimoto | 0:0e0631af0305 | 1712 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1713 | return Mat::at<_Tp>(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 1714 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1715 | |
RyoheiHagimoto | 0:0e0631af0305 | 1716 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1717 | _Tp& Mat_<_Tp>::operator ()(int i0) |
RyoheiHagimoto | 0:0e0631af0305 | 1718 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1719 | return this->at<_Tp>(i0); |
RyoheiHagimoto | 0:0e0631af0305 | 1720 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1721 | |
RyoheiHagimoto | 0:0e0631af0305 | 1722 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1723 | const _Tp& Mat_<_Tp>::operator ()(int i0) const |
RyoheiHagimoto | 0:0e0631af0305 | 1724 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1725 | return this->at<_Tp>(i0); |
RyoheiHagimoto | 0:0e0631af0305 | 1726 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1727 | |
RyoheiHagimoto | 0:0e0631af0305 | 1728 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1729 | _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) |
RyoheiHagimoto | 0:0e0631af0305 | 1730 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1731 | return this->at<_Tp>(i0, i1, i2); |
RyoheiHagimoto | 0:0e0631af0305 | 1732 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1733 | |
RyoheiHagimoto | 0:0e0631af0305 | 1734 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1735 | const _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) const |
RyoheiHagimoto | 0:0e0631af0305 | 1736 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1737 | return this->at<_Tp>(i0, i1, i2); |
RyoheiHagimoto | 0:0e0631af0305 | 1738 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1739 | |
RyoheiHagimoto | 0:0e0631af0305 | 1740 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1741 | Mat_<_Tp>::operator std::vector<_Tp>() const |
RyoheiHagimoto | 0:0e0631af0305 | 1742 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1743 | std::vector<_Tp> v; |
RyoheiHagimoto | 0:0e0631af0305 | 1744 | copyTo(v); |
RyoheiHagimoto | 0:0e0631af0305 | 1745 | return v; |
RyoheiHagimoto | 0:0e0631af0305 | 1746 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1747 | |
RyoheiHagimoto | 0:0e0631af0305 | 1748 | template<typename _Tp> template<int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1749 | Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>() const |
RyoheiHagimoto | 0:0e0631af0305 | 1750 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1751 | CV_Assert(n % DataType<_Tp>::channels == 0); |
RyoheiHagimoto | 0:0e0631af0305 | 1752 | |
RyoheiHagimoto | 0:0e0631af0305 | 1753 | #if defined _MSC_VER |
RyoheiHagimoto | 0:0e0631af0305 | 1754 | const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) |
RyoheiHagimoto | 0:0e0631af0305 | 1755 | return pMat->operator Vec<typename DataType<_Tp>::channel_type, n>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1756 | #else |
RyoheiHagimoto | 0:0e0631af0305 | 1757 | return this->Mat::operator Vec<typename DataType<_Tp>::channel_type, n>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1758 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 1759 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1760 | |
RyoheiHagimoto | 0:0e0631af0305 | 1761 | template<typename _Tp> template<int m, int n> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1762 | Mat_<_Tp>::operator Matx<typename DataType<_Tp>::channel_type, m, n>() const |
RyoheiHagimoto | 0:0e0631af0305 | 1763 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1764 | CV_Assert(n % DataType<_Tp>::channels == 0); |
RyoheiHagimoto | 0:0e0631af0305 | 1765 | |
RyoheiHagimoto | 0:0e0631af0305 | 1766 | #if defined _MSC_VER |
RyoheiHagimoto | 0:0e0631af0305 | 1767 | const Mat* pMat = (const Mat*)this; // workaround for MSVS <= 2012 compiler bugs (but GCC 4.6 dislikes this workaround) |
RyoheiHagimoto | 0:0e0631af0305 | 1768 | Matx<typename DataType<_Tp>::channel_type, m, n> res = pMat->operator Matx<typename DataType<_Tp>::channel_type, m, n>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1769 | return res; |
RyoheiHagimoto | 0:0e0631af0305 | 1770 | #else |
RyoheiHagimoto | 0:0e0631af0305 | 1771 | Matx<typename DataType<_Tp>::channel_type, m, n> res = this->Mat::operator Matx<typename DataType<_Tp>::channel_type, m, n>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1772 | return res; |
RyoheiHagimoto | 0:0e0631af0305 | 1773 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 1774 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1775 | |
RyoheiHagimoto | 0:0e0631af0305 | 1776 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1777 | MatConstIterator_<_Tp> Mat_<_Tp>::begin() const |
RyoheiHagimoto | 0:0e0631af0305 | 1778 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1779 | return Mat::begin<_Tp>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1780 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1781 | |
RyoheiHagimoto | 0:0e0631af0305 | 1782 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1783 | MatConstIterator_<_Tp> Mat_<_Tp>::end() const |
RyoheiHagimoto | 0:0e0631af0305 | 1784 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1785 | return Mat::end<_Tp>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1786 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1787 | |
RyoheiHagimoto | 0:0e0631af0305 | 1788 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1789 | MatIterator_<_Tp> Mat_<_Tp>::begin() |
RyoheiHagimoto | 0:0e0631af0305 | 1790 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1791 | return Mat::begin<_Tp>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1792 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1793 | |
RyoheiHagimoto | 0:0e0631af0305 | 1794 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1795 | MatIterator_<_Tp> Mat_<_Tp>::end() |
RyoheiHagimoto | 0:0e0631af0305 | 1796 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1797 | return Mat::end<_Tp>(); |
RyoheiHagimoto | 0:0e0631af0305 | 1798 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1799 | |
RyoheiHagimoto | 0:0e0631af0305 | 1800 | template<typename _Tp> template<typename Functor> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1801 | void Mat_<_Tp>::forEach(const Functor& operation) { |
RyoheiHagimoto | 0:0e0631af0305 | 1802 | Mat::forEach<_Tp, Functor>(operation); |
RyoheiHagimoto | 0:0e0631af0305 | 1803 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1804 | |
RyoheiHagimoto | 0:0e0631af0305 | 1805 | template<typename _Tp> template<typename Functor> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1806 | void Mat_<_Tp>::forEach(const Functor& operation) const { |
RyoheiHagimoto | 0:0e0631af0305 | 1807 | Mat::forEach<_Tp, Functor>(operation); |
RyoheiHagimoto | 0:0e0631af0305 | 1808 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1809 | |
RyoheiHagimoto | 0:0e0631af0305 | 1810 | #ifdef CV_CXX_MOVE_SEMANTICS |
RyoheiHagimoto | 0:0e0631af0305 | 1811 | |
RyoheiHagimoto | 0:0e0631af0305 | 1812 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1813 | Mat_<_Tp>::Mat_(Mat_&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1814 | : Mat(m) |
RyoheiHagimoto | 0:0e0631af0305 | 1815 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1816 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1817 | |
RyoheiHagimoto | 0:0e0631af0305 | 1818 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1819 | Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1820 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1821 | Mat::operator = (m); |
RyoheiHagimoto | 0:0e0631af0305 | 1822 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1823 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1824 | |
RyoheiHagimoto | 0:0e0631af0305 | 1825 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1826 | Mat_<_Tp>::Mat_(Mat&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1827 | : Mat() |
RyoheiHagimoto | 0:0e0631af0305 | 1828 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1829 | flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; |
RyoheiHagimoto | 0:0e0631af0305 | 1830 | *this = m; |
RyoheiHagimoto | 0:0e0631af0305 | 1831 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1832 | |
RyoheiHagimoto | 0:0e0631af0305 | 1833 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1834 | Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1835 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1836 | if( DataType<_Tp>::type == m.type() ) |
RyoheiHagimoto | 0:0e0631af0305 | 1837 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1838 | Mat::operator = ((Mat&&)m); |
RyoheiHagimoto | 0:0e0631af0305 | 1839 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1840 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1841 | if( DataType<_Tp>::depth == m.depth() ) |
RyoheiHagimoto | 0:0e0631af0305 | 1842 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1843 | Mat::operator = ((Mat&&)m.reshape(DataType<_Tp>::channels, m.dims, 0)); |
RyoheiHagimoto | 0:0e0631af0305 | 1844 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1845 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1846 | CV_DbgAssert(DataType<_Tp>::channels == m.channels()); |
RyoheiHagimoto | 0:0e0631af0305 | 1847 | m.convertTo(*this, type()); |
RyoheiHagimoto | 0:0e0631af0305 | 1848 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1849 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1850 | |
RyoheiHagimoto | 0:0e0631af0305 | 1851 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 1852 | Mat_<_Tp>::Mat_(MatExpr&& e) |
RyoheiHagimoto | 0:0e0631af0305 | 1853 | : Mat() |
RyoheiHagimoto | 0:0e0631af0305 | 1854 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1855 | flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; |
RyoheiHagimoto | 0:0e0631af0305 | 1856 | *this = Mat(e); |
RyoheiHagimoto | 0:0e0631af0305 | 1857 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1858 | |
RyoheiHagimoto | 0:0e0631af0305 | 1859 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 1860 | |
RyoheiHagimoto | 0:0e0631af0305 | 1861 | ///////////////////////////// SparseMat ///////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 1862 | |
RyoheiHagimoto | 0:0e0631af0305 | 1863 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1864 | SparseMat::SparseMat() |
RyoheiHagimoto | 0:0e0631af0305 | 1865 | : flags(MAGIC_VAL), hdr(0) |
RyoheiHagimoto | 0:0e0631af0305 | 1866 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 1867 | |
RyoheiHagimoto | 0:0e0631af0305 | 1868 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1869 | SparseMat::SparseMat(int _dims, const int* _sizes, int _type) |
RyoheiHagimoto | 0:0e0631af0305 | 1870 | : flags(MAGIC_VAL), hdr(0) |
RyoheiHagimoto | 0:0e0631af0305 | 1871 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1872 | create(_dims, _sizes, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 1873 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1874 | |
RyoheiHagimoto | 0:0e0631af0305 | 1875 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1876 | SparseMat::SparseMat(const SparseMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1877 | : flags(m.flags), hdr(m.hdr) |
RyoheiHagimoto | 0:0e0631af0305 | 1878 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1879 | addref(); |
RyoheiHagimoto | 0:0e0631af0305 | 1880 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1881 | |
RyoheiHagimoto | 0:0e0631af0305 | 1882 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1883 | SparseMat::~SparseMat() |
RyoheiHagimoto | 0:0e0631af0305 | 1884 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1885 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 1886 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1887 | |
RyoheiHagimoto | 0:0e0631af0305 | 1888 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1889 | SparseMat& SparseMat::operator = (const SparseMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1890 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1891 | if( this != &m ) |
RyoheiHagimoto | 0:0e0631af0305 | 1892 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1893 | if( m.hdr ) |
RyoheiHagimoto | 0:0e0631af0305 | 1894 | CV_XADD(&m.hdr->refcount, 1); |
RyoheiHagimoto | 0:0e0631af0305 | 1895 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 1896 | flags = m.flags; |
RyoheiHagimoto | 0:0e0631af0305 | 1897 | hdr = m.hdr; |
RyoheiHagimoto | 0:0e0631af0305 | 1898 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1899 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1900 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1901 | |
RyoheiHagimoto | 0:0e0631af0305 | 1902 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1903 | SparseMat& SparseMat::operator = (const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 1904 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1905 | return (*this = SparseMat(m)); |
RyoheiHagimoto | 0:0e0631af0305 | 1906 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1907 | |
RyoheiHagimoto | 0:0e0631af0305 | 1908 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1909 | SparseMat SparseMat::clone() const |
RyoheiHagimoto | 0:0e0631af0305 | 1910 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1911 | SparseMat temp; |
RyoheiHagimoto | 0:0e0631af0305 | 1912 | this->copyTo(temp); |
RyoheiHagimoto | 0:0e0631af0305 | 1913 | return temp; |
RyoheiHagimoto | 0:0e0631af0305 | 1914 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1915 | |
RyoheiHagimoto | 0:0e0631af0305 | 1916 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1917 | void SparseMat::assignTo( SparseMat& m, int _type ) const |
RyoheiHagimoto | 0:0e0631af0305 | 1918 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1919 | if( _type < 0 ) |
RyoheiHagimoto | 0:0e0631af0305 | 1920 | m = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 1921 | else |
RyoheiHagimoto | 0:0e0631af0305 | 1922 | convertTo(m, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 1923 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1924 | |
RyoheiHagimoto | 0:0e0631af0305 | 1925 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1926 | void SparseMat::addref() |
RyoheiHagimoto | 0:0e0631af0305 | 1927 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1928 | if( hdr ) |
RyoheiHagimoto | 0:0e0631af0305 | 1929 | CV_XADD(&hdr->refcount, 1); |
RyoheiHagimoto | 0:0e0631af0305 | 1930 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1931 | |
RyoheiHagimoto | 0:0e0631af0305 | 1932 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1933 | void SparseMat::release() |
RyoheiHagimoto | 0:0e0631af0305 | 1934 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1935 | if( hdr && CV_XADD(&hdr->refcount, -1) == 1 ) |
RyoheiHagimoto | 0:0e0631af0305 | 1936 | delete hdr; |
RyoheiHagimoto | 0:0e0631af0305 | 1937 | hdr = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1938 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1939 | |
RyoheiHagimoto | 0:0e0631af0305 | 1940 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1941 | size_t SparseMat::elemSize() const |
RyoheiHagimoto | 0:0e0631af0305 | 1942 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1943 | return CV_ELEM_SIZE(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 1944 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1945 | |
RyoheiHagimoto | 0:0e0631af0305 | 1946 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1947 | size_t SparseMat::elemSize1() const |
RyoheiHagimoto | 0:0e0631af0305 | 1948 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1949 | return CV_ELEM_SIZE1(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 1950 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1951 | |
RyoheiHagimoto | 0:0e0631af0305 | 1952 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1953 | int SparseMat::type() const |
RyoheiHagimoto | 0:0e0631af0305 | 1954 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1955 | return CV_MAT_TYPE(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 1956 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1957 | |
RyoheiHagimoto | 0:0e0631af0305 | 1958 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1959 | int SparseMat::depth() const |
RyoheiHagimoto | 0:0e0631af0305 | 1960 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1961 | return CV_MAT_DEPTH(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 1962 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1963 | |
RyoheiHagimoto | 0:0e0631af0305 | 1964 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1965 | int SparseMat::channels() const |
RyoheiHagimoto | 0:0e0631af0305 | 1966 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1967 | return CV_MAT_CN(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 1968 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1969 | |
RyoheiHagimoto | 0:0e0631af0305 | 1970 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1971 | const int* SparseMat::size() const |
RyoheiHagimoto | 0:0e0631af0305 | 1972 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1973 | return hdr ? hdr->size : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1974 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1975 | |
RyoheiHagimoto | 0:0e0631af0305 | 1976 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1977 | int SparseMat::size(int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 1978 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1979 | if( hdr ) |
RyoheiHagimoto | 0:0e0631af0305 | 1980 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1981 | CV_DbgAssert((unsigned)i < (unsigned)hdr->dims); |
RyoheiHagimoto | 0:0e0631af0305 | 1982 | return hdr->size[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 1983 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1984 | return 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1985 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1986 | |
RyoheiHagimoto | 0:0e0631af0305 | 1987 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1988 | int SparseMat::dims() const |
RyoheiHagimoto | 0:0e0631af0305 | 1989 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1990 | return hdr ? hdr->dims : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1991 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1992 | |
RyoheiHagimoto | 0:0e0631af0305 | 1993 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 1994 | size_t SparseMat::nzcount() const |
RyoheiHagimoto | 0:0e0631af0305 | 1995 | { |
RyoheiHagimoto | 0:0e0631af0305 | 1996 | return hdr ? hdr->nodeCount : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 1997 | } |
RyoheiHagimoto | 0:0e0631af0305 | 1998 | |
RyoheiHagimoto | 0:0e0631af0305 | 1999 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2000 | size_t SparseMat::hash(int i0) const |
RyoheiHagimoto | 0:0e0631af0305 | 2001 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2002 | return (size_t)i0; |
RyoheiHagimoto | 0:0e0631af0305 | 2003 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2004 | |
RyoheiHagimoto | 0:0e0631af0305 | 2005 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2006 | size_t SparseMat::hash(int i0, int i1) const |
RyoheiHagimoto | 0:0e0631af0305 | 2007 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2008 | return (size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1; |
RyoheiHagimoto | 0:0e0631af0305 | 2009 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2010 | |
RyoheiHagimoto | 0:0e0631af0305 | 2011 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2012 | size_t SparseMat::hash(int i0, int i1, int i2) const |
RyoheiHagimoto | 0:0e0631af0305 | 2013 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2014 | return ((size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1) * HASH_SCALE + (unsigned)i2; |
RyoheiHagimoto | 0:0e0631af0305 | 2015 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2016 | |
RyoheiHagimoto | 0:0e0631af0305 | 2017 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2018 | size_t SparseMat::hash(const int* idx) const |
RyoheiHagimoto | 0:0e0631af0305 | 2019 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2020 | size_t h = (unsigned)idx[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 2021 | if( !hdr ) |
RyoheiHagimoto | 0:0e0631af0305 | 2022 | return 0; |
RyoheiHagimoto | 0:0e0631af0305 | 2023 | int d = hdr->dims; |
RyoheiHagimoto | 0:0e0631af0305 | 2024 | for(int i = 1; i < d; i++ ) |
RyoheiHagimoto | 0:0e0631af0305 | 2025 | h = h * HASH_SCALE + (unsigned)idx[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 2026 | return h; |
RyoheiHagimoto | 0:0e0631af0305 | 2027 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2028 | |
RyoheiHagimoto | 0:0e0631af0305 | 2029 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2030 | _Tp& SparseMat::ref(int i0, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2031 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2032 | return *(_Tp*)((SparseMat*)this)->ptr(i0, true, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2033 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2034 | |
RyoheiHagimoto | 0:0e0631af0305 | 2035 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2036 | _Tp& SparseMat::ref(int i0, int i1, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2037 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2038 | return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, true, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2039 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2040 | |
RyoheiHagimoto | 0:0e0631af0305 | 2041 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2042 | _Tp& SparseMat::ref(int i0, int i1, int i2, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2043 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2044 | return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, i2, true, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2045 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2046 | |
RyoheiHagimoto | 0:0e0631af0305 | 2047 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2048 | _Tp& SparseMat::ref(const int* idx, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2049 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2050 | return *(_Tp*)((SparseMat*)this)->ptr(idx, true, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2051 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2052 | |
RyoheiHagimoto | 0:0e0631af0305 | 2053 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2054 | _Tp SparseMat::value(int i0, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2055 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2056 | const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2057 | return p ? *p : _Tp(); |
RyoheiHagimoto | 0:0e0631af0305 | 2058 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2059 | |
RyoheiHagimoto | 0:0e0631af0305 | 2060 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2061 | _Tp SparseMat::value(int i0, int i1, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2062 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2063 | const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2064 | return p ? *p : _Tp(); |
RyoheiHagimoto | 0:0e0631af0305 | 2065 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2066 | |
RyoheiHagimoto | 0:0e0631af0305 | 2067 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2068 | _Tp SparseMat::value(int i0, int i1, int i2, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2069 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2070 | const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2071 | return p ? *p : _Tp(); |
RyoheiHagimoto | 0:0e0631af0305 | 2072 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2073 | |
RyoheiHagimoto | 0:0e0631af0305 | 2074 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2075 | _Tp SparseMat::value(const int* idx, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2076 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2077 | const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2078 | return p ? *p : _Tp(); |
RyoheiHagimoto | 0:0e0631af0305 | 2079 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2080 | |
RyoheiHagimoto | 0:0e0631af0305 | 2081 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2082 | const _Tp* SparseMat::find(int i0, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2083 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2084 | return (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2085 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2086 | |
RyoheiHagimoto | 0:0e0631af0305 | 2087 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2088 | const _Tp* SparseMat::find(int i0, int i1, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2089 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2090 | return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2091 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2092 | |
RyoheiHagimoto | 0:0e0631af0305 | 2093 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2094 | const _Tp* SparseMat::find(int i0, int i1, int i2, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2095 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2096 | return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2097 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2098 | |
RyoheiHagimoto | 0:0e0631af0305 | 2099 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2100 | const _Tp* SparseMat::find(const int* idx, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2101 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2102 | return (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2103 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2104 | |
RyoheiHagimoto | 0:0e0631af0305 | 2105 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2106 | _Tp& SparseMat::value(Node* n) |
RyoheiHagimoto | 0:0e0631af0305 | 2107 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2108 | return *(_Tp*)((uchar*)n + hdr->valueOffset); |
RyoheiHagimoto | 0:0e0631af0305 | 2109 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2110 | |
RyoheiHagimoto | 0:0e0631af0305 | 2111 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2112 | const _Tp& SparseMat::value(const Node* n) const |
RyoheiHagimoto | 0:0e0631af0305 | 2113 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2114 | return *(const _Tp*)((const uchar*)n + hdr->valueOffset); |
RyoheiHagimoto | 0:0e0631af0305 | 2115 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2116 | |
RyoheiHagimoto | 0:0e0631af0305 | 2117 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2118 | SparseMat::Node* SparseMat::node(size_t nidx) |
RyoheiHagimoto | 0:0e0631af0305 | 2119 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2120 | return (Node*)(void*)&hdr->pool[nidx]; |
RyoheiHagimoto | 0:0e0631af0305 | 2121 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2122 | |
RyoheiHagimoto | 0:0e0631af0305 | 2123 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2124 | const SparseMat::Node* SparseMat::node(size_t nidx) const |
RyoheiHagimoto | 0:0e0631af0305 | 2125 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2126 | return (const Node*)(const void*)&hdr->pool[nidx]; |
RyoheiHagimoto | 0:0e0631af0305 | 2127 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2128 | |
RyoheiHagimoto | 0:0e0631af0305 | 2129 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2130 | SparseMatIterator SparseMat::begin() |
RyoheiHagimoto | 0:0e0631af0305 | 2131 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2132 | return SparseMatIterator(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2133 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2134 | |
RyoheiHagimoto | 0:0e0631af0305 | 2135 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2136 | SparseMatConstIterator SparseMat::begin() const |
RyoheiHagimoto | 0:0e0631af0305 | 2137 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2138 | return SparseMatConstIterator(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2139 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2140 | |
RyoheiHagimoto | 0:0e0631af0305 | 2141 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2142 | SparseMatIterator SparseMat::end() |
RyoheiHagimoto | 0:0e0631af0305 | 2143 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2144 | SparseMatIterator it(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2145 | it.seekEnd(); |
RyoheiHagimoto | 0:0e0631af0305 | 2146 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2147 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2148 | |
RyoheiHagimoto | 0:0e0631af0305 | 2149 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2150 | SparseMatConstIterator SparseMat::end() const |
RyoheiHagimoto | 0:0e0631af0305 | 2151 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2152 | SparseMatConstIterator it(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2153 | it.seekEnd(); |
RyoheiHagimoto | 0:0e0631af0305 | 2154 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2155 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2156 | |
RyoheiHagimoto | 0:0e0631af0305 | 2157 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2158 | SparseMatIterator_<_Tp> SparseMat::begin() |
RyoheiHagimoto | 0:0e0631af0305 | 2159 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2160 | return SparseMatIterator_<_Tp>(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2161 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2162 | |
RyoheiHagimoto | 0:0e0631af0305 | 2163 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2164 | SparseMatConstIterator_<_Tp> SparseMat::begin() const |
RyoheiHagimoto | 0:0e0631af0305 | 2165 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2166 | return SparseMatConstIterator_<_Tp>(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2167 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2168 | |
RyoheiHagimoto | 0:0e0631af0305 | 2169 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2170 | SparseMatIterator_<_Tp> SparseMat::end() |
RyoheiHagimoto | 0:0e0631af0305 | 2171 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2172 | SparseMatIterator_<_Tp> it(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2173 | it.seekEnd(); |
RyoheiHagimoto | 0:0e0631af0305 | 2174 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2175 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2176 | |
RyoheiHagimoto | 0:0e0631af0305 | 2177 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2178 | SparseMatConstIterator_<_Tp> SparseMat::end() const |
RyoheiHagimoto | 0:0e0631af0305 | 2179 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2180 | SparseMatConstIterator_<_Tp> it(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2181 | it.seekEnd(); |
RyoheiHagimoto | 0:0e0631af0305 | 2182 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2183 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2184 | |
RyoheiHagimoto | 0:0e0631af0305 | 2185 | |
RyoheiHagimoto | 0:0e0631af0305 | 2186 | |
RyoheiHagimoto | 0:0e0631af0305 | 2187 | ///////////////////////////// SparseMat_ //////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2188 | |
RyoheiHagimoto | 0:0e0631af0305 | 2189 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2190 | SparseMat_<_Tp>::SparseMat_() |
RyoheiHagimoto | 0:0e0631af0305 | 2191 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2192 | flags = MAGIC_VAL | DataType<_Tp>::type; |
RyoheiHagimoto | 0:0e0631af0305 | 2193 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2194 | |
RyoheiHagimoto | 0:0e0631af0305 | 2195 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2196 | SparseMat_<_Tp>::SparseMat_(int _dims, const int* _sizes) |
RyoheiHagimoto | 0:0e0631af0305 | 2197 | : SparseMat(_dims, _sizes, DataType<_Tp>::type) |
RyoheiHagimoto | 0:0e0631af0305 | 2198 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2199 | |
RyoheiHagimoto | 0:0e0631af0305 | 2200 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2201 | SparseMat_<_Tp>::SparseMat_(const SparseMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 2202 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2203 | if( m.type() == DataType<_Tp>::type ) |
RyoheiHagimoto | 0:0e0631af0305 | 2204 | *this = (const SparseMat_<_Tp>&)m; |
RyoheiHagimoto | 0:0e0631af0305 | 2205 | else |
RyoheiHagimoto | 0:0e0631af0305 | 2206 | m.convertTo(*this, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 2207 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2208 | |
RyoheiHagimoto | 0:0e0631af0305 | 2209 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2210 | SparseMat_<_Tp>::SparseMat_(const SparseMat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 2211 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2212 | this->flags = m.flags; |
RyoheiHagimoto | 0:0e0631af0305 | 2213 | this->hdr = m.hdr; |
RyoheiHagimoto | 0:0e0631af0305 | 2214 | if( this->hdr ) |
RyoheiHagimoto | 0:0e0631af0305 | 2215 | CV_XADD(&this->hdr->refcount, 1); |
RyoheiHagimoto | 0:0e0631af0305 | 2216 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2217 | |
RyoheiHagimoto | 0:0e0631af0305 | 2218 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2219 | SparseMat_<_Tp>::SparseMat_(const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 2220 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2221 | SparseMat sm(m); |
RyoheiHagimoto | 0:0e0631af0305 | 2222 | *this = sm; |
RyoheiHagimoto | 0:0e0631af0305 | 2223 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2224 | |
RyoheiHagimoto | 0:0e0631af0305 | 2225 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2226 | SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const SparseMat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 2227 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2228 | if( this != &m ) |
RyoheiHagimoto | 0:0e0631af0305 | 2229 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2230 | if( m.hdr ) CV_XADD(&m.hdr->refcount, 1); |
RyoheiHagimoto | 0:0e0631af0305 | 2231 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 2232 | flags = m.flags; |
RyoheiHagimoto | 0:0e0631af0305 | 2233 | hdr = m.hdr; |
RyoheiHagimoto | 0:0e0631af0305 | 2234 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2235 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2236 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2237 | |
RyoheiHagimoto | 0:0e0631af0305 | 2238 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2239 | SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const SparseMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 2240 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2241 | if( m.type() == DataType<_Tp>::type ) |
RyoheiHagimoto | 0:0e0631af0305 | 2242 | return (*this = (const SparseMat_<_Tp>&)m); |
RyoheiHagimoto | 0:0e0631af0305 | 2243 | m.convertTo(*this, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 2244 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2245 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2246 | |
RyoheiHagimoto | 0:0e0631af0305 | 2247 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2248 | SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (const Mat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 2249 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2250 | return (*this = SparseMat(m)); |
RyoheiHagimoto | 0:0e0631af0305 | 2251 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2252 | |
RyoheiHagimoto | 0:0e0631af0305 | 2253 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2254 | SparseMat_<_Tp> SparseMat_<_Tp>::clone() const |
RyoheiHagimoto | 0:0e0631af0305 | 2255 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2256 | SparseMat_<_Tp> m; |
RyoheiHagimoto | 0:0e0631af0305 | 2257 | this->copyTo(m); |
RyoheiHagimoto | 0:0e0631af0305 | 2258 | return m; |
RyoheiHagimoto | 0:0e0631af0305 | 2259 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2260 | |
RyoheiHagimoto | 0:0e0631af0305 | 2261 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2262 | void SparseMat_<_Tp>::create(int _dims, const int* _sizes) |
RyoheiHagimoto | 0:0e0631af0305 | 2263 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2264 | SparseMat::create(_dims, _sizes, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 2265 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2266 | |
RyoheiHagimoto | 0:0e0631af0305 | 2267 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2268 | int SparseMat_<_Tp>::type() const |
RyoheiHagimoto | 0:0e0631af0305 | 2269 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2270 | return DataType<_Tp>::type; |
RyoheiHagimoto | 0:0e0631af0305 | 2271 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2272 | |
RyoheiHagimoto | 0:0e0631af0305 | 2273 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2274 | int SparseMat_<_Tp>::depth() const |
RyoheiHagimoto | 0:0e0631af0305 | 2275 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2276 | return DataType<_Tp>::depth; |
RyoheiHagimoto | 0:0e0631af0305 | 2277 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2278 | |
RyoheiHagimoto | 0:0e0631af0305 | 2279 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2280 | int SparseMat_<_Tp>::channels() const |
RyoheiHagimoto | 0:0e0631af0305 | 2281 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2282 | return DataType<_Tp>::channels; |
RyoheiHagimoto | 0:0e0631af0305 | 2283 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2284 | |
RyoheiHagimoto | 0:0e0631af0305 | 2285 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2286 | _Tp& SparseMat_<_Tp>::ref(int i0, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2287 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2288 | return SparseMat::ref<_Tp>(i0, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2289 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2290 | |
RyoheiHagimoto | 0:0e0631af0305 | 2291 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2292 | _Tp SparseMat_<_Tp>::operator()(int i0, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2293 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2294 | return SparseMat::value<_Tp>(i0, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2295 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2296 | |
RyoheiHagimoto | 0:0e0631af0305 | 2297 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2298 | _Tp& SparseMat_<_Tp>::ref(int i0, int i1, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2299 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2300 | return SparseMat::ref<_Tp>(i0, i1, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2301 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2302 | |
RyoheiHagimoto | 0:0e0631af0305 | 2303 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2304 | _Tp SparseMat_<_Tp>::operator()(int i0, int i1, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2305 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2306 | return SparseMat::value<_Tp>(i0, i1, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2307 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2308 | |
RyoheiHagimoto | 0:0e0631af0305 | 2309 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2310 | _Tp& SparseMat_<_Tp>::ref(int i0, int i1, int i2, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2311 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2312 | return SparseMat::ref<_Tp>(i0, i1, i2, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2313 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2314 | |
RyoheiHagimoto | 0:0e0631af0305 | 2315 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2316 | _Tp SparseMat_<_Tp>::operator()(int i0, int i1, int i2, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2317 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2318 | return SparseMat::value<_Tp>(i0, i1, i2, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2319 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2320 | |
RyoheiHagimoto | 0:0e0631af0305 | 2321 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2322 | _Tp& SparseMat_<_Tp>::ref(const int* idx, size_t* hashval) |
RyoheiHagimoto | 0:0e0631af0305 | 2323 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2324 | return SparseMat::ref<_Tp>(idx, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2325 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2326 | |
RyoheiHagimoto | 0:0e0631af0305 | 2327 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2328 | _Tp SparseMat_<_Tp>::operator()(const int* idx, size_t* hashval) const |
RyoheiHagimoto | 0:0e0631af0305 | 2329 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2330 | return SparseMat::value<_Tp>(idx, hashval); |
RyoheiHagimoto | 0:0e0631af0305 | 2331 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2332 | |
RyoheiHagimoto | 0:0e0631af0305 | 2333 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2334 | SparseMatIterator_<_Tp> SparseMat_<_Tp>::begin() |
RyoheiHagimoto | 0:0e0631af0305 | 2335 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2336 | return SparseMatIterator_<_Tp>(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2337 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2338 | |
RyoheiHagimoto | 0:0e0631af0305 | 2339 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2340 | SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::begin() const |
RyoheiHagimoto | 0:0e0631af0305 | 2341 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2342 | return SparseMatConstIterator_<_Tp>(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2343 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2344 | |
RyoheiHagimoto | 0:0e0631af0305 | 2345 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2346 | SparseMatIterator_<_Tp> SparseMat_<_Tp>::end() |
RyoheiHagimoto | 0:0e0631af0305 | 2347 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2348 | SparseMatIterator_<_Tp> it(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2349 | it.seekEnd(); |
RyoheiHagimoto | 0:0e0631af0305 | 2350 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2351 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2352 | |
RyoheiHagimoto | 0:0e0631af0305 | 2353 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2354 | SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::end() const |
RyoheiHagimoto | 0:0e0631af0305 | 2355 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2356 | SparseMatConstIterator_<_Tp> it(this); |
RyoheiHagimoto | 0:0e0631af0305 | 2357 | it.seekEnd(); |
RyoheiHagimoto | 0:0e0631af0305 | 2358 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2359 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2360 | |
RyoheiHagimoto | 0:0e0631af0305 | 2361 | |
RyoheiHagimoto | 0:0e0631af0305 | 2362 | |
RyoheiHagimoto | 0:0e0631af0305 | 2363 | ////////////////////////// MatConstIterator ///////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2364 | |
RyoheiHagimoto | 0:0e0631af0305 | 2365 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2366 | MatConstIterator::MatConstIterator() |
RyoheiHagimoto | 0:0e0631af0305 | 2367 | : m(0), elemSize(0), ptr(0), sliceStart(0), sliceEnd(0) |
RyoheiHagimoto | 0:0e0631af0305 | 2368 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2369 | |
RyoheiHagimoto | 0:0e0631af0305 | 2370 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2371 | MatConstIterator::MatConstIterator(const Mat* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 2372 | : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) |
RyoheiHagimoto | 0:0e0631af0305 | 2373 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2374 | if( m && m->isContinuous() ) |
RyoheiHagimoto | 0:0e0631af0305 | 2375 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2376 | sliceStart = m->ptr(); |
RyoheiHagimoto | 0:0e0631af0305 | 2377 | sliceEnd = sliceStart + m->total()*elemSize; |
RyoheiHagimoto | 0:0e0631af0305 | 2378 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2379 | seek((const int*)0); |
RyoheiHagimoto | 0:0e0631af0305 | 2380 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2381 | |
RyoheiHagimoto | 0:0e0631af0305 | 2382 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2383 | MatConstIterator::MatConstIterator(const Mat* _m, int _row, int _col) |
RyoheiHagimoto | 0:0e0631af0305 | 2384 | : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) |
RyoheiHagimoto | 0:0e0631af0305 | 2385 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2386 | CV_Assert(m && m->dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 2387 | if( m->isContinuous() ) |
RyoheiHagimoto | 0:0e0631af0305 | 2388 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2389 | sliceStart = m->ptr(); |
RyoheiHagimoto | 0:0e0631af0305 | 2390 | sliceEnd = sliceStart + m->total()*elemSize; |
RyoheiHagimoto | 0:0e0631af0305 | 2391 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2392 | int idx[] = {_row, _col}; |
RyoheiHagimoto | 0:0e0631af0305 | 2393 | seek(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 2394 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2395 | |
RyoheiHagimoto | 0:0e0631af0305 | 2396 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2397 | MatConstIterator::MatConstIterator(const Mat* _m, Point _pt) |
RyoheiHagimoto | 0:0e0631af0305 | 2398 | : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) |
RyoheiHagimoto | 0:0e0631af0305 | 2399 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2400 | CV_Assert(m && m->dims <= 2); |
RyoheiHagimoto | 0:0e0631af0305 | 2401 | if( m->isContinuous() ) |
RyoheiHagimoto | 0:0e0631af0305 | 2402 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2403 | sliceStart = m->ptr(); |
RyoheiHagimoto | 0:0e0631af0305 | 2404 | sliceEnd = sliceStart + m->total()*elemSize; |
RyoheiHagimoto | 0:0e0631af0305 | 2405 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2406 | int idx[] = {_pt.y, _pt.x}; |
RyoheiHagimoto | 0:0e0631af0305 | 2407 | seek(idx); |
RyoheiHagimoto | 0:0e0631af0305 | 2408 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2409 | |
RyoheiHagimoto | 0:0e0631af0305 | 2410 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2411 | MatConstIterator::MatConstIterator(const MatConstIterator& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2412 | : m(it.m), elemSize(it.elemSize), ptr(it.ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd) |
RyoheiHagimoto | 0:0e0631af0305 | 2413 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2414 | |
RyoheiHagimoto | 0:0e0631af0305 | 2415 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2416 | MatConstIterator& MatConstIterator::operator = (const MatConstIterator& it ) |
RyoheiHagimoto | 0:0e0631af0305 | 2417 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2418 | m = it.m; elemSize = it.elemSize; ptr = it.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2419 | sliceStart = it.sliceStart; sliceEnd = it.sliceEnd; |
RyoheiHagimoto | 0:0e0631af0305 | 2420 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2421 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2422 | |
RyoheiHagimoto | 0:0e0631af0305 | 2423 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2424 | const uchar* MatConstIterator::operator *() const |
RyoheiHagimoto | 0:0e0631af0305 | 2425 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2426 | return ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2427 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2428 | |
RyoheiHagimoto | 0:0e0631af0305 | 2429 | inline MatConstIterator& MatConstIterator::operator += (ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2430 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2431 | if( !m || ofs == 0 ) |
RyoheiHagimoto | 0:0e0631af0305 | 2432 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2433 | ptrdiff_t ofsb = ofs*elemSize; |
RyoheiHagimoto | 0:0e0631af0305 | 2434 | ptr += ofsb; |
RyoheiHagimoto | 0:0e0631af0305 | 2435 | if( ptr < sliceStart || sliceEnd <= ptr ) |
RyoheiHagimoto | 0:0e0631af0305 | 2436 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2437 | ptr -= ofsb; |
RyoheiHagimoto | 0:0e0631af0305 | 2438 | seek(ofs, true); |
RyoheiHagimoto | 0:0e0631af0305 | 2439 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2440 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2441 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2442 | |
RyoheiHagimoto | 0:0e0631af0305 | 2443 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2444 | MatConstIterator& MatConstIterator::operator -= (ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2445 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2446 | return (*this += -ofs); |
RyoheiHagimoto | 0:0e0631af0305 | 2447 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2448 | |
RyoheiHagimoto | 0:0e0631af0305 | 2449 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2450 | MatConstIterator& MatConstIterator::operator --() |
RyoheiHagimoto | 0:0e0631af0305 | 2451 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2452 | if( m && (ptr -= elemSize) < sliceStart ) |
RyoheiHagimoto | 0:0e0631af0305 | 2453 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2454 | ptr += elemSize; |
RyoheiHagimoto | 0:0e0631af0305 | 2455 | seek(-1, true); |
RyoheiHagimoto | 0:0e0631af0305 | 2456 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2457 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2458 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2459 | |
RyoheiHagimoto | 0:0e0631af0305 | 2460 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2461 | MatConstIterator MatConstIterator::operator --(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2462 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2463 | MatConstIterator b = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2464 | *this += -1; |
RyoheiHagimoto | 0:0e0631af0305 | 2465 | return b; |
RyoheiHagimoto | 0:0e0631af0305 | 2466 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2467 | |
RyoheiHagimoto | 0:0e0631af0305 | 2468 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2469 | MatConstIterator& MatConstIterator::operator ++() |
RyoheiHagimoto | 0:0e0631af0305 | 2470 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2471 | if( m && (ptr += elemSize) >= sliceEnd ) |
RyoheiHagimoto | 0:0e0631af0305 | 2472 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2473 | ptr -= elemSize; |
RyoheiHagimoto | 0:0e0631af0305 | 2474 | seek(1, true); |
RyoheiHagimoto | 0:0e0631af0305 | 2475 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2476 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2477 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2478 | |
RyoheiHagimoto | 0:0e0631af0305 | 2479 | inline MatConstIterator MatConstIterator::operator ++(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2480 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2481 | MatConstIterator b = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2482 | *this += 1; |
RyoheiHagimoto | 0:0e0631af0305 | 2483 | return b; |
RyoheiHagimoto | 0:0e0631af0305 | 2484 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2485 | |
RyoheiHagimoto | 0:0e0631af0305 | 2486 | |
RyoheiHagimoto | 0:0e0631af0305 | 2487 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2488 | bool operator == (const MatConstIterator& a, const MatConstIterator& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2489 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2490 | return a.m == b.m && a.ptr == b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2491 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2492 | |
RyoheiHagimoto | 0:0e0631af0305 | 2493 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2494 | bool operator != (const MatConstIterator& a, const MatConstIterator& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2495 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2496 | return !(a == b); |
RyoheiHagimoto | 0:0e0631af0305 | 2497 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2498 | |
RyoheiHagimoto | 0:0e0631af0305 | 2499 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2500 | bool operator < (const MatConstIterator& a, const MatConstIterator& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2501 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2502 | return a.ptr < b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2503 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2504 | |
RyoheiHagimoto | 0:0e0631af0305 | 2505 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2506 | bool operator > (const MatConstIterator& a, const MatConstIterator& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2507 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2508 | return a.ptr > b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2509 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2510 | |
RyoheiHagimoto | 0:0e0631af0305 | 2511 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2512 | bool operator <= (const MatConstIterator& a, const MatConstIterator& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2513 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2514 | return a.ptr <= b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2515 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2516 | |
RyoheiHagimoto | 0:0e0631af0305 | 2517 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2518 | bool operator >= (const MatConstIterator& a, const MatConstIterator& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2519 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2520 | return a.ptr >= b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2521 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2522 | |
RyoheiHagimoto | 0:0e0631af0305 | 2523 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2524 | ptrdiff_t operator - (const MatConstIterator& b, const MatConstIterator& a) |
RyoheiHagimoto | 0:0e0631af0305 | 2525 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2526 | if( a.m != b.m ) |
RyoheiHagimoto | 0:0e0631af0305 | 2527 | return ((size_t)(-1) >> 1); |
RyoheiHagimoto | 0:0e0631af0305 | 2528 | if( a.sliceEnd == b.sliceEnd ) |
RyoheiHagimoto | 0:0e0631af0305 | 2529 | return (b.ptr - a.ptr)/static_cast<ptrdiff_t>(b.elemSize); |
RyoheiHagimoto | 0:0e0631af0305 | 2530 | |
RyoheiHagimoto | 0:0e0631af0305 | 2531 | return b.lpos() - a.lpos(); |
RyoheiHagimoto | 0:0e0631af0305 | 2532 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2533 | |
RyoheiHagimoto | 0:0e0631af0305 | 2534 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2535 | MatConstIterator operator + (const MatConstIterator& a, ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2536 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2537 | MatConstIterator b = a; |
RyoheiHagimoto | 0:0e0631af0305 | 2538 | return b += ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2539 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2540 | |
RyoheiHagimoto | 0:0e0631af0305 | 2541 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2542 | MatConstIterator operator + (ptrdiff_t ofs, const MatConstIterator& a) |
RyoheiHagimoto | 0:0e0631af0305 | 2543 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2544 | MatConstIterator b = a; |
RyoheiHagimoto | 0:0e0631af0305 | 2545 | return b += ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2546 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2547 | |
RyoheiHagimoto | 0:0e0631af0305 | 2548 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2549 | MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2550 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2551 | MatConstIterator b = a; |
RyoheiHagimoto | 0:0e0631af0305 | 2552 | return b += -ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2553 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2554 | |
RyoheiHagimoto | 0:0e0631af0305 | 2555 | |
RyoheiHagimoto | 0:0e0631af0305 | 2556 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2557 | const uchar* MatConstIterator::operator [](ptrdiff_t i) const |
RyoheiHagimoto | 0:0e0631af0305 | 2558 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2559 | return *(*this + i); |
RyoheiHagimoto | 0:0e0631af0305 | 2560 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2561 | |
RyoheiHagimoto | 0:0e0631af0305 | 2562 | |
RyoheiHagimoto | 0:0e0631af0305 | 2563 | |
RyoheiHagimoto | 0:0e0631af0305 | 2564 | ///////////////////////// MatConstIterator_ ///////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2565 | |
RyoheiHagimoto | 0:0e0631af0305 | 2566 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2567 | MatConstIterator_<_Tp>::MatConstIterator_() |
RyoheiHagimoto | 0:0e0631af0305 | 2568 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2569 | |
RyoheiHagimoto | 0:0e0631af0305 | 2570 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2571 | MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 2572 | : MatConstIterator(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 2573 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2574 | |
RyoheiHagimoto | 0:0e0631af0305 | 2575 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2576 | MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col) |
RyoheiHagimoto | 0:0e0631af0305 | 2577 | : MatConstIterator(_m, _row, _col) |
RyoheiHagimoto | 0:0e0631af0305 | 2578 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2579 | |
RyoheiHagimoto | 0:0e0631af0305 | 2580 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2581 | MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m, Point _pt) |
RyoheiHagimoto | 0:0e0631af0305 | 2582 | : MatConstIterator(_m, _pt) |
RyoheiHagimoto | 0:0e0631af0305 | 2583 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2584 | |
RyoheiHagimoto | 0:0e0631af0305 | 2585 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2586 | MatConstIterator_<_Tp>::MatConstIterator_(const MatConstIterator_& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2587 | : MatConstIterator(it) |
RyoheiHagimoto | 0:0e0631af0305 | 2588 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2589 | |
RyoheiHagimoto | 0:0e0631af0305 | 2590 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2591 | MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator = (const MatConstIterator_& it ) |
RyoheiHagimoto | 0:0e0631af0305 | 2592 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2593 | MatConstIterator::operator = (it); |
RyoheiHagimoto | 0:0e0631af0305 | 2594 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2595 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2596 | |
RyoheiHagimoto | 0:0e0631af0305 | 2597 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2598 | const _Tp& MatConstIterator_<_Tp>::operator *() const |
RyoheiHagimoto | 0:0e0631af0305 | 2599 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2600 | return *(_Tp*)(this->ptr); |
RyoheiHagimoto | 0:0e0631af0305 | 2601 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2602 | |
RyoheiHagimoto | 0:0e0631af0305 | 2603 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2604 | MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator += (ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2605 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2606 | MatConstIterator::operator += (ofs); |
RyoheiHagimoto | 0:0e0631af0305 | 2607 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2608 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2609 | |
RyoheiHagimoto | 0:0e0631af0305 | 2610 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2611 | MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator -= (ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2612 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2613 | return (*this += -ofs); |
RyoheiHagimoto | 0:0e0631af0305 | 2614 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2615 | |
RyoheiHagimoto | 0:0e0631af0305 | 2616 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2617 | MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator --() |
RyoheiHagimoto | 0:0e0631af0305 | 2618 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2619 | MatConstIterator::operator --(); |
RyoheiHagimoto | 0:0e0631af0305 | 2620 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2621 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2622 | |
RyoheiHagimoto | 0:0e0631af0305 | 2623 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2624 | MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator --(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2625 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2626 | MatConstIterator_ b = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2627 | MatConstIterator::operator --(); |
RyoheiHagimoto | 0:0e0631af0305 | 2628 | return b; |
RyoheiHagimoto | 0:0e0631af0305 | 2629 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2630 | |
RyoheiHagimoto | 0:0e0631af0305 | 2631 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2632 | MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator ++() |
RyoheiHagimoto | 0:0e0631af0305 | 2633 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2634 | MatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 2635 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2636 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2637 | |
RyoheiHagimoto | 0:0e0631af0305 | 2638 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2639 | MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator ++(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2640 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2641 | MatConstIterator_ b = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2642 | MatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 2643 | return b; |
RyoheiHagimoto | 0:0e0631af0305 | 2644 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2645 | |
RyoheiHagimoto | 0:0e0631af0305 | 2646 | |
RyoheiHagimoto | 0:0e0631af0305 | 2647 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2648 | Point MatConstIterator_<_Tp>::pos() const |
RyoheiHagimoto | 0:0e0631af0305 | 2649 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2650 | if( !m ) |
RyoheiHagimoto | 0:0e0631af0305 | 2651 | return Point(); |
RyoheiHagimoto | 0:0e0631af0305 | 2652 | CV_DbgAssert( m->dims <= 2 ); |
RyoheiHagimoto | 0:0e0631af0305 | 2653 | if( m->isContinuous() ) |
RyoheiHagimoto | 0:0e0631af0305 | 2654 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2655 | ptrdiff_t ofs = (const _Tp*)ptr - (const _Tp*)m->data; |
RyoheiHagimoto | 0:0e0631af0305 | 2656 | int y = (int)(ofs / m->cols); |
RyoheiHagimoto | 0:0e0631af0305 | 2657 | int x = (int)(ofs - (ptrdiff_t)y * m->cols); |
RyoheiHagimoto | 0:0e0631af0305 | 2658 | return Point(x, y); |
RyoheiHagimoto | 0:0e0631af0305 | 2659 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2660 | else |
RyoheiHagimoto | 0:0e0631af0305 | 2661 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2662 | ptrdiff_t ofs = (uchar*)ptr - m->data; |
RyoheiHagimoto | 0:0e0631af0305 | 2663 | int y = (int)(ofs / m->step); |
RyoheiHagimoto | 0:0e0631af0305 | 2664 | int x = (int)((ofs - y * m->step)/sizeof(_Tp)); |
RyoheiHagimoto | 0:0e0631af0305 | 2665 | return Point(x, y); |
RyoheiHagimoto | 0:0e0631af0305 | 2666 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2667 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2668 | |
RyoheiHagimoto | 0:0e0631af0305 | 2669 | |
RyoheiHagimoto | 0:0e0631af0305 | 2670 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2671 | bool operator == (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2672 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2673 | return a.m == b.m && a.ptr == b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2674 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2675 | |
RyoheiHagimoto | 0:0e0631af0305 | 2676 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2677 | bool operator != (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2678 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2679 | return a.m != b.m || a.ptr != b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2680 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2681 | |
RyoheiHagimoto | 0:0e0631af0305 | 2682 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2683 | MatConstIterator_<_Tp> operator + (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2684 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2685 | MatConstIterator t = (const MatConstIterator&)a + ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2686 | return (MatConstIterator_<_Tp>&)t; |
RyoheiHagimoto | 0:0e0631af0305 | 2687 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2688 | |
RyoheiHagimoto | 0:0e0631af0305 | 2689 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2690 | MatConstIterator_<_Tp> operator + (ptrdiff_t ofs, const MatConstIterator_<_Tp>& a) |
RyoheiHagimoto | 0:0e0631af0305 | 2691 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2692 | MatConstIterator t = (const MatConstIterator&)a + ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2693 | return (MatConstIterator_<_Tp>&)t; |
RyoheiHagimoto | 0:0e0631af0305 | 2694 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2695 | |
RyoheiHagimoto | 0:0e0631af0305 | 2696 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2697 | MatConstIterator_<_Tp> operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2698 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2699 | MatConstIterator t = (const MatConstIterator&)a - ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2700 | return (MatConstIterator_<_Tp>&)t; |
RyoheiHagimoto | 0:0e0631af0305 | 2701 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2702 | |
RyoheiHagimoto | 0:0e0631af0305 | 2703 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2704 | const _Tp& MatConstIterator_<_Tp>::operator [](ptrdiff_t i) const |
RyoheiHagimoto | 0:0e0631af0305 | 2705 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2706 | return *(_Tp*)MatConstIterator::operator [](i); |
RyoheiHagimoto | 0:0e0631af0305 | 2707 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2708 | |
RyoheiHagimoto | 0:0e0631af0305 | 2709 | |
RyoheiHagimoto | 0:0e0631af0305 | 2710 | |
RyoheiHagimoto | 0:0e0631af0305 | 2711 | //////////////////////////// MatIterator_ /////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2712 | |
RyoheiHagimoto | 0:0e0631af0305 | 2713 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2714 | MatIterator_<_Tp>::MatIterator_() |
RyoheiHagimoto | 0:0e0631af0305 | 2715 | : MatConstIterator_<_Tp>() |
RyoheiHagimoto | 0:0e0631af0305 | 2716 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2717 | |
RyoheiHagimoto | 0:0e0631af0305 | 2718 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2719 | MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 2720 | : MatConstIterator_<_Tp>(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 2721 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2722 | |
RyoheiHagimoto | 0:0e0631af0305 | 2723 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2724 | MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, int _row, int _col) |
RyoheiHagimoto | 0:0e0631af0305 | 2725 | : MatConstIterator_<_Tp>(_m, _row, _col) |
RyoheiHagimoto | 0:0e0631af0305 | 2726 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2727 | |
RyoheiHagimoto | 0:0e0631af0305 | 2728 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2729 | MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, Point _pt) |
RyoheiHagimoto | 0:0e0631af0305 | 2730 | : MatConstIterator_<_Tp>(_m, _pt) |
RyoheiHagimoto | 0:0e0631af0305 | 2731 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2732 | |
RyoheiHagimoto | 0:0e0631af0305 | 2733 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2734 | MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, const int* _idx) |
RyoheiHagimoto | 0:0e0631af0305 | 2735 | : MatConstIterator_<_Tp>(_m, _idx) |
RyoheiHagimoto | 0:0e0631af0305 | 2736 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2737 | |
RyoheiHagimoto | 0:0e0631af0305 | 2738 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2739 | MatIterator_<_Tp>::MatIterator_(const MatIterator_& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2740 | : MatConstIterator_<_Tp>(it) |
RyoheiHagimoto | 0:0e0631af0305 | 2741 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2742 | |
RyoheiHagimoto | 0:0e0631af0305 | 2743 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2744 | MatIterator_<_Tp>& MatIterator_<_Tp>::operator = (const MatIterator_<_Tp>& it ) |
RyoheiHagimoto | 0:0e0631af0305 | 2745 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2746 | MatConstIterator::operator = (it); |
RyoheiHagimoto | 0:0e0631af0305 | 2747 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2748 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2749 | |
RyoheiHagimoto | 0:0e0631af0305 | 2750 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2751 | _Tp& MatIterator_<_Tp>::operator *() const |
RyoheiHagimoto | 0:0e0631af0305 | 2752 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2753 | return *(_Tp*)(this->ptr); |
RyoheiHagimoto | 0:0e0631af0305 | 2754 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2755 | |
RyoheiHagimoto | 0:0e0631af0305 | 2756 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2757 | MatIterator_<_Tp>& MatIterator_<_Tp>::operator += (ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2758 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2759 | MatConstIterator::operator += (ofs); |
RyoheiHagimoto | 0:0e0631af0305 | 2760 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2761 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2762 | |
RyoheiHagimoto | 0:0e0631af0305 | 2763 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2764 | MatIterator_<_Tp>& MatIterator_<_Tp>::operator -= (ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2765 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2766 | MatConstIterator::operator += (-ofs); |
RyoheiHagimoto | 0:0e0631af0305 | 2767 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2768 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2769 | |
RyoheiHagimoto | 0:0e0631af0305 | 2770 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2771 | MatIterator_<_Tp>& MatIterator_<_Tp>::operator --() |
RyoheiHagimoto | 0:0e0631af0305 | 2772 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2773 | MatConstIterator::operator --(); |
RyoheiHagimoto | 0:0e0631af0305 | 2774 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2775 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2776 | |
RyoheiHagimoto | 0:0e0631af0305 | 2777 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2778 | MatIterator_<_Tp> MatIterator_<_Tp>::operator --(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2779 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2780 | MatIterator_ b = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2781 | MatConstIterator::operator --(); |
RyoheiHagimoto | 0:0e0631af0305 | 2782 | return b; |
RyoheiHagimoto | 0:0e0631af0305 | 2783 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2784 | |
RyoheiHagimoto | 0:0e0631af0305 | 2785 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2786 | MatIterator_<_Tp>& MatIterator_<_Tp>::operator ++() |
RyoheiHagimoto | 0:0e0631af0305 | 2787 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2788 | MatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 2789 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2790 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2791 | |
RyoheiHagimoto | 0:0e0631af0305 | 2792 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2793 | MatIterator_<_Tp> MatIterator_<_Tp>::operator ++(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2794 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2795 | MatIterator_ b = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2796 | MatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 2797 | return b; |
RyoheiHagimoto | 0:0e0631af0305 | 2798 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2799 | |
RyoheiHagimoto | 0:0e0631af0305 | 2800 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2801 | _Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i) const |
RyoheiHagimoto | 0:0e0631af0305 | 2802 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2803 | return *(*this + i); |
RyoheiHagimoto | 0:0e0631af0305 | 2804 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2805 | |
RyoheiHagimoto | 0:0e0631af0305 | 2806 | |
RyoheiHagimoto | 0:0e0631af0305 | 2807 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2808 | bool operator == (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2809 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2810 | return a.m == b.m && a.ptr == b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2811 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2812 | |
RyoheiHagimoto | 0:0e0631af0305 | 2813 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2814 | bool operator != (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) |
RyoheiHagimoto | 0:0e0631af0305 | 2815 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2816 | return a.m != b.m || a.ptr != b.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2817 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2818 | |
RyoheiHagimoto | 0:0e0631af0305 | 2819 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2820 | MatIterator_<_Tp> operator + (const MatIterator_<_Tp>& a, ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2821 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2822 | MatConstIterator t = (const MatConstIterator&)a + ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2823 | return (MatIterator_<_Tp>&)t; |
RyoheiHagimoto | 0:0e0631af0305 | 2824 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2825 | |
RyoheiHagimoto | 0:0e0631af0305 | 2826 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2827 | MatIterator_<_Tp> operator + (ptrdiff_t ofs, const MatIterator_<_Tp>& a) |
RyoheiHagimoto | 0:0e0631af0305 | 2828 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2829 | MatConstIterator t = (const MatConstIterator&)a + ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2830 | return (MatIterator_<_Tp>&)t; |
RyoheiHagimoto | 0:0e0631af0305 | 2831 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2832 | |
RyoheiHagimoto | 0:0e0631af0305 | 2833 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2834 | MatIterator_<_Tp> operator - (const MatIterator_<_Tp>& a, ptrdiff_t ofs) |
RyoheiHagimoto | 0:0e0631af0305 | 2835 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2836 | MatConstIterator t = (const MatConstIterator&)a - ofs; |
RyoheiHagimoto | 0:0e0631af0305 | 2837 | return (MatIterator_<_Tp>&)t; |
RyoheiHagimoto | 0:0e0631af0305 | 2838 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2839 | |
RyoheiHagimoto | 0:0e0631af0305 | 2840 | |
RyoheiHagimoto | 0:0e0631af0305 | 2841 | |
RyoheiHagimoto | 0:0e0631af0305 | 2842 | /////////////////////// SparseMatConstIterator ////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2843 | |
RyoheiHagimoto | 0:0e0631af0305 | 2844 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2845 | SparseMatConstIterator::SparseMatConstIterator() |
RyoheiHagimoto | 0:0e0631af0305 | 2846 | : m(0), hashidx(0), ptr(0) |
RyoheiHagimoto | 0:0e0631af0305 | 2847 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2848 | |
RyoheiHagimoto | 0:0e0631af0305 | 2849 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2850 | SparseMatConstIterator::SparseMatConstIterator(const SparseMatConstIterator& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2851 | : m(it.m), hashidx(it.hashidx), ptr(it.ptr) |
RyoheiHagimoto | 0:0e0631af0305 | 2852 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2853 | |
RyoheiHagimoto | 0:0e0631af0305 | 2854 | inline SparseMatConstIterator& SparseMatConstIterator::operator = (const SparseMatConstIterator& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2855 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2856 | if( this != &it ) |
RyoheiHagimoto | 0:0e0631af0305 | 2857 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2858 | m = it.m; |
RyoheiHagimoto | 0:0e0631af0305 | 2859 | hashidx = it.hashidx; |
RyoheiHagimoto | 0:0e0631af0305 | 2860 | ptr = it.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2861 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2862 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2863 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2864 | |
RyoheiHagimoto | 0:0e0631af0305 | 2865 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2866 | const _Tp& SparseMatConstIterator::value() const |
RyoheiHagimoto | 0:0e0631af0305 | 2867 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2868 | return *(const _Tp*)ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2869 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2870 | |
RyoheiHagimoto | 0:0e0631af0305 | 2871 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2872 | const SparseMat::Node* SparseMatConstIterator::node() const |
RyoheiHagimoto | 0:0e0631af0305 | 2873 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2874 | return (ptr && m && m->hdr) ? (const SparseMat::Node*)(const void*)(ptr - m->hdr->valueOffset) : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 2875 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2876 | |
RyoheiHagimoto | 0:0e0631af0305 | 2877 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2878 | SparseMatConstIterator SparseMatConstIterator::operator ++(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2879 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2880 | SparseMatConstIterator it = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2881 | ++*this; |
RyoheiHagimoto | 0:0e0631af0305 | 2882 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2883 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2884 | |
RyoheiHagimoto | 0:0e0631af0305 | 2885 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2886 | void SparseMatConstIterator::seekEnd() |
RyoheiHagimoto | 0:0e0631af0305 | 2887 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2888 | if( m && m->hdr ) |
RyoheiHagimoto | 0:0e0631af0305 | 2889 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2890 | hashidx = m->hdr->hashtab.size(); |
RyoheiHagimoto | 0:0e0631af0305 | 2891 | ptr = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 2892 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2893 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2894 | |
RyoheiHagimoto | 0:0e0631af0305 | 2895 | |
RyoheiHagimoto | 0:0e0631af0305 | 2896 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2897 | bool operator == (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) |
RyoheiHagimoto | 0:0e0631af0305 | 2898 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2899 | return it1.m == it2.m && it1.ptr == it2.ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2900 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2901 | |
RyoheiHagimoto | 0:0e0631af0305 | 2902 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 2903 | bool operator != (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) |
RyoheiHagimoto | 0:0e0631af0305 | 2904 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2905 | return !(it1 == it2); |
RyoheiHagimoto | 0:0e0631af0305 | 2906 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2907 | |
RyoheiHagimoto | 0:0e0631af0305 | 2908 | |
RyoheiHagimoto | 0:0e0631af0305 | 2909 | |
RyoheiHagimoto | 0:0e0631af0305 | 2910 | ///////////////////////// SparseMatIterator ///////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2911 | |
RyoheiHagimoto | 0:0e0631af0305 | 2912 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2913 | SparseMatIterator::SparseMatIterator() |
RyoheiHagimoto | 0:0e0631af0305 | 2914 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2915 | |
RyoheiHagimoto | 0:0e0631af0305 | 2916 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2917 | SparseMatIterator::SparseMatIterator(SparseMat* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 2918 | : SparseMatConstIterator(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 2919 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2920 | |
RyoheiHagimoto | 0:0e0631af0305 | 2921 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2922 | SparseMatIterator::SparseMatIterator(const SparseMatIterator& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2923 | : SparseMatConstIterator(it) |
RyoheiHagimoto | 0:0e0631af0305 | 2924 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2925 | |
RyoheiHagimoto | 0:0e0631af0305 | 2926 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2927 | SparseMatIterator& SparseMatIterator::operator = (const SparseMatIterator& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2928 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2929 | (SparseMatConstIterator&)*this = it; |
RyoheiHagimoto | 0:0e0631af0305 | 2930 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2931 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2932 | |
RyoheiHagimoto | 0:0e0631af0305 | 2933 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2934 | _Tp& SparseMatIterator::value() const |
RyoheiHagimoto | 0:0e0631af0305 | 2935 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2936 | return *(_Tp*)ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2937 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2938 | |
RyoheiHagimoto | 0:0e0631af0305 | 2939 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2940 | SparseMat::Node* SparseMatIterator::node() const |
RyoheiHagimoto | 0:0e0631af0305 | 2941 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2942 | return (SparseMat::Node*)SparseMatConstIterator::node(); |
RyoheiHagimoto | 0:0e0631af0305 | 2943 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2944 | |
RyoheiHagimoto | 0:0e0631af0305 | 2945 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2946 | SparseMatIterator& SparseMatIterator::operator ++() |
RyoheiHagimoto | 0:0e0631af0305 | 2947 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2948 | SparseMatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 2949 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2950 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2951 | |
RyoheiHagimoto | 0:0e0631af0305 | 2952 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 2953 | SparseMatIterator SparseMatIterator::operator ++(int) |
RyoheiHagimoto | 0:0e0631af0305 | 2954 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2955 | SparseMatIterator it = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 2956 | ++*this; |
RyoheiHagimoto | 0:0e0631af0305 | 2957 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 2958 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2959 | |
RyoheiHagimoto | 0:0e0631af0305 | 2960 | |
RyoheiHagimoto | 0:0e0631af0305 | 2961 | |
RyoheiHagimoto | 0:0e0631af0305 | 2962 | ////////////////////// SparseMatConstIterator_ ////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2963 | |
RyoheiHagimoto | 0:0e0631af0305 | 2964 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2965 | SparseMatConstIterator_<_Tp>::SparseMatConstIterator_() |
RyoheiHagimoto | 0:0e0631af0305 | 2966 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2967 | |
RyoheiHagimoto | 0:0e0631af0305 | 2968 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2969 | SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat_<_Tp>* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 2970 | : SparseMatConstIterator(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 2971 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2972 | |
RyoheiHagimoto | 0:0e0631af0305 | 2973 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2974 | SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 2975 | : SparseMatConstIterator(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 2976 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2977 | CV_Assert( _m->type() == DataType<_Tp>::type ); |
RyoheiHagimoto | 0:0e0631af0305 | 2978 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2979 | |
RyoheiHagimoto | 0:0e0631af0305 | 2980 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2981 | SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMatConstIterator_<_Tp>& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2982 | : SparseMatConstIterator(it) |
RyoheiHagimoto | 0:0e0631af0305 | 2983 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 2984 | |
RyoheiHagimoto | 0:0e0631af0305 | 2985 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2986 | SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator = (const SparseMatConstIterator_<_Tp>& it) |
RyoheiHagimoto | 0:0e0631af0305 | 2987 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2988 | return reinterpret_cast<SparseMatConstIterator_<_Tp>&> |
RyoheiHagimoto | 0:0e0631af0305 | 2989 | (*reinterpret_cast<SparseMatConstIterator*>(this) = |
RyoheiHagimoto | 0:0e0631af0305 | 2990 | reinterpret_cast<const SparseMatConstIterator&>(it)); |
RyoheiHagimoto | 0:0e0631af0305 | 2991 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2992 | |
RyoheiHagimoto | 0:0e0631af0305 | 2993 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 2994 | const _Tp& SparseMatConstIterator_<_Tp>::operator *() const |
RyoheiHagimoto | 0:0e0631af0305 | 2995 | { |
RyoheiHagimoto | 0:0e0631af0305 | 2996 | return *(const _Tp*)this->ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 2997 | } |
RyoheiHagimoto | 0:0e0631af0305 | 2998 | |
RyoheiHagimoto | 0:0e0631af0305 | 2999 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3000 | SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator ++() |
RyoheiHagimoto | 0:0e0631af0305 | 3001 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3002 | SparseMatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 3003 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3004 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3005 | |
RyoheiHagimoto | 0:0e0631af0305 | 3006 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3007 | SparseMatConstIterator_<_Tp> SparseMatConstIterator_<_Tp>::operator ++(int) |
RyoheiHagimoto | 0:0e0631af0305 | 3008 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3009 | SparseMatConstIterator_<_Tp> it = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3010 | SparseMatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 3011 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 3012 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3013 | |
RyoheiHagimoto | 0:0e0631af0305 | 3014 | |
RyoheiHagimoto | 0:0e0631af0305 | 3015 | |
RyoheiHagimoto | 0:0e0631af0305 | 3016 | ///////////////////////// SparseMatIterator_ //////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 3017 | |
RyoheiHagimoto | 0:0e0631af0305 | 3018 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3019 | SparseMatIterator_<_Tp>::SparseMatIterator_() |
RyoheiHagimoto | 0:0e0631af0305 | 3020 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3021 | |
RyoheiHagimoto | 0:0e0631af0305 | 3022 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3023 | SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat_<_Tp>* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 3024 | : SparseMatConstIterator_<_Tp>(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 3025 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3026 | |
RyoheiHagimoto | 0:0e0631af0305 | 3027 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3028 | SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 3029 | : SparseMatConstIterator_<_Tp>(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 3030 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3031 | |
RyoheiHagimoto | 0:0e0631af0305 | 3032 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3033 | SparseMatIterator_<_Tp>::SparseMatIterator_(const SparseMatIterator_<_Tp>& it) |
RyoheiHagimoto | 0:0e0631af0305 | 3034 | : SparseMatConstIterator_<_Tp>(it) |
RyoheiHagimoto | 0:0e0631af0305 | 3035 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3036 | |
RyoheiHagimoto | 0:0e0631af0305 | 3037 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3038 | SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator = (const SparseMatIterator_<_Tp>& it) |
RyoheiHagimoto | 0:0e0631af0305 | 3039 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3040 | return reinterpret_cast<SparseMatIterator_<_Tp>&> |
RyoheiHagimoto | 0:0e0631af0305 | 3041 | (*reinterpret_cast<SparseMatConstIterator*>(this) = |
RyoheiHagimoto | 0:0e0631af0305 | 3042 | reinterpret_cast<const SparseMatConstIterator&>(it)); |
RyoheiHagimoto | 0:0e0631af0305 | 3043 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3044 | |
RyoheiHagimoto | 0:0e0631af0305 | 3045 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3046 | _Tp& SparseMatIterator_<_Tp>::operator *() const |
RyoheiHagimoto | 0:0e0631af0305 | 3047 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3048 | return *(_Tp*)this->ptr; |
RyoheiHagimoto | 0:0e0631af0305 | 3049 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3050 | |
RyoheiHagimoto | 0:0e0631af0305 | 3051 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3052 | SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator ++() |
RyoheiHagimoto | 0:0e0631af0305 | 3053 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3054 | SparseMatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 3055 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3056 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3057 | |
RyoheiHagimoto | 0:0e0631af0305 | 3058 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3059 | SparseMatIterator_<_Tp> SparseMatIterator_<_Tp>::operator ++(int) |
RyoheiHagimoto | 0:0e0631af0305 | 3060 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3061 | SparseMatIterator_<_Tp> it = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3062 | SparseMatConstIterator::operator ++(); |
RyoheiHagimoto | 0:0e0631af0305 | 3063 | return it; |
RyoheiHagimoto | 0:0e0631af0305 | 3064 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3065 | |
RyoheiHagimoto | 0:0e0631af0305 | 3066 | |
RyoheiHagimoto | 0:0e0631af0305 | 3067 | |
RyoheiHagimoto | 0:0e0631af0305 | 3068 | //////////////////////// MatCommaInitializer_ /////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 3069 | |
RyoheiHagimoto | 0:0e0631af0305 | 3070 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3071 | MatCommaInitializer_<_Tp>::MatCommaInitializer_(Mat_<_Tp>* _m) |
RyoheiHagimoto | 0:0e0631af0305 | 3072 | : it(_m) |
RyoheiHagimoto | 0:0e0631af0305 | 3073 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3074 | |
RyoheiHagimoto | 0:0e0631af0305 | 3075 | template<typename _Tp> template<typename T2> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3076 | MatCommaInitializer_<_Tp>& MatCommaInitializer_<_Tp>::operator , (T2 v) |
RyoheiHagimoto | 0:0e0631af0305 | 3077 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3078 | CV_DbgAssert( this->it < ((const Mat_<_Tp>*)this->it.m)->end() ); |
RyoheiHagimoto | 0:0e0631af0305 | 3079 | *this->it = _Tp(v); |
RyoheiHagimoto | 0:0e0631af0305 | 3080 | ++this->it; |
RyoheiHagimoto | 0:0e0631af0305 | 3081 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3082 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3083 | |
RyoheiHagimoto | 0:0e0631af0305 | 3084 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3085 | MatCommaInitializer_<_Tp>::operator Mat_<_Tp>() const |
RyoheiHagimoto | 0:0e0631af0305 | 3086 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3087 | CV_DbgAssert( this->it == ((const Mat_<_Tp>*)this->it.m)->end() ); |
RyoheiHagimoto | 0:0e0631af0305 | 3088 | return Mat_<_Tp>(*this->it.m); |
RyoheiHagimoto | 0:0e0631af0305 | 3089 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3090 | |
RyoheiHagimoto | 0:0e0631af0305 | 3091 | |
RyoheiHagimoto | 0:0e0631af0305 | 3092 | template<typename _Tp, typename T2> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3093 | MatCommaInitializer_<_Tp> operator << (const Mat_<_Tp>& m, T2 val) |
RyoheiHagimoto | 0:0e0631af0305 | 3094 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3095 | MatCommaInitializer_<_Tp> commaInitializer((Mat_<_Tp>*)&m); |
RyoheiHagimoto | 0:0e0631af0305 | 3096 | return (commaInitializer, val); |
RyoheiHagimoto | 0:0e0631af0305 | 3097 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3098 | |
RyoheiHagimoto | 0:0e0631af0305 | 3099 | |
RyoheiHagimoto | 0:0e0631af0305 | 3100 | |
RyoheiHagimoto | 0:0e0631af0305 | 3101 | ///////////////////////// Matrix Expressions //////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 3102 | |
RyoheiHagimoto | 0:0e0631af0305 | 3103 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3104 | Mat& Mat::operator = (const MatExpr& e) |
RyoheiHagimoto | 0:0e0631af0305 | 3105 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3106 | e.op->assign(e, *this); |
RyoheiHagimoto | 0:0e0631af0305 | 3107 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3108 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3109 | |
RyoheiHagimoto | 0:0e0631af0305 | 3110 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3111 | Mat_<_Tp>::Mat_(const MatExpr& e) |
RyoheiHagimoto | 0:0e0631af0305 | 3112 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3113 | e.op->assign(e, *this, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3114 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3115 | |
RyoheiHagimoto | 0:0e0631af0305 | 3116 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3117 | Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e) |
RyoheiHagimoto | 0:0e0631af0305 | 3118 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3119 | e.op->assign(e, *this, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3120 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3121 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3122 | |
RyoheiHagimoto | 0:0e0631af0305 | 3123 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3124 | MatExpr Mat_<_Tp>::zeros(int rows, int cols) |
RyoheiHagimoto | 0:0e0631af0305 | 3125 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3126 | return Mat::zeros(rows, cols, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3127 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3128 | |
RyoheiHagimoto | 0:0e0631af0305 | 3129 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3130 | MatExpr Mat_<_Tp>::zeros(Size sz) |
RyoheiHagimoto | 0:0e0631af0305 | 3131 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3132 | return Mat::zeros(sz, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3133 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3134 | |
RyoheiHagimoto | 0:0e0631af0305 | 3135 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3136 | MatExpr Mat_<_Tp>::ones(int rows, int cols) |
RyoheiHagimoto | 0:0e0631af0305 | 3137 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3138 | return Mat::ones(rows, cols, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3139 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3140 | |
RyoheiHagimoto | 0:0e0631af0305 | 3141 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3142 | MatExpr Mat_<_Tp>::ones(Size sz) |
RyoheiHagimoto | 0:0e0631af0305 | 3143 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3144 | return Mat::ones(sz, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3145 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3146 | |
RyoheiHagimoto | 0:0e0631af0305 | 3147 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3148 | MatExpr Mat_<_Tp>::eye(int rows, int cols) |
RyoheiHagimoto | 0:0e0631af0305 | 3149 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3150 | return Mat::eye(rows, cols, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3151 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3152 | |
RyoheiHagimoto | 0:0e0631af0305 | 3153 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3154 | MatExpr Mat_<_Tp>::eye(Size sz) |
RyoheiHagimoto | 0:0e0631af0305 | 3155 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3156 | return Mat::eye(sz, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3157 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3158 | |
RyoheiHagimoto | 0:0e0631af0305 | 3159 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3160 | MatExpr::MatExpr() |
RyoheiHagimoto | 0:0e0631af0305 | 3161 | : op(0), flags(0), a(Mat()), b(Mat()), c(Mat()), alpha(0), beta(0), s() |
RyoheiHagimoto | 0:0e0631af0305 | 3162 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3163 | |
RyoheiHagimoto | 0:0e0631af0305 | 3164 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3165 | MatExpr::MatExpr(const MatOp* _op, int _flags, const Mat& _a, const Mat& _b, |
RyoheiHagimoto | 0:0e0631af0305 | 3166 | const Mat& _c, double _alpha, double _beta, const Scalar& _s) |
RyoheiHagimoto | 0:0e0631af0305 | 3167 | : op(_op), flags(_flags), a(_a), b(_b), c(_c), alpha(_alpha), beta(_beta), s(_s) |
RyoheiHagimoto | 0:0e0631af0305 | 3168 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3169 | |
RyoheiHagimoto | 0:0e0631af0305 | 3170 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3171 | MatExpr::operator Mat() const |
RyoheiHagimoto | 0:0e0631af0305 | 3172 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3173 | Mat m; |
RyoheiHagimoto | 0:0e0631af0305 | 3174 | op->assign(*this, m); |
RyoheiHagimoto | 0:0e0631af0305 | 3175 | return m; |
RyoheiHagimoto | 0:0e0631af0305 | 3176 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3177 | |
RyoheiHagimoto | 0:0e0631af0305 | 3178 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3179 | MatExpr::operator Mat_<_Tp>() const |
RyoheiHagimoto | 0:0e0631af0305 | 3180 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3181 | Mat_<_Tp> m; |
RyoheiHagimoto | 0:0e0631af0305 | 3182 | op->assign(*this, m, DataType<_Tp>::type); |
RyoheiHagimoto | 0:0e0631af0305 | 3183 | return m; |
RyoheiHagimoto | 0:0e0631af0305 | 3184 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3185 | |
RyoheiHagimoto | 0:0e0631af0305 | 3186 | |
RyoheiHagimoto | 0:0e0631af0305 | 3187 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3188 | MatExpr min(const Mat_<_Tp>& a, const Mat_<_Tp>& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3189 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3190 | return cv::min((const Mat&)a, (const Mat&)b); |
RyoheiHagimoto | 0:0e0631af0305 | 3191 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3192 | |
RyoheiHagimoto | 0:0e0631af0305 | 3193 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3194 | MatExpr min(const Mat_<_Tp>& a, double s) |
RyoheiHagimoto | 0:0e0631af0305 | 3195 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3196 | return cv::min((const Mat&)a, s); |
RyoheiHagimoto | 0:0e0631af0305 | 3197 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3198 | |
RyoheiHagimoto | 0:0e0631af0305 | 3199 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3200 | MatExpr min(double s, const Mat_<_Tp>& a) |
RyoheiHagimoto | 0:0e0631af0305 | 3201 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3202 | return cv::min((const Mat&)a, s); |
RyoheiHagimoto | 0:0e0631af0305 | 3203 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3204 | |
RyoheiHagimoto | 0:0e0631af0305 | 3205 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3206 | MatExpr max(const Mat_<_Tp>& a, const Mat_<_Tp>& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3207 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3208 | return cv::max((const Mat&)a, (const Mat&)b); |
RyoheiHagimoto | 0:0e0631af0305 | 3209 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3210 | |
RyoheiHagimoto | 0:0e0631af0305 | 3211 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3212 | MatExpr max(const Mat_<_Tp>& a, double s) |
RyoheiHagimoto | 0:0e0631af0305 | 3213 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3214 | return cv::max((const Mat&)a, s); |
RyoheiHagimoto | 0:0e0631af0305 | 3215 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3216 | |
RyoheiHagimoto | 0:0e0631af0305 | 3217 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3218 | MatExpr max(double s, const Mat_<_Tp>& a) |
RyoheiHagimoto | 0:0e0631af0305 | 3219 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3220 | return cv::max((const Mat&)a, s); |
RyoheiHagimoto | 0:0e0631af0305 | 3221 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3222 | |
RyoheiHagimoto | 0:0e0631af0305 | 3223 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3224 | MatExpr abs(const Mat_<_Tp>& m) |
RyoheiHagimoto | 0:0e0631af0305 | 3225 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3226 | return cv::abs((const Mat&)m); |
RyoheiHagimoto | 0:0e0631af0305 | 3227 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3228 | |
RyoheiHagimoto | 0:0e0631af0305 | 3229 | |
RyoheiHagimoto | 0:0e0631af0305 | 3230 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3231 | Mat& operator += (Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3232 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3233 | b.op->augAssignAdd(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3234 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3235 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3236 | |
RyoheiHagimoto | 0:0e0631af0305 | 3237 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3238 | const Mat& operator += (const Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3239 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3240 | b.op->augAssignAdd(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3241 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3242 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3243 | |
RyoheiHagimoto | 0:0e0631af0305 | 3244 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3245 | Mat_<_Tp>& operator += (Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3246 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3247 | b.op->augAssignAdd(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3248 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3249 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3250 | |
RyoheiHagimoto | 0:0e0631af0305 | 3251 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3252 | const Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3253 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3254 | b.op->augAssignAdd(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3255 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3256 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3257 | |
RyoheiHagimoto | 0:0e0631af0305 | 3258 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3259 | Mat& operator -= (Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3260 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3261 | b.op->augAssignSubtract(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3262 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3263 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3264 | |
RyoheiHagimoto | 0:0e0631af0305 | 3265 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3266 | const Mat& operator -= (const Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3267 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3268 | b.op->augAssignSubtract(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3269 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3270 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3271 | |
RyoheiHagimoto | 0:0e0631af0305 | 3272 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3273 | Mat_<_Tp>& operator -= (Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3274 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3275 | b.op->augAssignSubtract(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3276 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3277 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3278 | |
RyoheiHagimoto | 0:0e0631af0305 | 3279 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3280 | const Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3281 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3282 | b.op->augAssignSubtract(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3283 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3284 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3285 | |
RyoheiHagimoto | 0:0e0631af0305 | 3286 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3287 | Mat& operator *= (Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3288 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3289 | b.op->augAssignMultiply(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3290 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3291 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3292 | |
RyoheiHagimoto | 0:0e0631af0305 | 3293 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3294 | const Mat& operator *= (const Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3295 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3296 | b.op->augAssignMultiply(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3297 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3298 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3299 | |
RyoheiHagimoto | 0:0e0631af0305 | 3300 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3301 | Mat_<_Tp>& operator *= (Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3302 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3303 | b.op->augAssignMultiply(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3304 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3305 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3306 | |
RyoheiHagimoto | 0:0e0631af0305 | 3307 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3308 | const Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3309 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3310 | b.op->augAssignMultiply(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3311 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3312 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3313 | |
RyoheiHagimoto | 0:0e0631af0305 | 3314 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3315 | Mat& operator /= (Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3316 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3317 | b.op->augAssignDivide(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3318 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3319 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3320 | |
RyoheiHagimoto | 0:0e0631af0305 | 3321 | static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3322 | const Mat& operator /= (const Mat& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3323 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3324 | b.op->augAssignDivide(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3325 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3326 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3327 | |
RyoheiHagimoto | 0:0e0631af0305 | 3328 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3329 | Mat_<_Tp>& operator /= (Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3330 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3331 | b.op->augAssignDivide(b, a); |
RyoheiHagimoto | 0:0e0631af0305 | 3332 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3333 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3334 | |
RyoheiHagimoto | 0:0e0631af0305 | 3335 | template<typename _Tp> static inline |
RyoheiHagimoto | 0:0e0631af0305 | 3336 | const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) |
RyoheiHagimoto | 0:0e0631af0305 | 3337 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3338 | b.op->augAssignDivide(b, (Mat&)a); |
RyoheiHagimoto | 0:0e0631af0305 | 3339 | return a; |
RyoheiHagimoto | 0:0e0631af0305 | 3340 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3341 | |
RyoheiHagimoto | 0:0e0631af0305 | 3342 | |
RyoheiHagimoto | 0:0e0631af0305 | 3343 | //////////////////////////////// UMat //////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 3344 | |
RyoheiHagimoto | 0:0e0631af0305 | 3345 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3346 | UMat::UMat(UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3347 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3348 | {} |
RyoheiHagimoto | 0:0e0631af0305 | 3349 | |
RyoheiHagimoto | 0:0e0631af0305 | 3350 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3351 | UMat::UMat(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3352 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3353 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3354 | create(_rows, _cols, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 3355 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3356 | |
RyoheiHagimoto | 0:0e0631af0305 | 3357 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3358 | UMat::UMat(int _rows, int _cols, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3359 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3360 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3361 | create(_rows, _cols, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 3362 | *this = _s; |
RyoheiHagimoto | 0:0e0631af0305 | 3363 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3364 | |
RyoheiHagimoto | 0:0e0631af0305 | 3365 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3366 | UMat::UMat(Size _sz, int _type, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3367 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3368 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3369 | create( _sz.height, _sz.width, _type ); |
RyoheiHagimoto | 0:0e0631af0305 | 3370 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3371 | |
RyoheiHagimoto | 0:0e0631af0305 | 3372 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3373 | UMat::UMat(Size _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3374 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3375 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3376 | create(_sz.height, _sz.width, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 3377 | *this = _s; |
RyoheiHagimoto | 0:0e0631af0305 | 3378 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3379 | |
RyoheiHagimoto | 0:0e0631af0305 | 3380 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3381 | UMat::UMat(int _dims, const int* _sz, int _type, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3382 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3383 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3384 | create(_dims, _sz, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 3385 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3386 | |
RyoheiHagimoto | 0:0e0631af0305 | 3387 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3388 | UMat::UMat(int _dims, const int* _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3389 | : flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3390 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3391 | create(_dims, _sz, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 3392 | *this = _s; |
RyoheiHagimoto | 0:0e0631af0305 | 3393 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3394 | |
RyoheiHagimoto | 0:0e0631af0305 | 3395 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3396 | UMat::UMat(const UMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 3397 | : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator), |
RyoheiHagimoto | 0:0e0631af0305 | 3398 | usageFlags(m.usageFlags), u(m.u), offset(m.offset), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3399 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3400 | addref(); |
RyoheiHagimoto | 0:0e0631af0305 | 3401 | if( m.dims <= 2 ) |
RyoheiHagimoto | 0:0e0631af0305 | 3402 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3403 | step[0] = m.step[0]; step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 3404 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3405 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3406 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3407 | dims = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3408 | copySize(m); |
RyoheiHagimoto | 0:0e0631af0305 | 3409 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3410 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3411 | |
RyoheiHagimoto | 0:0e0631af0305 | 3412 | |
RyoheiHagimoto | 0:0e0631af0305 | 3413 | template<typename _Tp> inline |
RyoheiHagimoto | 0:0e0631af0305 | 3414 | UMat::UMat(const std::vector<_Tp>& vec, bool copyData) |
RyoheiHagimoto | 0:0e0631af0305 | 3415 | : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), |
RyoheiHagimoto | 0:0e0631af0305 | 3416 | cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3417 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3418 | if(vec.empty()) |
RyoheiHagimoto | 0:0e0631af0305 | 3419 | return; |
RyoheiHagimoto | 0:0e0631af0305 | 3420 | if( !copyData ) |
RyoheiHagimoto | 0:0e0631af0305 | 3421 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3422 | // !!!TODO!!! |
RyoheiHagimoto | 0:0e0631af0305 | 3423 | CV_Error(Error::StsNotImplemented, ""); |
RyoheiHagimoto | 0:0e0631af0305 | 3424 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3425 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3426 | Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this); |
RyoheiHagimoto | 0:0e0631af0305 | 3427 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3428 | |
RyoheiHagimoto | 0:0e0631af0305 | 3429 | |
RyoheiHagimoto | 0:0e0631af0305 | 3430 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3431 | UMat& UMat::operator = (const UMat& m) |
RyoheiHagimoto | 0:0e0631af0305 | 3432 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3433 | if( this != &m ) |
RyoheiHagimoto | 0:0e0631af0305 | 3434 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3435 | const_cast<UMat&>(m).addref(); |
RyoheiHagimoto | 0:0e0631af0305 | 3436 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 3437 | flags = m.flags; |
RyoheiHagimoto | 0:0e0631af0305 | 3438 | if( dims <= 2 && m.dims <= 2 ) |
RyoheiHagimoto | 0:0e0631af0305 | 3439 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3440 | dims = m.dims; |
RyoheiHagimoto | 0:0e0631af0305 | 3441 | rows = m.rows; |
RyoheiHagimoto | 0:0e0631af0305 | 3442 | cols = m.cols; |
RyoheiHagimoto | 0:0e0631af0305 | 3443 | step[0] = m.step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 3444 | step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 3445 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3446 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3447 | copySize(m); |
RyoheiHagimoto | 0:0e0631af0305 | 3448 | allocator = m.allocator; |
RyoheiHagimoto | 0:0e0631af0305 | 3449 | if (usageFlags == USAGE_DEFAULT) |
RyoheiHagimoto | 0:0e0631af0305 | 3450 | usageFlags = m.usageFlags; |
RyoheiHagimoto | 0:0e0631af0305 | 3451 | u = m.u; |
RyoheiHagimoto | 0:0e0631af0305 | 3452 | offset = m.offset; |
RyoheiHagimoto | 0:0e0631af0305 | 3453 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3454 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3455 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3456 | |
RyoheiHagimoto | 0:0e0631af0305 | 3457 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3458 | UMat UMat::row(int y) const |
RyoheiHagimoto | 0:0e0631af0305 | 3459 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3460 | return UMat(*this, Range(y, y + 1), Range::all()); |
RyoheiHagimoto | 0:0e0631af0305 | 3461 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3462 | |
RyoheiHagimoto | 0:0e0631af0305 | 3463 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3464 | UMat UMat::col(int x) const |
RyoheiHagimoto | 0:0e0631af0305 | 3465 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3466 | return UMat(*this, Range::all(), Range(x, x + 1)); |
RyoheiHagimoto | 0:0e0631af0305 | 3467 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3468 | |
RyoheiHagimoto | 0:0e0631af0305 | 3469 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3470 | UMat UMat::rowRange(int startrow, int endrow) const |
RyoheiHagimoto | 0:0e0631af0305 | 3471 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3472 | return UMat(*this, Range(startrow, endrow), Range::all()); |
RyoheiHagimoto | 0:0e0631af0305 | 3473 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3474 | |
RyoheiHagimoto | 0:0e0631af0305 | 3475 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3476 | UMat UMat::rowRange(const Range& r) const |
RyoheiHagimoto | 0:0e0631af0305 | 3477 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3478 | return UMat(*this, r, Range::all()); |
RyoheiHagimoto | 0:0e0631af0305 | 3479 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3480 | |
RyoheiHagimoto | 0:0e0631af0305 | 3481 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3482 | UMat UMat::colRange(int startcol, int endcol) const |
RyoheiHagimoto | 0:0e0631af0305 | 3483 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3484 | return UMat(*this, Range::all(), Range(startcol, endcol)); |
RyoheiHagimoto | 0:0e0631af0305 | 3485 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3486 | |
RyoheiHagimoto | 0:0e0631af0305 | 3487 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3488 | UMat UMat::colRange(const Range& r) const |
RyoheiHagimoto | 0:0e0631af0305 | 3489 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3490 | return UMat(*this, Range::all(), r); |
RyoheiHagimoto | 0:0e0631af0305 | 3491 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3492 | |
RyoheiHagimoto | 0:0e0631af0305 | 3493 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3494 | UMat UMat::clone() const |
RyoheiHagimoto | 0:0e0631af0305 | 3495 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3496 | UMat m; |
RyoheiHagimoto | 0:0e0631af0305 | 3497 | copyTo(m); |
RyoheiHagimoto | 0:0e0631af0305 | 3498 | return m; |
RyoheiHagimoto | 0:0e0631af0305 | 3499 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3500 | |
RyoheiHagimoto | 0:0e0631af0305 | 3501 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3502 | void UMat::assignTo( UMat& m, int _type ) const |
RyoheiHagimoto | 0:0e0631af0305 | 3503 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3504 | if( _type < 0 ) |
RyoheiHagimoto | 0:0e0631af0305 | 3505 | m = *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3506 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3507 | convertTo(m, _type); |
RyoheiHagimoto | 0:0e0631af0305 | 3508 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3509 | |
RyoheiHagimoto | 0:0e0631af0305 | 3510 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3511 | void UMat::create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3512 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3513 | _type &= TYPE_MASK; |
RyoheiHagimoto | 0:0e0631af0305 | 3514 | if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && u ) |
RyoheiHagimoto | 0:0e0631af0305 | 3515 | return; |
RyoheiHagimoto | 0:0e0631af0305 | 3516 | int sz[] = {_rows, _cols}; |
RyoheiHagimoto | 0:0e0631af0305 | 3517 | create(2, sz, _type, _usageFlags); |
RyoheiHagimoto | 0:0e0631af0305 | 3518 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3519 | |
RyoheiHagimoto | 0:0e0631af0305 | 3520 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3521 | void UMat::create(Size _sz, int _type, UMatUsageFlags _usageFlags) |
RyoheiHagimoto | 0:0e0631af0305 | 3522 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3523 | create(_sz.height, _sz.width, _type, _usageFlags); |
RyoheiHagimoto | 0:0e0631af0305 | 3524 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3525 | |
RyoheiHagimoto | 0:0e0631af0305 | 3526 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3527 | void UMat::addref() |
RyoheiHagimoto | 0:0e0631af0305 | 3528 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3529 | if( u ) |
RyoheiHagimoto | 0:0e0631af0305 | 3530 | CV_XADD(&(u->urefcount), 1); |
RyoheiHagimoto | 0:0e0631af0305 | 3531 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3532 | |
RyoheiHagimoto | 0:0e0631af0305 | 3533 | inline void UMat::release() |
RyoheiHagimoto | 0:0e0631af0305 | 3534 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3535 | if( u && CV_XADD(&(u->urefcount), -1) == 1 ) |
RyoheiHagimoto | 0:0e0631af0305 | 3536 | deallocate(); |
RyoheiHagimoto | 0:0e0631af0305 | 3537 | for(int i = 0; i < dims; i++) |
RyoheiHagimoto | 0:0e0631af0305 | 3538 | size.p[i] = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3539 | u = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3540 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3541 | |
RyoheiHagimoto | 0:0e0631af0305 | 3542 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3543 | UMat UMat::operator()( Range _rowRange, Range _colRange ) const |
RyoheiHagimoto | 0:0e0631af0305 | 3544 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3545 | return UMat(*this, _rowRange, _colRange); |
RyoheiHagimoto | 0:0e0631af0305 | 3546 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3547 | |
RyoheiHagimoto | 0:0e0631af0305 | 3548 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3549 | UMat UMat::operator()( const Rect& roi ) const |
RyoheiHagimoto | 0:0e0631af0305 | 3550 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3551 | return UMat(*this, roi); |
RyoheiHagimoto | 0:0e0631af0305 | 3552 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3553 | |
RyoheiHagimoto | 0:0e0631af0305 | 3554 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3555 | UMat UMat::operator()(const Range* ranges) const |
RyoheiHagimoto | 0:0e0631af0305 | 3556 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3557 | return UMat(*this, ranges); |
RyoheiHagimoto | 0:0e0631af0305 | 3558 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3559 | |
RyoheiHagimoto | 0:0e0631af0305 | 3560 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3561 | UMat UMat::operator()(const std::vector<Range>& ranges) const |
RyoheiHagimoto | 0:0e0631af0305 | 3562 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3563 | return UMat(*this, ranges); |
RyoheiHagimoto | 0:0e0631af0305 | 3564 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3565 | |
RyoheiHagimoto | 0:0e0631af0305 | 3566 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3567 | bool UMat::isContinuous() const |
RyoheiHagimoto | 0:0e0631af0305 | 3568 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3569 | return (flags & CONTINUOUS_FLAG) != 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3570 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3571 | |
RyoheiHagimoto | 0:0e0631af0305 | 3572 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3573 | bool UMat::isSubmatrix() const |
RyoheiHagimoto | 0:0e0631af0305 | 3574 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3575 | return (flags & SUBMATRIX_FLAG) != 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3576 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3577 | |
RyoheiHagimoto | 0:0e0631af0305 | 3578 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3579 | size_t UMat::elemSize() const |
RyoheiHagimoto | 0:0e0631af0305 | 3580 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3581 | return dims > 0 ? step.p[dims - 1] : 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3582 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3583 | |
RyoheiHagimoto | 0:0e0631af0305 | 3584 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3585 | size_t UMat::elemSize1() const |
RyoheiHagimoto | 0:0e0631af0305 | 3586 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3587 | return CV_ELEM_SIZE1(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 3588 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3589 | |
RyoheiHagimoto | 0:0e0631af0305 | 3590 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3591 | int UMat::type() const |
RyoheiHagimoto | 0:0e0631af0305 | 3592 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3593 | return CV_MAT_TYPE(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 3594 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3595 | |
RyoheiHagimoto | 0:0e0631af0305 | 3596 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3597 | int UMat::depth() const |
RyoheiHagimoto | 0:0e0631af0305 | 3598 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3599 | return CV_MAT_DEPTH(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 3600 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3601 | |
RyoheiHagimoto | 0:0e0631af0305 | 3602 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3603 | int UMat::channels() const |
RyoheiHagimoto | 0:0e0631af0305 | 3604 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3605 | return CV_MAT_CN(flags); |
RyoheiHagimoto | 0:0e0631af0305 | 3606 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3607 | |
RyoheiHagimoto | 0:0e0631af0305 | 3608 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3609 | size_t UMat::step1(int i) const |
RyoheiHagimoto | 0:0e0631af0305 | 3610 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3611 | return step.p[i] / elemSize1(); |
RyoheiHagimoto | 0:0e0631af0305 | 3612 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3613 | |
RyoheiHagimoto | 0:0e0631af0305 | 3614 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3615 | bool UMat::empty() const |
RyoheiHagimoto | 0:0e0631af0305 | 3616 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3617 | return u == 0 || total() == 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3618 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3619 | |
RyoheiHagimoto | 0:0e0631af0305 | 3620 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3621 | size_t UMat::total() const |
RyoheiHagimoto | 0:0e0631af0305 | 3622 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3623 | if( dims <= 2 ) |
RyoheiHagimoto | 0:0e0631af0305 | 3624 | return (size_t)rows * cols; |
RyoheiHagimoto | 0:0e0631af0305 | 3625 | size_t p = 1; |
RyoheiHagimoto | 0:0e0631af0305 | 3626 | for( int i = 0; i < dims; i++ ) |
RyoheiHagimoto | 0:0e0631af0305 | 3627 | p *= size[i]; |
RyoheiHagimoto | 0:0e0631af0305 | 3628 | return p; |
RyoheiHagimoto | 0:0e0631af0305 | 3629 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3630 | |
RyoheiHagimoto | 0:0e0631af0305 | 3631 | #ifdef CV_CXX_MOVE_SEMANTICS |
RyoheiHagimoto | 0:0e0631af0305 | 3632 | |
RyoheiHagimoto | 0:0e0631af0305 | 3633 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3634 | UMat::UMat(UMat&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 3635 | : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator), |
RyoheiHagimoto | 0:0e0631af0305 | 3636 | usageFlags(m.usageFlags), u(m.u), offset(m.offset), size(&rows) |
RyoheiHagimoto | 0:0e0631af0305 | 3637 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3638 | if (m.dims <= 2) // move new step/size info |
RyoheiHagimoto | 0:0e0631af0305 | 3639 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3640 | step[0] = m.step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 3641 | step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 3642 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3643 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3644 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3645 | CV_DbgAssert(m.step.p != m.step.buf); |
RyoheiHagimoto | 0:0e0631af0305 | 3646 | step.p = m.step.p; |
RyoheiHagimoto | 0:0e0631af0305 | 3647 | size.p = m.size.p; |
RyoheiHagimoto | 0:0e0631af0305 | 3648 | m.step.p = m.step.buf; |
RyoheiHagimoto | 0:0e0631af0305 | 3649 | m.size.p = &m.rows; |
RyoheiHagimoto | 0:0e0631af0305 | 3650 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3651 | m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3652 | m.allocator = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 3653 | m.u = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 3654 | m.offset = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3655 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3656 | |
RyoheiHagimoto | 0:0e0631af0305 | 3657 | inline |
RyoheiHagimoto | 0:0e0631af0305 | 3658 | UMat& UMat::operator = (UMat&& m) |
RyoheiHagimoto | 0:0e0631af0305 | 3659 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3660 | if (this == &m) |
RyoheiHagimoto | 0:0e0631af0305 | 3661 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3662 | release(); |
RyoheiHagimoto | 0:0e0631af0305 | 3663 | flags = m.flags; dims = m.dims; rows = m.rows; cols = m.cols; |
RyoheiHagimoto | 0:0e0631af0305 | 3664 | allocator = m.allocator; usageFlags = m.usageFlags; |
RyoheiHagimoto | 0:0e0631af0305 | 3665 | u = m.u; |
RyoheiHagimoto | 0:0e0631af0305 | 3666 | offset = m.offset; |
RyoheiHagimoto | 0:0e0631af0305 | 3667 | if (step.p != step.buf) // release self step/size |
RyoheiHagimoto | 0:0e0631af0305 | 3668 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3669 | fastFree(step.p); |
RyoheiHagimoto | 0:0e0631af0305 | 3670 | step.p = step.buf; |
RyoheiHagimoto | 0:0e0631af0305 | 3671 | size.p = &rows; |
RyoheiHagimoto | 0:0e0631af0305 | 3672 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3673 | if (m.dims <= 2) // move new step/size info |
RyoheiHagimoto | 0:0e0631af0305 | 3674 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3675 | step[0] = m.step[0]; |
RyoheiHagimoto | 0:0e0631af0305 | 3676 | step[1] = m.step[1]; |
RyoheiHagimoto | 0:0e0631af0305 | 3677 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3678 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3679 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3680 | CV_DbgAssert(m.step.p != m.step.buf); |
RyoheiHagimoto | 0:0e0631af0305 | 3681 | step.p = m.step.p; |
RyoheiHagimoto | 0:0e0631af0305 | 3682 | size.p = m.size.p; |
RyoheiHagimoto | 0:0e0631af0305 | 3683 | m.step.p = m.step.buf; |
RyoheiHagimoto | 0:0e0631af0305 | 3684 | m.size.p = &m.rows; |
RyoheiHagimoto | 0:0e0631af0305 | 3685 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3686 | m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3687 | m.allocator = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 3688 | m.u = NULL; |
RyoheiHagimoto | 0:0e0631af0305 | 3689 | m.offset = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 3690 | return *this; |
RyoheiHagimoto | 0:0e0631af0305 | 3691 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3692 | |
RyoheiHagimoto | 0:0e0631af0305 | 3693 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 3694 | |
RyoheiHagimoto | 0:0e0631af0305 | 3695 | |
RyoheiHagimoto | 0:0e0631af0305 | 3696 | inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; } |
RyoheiHagimoto | 0:0e0631af0305 | 3697 | inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; } |
RyoheiHagimoto | 0:0e0631af0305 | 3698 | inline bool UMatData::deviceMemMapped() const { return (flags & DEVICE_MEM_MAPPED) != 0; } |
RyoheiHagimoto | 0:0e0631af0305 | 3699 | inline bool UMatData::copyOnMap() const { return (flags & COPY_ON_MAP) != 0; } |
RyoheiHagimoto | 0:0e0631af0305 | 3700 | inline bool UMatData::tempUMat() const { return (flags & TEMP_UMAT) != 0; } |
RyoheiHagimoto | 0:0e0631af0305 | 3701 | inline bool UMatData::tempCopiedUMat() const { return (flags & TEMP_COPIED_UMAT) == TEMP_COPIED_UMAT; } |
RyoheiHagimoto | 0:0e0631af0305 | 3702 | |
RyoheiHagimoto | 0:0e0631af0305 | 3703 | inline void UMatData::markDeviceMemMapped(bool flag) |
RyoheiHagimoto | 0:0e0631af0305 | 3704 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3705 | if(flag) |
RyoheiHagimoto | 0:0e0631af0305 | 3706 | flags |= DEVICE_MEM_MAPPED; |
RyoheiHagimoto | 0:0e0631af0305 | 3707 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3708 | flags &= ~DEVICE_MEM_MAPPED; |
RyoheiHagimoto | 0:0e0631af0305 | 3709 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3710 | |
RyoheiHagimoto | 0:0e0631af0305 | 3711 | inline void UMatData::markHostCopyObsolete(bool flag) |
RyoheiHagimoto | 0:0e0631af0305 | 3712 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3713 | if(flag) |
RyoheiHagimoto | 0:0e0631af0305 | 3714 | flags |= HOST_COPY_OBSOLETE; |
RyoheiHagimoto | 0:0e0631af0305 | 3715 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3716 | flags &= ~HOST_COPY_OBSOLETE; |
RyoheiHagimoto | 0:0e0631af0305 | 3717 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3718 | inline void UMatData::markDeviceCopyObsolete(bool flag) |
RyoheiHagimoto | 0:0e0631af0305 | 3719 | { |
RyoheiHagimoto | 0:0e0631af0305 | 3720 | if(flag) |
RyoheiHagimoto | 0:0e0631af0305 | 3721 | flags |= DEVICE_COPY_OBSOLETE; |
RyoheiHagimoto | 0:0e0631af0305 | 3722 | else |
RyoheiHagimoto | 0:0e0631af0305 | 3723 | flags &= ~DEVICE_COPY_OBSOLETE; |
RyoheiHagimoto | 0:0e0631af0305 | 3724 | } |
RyoheiHagimoto | 0:0e0631af0305 | 3725 | |
RyoheiHagimoto | 0:0e0631af0305 | 3726 | inline UMatDataAutoLock::UMatDataAutoLock(UMatData* _u) : u(_u) { u->lock(); } |
RyoheiHagimoto | 0:0e0631af0305 | 3727 | inline UMatDataAutoLock::~UMatDataAutoLock() { u->unlock(); } |
RyoheiHagimoto | 0:0e0631af0305 | 3728 | |
RyoheiHagimoto | 0:0e0631af0305 | 3729 | //! @endcond |
RyoheiHagimoto | 0:0e0631af0305 | 3730 | |
RyoheiHagimoto | 0:0e0631af0305 | 3731 | } //cv |
RyoheiHagimoto | 0:0e0631af0305 | 3732 | |
RyoheiHagimoto | 0:0e0631af0305 | 3733 | #endif |