openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/core/eigen.hpp@0:0e0631af0305, 2021-01-29 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Fri Jan 29 04:53:38 2021 +0000
- Revision:
- 0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| RyoheiHagimoto | 0:0e0631af0305 | 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
| RyoheiHagimoto | 0:0e0631af0305 | 2 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
| RyoheiHagimoto | 0:0e0631af0305 | 4 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 5 | // By downloading, copying, installing or using the software you agree to this license. |
| RyoheiHagimoto | 0:0e0631af0305 | 6 | // If you do not agree to this license, do not download, install, |
| RyoheiHagimoto | 0:0e0631af0305 | 7 | // copy or use the software. |
| RyoheiHagimoto | 0:0e0631af0305 | 8 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 9 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 10 | // License Agreement |
| RyoheiHagimoto | 0:0e0631af0305 | 11 | // For Open Source Computer Vision Library |
| RyoheiHagimoto | 0:0e0631af0305 | 12 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
| RyoheiHagimoto | 0:0e0631af0305 | 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
| RyoheiHagimoto | 0:0e0631af0305 | 15 | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. |
| RyoheiHagimoto | 0:0e0631af0305 | 16 | // Third party copyrights are property of their respective owners. |
| RyoheiHagimoto | 0:0e0631af0305 | 17 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 18 | // Redistribution and use in source and binary forms, with or without modification, |
| RyoheiHagimoto | 0:0e0631af0305 | 19 | // are permitted provided that the following conditions are met: |
| RyoheiHagimoto | 0:0e0631af0305 | 20 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 21 | // * Redistribution's of source code must retain the above copyright notice, |
| RyoheiHagimoto | 0:0e0631af0305 | 22 | // this list of conditions and the following disclaimer. |
| RyoheiHagimoto | 0:0e0631af0305 | 23 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 24 | // * Redistribution's in binary form must reproduce the above copyright notice, |
| RyoheiHagimoto | 0:0e0631af0305 | 25 | // this list of conditions and the following disclaimer in the documentation |
| RyoheiHagimoto | 0:0e0631af0305 | 26 | // and/or other materials provided with the distribution. |
| RyoheiHagimoto | 0:0e0631af0305 | 27 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 28 | // * The name of the copyright holders may not be used to endorse or promote products |
| RyoheiHagimoto | 0:0e0631af0305 | 29 | // derived from this software without specific prior written permission. |
| RyoheiHagimoto | 0:0e0631af0305 | 30 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 31 | // This software is provided by the copyright holders and contributors "as is" and |
| RyoheiHagimoto | 0:0e0631af0305 | 32 | // any express or implied warranties, including, but not limited to, the implied |
| RyoheiHagimoto | 0:0e0631af0305 | 33 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
| RyoheiHagimoto | 0:0e0631af0305 | 34 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
| RyoheiHagimoto | 0:0e0631af0305 | 35 | // indirect, incidental, special, exemplary, or consequential damages |
| RyoheiHagimoto | 0:0e0631af0305 | 36 | // (including, but not limited to, procurement of substitute goods or services; |
| RyoheiHagimoto | 0:0e0631af0305 | 37 | // loss of use, data, or profits; or business interruption) however caused |
| RyoheiHagimoto | 0:0e0631af0305 | 38 | // and on any theory of liability, whether in contract, strict liability, |
| RyoheiHagimoto | 0:0e0631af0305 | 39 | // or tort (including negligence or otherwise) arising in any way out of |
| RyoheiHagimoto | 0:0e0631af0305 | 40 | // the use of this software, even if advised of the possibility of such damage. |
| RyoheiHagimoto | 0:0e0631af0305 | 41 | // |
| RyoheiHagimoto | 0:0e0631af0305 | 42 | //M*/ |
| RyoheiHagimoto | 0:0e0631af0305 | 43 | |
| RyoheiHagimoto | 0:0e0631af0305 | 44 | |
| RyoheiHagimoto | 0:0e0631af0305 | 45 | #ifndef OPENCV_CORE_EIGEN_HPP |
| RyoheiHagimoto | 0:0e0631af0305 | 46 | #define OPENCV_CORE_EIGEN_HPP |
| RyoheiHagimoto | 0:0e0631af0305 | 47 | |
| RyoheiHagimoto | 0:0e0631af0305 | 48 | #include "opencv2/core.hpp" |
| RyoheiHagimoto | 0:0e0631af0305 | 49 | |
| RyoheiHagimoto | 0:0e0631af0305 | 50 | #if defined _MSC_VER && _MSC_VER >= 1200 |
| RyoheiHagimoto | 0:0e0631af0305 | 51 | #pragma warning( disable: 4714 ) //__forceinline is not inlined |
| RyoheiHagimoto | 0:0e0631af0305 | 52 | #pragma warning( disable: 4127 ) //conditional expression is constant |
| RyoheiHagimoto | 0:0e0631af0305 | 53 | #pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data |
| RyoheiHagimoto | 0:0e0631af0305 | 54 | #endif |
| RyoheiHagimoto | 0:0e0631af0305 | 55 | |
| RyoheiHagimoto | 0:0e0631af0305 | 56 | namespace cv |
| RyoheiHagimoto | 0:0e0631af0305 | 57 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 58 | |
| RyoheiHagimoto | 0:0e0631af0305 | 59 | //! @addtogroup core_eigen |
| RyoheiHagimoto | 0:0e0631af0305 | 60 | //! @{ |
| RyoheiHagimoto | 0:0e0631af0305 | 61 | |
| RyoheiHagimoto | 0:0e0631af0305 | 62 | template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 63 | void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 64 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 65 | if( !(src.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 66 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 67 | Mat _src(src.cols(), src.rows(), DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 68 | (void*)src.data(), src.stride()*sizeof(_Tp)); |
| RyoheiHagimoto | 0:0e0631af0305 | 69 | transpose(_src, dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 70 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 71 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 72 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 73 | Mat _src(src.rows(), src.cols(), DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 74 | (void*)src.data(), src.stride()*sizeof(_Tp)); |
| RyoheiHagimoto | 0:0e0631af0305 | 75 | _src.copyTo(dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 76 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 77 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 78 | |
| RyoheiHagimoto | 0:0e0631af0305 | 79 | // Matx case |
| RyoheiHagimoto | 0:0e0631af0305 | 80 | template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 81 | void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 82 | Matx<_Tp, _rows, _cols>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 83 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 84 | if( !(src.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 85 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 86 | dst = Matx<_Tp, _cols, _rows>(static_cast<const _Tp*>(src.data())).t(); |
| RyoheiHagimoto | 0:0e0631af0305 | 87 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 88 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 89 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 90 | dst = Matx<_Tp, _rows, _cols>(static_cast<const _Tp*>(src.data())); |
| RyoheiHagimoto | 0:0e0631af0305 | 91 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 92 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 93 | |
| RyoheiHagimoto | 0:0e0631af0305 | 94 | template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 95 | void cv2eigen( const Mat& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 96 | Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 97 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 98 | CV_DbgAssert(src.rows == _rows && src.cols == _cols); |
| RyoheiHagimoto | 0:0e0631af0305 | 99 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 100 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 101 | const Mat _dst(src.cols, src.rows, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 102 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 103 | if( src.type() == _dst.type() ) |
| RyoheiHagimoto | 0:0e0631af0305 | 104 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 105 | else if( src.cols == src.rows ) |
| RyoheiHagimoto | 0:0e0631af0305 | 106 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 107 | src.convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 108 | transpose(_dst, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 109 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 110 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 111 | Mat(src.t()).convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 112 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 113 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 114 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 115 | const Mat _dst(src.rows, src.cols, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 116 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 117 | src.convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 118 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 119 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 120 | |
| RyoheiHagimoto | 0:0e0631af0305 | 121 | // Matx case |
| RyoheiHagimoto | 0:0e0631af0305 | 122 | template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 123 | void cv2eigen( const Matx<_Tp, _rows, _cols>& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 124 | Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 125 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 126 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 127 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 128 | const Mat _dst(_cols, _rows, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 129 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 130 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 131 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 132 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 133 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 134 | const Mat _dst(_rows, _cols, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 135 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 136 | Mat(src).copyTo(_dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 137 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 138 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 139 | |
| RyoheiHagimoto | 0:0e0631af0305 | 140 | template<typename _Tp> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 141 | void cv2eigen( const Mat& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 142 | Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 143 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 144 | dst.resize(src.rows, src.cols); |
| RyoheiHagimoto | 0:0e0631af0305 | 145 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 146 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 147 | const Mat _dst(src.cols, src.rows, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 148 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 149 | if( src.type() == _dst.type() ) |
| RyoheiHagimoto | 0:0e0631af0305 | 150 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 151 | else if( src.cols == src.rows ) |
| RyoheiHagimoto | 0:0e0631af0305 | 152 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 153 | src.convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 154 | transpose(_dst, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 155 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 156 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 157 | Mat(src.t()).convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 158 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 159 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 160 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 161 | const Mat _dst(src.rows, src.cols, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 162 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 163 | src.convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 164 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 165 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 166 | |
| RyoheiHagimoto | 0:0e0631af0305 | 167 | // Matx case |
| RyoheiHagimoto | 0:0e0631af0305 | 168 | template<typename _Tp, int _rows, int _cols> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 169 | void cv2eigen( const Matx<_Tp, _rows, _cols>& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 170 | Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 171 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 172 | dst.resize(_rows, _cols); |
| RyoheiHagimoto | 0:0e0631af0305 | 173 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 174 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 175 | const Mat _dst(_cols, _rows, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 176 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 177 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 178 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 179 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 180 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 181 | const Mat _dst(_rows, _cols, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 182 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 183 | Mat(src).copyTo(_dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 184 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 185 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 186 | |
| RyoheiHagimoto | 0:0e0631af0305 | 187 | template<typename _Tp> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 188 | void cv2eigen( const Mat& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 189 | Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 190 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 191 | CV_Assert(src.cols == 1); |
| RyoheiHagimoto | 0:0e0631af0305 | 192 | dst.resize(src.rows); |
| RyoheiHagimoto | 0:0e0631af0305 | 193 | |
| RyoheiHagimoto | 0:0e0631af0305 | 194 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 195 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 196 | const Mat _dst(src.cols, src.rows, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 197 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 198 | if( src.type() == _dst.type() ) |
| RyoheiHagimoto | 0:0e0631af0305 | 199 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 200 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 201 | Mat(src.t()).convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 202 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 203 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 204 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 205 | const Mat _dst(src.rows, src.cols, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 206 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 207 | src.convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 208 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 209 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 210 | |
| RyoheiHagimoto | 0:0e0631af0305 | 211 | // Matx case |
| RyoheiHagimoto | 0:0e0631af0305 | 212 | template<typename _Tp, int _rows> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 213 | void cv2eigen( const Matx<_Tp, _rows, 1>& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 214 | Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 215 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 216 | dst.resize(_rows); |
| RyoheiHagimoto | 0:0e0631af0305 | 217 | |
| RyoheiHagimoto | 0:0e0631af0305 | 218 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 219 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 220 | const Mat _dst(1, _rows, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 221 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 222 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 223 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 224 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 225 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 226 | const Mat _dst(_rows, 1, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 227 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 228 | src.copyTo(_dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 229 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 230 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 231 | |
| RyoheiHagimoto | 0:0e0631af0305 | 232 | |
| RyoheiHagimoto | 0:0e0631af0305 | 233 | template<typename _Tp> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 234 | void cv2eigen( const Mat& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 235 | Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 236 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 237 | CV_Assert(src.rows == 1); |
| RyoheiHagimoto | 0:0e0631af0305 | 238 | dst.resize(src.cols); |
| RyoheiHagimoto | 0:0e0631af0305 | 239 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 240 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 241 | const Mat _dst(src.cols, src.rows, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 242 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 243 | if( src.type() == _dst.type() ) |
| RyoheiHagimoto | 0:0e0631af0305 | 244 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 245 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 246 | Mat(src.t()).convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 247 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 248 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 249 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 250 | const Mat _dst(src.rows, src.cols, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 251 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 252 | src.convertTo(_dst, _dst.type()); |
| RyoheiHagimoto | 0:0e0631af0305 | 253 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 254 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 255 | |
| RyoheiHagimoto | 0:0e0631af0305 | 256 | //Matx |
| RyoheiHagimoto | 0:0e0631af0305 | 257 | template<typename _Tp, int _cols> static inline |
| RyoheiHagimoto | 0:0e0631af0305 | 258 | void cv2eigen( const Matx<_Tp, 1, _cols>& src, |
| RyoheiHagimoto | 0:0e0631af0305 | 259 | Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) |
| RyoheiHagimoto | 0:0e0631af0305 | 260 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 261 | dst.resize(_cols); |
| RyoheiHagimoto | 0:0e0631af0305 | 262 | if( !(dst.Flags & Eigen::RowMajorBit) ) |
| RyoheiHagimoto | 0:0e0631af0305 | 263 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 264 | const Mat _dst(_cols, 1, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 265 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 266 | transpose(src, _dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 267 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 268 | else |
| RyoheiHagimoto | 0:0e0631af0305 | 269 | { |
| RyoheiHagimoto | 0:0e0631af0305 | 270 | const Mat _dst(1, _cols, DataType<_Tp>::type, |
| RyoheiHagimoto | 0:0e0631af0305 | 271 | dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); |
| RyoheiHagimoto | 0:0e0631af0305 | 272 | Mat(src).copyTo(_dst); |
| RyoheiHagimoto | 0:0e0631af0305 | 273 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 274 | } |
| RyoheiHagimoto | 0:0e0631af0305 | 275 | |
| RyoheiHagimoto | 0:0e0631af0305 | 276 | //! @} |
| RyoheiHagimoto | 0:0e0631af0305 | 277 | |
| RyoheiHagimoto | 0:0e0631af0305 | 278 | } // cv |
| RyoheiHagimoto | 0:0e0631af0305 | 279 | |
| RyoheiHagimoto | 0:0e0631af0305 | 280 | #endif |