EstervQrCode 2.0.0
Library for qr code manipulation
Loading...
Searching...
No Matches
cuda_types.hpp
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// Third party copyrights are property of their respective owners.
16//
17// Redistribution and use in source and binary forms, with or without modification,
18// are permitted provided that the following conditions are met:
19//
20// * Redistribution's of source code must retain the above copyright notice,
21// this list of conditions and the following disclaimer.
22//
23// * Redistribution's in binary form must reproduce the above copyright notice,
24// this list of conditions and the following disclaimer in the documentation
25// and/or other materials provided with the distribution.
26//
27// * The name of the copyright holders may not be used to endorse or promote products
28// derived from this software without specific prior written permission.
29//
30// This software is provided by the copyright holders and contributors "as is" and
31// any express or implied warranties, including, but not limited to, the implied
32// warranties of merchantability and fitness for a particular purpose are disclaimed.
33// In no event shall the Intel Corporation or contributors be liable for any direct,
34// indirect, incidental, special, exemplary, or consequential damages
35// (including, but not limited to, procurement of substitute goods or services;
36// loss of use, data, or profits; or business interruption) however caused
37// and on any theory of liability, whether in contract, strict liability,
38// or tort (including negligence or otherwise) arising in any way out of
39// the use of this software, even if advised of the possibility of such damage.
40//
41//M*/
42
43#ifndef OPENCV_CORE_CUDA_TYPES_HPP
44#define OPENCV_CORE_CUDA_TYPES_HPP
45
46#ifndef __cplusplus
47# error cuda_types.hpp header must be compiled as C++
48#endif
49
50#if defined(__OPENCV_BUILD) && defined(__clang__)
51#pragma clang diagnostic ignored "-Winconsistent-missing-override"
52#endif
53#if defined(__OPENCV_BUILD) && defined(__GNUC__) && __GNUC__ >= 5
54#pragma GCC diagnostic ignored "-Wsuggest-override"
55#endif
56
62
63#ifdef __CUDACC__
64 #define __CV_CUDA_HOST_DEVICE__ __host__ __device__ __forceinline__
65#else
66 #define __CV_CUDA_HOST_DEVICE__
67#endif
68
69namespace cv
70{
71 namespace cuda
72 {
73
74 // Simple lightweight structures that encapsulates information about an image on device.
75 // It is intended to pass to nvcc-compiled code. GpuMat depends on headers that nvcc can't compile
76
77 template <typename T> struct DevPtr
78 {
79 typedef T elem_type;
80 typedef int index_type;
81
82 enum { elem_size = sizeof(elem_type) };
83
84 T* data;
85
86 __CV_CUDA_HOST_DEVICE__ DevPtr() : data(0) {}
87 __CV_CUDA_HOST_DEVICE__ DevPtr(T* data_) : data(data_) {}
88
89 __CV_CUDA_HOST_DEVICE__ size_t elemSize() const { return elem_size; }
90 __CV_CUDA_HOST_DEVICE__ operator T*() { return data; }
91 __CV_CUDA_HOST_DEVICE__ operator const T*() const { return data; }
92 };
93
94 template <typename T> struct PtrSz : public DevPtr<T>
95 {
96 __CV_CUDA_HOST_DEVICE__ PtrSz() : size(0) {}
97 __CV_CUDA_HOST_DEVICE__ PtrSz(T* data_, size_t size_) : DevPtr<T>(data_), size(size_) {}
98
99 size_t size;
100 };
101
102 template <typename T> struct PtrStep : public DevPtr<T>
103 {
104 __CV_CUDA_HOST_DEVICE__ PtrStep() : step(0) {}
105 __CV_CUDA_HOST_DEVICE__ PtrStep(T* data_, size_t step_) : DevPtr<T>(data_), step(step_) {}
106
107 size_t step;
108
109 __CV_CUDA_HOST_DEVICE__ T* ptr(int y = 0) { return ( T*)( ( char*)(((DevPtr<T>*)this)->data) + y * step); }
110 __CV_CUDA_HOST_DEVICE__ const T* ptr(int y = 0) const { return (const T*)( (const char*)(((DevPtr<T>*)this)->data) + y * step); }
111
112 __CV_CUDA_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; }
113 __CV_CUDA_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; }
114 };
115
116 template <typename T> struct PtrStepSz : public PtrStep<T>
117 {
118 __CV_CUDA_HOST_DEVICE__ PtrStepSz() : cols(0), rows(0) {}
119 __CV_CUDA_HOST_DEVICE__ PtrStepSz(int rows_, int cols_, T* data_, size_t step_)
120 : PtrStep<T>(data_, step_), cols(cols_), rows(rows_) {}
121
122 template <typename U>
123 explicit PtrStepSz(const PtrStepSz<U>& d) : PtrStep<T>((T*)d.data, d.step), cols(d.cols), rows(d.rows){}
124
125 int cols;
126 int rows;
127 };
128
129 typedef PtrStepSz<unsigned char> PtrStepSzb;
130 typedef PtrStepSz<unsigned short> PtrStepSzus;
131 typedef PtrStepSz<float> PtrStepSzf;
132 typedef PtrStepSz<int> PtrStepSzi;
133
134 typedef PtrStep<unsigned char> PtrStepb;
135 typedef PtrStep<unsigned short> PtrStepus;
136 typedef PtrStep<float> PtrStepf;
137 typedef PtrStep<int> PtrStepi;
138
139 }
140}
141
143
144#endif /* OPENCV_CORE_CUDA_TYPES_HPP */
InputArrayOfArrays InputArrayOfArrays InputOutputArray InputOutputArray InputOutputArray InputOutputArray Size InputOutputArray InputOutputArray T
Definition calib3d.hpp:1867
int rows
Definition core_c.h:257
int cols
Definition core_c.h:221
CvSize size
Definition core_c.h:112
void int step
Definition core_c.h:905
void * data
Definition core_c.h:427
const CvArr CvArr * x
Definition core_c.h:1195
size_t size_t elem_size
Definition core_c.h:1587
const CvArr * y
Definition core_c.h:1187
"black box" representation of the file storage associated with a file on disk.
Definition calib3d.hpp:441