5#include "../_cexports/c_foundation.h"
7#include "../global.hpp"
9#include "../exception.hpp"
10#include "../point_2d.hpp"
23inline HandleGuard<Foundation::Moments::ImageMoments>::HandleGuard(
void * handle) noexcept
24 : HandleGuard<Foundation::Moments::ImageMoments>(handle, [](
void* h) { CVB_CALL_CAPI(ReleaseObject(h)); })
117 calculationPreference_ (preference),
118 lastOffset_ (aoi.Location ())
120 auto h = CVB_CALL_CAPI(CreateImageMoments(
static_cast<CExports::TMomentsCalculation
>(preference)));
123 Utilities::SystemInfo::ThrowLastError ();
127 CVB_CALL_CAPI_CHECKED (CalculateMoments(imagePlane.
Parent().
Handle(), imagePlane.
Plane(),
128 aoi.Left(), aoi.Top(), aoi.Right(), aoi.Bottom(), h));
139 :
ImageMoments (imagePlane, imagePlane.Parent ().Bounds (), preference)
182 return calculationPreference_;
194 return handle_.Handle();
211 CVB_CALL_CAPI_CHECKED (GetSpatialImageMoment(
Handle(),
static_cast<int>(xOrder),
static_cast<int>(yOrder),
229 return SpatialMoment (xOrder, yOrder, normalization, lastOffset_);
244 CVB_CALL_CAPI_CHECKED (GetCentralImageMoment(
Handle(),
static_cast<int>(xOrder),
static_cast<int>(yOrder),
257 double m1, m2, m3, m4, m5, m6, m7;
258 CVB_CALL_CAPI_CHECKED (GetHuImageMoments(
Handle(), m1, m2, m3, m4, m5, m6, m7));
260 return HuMomentsType{m1, m2, m3, m4, m5, m6, m7};
264 HandleGuard<ImageMoments> handle_;
State object for calculating various image moments.
Definition: moments.hpp:105
ImageMoments(const ImagePlane &imagePlane, Rect< int > aoi, MomentsCalculation preference=MomentsCalculation::FavorNone)
Calculate the moments on the input ImagePlane and area of interest.
Definition: moments.hpp:115
ImageMoments(const ImagePlane &imagePlane, MomentsCalculation preference=MomentsCalculation::FavorNone)
Calculate the moments on the input imagePlane.
Definition: moments.hpp:138
MomentsCalculation CalculationPreference() const noexcept
The preference of speed versus accuracy chosen when this object was created.
Definition: moments.hpp:180
static std::unique_ptr< ImageMoments > Calculate(const ImagePlane &imagePlane, MomentsCalculation preference=MomentsCalculation::FavorNone)
Calculate the moments on the input imagePlane.
Definition: moments.hpp:169
HuMoments HuMoments()
Get the seven Hu moments of the image.
Definition: moments.hpp:255
ImageMoments(ImageMoments &&) noexcept=default
Move constructor.
double SpatialMoment(MomentsOrder xOrder, MomentsOrder yOrder, MomentsNormalization normalization)
Get one of the spatial image moments.
Definition: moments.hpp:227
double SpatialMoment(MomentsOrder xOrder, MomentsOrder yOrder, MomentsNormalization normalization, Point2D< int > offset)
Get one of the spatial image moments.
Definition: moments.hpp:208
void * Handle() const noexcept
Classic API IMGMOMENTS handle.
Definition: moments.hpp:192
double CentralMoment(MomentsOrder xOrder, MomentsOrder yOrder, MomentsNormalization normalization)
Get one of the central image moments.
Definition: moments.hpp:241
static std::unique_ptr< ImageMoments > Calculate(const ImagePlane &imagePlane, Rect< int > aoi, MomentsCalculation preference=MomentsCalculation::FavorNone)
Calculate the moments on the input imagePlane and aoi.
Definition: moments.hpp:157
void * Handle() const noexcept
Classic API image handle.
Definition: decl_image.hpp:223
Image plane information container.
Definition: decl_image_plane.hpp:33
int Plane() const noexcept
Plane index in the image, to which this plane refers to.
Definition: decl_image_plane.hpp:169
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition: detail_image_plane.hpp:87
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
MomentsOrder
Enumerated order for x and y central or spatial moments.
Definition: moments.hpp:54
std::shared_ptr< ImageMoments > ImageMomentsPtr
Convenience shared pointer for ImageMoments.
Definition: moments.hpp:270
MomentsCalculation
Choose between speed and accuracy during image moment calculation.
Definition: moments.hpp:42
@ FavorNone
Favor neither speed nor accuracy.
@ FavorSpeed
Favor speed over accuracy during moments calculation.
@ FavorAccuracy
Favor accuracy over speed during moments calculation.
MomentsNormalization
Available normalization modes for moment calculations.
Definition: moments.hpp:67
@ Normalized
Report moments normalized.
@ Unnormalized
Report moments unnormalized.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
Results of Hu Moment calculation.
Definition: moments.hpp:78
double M2
Hu Moment M2.
Definition: moments.hpp:83
double M5
Hu Moment M5.
Definition: moments.hpp:92
double M7
Hu Moment M7.
Definition: moments.hpp:98
double M1
Hu Moment M1.
Definition: moments.hpp:80
double M6
Hu Moment M6.
Definition: moments.hpp:95
double M4
Hu Moment M4.
Definition: moments.hpp:89
double M3
Hu Moment M3.
Definition: moments.hpp:86