13#include "enrollment/Export.h"
51 expectNarrowFinger = expectNarrow;
61 return expectNarrowFinger;
70 writer.
Write(
"enf",
static_cast<int>(expectNarrowFinger));
85 bool expectNarrowFinger =
true;
106 std::vector<std::shared_ptr<PrintSegment>>
Segment(
const std::shared_ptr<PrintCapture>& capture)
final
109 auto r =
DoDetect(exec, capture->image, log);
111 std::vector<std::shared_ptr<PrintSegment>> res;
116 for (
unsigned int i = 0; i < r.count; i++)
119 { r.topLeftX[i], r.topLeftY[i] },
120 { r.topRightX[i], r.topRightY[i] },
123 { r.bottomLeftX[i], r.bottomLeftY[i] }
125 res.emplace_back(std::make_shared<PrintSegment>(
127 capture->printAttributes,
133 log.LogInfo(
"Print segmentation result %v", res);
153 explicit PrintDetector(std::shared_ptr<PrintExecutor> executor)
155 , exec(std::move(executor))
178 virtual inno_PrintDetector_result
DoDetect(
const std::shared_ptr<PrintExecutor>& executor,
179 const std::shared_ptr<Image>& image,
184 std::shared_ptr<PrintExecutor> exec;
206 writer.Write(
"mr", maxRotation);
207 writer.Write(
"rn",
static_cast<int>(reduceNoise));
220 static constexpr unsigned int MaxRotation = 45;
221 if (value > MaxRotation)
224 "Max rotation of fingers for AlgorithmicSegmentation MUST be in range <0,45>");
286 static constexpr unsigned int DefaultMaxRotation = 45;
287 unsigned int maxRotation = DefaultMaxRotation;
288 bool reduceNoise =
false;
297 : cfg(std::move(config))
314 , cfg(std::move(config))
338 Config cfg = Config::Default();
340 inno_PrintDetector_result DoDetect(
const std::shared_ptr<PrintExecutor>& executor,
341 const std::shared_ptr<Image>& image,
344 logger.LogInfo(
"Algorithmic segmentation of image %v and config %v", image, cfg);
345 auto gs = image->AsRawGrayscale();
346 return executor->AlgoSegment(gs.height,
348 static_cast<unsigned int>(gs.dpi),
350 cfg.GetMaxRotation(),
351 cfg.IsNoiseReduction(),
352 cfg.GetNarrowFingerPreference(),
376 writer.Write(
"mr", maxRotation);
377 writer.Write(
"ct", confidenceThreshold);
390 static constexpr unsigned int MaxRotation = 45;
391 if (value > MaxRotation)
394 "Max rotation of fingers for NeuralSegmentation MUST be in range <0,45>");
418 static constexpr unsigned int MaxConfidenceThreshold = 10000;
419 if (value > MaxConfidenceThreshold)
422 "Confidence threshold for NeuralSegmentation MUST be in range [0-10000]");
424 confidenceThreshold = value;
434 return confidenceThreshold;
465 static constexpr unsigned int DefaultMaxRotation = 45;
466 unsigned int maxRotation = DefaultMaxRotation;
467 static constexpr unsigned int DefaultConfidenceThreshold = 9000;
468 unsigned int confidenceThreshold = DefaultConfidenceThreshold;
477 : cfg(std::move(config))
497 , cfg(std::move(config))
521 inno_PrintDetector_result DoDetect(
const std::shared_ptr<PrintExecutor>& executor,
522 const std::shared_ptr<Image>& image,
525 logger.LogInfo(
"Neural segmentation of image %v and config %v", image, cfg);
526 auto gs = image->AsRawGrayscale();
527 return executor->NeuralSegment(gs.height,
529 static_cast<unsigned int>(gs.dpi),
531 cfg.GetMaxRotation(),
532 cfg.GetConfidenceThreshold(),
533 cfg.GetNarrowFingerPreference(),
Configuration for AlgorithmicSegmentation.
Definition PrintDetector.h:197
void WriteTo(Writer &writer) const final
Function serializes configuration via provided Writer.
Definition PrintDetector.h:203
void SetMaxRotation(unsigned int value)
It sets maximum rotation of fingers in the slap image.
Definition PrintDetector.h:217
void EnableNoiseReduction()
It enables noise reduction before segmentation.
Definition PrintDetector.h:242
bool IsNoiseReduction() const
It returns true when noise reduction before segmentation is enabled.
Definition PrintDetector.h:252
static Config Default()
Provides default config.
Definition PrintDetector.h:263
Config()=default
Constructs default configuration.
unsigned int GetMaxRotation() const
It gets maximum rotation of fingers in the slap image.
Definition PrintDetector.h:233
AlgorithmicSegmentation implements algorithmic segmentation from Innovatrics ISegLib library.
Definition PrintDetector.h:191
AlgorithmicSegmentation(Config config)
Construct a new AlgorithmicSegmentation object.
Definition PrintDetector.h:295
AlgorithmicSegmentation(Config config, std::shared_ptr< PrintExecutor > executor)
Construct a new AlgorithmicSegmentation object.
Definition PrintDetector.h:311
AlgorithmicSegmentation()=default
Construct a new Algorithmic Segmentation with default config.
AlgorithmicSegmentation(std::shared_ptr< PrintExecutor > executor)
Construct a new Algorithmic Segmentation with default config.
Definition PrintDetector.h:323
Base exception for all enrollment-sdk invalid argument exceptions.
Definition EnrollmentException.h:96
Holds instance of Logger.
Definition Logger.h:275
Holds instance of PrintExecutor.
Definition PrintExecutor.h:1300
Configuration for NeuralSegmentation.
Definition PrintDetector.h:367
void WriteTo(Writer &writer) const final
Function serializes configuration via provided Writer.
Definition PrintDetector.h:373
void SetConfidenceThreshold(unsigned int value)
It sets confidence threshold.
Definition PrintDetector.h:415
void SetMaxRotation(unsigned int value)
It sets maximum rotation of fingers in the slap image.
Definition PrintDetector.h:387
static Config Default()
Provides default config.
Definition PrintDetector.h:442
Config()=default
Constructs default configuration.
unsigned int GetConfidenceThreshold() const
It gets confidence threshold.
Definition PrintDetector.h:431
unsigned int GetMaxRotation() const
It gets maximum rotation of fingers in the slap image.
Definition PrintDetector.h:403
NeuralSegmentation implements segmentation based on neural network from Innovatrics ISegLib library.
Definition PrintDetector.h:361
NeuralSegmentation(Config config, std::shared_ptr< PrintExecutor > executor)
Construct a new NeuralSegmentation object.
Definition PrintDetector.h:494
NeuralSegmentation(std::shared_ptr< PrintExecutor > executor)
Construct a new NeuralSegmentation with default config.
Definition PrintDetector.h:505
NeuralSegmentation(Config config)
Construct a new NeuralSegmentation object.
Definition PrintDetector.h:475
NeuralSegmentation()
Construct a new NeuralSegmentation with default config.
Definition PrintDetector.h:483
Null argument is not allowed.
Definition EnrollmentException.h:156
void WriteTo(Writer &writer) const override
Function serializes configuration via provided Writer.
Definition PrintDetector.h:67
void SetNarrowFingerPreference(bool expectNarrow)
Informs the print detector to anticipate narrow fingers.
Definition PrintDetector.h:48
bool GetNarrowFingerPreference() const
Retrieves information about the expected narrowness of detected fingers.
Definition PrintDetector.h:58
PrintDetectorConfig()=default
Default PrintDetector configuration is.
PrintDetector implements segmentation by means of Innovatrics ISegLib library.
Definition PrintDetector.h:93
virtual inno_PrintDetector_result DoDetect(const std::shared_ptr< PrintExecutor > &executor, const std::shared_ptr< Image > &image, FormattingLogger &logger)=0
Template method for various segmentation strategies.
PrintDetector()
Construct a new PrintDetector object GlobalPrintExecutor is used for PrintSegment detection.
Definition PrintDetector.h:141
std::vector< std::shared_ptr< PrintSegment > > Segment(const std::shared_ptr< PrintCapture > &capture) final
Detects segments in given image The Function scans the provided capture to locate fingers.
Definition PrintDetector.h:105
PrintDetector(std::shared_ptr< PrintExecutor > executor)
Construct a new PrintDetector object.
Definition PrintDetector.h:152
It holds rectangle vertexes, width, height.
Definition ImageAttribute.h:357
Provides interface for serialization of all classes.
Definition Writer.h:164
virtual void Write(const char *name, const Serializable &s)=0
Serialize serializable.