5# include "../_cexports/c_foundation.h"
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"
40 inline HandleGuard<Foundation::Transform2D::NonLinearTransformation>::HandleGuard(
void *handle) noexcept
41 : HandleGuard<Foundation::Transform2D::NonLinearTransformation>(handle,
114 rightTop.
X(), rightTop.
Y(), rightBottom.
X(), rightBottom.
Y(), leftBottom.
X(), leftBottom.
Y(), c00_, c01_,
115 c02_, c10_, c11_, c12_, c20_, c21_, c22_));
132 rightTop.
X(), rightTop.
Y(), rightBottom.
X(), rightBottom.
Y(), leftBottom.
X(), leftBottom.
Y(), c00_, c01_,
133 c02_, c10_, c11_, c12_, c20_, c21_, c22_));
141 double C00() const noexcept
151 double C01() const noexcept
161 double C02() const noexcept
171 double C10() const noexcept
181 double C11() const noexcept
191 double C12() const noexcept
201 double C20() const noexcept
211 double C21() const noexcept
221 double C22() const noexcept
251 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
255 static_cast<CExports::TInterpolationMode
>(interpolation), resimg));
269 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
290 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
294 static_cast<CExports::TInterpolationMode
>(interpolation), resimg));
311 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
313 static_cast<CExports::TInterpolationMode
>(interpolation), resimg));
330 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
332 static_cast<CExports::TInterpolationMode
>(interpolation), resimg));
350 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
352 static_cast<CExports::TInterpolationMode
>(interpolation), resimg));
417 int numColumns,
int numRows)
419 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
421 width, height, numColumns, numRows,
static_cast<CExports::TCalibrationPatternStyle
>(style),
422 static_cast<CExports::TCalibrationPatternContrast
>(contrast), resimg));
463 int numColumns,
int numRows,
double horizontalBorder,
double verticalBorder,
466 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
470 return CVB_CALL_CAPI(
473 static_cast<CExports::TCalibrationPatternStyle
>(style),
474 static_cast<CExports::TCalibrationPatternContrast
>(contrast), resimg));
476 return CVB_CALL_CAPI(
479 static_cast<CExports::TCalibrationPatternStyle
>(style),
480 static_cast<CExports::TCalibrationPatternContrast
>(contrast), resimg));
548 CExports::PIXELLIST originalPixelList =
nullptr;
549 CExports::PIXELLIST transformedPixelList =
nullptr;
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);
558 originalPixels = Internal::PixelList::FromHandle(
std::move(originalGuard))->ToPoints();
559 transformedPixels = Internal::PixelList::FromHandle(
std::move(transformedGuard))->ToPoints();
621 class NonLinearTransformation
628 ~NonLinearTransformation() =
default;
629 NonLinearTransformation(
const NonLinearTransformation &) =
delete;
630 NonLinearTransformation &operator=(
const NonLinearTransformation &) =
delete;
634 NonLinearTransformation(HandleGuard<NonLinearTransformation> &&guard, PrivateTag)
636 , coefficientsTransX_()
637 , coefficientsTransY_()
638 , coefficientsInvTransX_()
639 , coefficientsInvTransY_()
643 if (numCoefficients < 0)
645 Utilities::SystemInfo::ThrowLastError();
648 coefficientsTransX_.resize(numCoefficients);
649 coefficientsTransY_.resize(numCoefficients);
650 coefficientsInvTransX_.resize(numCoefficients);
651 coefficientsInvTransY_.resize(numCoefficients);
654 coefficientsTransY_.data(), coefficientsInvTransX_.data(),
655 coefficientsInvTransY_.data()));
660 static CExports::NLTRANSFORMATION LoadInternal(
const String &fileName)
662 CExports::NLTRANSFORMATION transformation =
nullptr;
664 CVB_CALL_CAPI_CHECKED(LoadNLTransformFileTyped(fileName.c_str(), transformation));
665 return transformation;
675 : NonLinearTransformation(HandleGuard<NonLinearTransformation>(LoadInternal(fileName)), PrivateTag{})
683 NonLinearTransformation &operator=(NonLinearTransformation &&) noexcept = default;
691 static std::unique_ptr<NonLinearTransformation>
Load(const
String &fileName)
693 return std::make_unique<NonLinearTransformation>(fileName);
705 return handle_.Handle();
722 return std::make_unique<NonLinearTransformation>(
std::move(guard), PrivateTag{});
725 typedef std::function<bool(
int stepsTotal,
int stepsDone)> CreationProgress;
739 template <
class RANGE>
740 static typename TypedRange<std::unique_ptr<NonLinearTransformation>,
Point2D<double>, RANGE>::type
742 CreationProgress progressCallback = CreationProgress())
744 auto originalPixelList = Internal::PixelList::FromPoints(originalPixels);
745 auto transformedPixelList = Internal::PixelList::FromPoints(transformedPixels);
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));
810 int order,
Area2D aoi, CreationProgress progressCallback = CreationProgress())
860 int order, CreationProgress progressCallback = CreationProgress())
883 return coefficientsTransX_;
893 return coefficientsTransY_;
903 return coefficientsInvTransX_;
913 return coefficientsInvTransY_;
924 CVB_CALL_CAPI_CHECKED(WriteNLTransformFileTyped(handle_.Handle(), fileName.c_str()));
938 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
940 targetSize.
Height(), targetOffset.
X(), targetOffset.
Y(),
954 double x = point.
X(), y = point.
Y();
988 template <
class RANGE>
1009 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
1011 targetSize.
Height(), targetOffset.
X(),
1012 targetOffset.
Y(), resimg));
1025 double x = point.
X(), y = point.
Y();
1037 template <
class RANGE>
1038 typename TypedRange<std::vector<Point2D<double>>,
Point2D<double>, RANGE>::type
1049 static CExports::cvbbool_t __stdcall CreationProgressCaller(
void *pPrivate, CExports::cvbval_t stepsTotal,
1050 CExports::cvbval_t stepsDone)
1052 CreationProgress *cbk =
reinterpret_cast<CreationProgress *
>(pPrivate);
1053 return (*cbk)(
static_cast<int>(stepsTotal),
static_cast<int>(stepsDone));
1057 HandleGuard<NonLinearTransformation> handle_;
T back_inserter(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
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
cvbbool_t ReleaseObject(OBJ &Object)
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