OpenCV 4.11.0
开源计算机视觉库
加载中…
搜索中…
无匹配项
结构分析和形状描述符

详细描述

枚举

枚举  cv::cuda::MomentsOrder {
  cv::cuda::FIRST_ORDER_MOMENTS = 1 ,
  cv::cuda::SECOND_ORDER_MOMENTS = 2 ,
  cv::cuda::THIRD_ORDER_MOMENTS = 3
}
 图像矩的阶数。 更多…
 

函数

Moments cv::cuda::convertSpatialMoments (Mat spatialMoments, const MomentsOrder order, const int momentsType)
 将从 cuda::spatialMoments 返回的空间图像矩转换为 cv::Moments
 
Moments cv::cuda::moments (InputArray src, const bool binaryImage=false, const MomentsOrder order=MomentsOrder::THIRD_ORDER_MOMENTS, const int momentsType=CV_64F)
 计算栅格化形状最多 3 阶的所有矩。
 
int cv::cuda::numMoments (const MomentsOrder order)
 返回小于或等于最大图像矩 *order* 的图像矩的数量。
 
void cv::cuda::spatialMoments (InputArray src, OutputArray moments, const bool binaryImage=false, const MomentsOrder order=MomentsOrder::THIRD_ORDER_MOMENTS, const int momentsType=CV_64F, Stream &stream=Stream::Null())
 计算栅格化形状最多 3 阶的所有空间矩。
 

枚举类型文档

◆ MomentsOrder

#include <opencv2/cudaimgproc.hpp>

图像矩的阶数。

参数
FIRST_ORDER_MOMENTS一阶矩
SECOND_ORDER_MOMENTS二阶矩。
THIRD_ORDER_MOMENTS三阶矩。
枚举值
FIRST_ORDER_MOMENTS 
SECOND_ORDER_MOMENTS 
THIRD_ORDER_MOMENTS 

函数文档

◆ convertSpatialMoments()

Moments cv::cuda::convertSpatialMoments ( Mat spatialMoments,
const MomentsOrder order,
const int momentsType )

#include <opencv2/cudaimgproc.hpp>

将从 cuda::spatialMoments 返回的空间图像矩转换为 cv::Moments

参数
spatialMomentscuda::spatialMoments 返回的空间矩。
order使用 cuda::spatialMoments 计算图像矩时使用的阶数。
momentsType使用 cuda::spatialMoments 计算图像矩时使用的精度。
返回值
cv::Moments.
参见
cuda::spatialMoments, cuda::moments, cuda::convertSpatialMoments, cuda::numMoments, cuda::MomentsOrder

◆ moments()

Moments cv::cuda::moments ( InputArray src,
const bool binaryImage = false,
const MomentsOrder order = MomentsOrder::THIRD_ORDER_MOMENTS,
const int momentsType = CV_64F )

#include <opencv2/cudaimgproc.hpp>

计算栅格化形状最多 3 阶的所有矩。

该函数计算栅格化形状最多 3 阶的矩。结果以 cv::Moments 结构体的形式返回。

参数
src栅格图像(单通道二维数组)。
binaryImage如果为真,则所有非零图像像素都视为 1。
order要计算的最大矩的阶数,低阶矩需要较少的计算。
momentsType计算矩时使用的精度。可用类型为 CV_32FCV_64FCV_32F 的性能比 CV_64F 高一个数量级。如果图像较小,则 CV_32F 的精度可以等于或非常接近 CV_64F
注意
为了获得最佳性能,请使用异步版本 cuda::spatialMoments(),因为此版本在内部分配和释放 GpuMatHostMem,分别在设备上执行计算并将结果下载到主机。代价高昂的 HostMem 分配是不可避免的,但是可以通过使用 BufferPool 来避免 GpuMat 设备分配,例如:
setBufferPoolConfig(getDevice(), numMoments(order) * ((momentsType == CV_64F) ? sizeof(double) : sizeof(float)), 1);
#define CV_64F
定义 interface.h:79
int getDevice()
返回由cuda::setDevice设置或默认初始化的当前设备索引。
void setBufferPoolUsage(bool on)
BufferPool管理(必须在创建Stream之前调用)
void setBufferPoolConfig(int deviceId, size_t stackSize, int stackCount)
int numMoments(const MomentsOrder order)
返回小于或等于最大图像矩阶数的图像矩数。
参见opencv_contrib_source_code/modules/cudaimgproc/test/test_moments.cpp中的CUDA_TEST_P(Moments, Accuracy)测试示例。
返回值
cv::Moments.
参见
cuda::spatialMomentscuda::convertSpatialMomentscuda::numMomentscuda::MomentsOrder

