43 #ifndef __OPENCV_GPUMAT_HPP__
44 #define __OPENCV_GPUMAT_HPP__
51 namespace cv {
namespace gpu
94 static bool has(
int major,
int minor);
95 static bool hasPtx(
int major,
int minor);
96 static bool hasBin(
int major,
int minor);
97 static bool hasEqualOrLessPtx(
int major,
int minor);
98 static bool hasEqualOrGreater(
int major,
int minor);
99 static bool hasEqualOrGreaterPtx(
int major,
int minor);
100 static bool hasEqualOrGreaterBin(
int major,
int minor);
113 DeviceInfo(
int device_id) : device_id_(device_id) { query(); }
115 std::string
name()
const {
return name_; }
123 size_t sharedMemPerBlock()
const;
125 void queryMemory(
size_t& totalMemory,
size_t& freeMemory)
const;
126 size_t freeMemory()
const;
127 size_t totalMemory()
const;
133 bool isCompatible()
const;
143 int multi_processor_count_;
189 void upload(
const Mat& m);
192 void download(
Mat& m)
const;
199 GpuMat rowRange(
int startrow,
int endrow)
const;
202 GpuMat colRange(
int startcol,
int endcol)
const;
209 void copyTo(
GpuMat& m)
const;
213 void convertTo(
GpuMat& m,
int rtype,
double alpha = 1,
double beta = 0)
const;
215 void assignTo(
GpuMat& m,
int type=-1)
const;
223 GpuMat reshape(
int cn,
int rows = 0)
const;
227 void create(
int rows,
int cols,
int type);
228 void create(
Size size,
int type);
237 void locateROI(
Size& wholeSize,
Point& ofs)
const;
239 GpuMat& adjustROI(
int dtop,
int dbottom,
int dleft,
int dright);
248 bool isContinuous()
const;
251 size_t elemSize()
const;
253 size_t elemSize1()
const;
261 size_t step1()
const;
273 template<
typename _Tp> _Tp*
ptr(
int y = 0);
274 template<
typename _Tp>
const _Tp*
ptr(
int y = 0)
const;
282 #undef __CV_GPU_DEPR_BEFORE__
283 #undef __CV_GPU_DEPR_AFTER__
327 CV_EXPORTS
void error(
const char* error_string,
const char* file,
const int line,
const char*
func =
"");
341 if (rows_ > 0 && cols_ > 0)
342 create(rows_, cols_, type_);
355 if (rows_ > 0 && cols_ > 0)
357 create(rows_, cols_, type_);
409 return (
const _Tp*)
ptr(y);
454 return GpuMat(*
this, _rowRange, _colRange);
459 return GpuMat(*
this, roi);
469 return CV_ELEM_SIZE(
flags);
474 return CV_ELEM_SIZE1(
flags);
479 return CV_MAT_TYPE(
flags);
484 return CV_MAT_DEPTH(
flags);
489 return CV_MAT_CN(
flags);
499 CV_DbgAssert((
unsigned)y < (
unsigned)
rows);
505 CV_DbgAssert((
unsigned)y < (
unsigned)
rows);
515 template <
class T>
inline GpuMat::operator
PtrStepSz<T>()
const
520 template <
class T>
inline GpuMat::operator PtrStep<T>()
const
525 template <
class T>
inline GpuMat::operator DevMem2D_<T>()
const
530 template <
class T>
inline GpuMat::operator PtrStep_<T>()
const
532 return PtrStep_<T>(
static_cast< DevMem2D_<T>
>(*this));
560 #endif // __cplusplus
562 #endif // __OPENCV_GPUMAT_HPP__
GLdouble GLdouble GLdouble r
Definition: core.hpp:1950
Definition: gpumat.hpp:76
GLenum GLint GLint y
Definition: core_c.h:613
IplImage CvRect * roi
Definition: legacy.hpp:234
CV_EXPORTS void createContinuous(int rows, int cols, int type, GpuMat &m)
Creates continuous GPU matrix.
uchar * dataend
Definition: gpumat.hpp:308
int depth
Definition: core_c.h:73
Definition: gpumat.hpp:78
CV_EXPORTS GpuMat allocMatFromBuf(int rows, int cols, int type, GpuMat &mat)
void copyTo(GpuMat &m) const
copies the GpuMatrix content to "m".
void swap(GpuMat &a, GpuMat &b)
Definition: gpumat.hpp:412
size_t elemSize() const
returns element size in bytes,
Definition: gpumat.hpp:467
Definition: gpumat.hpp:69
Size2i Size
Definition: core.hpp:896
int channels() const
returns element type, similar to CV_MAT_CN(cvMat->type)
Definition: gpumat.hpp:487
int cols
Definition: gpumat.hpp:294
CV_EXPORTS void printCudaDeviceInfo(int device)
CV_EXPORTS void printShortCudaDeviceInfo(int device)
CvCmpFunc func
Definition: core_c.h:1072
GpuMat rowRange(int startrow, int endrow) const
... for the specified row span
Definition: gpumat.hpp:427
GpuMat col(int x) const
returns a new GpuMatrix header for the specified column
Definition: gpumat.hpp:422
static Range all()
Definition: operations.hpp:2219
CV_EXPORTS int getCudaEnabledDeviceCount()
This is the only function that do not throw exceptions if the library is compiled without Cuda...
CvSize size
Definition: calib3d.hpp:212
The 2D range class.
Definition: core.hpp:979
void release()
decreases reference counter;
int deviceID() const
Definition: gpumat.hpp:135
int int int flags
Definition: highgui_c.h:186
GpuMat()
default constructor
Definition: gpumat.hpp:333
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: core_c.h:403
Definition: gpumat.hpp:73
const CvMat const CvMat const CvMat CvMat CvMat CvMat CvMat CvSize CvMat CvMat * T
Definition: calib3d.hpp:270
int majorVersion() const
Definition: gpumat.hpp:118
CV_EXPORTS void resetDevice()
Definition: gpumat.hpp:75
internal::ParamGenerator< T > Range(T start, T end, IncrementT step)
Definition: ts_gtest.h:15869
cv::gpu::DevMem2D_ __CV_GPU_DEPR_AFTER__
void int step
Definition: core_c.h:403
void assignTo(GpuMat &m, int type=-1) const
Definition: gpumat.hpp:384
Definition: gpumat.hpp:79
std::string name() const
Definition: gpumat.hpp:115
The 2D size class.
Definition: core.hpp:81
Definition: cuda_devptrs.hpp:104
GpuMat & operator=(const GpuMat &m)
assignment operators
GpuMat clone() const
returns deep copy of the GpuMatrix, i.e. the data is copied
Definition: gpumat.hpp:377
Definition: gpumat.hpp:80
GLenum GLenum GLvoid * row
FeatureSet
Definition: gpumat.hpp:67
Definition: gpumat.hpp:106
int type() const
returns element type, similar to CV_MAT_TYPE(cvMat->type)
Definition: gpumat.hpp:477
CV_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func="")
CV_EXPORTS int getDevice()
CvArr const CvMat * mat
Definition: core_c.h:700
int flags
includes several bit-fields:
Definition: gpumat.hpp:291
GLclampf GLclampf GLclampf alpha
Definition: core_c.h:687
int depth() const
returns element type, similar to CV_MAT_DEPTH(cvMat->type)
Definition: gpumat.hpp:482
Definition: gpumat.hpp:82
Definition: cuda_devptrs.hpp:138
Definition: gpumat.hpp:72
DeviceInfo(int device_id)
Definition: gpumat.hpp:113
size_t elemSize1() const
returns the size of element channel in bytes.
Definition: gpumat.hpp:472
void create(int rows, int cols, int type)
allocates new GpuMatrix data unless the GpuMatrix already has specified size and type.
Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat...
Definition: gpumat.hpp:154
GLenum GLint x
Definition: core_c.h:632
int * refcount
pointer to the reference counter;
Definition: gpumat.hpp:304
Definition: gpumat.hpp:71
Definition: cuda_devptrs.hpp:89
bool empty() const
returns true if GpuMatrix data is NULL
Definition: gpumat.hpp:397
bool isContinuous() const
returns true iff the GpuMatrix data is continuous
Definition: gpumat.hpp:462
uchar * ptr(int y=0)
returns pointer to y-th row
Definition: gpumat.hpp:497
double const CvArr double beta
Definition: core_c.h:523
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
size_t step
a distance between successive rows in bytes; includes the gap if any
Definition: gpumat.hpp:297
The n-dimensional matrix class.
Definition: core.hpp:1688
GpuMat row(int y) const
returns a new GpuMatrix header for the specified row
Definition: gpumat.hpp:417
int rows
Definition: core_c.h:114
int int y
Definition: highgui_c.h:186
Size size() const
returns GpuMatrix size:
Definition: gpumat.hpp:492
int cols
Definition: core_c.h:109
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
void convertTo(GpuMat &m, int rtype, double alpha=1, double beta=0) const
converts GpuMatrix to another datatype with optional scalng. See cvConvertScale.
int int type
Definition: core_c.h:109
int int channels
Definition: core_c.h:73
GpuMat & setTo(Scalar s, const GpuMat &mask=GpuMat())
sets some of the GpuMatrix elements to s, according to the mask
Definition: gpumat.hpp:81
Definition: gpumat.hpp:70
size_t step1() const
returns step/elemSize1()
Definition: gpumat.hpp:392
template 2D point class.
Definition: core.hpp:82
_Tp width
Definition: core.hpp:840
~GpuMat()
destructor - calls release()
Definition: gpumat.hpp:372
const char * ptr
Definition: core_c.h:942
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
Definition: cuda_devptrs.hpp:167
uchar * datastart
helper fields used in locateROI and adjustROI
Definition: gpumat.hpp:307
Definition: gpumat.hpp:74
unsigned char uchar
Definition: types_c.h:170
GpuMat colRange(int startcol, int endcol) const
... for the specified column span
Definition: gpumat.hpp:437
Definition: core.hpp:1950
uchar * data
pointer to the data
Definition: gpumat.hpp:300
DeviceInfo()
Definition: gpumat.hpp:110
CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, GpuMat &m)
_Tp height
Definition: core.hpp:840
GpuMat operator()(Range rowRange, Range colRange) const
extracts a rectangular sub-GpuMatrix
Definition: gpumat.hpp:452
CV_EXPORTS bool deviceSupports(FeatureSet feature_set)
GLenum GLint GLuint mask
Definition: tracking.hpp:132
void swap(GpuMat &mat)
swaps with other smart pointer
int rows
the number of rows and columns
Definition: gpumat.hpp:294
GLsizeiptr size
Definition: core_c.h:939
int minorVersion() const
Definition: gpumat.hpp:119
int multiProcessorCount() const
Definition: gpumat.hpp:121
Definition: gpumat.hpp:90
CV_EXPORTS void setDevice(int device)
Functions below throw cv::Expception if the library is compiled without Cuda.
CV_EXPORTS_W void line(CV_IN_OUT Mat &img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=8, int shift=0)
draws the line segment (pt1, pt2) in the image