CVB++ 15.1
Loading...
Searching...
No Matches
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{
29 CVB_BEGIN_INLINE_NS
30
31 namespace Foundation
32 {
33 namespace Transform2D
34 {
36 }
37 } // namespace Foundation
38
39 template <>
40 inline HandleGuard<Foundation::Transform2D::NonLinearTransformation>::HandleGuard(void *handle) noexcept
41 : HandleGuard<Foundation::Transform2D::NonLinearTransformation>(handle,
42 [](void *h) { CVB_CALL_CAPI(ReleaseObject(h)); })
43 {
44 }
45
46 namespace Foundation
47 {
48
50
54 namespace Transform2D
55 {
56
58 enum class Interpolation
59 {
62 NearestNeighbor = CExports::IP_NearestNeighbour,
65 Linear = CExports::IP_Linear,
68 Cubic = CExports::IP_Cubic,
70 Lanczos = CExports::IP_Lanczos,
73 Supersample = CExports::IP_Supersample
74 };
75
77 enum class Axis
78 {
80 NoAxis = 0,
82 X = 1,
84 Y = 2,
86 Both = 3
87 };
88
90
98 {
99 public:
101
110 Point2D<double> leftBottom, Rect<int> destRect)
111 {
112 CVB_CALL_CAPI_CHECKED(CalcPerspectiveTransformation(
113 destRect.Left(), destRect.Top(), destRect.Right(), destRect.Bottom(), leftTop.X(), leftTop.Y(),
114 rightTop.X(), rightTop.Y(), rightBottom.X(), rightBottom.Y(), leftBottom.X(), leftBottom.Y(), c00_, c01_,
115 c02_, c10_, c11_, c12_, c20_, c21_, c22_));
116 }
117
119
128 Point2D<double> leftBottom, Rect<double> destRect)
129 {
130 CVB_CALL_CAPI_CHECKED(CalcPerspectiveTransformationEx(
131 destRect.Left(), destRect.Top(), destRect.Right(), destRect.Bottom(), leftTop.X(), leftTop.Y(),
132 rightTop.X(), rightTop.Y(), rightBottom.X(), rightBottom.Y(), leftBottom.X(), leftBottom.Y(), c00_, c01_,
133 c02_, c10_, c11_, c12_, c20_, c21_, c22_));
134 }
135
137
141 double C00() const noexcept
142 {
143 return c00_;
144 }
145
147
151 double C01() const noexcept
152 {
153 return c01_;
154 }
155
157
161 double C02() const noexcept
162 {
163 return c02_;
164 }
165
167
171 double C10() const noexcept
172 {
173 return c10_;
174 }
175
177
181 double C11() const noexcept
182 {
183 return c11_;
184 }
185
187
191 double C12() const noexcept
192 {
193 return c12_;
194 }
195
197
201 double C20() const noexcept
202 {
203 return c20_;
204 }
205
207
211 double C21() const noexcept
212 {
213 return c21_;
214 }
215
217
221 double C22() const noexcept
222 {
223 return c22_;
224 }
225
226 private:
227 double c00_ = 0.0;
228 double c01_ = 0.0;
229 double c02_ = 0.0;
230 double c10_ = 0.0;
231 double c11_ = 0.0;
232 double c12_ = 0.0;
233 double c20_ = 0.0;
234 double c21_ = 0.0;
235 double c22_ = 0.0;
236 };
237
239
248 inline std::unique_ptr<Image> MatrixTransform(const Image &image, const Matrix2D &matrix,
249 Interpolation interpolation = Interpolation::Linear)
250 {
251 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
252 /* Note: the binary compatibility between Matrix and TMatrix is guaranteed, therefore the cast below is legal.
253 */
254 return CVB_CALL_CAPI(MatrixTransformImage(image.Handle(), reinterpret_cast<const CExports::TMatrix &>(matrix),
255 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
256 });
257 }
258
260
267 inline std::unique_ptr<Image> Mirror(const Image &image, Axis axis)
268 {
269 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
270 return CVB_CALL_CAPI(MirrorImage(image.Handle(), axis == Axis::X || axis == Axis::Both,
271 axis == Axis::Y || axis == Axis::Both, resimg));
272 });
273 }
274
276
287 Size2D<int> targetSize,
288 Interpolation interpolation = Interpolation::Linear)
289 {
290 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
291 return CVB_CALL_CAPI(PerspectiveTransformImage(
292 image.Handle(), targetSize.Width(), targetSize.Height(), 0, 0, coeffs.C00(), coeffs.C01(), coeffs.C02(),
293 coeffs.C10(), coeffs.C11(), coeffs.C12(), coeffs.C20(), coeffs.C21(), coeffs.C22(),
294 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
295 });
296 }
297
299
308 inline std::unique_ptr<Image> Resize(const Image &image, Size2D<int> targetSize,
309 Interpolation interpolation = Interpolation::Linear)
310 {
311 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
312 return CVB_CALL_CAPI(ResizeImage(image.Handle(), targetSize.Width(), targetSize.Height(),
313 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
314 });
315 }
316
318
327 inline std::unique_ptr<Image> Rotate(const Image &image, Angle angle,
328 Interpolation interpolation = Interpolation::Linear)
329 {
330 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
331 return CVB_CALL_CAPI(RotateImage(image.Handle(), angle.Deg(),
332 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
333 });
334 }
335
337
347 inline std::unique_ptr<Image> Shear(const Image &image, double shearX, double shearY,
348 Interpolation interpolation = Interpolation::Linear)
349 {
350 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
351 return CVB_CALL_CAPI(ShearImage(image.Handle(), shearX, shearY,
352 static_cast<CExports::TInterpolationMode>(interpolation), resimg));
353 });
354 }
355
358 {
360 BlackOnWhite = CExports::CPC_Black_On_White,
362 WhiteOnBlack = CExports::CPC_White_On_Black
363 };
364
367 {
370 UniformDots = CExports::CPS_Uniform_Dots,
373 AsymmetricDots = CExports::CPS_Asymmetric_Dots
374 };
375
384
393
395
416 CalibrationPatternContrast contrast, int width, int height,
417 int numColumns, int numRows)
418 {
419 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
420 return CVB_CALL_CAPI(CreateCalibrationPattern(
421 width, height, numColumns, numRows, static_cast<CExports::TCalibrationPatternStyle>(style),
422 static_cast<CExports::TCalibrationPatternContrast>(contrast), resimg));
423 });
424 }
425
427
463 int numColumns, int numRows, double horizontalBorder, double verticalBorder,
464 int dpi)
465 {
466 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
467 switch (paperSize)
468 {
470 return CVB_CALL_CAPI(
471 CreateCalibrationPatternA4(numColumns, numRows, horizontalBorder, verticalBorder, dpi,
473 static_cast<CExports::TCalibrationPatternStyle>(style),
474 static_cast<CExports::TCalibrationPatternContrast>(contrast), resimg));
476 return CVB_CALL_CAPI(
477 CreateCalibrationPatternLetter(numColumns, numRows, horizontalBorder, verticalBorder, dpi,
479 static_cast<CExports::TCalibrationPatternStyle>(style),
480 static_cast<CExports::TCalibrationPatternContrast>(contrast), resimg));
481 default:
482 throw std::invalid_argument("unknown paper size format");
483 }
484 });
485 }
486
488
544 CalibrationPatternContrast contrast, int gridSpacing, int minContrast,
545 double maxRatio, Area2D aoi, std::vector<Point2D<double>> &originalPixels,
546 std::vector<Point2D<double>> &transformedPixels)
547 {
548 CExports::PIXELLIST originalPixelList = nullptr;
549 CExports::PIXELLIST transformedPixelList = nullptr;
550
551 CVB_CALL_CAPI_CHECKED(GetCalibrationLists(
552 plane.Parent().Handle(), plane.Plane(), static_cast<CExports::TCalibrationPatternStyle>(style),
553 static_cast<CExports::TCalibrationPatternContrast>(contrast), reinterpret_cast<CExports::TArea &>(aoi),
554 gridSpacing, minContrast, maxRatio, originalPixelList, transformedPixelList));
555 HandleGuard<Internal::PixelList> originalGuard(originalPixelList);
556 HandleGuard<Internal::PixelList> transformedGuard(transformedPixelList);
557
558 originalPixels = Internal::PixelList::FromHandle(std::move(originalGuard))->ToPoints();
559 transformedPixels = Internal::PixelList::FromHandle(std::move(transformedGuard))->ToPoints();
560 }
561
563
608 CalibrationPatternContrast contrast, int gridSpacing, int minContrast,
609 double maxRatio, std::vector<Point2D<double>> &originalPixels,
610 std::vector<Point2D<double>> &transformedPixels)
611 {
612 ExtractCalibrationLists(plane, style, contrast, gridSpacing, minContrast, maxRatio,
613 Area2D(static_cast<Rect<double>>(plane.Parent().Bounds())), originalPixels,
614 transformedPixels);
615 }
616
619
621 class NonLinearTransformation
622 {
623 struct PrivateTag
624 {
625 };
626
627 public:
628 ~NonLinearTransformation() = default;
629 NonLinearTransformation(const NonLinearTransformation &) = delete;
630 NonLinearTransformation &operator=(const NonLinearTransformation &) = delete;
631
632
633 // Internal helper constructor version
634 NonLinearTransformation(HandleGuard<NonLinearTransformation> &&guard, PrivateTag)
635 : handle_(std::move(guard))
636 , coefficientsTransX_()
637 , coefficientsTransY_()
638 , coefficientsInvTransX_()
639 , coefficientsInvTransY_()
640 {
641 // retrieve the transformations' coefficients
642 auto numCoefficients = CVB_CALL_CAPI(NLTransformNumCoefficients(handle_.Handle()));
643 if (numCoefficients < 0)
644 {
645 Utilities::SystemInfo::ThrowLastError();
646 }
647
648 coefficientsTransX_.resize(numCoefficients);
649 coefficientsTransY_.resize(numCoefficients);
650 coefficientsInvTransX_.resize(numCoefficients);
651 coefficientsInvTransY_.resize(numCoefficients);
652
653 CVB_CALL_CAPI_CHECKED(NLTransformCoefficients(handle_.Handle(), coefficientsTransX_.data(),
654 coefficientsTransY_.data(), coefficientsInvTransX_.data(),
655 coefficientsInvTransY_.data()));
656 }
657
658 private:
659 // Helper to load a saved transformation from file
660 static CExports::NLTRANSFORMATION LoadInternal(const String &fileName)
661 {
662 CExports::NLTRANSFORMATION transformation = nullptr;
663
664 CVB_CALL_CAPI_CHECKED(LoadNLTransformFileTyped(fileName.c_str(), transformation));
665 return transformation;
666 }
667
668 public:
670
674 explicit NonLinearTransformation(const String &fileName)
675 : NonLinearTransformation(HandleGuard<NonLinearTransformation>(LoadInternal(fileName)), PrivateTag{})
676 {
677 }
678
680 NonLinearTransformation(NonLinearTransformation &&) noexcept = default;
681
683 NonLinearTransformation &operator=(NonLinearTransformation &&) noexcept = default;
684
686
691 static std::unique_ptr<NonLinearTransformation> Load(const String &fileName)
692 {
693 return std::make_unique<NonLinearTransformation>(fileName);
694 }
695
697
703 void *Handle() const noexcept
704 {
705 return handle_.Handle();
706 }
707
709
716 static std::unique_ptr<NonLinearTransformation> FromHandle(HandleGuard<NonLinearTransformation> &&guard)
717 {
718 if (!guard.Handle())
719 {
720 throw std::invalid_argument("invalid non-linear transformation native handle");
721 }
722 return std::make_unique<NonLinearTransformation>(std::move(guard), PrivateTag{});
723 }
724
725 typedef std::function<bool(int stepsTotal, int stepsDone)> CreationProgress;
726
729
739 template <class RANGE>
740 static typename TypedRange<std::unique_ptr<NonLinearTransformation>, Point2D<double>, RANGE>::type
741 FromPositionLists(const RANGE &originalPixels, const RANGE &transformedPixels, int order,
742 CreationProgress progressCallback = CreationProgress())
743 {
744 auto originalPixelList = Internal::PixelList::FromPoints(originalPixels);
745 auto transformedPixelList = Internal::PixelList::FromPoints(transformedPixels);
746 double quality = 0;
747
748 return Internal::DoResCallObjectOut<NonLinearTransformation>([&](void *&restrans) {
749 return CVB_CALL_CAPI(CreateNLTransform(originalPixelList->Handle(), transformedPixelList->Handle(), order,
750 progressCallback ? CreationProgressCaller : nullptr,
751 &progressCallback, restrans, quality));
752 });
753 }
754
757
809 CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio,
810 int order, Area2D aoi, CreationProgress progressCallback = CreationProgress())
811 {
812 std::vector<Point2D<double>> original, transformed;
813 ExtractCalibrationLists(plane, style, contrast, gridSpacing, minContrast, maxRatio, aoi, original,
814 transformed);
815
816 return FromPositionLists(original, transformed, order, progressCallback);
817 }
818
821
859 CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio,
860 int order, CreationProgress progressCallback = CreationProgress())
861 {
862 return FromCalibrationPattern(plane, style, contrast, gridSpacing, minContrast, maxRatio, order,
863 Area2D(static_cast<Rect<double>>(plane.Parent().Bounds())), progressCallback);
864 }
865
867
871 int Order() const noexcept
872 {
873 return CVB_CALL_CAPI(NLTransformOrder(handle_.Handle()));
874 }
875
877
882 {
883 return coefficientsTransX_;
884 }
885
887
892 {
893 return coefficientsTransY_;
894 }
895
897
902 {
903 return coefficientsInvTransX_;
904 }
905
907
912 {
913 return coefficientsInvTransY_;
914 }
915
917
922 void Save(const String &fileName) const
923 {
924 CVB_CALL_CAPI_CHECKED(WriteNLTransformFileTyped(handle_.Handle(), fileName.c_str()));
925 }
926
928
936 std::unique_ptr<Image> Transform(const Image &image, Size2D<int> targetSize, Point2D<int> targetOffset)
937 {
938 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
939 return CVB_CALL_CAPI(CreateNLTransformedImage(image.Handle(), handle_.Handle(), targetSize.Width(),
940 targetSize.Height(), targetOffset.X(), targetOffset.Y(),
941 resimg));
942 });
943 }
944
946
953 {
954 double x = point.X(), y = point.Y();
955 CVB_CALL_CAPI_CHECKED(ApplyNLTransform(handle_.Handle(), x, y));
956 return Point2D<double>(x, y);
957 }
958
960
969 {
970 auto topLeft = Transform(Point2D<double>(rect.Left(), rect.Top()));
971 auto topRight = Transform(Point2D<double>(rect.Right(), rect.Top()));
972 auto bottomLeft = Transform(Point2D<double>(rect.Left(), rect.Bottom()));
973 auto bottomRight = Transform(Point2D<double>(rect.Right(), rect.Bottom()));
974
975 return Rect<double>(std::min(topLeft.X(), std::min(topRight.X(), std::min(bottomLeft.X(), bottomRight.X()))),
976 std::min(topLeft.Y(), std::min(topRight.Y(), std::min(bottomLeft.Y(), bottomRight.Y()))),
977 std::max(topLeft.X(), std::max(topRight.X(), std::max(bottomLeft.X(), bottomRight.X()))),
978 std::max(topLeft.Y(), std::max(topRight.Y(), std::max(bottomLeft.Y(), bottomRight.Y()))));
979 }
980
982
988 template <class RANGE>
989 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type Transform(const RANGE &points)
990 {
992 std::transform(std::begin(points), std::end(points), std::back_inserter(results),
993 [this](Point2D<double> p) { return Transform(p); });
994
995 return results;
996 }
997
999
1008 {
1009 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
1010 return CVB_CALL_CAPI(CreateInverseNLTransformedImage(image.Handle(), handle_.Handle(), targetSize.Width(),
1011 targetSize.Height(), targetOffset.X(),
1012 targetOffset.Y(), resimg));
1013 });
1014 }
1015
1017
1024 {
1025 double x = point.X(), y = point.Y();
1026 CVB_CALL_CAPI_CHECKED(ApplyInverseNLTransform(handle_.Handle(), x, y));
1027 return Point2D<double>(x, y);
1028 }
1029
1031
1037 template <class RANGE>
1038 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type
1039 InverseTransform(const RANGE &points)
1040 {
1042 std::transform(std::begin(points), std::end(points), std::back_inserter(results),
1043 [this](Point2D<double> p) { return InverseTransform(p); });
1044
1045 return results;
1046 }
1047
1048 private:
1049 static CExports::cvbbool_t __stdcall CreationProgressCaller(void *pPrivate, CExports::cvbval_t stepsTotal,
1050 CExports::cvbval_t stepsDone)
1051 {
1052 CreationProgress *cbk = reinterpret_cast<CreationProgress *>(pPrivate);
1053 return (*cbk)(static_cast<int>(stepsTotal), static_cast<int>(stepsDone));
1054 }
1055
1056 private:
1057 HandleGuard<NonLinearTransformation> handle_;
1058 std::vector<double> coefficientsTransX_;
1059 std::vector<double> coefficientsTransY_;
1060 std::vector<double> coefficientsInvTransX_;
1061 std::vector<double> coefficientsInvTransY_;
1062 }; /* class NonLinearTransformation */
1063
1066
1067 } /* namespace Transform2D */
1068
1069 using Transform2D::Axis;
1072
1074 using Transform2D::Mirror;
1076 using Transform2D::Resize;
1077 using Transform2D::Rotate;
1078 using Transform2D::Shear;
1079
1084
1088
1091
1092 } /* namespace Foundation */
1093 CVB_END_INLINE_NS
1094} /* namespace Cvb */
1095
1096#endif
T back_inserter(T... args)
T begin(T... args)
Object for convenient and type - safe handling of angles.
Definition angle.hpp:16
double Deg() const noexcept
Get the value in degrees.
Definition angle.hpp:89
Structure that represents an area of interest in the image.
Definition area_2d.hpp:21
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:109
Object implementing the non linear polynomially approximated transform implemented in the CVB Foundat...
Definition transform_2d.hpp:622
std::vector< double > CoefficientsYInverse() const
Return an array of the coefficients used for the inverse transformation of x coordinates.
Definition transform_2d.hpp:911
std::vector< double > CoefficientsY() const
Return an array of the coefficients used for the transformation of y coordinates.
Definition transform_2d.hpp:891
static std::unique_ptr< NonLinearTransformation > FromHandle(HandleGuard< NonLinearTransformation > &&guard)
Creates transformation from a classic API handle.
Definition transform_2d.hpp:716
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:901
static std::unique_ptr< NonLinearTransformation > Load(const String &fileName)
Load a saved transformation from a file.
Definition transform_2d.hpp:691
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:808
Rect< double > Transform(Rect< double > rect)
Transform a rect with this nonlinear transformation.
Definition transform_2d.hpp:968
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:1039
Point2D< double > InverseTransform(Point2D< double > point)
Back transform a point with this nonlinear transformation.
Definition transform_2d.hpp:1023
void Save(const String &fileName) const
Write the transformation to a file.
Definition transform_2d.hpp:922
int Order() const noexcept
Gets the transformation order.
Definition transform_2d.hpp:871
Point2D< double > Transform(Point2D< double > point)
Transform a point with this nonlinear transformation.
Definition transform_2d.hpp:952
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:858
std::vector< double > CoefficientsX() const
Return an array of the coefficients used for the transformation of x coordinates.
Definition transform_2d.hpp:881
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:989
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:936
void * Handle() const noexcept
Classic API NLTRANSFORMATION handle.
Definition transform_2d.hpp:703
NonLinearTransformation(const String &fileName)
Load a saved transformation from a file.
Definition transform_2d.hpp:674
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:741
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:1007
Perspective transformation coefficients.
Definition transform_2d.hpp:98
double C10() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:171
double C00() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:141
double C02() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:161
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:127
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:109
double C12() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:191
double C21() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:211
double C01() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:151
double C22() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:221
double C11() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:181
double C20() const noexcept
Get defining coefficient for the transformation.
Definition transform_2d.hpp:201
The Common Vision Blox image.
Definition decl_image.hpp:50
Rect< int > Bounds() const noexcept
Bounding rectangle of the image in pixels.
Definition decl_image.hpp:438
void * Handle() const noexcept
Classic API image handle.
Definition decl_image.hpp:237
Image plane information container.
Definition decl_image_plane.hpp:31
int Plane() const noexcept
Plane index in the image, to which this plane refers to.
Definition decl_image_plane.hpp:149
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition detail_image_plane.hpp:87
Double precision 2x2 matrix class.
Definition matrix_2d.hpp:16
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
T X() const noexcept
Gets the x-component of the point.
Definition point_2d.hpp:84
T Y() const noexcept
Gets the y-component of the point.
Definition point_2d.hpp:104
Rectangle object.
Definition rect.hpp:24
T Bottom() const noexcept
Gets bottom row of the rectangle (still inside the rectangle).
Definition rect.hpp:144
T Top() const noexcept
Gets first row of the rectangle.
Definition rect.hpp:104
T Right() const noexcept
Gets rightmost column of the rectangle (still inside the rectangle).
Definition rect.hpp:124
T Left() const noexcept
Gets first column of the rectangle.
Definition rect.hpp:84
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T Height() const noexcept
Gets the vertical component of the size.
Definition size_2d.hpp:77
T Width() const noexcept
Gets the horizontal component of the size.
Definition size_2d.hpp:57
T end(T... args)
cvbres_t CreateInverseNLTransformedImage(IMG Image, NLTRANSFORMATION Transformation, cvbdim_t TargetWidth, cvbdim_t TargetHeight, cvbdim_t XTargetOffset, cvbdim_t YTargetOffset, IMG &Out)
cvbbool_t NLTransformCoefficients(NLTRANSFORMATION Transformation, double *CoeffsTransX, double *CoeffsTransY, double *CoeffsInvTransX, double *CoeffsInvTransY)
cvbres_t NLTransformNumCoefficients(NLTRANSFORMATION Transformation)
cvbres_t ApplyInverseNLTransform(NLTRANSFORMATION Transformation, double &X, double &Y)
cvbres_t CreateCalibrationPatternLetter(cvbval_t numColumns, cvbval_t numRows, double borderH, double borderV, cvbval_t dpi, cvbbool_t landscape, TCalibrationPatternStyle style, TCalibrationPatternContrast contrast, IMG &imgOut)
cvbres_t CreateNLTransformedImage(IMG Image, NLTRANSFORMATION Transformation, cvbdim_t TargetWidth, cvbdim_t TargetHeight, cvbdim_t XTargetOffset, cvbdim_t YTargetOffset, IMG &Out)
cvbres_t GetCalibrationLists(IMG img, cvbdim_t index, TCalibrationPatternStyle style, TCalibrationPatternContrast contrast, TArea aoi, cvbdim_t gridSpacing, cvbval_t minContrast, double maxRatio, PIXELLIST &originalPixels, PIXELLIST &transformedPixels)
cvbres_t ApplyNLTransform(NLTRANSFORMATION Transformation, double &X, double &Y)
cvbres_t CreateCalibrationPatternA4(cvbval_t numColumns, cvbval_t numRows, double borderH, double borderV, cvbval_t dpi, cvbbool_t landscape, TCalibrationPatternStyle style, TCalibrationPatternContrast contrast, IMG &imgOut)
cvbres_t NLTransformOrder(NLTRANSFORMATION Transformation)
cvbres_t CreateNLTransform(PIXELLIST OriginalPixels, PIXELLIST TransformedPixels, cvbval_t Order, TFProgress Callback, void *PrivateData, NLTRANSFORMATION &Transformation, double &Quality)
cvbres_t MirrorImage(IMG ImgIn, cvbbool_t MirrorX, cvbbool_t MirrorY, IMG &ImgOut)
cvbres_t PerspectiveTransformImage(IMG ImgIn, long DstWidth, long DstHeight, long, long, double C00, double C01, double C02, double C10, double C11, double C12, double C20, double C21, double C22, TInterpolationMode Interpolation, IMG &ImgOut)
cvbres_t RotateImage(IMG ImgIn, double Angle, TInterpolationMode Interpolation, IMG &ImgOut)
cvbres_t ResizeImage(IMG ImgIn, long TargetWidth, long TargetHeight, TInterpolationMode Interpolation, IMG &ImgOut)
cvbres_t ShearImage(IMG ImgIn, double ShearX, double ShearY, TInterpolationMode Interpolation, IMG &ImgOut)
cvbres_t CalcPerspectiveTransformation(long dstLeft, long dstTop, long dstRight, long dstBottom, double srcX0, double srcY0, double srcX1, double srcY1, double srcX2, double srcY2, double srcX3, double srcY3, double &C00, double &C01, double &C02, double &C10, double &C11, double &C12, double &C20, double &C21, double &C22)
cvbres_t MatrixTransformImage(IMG ImgIn, TMatrix Matrix, TInterpolationMode Interpolation, IMG &ImgOut)
cvbres_t CalcPerspectiveTransformationEx(double dstLeft, double dstTop, double dstRight, double dstBottom, double srcX0, double srcY0, double srcX1, double srcY1, double srcX2, double srcY2, double srcX3, double srcY3, double &C00, double &C01, double &C02, double &C10, double &C11, double &C12, double &C20, double &C21, double &C22)
cvbbool_t ReleaseObject(OBJ &Object)
T max(T... args)
T min(T... args)
T move(T... args)
Namespace for collection of image 2D transformation functions from the Foundation package.
Definition transform_2d.hpp:34
std::unique_ptr< Image > Shear(const Image &image, double shearX, double shearY, Interpolation interpolation=Interpolation::Linear)
Shear the input image.
Definition transform_2d.hpp:347
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:286
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:543
CalibrationPatternStyle
Definition of the calibration pattern style used for automatic calibration.
Definition transform_2d.hpp:367
@ AsymmetricDots
Definition transform_2d.hpp:373
@ UniformDots
Definition transform_2d.hpp:370
CalibrationPatternFormat
Definition of the paper format used for printing calibration patterns.
Definition transform_2d.hpp:378
@ A4
A4 paper size (210 x 297 mm).
Definition transform_2d.hpp:380
@ Letter
Letter sized paper (8.5 x 11 inches).
Definition transform_2d.hpp:382
CalibrationPatternContrast
Definition of the contrast of the pattern used for automatic calibration.
Definition transform_2d.hpp:358
@ WhiteOnBlack
White objects on black background.
Definition transform_2d.hpp:362
@ BlackOnWhite
Black objects on white background.
Definition transform_2d.hpp:360
CalibrationPatternOrientation
Format orientation for the CalibrationPatternFormat.
Definition transform_2d.hpp:387
@ Portrait
Portrait has the long side vertically.
Definition transform_2d.hpp:389
@ Landscape
Landscape has the long side horizontally.
Definition transform_2d.hpp:391
std::unique_ptr< Image > Resize(const Image &image, Size2D< int > targetSize, Interpolation interpolation=Interpolation::Linear)
Resize the input image.
Definition transform_2d.hpp:308
Interpolation
Interpolation modes available inside the Foundation package.
Definition transform_2d.hpp:59
@ Lanczos
Definition transform_2d.hpp:70
@ Linear
Definition transform_2d.hpp:65
@ Supersample
Definition transform_2d.hpp:73
@ NearestNeighbor
Definition transform_2d.hpp:62
@ Cubic
Definition transform_2d.hpp:68
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:248
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:267
std::shared_ptr< NonLinearTransformation > NonLinearTransformationPtr
Convenience shared pointer for NonLinearTransformation.
Definition transform_2d.hpp:1065
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:327
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:461
Axis
Axis enumeration.
Definition transform_2d.hpp:78
@ X
Definition transform_2d.hpp:82
@ Both
Definition transform_2d.hpp:86
@ NoAxis
Definition transform_2d.hpp:80
@ Y
Definition transform_2d.hpp:84
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:415
Namespace for the Foundation package.
Definition decl_metric_aqs12_calibration_piece.hpp:11
Root namespace for the Image Manager interface.
Definition version.hpp:11
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
T transform(T... args)