3#include "../_cexports/c_polimago.h"
5#include "../global.hpp"
7#include "../string.hpp"
9#include "../size_2d.hpp"
10#include "../point_2d.hpp"
24 inline String GetPreprocessing(CExports::TFeatureMap fm)
26 std::string s(std::begin(fm.Code));
27 return String(s.begin(), s.end());
43 class PolimagoFactoryCreatedObject
46 PolimagoFactoryCreatedObject(
const PolimagoFactoryCreatedObject &other) =
delete;
47 PolimagoFactoryCreatedObject &operator=(
const PolimagoFactoryCreatedObject &other) =
delete;
48 PolimagoFactoryCreatedObject(PolimagoFactoryCreatedObject &&other) =
delete;
49 PolimagoFactoryCreatedObject &operator=(PolimagoFactoryCreatedObject &&other) =
delete;
50 virtual ~PolimagoFactoryCreatedObject() =
default;
53 explicit PolimagoFactoryCreatedObject(ReleaseObjectGuard &&guard)
55 , trainingParameters_()
70 return handle_.Handle();
91 SaveFunction(fileName);
102 return trainingParameters_.Lambda;
112 return trainingParameters_.Offset;
122 if (trainingParameters_.FeatureMap.Interpolate == 0)
140 return trainingParameters_.FeatureMap.NumImgPlanes;
150 return Rect<int>(trainingParameters_.FeatureMap.FWL, trainingParameters_.FeatureMap.FWT,
151 trainingParameters_.FeatureMap.FWR, trainingParameters_.FeatureMap.FWB);
162 return Size2D<int>(trainingParameters_.FeatureMap.RetinaW, trainingParameters_.FeatureMap.RetinaH);
173 return Point2D<double>(trainingParameters_.FeatureMap.CorrectX, trainingParameters_.FeatureMap.CorrectY);
183 return Private::GetPreprocessing(trainingParameters_.FeatureMap);
187 virtual void SaveFunction(
const String &fileName)
const = 0;
190 CExports::TTrainParams &TrainingParameters() noexcept
192 return trainingParameters_;
195 const CExports::TTrainParams &TrainingParameters() const noexcept
197 return trainingParameters_;
203 ReleaseObjectGuard handle_;
204 CExports::TTrainParams trainingParameters_;
43 class PolimagoFactoryCreatedObject {
…};
213 class PredictorBase :
public PolimagoFactoryCreatedObject
216 explicit PredictorBase(ReleaseObjectGuard &&guard)
217 : PolimagoFactoryCreatedObject(
std::move(guard))
234 VerifyCompatibility(img, pos);
254 VerifyCompatibility(img);
264 void VerifyCompatibility(
const Image &img)
const
276 void VerifyCompatibility(
const Image &img, Point2D<int> pos)
const
278 VerifyCompatibility(img);
281 throw std::invalid_argument(
282 "The selected position cannot be evaluated because there is not enough image data available around it.");
287 throw std::invalid_argument(
288 "The selected position cannot be evaluated because there is not enough image data available around it.");
213 class PredictorBase :
public PolimagoFactoryCreatedObject {
…};
299 class PredictorBaseEx :
public PredictorBase
302 explicit PredictorBaseEx(ReleaseObjectGuard &&guard)
305 CVB_CALL_CAPI(PMGetClfTrainParams(
Handle(), TrainingParameters()));
316 return TrainingParameters().FeatureMap.FeatureResolution;
299 class PredictorBaseEx :
public PredictorBase {
…};
332 std::string asciiCode(Internal::CastToAscii(preproCode));
333 return CVB_CALL_CAPI(PMGetGranularity(asciiCode.c_str()));
The Common Vision Blox image.
Definition decl_image.hpp:50
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
String Preprocessing() const
Preprocessing code with which this object was generated.
Definition predictor_base.hpp:181
Size2D< int > RetinaSize() const noexcept
Size of the 'Retina' in pixels. The retina is the set of paxels onto which the input image is project...
Definition predictor_base.hpp:160
double Offset() const noexcept
Intercept weight that has been used for generating this object.
Definition predictor_base.hpp:110
double Lambda() const noexcept
Regularization value that has been used for generating this object.
Definition predictor_base.hpp:100
Rect< int > FeatureWindowExtent() const noexcept
The feature window extent that has been used during classifier training.
Definition predictor_base.hpp:148
int ImagePlanes() const noexcept
The plane count of the images that have been used for generating this classifier. Image on which this...
Definition predictor_base.hpp:138
void Save(const String &fileName) const
Save this object into a file.
Definition predictor_base.hpp:89
Point2D< double > Correction() const noexcept
Correction factors in X and Y direction required to rescale the input images for projection onto the ...
Definition predictor_base.hpp:171
InterpolationType Interpolation() const noexcept
Interpolation setting used for generating this object.
Definition predictor_base.hpp:120
String FileName() const
Name of the file the object has been loaded from (or empty string if the object was not loaded).
Definition predictor_base.hpp:78
void * Handle() const noexcept
Classic API Polimago handle.
Definition predictor_base.hpp:68
int FeatureResolution() const noexcept
Feature resolution value with which the classifier was trained.
Definition predictor_base.hpp:314
bool IsCompatible(const Image &img) const
Verify the compatibility of a CVB image with this classifier.
Definition predictor_base.hpp:250
bool IsCompatible(const Image &img, Point2D< int > pos) const
Verify the compatibility of a CVB image with this classifier.
Definition predictor_base.hpp:230
Rectangle object.
Definition rect.hpp:24
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
Namespace for the Polimago package.
Definition classification_predictor.hpp:38
int GetGranularity(const String &preproCode)
The function returns the granularity associated with a preprocessing code.
Definition predictor_base.hpp:330
std::shared_ptr< PredictorBaseEx > PredictorBaseExPtr
Convenience shared pointer for PredictorBaseEx.
Definition predictor_base.hpp:321
std::shared_ptr< PredictorBase > PredictorBasePtr
Convenience shared pointer for PredictorBase.
Definition predictor_base.hpp:294
@ None
The enum element indicating undefined state.
Definition classification_predictor.hpp:44
InterpolationType
Interpolation to be used when extracting image data for classifier generation.
Definition predictor_base.hpp:33
@ Linear
Image data is (if necessary) extracted with linear interpolation.
Definition predictor_base.hpp:37
@ None
Image data is (if necessary) extracted without interpolation.
Definition predictor_base.hpp:35
std::shared_ptr< PolimagoFactoryCreatedObject > PolimagoFactoryCreatedObjectPtr
Convenience shared pointer for PolimagoFactoryCreatedObject.
Definition predictor_base.hpp:208
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49