~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/modules/cudev/include/opencv2/cudev/ptr2d/detail/gpumat.hpp

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*M///////////////////////////////////////////////////////////////////////////////////////
 
2
//
 
3
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
 
4
//
 
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.
 
8
//
 
9
//
 
10
//                          License Agreement
 
11
//                For Open Source Computer Vision Library
 
12
//
 
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.
 
17
//
 
18
// Redistribution and use in source and binary forms, with or without modification,
 
19
// are permitted provided that the following conditions are met:
 
20
//
 
21
//   * Redistribution's of source code must retain the above copyright notice,
 
22
//     this list of conditions and the following disclaimer.
 
23
//
 
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.
 
27
//
 
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.
 
30
//
 
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.
 
41
//
 
42
//M*/
 
43
 
 
44
#pragma once
 
45
 
 
46
#ifndef __OPENCV_CUDEV_PTR2D_GPUMAT_DETAIL_HPP__
 
47
#define __OPENCV_CUDEV_PTR2D_GPUMAT_DETAIL_HPP__
 
48
 
 
49
#include "../gpumat.hpp"
 
50
 
 
51
namespace cv { namespace cudev {
 
52
 
 
53
template <typename T>
 
54
__host__ GpuMat_<T>::GpuMat_(Allocator* allocator)
 
55
    : GpuMat(allocator)
 
56
{
 
57
    flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
 
58
}
 
59
 
 
60
template <typename T>
 
61
__host__ GpuMat_<T>::GpuMat_(int arows, int acols, Allocator* allocator)
 
62
    : GpuMat(arows, acols, DataType<T>::type, allocator)
 
63
{
 
64
}
 
65
 
 
66
template <typename T>
 
67
__host__ GpuMat_<T>::GpuMat_(Size asize, Allocator* allocator)
 
68
    : GpuMat(asize.height, asize.width, DataType<T>::type, allocator)
 
69
{
 
70
}
 
71
 
 
72
template <typename T>
 
73
__host__ GpuMat_<T>::GpuMat_(int arows, int acols, Scalar val, Allocator* allocator)
 
74
    : GpuMat(arows, acols, DataType<T>::type, val, allocator)
 
75
{
 
76
}
 
77
 
 
78
template <typename T>
 
79
__host__ GpuMat_<T>::GpuMat_(Size asize, Scalar val, Allocator* allocator)
 
80
    : GpuMat(asize.height, asize.width, DataType<T>::type, val, allocator)
 
81
{
 
82
}
 
83
 
 
84
template <typename T>
 
85
__host__ GpuMat_<T>::GpuMat_(const GpuMat_& m)
 
86
    : GpuMat(m)
 
87
{
 
88
}
 
89
 
 
90
template <typename T>
 
91
__host__ GpuMat_<T>::GpuMat_(const GpuMat& m, Allocator* allocator)
 
92
    : GpuMat(allocator)
 
93
{
 
94
    flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
 
95
 
 
96
    if (DataType<T>::type == m.type())
 
97
    {
 
98
        GpuMat::operator =(m);
 
99
        return;
 
100
    }
 
101
 
 
102
    if (DataType<T>::depth == m.depth())
 
103
    {
 
104
        GpuMat::operator =(m.reshape(DataType<T>::channels, m.rows));
 
105
        return;
 
106
    }
 
107
 
 
108
    CV_Assert( DataType<T>::channels == m.channels() );
 
109
    m.convertTo(*this, type());
 
110
}
 
111
 
 
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)
 
115
{
 
116
}
 
117
 
 
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)
 
121
{
 
122
}
 
123
 
 
124
template <typename T>
 
125
__host__ GpuMat_<T>::GpuMat_(const GpuMat_& m, Range arowRange, Range acolRange)
 
126
    : GpuMat(m, arowRange, acolRange)
 
127
{
 
128
}
 
129
 
 
130
template <typename T>
 
131
__host__ GpuMat_<T>::GpuMat_(const GpuMat_& m, Rect roi)
 
132
    : GpuMat(m, roi)
 
133
{
 
134
}
 
135
 
 
136
template <typename T>
 
