55 explicit constexpr ImageDpi(
unsigned int i)
62 explicit operator unsigned int()
const
71 [[nodiscard]]
unsigned int ToDPCM()
const
73 static constexpr float CmInInch = 2.54F;
74 return static_cast<unsigned int>(std::round(
static_cast<float>(dpi) / CmInInch));
84 static constexpr float CmInInch = 2.54F;
85 return ImageDpi{
static_cast<unsigned int>(
static_cast<float>(dpcm) * CmInInch) };
88 bool operator==(
const ImageDpi& r)
const
94 ~ImageDpi() =
default;
95 ImageDpi(
const ImageDpi&) =
default;
96 ImageDpi(ImageDpi&&) =
default;
97 ImageDpi& operator=(
const ImageDpi&) =
default;
98 ImageDpi& operator=(ImageDpi&&) =
default;
101 static constexpr unsigned int DefaultDpi = 500;
128 using Radius =
unsigned int;
135 class RawImage :
public Serializable
186 [[nodiscard]]
const std::vector<uint8_t>&
Data()
const
197 writer.Write(
"t",
type);
198 writer.Write(
"h",
height);
199 writer.Write(
"w",
width);
200 writer.Write(
"p",
static_cast<unsigned int>(
dpi));
201 writer.WriteArray(
"d", data);
248 bool operator==(
const RawImage& r)
const
253 bool operator!=(
const RawImage& r)
const
255 return !(*
this == r);
259 std::vector<uint8_t> data;
261 static unsigned char Channels(Type t)
312 class Point final :
public Serializable
320 Point(
X xCoordinate,
Y yCoordinate)
333 writer.Write(
"x",
x);
334 writer.Write(
"y",
y);
343 bool operator==(
const Point& r)
const
345 return r.
x == x && r.
y == y;
348 virtual ~Point() =
default;
357 class Rectangle final :
public Serializable
450 int newTopRightX = 0;
451 int newTopRightY = 0;
452 int newBottomRightX = 0;
453 int newBottomRightY = 0;
454 int newBottomLeftX = 0;
455 int newBottomLeftY = 0;
456 exec->ResizeRectangle(w,
476 return { { newTopLeftX, newTopLeftY },
477 { newTopRightX, newTopRightY },
478 { newBottomRightX, newBottomRightY },
479 { newBottomLeftX, newBottomLeftY },
492 static_cast<int>(
static_cast<float>(topLeft.x + bottomRight.x + topRight.x + bottomLeft.x) / 4.0F);
494 static_cast<int>(
static_cast<float>(topLeft.y + bottomRight.y + topRight.y + bottomLeft.y) / 4.0F);
495 return { centerX, centerY };
500 writer.Write(
"tl", topLeft);
501 writer.Write(
"tr", topRight);
502 writer.Write(
"br", bottomRight);
503 writer.Write(
"bl", bottomLeft);
504 writer.Write(
"h", height);
505 writer.Write(
"w", width);
519 std::move(topRightPoint),
520 std::move(bottomRightPoint),
521 std::move(bottomLeftPoint),
538 Point bottomRightPoint,
539 Point bottomLeftPoint,
540 std::shared_ptr<ImageExecutor> executor)
541 : topLeft(std::move(topLeftPoint))
542 , topRight(std::move(topRightPoint))
543 , bottomLeft(std::move(bottomLeftPoint))
544 , bottomRight(std::move(bottomRightPoint))
545 , exec(std::move(executor))
552 exec->GetRectangleDimensions(&width,
570 bool operator==(
const Rectangle& r)
const
572 return r.bottomLeft == bottomLeft && r.bottomRight == bottomRight && r.topLeft == topLeft &&
573 r.topRight == topRight;
576 bool operator!=(
const Rectangle& r)
const
578 return !(*
this == r);
581 virtual ~Rectangle() =
default;
582 Rectangle() =
default;
585 Rectangle(Point topLeftPoint,
587 Point bottomRightPoint,
588 Point bottomLeftPoint,
591 std::shared_ptr<ImageExecutor> executor)
592 : topLeft(std::move(topLeftPoint))
593 , topRight(std::move(topRightPoint))
594 , bottomLeft(std::move(bottomLeftPoint))
595 , bottomRight(std::move(bottomRightPoint))
598 , exec(std::move(executor))
607 Height height = 0.0F;
608 std::shared_ptr<ImageExecutor> exec;
615 class Line final :
public Serializable
625 writer.Write(
"b",
begin);
626 writer.Write(
"e",
end);
635 :
begin(std::move(beginPoint))
636 ,
end(std::move(endPoint))
646 Line(
Point b,
float angle,
unsigned int length)
647 :
begin(std::move(b))
648 ,
end(CalculateEndPoint(
begin, angle, length))
653 Line& operator=(
const Line&) =
default;
656 bool operator==(
const Line& r)
const
658 return r.
begin == begin && r.
end == end;
661 bool operator!=(
const Line& r)
const
663 return !(*
this == r);
666 virtual ~Line() =
default;
670 static Point CalculateEndPoint(
const Point& begin,
float angle,
unsigned int length)
675 static constexpr float PiNum = 3.14159265358979323846F;
676 static constexpr float Degrees = 180.0F;
678 auto angleRadians = angle * PiNum / Degrees;
679 auto ex =
static_cast<X>(
680 std::round(
static_cast<float>(begin.
x) +
static_cast<float>(length) * std::cos(angleRadians)));
681 auto ey =
static_cast<Y>(
682 std::round(
static_cast<float>(begin.
y) -
static_cast<float>(length) * std::sin(angleRadians)));
683 return Point{ ex, ey };
691 class Circle final :
public Serializable
708 const float diameter = std::min(width, height);
709 constexpr auto RadiusDiameterQuotient = 2.0F;
710 const auto radius =
static_cast<unsigned int>(diameter / RadiusDiameterQuotient);
717 writer.Write(
"c",
center);
718 writer.Write(
"r",
radius);
739 :
center(std::move(centerPoint))
750 bool operator==(
const Circle& c)
const
755 bool operator!=(
const Circle& c)
const
757 return !(*
this == c);
765 class Polygon final :
public Serializable
770 writer.WriteArray(
"p", p);
789 p.push_back(std::move(point));
797 [[nodiscard]]
const std::vector<Point>&
GetPoints()
const
807 explicit Polygon(std::vector<Point>&& points)
808 : p(std::move(points)) {};
815 explicit Polygon(
const std::vector<Point>& points)
825 bool operator==(
const Polygon& other)
const
827 auto otherIt = other.
GetPoints().cbegin();
828 for (
const auto& thisPoint : p)
830 if (thisPoint != *otherIt)
839 bool operator!=(
const Polygon& other)
const
841 return !(*
this == other);
845 std::vector<Point> p;
862 class RGB final :
public Serializable
866 unsigned char red = 0;
868 unsigned char green = 0;
870 unsigned char blue = 0;
874 writer.Write(
"r",
red);
875 writer.Write(
"g",
green);
876 writer.Write(
"b",
blue);
879 RGB(
unsigned char r,
unsigned char g,
unsigned char b)
885 RGB(
const RGB&) =
default;
886 RGB(RGB&&) =
default;
887 RGB& operator=(
const RGB&) =
default;
888 RGB& operator=(RGB&& c) =
default;
891 bool operator==(
const RGB& c)
const
893 return c.
red == red && c.
green == green && c.
blue == blue;
896 bool operator!=(
const RGB& c)
const
898 return !(*
this == c);
901 virtual ~RGB() =
default;
908 class RGBA final :
public Serializable
926 writer.Write(
"c",
color);
930 RGBA(
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char t) noexcept
935 RGBA(RGB rgb,
unsigned char t) noexcept
936 : color(std::move(rgb))
941 explicit RGBA(RGB rgb) noexcept
942 : color(std::move(rgb))
945 RGBA(
const RGBA& c) =
default;
946 RGBA(RGBA&& c) =
default;
947 RGBA& operator=(
const RGBA& c) =
default;
948 RGBA& operator=(RGBA&& c) =
default;
951 bool operator==(
const RGBA& c)
const
956 bool operator!=(
const RGBA& c)
const
958 return !(*
this == c);
961 virtual ~RGBA() =
default;
964#if defined SWIGPYTHON || defined SWIGRUBY
988 Colors(
const Colors&) =
delete;
989 Colors(Colors&&) =
delete;
990 Colors& operator=(
const Colors&) =
delete;
991 Colors& operator=(Colors&&) =
delete;
constexpr ImageDpi DefaultDpi
Provides default DPI Default DPI is 500.
Definition ImageAttribute.h:107
It holds circle dimensions.
Definition ImageAttribute.h:691
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:714
Point center
top left
Definition ImageAttribute.h:694
Rectangle BoundingRectangle() const
It provides bounding rectangle for circle.
Definition ImageAttribute.h:725
static Circle CreateInscribedCircle(const Rectangle &rect)
Creates the largest circle that fits entirely within a given rectangle.
Definition ImageAttribute.h:703
Circle(Point centerPoint, Radius circleRadius)
Constructor store given coordinates.
Definition ImageAttribute.h:737
Radius radius
top right
Definition ImageAttribute.h:696
Base exception for all enrollment-sdk invalid argument exceptions.
Definition EnrollmentException.h:96
Holds instance of ImageExecutor.
Definition ImageExecutor.h:1564
ImageDimensions(ImageWidth w, ImageHeight h)
Constructor store given dimensions.
Definition ImageAttribute.h:288
ImageWidth width
width
Definition ImageAttribute.h:295
ImageHeight height
height
Definition ImageAttribute.h:297
Image DPI.
Definition ImageAttribute.h:47
static ImageDpi FromDPCM(unsigned int dpcm)
Converts dot per centimeter to dot per inch.
Definition ImageAttribute.h:81
unsigned int ToDPCM() const
Converts DPI to dot per centimeter.
Definition ImageAttribute.h:70
constexpr ImageDpi(unsigned int i)
Construct a new DPI.
Definition ImageAttribute.h:54
It holds line points.
Definition ImageAttribute.h:615
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:622
Line(Point b, float angle, unsigned int length)
Constructor calculates end point based on angle and length.
Definition ImageAttribute.h:645
Point end
line end point
Definition ImageAttribute.h:620
Point begin
line begin point
Definition ImageAttribute.h:618
Line(Point beginPoint, Point endPoint)
Constructor store given coordinates.
Definition ImageAttribute.h:633
Null argument is not allowed.
Definition EnrollmentException.h:156
It holds X and Y coordinates of point.
Definition ImageAttribute.h:312
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:330
X x
X Coordinate.
Definition ImageAttribute.h:326
Point(X xCoordinate, Y yCoordinate)
Constructor store given dimensions.
Definition ImageAttribute.h:319
Y y
Y Coordinate.
Definition ImageAttribute.h:328
It holds polygon points.
Definition ImageAttribute.h:765
void AddPoint(const Point &point)
Adds a point to the polygon.
Definition ImageAttribute.h:777
Polygon(const std::vector< Point > &points)
Constructs a polygon with a given set of points.
Definition ImageAttribute.h:814
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:767
const std::vector< Point > & GetPoints() const
Retrieves the points describing the polygon.
Definition ImageAttribute.h:796
Polygon(std::vector< Point > &&points)
Constructs a polygon with a given set of points using move semantics.
Definition ImageAttribute.h:806
void AddPoint(Point &&point)
Adds a point to the polygon using move semantics.
Definition ImageAttribute.h:786
It holds RGB color with transparency.
Definition ImageAttribute.h:908
RGB color
color definition in RGB model
Definition ImageAttribute.h:911
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:923
@ FULLY_TRANSPARENT
Color is fully transparent, means it is not visible.
Definition ImageAttribute.h:918
@ FULLY_OPAQUE
Color is fully opaque, means it is visible.
Definition ImageAttribute.h:920
unsigned char transparency
Transparency where 0 is fully transparent and 255 is fully opaque.
Definition ImageAttribute.h:913
It holds RGB colors.
Definition ImageAttribute.h:862
unsigned char red
Red value of RGB color model. The value is in range <0,255>.
Definition ImageAttribute.h:865
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:871
unsigned char green
Green value of RGB color model. The value is in range <0,255>.
Definition ImageAttribute.h:867
unsigned char blue
Blue value of RGB color model. The value is in range <0,255>.
Definition ImageAttribute.h:869
Contains plain image data.
Definition ImageAttribute.h:135
RawImage(ImageWidth w, ImageHeight h, ImageDpi d, Type t, const std::vector< uint8_t > &r)
Construct a new Raw Image object Data vector is stored as a copy.
Definition ImageAttribute.h:231
const ImageHeight height
Image height in pixels.
Definition ImageAttribute.h:174
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:194
const ImageDpi dpi
Image DPI.
Definition ImageAttribute.h:170
const ImageWidth width
Image width in pixels.
Definition ImageAttribute.h:172
const unsigned char channels
Number of RawImage channels.
Definition ImageAttribute.h:178
RawImage(ImageWidth w, ImageHeight h, ImageDpi d, Type t, std::vector< uint8_t > &&r)
Construct a new Raw Image object Data vector is passed by rvalue reference for efficient transfer wit...
Definition ImageAttribute.h:213
Type
RawImage encoding type.
Definition ImageAttribute.h:139
@ GRAYSCALE
Raw data where image pixels are stored in grayscale format.
Definition ImageAttribute.h:146
@ BGR
Raw data where image pixels are stored in BGR format.
Definition ImageAttribute.h:153
@ BGRA
Raw data where image pixels are stored in BGR with alpha format.
Definition ImageAttribute.h:166
const std::vector< uint8_t > & Data() const
Definition ImageAttribute.h:185
const Type type
RawImage type.
Definition ImageAttribute.h:176
It holds rectangle vertexes, width, height.
Definition ImageAttribute.h:357
void WriteTo(Writer &writer) const final
Write itself into writer.
Definition ImageAttribute.h:497
Dimension Height
Rectangle height.
Definition ImageAttribute.h:367
Rectangle(Point topLeftPoint, Point topRightPoint, Point bottomRightPoint, Point bottomLeftPoint)
Constructor store given coordinates.
Definition ImageAttribute.h:516
float Dimension
The rectangle dimension.
Definition ImageAttribute.h:363
Rectangle Resize(Width w, Height h) const
Resize rectangle to given width and height.
Definition ImageAttribute.h:436
const Point & GetBottomLeft() const
Provides bottom-left vertex.
Definition ImageAttribute.h:401
Dimension Width
Rectangle width.
Definition ImageAttribute.h:371
const Point & GetTopLeft() const
Provides top-left vertex.
Definition ImageAttribute.h:377
const Point & GetBottomRight() const
Provides bottom-right vertex.
Definition ImageAttribute.h:393
Point CalculateCenter() const
Calculates the center point of the rectangle.
Definition ImageAttribute.h:488
Rectangle(Point topLeftPoint, Point topRightPoint, Point bottomRightPoint, Point bottomLeftPoint, std::shared_ptr< ImageExecutor > executor)
Constructor store given coordinates.
Definition ImageAttribute.h:535
Width GetWidth() const
Provides width of rectangle The width is distance between top-left and top-right vertexes.
Definition ImageAttribute.h:412
const Point & GetTopRight() const
Provides top-right vertex.
Definition ImageAttribute.h:385
Height GetHeight() const
Provides height of rectangle The height is distance between bottom-left and top-left vertexes.
Definition ImageAttribute.h:423
Provides interface for serialization of all classes.
Definition Writer.h:164
float Angle
Angle in degrees.
Definition ImageAttribute.h:122
unsigned int Radius
Radius.
Definition ImageAttribute.h:127
int Y
Y coordinate.
Definition ImageAttribute.h:117
ImageDimension ImageHeight
Image Height.
Definition ImageAttribute.h:36
unsigned int ImageDimension
Image dimension.
Definition ImageAttribute.h:31
ImageDimension ImageWidth
Image Width.
Definition ImageAttribute.h:41
int X
X coordinate.
Definition ImageAttribute.h:112