openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

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?

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