137
__host__ GpuMat_<T>::GpuMat_(InputArray arr, Allocator* allocator)
 
138
    : GpuMat(allocator)
 
139
{
 
140
    flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
 
141
    upload(arr);
 
142
}
 
143
 
 
144
template <typename T>
 
145
__host__ GpuMat_<T>& GpuMat_<T>::operator =(const GpuMat_& m)
 
146
{
 
147
    GpuMat::operator =(m);
 
148
    return *this;
 
149
}
 
150
 
 
151
template <typename T>
 
152
__host__ void GpuMat_<T>::create(int arows, int acols)
 
153
{
 
154
    GpuMat::create(arows, acols, DataType<T>::type);
 
155
}
 
156
 
 
157
template <typename T>
 
158
__host__ void GpuMat_<T>::create(Size asize)
 
159
{
 
160
    GpuMat::create(asize, DataType<T>::type);
 
161
}
 
162
 
 
163
template <typename T>
 
164
__host__ void GpuMat_<T>::swap(GpuMat_& mat)
 
165
{
 
166
    GpuMat::swap(mat);
 
167
}
 
168
 
 
169
template <typename T>
 
170
__host__ void GpuMat_<T>::upload(InputArray arr)
 
171
{
 
172
    CV_Assert( arr.type() == DataType<T>::type );
 
173
    GpuMat::upload(arr);
 
174
}
 
175
 
 
176
template <typename T>
 
177
__host__ void GpuMat_<T>::upload(InputArray arr, Stream& stream)
 
178
{
 
179
    CV_Assert( arr.type() == DataType<T>::type );
 
180
    GpuMat::upload(arr, stream);
 
181
}
 
182
 
 
183
template <typename T>
 
184
__host__ GpuMat_<T>::operator GlobPtrSz<T>() const
 
185
{
 
186
    return globPtr((T*) data, step, rows, cols);
 
187
}
 
188
 
 
189
template <typename T>
 
190
__host__ GpuMat_<T>::operator GlobPtr<T>() const
 
191
{
 
192
    return globPtr((T*) data, step);
 
193
}
 
194
 
 
195
template <typename T>
 
196
__host__ GpuMat_<T> GpuMat_<T>::clone() const
 
197
{
 
198
    return GpuMat_(GpuMat::clone());
 
199
}
 
200
 
 
201
template <typename T>
 
202
__host__ GpuMat_<T> GpuMat_<T>::row(int y) const
 
203
{
 
204
    return GpuMat_(*this, Range(y, y+1), Range::all());
 
205
}
 
206
 
 
207
template <typename T>
 
208
__host__ GpuMat_<T> GpuMat_<T>::col(int x) const
 
209
{
 
210
    return GpuMat_(*this, Range::all(), Range(x, x+1));
 
211
}
 
212
 
 
213
template <typename T>
 
214
__host__ GpuMat_<T> GpuMat_<T>::rowRange(int startrow, int endrow) const
 
215
{
 
216
    return GpuMat_(*this, Range(startrow, endrow), Range::all());
 
217
}
 
218
 
 
219
template <typename T>
 
220
__host__ GpuMat_<T> GpuMat_<T>::rowRange(Range r) const
 
221
{
 
222
    return GpuMat_(*this, r, Range::all());
 
223
}
 
224
 
 
225
template <typename T>
 
226
__host__ GpuMat_<T> GpuMat_<T>::colRange(int startcol, int endcol) const
 
227
{
 
228
    return GpuMat_(*this, Range::all(), Range(startcol, endcol));
 
229
}
 
230
 
 
231
template <typename T>
 
232
__host__ GpuMat_<T> GpuMat_<T>::colRange(Range r) const
 
233
{
 
234
    return GpuMat_(*this, Range::all(), r);
 
235
}
 
236
 
 
237
template <typename T>
 
238
__host__ GpuMat_<T> GpuMat_<T>::operator ()(Range _rowRange, Range _colRange) const
 
239
{
 
240
    return GpuMat_(*this, _rowRange, _colRange);
 
241
}
 
242
 
 
243
template <typename T>
 
244
__host__ GpuMat_<T> GpuMat_<T>::operator ()(Rect roi) const
 
