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()))
51 CExports::cvbval_t retval[256];
52 CExports::SFGradHistogram(plane.Parent().Handle(), plane.Plane(), aoi.Left(), aoi.Top(), aoi.Right(), aoi.Bottom(),
static_cast<CExports::TSFGradientType
>(gradient), &retval[0]);
73 return rotationRange_;
85 rotationRange_ = value;
127 return featureCount_;
137 if (value < FeatureCountMin)
139 featureCount_ = value;
149 return contrastThreshold_;
159 if (value < ContrastThresholdMin)
161 contrastThreshold_ = value;
171 return maxCoarseScale_;
183 maxCoarseScale_ = value;
193 return contrastMode_;
203 contrastMode_ = mode;
225 if ((value % 2) == 0)
227 profileSize_ = value;
237 return profileDelta_;
249 profileDelta_ = value;
263 return Learn(plane, position,
Angle(), 0.0, teachWindow, dontCarePoints);
276 return Learn(plane, position,
Angle(), 0.0, teachWindow);
291 CExports::PIXELLIST dontCarePointsNative =
nullptr;
293 if (plane.Parent().Handle() !=
nullptr && plane.DataType().HasOverlayBit())
295 CExports::CreatePixelListFromOverlay(plane.Parent().Handle(), plane.Plane(), 0, 0, plane.Parent().Width() - 1, plane.Parent().Height() - 1, dontCarePointsNative);
296 if (dontCarePointsNative)
298 CExports::TMatrix matrix;
303 CExports::TransformPixelListMatrix(dontCarePointsNative, matrix, -position.
X(), -position.
Y());
307 return Learn(plane, position, angleOffset, scaleFactor, teachWindow, dontCarePointsNative);
323 CExports::PIXELLIST dontCareList =
static_cast<CExports::PIXELLIST
>(Point2DToPixelList(dontCarePoints));
324 return Learn(plane, position, angleOffset, scaleFactor, teachWindow, dontCareList);
340 static ValueRange<double> ScaleRangeDefault() noexcept
342 return ValueRange<double>(1.0, 1.0);
345 std::unique_ptr<Classifier> Learn(
const ImagePlane & plane, Point2D<double> position, Angle angleOffset,
double scaleFactor, Rect<int> teachWindow, CExports::PIXELLIST dontCareList )
const
347 CExports::TSymmetryParams symmetries;
348 symmetries.ContrastMode = (int)contrastMode_;
355 if (maxCoarseScale < 0)
358 CExports::SF sf =
nullptr;
361 sf = CExports::CreateSF2ExEx(plane.Parent().Handle(), plane.Plane(), (CExports::cvbdim_t)position.X(), (CExports::cvbdim_t)position.Y(), angleOffset.Rad(), scaleFactor
367 sf = CExports::CreateSF2Ex(plane.Parent().Handle(), plane.Plane(), (CExports::cvbdim_t)position.X(), (CExports::cvbdim_t)position.Y(), angleOffset.Rad(), scaleFactor
369 , maxCoarseScale, symmetries, dontCareList);
373 Utilities::SystemInfo::ThrowLastError();
381 static Internal::PixelList* Point2DToPixelList(
const std::vector<Point2D<int>>& points)
386 tmp.push_back(
static_cast<Point2D<double>
>(points.at(i)));
388 auto pixelList = Internal::PixelList::FromPoints (tmp);
389 return pixelList.get();
394 static const int FeatureCountMin = 10;
395 static const int ContrastThresholdMin = 1;
399 static const int FeatureCountDefault = 100;
400 static const int ContrastThresholdDefault = 25;
401 static const int MaxCoarseLayerDefault = 8;
403 int featureCount_ = FeatureCountDefault;
404 int contrastThreshold_ = ContrastThresholdDefault;
405 int maxCoarseScale_ = MaxCoarseLayerDefault;
406 int profileSize_ = 1;
407 int profileDelta_ = 1;
417using 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
double A11() const noexcept
Gets top left matrix element.
Definition: matrix_2d.hpp:165
static Matrix2D Identity() noexcept
The identity element.
Definition: matrix_2d.hpp:24
double A22() const noexcept
Gets bottom right matrix element.
Definition: matrix_2d.hpp:225
double A12() const noexcept
Gets top right matrix element.
Definition: matrix_2d.hpp:185
double A21() const noexcept
Gets bottom left matrix element.
Definition: matrix_2d.hpp:205
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:274
int ContrastThreshold() const noexcept
Minimum contrast a feature must have to enter into the classifier.
Definition: classifier_factory.hpp:147
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:157
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:235
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:289
int MaxCoarseLayerScale() const noexcept
Maximum exponent of the scale factor between the coarse layer and the image.
Definition: classifier_factory.hpp:169
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:261
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:179
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:245
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:201
int ProfileSize() const noexcept
Profile size gives the number of profile points to be used for correlation around each feature.
Definition: classifier_factory.hpp:211
Cvb::ShapeFinder2::ContrastMode ContrastMode() const noexcept
Contrast mode to be used for feature extraction.
Definition: classifier_factory.hpp:191
void SetProfileSize(int value)
Profile size gives the number of profile points to be used for correlation around each feature.
Definition: classifier_factory.hpp:221
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:321
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