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
141 double C00() const noexcept {
…}
151 double C01() const noexcept
151 double C01() const noexcept {
…}
161 double C02() const noexcept
161 double C02() const noexcept {
…}
171 double C10() const noexcept
171 double C10() const noexcept {
…}
181 double C11() const noexcept
181 double C11() const noexcept {
…}
191 double C12() const noexcept
191 double C12() const noexcept {
…}
201 double C20() const noexcept
201 double C20() const noexcept {
…}
211 double C21() const noexcept
211 double C21() const noexcept {
…}
221 double C22() 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
629 NonLinearTransformation(HandleGuard<NonLinearTransformation> &&guard, PrivateTag)
631 , coefficientsTransX_()
632 , coefficientsTransY_()
633 , coefficientsInvTransX_()
634 , coefficientsInvTransY_()
638 if (numCoefficients < 0)
640 Utilities::SystemInfo::ThrowLastError();
643 coefficientsTransX_.resize(numCoefficients);
644 coefficientsTransY_.resize(numCoefficients);
645 coefficientsInvTransX_.resize(numCoefficients);
646 coefficientsInvTransY_.resize(numCoefficients);
649 coefficientsTransY_.data(), coefficientsInvTransX_.data(),
650 coefficientsInvTransY_.data()));
655 static CExports::NLTRANSFORMATION LoadInternal(
const String &fileName)
657 CExports::NLTRANSFORMATION transformation =
nullptr;
659 CVB_CALL_CAPI_CHECKED(LoadNLTransformFileTyped(fileName.c_str(), transformation));
660 return transformation;
670 : NonLinearTransformation(HandleGuard<NonLinearTransformation>(LoadInternal(fileName)), PrivateTag{})
678 NonLinearTransformation &operator=(NonLinearTransformation &&) noexcept = default;
687 static std::unique_ptr<NonLinearTransformation>
Load(const
String &fileName)
689 return std::make_unique<NonLinearTransformation>(fileName);
687 static std::unique_ptr<NonLinearTransformation>
Load(const
String &fileName) {
…}
701 return handle_.Handle();
718 return std::make_unique<NonLinearTransformation>(
std::move(guard), PrivateTag{});
721 typedef std::function<bool(
int stepsTotal,
int stepsDone)> CreationProgress;
735 template <
class RANGE>
736 static typename TypedRange<std::unique_ptr<NonLinearTransformation>,
Point2D<double>, RANGE>::type
738 CreationProgress progressCallback = CreationProgress())
740 auto originalPixelList = Internal::PixelList::FromPoints(originalPixels);
741 auto transformedPixelList = Internal::PixelList::FromPoints(transformedPixels);
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));
806 int order,
Area2D aoi, CreationProgress progressCallback = CreationProgress())
856 int order, CreationProgress progressCallback = CreationProgress())
879 return coefficientsTransX_;
889 return coefficientsTransY_;
899 return coefficientsInvTransX_;
909 return coefficientsInvTransY_;
920 CVB_CALL_CAPI_CHECKED(WriteNLTransformFileTyped(handle_.Handle(), fileName.c_str()));
934 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
936 targetSize.
Height(), targetOffset.
X(), targetOffset.
Y(),
950 double x = point.
X(), y = point.
Y();
984 template <
class RANGE>
1005 return Internal::DoResCallObjectOut<Image>([&](
void *&resimg) {
1007 targetSize.
Height(), targetOffset.
X(),
1008 targetOffset.
Y(), resimg));
1021 double x = point.
X(), y = point.
Y();
1033 template <
class RANGE>
1034 typename TypedRange<std::vector<Point2D<double>>,
Point2D<double>, RANGE>::type
1045 static CExports::cvbbool_t __stdcall CreationProgressCaller(
void *pPrivate, CExports::cvbval_t stepsTotal,
1046 CExports::cvbval_t stepsDone)
1048 CreationProgress *cbk =
reinterpret_cast<CreationProgress *
>(pPrivate);
1049 return (*cbk)(
static_cast<int>(stepsTotal),
static_cast<int>(stepsDone));
1053 HandleGuard<NonLinearTransformation> handle_;
621 class NonLinearTransformation {
…};
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: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
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 c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49