245
{
 
246
    return GpuMat_(*this, roi);
 
247
}
 
248
 
 
249
template <typename T>
 
250
__host__ GpuMat_<T>& GpuMat_<T>::adjustROI(int dtop, int dbottom, int dleft, int dright)
 
251
{
 
252
    return (GpuMat_<T>&)(GpuMat::adjustROI(dtop, dbottom, dleft, dright));
 
253
}
 
254
 
 
255
template <typename T>
 
256
__host__ size_t GpuMat_<T>::elemSize() const
 
257
{
 
258
    CV_DbgAssert( GpuMat::elemSize() == sizeof(T) );
 
259
    return sizeof(T);
 
260
}
 
261
 
 
262
template <typename T>
 
263
__host__ size_t GpuMat_<T>::elemSize1() const
 
264
{
 
265
    CV_DbgAssert( GpuMat::elemSize1() == sizeof(T) / DataType<T>::channels );
 
266
    return sizeof(T) / DataType<T>::channels;
 
267
}
 
268
 
 
269
template <typename T>
 
270
__host__ int GpuMat_<T>::type() const
 
271
{
 
272
    CV_DbgAssert( GpuMat::type() == DataType<T>::type );
 
273
    return DataType<T>::type;
 
274
}
 
275
 
 
276
template <typename T>
 
277
__host__ int GpuMat_<T>::depth() const
 
278
{
 
279
    CV_DbgAssert( GpuMat::depth() == DataType<T>::depth );
 
280
    return DataType<T>::depth;
 
281
}
 
282
 
 
283
template <typename T>
 
284
__host__ int GpuMat_<T>::channels() const
 
285
{
 
286
    CV_DbgAssert( GpuMat::channels() == DataType<T>::channels );
 
287
    return DataType<T>::channels;
 
288
}
 
289
 
 
290
template <typename T>
 
291
__host__ size_t GpuMat_<T>::stepT() const
 
292
{
 
293
    return step / elemSize();
 
294
}
 
295
 
 
296
template <typename T>
 
297
__host__ size_t GpuMat_<T>::step1() const
 
298
{
 
299
    return step / elemSize1();
 
300
}
 
301
 
 
302
template <typename T>
 
303
__host__ T* GpuMat_<T>::operator [](int y)
 
304
{
 
305
    return (T*)ptr(y);
 
306
}
 
307
 
 
308
template <typename T>
 
309
__host__ const T* GpuMat_<T>::operator [](int y) const
 
310
{
 
311
    return (const T*)ptr(y);
 
312
}
 
313
 
 
314
template <typename T> template <class Body>
 
315
__host__ GpuMat_<T>::GpuMat_(const Expr<Body>& expr)
 
316
    : GpuMat()
 
317
{
 
318
    flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<T>::type;
 
319
    *this = expr;
 
320
}
 
321
 
 
322
template <typename T> template <class Body>
 
323
__host__ GpuMat_<T>& GpuMat_<T>::operator =(const Expr<Body>& expr)
 
324
{
 
325
    expr.body.assignTo(*this);
 
326
    return *this;
 
327
}
 
328
 
 
329
template <typename T> template <class Body>
 
330
__host__ GpuMat_<T>& GpuMat_<T>::assign(const Expr<Body>& expr, Stream& stream)
 
331
{
 
332
    expr.body.assignTo(*this, stream);
 
333
    return *this;
 
334
}
 
335
 
 
336
}}
 
337
 
 
338
// Input / Output Arrays
 
339
 
 
340
namespace cv {
 
341
 
 
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)
 
345
{}
 
346
 
 
347
template<typename _Tp>
 
348
__host__ _OutputArray::_OutputArray(cudev::GpuMat_<_Tp>& m)
 
349
    : _InputArray(m)
 
350
{}
 
351
 
 
352
template<typename _Tp>
 
353
__host__ _OutputArray::_OutputArray(const cudev::GpuMat_<_Tp>& m)
 
354
    : _InputArray(m)
 
355
{
 
356
    flags |= FIXED_SIZE;
 
357
}
 
358
 
 
359
}
 
360
 
 
361
#endif