OpenCV 4.11.0
开源计算机视觉
加载中…
搜索中…
无匹配项
cv::cuda::HostMem 类参考

带有引用计数的类,包装了来自 CUDA 的特殊内存类型分配函数。更多…

#include <opencv2/core/cuda.hpp>

cv::cuda::HostMem 的协作图

公共类型

枚举  AllocType {
  PAGE_LOCKED = 1 ,
  SHARED = 2 ,
  WRITE_COMBINED = 4
}
 

公共成员函数

 HostMem (const HostMem &m)
 
 HostMem (HostMem::AllocType alloc_type=HostMem::AllocType::PAGE_LOCKED)
 
 HostMem (InputArray arr, HostMem::AllocType alloc_type=HostMem::AllocType::PAGE_LOCKED)
 从主机内存创建,并复制数据
 
 HostMem (int rows, int cols, int type, HostMem::AllocType alloc_type=HostMem::AllocType::PAGE_LOCKED)
 
 HostMem (Size size, int type, HostMem::AllocType alloc_type=HostMem::AllocType::PAGE_LOCKED)
 
 ~HostMem ()
 
int channels () const
 
HostMem clone () const
 返回矩阵的深拷贝,即数据被复制
 
void create (int rows, int cols, int type)
 除非矩阵已经具有指定的尺寸和类型,否则分配新的矩阵数据。
 
void create (Size size, int type)
 
GpuMat createGpuMatHeader () const
 将 CPU 内存映射到 GPU 地址空间,并创建 cuda::GpuMat 头文件,但不为其进行引用计数。
 
Mat createMatHeader () const
 返回具有禁用引用计数的矩阵头文件,用于 HostMem 数据。
 
int depth () const
 
size_t elemSize () const
 
size_t elemSize1 () const
 
bool empty () const
 
bool isContinuous () const
 
HostMemoperator= (const HostMem &m)
 
void release ()
 递减引用计数,并在需要时释放内存。
 
HostMem reshape (int cn, int rows=0) const
 
Size size () const
 
size_t step1 () const
 
void swap (HostMem &b)
 与其他智能指针交换
 
int type () const
 

公共静态成员函数

static MatAllocatorgetAllocator (HostMem::AllocType alloc_type=HostMem::AllocType::PAGE_LOCKED)
 

公共属性

AllocType alloc_type
 
int cols
 
uchardata
 
const uchardataend
 
uchardatastart
 
int flags
 
int * refcount
 
int rows
 
size_t step
 

详细描述

带有引用计数的类,包装了来自 CUDA 的特殊内存类型分配函数。

它的接口也类似于 Mat,但具有额外的内存类型参数。

  • PAGE_LOCKED 设置页面锁定内存类型,通常用于从 GPU 上传/下载数据的高速异步操作。
  • SHARED 指定零拷贝内存分配,如果支持,则可以将主机内存映射到 GPU 地址空间。
  • WRITE_COMBINED 设置不被 CPU 缓存的写组合缓冲区。此类缓冲区用于在 GPU 只读取数据时向 GPU 提供数据。其优点是更好的 CPU 缓存利用率。
注意
此类内存类型的分配大小通常有限制。有关更多详细信息,请参阅 _CUDA 2.2 固定内存 API_ 文档或 _CUDA C 编程指南_。

成员枚举文档

◆ AllocType

枚举器
PAGE_LOCKED 
共享
写入合并

构造函数和析构函数文档

◆ HostMem() [1/5]

