CVB++ 14.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{
585private:
586 // Internal helper constructor version
587 NonLinearTransformation (HandleGuard<NonLinearTransformation>&& guard)
588 : handle_(std::move(guard)),
589 coefficientsTransX_(), coefficientsTransY_(), coefficientsInvTransX_(), coefficientsInvTransY_()
590 {
591 // retrieve the transformations' coefficients
592 auto numCoefficients = CVB_CALL_CAPI (NLTransformNumCoefficients(handle_.Handle()));
593 if (numCoefficients < 0)
594 {
595 Utilities::SystemInfo::ThrowLastError ();
596 }
597
598 coefficientsTransX_.resize (numCoefficients);
599 coefficientsTransY_.resize (numCoefficients);
600 coefficientsInvTransX_.resize (numCoefficients);
601 coefficientsInvTransY_.resize (numCoefficients);
602
603 CVB_CALL_CAPI_CHECKED (NLTransformCoefficients(handle_.Handle(), coefficientsTransX_.data(), coefficientsTransY_.data(),
604 coefficientsInvTransX_.data(), coefficientsInvTransY_.data()));
605 }
606
607 // Helper to load a saved transformation from file
608 static CExports::NLTRANSFORMATION LoadInternal (const String & fileName)
609 {
610 CExports::NLTRANSFORMATION transformation = nullptr;
611
612 CVB_CALL_CAPI_CHECKED (LoadNLTransformFileTyped (fileName.c_str(), transformation));
613 return transformation;
614 }
615
616public:
618
624 : NonLinearTransformation (HandleGuard<NonLinearTransformation>(LoadInternal (fileName)))
625 { }
626
627
630
632 NonLinearTransformation& operator=(NonLinearTransformation&&) noexcept = default;
633
634public:
636
641 static std::unique_ptr<NonLinearTransformation> Load (const String & fileName)
642 {
644 }
645
647
653 void * Handle() const noexcept
654 {
655 return handle_.Handle();
656 }
657
659
666 static std::unique_ptr<NonLinearTransformation> FromHandle (HandleGuard<NonLinearTransformation>&& guard)
667 {
668 if (!guard.Handle ())
669 {
670 throw std::invalid_argument ("invalid non-linear transformation native handle");
671 }
673 }
674
675 typedef std::function<bool (int stepsTotal, int stepsDone)> CreationProgress;
676
678
687 template <class RANGE>
688 static typename TypedRange<std::unique_ptr<NonLinearTransformation>, Point2D<double>, RANGE>::type FromPositionLists (const RANGE & originalPixels, const RANGE & transformedPixels,
689 int order, CreationProgress progressCallback = CreationProgress())
690 {
691 auto originalPixelList = Internal::PixelList::FromPoints (originalPixels);
692 auto transformedPixelList = Internal::PixelList::FromPoints (transformedPixels);
693 double quality;
694
695 return Internal::DoResCallObjectOut<NonLinearTransformation>([&](void* & restrans)
696 {
697 return CVB_CALL_CAPI(CreateNLTransform (originalPixelList->Handle (), transformedPixelList->Handle (), order,
698 progressCallback ? CreationProgressCaller : nullptr, &progressCallback,
699 restrans, quality));
700 });
701 }
702
704
752 int gridSpacing, int minContrast, double maxRatio, int order, Area2D aoi,
753 CreationProgress progressCallback = CreationProgress())
754 {
755 std::vector<Point2D<double>> original, transformed;
756 ExtractCalibrationLists (plane, style, contrast, gridSpacing, minContrast, maxRatio, aoi, original, transformed);
757
758 return FromPositionLists(original, transformed, order, progressCallback);
759 }
760
762
796 int gridSpacing, int minContrast, double maxRatio, int order,
797 CreationProgress progressCallback = CreationProgress())
798 {
799 return FromCalibrationPattern (plane, style, contrast, gridSpacing, minContrast, maxRatio, order,
800 Area2D (static_cast<Rect<double>>(plane.Parent ().Bounds ())), progressCallback);
801 }
802
804
808 int Order() const noexcept
809 {
810 return CVB_CALL_CAPI (NLTransformOrder(handle_.Handle()));
811 }
812
814
819 {
820 return coefficientsTransX_;
821 }
822
824
829 {
830 return coefficientsTransY_;
831 }
832
834
839 {
840 return coefficientsInvTransX_;
841 }
842
844
849 {
850 return coefficientsInvTransY_;
851 }
852
854
859 void Save (const String & fileName) const
860 {
861 CVB_CALL_CAPI_CHECKED (WriteNLTransformFileTyped (handle_.Handle(), fileName.c_str()));
862 }
863
865
873 std::unique_ptr<Image> Transform (const Image & image, Size2D<int> targetSize, Point2D<int> targetOffset)
874 {
875 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
876 {
877 return CVB_CALL_CAPI(CreateNLTransformedImage (image.Handle (), handle_.Handle (), targetSize.Width(), targetSize.Height(), targetOffset.X(), targetOffset.Y(), resimg));
878 });
879 }
880
882
889 {
890 double x = point.X(), y = point.Y();
891 CVB_CALL_CAPI_CHECKED (ApplyNLTransform(handle_.Handle(), x, y));
892 return Point2D<double>(x, y);
893 }
894
896
905 {
906 auto topLeft = Transform(Point2D<double>(rect.Left(), rect.Top()));
907 auto topRight = Transform(Point2D<double>(rect.Right(), rect.Top()));
908 auto bottomLeft = Transform(Point2D<double>(rect.Left(), rect.Bottom()));
909 auto bottomRight = Transform(Point2D<double>(rect.Right(), rect.Bottom()));
910
911 return Rect<double>(std::min(topLeft.X(), std::min(topRight.X(), std::min(bottomLeft.X(), bottomRight.X()))),
912 std::min(topLeft.Y(), std::min(topRight.Y(), std::min(bottomLeft.Y(), bottomRight.Y()))),
913 std::max(topLeft.X(), std::max(topRight.X(), std::max(bottomLeft.X(), bottomRight.X()))),
914 std::max(topLeft.Y(), std::max(topRight.Y(), std::max(bottomLeft.Y(), bottomRight.Y()))));
915 }
916
918
924 template <class RANGE>
925 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type Transform (const RANGE & points)
926 {
928 std::transform (std::begin (points), std::end (points), std::back_inserter (results),
929 [this](Point2D<double> p) {return Transform (p); });
930
931 return results;
932 }
933
935
943 std::unique_ptr<Image> InverseTransform (const Image & image, Size2D<int> targetSize, Point2D<int> targetOffset)
944 {
945 return Internal::DoResCallObjectOut<Image>([&](void* & resimg)
946 {
947 return CVB_CALL_CAPI(CreateInverseNLTransformedImage (image.Handle (), handle_.Handle (), targetSize.Width(), targetSize.Height(), targetOffset.X(), targetOffset.Y(), resimg));
948 });
949 }
950
952
959 {
960 double x = point.X(), y = point.Y();
961 CVB_CALL_CAPI_CHECKED (ApplyInverseNLTransform(handle_.Handle(), x, y));
962 return Point2D<double>(x, y);
963 }
964
966
972 template <class RANGE>
973 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type InverseTransform (const RANGE & points)
974 {
976 std::transform (std::begin (points), std::end (points), std::back_inserter (results),
977 [this](Point2D<double> p) {return InverseTransform (p); });
978
979 return results;
980 }
981
982private:
983 static CExports::cvbbool_t __stdcall CreationProgressCaller (void* pPrivate, CExports::cvbval_t stepsTotal, CExports::cvbval_t stepsDone)
984 {
985 CreationProgress *cbk = reinterpret_cast<CreationProgress*> (pPrivate);
986 return (*cbk) (static_cast<int>(stepsTotal), static_cast<int>(stepsDone));
987 }
988
989private:
990 HandleGuard<NonLinearTransformation> handle_;
991 std::vector<double> coefficientsTransX_;
992 std::vector<double> coefficientsTransY_;
993 std::vector<double> coefficientsInvTransX_;
994 std::vector<double> coefficientsInvTransY_;
995}; /* class NonLinearTransformation */
996
999
1000
1001} /* namespace Transform2D */
1002
1004using Transform2D::Axis;
1006
1012using Transform2D::Shear;
1013
1018
1022
1025
1026} /* namespace Foundation */
1027CVB_END_INLINE_NS
1028} /* namespace Cvb */
1029
1030#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:848
std::vector< double > CoefficientsY() const
Return an array of the coefficients used for the transformation of y coordinates.
Definition: transform_2d.hpp:828
static std::unique_ptr< NonLinearTransformation > FromHandle(HandleGuard< NonLinearTransformation > &&guard)
Creates transformation from a classic API handle.
Definition: transform_2d.hpp:666
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:838
static std::unique_ptr< NonLinearTransformation > Load(const String &fileName)
Load a saved transformation from a file.
Definition: transform_2d.hpp:641
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:751
Rect< double > Transform(Rect< double > rect)
Transform a rect with this nonlinear transformation.
Definition: transform_2d.hpp:904
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:973
Point2D< double > InverseTransform(Point2D< double > point)
Back transform a point with this nonlinear transformation.
Definition: transform_2d.hpp:958
void Save(const String &fileName) const
Write the transformation to a file.
Definition: transform_2d.hpp:859
int Order() const noexcept
Gets the transformation order.
Definition: transform_2d.hpp:808
Point2D< double > Transform(Point2D< double > point)
Transform a point with this nonlinear transformation.
Definition: transform_2d.hpp:888
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:795
std::vector< double > CoefficientsX() const
Return an array of the coefficients used for the transformation of x coordinates.
Definition: transform_2d.hpp:818
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:925
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:873
void * Handle() const noexcept
Classic API NLTRANSFORMATION handle.
Definition: transform_2d.hpp:653
NonLinearTransformation(const String &fileName)
Load a saved transformation from a file.
Definition: transform_2d.hpp:623
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:688
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:943
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:998
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...