12#include "enrollment/Export.h"
41 const std::shared_ptr<Image>
image;
55 static std::shared_ptr<IrisCapture>
Create(std::shared_ptr<Image> img,
63 return std::shared_ptr<IrisCapture>(
new IrisCapture(std::move(img), pos, ia));
74 [[nodiscard]]
static std::shared_ptr<IrisCapture>
FromIsoImage(
const std::vector<uint8_t>& isoImage)
76 static constexpr size_t SizeOfIdentifier = 4UL;
77 static constexpr size_t SizeOfVersion = 4UL;
78 if (isoImage.size() < SizeOfIdentifier + SizeOfVersion)
82 if (
const std::vector<uint8_t>
id = {
'I',
'I',
'R',
'\0' };
83 std::search(isoImage.begin(), isoImage.end(),
id.begin(),
id.end()) == isoImage.end())
87 static constexpr size_t VersionIndex = SizeOfIdentifier;
88 if (
const std::vector<uint8_t> ver = {
'0',
'2',
'0',
'\0' };
89 std::search(isoImage.begin() + VersionIndex, isoImage.end(), ver.begin(), ver.end()) == isoImage.end())
93 static constexpr size_t QualityBlocksCountIndex = 34UL;
94 static constexpr size_t SizeOfQualityBlocksCount = 1UL;
95 if (isoImage.size() < (QualityBlocksCountIndex + SizeOfQualityBlocksCount))
98 "Fail to decode iris ISO image (fail to read quality blocks count)");
100 static constexpr size_t QualityBlockSize = 5UL;
101 const auto qualityBlocksCount = isoImage[QualityBlocksCountIndex];
102 const auto qualityBlocksSize = qualityBlocksCount * QualityBlockSize;
104 const auto representationHeaderIndex =
105 QualityBlocksCountIndex + SizeOfQualityBlocksCount + qualityBlocksSize;
106 static constexpr size_t RepresentationNumberSize = 2UL;
107 const auto positionIndex = representationHeaderIndex + RepresentationNumberSize;
108 static constexpr size_t PositionSize = 1UL;
109 if (isoImage.size() < positionIndex + PositionSize)
113 const auto position = isoImage[positionIndex];
114 const auto imageTypeIndex = positionIndex + PositionSize;
115 static constexpr size_t ImageTypeSize = 1UL;
116 if (isoImage.size() < imageTypeIndex + ImageTypeSize)
121 const auto imageFormatIndex = imageTypeIndex + ImageTypeSize;
122 static constexpr size_t ImageFormatSize = 1UL;
123 if (isoImage.size() < imageFormatIndex + ImageFormatSize)
127 auto imageFormat = isoImage[imageFormatIndex];
128 constexpr uint8_t ImageFormatMonoRaw = 2;
130 static constexpr size_t ImageLengthOffsetFromRepresentationStart = 29UL;
131 const auto imageLengthIndex = representationHeaderIndex + ImageLengthOffsetFromRepresentationStart;
132 static constexpr size_t SizeOfImageLength = 4UL;
133 if (isoImage.size() < (imageLengthIndex + SizeOfImageLength))
137 const size_t imageLength = (isoImage[imageLengthIndex] << 24U) + (isoImage[imageLengthIndex + 1] << 16U) +
138 (isoImage[imageLengthIndex + 2] << 8U) + isoImage[imageLengthIndex + 3];
139 const auto imageDataIndex = imageLengthIndex + SizeOfImageLength;
140 if (isoImage.size() < (imageDataIndex + imageLength))
144 std::vector<uint8_t> encodedImageData =
145 std::vector<uint8_t>(std::next(isoImage.begin(),
static_cast<ptrdiff_t
>(imageDataIndex)),
146 std::next(isoImage.begin(),
static_cast<ptrdiff_t
>(imageDataIndex + imageLength)));
148 static constexpr size_t CaptureEquipmentIdIndex = 30UL;
149 const unsigned int captureEquipmentID =
150 (isoImage[CaptureEquipmentIdIndex] << 8U) + isoImage[CaptureEquipmentIdIndex + 1];
151 static constexpr size_t CaptureDeviceTypeIdIndex = 32UL;
152 const unsigned int captureDeviceTypeID =
153 (isoImage[CaptureDeviceTypeIdIndex] << 8U) + isoImage[CaptureDeviceTypeIdIndex + 1];
156 static constexpr size_t CaptureDeviceTechnologyIndex = 29UL;
162 if (imageFormat == ImageFormatMonoRaw)
165 static constexpr size_t WidthOffsetFromRepresentationStart = 6UL;
166 const auto widthIndex = representationHeaderIndex + WidthOffsetFromRepresentationStart;
167 const ImageWidth width = ((isoImage[widthIndex] << 8U) + isoImage[widthIndex + 1]);
168 static constexpr size_t HeightOffsetFromRepresentationStart = 8UL;
169 const auto heightIndex = representationHeaderIndex + HeightOffsetFromRepresentationStart;
170 const ImageHeight height = ((isoImage[heightIndex] << 8U) + isoImage[heightIndex + 1]);
190 [[nodiscard]] std::shared_ptr<Image> DrawSegment(
const IrisSegment& segment,
194 const RoundingShape rcs(segment, pupil, iris);
195 return image->DrawShape(rcs);
198 IrisCapture(
const IrisCapture&) =
delete;
199 IrisCapture(IrisCapture&&) =
delete;
200 IrisCapture& operator=(
const IrisCapture&) =
delete;
201 IrisCapture& operator=(IrisCapture&&) =
delete;
202 virtual ~IrisCapture() =
default;
203 IrisCapture() =
delete;
212 IrisCapture(std::shared_ptr<Image> img,
const IrisPosition& pos, IrisAttributes ia)
213 : image(std::move(img))
215 , irisAttributes(std::move(ia))
219 class RoundingShape :
public ImageShape
222 void DrawIn(ImageShapeDrawer& drawer)
const final
224 auto ps = RectangleShape(iris.pupilRoundingBox, pupilAttr);
226 auto is = RectangleShape(iris.irisRoundingBox, irisAttr);
230 RoundingShape(
const IrisSegment& i, ImageShapeAttributes pc, ImageShapeAttributes ic)
232 , pupilAttr(std::move(pc))
233 , irisAttr(std::move(ic))
236 RoundingShape() =
delete;
237 virtual ~RoundingShape() =
default;
238 RoundingShape(
const RoundingShape&) =
delete;
239 RoundingShape(RoundingShape&&) =
delete;
240 RoundingShape& operator=(
const RoundingShape&) =
delete;
241 RoundingShape& operator=(RoundingShape&&) =
delete;
244 const IrisSegment& iris;
245 ImageShapeAttributes pupilAttr;
246 ImageShapeAttributes irisAttr;
constexpr ImageDpi DefaultDpi
Provides default DPI Default DPI is 500.
Definition ImageAttribute.h:107
Base exception for all enrollment-sdk invalid argument exceptions.
Definition EnrollmentException.h:96
It holds shape attributes such as color and line width.
Definition ImageShape.h:22
static std::shared_ptr< Image > DecodeRawImage(const RawImage &raw, std::shared_ptr< ImageEncoder > originalEncoder=nullptr, std::shared_ptr< ImageExecutor > executor=GlobalImageExecutor::Get())
Creates Image from raw data.
Definition Image.h:200
static std::shared_ptr< Image > Decode(const std::vector< uint8_t > &imageData)
Creates Image from image data with 500 DPI.
Definition Image.h:48
Iris attributes Holds the iris attributes.
Definition IrisAttributes.h:32
void SetCaptureDeviceTechnology(IrisCaptureDeviceTechnology technology)
Sets capture device technology.
Definition IrisAttributes.h:118
void SetImageType(IrisImageType type)
Set capture image type.
Definition IrisAttributes.h:188
void SetCaptureDeviceVendorID(IrisCaptureDeviceVendorID vendor)
Sets capture device vendor ID.
Definition IrisAttributes.h:138
void SetCaptureDeviceTypeID(IrisCaptureDeviceTypeID type)
Sets capture device type ID.
Definition IrisAttributes.h:158
The capture device type identifier shall identify the product type that created the BDIR.
Definition IrisCaptureDeviceTypeID.h:22
Capture device vendor identifier The capture device vendor identifier shall identify the biometric or...
Definition IrisCaptureDeviceVendorID.h:24
std::shared_ptr< IrisSegment > DetectWith(IrisDetector &detector) const
It detects iris.
Definition IrisCapture.h:184
const IrisAttributes irisAttributes
Provides IrisAttributes.
Definition IrisCapture.h:44
const IrisPosition position
Provides IrisPosition.
Definition IrisCapture.h:42
const std::shared_ptr< Image > image
Provides IrisCapture Image.
Definition IrisCapture.h:40
static std::shared_ptr< IrisCapture > Create(std::shared_ptr< Image > img, const IrisPosition &pos, const IrisAttributes &ia=IrisAttributes())
Constructor of IrisCapture.
Definition IrisCapture.h:54
static std::shared_ptr< IrisCapture > FromIsoImage(const std::vector< uint8_t > &isoImage)
Function creates shared pointer of the Iris object from ISO image based on ISO/IEC 19794-6 (Iris imag...
Definition IrisCapture.h:73
IrisDetector implements detection by means of Innovatrics IFace.
Definition IrisDetector.h:29
std::shared_ptr< IrisSegment > Detect(const std::shared_ptr< Image > &image, const IrisPosition &position, const IrisAttributes &ia=IrisAttributes()) const
Detect iris in given image.
Definition IrisDetector.h:169
It describes Iris segmented from original IrisCapture (one that contain this IrisSegment) with IrisDe...
Definition IrisSegment.h:32
It holds all functions and data related to iris manipulation.
Definition Iris.h:488
Interface for library logging.
Definition Logger.h:45
Null argument is not allowed.
Definition EnrollmentException.h:156
Contains plain image data.
Definition ImageAttribute.h:135
@ GRAYSCALE
Raw data where image pixels are stored in grayscale format.
Definition ImageAttribute.h:146
ImageDimension ImageHeight
Image Height.
Definition ImageAttribute.h:36
ImageDimension ImageWidth
Image Width.
Definition ImageAttribute.h:41
IrisPosition
It is position of iris on face iso_19794-6_2011.
Definition IrisPosition.h:22
static constexpr IrisPosition IsoToIrisPosition(int irisPosition)
Function converts ISO position to IrisPosition.
Definition IrisPosition.h:56
static constexpr IrisCaptureDeviceTechnology IsoToIrisCaptureDeviceTechnology(int isoCaptureDeviceTechnology)
Function converts ISO capture technology to IrisCaptureDeviceTechnology.
Definition IrisCaptureDeviceTechnology.h:61
static constexpr IrisImageType IsoToIrisImageType(int type)
Function converts ISO iris image type to IrisImageType.
Definition IrisImageType.h:72