◆ numMoments()

int cv::cuda::numMoments ( const MomentsOrder order)

#include <opencv2/cudaimgproc.hpp>

返回小于或等于最大图像矩 *order* 的图像矩的数量。

参数
order要计算的最大矩的阶数,低阶矩需要较少的计算。
返回值
图像矩的数量。
参见
cuda::spatialMomentscuda::momentscuda::MomentsOrder

◆ spatialMoments()

void cv::cuda::spatialMoments ( InputArray src,
OutputArray moments,
const bool binaryImage = false,
const MomentsOrder order = MomentsOrder::THIRD_ORDER_MOMENTS,
const int momentsType = CV_64F,
Stream & stream = Stream::Null() )

#include <opencv2/cudaimgproc.hpp>

计算栅格化形状最多 3 阶的所有空间矩。

cuda::moments() 的异步版本,它只计算光栅化形状的最高三阶空间矩(非中心化或归一化)。每个矩作为1D moments 数组中的列条目返回。

参数
src栅格图像(单通道二维数组)。
[输出]moments每个列条目包含一个空间图像矩的1D数组。
binaryImage如果为真,则所有非零图像像素都视为 1。
order要计算的最大矩的阶数,低阶矩需要较少的计算。
momentsType计算矩时使用的精度。可用类型为 CV_32FCV_64FCV_32F 的性能比 CV_64F 高一个数量级。如果图像较小,则 CV_32F 的精度可以等于或非常接近 CV_64F
stream异步版本的Stream
注意
为了获得最佳性能,请预先分配一个正确的类型和大小的1D GpuMat 用于 moments,其大小足以存储高达所需 order 的所有图像矩。例如,如果 order === MomentsOrder::SECOND_ORDER_MOMENTSmomentsType == CV_32F,则可以将 moments 分配为:
具有引用计数的GPU内存的基本存储类。
定义 cuda.hpp:106
#define CV_32F
定义 interface.h:78
@ SECOND_ORDER_MOMENTS
定义 cudaimgproc.hpp:798
可以通过下载 moments 数组并使用 cuda::convertSpatialMoments 辅助函数来轻松计算主机上的中心矩和归一化矩。例如:
spatialMomentsDevice.download(spatialMomentsHostMem, stream);
stream.waitForCompletion();
Mat spatialMoments = spatialMomentsHostMem.createMatHeader();
n维密集数组类
定义 mat.hpp:829
cv::moments返回的结构体
定义 types.hpp:967
具有引用计数的类,包装来自CUDA的特殊内存类型分配函数。
定义 cuda.hpp:792
void spatialMoments(InputArray src, OutputArray moments, const bool binaryImage=false, const MomentsOrder order=MomentsOrder::THIRD_ORDER_MOMENTS, const int momentsType=CV_64F, Stream &stream=Stream::Null())
计算栅格化形状最多 3 阶的所有空间矩。
Moments convertSpatialMoments(Mat spatialMoments, const MomentsOrder order, const int momentsType)
将从cuda::spatialMoments返回的空间图像矩转换为cv::Moments。

参见opencv_contrib_source_code/modules/cudaimgproc/test/test_moments.cpp中的CUDA_TEST_P(Moments, Async)测试示例。

参见
cuda::momentscuda::convertSpatialMomentscuda::numMomentscuda::MomentsOrder