44#ifndef OPENCV_CORE_CUDAINL_HPP
45#define OPENCV_CORE_CUDAINL_HPP
47#include "opencv2/core/cuda.hpp"
51namespace cv {
namespace cuda {
59 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
63GpuMat::GpuMat(
int rows_,
int cols_,
int type_, Allocator* allocator_)
64 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
66 if (rows_ > 0 && cols_ > 0)
67 create(rows_, cols_, type_);
71GpuMat::GpuMat(Size size_,
int type_, Allocator* allocator_)
72 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
74 if (size_.height > 0 && size_.width > 0)
75 create(size_.height, size_.width, type_);
79#if defined _MSC_VER && _MSC_VER >= 1920
81#pragma warning(disable: 4702)
84GpuMat::GpuMat(
int rows_,
int cols_,
int type_, Scalar s_, Allocator* allocator_)
85 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
87 if (rows_ > 0 && cols_ > 0)
89 create(rows_, cols_, type_);
95GpuMat::GpuMat(Size size_,
int type_, Scalar s_, Allocator* allocator_)
96 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
98 if (size_.height > 0 && size_.width > 0)
100 create(size_.height, size_.width, type_);
104#if defined _MSC_VER && _MSC_VER >= 1920
109GpuMat::GpuMat(
const GpuMat& m)
113 CV_XADD(refcount, 1);
117GpuMat::GpuMat(InputArray
arr, Allocator* allocator_) :
118 flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), allocator(allocator_)
130GpuMat& GpuMat::operator =(
const GpuMat& m)
142void GpuMat::create(Size size_,
int type_)
144 create(size_.height, size_.width, type_);
148void GpuMat::swap(GpuMat& b)
162GpuMat GpuMat::clone()
const
170#if defined _MSC_VER && _MSC_VER >= 1920
172#pragma warning(disable: 4702)
175void GpuMat::copyTo(OutputArray
dst, InputArray
mask)
const
179#if defined _MSC_VER && _MSC_VER >= 1920
184GpuMat& GpuMat::setTo(Scalar s)
186 return setTo(s, Stream::Null());
190GpuMat& GpuMat::setTo(Scalar s, InputArray
mask)
192 return setTo(s,
mask, Stream::Null());
196#if defined _MSC_VER && _MSC_VER >= 1920
198#pragma warning(disable: 4702)
201void GpuMat::convertTo(OutputArray
dst,
int rtype)
const
203 convertTo(
dst, rtype, Stream::Null());
207void GpuMat::convertTo(OutputArray
dst,
int rtype,
double alpha,
double beta)
const
211#if defined _MSC_VER && _MSC_VER >= 1920
216void GpuMat::convertTo(OutputArray
dst,
int rtype,
double alpha, Stream& stream)
const
218 convertTo(
dst, rtype,
alpha, 0.0, stream);
222void GpuMat::assignTo(GpuMat& m,
int _type)
const
238const uchar* GpuMat::ptr(
int y)
const
244template<
typename _Tp>
inline
245_Tp* GpuMat::ptr(
int y)
250template<
typename _Tp>
inline
251const _Tp* GpuMat::ptr(
int y)
const
253 return (
const _Tp*)ptr(
y);
256template <
class T>
inline
257GpuMat::operator PtrStepSz<T>()
const
262template <
class T>
inline
263GpuMat::operator PtrStep<T>()
const
269GpuMat GpuMat::row(
int y)
const
271 return GpuMat(*
this, Range(
y,
y+1), Range::all());
275GpuMat GpuMat::col(
int x)
const
277 return GpuMat(*
this, Range::all(), Range(
x,
x+1));
281GpuMat GpuMat::rowRange(
int startrow,
int endrow)
const
283 return GpuMat(*
this, Range(startrow, endrow), Range::all());
287GpuMat GpuMat::rowRange(Range
r)
const
289 return GpuMat(*
this,
r, Range::all());
293GpuMat GpuMat::colRange(
int startcol,
int endcol)
const
295 return GpuMat(*
this, Range::all(), Range(startcol, endcol));
299GpuMat GpuMat::colRange(Range
r)
const
301 return GpuMat(*
this, Range::all(),
r);
305GpuMat GpuMat::operator ()(Range rowRange_, Range colRange_)
const
307 return GpuMat(*
this, rowRange_, colRange_);
311GpuMat GpuMat::operator ()(Rect roi)
const
313 return GpuMat(*
this, roi);
317bool GpuMat::isContinuous()
const
319 return (
flags & Mat::CONTINUOUS_FLAG) != 0;
323size_t GpuMat::elemSize()
const
329size_t GpuMat::elemSize1()
const
335int GpuMat::type()
const
341int GpuMat::depth()
const
347int GpuMat::channels()
const
353size_t GpuMat::step1()
const
355 return step / elemSize1();
359Size GpuMat::size()
const
365bool GpuMat::empty()
const
371void* GpuMat::cudaPtr()
const
405void swap(GpuMat& a, GpuMat& b)
415GpuMatND::GpuMatND() :
421GpuMatND::GpuMatND(SizeArray _size,
int _type) :
428void GpuMatND::swap(GpuMatND& m)
noexcept
434bool GpuMatND::isContinuous()
const
436 return (
flags & Mat::CONTINUOUS_FLAG) != 0;
440bool GpuMatND::isSubmatrix()
const
442 return (
flags & Mat::SUBMATRIX_FLAG) != 0;
446size_t GpuMatND::elemSize()
const
452size_t GpuMatND::elemSize1()
const
458bool GpuMatND::empty()
const
460 return data ==
nullptr;
464bool GpuMatND::external()
const
466 return !empty() && data_.use_count() == 0;
470uchar* GpuMatND::getDevicePtr()
const
476size_t GpuMatND::total()
const
485size_t GpuMatND::totalMemSize()
const
491int GpuMatND::type()
const
501HostMem::HostMem(AllocType alloc_type_)
502 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
507HostMem::HostMem(
const HostMem& m)
511 CV_XADD(refcount, 1);
515HostMem::HostMem(
int rows_,
int cols_,
int type_, AllocType alloc_type_)
516 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
518 if (rows_ > 0 && cols_ > 0)
519 create(rows_, cols_, type_);
523HostMem::HostMem(Size size_,
int type_, AllocType alloc_type_)
524 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
526 if (size_.height > 0 && size_.width > 0)
527 create(size_.height, size_.width, type_);
531HostMem::HostMem(InputArray
arr, AllocType alloc_type_)
532 :
flags(0),
rows(0),
cols(0),
step(0),
data(0), refcount(0), datastart(0), dataend(0), alloc_type(alloc_type_)
534 arr.getMat().copyTo(*
this);
544HostMem& HostMem::operator =(
const HostMem& m)
556void HostMem::swap(HostMem& b)
570HostMem HostMem::clone()
const
572 HostMem m(
size(),
type(), alloc_type);
573 createMatHeader().copyTo(m);
578void HostMem::create(Size size_,
int type_)
580 create(size_.height, size_.width, type_);
584Mat HostMem::createMatHeader()
const
590bool HostMem::isContinuous()
const
592 return (
flags & Mat::CONTINUOUS_FLAG) != 0;
596size_t HostMem::elemSize()
const
602size_t HostMem::elemSize1()
const
608int HostMem::type()
const
614int HostMem::depth()
const
620int HostMem::channels()
const
626size_t HostMem::step1()
const
628 return step / elemSize1();
632Size HostMem::size()
const
638bool HostMem::empty()
const
644void swap(HostMem& a, HostMem& b)
654Stream::Stream(
const Ptr<Impl>& impl)
664Event::Event(
const Ptr<Impl>& impl)
674#if defined _MSC_VER && _MSC_VER >= 1920
676#pragma warning(disable: 4702)
679bool TargetArchs::has(
int major,
int minor)
681 return hasPtx(major, minor) || hasBin(major, minor);
685bool TargetArchs::hasEqualOrGreater(
int major,
int minor)
687 return hasEqualOrGreaterPtx(major, minor) || hasEqualOrGreaterBin(major, minor);
691DeviceInfo::DeviceInfo()
695#if defined _MSC_VER && _MSC_VER >= 1920
700DeviceInfo::DeviceInfo(
int device_id)
703 device_id_ = device_id;
707#if defined _MSC_VER && _MSC_VER >= 1920
709#pragma warning(disable: 4702)
712int DeviceInfo::deviceID()
const
718size_t DeviceInfo::freeMemory()
const
720 size_t _totalMemory = 0, _freeMemory = 0;
721 queryMemory(_totalMemory, _freeMemory);
726size_t DeviceInfo::totalMemory()
const
728 size_t _totalMemory = 0, _freeMemory = 0;
729 queryMemory(_totalMemory, _freeMemory);
734bool DeviceInfo::supports(FeatureSet feature_set)
const
736 int version = majorVersion() * 10 + minorVersion();
737 return version >= feature_set;
739#if defined _MSC_VER && _MSC_VER >= 1920
754 :
flags(0),
dims(0),
rows(0),
cols(0),
data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0),
size(&
rows)
CV_WRAP GpuMat(GpuMat::Allocator *allocator=GpuMat::defaultAllocator())
default constructor
InputArrayOfArrays Size InputOutputArray InputOutputArray OutputArrayOfArrays OutputArrayOfArrays OutputArray OutputArray OutputArray int flags
Definition calib3d.hpp:1617
void CV_EXPORTS_W copyTo(InputArray src, OutputArray dst, InputArray mask)
This is an overloaded member function, provided for convenience (python) Copies the matrix to another...
Size2i Size
Definition types.hpp:370
int rows
Definition core_c.h:257
const CvArr const CvArr const CvArr CvArr int flags
Definition core_c.h:1342
CvArr * dst
Definition core_c.h:875
int cols
Definition core_c.h:221
double const CvArr double beta
Definition core_c.h:1094
CvSize size
Definition core_c.h:112
int int type
Definition core_c.h:221
void int step
Definition core_c.h:905
CvArr const CvArr * mask
Definition core_c.h:589
CvArr * arr
Definition core_c.h:1247
void * data
Definition core_c.h:427
const CvArr CvArr * x
Definition core_c.h:1195
double alpha
Definition core_c.h:1093
int dims
Definition core_c.h:464
const CvArr * y
Definition core_c.h:1187
#define CV_MAT_DEPTH(flags)
Definition interface.h:83
unsigned char uchar
Definition interface.h:51
#define CV_ELEM_SIZE1(type)
Definition cvdef.h:508
#define CV_MAT_CN(flags)
Definition cvdef.h:495
#define CV_MAT_TYPE(flags)
Definition cvdef.h:497
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails.
Definition base.hpp:342
#define CV_DbgAssert(expr)
Definition base.hpp:375
#define CV_ELEM_SIZE(type)
Definition cvdef.h:510
CV_EXPORTS_W int getDevice()
Returns the current device index set by cuda::setDevice or initialized by default.
CV_EXPORTS_W int getCudaEnabledDeviceCount()
Returns the number of installed CUDA-enabled devices.
CV_EXPORTS_W void createContinuous(int rows, int cols, int type, OutputArray arr)
Creates a continuous matrix.
CV_EXPORTS_W void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr)
Ensures that the size of a matrix is big enough and the matrix has a proper type.
CvRect r
Definition imgproc_c.h:984
CvArr CvPoint offset
Definition imgproc_c.h:88
CvArr CvArr * temp
Definition imgproc_c.h:329
"black box" representation of the file storage associated with a file on disk.
Definition calib3d.hpp:441
int width
Definition types_c.h:1159
int height
Definition types_c.h:1160