1
/*M///////////////////////////////////////////////////////////////////////////////////////
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5
// By downloading, copying, installing or using the software you agree to this license.
6
// If you do not agree to this license, do not download, install,
7
// copy or use the software.
11
// For Open Source Computer Vision Library
13
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16
// Third party copyrights are property of their respective owners.
18
// Redistribution and use in source and binary forms, with or without modification,
19
// are permitted provided that the following conditions are met:
21
// * Redistribution's of source code must retain the above copyright notice,
22
// this list of conditions and the following disclaimer.
24
// * Redistribution's in binary form must reproduce the above copyright notice,
25
// this list of conditions and the following disclaimer in the documentation
26
// and/or other materials provided with the distribution.
28
// * The name of the copyright holders may not be used to endorse or promote products
29
// derived from this software without specific prior written permission.
31
// This software is provided by the copyright holders and contributors "as is" and
32
// any express or implied warranties, including, but not limited to, the implied
33
// warranties of merchantability and fitness for a particular purpose are disclaimed.
34
// In no event shall the Intel Corporation or contributors be liable for any direct,
35
// indirect, incidental, special, exemplary, or consequential damages
36
// (including, but not limited to, procurement of substitute goods or services;
37
// loss of use, data, or profits; or business interruption) however caused
38
// and on any theory of liability, whether in contract, strict liability,
39
// or tort (including negligence or otherwise) arising in any way out of
40
// the use of this software, even if advised of the possibility of such damage.
46
#ifndef __OPENCV_CUDEV_PTR2D_GPUMAT_DETAIL_HPP__
47
#define __OPENCV_CUDEV_PTR2D_GPUMAT_DETAIL_HPP__
49
#include "../gpumat.hpp"
51
namespace cv { namespace cudev {
54
__host__ GpuMat_<T>::GpuMat_(Allocator* allocator)
57
flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
61
__host__ GpuMat_<T>::GpuMat_(int arows, int acols, Allocator* allocator)
62
: GpuMat(arows, acols, DataType<T>::type, allocator)
67
__host__ GpuMat_<T>::GpuMat_(Size asize, Allocator* allocator)
68
: GpuMat(asize.height, asize.width, DataType<T>::type, allocator)
73
__host__ GpuMat_<T>::GpuMat_(int arows, int acols, Scalar val, Allocator* allocator)
74
: GpuMat(arows, acols, DataType<T>::type, val, allocator)
79
__host__ GpuMat_<T>::GpuMat_(Size asize, Scalar val, Allocator* allocator)
80
: GpuMat(asize.height, asize.width, DataType<T>::type, val, allocator)
85
__host__ GpuMat_<T>::GpuMat_(const GpuMat_& m)
91
__host__ GpuMat_<T>::GpuMat_(const GpuMat& m, Allocator* allocator)
94
flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
96
if (DataType<T>::type == m.type())
98
GpuMat::operator =(m);
102
if (DataType<T>::depth == m.depth())
104
GpuMat::operator =(m.reshape(DataType<T>::channels, m.rows));
108
CV_Assert( DataType<T>::channels == m.channels() );
109
m.convertTo(*this, type());
112
template <typename T>
113
__host__ GpuMat_<T>::GpuMat_(int arows, int acols, T* adata, size_t astep)
114
: GpuMat(arows, acols, DataType<T>::type, adata, astep)
118
template <typename T>
119
__host__ GpuMat_<T>::GpuMat_(Size asize, T* adata, size_t astep)
120
: GpuMat(asize.height, asize.width, DataType<T>::type, adata, astep)
124
template <typename T>
125
__host__ GpuMat_<T>::GpuMat_(const GpuMat_& m, Range arowRange, Range acolRange)
126
: GpuMat(m, arowRange, acolRange)
130
template <typename T>
131
__host__ GpuMat_<T>::GpuMat_(const GpuMat_& m, Rect roi)
136
template <typename T>
137
__host__ GpuMat_<T>::GpuMat_(InputArray arr, Allocator* allocator)
140
flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
144
template <typename T>
145
__host__ GpuMat_<T>& GpuMat_<T>::operator =(const GpuMat_& m)
147
GpuMat::operator =(m);
151
template <typename T>
152
__host__ void GpuMat_<T>::create(int arows, int acols)
154
GpuMat::create(arows, acols, DataType<T>::type);
157
template <typename T>
158
__host__ void GpuMat_<T>::create(Size asize)
160
GpuMat::create(asize, DataType<T>::type);
163
template <typename T>
164
__host__ void GpuMat_<T>::swap(GpuMat_& mat)
169
template <typename T>
170
__host__ void GpuMat_<T>::upload(InputArray arr)
172
CV_Assert( arr.type() == DataType<T>::type );
176
template <typename T>
177
__host__ void GpuMat_<T>::upload(InputArray arr, Stream& stream)
179
CV_Assert( arr.type() == DataType<T>::type );
180
GpuMat::upload(arr, stream);
183
template <typename T>
184
__host__ GpuMat_<T>::operator GlobPtrSz<T>() const
186
return globPtr((T*) data, step, rows, cols);
189
template <typename T>
190
__host__ GpuMat_<T>::operator GlobPtr<T>() const
192
return globPtr((T*) data, step);
195
template <typename T>
196
__host__ GpuMat_<T> GpuMat_<T>::clone() const
198
return GpuMat_(GpuMat::clone());
201
template <typename T>
202
__host__ GpuMat_<T> GpuMat_<T>::row(int y) const
204
return GpuMat_(*this, Range(y, y+1), Range::all());
207
template <typename T>
208
__host__ GpuMat_<T> GpuMat_<T>::col(int x) const
210
return GpuMat_(*this, Range::all(), Range(x, x+1));
213
template <typename T>
214
__host__ GpuMat_<T> GpuMat_<T>::rowRange(int startrow, int endrow) const
216
return GpuMat_(*this, Range(startrow, endrow), Range::all());
219
template <typename T>
220
__host__ GpuMat_<T> GpuMat_<T>::rowRange(Range r) const
222
return GpuMat_(*this, r, Range::all());
225
template <typename T>
226
__host__ GpuMat_<T> GpuMat_<T>::colRange(int startcol, int endcol) const
228
return GpuMat_(*this, Range::all(), Range(startcol, endcol));
231
template <typename T>
232
__host__ GpuMat_<T> GpuMat_<T>::colRange(Range r) const
234
return GpuMat_(*this, Range::all(), r);
237
template <typename T>
238
__host__ GpuMat_<T> GpuMat_<T>::operator ()(Range _rowRange, Range _colRange) const
240
return GpuMat_(*this, _rowRange, _colRange);
243
template <typename T>
244
__host__ GpuMat_<T> GpuMat_<T>::operator ()(Rect roi) const
246
return GpuMat_(*this, roi);
249
template <typename T>
250
__host__ GpuMat_<T>& GpuMat_<T>::adjustROI(int dtop, int dbottom, int dleft, int dright)
252
return (GpuMat_<T>&)(GpuMat::adjustROI(dtop, dbottom, dleft, dright));
255
template <typename T>
256
__host__ size_t GpuMat_<T>::elemSize() const
258
CV_DbgAssert( GpuMat::elemSize() == sizeof(T) );
262
template <typename T>
263
__host__ size_t GpuMat_<T>::elemSize1() const
265
CV_DbgAssert( GpuMat::elemSize1() == sizeof(T) / DataType<T>::channels );
266
return sizeof(T) / DataType<T>::channels;
269
template <typename T>
270
__host__ int GpuMat_<T>::type() const
272
CV_DbgAssert( GpuMat::type() == DataType<T>::type );
273
return DataType<T>::type;
276
template <typename T>
277
__host__ int GpuMat_<T>::depth() const
279
CV_DbgAssert( GpuMat::depth() == DataType<T>::depth );
280
return DataType<T>::depth;
283
template <typename T>
284
__host__ int GpuMat_<T>::channels() const
286
CV_DbgAssert( GpuMat::channels() == DataType<T>::channels );
287
return DataType<T>::channels;
290
template <typename T>
291
__host__ size_t GpuMat_<T>::stepT() const
293
return step / elemSize();
296
template <typename T>
297
__host__ size_t GpuMat_<T>::step1() const
299
return step / elemSize1();
302
template <typename T>
303
__host__ T* GpuMat_<T>::operator [](int y)
308
template <typename T>
309
__host__ const T* GpuMat_<T>::operator [](int y) const
311
return (const T*)ptr(y);
314
template <typename T> template <class Body>
315
__host__ GpuMat_<T>::GpuMat_(const Expr<Body>& expr)
318
flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
322
template <typename T> template <class Body>
323
__host__ GpuMat_<T>& GpuMat_<T>::operator =(const Expr<Body>& expr)
325
expr.body.assignTo(*this);
329
template <typename T> template <class Body>
330
__host__ GpuMat_<T>& GpuMat_<T>::assign(const Expr<Body>& expr, Stream& stream)
332
expr.body.assignTo(*this, stream);
338
// Input / Output Arrays
342
template<typename _Tp>
343
__host__ _InputArray::_InputArray(const cudev::GpuMat_<_Tp>& m)
344
: flags(FIXED_TYPE + CUDA_GPU_MAT + DataType<_Tp>::type), obj((void*)&m)
347
template<typename _Tp>
348
__host__ _OutputArray::_OutputArray(cudev::GpuMat_<_Tp>& m)
352
template<typename _Tp>
353
__host__ _OutputArray::_OutputArray(const cudev::GpuMat_<_Tp>& m)