cv::cuda::HostMem::HostMem ( HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED)
显式
Python
cv.cuda.HostMem([, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(rows, cols, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(size, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(arr[, alloc_type]) -> <cuda_HostMem 对象>

◆ HostMem() [2/5]

cv::cuda::HostMem::HostMem ( const HostMem & m)
Python
cv.cuda.HostMem([, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(rows, cols, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(size, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(arr[, alloc_type]) -> <cuda_HostMem 对象>

◆ HostMem() [3/5]

cv::cuda::HostMem::HostMem ( int rows,
int cols,
int type,
HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED )
Python
cv.cuda.HostMem([, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(rows, cols, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(size, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(arr[, alloc_type]) -> <cuda_HostMem 对象>

◆ HostMem() [4/5]

cv::cuda::HostMem::HostMem ( Size size,
int type,
HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED )
Python
cv.cuda.HostMem([, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(rows, cols, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(size, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(arr[, alloc_type]) -> <cuda_HostMem 对象>

◆ HostMem() [5/5]

cv::cuda::HostMem::HostMem ( InputArray arr,
HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED )
显式
Python
cv.cuda.HostMem([, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(rows, cols, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(size, type[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(arr[, alloc_type]) -> <cuda_HostMem 对象>

从主机内存创建,并复制数据

◆ ~HostMem()

cv::cuda::HostMem::~HostMem ( )

成员函数文档

◆ channels()

int cv::cuda::HostMem::channels ( ) const
Python
cv.cuda.HostMem.channels() -> retval

◆ clone()

HostMem cv::cuda::HostMem::clone ( ) const
Python
cv.cuda.HostMem.clone() -> retval

返回矩阵的深拷贝,即数据被复制

◆ create() [1/2]

void cv::cuda::HostMem::create ( int rows,
int cols,
int type )
Python
cv.cuda.HostMem.create(rows, cols, type) -> None

除非矩阵已经具有指定的尺寸和类型,否则分配新的矩阵数据。

◆ create() [2/2]

void cv::cuda::HostMem::create ( Size size,
int type )
Python
cv.cuda.HostMem.create(rows, cols, type) -> None

◆ createGpuMatHeader()

GpuMat cv::cuda::HostMem::createGpuMatHeader ( ) const

将 CPU 内存映射到 GPU 地址空间,并创建 cuda::GpuMat 头文件,但不为其进行引用计数。

只有在使用SHARED标志分配内存并且硬件支持的情况下才能执行此操作。笔记本电脑通常共享视频和CPU内存,因此可以映射地址空间,从而避免额外的复制。

◆ createMatHeader()

Mat cv::cuda::HostMem::createMatHeader ( ) const
Python
cv.cuda.HostMem.createMatHeader() -> retval

返回具有禁用引用计数的矩阵头文件,用于 HostMem 数据。

◆ depth()

int cv::cuda::HostMem::depth ( ) const
Python
cv.cuda.HostMem.depth() -> retval

◆ elemSize()

size_t cv::cuda::HostMem::elemSize ( ) const
Python
cv.cuda.HostMem.elemSize() -> retval

◆ elemSize1()

size_t cv::cuda::HostMem::elemSize1 ( ) const
Python
cv.cuda.HostMem.elemSize1() -> retval

◆ empty()

bool cv::cuda::HostMem::empty ( ) const
Python
cv.cuda.HostMem.empty() -> retval

◆ getAllocator()

static MatAllocator * cv::cuda::HostMem::getAllocator ( HostMem::AllocType alloc_type = HostMem::AllocType::PAGE_LOCKED)
static

◆ isContinuous()

bool cv::cuda::HostMem::isContinuous ( ) const
Python
cv.cuda.HostMem.isContinuous() -> retval

◆ operator=()

HostMem & cv::cuda::HostMem::operator= ( const HostMem & m)

◆ release()

void cv::cuda::HostMem::release ( )

递减引用计数,并在需要时释放内存。

◆ reshape()

HostMem cv::cuda::HostMem::reshape ( int cn,
int rows = 0 ) const
Python
cv.cuda.HostMem.reshape(cn[, rows]) -> retval

为相同数据创建具有不同通道数和/或不同行数的替代HostMem 头。

◆ size()

Size cv::cuda::HostMem::size ( ) const
Python
cv.cuda.HostMem.size() -> retval

◆ step1()

size_t cv::cuda::HostMem::step1 ( ) const
Python
cv.cuda.HostMem.step1() -> retval

◆ swap()

void cv::cuda::HostMem::swap ( HostMem & b)
Python
cv.cuda.HostMem.swap(b) -> None

与其他智能指针交换

◆ type()

int cv::cuda::HostMem::type ( ) const
Python
cv.cuda.HostMem.type() -> retval

成员数据文档

◆ alloc_type

AllocType cv::cuda::HostMem::alloc_type

◆ cols

int cv::cuda::HostMem::cols

◆ data

uchar* cv::cuda::HostMem::data

◆ dataend

const uchar* cv::cuda::HostMem::dataend

◆ datastart

uchar* cv::cuda::HostMem::datastart

◆ flags

int cv::cuda::HostMem::flags

◆ refcount

int* cv::cuda::HostMem::refcount

◆ rows

int cv::cuda::HostMem::rows

◆ step

size_t cv::cuda::HostMem::step

此类的文档是从以下文件生成的: