CVB++ 15.0
transform_2d.hpp
1#pragma once
2
3#if defined _WIN32
4
5#include "../_cexports/c_foundation.h"
6
7#include "../global.hpp"
8#include "../image.hpp"
9#include "../exception.hpp"
10#include "../size_2d.hpp"
11#include "../angle.hpp"
12#include "../matrix_2d.hpp"
13#include "../point_2d.hpp"
14#include "../rect.hpp"
15#include "../string.hpp"
16#include "../_detail/detail_pixel_list.hpp"
17#include "../area_2d.hpp"
18#include "../rect.hpp"
19
20#include <memory>
21#include <vector>
22#include <utility>
23#include <algorithm>
24#include <iterator>
25#include <functional>
26
27namespace Cvb
28{
29CVB_BEGIN_INLINE_NS
30
31namespace Foundation { namespace Transform2D { class NonLinearTransformation; } }
32
33template <>
34inline HandleGuard<Foundation::Transform2D::NonLinearTransformation>::HandleGuard(void * handle) noexcept
35 : HandleGuard<Foundation::Transform2D::NonLinearTransformation>(handle, [](void* h) { CVB_CALL_CAPI(ReleaseObject(h)); })
36{
37}
38
39
40
41
42namespace Foundation
43{
44
46
50namespace Transform2D
51{
52
54enum class Interpolation
55{
58 NearestNeighbor = CExports::IP_NearestNeighbour,
61 Linear = CExports::IP_Linear,
64 Cubic = CExports::IP_Cubic,
66 Lanczos = CExports::IP_Lanczos,
69 Supersample = CExports::IP_Supersample
70};
71
73enum class Axis
74{
76 NoAxis = 0,
78 X = 1,
80 Y = 2,
82 Both = 3
83};
84
86
94{
95 public:
96
98
107 Rect<int> destRect)
108 {
109 CVB_CALL_CAPI_CHECKED(CalcPerspectiveTransformation (destRect.Left(), destRect.Top(), destRect.Right(), destRect.Bottom(),
110 leftTop.X(), leftTop.Y(), rightTop.X(), rightTop.Y(),
111 rightBottom.X(), rightBottom.Y(), leftBottom.X(), leftBottom.Y(),
112 c00_, c01_, c02_, c10_, c11_, c12_, c20_, c21_, c22_));
113 }
114
116
125 Rect<double> destRect)
126 {
127 CVB_CALL_CAPI_CHECKED(CalcPerspectiveTransformationEx (destRect.Left(), destRect.Top(), destRect.Right(), destRect.Bottom(),
128 leftTop.X(), leftTop.Y(), rightTop.X(), rightTop.Y(),
129 rightBottom.X(), rightBottom.Y(), leftBottom.X(), leftBottom.Y(),
130 c00_, c01_, c02_, c10_, c11_, c12_, c20_, c21_, c22_));
131 }
132
134
138 double C00() const noexcept
139 {
140 return c00_;
141 }
142
144
148 double C01() const noexcept
149 {
150 return c01_;
151 }
152
154
158 double C02() const noexcept
159 {
160 return c02_;
161 }
162
164
168 double C10() const noexcept
169 {
170 return c10_;
171 }
172
174
178 double C11() const noexcept
179 {
180 return c11_;
181 }
182
184
188 double C12() const noexcept
189 {
190 return c12_;
191 }
192
194
198 double C20() const noexcept
199 {
200 return c20_;
201 }
202
204
208 double C21() const noexcept
209 {
210 return c21_;
211 }
212
214
218 double C22() const noexcept
219 {
220 return c22_;
221 }
222
223
224
225 private:
226 double c00_ = 0.0;
227 double c01_ = 0.0;
228 double c02_ = 0.0;
229 double c10_ = 0.0;
230 double c11_ = 0.0;
231 double c12_ = 0.0;
232 double c20_ = 0.0;
233 double c21_ = 0.0;
234 double c22_ = 0.0;
235};
236
237
239
247inline std::unique_ptr<Image> MatrixTransform (const Image & image, const Matrix2D & matrix, Interpolation interpolation = Interpolation::Linear)
248{
249 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
250 {
251 /* Note: the binary compatibility between Matrix and TMatrix is guaranteed, therefore the cast below is legal. */
252 return CVB_CALL_CAPI(MatrixTransformImage (image.Handle (), reinterpret_cast<const CExports::TMatrix&>(matrix),
253 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
254 });
255}
256
258
265inline std::unique_ptr<Image> Mirror (const Image & image, Axis axis)
266{
267 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
268 {
269 return CVB_CALL_CAPI(MirrorImage (image.Handle (), axis==Axis::X || axis==Axis::Both, axis==Axis::Y || axis==Axis::Both, resimg));
270 });
271}
272
274
284 Size2D<int> targetSize, Interpolation interpolation = Interpolation::Linear)
285{
286 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
287 {
288 return CVB_CALL_CAPI(PerspectiveTransformImage (image.Handle (), targetSize.Width(), targetSize.Height(), 0, 0,
289 coeffs.C00(), coeffs.C01(), coeffs.C02(), coeffs.C10(), coeffs.C11(), coeffs.C12(), coeffs.C20(), coeffs.C21(), coeffs.C22(),
290 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
291 });
292}
293
295
303inline std::unique_ptr<Image> Resize (const Image & image, Size2D<int> targetSize, Interpolation interpolation = Interpolation::Linear)
304{
305 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
306 {
307 return CVB_CALL_CAPI(ResizeImage (image.Handle (), targetSize.Width(), targetSize.Height(),
308 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
309 });
310}
311
313
321inline std::unique_ptr<Image> Rotate (const Image & image, Angle angle, Interpolation interpolation = Interpolation::Linear)
322{
323 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
324 {
325 return CVB_CALL_CAPI(RotateImage (image.Handle (), angle.Deg(),
326 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
327 });
328}
329
331
340inline std::unique_ptr<Image> Shear (const Image & image, double shearX, double shearY, Interpolation interpolation = Interpolation::Linear)
341{
342 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
343 {
344 return CVB_CALL_CAPI(ShearImage (image.Handle (), shearX, shearY,
345 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
346 });
347}
348
351{
353 BlackOnWhite = CExports::CPC_Black_On_White,
355 WhiteOnBlack = CExports::CPC_White_On_Black
356};
357
360{
362 UniformDots = CExports::CPS_Uniform_Dots,
364 AsymmetricDots = CExports::CPS_Asymmetric_Dots
365};
366
369{
371 A4,
373 Letter
374};
375
378{
380 Portrait,
383};
384
386
405inline std::unique_ptr<Image> CreateCalibrationPattern (CalibrationPatternStyle style, CalibrationPatternContrast contrast, int width, int height, int numColumns, int numRows)
406{
407 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
408 {
409 return CVB_CALL_CAPI(CreateCalibrationPattern(width, height, numColumns, numRows,
410 static_cast<CExports::TCalibrationPatternStyle>(style), static_cast<CExports::TCalibrationPatternContrast>(contrast),
411 resimg));
412 });
413}
414
416
448 int numColumns, int numRows, double horizontalBorder, double verticalBorder, int dpi)
449{
450 return Internal::DoResCallObjectOut<Image> ([&](void* & resimg)
451 {
452 switch (paperSize)
453 {
455 return CVB_CALL_CAPI (CreateCalibrationPatternA4 (numColumns, numRows, horizontalBorder, verticalBorder, dpi, orientation == CalibrationPatternOrientation::Landscape,
456 static_cast<CExports::TCalibrationPatternStyle>(style), static_cast<CExports::TCalibrationPatternContrast>(contrast),
457 resimg));
459 return CVB_CALL_CAPI (CreateCalibrationPatternLetter (numColumns, numRows, horizontalBorder, verticalBorder, dpi, orientation == CalibrationPatternOrientation::Landscape,
460 static_cast<CExports::TCalibrationPatternStyle>(style), static_cast<CExports::TCalibrationPatternContrast>(contrast),
461 resimg));
462 default:
463 throw std::invalid_argument ("unknown paper size format");
464 }
465 });
466}
467
469
519inline void ExtractCalibrationLists (const ImagePlane &plane, CalibrationPatternStyle style, CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio, Area2D aoi,
520 std::vector<Point2D<double>> &originalPixels, std::vector<Point2D<double>> &transformedPixels)
521{
522 CExports::PIXELLIST originalPixelList = nullptr;
523 CExports::PIXELLIST transformedPixelList = nullptr;
524
525 CVB_CALL_CAPI_CHECKED (GetCalibrationLists (plane.Parent().Handle(), plane.Plane(), static_cast<CExports::TCalibrationPatternStyle>(style), static_cast<CExports::TCalibrationPatternContrast>(contrast),
526 reinterpret_cast<CExports::TArea&>(aoi), gridSpacing, minContrast, maxRatio, originalPixelList, transformedPixelList));
527 HandleGuard<Internal::PixelList> originalGuard(originalPixelList);
528 HandleGuard<Internal::PixelList> transformedGuard(transformedPixelList);
529
530 originalPixels = Internal::PixelList::FromHandle(std::move(originalGuard))->ToPoints();
531 transformedPixels = Internal::PixelList::FromHandle(std::move(transformedGuard))->ToPoints();
532}
533
535
574inline void ExtractCalibrationLists (const ImagePlane &plane, CalibrationPatternStyle style, CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio,
575 std::vector<Point2D<double>> &originalPixels, std::vector<Point2D<double>> &transformedPixels)
576{
577 ExtractCalibrationLists (plane, style, contrast, gridSpacing, minContrast, maxRatio, Area2D (static_cast<Rect<double>>(plane.Parent ().Bounds ())), originalPixels, transformedPixels);
578}
579
581
584{
585 struct PrivateTag {};
586
587public:
588 // Internal helper constructor version
589 NonLinearTransformation (HandleGuard<NonLinearTransformation>&& guard, PrivateTag)
590 : handle_(std::move(guard)),
591 coefficientsTransX_(), coefficientsTransY_(), coefficientsInvTransX_(), coefficientsInvTransY_()
592 {
593 // retrieve the transformations' coefficients
594 auto numCoefficients = CVB_CALL_CAPI (NLTransformNumCoefficients(handle_.Handle()));
595 if (numCoefficients < 0)
596 {
597 Utilities::SystemInfo::ThrowLastError ();
598 }
599
600 coefficientsTransX_.resize (numCoefficients);
601 coefficientsTransY_.resize (numCoefficients);
602 coefficientsInvTransX_.resize (numCoefficients);
603 coefficientsInvTransY_.resize (numCoefficients);
604
605 CVB_CALL_CAPI_CHECKED (NLTransformCoefficients(handle_.Handle(), coefficientsTransX_.data(), coefficientsTransY_.data(),
606 coefficientsInvTransX_.data(), coefficientsInvTransY_.data()));
607 }
608
609private:
610 // Helper to load a saved transformation from file
611 static CExports::NLTRANSFORMATION LoadInternal (const String & fileName)
612 {
613 CExports::NLTRANSFORMATION transformation = nullptr;
614
615 CVB_CALL_CAPI_CHECKED (LoadNLTransformFileTyped (fileName.c_str(), transformation));
616 return transformation;
617 }
618
619public:
621
626 : NonLinearTransformation(HandleGuard<NonLinearTransformation>(LoadInternal(fileName)), PrivateTag{})
627 { }
628
629
632
634 NonLinearTransformation& operator=(NonLinearTransformation&&) noexcept = default;
635
636public:
638
643 static std::unique_ptr<NonLinearTransformation> Load (const String & fileName)
644 {
645 return std::make_unique<NonLinearTransformation>(fileName);
646 }
647
649
655 void * Handle() const noexcept
656 {
657 return handle_.Handle();
658 }
659
661
668 static std::unique_ptr<NonLinearTransformation> FromHandle (HandleGuard<NonLinearTransformation>&& guard)
669 {
670 if (!guard.Handle ())
671 {
672 throw std::invalid_argument ("invalid non-linear transformation native handle");
673 }
674 return std::make_unique<NonLinearTransformation>(std::move(guard), PrivateTag{});
675 }
676
677 typedef std::function<bool (int stepsTotal, int stepsDone)> CreationProgress;
678
680
689 template <class RANGE>
690 static typename TypedRange<std::unique_ptr<NonLinearTransformation>, Point2D<double>, RANGE>::type FromPositionLists (const RANGE & originalPixels, const RANGE & transformedPixels,
691 int order, CreationProgress progressCallback = CreationProgress())
692 {
693 auto originalPixelList = Internal::PixelList::FromPoints (originalPixels);
694 auto transformedPixelList = Internal::PixelList::FromPoints (transformedPixels);
695 double quality;
696
697 return Internal::DoResCallObjectOut<NonLinearTransformation>([&](void* & restrans)
698 {
699 return CVB_CALL_CAPI(CreateNLTransform (originalPixelList->Handle (), transformedPixelList->Handle (), order,
700 progressCallback ? CreationProgressCaller : nullptr, &progressCallback,
701 restrans, quality));
702 });
703 }
704
706
754 int gridSpacing, int minContrast, double maxRatio, int order, Area2D aoi,
755 CreationProgress progressCallback = CreationProgress())
756 {
757 std::vector<Point2D<double>> original, transformed;
758 ExtractCalibrationLists (plane, style, contrast, gridSpacing, minContrast, maxRatio, aoi, original, transformed);
759
760 return FromPositionLists(original, transformed, order, progressCallback);
761 }
762
764
798 int gridSpacing, int minContrast, double maxRatio, int order,
799 CreationProgress progressCallback = CreationProgress())
800 {
801 return FromCalibrationPattern (plane, style, contrast, gridSpacing, minContrast, maxRatio, order,
802 Area2D (static_cast<Rect<double>>(plane.Parent ().Bounds ())), progressCallback);
803 }
804
806
810 int Order() const noexcept
811 {
812 return CVB_CALL_CAPI (NLTransformOrder(handle_.Handle()));
813 }
814
816
821 {
822 return coefficientsTransX_;
823 }
824
826
831 {
832 return coefficientsTransY_;
833 }
834
836
841 {
842 return coefficientsInvTransX_;
843 }
844
846
851 {
852 return coefficientsInvTransY_;
853 }
854
856
861 void Save (const String & fileName) const
862 {
863 CVB_CALL_CAPI_CHECKED (WriteNLTransformFileTyped (handle_.Handle(), fileName.c_str()));
864 }
865
867
875 std::unique_ptr<Image> Transform (const Image & image, Size2D<int> targetSize, Point2D<int> targetOffset)
876 {
877 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
878 {
879 return CVB_CALL_CAPI(CreateNLTransformedImage (image.Handle (), handle_.Handle (), targetSize.Width(), targetSize.Height(), targetOffset.X(), targetOffset.Y(), resimg));
880 });
881 }
882
884
891 {
892 double x = point.X(), y = point.Y();
893 CVB_CALL_CAPI_CHECKED (ApplyNLTransform(handle_.Handle(), x, y));
894 return Point2D<double>(x, y);
895 }
896
898
907 {
908 auto topLeft = Transform(Point2D<double>(rect.Left(), rect.Top()));
909 auto topRight = Transform(Point2D<double>(rect.Right(), rect.Top()));
910 auto bottomLeft = Transform(Point2D<double>(rect.Left(), rect.Bottom()));
911 auto bottomRight = Transform(Point2D<double>(rect.Right(), rect.Bottom()));
912
913 return Rect<double>(std::min(topLeft.X(), std::min(topRight.X(), std::min(bottomLeft.X(), bottomRight.X()))),
914 std::min(topLeft.Y(), std::min(topRight.Y(), std::min(bottomLeft.Y(), bottomRight.Y()))),
915 std::max(topLeft.X(), std::max(topRight.X(), std::max(bottomLeft.X(), bottomRight.X()))),
916 std::max(topLeft.Y(), std::max(topRight.Y(), std::max(bottomLeft.Y(), bottomRight.Y()))));
917 }
918
920
926 template <class RANGE>
927 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type Transform (const RANGE & points)
928 {
930 std::transform (std::begin (points), std::end (points), std::back_inserter (results),
931 [this](Point2D<double> p) {return Transform (p); });
932
933 return results;
934 }
935
937
945 std::unique_ptr<Image> InverseTransform (const Image & image, Size2D<int> targetSize, Point2D<int> targetOffset)
946 {
947 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
948 {
949 return CVB_CALL_CAPI(CreateInverseNLTransformedImage (image.Handle (), handle_.Handle (), targetSize.Width(), targetSize.Height(), targetOffset.X(), targetOffset.Y(), resimg));
950 });
951 }
952
954
961 {
962 double x = point.X(), y = point.Y();
963 CVB_CALL_CAPI_CHECKED (ApplyInverseNLTransform(handle_.Handle(), x, y));
964 return Point2D<double>(x, y);
965 }
966
968
974 template <class RANGE>
975 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type InverseTransform (const RANGE & points)
976 {
978 std::transform (std::begin (points), std::end (points), std::back_inserter (results),
979 [this](Point2D<double> p) {return InverseTransform (p); });
980
981 return results;
982 }
983
984private:
985 static CExports::cvbbool_t __stdcall CreationProgressCaller (void* pPrivate, CExports::cvbval_t stepsTotal, CExports::cvbval_t stepsDone)
986 {
987 CreationProgress *cbk = reinterpret_cast<CreationProgress*> (pPrivate);
988 return (*cbk) (static_cast<int>(stepsTotal), static_cast<int>(stepsDone));
989 }
990
991private:
992 HandleGuard<NonLinearTransformation> handle_;
993 std::vector<double> coefficientsTransX_;
994 std::vector<double> coefficientsTransY_;
995 std::vector<double> coefficientsInvTransX_;
996 std::vector<double> coefficientsInvTransY_;
997}; /* class NonLinearTransformation */
998
1001
1002
1003} /* namespace Transform2D */
1004
1006using Transform2D::Axis;
1008
1014using Transform2D::Shear;
1015
1020
1024
1027
1028} /* namespace Foundation */
1029CVB_END_INLINE_NS
1030} /* namespace Cvb */
1031
1032#endif
Object for convenient and type - safe handling of angles.
Definition: angle.hpp:19
double Deg() const noexcept
Get the value in degrees.
Definition: angle.hpp:87
Structure that represents an area of interest in the image.
Definition: area_2d.hpp:21
Object implementing the non linear polynomially approximated transform implemented in the CVB Foundat...
Definition: transform_2d.hpp:584
std::vector< double > CoefficientsYInverse() const
Return an array of the coefficients used for the inverse transformation of x coordinates.
Definition: transform_2d.hpp:850
std::vector< double > CoefficientsY() const
Return an array of the coefficients used for the transformation of y coordinates.
Definition: transform_2d.hpp:830
static std::unique_ptr< NonLinearTransformation > FromHandle(HandleGuard< NonLinearTransformation > &&guard)
Creates transformation from a classic API handle.
Definition: transform_2d.hpp:668
NonLinearTransformation(NonLinearTransformation &&) noexcept=default
Move constructor.
std::vector< double > CoefficientsXInverse() const
Return an array of the coefficients used for the inverse transformation of x coordinates.
Definition: transform_2d.hpp:840
static std::unique_ptr< NonLinearTransformation > Load(const String &fileName)
Load a saved transformation from a file.
Definition: transform_2d.hpp:643
static std::unique_ptr< NonLinearTransformation > FromCalibrationPattern(const ImagePlane &plane, CalibrationPatternStyle style, CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio, int order, Area2D aoi, CreationProgress progressCallback=CreationProgress())
Create a new transformation object by automatically extracting the pixel lists required for creating ...
Definition: transform_2d.hpp:753
Rect< double > Transform(Rect< double > rect)
Transform a rect with this nonlinear transformation.
Definition: transform_2d.hpp:906
TypedRange< std::vector< Point2D< double > >, Point2D< double >, RANGE >::type InverseTransform(const RANGE &points)
Back transform a sequence of points with this nonlinear transformation.
Definition: transform_2d.hpp:975
Point2D< double > InverseTransform(Point2D< double > point)
Back transform a point with this nonlinear transformation.
Definition: transform_2d.hpp:960
void Save(const String &fileName) const
Write the transformation to a file.
Definition: transform_2d.hpp:861
int Order() const noexcept
Gets the transformation order.
Definition: transform_2d.hpp:810
Point2D< double > Transform(Point2D< double > point)
Transform a point with this nonlinear transformation.
Definition: transform_2d.hpp:890
static std::unique_ptr< NonLinearTransformation > FromCalibrationPattern(const ImagePlane &plane, CalibrationPatternStyle style, CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio, int order, CreationProgress progressCallback=CreationProgress())
Create a new transformation object by automatically extracting the pixel lists required for creating ...
Definition: transform_2d.hpp:797
std::vector< double > CoefficientsX() const
Return an array of the coefficients used for the transformation of x coordinates.
Definition: transform_2d.hpp:820
TypedRange< std::vector< Point2D< double > >, Point2D< double >, RANGE >::type Transform(const RANGE &points)
Transform a sequence of points with this nonlinear transformation.
Definition: transform_2d.hpp:927
std::unique_ptr< Image > Transform(const Image &image, Size2D< int > targetSize, Point2D< int > targetOffset)
Transform an image with this nonlinear transformation.
Definition: transform_2d.hpp:875
void * Handle() const noexcept
Classic API NLTRANSFORMATION handle.
Definition: transform_2d.hpp:655
NonLinearTransformation(const String &fileName)
Load a saved transformation from a file.
Definition: transform_2d.hpp:625
static TypedRange< std::unique_ptr< NonLinearTransformation >, Point2D< double >, RANGE >::type FromPositionLists(const RANGE &originalPixels, const RANGE &transformedPixels, int order, CreationProgress progressCallback=CreationProgress())
Create a non linear transformation that - approximately - matches the set of originalPixels to the se...
Definition: transform_2d.hpp:690
std::unique_ptr< Image > InverseTransform(const Image &image, Size2D< int > targetSize, Point2D< int > targetOffset)
Back transform an image with this nonlinear transformation.
Definition: transform_2d.hpp:945
Perspective transformation coefficients.
Definition: transform_2d.hpp:94
double C10() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:168
double C00() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:138
double C02() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:158
PerspectiveTransformation(Point2D< double > leftTop, Point2D< double > rightTop, Point2D< double > rightBottom, Point2D< double > leftBottom, Rect< double > destRect)
Calculate the defining coefficients for the perspective transformation.
Definition: transform_2d.hpp:124
PerspectiveTransformation(Point2D< double > leftTop, Point2D< double > rightTop, Point2D< double > rightBottom, Point2D< double > leftBottom, Rect< int > destRect)
Calculate the defining coefficients for the perspective transformation.
Definition: transform_2d.hpp:106
double C12() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:188
double C21() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:208
double C01() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:148
double C22() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:218
double C11() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:178
double C20() const noexcept
Get defining coefficient for the transformation.
Definition: transform_2d.hpp:198
The Common Vision Blox image.
Definition: decl_image.hpp:45
Image plane information container.
Definition: decl_image_plane.hpp:33
Double precision 2x2 matrix class.
Definition: matrix_2d.hpp:16
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
T Bottom() const noexcept
Gets bottom row of the rectangle (still inside the rectangle).
Definition: rect.hpp:151
T Top() const noexcept
Gets first row of the rectangle.
Definition: rect.hpp:111
T Right() const noexcept
Gets rightmost column of the rectangle (still inside the rectangle).
Definition: rect.hpp:131
T Left() const noexcept
Gets first column of the rectangle.
Definition: rect.hpp:91
T Height() const noexcept
Gets the vertical component of the size.
Definition: size_2d.hpp:79
T Width() const noexcept
Gets the horizontal component of the size.
Definition: size_2d.hpp:59
std::unique_ptr< Image > Shear(const Image &image, double shearX, double shearY, Interpolation interpolation=Interpolation::Linear)
Shear the input image.
Definition: transform_2d.hpp:340
std::unique_ptr< Image > Perspective(const Image &image, const PerspectiveTransformation &coeffs, Size2D< int > targetSize, Interpolation interpolation=Interpolation::Linear)
Apply the perspective transformation coefficients to the image.
Definition: transform_2d.hpp:283
void ExtractCalibrationLists(const ImagePlane &plane, CalibrationPatternStyle style, CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio, Area2D aoi, std::vector< Point2D< double > > &originalPixels, std::vector< Point2D< double > > &transformedPixels)
Automatically extracts the pixel lists required for creating a NonLinearTransformation object.
Definition: transform_2d.hpp:519
CalibrationPatternStyle
Definition of the calibration pattern style used for automatic calibration.
Definition: transform_2d.hpp:360
@ AsymmetricDots
Symmetric grid of dots. Four dots are bigger than the others and define the pattern's origin and orie...
@ UniformDots
Symmetric grid of uniformly sized, circle-shaped dots. With this pattern it is not possible to determ...
CalibrationPatternFormat
Definition of the paper format used for printing calibration patterns.
Definition: transform_2d.hpp:369
@ Letter
Letter sized paper (8.5 x 11 inches).
CalibrationPatternContrast
Definition of the contrast of the pattern used for automatic calibration.
Definition: transform_2d.hpp:351
@ WhiteOnBlack
White objects on black background.
@ BlackOnWhite
Black objects on white background.
CalibrationPatternOrientation
Format orientation for the CalibrationPatternFormat.
Definition: transform_2d.hpp:378
@ Portrait
Portrait has the long side vertically.
@ Landscape
Landscape has the long side horizontally.
std::unique_ptr< Image > Resize(const Image &image, Size2D< int > targetSize, Interpolation interpolation=Interpolation::Linear)
Resize the input image.
Definition: transform_2d.hpp:303
Interpolation
Interpolation modes available inside the Foundation package.
Definition: transform_2d.hpp:55
std::unique_ptr< Image > MatrixTransform(const Image &image, const Matrix2D &matrix, Interpolation interpolation=Interpolation::Linear)
Use a matrix to transform an image.
Definition: transform_2d.hpp:247
std::unique_ptr< Image > Mirror(const Image &image, Axis axis)
Mirror the input image on the x and/or y axis.
Definition: transform_2d.hpp:265
std::shared_ptr< NonLinearTransformation > NonLinearTransformationPtr
Convenience shared pointer for NonLinearTransformation.
Definition: transform_2d.hpp:1000
std::unique_ptr< Image > Rotate(const Image &image, Angle angle, Interpolation interpolation=Interpolation::Linear)
Rotate the input image by the given angle.
Definition: transform_2d.hpp:321
std::unique_ptr< Image > CreatePrintableCalibrationPattern(CalibrationPatternStyle style, CalibrationPatternContrast contrast, CalibrationPatternFormat paperSize, CalibrationPatternOrientation orientation, int numColumns, int numRows, double horizontalBorder, double verticalBorder, int dpi)
Create a user-definable calibration pattern suitable for printing on a sheet of paper.
Definition: transform_2d.hpp:447
Axis
Axis enumeration.
Definition: transform_2d.hpp:74
std::unique_ptr< Image > CreateCalibrationPattern(CalibrationPatternStyle style, CalibrationPatternContrast contrast, int width, int height, int numColumns, int numRows)
Create a user-definable calibration pattern.
Definition: transform_2d.hpp:405
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
@ X
Sensor pixel values are mirrored in X (or denoted by u), so that the columns of the range map will be...
@ Y
Sensor pixel values are mirrored in Y (or denoted by v), so that the range map pixel values will be f...