4#include "../value_range.hpp"
5#include "../point_2d.hpp"
6#include "../_detail/detail_pixel_list.hpp"
9#include "shapefinder2.hpp"
10#include "classifier.hpp"
48 if ((plane.DataType().BitsPerPixel() != 8) || (!plane.DataType().IsUnsignedInteger()))
52 CExports::SFGradHistogram(plane.Parent().Handle(), plane.Plane(), aoi.Left(), aoi.Top(), aoi.Right(), aoi.Bottom(),
static_cast<CExports::TSFGradientType
>(gradient), retval.data());
73 return rotationRange_;
85 rotationRange_ = value;
127 return featureCount_;
137 using namespace std::string_literals;
138 if (value < FeatureCountMin)
139 throw std::out_of_range((
"feature count must be >= "s + std::to_string(FeatureCountMin)).c_str());
140 featureCount_ = value;
150 return contrastThreshold_;
160 using namespace std::string_literals;
161 if (value < ContrastThresholdMin)
162 throw std::out_of_range((
"contrast threshold must be >= "s + std::to_string(FeatureCountMin)).c_str());
163 contrastThreshold_ = value;
173 return maxCoarseScale_;
185 maxCoarseScale_ = value;
195 return contrastMode_;
205 contrastMode_ = mode;
227 if ((value % 2) == 0)
229 profileSize_ = value;
239 return profileDelta_;
251 profileDelta_ = value;
265 return Learn(plane, position,
Angle(), 0.0, teachWindow, dontCarePoints);
278 return Learn(plane, position,
Angle(), 0.0, teachWindow);
293 CExports::PIXELLIST dontCarePointsNative =
nullptr;
295 if (plane.Parent().Handle() !=
nullptr && plane.DataType().HasOverlayBit())
297 CExports::CreatePixelListFromOverlay(plane.Parent().Handle(), plane.Plane(), 0, 0, plane.Parent().Width() - 1, plane.Parent().Height() - 1, dontCarePointsNative);
298 if (dontCarePointsNative)
301 CExports::TransformPixelListMatrix(dontCarePointsNative, *
reinterpret_cast<CExports::TMatrix*
>(&identity), -position.
X(), -position.
Y());
306 return Learn(plane, position, angleOffset, scaleFactor, teachWindow, dontCarePointsNative);
322 return Learn(plane, position, angleOffset, scaleFactor, teachWindow, Point2DToPixelList(dontCarePoints)->Handle());
339 std::unique_ptr<Classifier> Learn(
const ImagePlane & plane, Point2D<double> position, Angle angleOffset,
double scaleFactor, Rect<int> teachWindow, CExports::PIXELLIST dontCareList )
const
341 CExports::TSymmetryParams symmetries = { 0 };
342 symmetries.ContrastMode = (int)contrastMode_;
349 if (maxCoarseScale < 0)
352 CExports::SF sf =
nullptr;
355 sf = CExports::CreateSF2ExEx(plane.Parent().Handle(), plane.Plane(), (CExports::cvbdim_t)position.X(), (CExports::cvbdim_t)position.Y(), angleOffset.Rad(), scaleFactor
361 sf = CExports::CreateSF2Ex(plane.Parent().Handle(), plane.Plane(), (CExports::cvbdim_t)position.X(), (CExports::cvbdim_t)position.Y(), angleOffset.Rad(), scaleFactor
363 , maxCoarseScale, symmetries, dontCareList);
367 Utilities::SystemInfo::ThrowLastError();
380 tmp.push_back(
static_cast<Point2D<double>
>(points.at(i)));
382 return Internal::PixelList::FromPoints (tmp);
387 static const int FeatureCountMin = 10;
388 static const int ContrastThresholdMin = 1;
392 static const int FeatureCountDefault = 100;
393 static const int ContrastThresholdDefault = 25;
394 static const int MaxCoarseLayerDefault = 8;
396 int featureCount_ = FeatureCountDefault;
397 int contrastThreshold_ = ContrastThresholdDefault;
398 int maxCoarseScale_ = MaxCoarseLayerDefault;
399 int profileSize_ = 1;
400 int profileDelta_ = 1;
410using ShapeFinder2::ClassifierFactory;
Object for convenient and type - safe handling of angles.
Definition: angle.hpp:19
static Angle FromDegrees(double deg, bool trim=false) noexcept
Create an angle in degrees.
Definition: angle.hpp:30
Image plane information container.
Definition: decl_image_plane.hpp:33
static Matrix2D Identity() noexcept
The identity element.
Definition: matrix_2d.hpp:24
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
Rectangle object.
Definition: rect.hpp:26
ShapeFinder2 classifier factory object.
Definition: classifier_factory.hpp:27
void SetFeatureCount(int value)
Minimum number of features the result classifier should have.
Definition: classifier_factory.hpp:135
std::unique_ptr< Classifier > Learn(const ImagePlane &plane, Point2D< double > position, Rect< int > teachWindow) const
Create a ShapeFinder2 classifier from plane 0 of the input image.
Definition: classifier_factory.hpp:276
int ContrastThreshold() const noexcept
Minimum contrast a feature must have to enter into the classifier.
Definition: classifier_factory.hpp:148
std::vector< int > GradientHistogram(const ImagePlane &plane, Rect< int > aoi, ShapeFinder2::GradientType gradient) const
Calculate the gradient histogram.
Definition: classifier_factory.hpp:46
ValueRange< double > ScaleRange() const noexcept
Range of scales, that the classifier should be able to cover.
Definition: classifier_factory.hpp:103
void SetScaleRange(ValueRange< double > value)
Range of scales, that the classifier should be able to cover.
Definition: classifier_factory.hpp:113
void SetContrastThreshold(int value)
Minimum contrast a feature must have to enter into the classifier.
Definition: classifier_factory.hpp:158
ValueRange< Angle > RotationRangeMax() const noexcept
The maximum range of rotations (in degrees), that may be set on the learner.
Definition: classifier_factory.hpp:61
int ProfileDelta() const noexcept
Distance (in pixels) between adjacent profile points.
Definition: classifier_factory.hpp:237
std::unique_ptr< Classifier > Learn(const ImagePlane &plane, Point2D< double > position, Angle angleOffset, double scaleFactor, Rect< int > teachWindow) const
Create a ShapeFinder2 classifier from the input image.
Definition: classifier_factory.hpp:291
int MaxCoarseLayerScale() const noexcept
Maximum exponent of the scale factor between the coarse layer and the image.
Definition: classifier_factory.hpp:171
std::unique_ptr< Classifier > Learn(const ImagePlane &plane, Point2D< double > position, Rect< int > teachWindow, const std::vector< Point2D< int > > &dontCarePoints) const
Creates a ShapeFinder2 classifier from plane 0 of the input image.
Definition: classifier_factory.hpp:263
int FeatureCount() const noexcept
Minimum number of features the result classifier should have.
Definition: classifier_factory.hpp:125
ClassifierFactory() noexcept=default
The object that holds methods for generating ShapeFinder classifier factory.
ValueRange< double > ScaleRangeMax() const noexcept
The maximum range of scales, that may be set on the learner.
Definition: classifier_factory.hpp:93
void SetMaxCoarseLayerScale(int value)
Maximum exponent of the scale factor between the coarse layer and the image.
Definition: classifier_factory.hpp:181
ValueRange< Angle > RotationRange() const noexcept
Range of rotations, that the classifier should be able to cover.
Definition: classifier_factory.hpp:71
void SetProfileDelta(int value)
Distance (in pixels) between adjacent profile points.
Definition: classifier_factory.hpp:247
void SetRotationRange(ValueRange< Angle > value)
Range of rotations, that the classifier should be able to cover.
Definition: classifier_factory.hpp:81
void SetContrastMode(Cvb::ShapeFinder2::ContrastMode mode) noexcept
Contrast mode to be used for feature extraction.
Definition: classifier_factory.hpp:203
int ProfileSize() const noexcept
Profile size gives the number of profile points to be used for correlation around each feature.
Definition: classifier_factory.hpp:213
Cvb::ShapeFinder2::ContrastMode ContrastMode() const noexcept
Contrast mode to be used for feature extraction.
Definition: classifier_factory.hpp:193
void SetProfileSize(int value)
Profile size gives the number of profile points to be used for correlation around each feature.
Definition: classifier_factory.hpp:223
std::unique_ptr< Classifier > Learn(const ImagePlane &plane, Point2D< double > position, Angle angleOffset, double scaleFactor, Rect< int > teachWindow, const std::vector< Point2D< int > > &dontCarePoints) const
Create a ShapeFinder2 classifier from the input image.
Definition: classifier_factory.hpp:320
static std::unique_ptr< Classifier > FromHandle(HandleGuard< Classifier > &&guard)
Creates a classifier from a classic API handle.
Definition: classifier.hpp:49
Container for range definitions.
Definition: value_range.hpp:17
T Min() const noexcept
Gets the minimum value.
Definition: value_range.hpp:50
T Max() const noexcept
Gets the maximum value.
Definition: value_range.hpp:72
const int CVB_INVALIDDATATYPE
Invalid data type.
Definition: exception.hpp:78
GradientType
Type of Gradient used for feature extraction.
Definition: shapefinder2.hpp:59
ContrastMode
Normal contrast features.
Definition: shapefinder2.hpp:37
@ Normal
Normal contrast features.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
Angle Max(Angle a, Angle b) noexcept
Returns the bigger of two angles.
Definition: angle.hpp:504
Angle Min(Angle a, Angle b) noexcept
Returns the smaller of two angles.
Definition: angle.hpp:521