OpenCV 4.12.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 Pinned Memory APIs 文档或 CUDA C Programming Guide

成员枚举文档

◆ AllocType

枚举器
PAGE_LOCKED 
SHARED 
WRITE_COMBINED 

构造函数 & 析构函数文档

◆ 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(行数, 列数, 类型[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(尺寸, 类型[, 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(行数, 列数, 类型[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(尺寸, 类型[, 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(行数, 列数, 类型[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(尺寸, 类型[, 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(行数, 列数, 类型[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(尺寸, 类型[, 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(行数, 列数, 类型[, alloc_type]) -> <cuda_HostMem 对象>
cv.cuda.HostMem(尺寸, 类型[, 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) ->

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

◆ create() [2/2]

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

◆ 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) ->

与其它智能指针交换

◆ 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

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