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{
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 // Internal helper constructor version
629 NonLinearTransformation(HandleGuard<NonLinearTransformation> &&guard, PrivateTag)
630 : handle_(std::move(guard))
631 , coefficientsTransX_()
632 , coefficientsTransY_()
633 , coefficientsInvTransX_()
634 , coefficientsInvTransY_()
635 {
636 // retrieve the transformations' coefficients
637 auto numCoefficients = CVB_CALL_CAPI(NLTransformNumCoefficients(handle_.Handle()));
638 if (numCoefficients < 0)
639 {
640 Utilities::SystemInfo::ThrowLastError();
641 }
642
643 coefficientsTransX_.resize(numCoefficients);
644 coefficientsTransY_.resize(numCoefficients);
645 coefficientsInvTransX_.resize(numCoefficients);
646 coefficientsInvTransY_.resize(numCoefficients);
647
648 CVB_CALL_CAPI_CHECKED(NLTransformCoefficients(handle_.Handle(), coefficientsTransX_.data(),
649 coefficientsTransY_.data(), coefficientsInvTransX_.data(),
650 coefficientsInvTransY_.data()));
651 }
652
653 private:
654 // Helper to load a saved transformation from file
655 static CExports::NLTRANSFORMATION LoadInternal(const String &fileName)
656 {
657 CExports::NLTRANSFORMATION transformation = nullptr;
658
659 CVB_CALL_CAPI_CHECKED(LoadNLTransformFileTyped(fileName.c_str(), transformation));
660 return transformation;
661 }
662
663 public:
665
670 : NonLinearTransformation(HandleGuard<NonLinearTransformation>(LoadInternal(fileName)), PrivateTag{})
671 {
672 }
673
675 NonLinearTransformation(NonLinearTransformation &&) noexcept = default;
676
678 NonLinearTransformation &operator=(NonLinearTransformation &&) noexcept = default;
679
680 public:
682
687 static std::unique_ptr<NonLinearTransformation> Load(const String &fileName)
688 {
689 return std::make_unique<NonLinearTransformation>(fileName);
690 }
691
693
699 void *Handle() const noexcept
700 {
701 return handle_.Handle();
702 }
703
705
712 static std::unique_ptr<NonLinearTransformation> FromHandle(HandleGuard<NonLinearTransformation> &&guard)
713 {
714 if (!guard.Handle())
715 {
716 throw std::invalid_argument("invalid non-linear transformation native handle");
717 }
718 return std::make_unique<NonLinearTransformation>(std::move(guard), PrivateTag{});
719 }
720
721 typedef std::function<bool(int stepsTotal, int stepsDone)> CreationProgress;
722
725
735 template <class RANGE>
736 static typename TypedRange<std::unique_ptr<NonLinearTransformation>, Point2D<double>, RANGE>::type
737 FromPositionLists(const RANGE &originalPixels, const RANGE &transformedPixels, int order,
738 CreationProgress progressCallback = CreationProgress())
739 {
740 auto originalPixelList = Internal::PixelList::FromPoints(originalPixels);
741 auto transformedPixelList = Internal::PixelList::FromPoints(transformedPixels);
742 double quality;
743
744 return Internal::DoResCallObjectOut<NonLinearTransformation>([&](void *&restrans) {
745 return CVB_CALL_CAPI(CreateNLTransform(originalPixelList->Handle(), transformedPixelList->Handle(), order,
746 progressCallback ? CreationProgressCaller : nullptr,
747 &progressCallback, restrans, quality));
748 });
749 }
750
753
805 CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio,
806 int order, Area2D aoi, CreationProgress progressCallback = CreationProgress())
807 {
808 std::vector<Point2D<double>> original, transformed;
809 ExtractCalibrationLists(plane, style, contrast, gridSpacing, minContrast, maxRatio, aoi, original,
810 transformed);
811
812 return FromPositionLists(original, transformed, order, progressCallback);
813 }
814
817
855 CalibrationPatternContrast contrast, int gridSpacing, int minContrast, double maxRatio,
856 int order, CreationProgress progressCallback = CreationProgress())
857 {
858 return FromCalibrationPattern(plane, style, contrast, gridSpacing, minContrast, maxRatio, order,
859 Area2D(static_cast<Rect<double>>(plane.Parent().Bounds())), progressCallback);
860 }
861
863
867 int Order() const noexcept
868 {
869 return CVB_CALL_CAPI(NLTransformOrder(handle_.Handle()));
870 }
871
873
878 {
879 return coefficientsTransX_;
880 }
881
883
888 {
889 return coefficientsTransY_;
890 }
891
893
898 {
899 return coefficientsInvTransX_;
900 }
901
903
908 {
909 return coefficientsInvTransY_;
910 }
911
913
918 void Save(const String &fileName) const
919 {
920 CVB_CALL_CAPI_CHECKED(WriteNLTransformFileTyped(handle_.Handle(), fileName.c_str()));
921 }
922
924
932 std::unique_ptr<Image> Transform(const Image &image, Size2D<int> targetSize, Point2D<int> targetOffset)
933 {
934 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
935 return CVB_CALL_CAPI(CreateNLTransformedImage(image.Handle(), handle_.Handle(), targetSize.Width(),
936 targetSize.Height(), targetOffset.X(), targetOffset.Y(),
937 resimg));
938 });
939 }
940
942
949 {
950 double x = point.X(), y = point.Y();
951 CVB_CALL_CAPI_CHECKED(ApplyNLTransform(handle_.Handle(), x, y));
952 return Point2D<double>(x, y);
953 }
954
956
965 {
966 auto topLeft = Transform(Point2D<double>(rect.Left(), rect.Top()));
967 auto topRight = Transform(Point2D<double>(rect.Right(), rect.Top()));
968 auto bottomLeft = Transform(Point2D<double>(rect.Left(), rect.Bottom()));
969 auto bottomRight = Transform(Point2D<double>(rect.Right(), rect.Bottom()));
970
971 return Rect<double>(std::min(topLeft.X(), std::min(topRight.X(), std::min(bottomLeft.X(), bottomRight.X()))),
972 std::min(topLeft.Y(), std::min(topRight.Y(), std::min(bottomLeft.Y(), bottomRight.Y()))),
973 std::max(topLeft.X(), std::max(topRight.X(), std::max(bottomLeft.X(), bottomRight.X()))),
974 std::max(topLeft.Y(), std::max(topRight.Y(), std::max(bottomLeft.Y(), bottomRight.Y()))));
975 }
976
978
984 template <class RANGE>
985 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type Transform(const RANGE &points)
986 {
988 std::transform(std::begin(points), std::end(points), std::back_inserter(results),
989 [this](Point2D<double> p) { return Transform(p); });
990
991 return results;
992 }
993
995
1004 {
1005 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
1006 return CVB_CALL_CAPI(CreateInverseNLTransformedImage(image.Handle(), handle_.Handle(), targetSize.Width(),
1007 targetSize.Height(), targetOffset.X(),
1008 targetOffset.Y(), resimg));
1009 });
1010 }
1011
1013
1020 {
1021 double x = point.X(), y = point.Y();
1022 CVB_CALL_CAPI_CHECKED(ApplyInverseNLTransform(handle_.Handle(), x, y));
1023 return Point2D<double>(x, y);
1024 }
1025
1027
1033 template <class RANGE>
1034 typename TypedRange<std::vector<Point2D<double>>, Point2D<double>, RANGE>::type
1035 InverseTransform(const RANGE &points)
1036 {
1038 std::transform(std::begin(points), std::end(points), std::back_inserter(results),
1039 [this](Point2D<double> p) { return InverseTransform(p); });
1040
1041 return results;
1042 }
1043
1044 private:
1045 static CExports::cvbbool_t __stdcall CreationProgressCaller(void *pPrivate, CExports::cvbval_t stepsTotal,
1046 CExports::cvbval_t stepsDone)
1047 {
1048 CreationProgress *cbk = reinterpret_cast<CreationProgress *>(pPrivate);
1049 return (*cbk)(static_cast<int>(stepsTotal), static_cast<int>(stepsDone));
1050 }
1051
1052 private:
1053 HandleGuard<NonLinearTransformation> handle_;
1054 std::vector<double> coefficientsTransX_;
1055 std::vector<double> coefficientsTransY_;
1056 std::vector<double> coefficientsInvTransX_;
1057 std::vector<double> coefficientsInvTransY_;
1058 }; /* class NonLinearTransformation */
1059
1062
1063 } /* namespace Transform2D */
1064
1065 using Transform2D::Axis;
1068
1070 using Transform2D::Mirror;
1072 using Transform2D::Resize;
1073 using Transform2D::Rotate;
1074 using Transform2D::Shear;
1075
1080
1084
1087
1088 } /* namespace Foundation */
1089 CVB_END_INLINE_NS
1090} /* namespace Cvb */
1091
1092#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:907
std::vector< double > CoefficientsY() const
Return an array of the coefficients used for the transformation of y coordinates.
Definition transform_2d.hpp:887
static std::unique_ptr< NonLinearTransformation > FromHandle(HandleGuard< NonLinearTransformation > &&guard)
Creates transformation from a classic API handle.
Definition transform_2d.hpp:712
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:897
static std::unique_ptr< NonLinearTransformation > Load(const String &fileName)
Load a saved transformation from a file.
Definition transform_2d.hpp:687
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:804
Rect< double > Transform(Rect< double > rect)
Transform a rect with this nonlinear transformation.
Definition transform_2d.hpp:964
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:1035
Point2D< double > InverseTransform(Point2D< double > point)
Back transform a point with this nonlinear transformation.
Definition transform_2d.hpp:1019
void Save(const String &fileName) const
Write the transformation to a file.
Definition transform_2d.hpp:918
int Order() const noexcept
Gets the transformation order.
Definition transform_2d.hpp:867
Point2D< double > Transform(Point2D< double > point)
Transform a point with this nonlinear transformation.
Definition transform_2d.hpp:948
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:854
std::vector< double > CoefficientsX() const
Return an array of the coefficients used for the transformation of x coordinates.
Definition transform_2d.hpp:877
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:985
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:932
void * Handle() const noexcept
Classic API NLTRANSFORMATION handle.
Definition transform_2d.hpp:699
NonLinearTransformation(const String &fileName)
Load a saved transformation from a file.
Definition transform_2d.hpp:669
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:737
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:1003
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:29
int Plane() const noexcept
Plane index in the image, to which this plane refers to.
Definition decl_image_plane.hpp:147
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 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)
cvbres_t PerspectiveTransformImage(IMG ImgIn, long DstWidth, long DstHeight, long DstXOffset, long DstYOffset, double C00, double C01, double C02, double C10, double C11, double C12, double C20, double C21, double C22, TInterpolationMode Interpolation, IMG &ImgOut)
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:1061
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 c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
T transform(T... args)