5# include "../_cexports/c_foundation.h"
6# include "cvb/foundation/transform_2d.hpp"
7# include "cvb/image_plane.hpp"
8# include "cvb/point_2d.hpp"
9# include "cvb/value_range.hpp"
40 X = CExports::CVFScanDirection::CVFSD_X,
45 Y = CExports::CVFScanDirection::CVFSD_Y
61 class LineScanCalibrationConfiguration final
64 LineScanCalibrationConfiguration() noexcept
89 double pixelSize) noexcept
90 : maxIterations_(maxIterations)
91 , polyDegree_(polyDegree)
92 , tolerance_(tolerance)
93 , scanDirection_(scanDirection)
94 , preDefinedPixelSizeMode_(preDefinedPixelSizeMode)
95 , pixelSize_(pixelSize)
115 return maxIterations_;
130 maxIterations_ = maxIterations;
158 polyDegree_ = polyDegree;
183 tolerance_ = tolerance;
193 return scanDirection_;
204 scanDirection_ = scanDirection;
216 return preDefinedPixelSizeMode_;
231 preDefinedPixelSizeMode_ = preDefinedPixelSize;
261 pixelSize_ = pixelSize;
301 Internal::DoResCall([&]() {
303 imagePlane.
Parent().
Handle(),
static_cast<CExports::cvbdim_t
>(imagePlane.
Plane()),
reinterpret_cast<const CExports::TArea&
>(aoi),
304 static_cast<CExports::TCalibrationPatternContrast
>(contrast), minContrast,
305 pointSizeRange.
Min(), pointSizeRange.
Max(),
static_cast<CExports::CVFScanDirection
>(scanDirection),
306 reinterpret_cast<CExports::CVIPointD&
>(points.first),
307 reinterpret_cast<CExports::CVIPointD&
>(points.second));
326 class EdgeDetectionResult final
330 double referenceDistanceCalibrationPoints,
331 const EdgeDetectionResult &edgeDetectionResult,
double referenceWidthStripes,
335 EdgeDetectionResult() =
default;
338 int numEdgesPerProfile)
339 : scanLineIndices_(
std::move(scanLineIndices))
341 , numProfiles_(numProfiles)
342 , numEdgesPerProfile_(numEdgesPerProfile)
357 return scanLineIndices_;
419 return numEdgesPerProfile_;
426 int numEdgesPerProfile_;
456 * (
static_cast<size_t>(numStripes) + 1));
457 size_t numProfiles = 0;
458 size_t numEdgesPerProfile = 0;
459 Internal::DoResCall([&]() {
460 return CVB_CALL_CAPI(
462 static_cast<CExports::cvbdim_t
>(aoi.
Top()),
static_cast<CExports::cvbdim_t
>(aoi.
Right()),
463 static_cast<CExports::cvbdim_t
>(aoi.
Bottom()), numStripes,
464 static_cast<CExports::CVFScanDirection
>(scanDirection), threshold,
465 scanLineIndices.data(), edgeIndices.data(), numProfiles, numEdgesPerProfile);
467 return {
std::move(scanLineIndices),
std::move(edgeIndices),
static_cast<int>(numProfiles),
468 static_cast<int>(numEdgesPerProfile)};
473 class LineScanCalibrator final
477 double referenceDistanceCalibrationPoints,
488 double standardDeviation, PrivateTag)
489 : transformation_(transformation)
490 , pixelSize_(pixelSize)
491 , meanError_(meanError)
492 , standardDeviation_(standardDeviation)
535 return transformation_;
570 return standardDeviation_;
577 double standardDeviation_;
619 double referenceDistanceCalibrationPoints,
620 const EdgeDetectionResult &edgeDetectionResult,
double referenceWidthStripes,
623 void *transformation =
nullptr;
624 double pixelSize = 0;
625 double meanError = 0;
626 double standardDeviation = 0;
627 Internal::DoResCall([&]() {
629 *
reinterpret_cast<const CExports::CVIPointD*
>(&calibrationPoint2),
630 referenceDistanceCalibrationPoints,
631 const_cast<int*
>(
reinterpret_cast<const int*
>(edgeDetectionResult.scanLineIndices_.data())),
632 const_cast<double*
>(
reinterpret_cast<const double*
>(edgeDetectionResult.edgeIndices_.data())),
633 edgeDetectionResult.numProfiles_,
634 edgeDetectionResult.numEdgesPerProfile_,
635 referenceWidthStripes,
636 *
reinterpret_cast<const CExports::CVFLineScanCalibrationConfiguration*
>(&configuration),
637 transformation, pixelSize, meanError, standardDeviation);
639 return std::make_unique<LineScanCalibrator>(
641 meanError, standardDeviation, LineScanCalibrator::PrivateTag{});
Structure that represents an area of interest in the image.
Definition area_2d.hpp:21
Result of the function DetectEdgesOfStripeTarget.
Definition calibration_line_scan.hpp:327
int NumProfiles() const noexcept
Gets the number of scan lines where edges are correctly detected.
Definition calibration_line_scan.hpp:407
int NumEdgesPerProfile() const noexcept
Gets the number of edges per profile (scan line).
Definition calibration_line_scan.hpp:417
std::vector< double > EdgeIndices() const noexcept
Gets the indices of edges for each scan line.
Definition calibration_line_scan.hpp:394
std::vector< int > ScanLineIndices() const noexcept
Gets the indices of the scan lines.
Definition calibration_line_scan.hpp:355
friend std::unique_ptr< LineScanCalibrator > CreateLineScanCalibration(const Point2D< double > &calibrationPoint1, const Point2D< double > &calibrationPoint2, double referenceDistanceCalibrationPoints, const EdgeDetectionResult &edgeDetectionResult, double referenceWidthStripes, const LineScanCalibrationConfiguration &configuration)
Calibrates linescan cameras.
Definition calibration_line_scan.hpp:618
A set of parameters, which is used to configure linescan calibration calculated with function CreateL...
Definition calibration_line_scan.hpp:62
void SetPolyDegree(std::uint32_t polyDegree) noexcept
Sets a positive (or zero) integer value that defines the polynomial to be used.
Definition calibration_line_scan.hpp:156
LineScanCalibrationConfiguration(std::uint32_t maxIterations, std::uint32_t polyDegree, double tolerance, ScanDirection scanDirection, PreDefinedPixelSizeMode preDefinedPixelSizeMode, double pixelSize) noexcept
Constructor for linescan calibration configuration.
Definition calibration_line_scan.hpp:87
std::uint32_t MaxIterations() const noexcept
Gets the number of maximal iterations for all nonlinear solvers in the calibration algorithm.
Definition calibration_line_scan.hpp:113
void SetScanDirection(Foundation::CalibrationLineScan::ScanDirection scanDirection) noexcept
Sets the scanning direction of camera.
Definition calibration_line_scan.hpp:202
double Tolerance() const noexcept
Gets the value for early stopping criteria.
Definition calibration_line_scan.hpp:168
ScanDirection ScanDirection() const noexcept
Gets the scanning direction of camera.
Definition calibration_line_scan.hpp:191
void SetTolerance(double tolerance) noexcept
Sets the value for early stopping criteria.
Definition calibration_line_scan.hpp:181
void SetMaxIterations(std::uint32_t maxIterations) noexcept
Sets number of maximal iterations for all nonlinear solvers in the calibration algorithm.
Definition calibration_line_scan.hpp:128
void SetPreDefinedPixelSizeMode(Foundation::CalibrationLineScan::PreDefinedPixelSizeMode preDefinedPixelSize) noexcept
Sets the decision if predefined pixel size needs to be used.
Definition calibration_line_scan.hpp:228
double PixelSize() const noexcept
Gets the pixel size of transformed image.
Definition calibration_line_scan.hpp:244
void SetPixelSize(double pixelSize) noexcept
Sets the pixel size of transformed image.
Definition calibration_line_scan.hpp:259
std::uint32_t PolyDegree() const noexcept
Gets a positive (or zero) integer value that defines the polynomial to be used.
Definition calibration_line_scan.hpp:142
PreDefinedPixelSizeMode PreDefinedPixelSizeMode() const noexcept
Gets the decision if the calibrator uses predefined pixel size.
Definition calibration_line_scan.hpp:214
Result of the linescan calibration executed by the CreateLineScanCalibration function.
Definition calibration_line_scan.hpp:474
double PixelSize() const noexcept
Gets the pixel size after transformation.
Definition calibration_line_scan.hpp:546
double MeanError() const noexcept
Gets the mean difference between stripe width in the transformed image and reference.
Definition calibration_line_scan.hpp:558
NonLinearTransformationPtr Transformation() const noexcept
Gets the transformation.
Definition calibration_line_scan.hpp:533
friend std::unique_ptr< LineScanCalibrator > CreateLineScanCalibration(const Point2D< double > &calibrationPoint1, const Point2D< double > &calibrationPoint2, double referenceDistanceCalibrationPoints, const EdgeDetectionResult &edgeDetectionResult, double referenceWidthStripes, const LineScanCalibrationConfiguration &configuration)
Calibrates linescan cameras.
Definition calibration_line_scan.hpp:618
double StandardDeviation() const noexcept
Gets the standard deviation of the mean error.
Definition calibration_line_scan.hpp:568
The Common Vision Blox image.
Definition decl_image.hpp:50
int Width() const noexcept
Width of the image in pixels.
Definition decl_image.hpp:309
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
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
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
Container for range definitions.
Definition value_range.hpp:17
T Min() const noexcept
Gets the minimum value.
Definition value_range.hpp:47
T Max() const noexcept
Gets the maximum value.
Definition value_range.hpp:69
cvbres_t CVFGet2PointsForCalibrationOfMovement(IMG Image, cvbdim_t Index, const TArea &Aoi, TCalibrationPatternContrast Contrast, cvbval_t MinContrast, double MinPointSize, double MaxPointSize, CVFScanDirection ScanDirection, CVIPointD &FirstPoint, CVIPointD &SecondPoint)
cvbres_t CVFCreateLineScanCalibration(CVIPointD CalibrationPoint1, CVIPointD CalibrationPoint2, double ReferenceDistanceCalibrationPoints, int *ScanLineIndices, double *EdgeIndices, size_t NumScanLines, size_t NumEdgesPerScanLine, double ReferenceWidthStripes, const CVFLineScanCalibrationConfiguration &Configuration, NLTRANSFORMATION &Transformation, double &PixelSize, double &MeanError, double &StdDev)
cvbres_t CVFDetectEdgesOfStripeTarget(IMG ImageStripes, cvbdim_t Left, cvbdim_t Top, cvbdim_t Right, cvbdim_t Bottom, size_t NumStripes, CVFScanDirection ScanDirection, double Threshold, int *ScanLineIndices, double *EdgeIndices, size_t &NumScanLines, size_t &NumEdgesPerScanLine)
Namespace for collection of calibration linescan functions from the Foundation package.
Definition calibration_line_scan.hpp:28
EdgeDetectionResult DetectEdgesOfStripeTarget(const Image &imageStripes, const Rect< int > &aoi, int numStripes, const ScanDirection &scanDirection, double threshold)
This function detects edges from a calibration pattern with alternating black and white stripes.
Definition calibration_line_scan.hpp:450
std::pair< Point2D< double >, Point2D< double > > CalculateTwoPointsForCalibrationOfMovement(const ImagePlane &imagePlane, const Area2D &aoi, Foundation::Transform2D::CalibrationPatternContrast contrast, int minContrast, const ValueRange< double > &pointSizeRange, const ScanDirection &scanDirection)
Extracts two points which can be used for the calibration of the movement of linescan cameras.
Definition calibration_line_scan.hpp:296
std::shared_ptr< LineScanCalibrator > LineScanCalibratorPtr
Convenience shared pointer for LineScanCalibrator.
Definition calibration_line_scan.hpp:314
PreDefinedPixelSizeMode
Specifies if the predefined pixel resolution is used for the metric calibration.
Definition calibration_line_scan.hpp:50
@ DoNotUse
Predefined pixel resolution will not be used.
Definition calibration_line_scan.hpp:52
@ Use
Predefined pixel resolution will be used.
Definition calibration_line_scan.hpp:54
std::unique_ptr< LineScanCalibrator > CreateLineScanCalibration(const Point2D< double > &calibrationPoint1, const Point2D< double > &calibrationPoint2, double referenceDistanceCalibrationPoints, const EdgeDetectionResult &edgeDetectionResult, double referenceWidthStripes, const LineScanCalibrationConfiguration &configuration)
Calibrates linescan cameras.
Definition calibration_line_scan.hpp:618
ScanDirection
Specifies the scanning direction.
Definition calibration_line_scan.hpp:35
@ X
Scans along the X coordinate.
Definition calibration_line_scan.hpp:40
@ Y
Scans along the Y coordinate.
Definition calibration_line_scan.hpp:45
Namespace for the Foundation package.
Definition decl_metric_aqs12_calibration_piece.hpp:11
Root namespace for the Image Manager interface.
Definition version.hpp:11