3#include "_cexports/c_core_2d.h"
4#include "_cexports/c_img.h"
18 inline HandleGuard<UndistPointFilter>::HandleGuard(
void *handle) noexcept
19 : HandleGuard<UndistPointFilter>(handle, [](
void *handle) { CVB_CALL_CAPI(
ReleaseObject(handle)); })
26 inline HandleGuard<UndistImageFilter>::HandleGuard(
void *handle) noexcept
27 : HandleGuard<UndistImageFilter>(handle, [](
void *handle) { CVB_CALL_CAPI(
ReleaseObject(handle)); })
39 class UndistPointFilter final
50 const std::string ascii_data = Cvb::Internal::CastToAscii(calibrationData);
51 return Internal::DoResCallObjectOut<UndistPointFilter>(
52 [&](
void *&handle) {
return CVB_CALL_CAPI(CVC2DCreateUndistortionPointFilter(ascii_data.c_str(), handle)); });
60 return std::make_unique<UndistPointFilter>(
std::move(guard));
63 explicit UndistPointFilter(HandleGuard<UndistPointFilter> &&guard) noexcept
68 UndistPointFilter(
const UndistPointFilter &other) =
delete;
69 UndistPointFilter &operator=(
const UndistPointFilter &other) =
delete;
70 UndistPointFilter(UndistPointFilter &&other) =
delete;
71 UndistPointFilter &operator=(UndistPointFilter &&other) =
delete;
73 ~UndistPointFilter() =
default;
75 void *Handle() const noexcept
77 return handle_.Handle();
90 for (
const auto &c : distortedPoints)
92 Cvb::CExports::CVIPointD pt;
95 distorted_points_CVI.push_back(pt);
98 const int N =
static_cast<int>(distortedPoints.size());
100 CVB_CALL_CAPI_CHECKED(
101 CVC2DUndistortionPointFilterRun(Handle(), distorted_points_CVI.data(), N, undistorted_points_CVI.data()));
105 for (
const auto &c : undistorted_points_CVI)
108 return undistorted_points;
112 HandleGuard<UndistPointFilter> handle_;
125 class UndistImageFilter final
141 Cvb::CExports::cvbdim_t outwidth, outheight;
142 const std::string ascii_data = Cvb::Internal::CastToAscii(calibrationData);
144 auto res = Internal::DoResCallObjectOut<UndistImageFilter>([&](
void *&handle) {
145 return CVB_CALL_CAPI(CVC2DCreateUndistortionFilter(
146 ascii_data.c_str(), imageSize.
Width(), imageSize.
Height(), crop,
147 static_cast<Cvb::CExports::CVC2DInterpolationMode
>(interpolationMode), handle, outwidth, outheight));
160 return std::make_unique<UndistImageFilter>(
std::move(guard));
163 explicit UndistImageFilter(HandleGuard<UndistImageFilter> &&guard) noexcept
168 UndistImageFilter(
const UndistImageFilter &other) =
delete;
169 UndistImageFilter &operator=(
const UndistImageFilter &other) =
delete;
170 UndistImageFilter(UndistImageFilter &&other) =
delete;
171 UndistImageFilter &operator=(UndistImageFilter &&other) =
delete;
173 ~UndistImageFilter() =
default;
175 void *Handle() const noexcept
177 return handle_.Handle();
214 auto outHandle = imageOut.
Handle();
215 CVB_CALL_CAPI_CHECKED(CVC2DUndistortionFilterRun(
216 Handle(),
static_cast<Cvb::CExports::CVC2DUndistThreads
>(Cvb::CExports::CVC2DUndistThreadsSingle),
217 imageIn.
Handle(), outHandle));
221 HandleGuard<UndistImageFilter> handle_;
The Common Vision Blox image.
Definition decl_image.hpp:50
int PlanesCount() const noexcept
Get the number of planes for this image.
Definition decl_image.hpp:247
ImagePlane Plane(int plane) const
Indexed access to the individual plane information.
Definition detail_image.hpp:58
bool PlaneDataTypesIdentical() const noexcept
Check if all planes have the same data type.
Definition decl_image.hpp:257
void * Handle() const noexcept
Classic API image handle.
Definition decl_image.hpp:237
static std::unique_ptr< Image > Create(Size2D< int > size, int numPlanes=1, DataType dataType=DataType::Int8BppUnsigned())
Creates an uninitialized image with the given parameters.
Definition decl_image.hpp:75
class DataType DataType() const noexcept override
Data type descriptor for this array.
Definition detail_image_plane.hpp:337
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
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
A filter for undistorting images.
Definition undistortion.hpp:126
static std::unique_ptr< UndistImageFilter > Create(const Cvb::String &calibrationData, const Size2D< int > &imageSize, bool crop, UndistInterpolationMode interpolationMode=UndistInterpolationMode::Bilinear)
Creates an image undistortion filter for a given calibration configuration.
Definition undistortion.hpp:138
std::unique_ptr< Image > Undistort(const Image &image) const
Undistort an image.
Definition undistortion.hpp:195
void Undistort(const Image &imageIn, Image &imageOut) const
Undistort an image.
Definition undistortion.hpp:212
const Size2D< int > & OutSize() const
Gives the dimensions of the undistorted images.
Definition undistortion.hpp:184
A filter for undistorting 2D-point sets.
Definition undistortion.hpp:40
std::vector< Point2D< double > > Undistort(const std::vector< Point2D< double > > &distortedPoints)
Undistort a set of 2D points.
Definition undistortion.hpp:86
static std::unique_ptr< UndistPointFilter > Create(const Cvb::String &calibrationData)
Creates a point undistortion filter for a given calibration configuration.
Definition undistortion.hpp:48
cvbbool_t ReleaseObject(OBJ &Object)
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
UndistInterpolationMode
Interpolation modes for image undistortion.
Definition core_2d.hpp:15
@ Bilinear
Bilinear interpolation.
Definition core_2d.hpp:17