Skip to content

Commit f50ec22

Browse files
committed
Eigen: fix Mat construction stride
1 parent 3e33820 commit f50ec22

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

modules/core/include/opencv2/core/eigen.hpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCo
6565
if( !(src.Flags & Eigen::RowMajorBit) )
6666
{
6767
Mat _src(src.cols(), src.rows(), traits::Type<_Tp>::value,
68-
(void*)src.data(), src.stride()*sizeof(_Tp));
68+
(void*)src.data(), src.outerStride()*sizeof(_Tp));
6969
transpose(_src, dst);
7070
}
7171
else
7272
{
7373
Mat _src(src.rows(), src.cols(), traits::Type<_Tp>::value,
74-
(void*)src.data(), src.stride()*sizeof(_Tp));
74+
(void*)src.data(), src.outerStride()*sizeof(_Tp));
7575
_src.copyTo(dst);
7676
}
7777
}
@@ -99,7 +99,7 @@ void cv2eigen( const Mat& src,
9999
if( !(dst.Flags & Eigen::RowMajorBit) )
100100
{
101101
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
102-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
102+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
103103
if( src.type() == _dst.type() )
104104
transpose(src, _dst);
105105
else if( src.cols == src.rows )
@@ -113,7 +113,7 @@ void cv2eigen( const Mat& src,
113113
else
114114
{
115115
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
116-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
116+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
117117
src.convertTo(_dst, _dst.type());
118118
}
119119
}
@@ -126,13 +126,13 @@ void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
126126
if( !(dst.Flags & Eigen::RowMajorBit) )
127127
{
128128
const Mat _dst(_cols, _rows, traits::Type<_Tp>::value,
129-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
129+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
130130
transpose(src, _dst);
131131
}
132132
else
133133
{
134134
const Mat _dst(_rows, _cols, traits::Type<_Tp>::value,
135-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
135+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
136136
Mat(src).copyTo(_dst);
137137
}
138138
}
@@ -145,7 +145,7 @@ void cv2eigen( const Mat& src,
145145
if( !(dst.Flags & Eigen::RowMajorBit) )
146146
{
147147
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
148-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
148+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
149149
if( src.type() == _dst.type() )
150150
transpose(src, _dst);
151151
else if( src.cols == src.rows )
@@ -159,7 +159,7 @@ void cv2eigen( const Mat& src,
159159
else
160160
{
161161
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
162-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
162+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
163163
src.convertTo(_dst, _dst.type());
164164
}
165165
}
@@ -173,13 +173,13 @@ void cv2eigen( const Matx<_Tp, _rows, _cols>& src,
173173
if( !(dst.Flags & Eigen::RowMajorBit) )
174174
{
175175
const Mat _dst(_cols, _rows, traits::Type<_Tp>::value,
176-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
176+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
177177
transpose(src, _dst);
178178
}
179179
else
180180
{
181181
const Mat _dst(_rows, _cols, traits::Type<_Tp>::value,
182-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
182+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
183183
Mat(src).copyTo(_dst);
184184
}
185185
}
@@ -194,7 +194,7 @@ void cv2eigen( const Mat& src,
194194
if( !(dst.Flags & Eigen::RowMajorBit) )
195195
{
196196
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
197-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
197+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
198198
if( src.type() == _dst.type() )
199199
transpose(src, _dst);
200200
else
@@ -203,7 +203,7 @@ void cv2eigen( const Mat& src,
203203
else
204204
{
205205
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
206-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
206+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
207207
src.convertTo(_dst, _dst.type());
208208
}
209209
}
@@ -218,13 +218,13 @@ void cv2eigen( const Matx<_Tp, _rows, 1>& src,
218218
if( !(dst.Flags & Eigen::RowMajorBit) )
219219
{
220220
const Mat _dst(1, _rows, traits::Type<_Tp>::value,
221-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
221+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
222222
transpose(src, _dst);
223223
}
224224
else
225225
{
226226
const Mat _dst(_rows, 1, traits::Type<_Tp>::value,
227-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
227+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
228228
src.copyTo(_dst);
229229
}
230230
}
@@ -239,7 +239,7 @@ void cv2eigen( const Mat& src,
239239
if( !(dst.Flags & Eigen::RowMajorBit) )
240240
{
241241
const Mat _dst(src.cols, src.rows, traits::Type<_Tp>::value,
242-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
242+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
243243
if( src.type() == _dst.type() )
244244
transpose(src, _dst);
245245
else
@@ -248,7 +248,7 @@ void cv2eigen( const Mat& src,
248248
else
249249
{
250250
const Mat _dst(src.rows, src.cols, traits::Type<_Tp>::value,
251-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
251+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
252252
src.convertTo(_dst, _dst.type());
253253
}
254254
}
@@ -262,13 +262,13 @@ void cv2eigen( const Matx<_Tp, 1, _cols>& src,
262262
if( !(dst.Flags & Eigen::RowMajorBit) )
263263
{
264264
const Mat _dst(_cols, 1, traits::Type<_Tp>::value,
265-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
265+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
266266
transpose(src, _dst);
267267
}
268268
else
269269
{
270270
const Mat _dst(1, _cols, traits::Type<_Tp>::value,
271-
dst.data(), (size_t)(dst.stride()*sizeof(_Tp)));
271+
dst.data(), (size_t)(dst.outerStride()*sizeof(_Tp)));
272272
Mat(src).copyTo(_dst);
273273
}
274274
}

0 commit comments

Comments
 (0)