OpenCV 4.13.0
Open Source Computer Vision
読み込み中...
検索中...
見つかりません
🤖 AIによる機械翻訳(非公式) — これは OpenCV 4.13.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。

詳細説明

列挙型

enum  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_MOMENTS1次モーメント
SECOND_ORDER_MOMENTS2次モーメント。
THIRD_ORDER_MOMENTS3次モーメント。
列挙値
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 から返される空間モーメント。
ordercuda::spatialMoments で画像モーメントを計算する際に使用する次数。
momentsTypecuda::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ラスター画像(シングルチャンネルの2次元配列)。
binaryImagetrue の場合、すべての非ゼロの画像ピクセルが1として扱われる。
order計算する最大モーメントの次数。低次のモーメントほど計算量が少なくて済む。
momentsTypeモーメントを計算する際に使用する精度。使用可能な型は CV_32FCV_64F であり、CV_32F の性能は CV_64F より1桁大きい。画像が小さい場合、CV_32F の精度は CV_64F と同等またはきわめて近くなることがある。
覚え書き
最大の性能を得るには、非同期版 cuda::spatialMoments() を使用する。このバージョンは、デバイス上で計算を行いその結果をホストへダウンロードするために、内部で GpuMatHostMem の両方を確保・解放する。コストの高い HostMem の確保は回避できないが、GpuMat のデバイス確保は BufferPool を使うことで回避できる。例えば次のようにする。
setBufferPoolConfig(getDevice(), numMoments(order) * ((momentsType == CV_64F) ? sizeof(double) : sizeof(float)), 1);
#define CV_64F
Definition interface.h:79
int getDevice()
Returns the current device index set by cuda::setDevice or initialized by default.
void setBufferPoolUsage(bool on)
BufferPool management (must be called before Stream creation)
void setBufferPoolConfig(int deviceId, size_t stackSize, int stackCount)
int numMoments(const MomentsOrder order)
Returns the number of image moments less than or equal to the largest image moments order.
例については opencv_contrib_source_code/modules/cudaimgproc/test/test_moments.cpp 内の CUDA_TEST_P(Moments, Accuracy) テストを参照のこと。
戻り値
cv::Moments.
参照
cuda::spatialMoments, cuda::convertSpatialMoments, cuda::numMoments, cuda::MomentsOrder

◆ numMoments()

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

#include <opencv2/cudaimgproc.hpp>

最大の画像モーメント次数 order 以下の画像モーメントの個数を返す。

引数
order計算する最大モーメントの次数。低次のモーメントほど計算量が少なくて済む。
戻り値
画像モーメントの個数。
参照
cuda::spatialMoments, cuda::moments, cuda::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() の非同期版で、ラスタライズされた形状の3次までの空間モーメント(中心モーメントや正規化モーメントではない)のみを計算する。各モーメントは1次元の moments 配列に列要素として返される。

引数
srcラスター画像(シングルチャンネルの2次元配列)。
[out]moments各列の要素に空間画像モーメントを1つずつ含む1次元配列。
binaryImagetrue の場合、すべての非ゼロの画像ピクセルが1として扱われる。
order計算する最大モーメントの次数。低次のモーメントほど計算量が少なくて済む。
momentsTypeモーメントを計算する際に使用する精度。使用可能な型は CV_32FCV_64F であり、CV_32F の性能は CV_64F より1桁大きい。画像が小さい場合、CV_32F の精度は CV_64F と同等またはきわめて近くなることがある。
stream非同期版のための Stream
覚え書き
最大の性能を得るには、目的の order までの全画像モーメントを格納できる十分なサイズと正しい型を持つ1次元の GpuMatmoments 用にあらかじめ確保しておく。例えば order === MomentsOrder::SECOND_ORDER_MOMENTS かつ momentsType == CV_32F の場合、moments は次のように確保できる。
Base storage class for GPU memory with reference counting.
Definition cuda.hpp:106
#define CV_32F
Definition interface.h:78
@ SECOND_ORDER_MOMENTS
Definition cudaimgproc.hpp:811
中心モーメントと正規化モーメントは、moments 配列をダウンロードし cuda::convertSpatialMoments ヘルパ関数を使うことで、ホスト上で簡単に計算できる。例えば次のようにする。
spatialMomentsDevice.download(spatialMomentsHostMem, stream);
stream.waitForCompletion();
Mat spatialMoments = spatialMomentsHostMem.createMatHeader();
n-dimensional dense array class
Definition mat.hpp:840
struct returned by cv::moments
Definition types.hpp:967
Class with reference counting wrapping special memory type allocation functions from CUDA.
Definition cuda.hpp:799
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())
Calculates all of the spatial moments up to the 3rd order of a rasterized shape.
Moments convertSpatialMoments(Mat spatialMoments, const MomentsOrder order, const int momentsType)
Converts the spatial image moments returned from cuda::spatialMoments to cv::Moments.

例については opencv_contrib_source_code/modules/cudaimgproc/test/test_moments.cpp 内の CUDA_TEST_P(Moments, Async) テストを参照のこと。

参照
cuda::moments, cuda::convertSpatialMoments, cuda::numMoments, cuda::MomentsOrder