3 #include "../angle.hpp" 4 #include "../value_range.hpp" 5 #include "../point_2d.hpp" 6 #include "../_detail/detail_pixel_list.hpp" 7 #include "../image.hpp" 9 #include "shapefinder2.hpp" 10 #include "classifier.hpp" 19 namespace ShapeFinder2
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;
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;
417 using ShapeFinder2::ClassifierFactory;
static std::unique_ptr< Classifier > FromHandle(HandleGuard< Classifier > &&guard)
Creates a classifier from a classic API handle.
Definition: classifier.hpp:49
int MaxCoarseLayerScale() const noexcept
Maximum exponent of the scale factor between the coarse layer and the image.
Definition: classifier_factory.hpp:169
Image plane information container.
Definition: decl_image_plane.hpp:31
T Top() const noexcept
Gets first row of the rectangle.
Definition: rect.hpp:111
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
double A21() const noexcept
Gets bottom left matrix element.
Definition: matrix_2d.hpp:205
ValueRange< Angle > RotationRangeMax() const noexcept
The maximum range of rotations (in degrees), that may be set on the learner.
Definition: classifier_factory.hpp:61
class DataType DataType() const noexcept override
Data type descriptor for this array.
Definition: detail_image_plane.hpp:340
void SetRotationRange(ValueRange< Angle > value)
Range of rotations, that the classifier should be able to cover.
Definition: classifier_factory.hpp:81
T Min() const noexcept
Gets the minimum value.
Definition: value_range.hpp:50
GradientType
Type of Gradient used for feature extraction.
Definition: shapefinder2.hpp:58
T Max() const noexcept
Gets the maximum value.
Definition: value_range.hpp:72
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition: detail_image_plane.hpp:87
Cvb::ShapeFinder2::ContrastMode ContrastMode() const noexcept
Contrast mode to be used for feature extraction.
Definition: classifier_factory.hpp:191
void SetScaleRange(ValueRange< double > value)
Range of scales, that the classifier should be able to cover.
Definition: classifier_factory.hpp:113
int FeatureCount() const noexcept
Minimum number of features the result classifier should have.
Definition: classifier_factory.hpp:125
T Bottom() const noexcept
Gets bottom row of the rectangle (still inside the rectangle).
Definition: rect.hpp:151
static Matrix2D Identity() noexcept
The identity element.
Definition: matrix_2d.hpp:24
void SetContrastThreshold(int value)
Minimum contrast a feature must have to enter into the classifier.
Definition: classifier_factory.hpp:157
T Left() const noexcept
Gets first column of the rectangle.
Definition: rect.hpp:91
ValueRange< double > ScaleRange() const noexcept
Range of scales, that the classifier should be able to cover.
Definition: classifier_factory.hpp:103
int Plane() const noexcept
Plane index in the image, to which this plane refers to.
Definition: decl_image_plane.hpp:169
Root namespace for the Image Manager interface.
Definition: version.hpp:11
static Angle FromDegrees(double deg, bool trim=false) noexcept
Create an angle in degrees.
Definition: angle.hpp:30
void SetMaxCoarseLayerScale(int value)
Maximum exponent of the scale factor between the coarse layer and the image.
Definition: classifier_factory.hpp:179
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
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
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
ClassifierFactory() noexcept=default
The object that holds methods for generating ShapeFinder classifier factory.
T Right() const noexcept
Gets rightmost column of the rectangle (still inside the rectangle).
Definition: rect.hpp:131
std::vector< int > GradientHistogram(const ImagePlane &plane, Rect< int > aoi, ShapeFinder2::GradientType gradient) const
Calculate the gradient histogram.
Definition: classifier_factory.hpp:46
ContrastMode
Normal contrast features.
Definition: shapefinder2.hpp:36
Normal contrast features.
void * Handle() const noexcept
Classic API image handle.
Definition: decl_image.hpp:223
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
bool HasOverlayBit() const noexcept
Gets whether bit 0 of the pixels of the plane are being used as an overlay indicator bit.
Definition: data_type.hpp:394
double A22() const noexcept
Gets bottom right matrix element.
Definition: matrix_2d.hpp:225
ValueRange< double > ScaleRangeMax() const noexcept
The maximum range of scales, that may be set on the learner.
Definition: classifier_factory.hpp:93
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
void SetProfileDelta(int value)
Distance (in pixels) between adjacent profile points.
Definition: classifier_factory.hpp:245
double A11() const noexcept
Gets top left matrix element.
Definition: matrix_2d.hpp:165
int Width() const noexcept
Width of the image in pixels.
Definition: decl_image.hpp:285
Container for range definitions.
Definition: value_range.hpp:16
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 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, 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
double A12() const noexcept
Gets top right matrix element.
Definition: matrix_2d.hpp:185
ShapeFinder2 classifier factory object.
Definition: classifier_factory.hpp:26
void SetFeatureCount(int value)
Minimum number of features the result classifier should have.
Definition: classifier_factory.hpp:135
int Height() const noexcept
Height of the image in pixels.
Definition: decl_image.hpp:278
int BitsPerPixel() const noexcept
Number of actually valid bits per pixel.
Definition: data_type.hpp:332
int ContrastThreshold() const noexcept
Minimum contrast a feature must have to enter into the classifier.
Definition: classifier_factory.hpp:147
void SetContrastMode(Cvb::ShapeFinder2::ContrastMode mode) noexcept
Contrast mode to be used for feature extraction.
Definition: classifier_factory.hpp:201
bool IsUnsignedInteger() const noexcept
Gets whether the pixels of the plane have unsigned integer values.
Definition: data_type.hpp:374
Object for convenient and type - safe handling of angles.
Definition: angle.hpp:18
const int CVB_INVALIDDATATYPE
Invalid data type.
Definition: exception.hpp:78
ValueRange< Angle > RotationRange() const noexcept
Range of rotations, that the classifier should be able to cover.
Definition: classifier_factory.hpp:71