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"
22 namespace CalibrationLineScan
35 X = CExports::CVFScanDirection::CVFSD_X,
40 Y = CExports::CVFScanDirection::CVFSD_Y
85 : maxIterations_(maxIterations)
86 , polyDegree_(polyDegree)
87 , tolerance_(tolerance)
88 , scanDirection_(scanDirection)
89 , preDefinedPixelSizeMode_(preDefinedPixelSizeMode)
90 , pixelSize_(pixelSize)
110 return maxIterations_;
125 maxIterations_ = maxIterations;
153 polyDegree_ = polyDegree;
178 tolerance_ = tolerance;
188 return scanDirection_;
199 scanDirection_ = scanDirection;
211 return preDefinedPixelSizeMode_;
226 preDefinedPixelSizeMode_ = preDefinedPixelSize;
256 pixelSize_ = pixelSize;
296 Internal::DoResCall([&]() {
297 return CVB_CALL_CAPI(CVFGet2PointsForCalibrationOfMovement(
298 imagePlane.
Parent().
Handle(),
static_cast<CExports::cvbdim_t
>(imagePlane.
Plane()),
reinterpret_cast<const CExports::TArea&
>(aoi),
299 static_cast<CExports::TCalibrationPatternContrast
>(contrast), minContrast,
300 pointSizeRange.
Min(), pointSizeRange.
Max(),
static_cast<CExports::CVFScanDirection
>(scanDirection),
301 reinterpret_cast<CExports::CVIPointD&
>(points.first),
302 reinterpret_cast<CExports::CVIPointD&
>(points.second));
325 double referenceDistanceCalibrationPoints,
327 double referenceWidthStripes,
334 : scanLineIndices_(std::move(scanLineIndices))
335 , edgeIndices_(std::move(edgeIndices))
336 , numProfiles_(numProfiles)
337 , numEdgesPerProfile_(numEdgesPerProfile)
352 return scanLineIndices_;
414 return numEdgesPerProfile_;
422 int numEdgesPerProfile_;
451 size_t numProfiles = 0;
452 size_t numEdgesPerProfile = 0;
453 Internal::DoResCall([&]() {
454 return CVB_CALL_CAPI(
455 CVFDetectEdgesOfStripeTarget(imageStripes.
Handle(),
static_cast<CExports::cvbdim_t
>(aoi.Left()),
456 static_cast<CExports::cvbdim_t
>(aoi.Top()),
static_cast<CExports::cvbdim_t
>(aoi.Right()),
457 static_cast<CExports::cvbdim_t
>(aoi.Bottom()), numStripes,
458 static_cast<CExports::CVFScanDirection
>(scanDirection), threshold,
459 scanLineIndices.data(), edgeIndices.data(), numProfiles, numEdgesPerProfile);
461 return { std::move(scanLineIndices), std::move(edgeIndices),
static_cast<int>(numProfiles),
static_cast<int>(numEdgesPerProfile) };
470 double referenceDistanceCalibrationPoints,
472 double referenceWidthStripes,
477 struct PrivateTag {};
481 LineScanCalibrator(
const NonLinearTransformationPtr& transformation,
double pixelSize,
double meanError,
double standardDeviation, PrivateTag)
482 : transformation_(transformation)
483 , pixelSize_(pixelSize)
484 , meanError_(meanError)
485 , standardDeviation_(standardDeviation)
528 return transformation_;
563 return standardDeviation_;
568 NonLinearTransformationPtr transformation_;
571 double standardDeviation_;
613 double referenceDistanceCalibrationPoints,
615 double referenceWidthStripes,
618 void *transformation =
nullptr;
619 double pixelSize = 0;
620 double meanError = 0;
621 double standardDeviation = 0;
622 Internal::DoResCall([&]() {
623 return CVB_CALL_CAPI(CVFCreateLineScanCalibration(*
reinterpret_cast<const CExports::CVIPointD*
>(&calibrationPoint1),
624 *
reinterpret_cast<const CExports::CVIPointD*
>(&calibrationPoint2),
625 referenceDistanceCalibrationPoints,
626 const_cast<int*
>(
reinterpret_cast<const int*
>(edgeDetectionResult.scanLineIndices_.data())),
627 const_cast<double*
>(
reinterpret_cast<const double*
>(edgeDetectionResult.edgeIndices_.data())),
628 edgeDetectionResult.numProfiles_,
629 edgeDetectionResult.numEdgesPerProfile_,
630 referenceWidthStripes,
631 *
reinterpret_cast<const CExports::CVFLineScanCalibrationConfiguration*
>(&configuration),
632 transformation, pixelSize, meanError, standardDeviation);
635 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:322
int NumProfiles() const noexcept
Gets the number of scan lines where edges are correctly detected.
Definition: calibration_line_scan.hpp:402
int NumEdgesPerProfile() const noexcept
Gets the number of edges per profile (scan line).
Definition: calibration_line_scan.hpp:412
std::vector< double > EdgeIndices() const noexcept
Gets the indices of edges for each scan line.
Definition: calibration_line_scan.hpp:389
std::vector< int > ScanLineIndices() const noexcept
Gets the indices of the scan lines.
Definition: calibration_line_scan.hpp:350
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:611
A set of parameters, which is used to configure linescan calibration calculated with function CreateL...
Definition: calibration_line_scan.hpp:56
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:151
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:81
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:108
void SetScanDirection(Foundation::CalibrationLineScan::ScanDirection scanDirection) noexcept
Sets the scanning direction of camera.
Definition: calibration_line_scan.hpp:197
double Tolerance() const noexcept
Gets the value for early stopping criteria.
Definition: calibration_line_scan.hpp:163
ScanDirection ScanDirection() const noexcept
Gets the scanning direction of camera.
Definition: calibration_line_scan.hpp:186
void SetTolerance(double tolerance) noexcept
Sets the value for early stopping criteria.
Definition: calibration_line_scan.hpp:176
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:123
void SetPreDefinedPixelSizeMode(Foundation::CalibrationLineScan::PreDefinedPixelSizeMode preDefinedPixelSize) noexcept
Sets the decision if predefined pixel size needs to be used.
Definition: calibration_line_scan.hpp:223
double PixelSize() const noexcept
Gets the pixel size of transformed image.
Definition: calibration_line_scan.hpp:239
void SetPixelSize(double pixelSize) noexcept
Sets the pixel size of transformed image.
Definition: calibration_line_scan.hpp:254
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:137
PreDefinedPixelSizeMode PreDefinedPixelSizeMode() const noexcept
Gets the decision if the calibrator uses predefined pixel size.
Definition: calibration_line_scan.hpp:209
Result of the linescan calibration executed by the CreateLineScanCalibration function.
Definition: calibration_line_scan.hpp:467
double PixelSize() const noexcept
Gets the pixel size after transformation.
Definition: calibration_line_scan.hpp:539
double MeanError() const noexcept
Gets the mean difference between stripe width in the transformed image and reference.
Definition: calibration_line_scan.hpp:551
NonLinearTransformationPtr Transformation() const noexcept
Gets the transformation.
Definition: calibration_line_scan.hpp:526
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:611
double StandardDeviation() const noexcept
Gets the standard deviation of the mean error.
Definition: calibration_line_scan.hpp:561
The Common Vision Blox image.
Definition: decl_image.hpp:45
int Width() const noexcept
Width of the image in pixels.
Definition: decl_image.hpp:288
void * Handle() const noexcept
Classic API image handle.
Definition: decl_image.hpp:226
Image plane information container.
Definition: decl_image_plane.hpp:33
int Plane() const noexcept
Plane index in the image, to which this plane refers to.
Definition: decl_image_plane.hpp:167
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition: detail_image_plane.hpp:87
T Min() const noexcept
Gets the minimum value.
Definition: value_range.hpp:50
T Max() const noexcept
Gets the maximum value.
Definition: value_range.hpp:72
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:446
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:291
PreDefinedPixelSizeMode
Specifies if the predefined pixel resolution is used for the metric calibration.
Definition: calibration_line_scan.hpp:45
@ DoNotUse
Predefined pixel resolution will not be used.
@ Use
Predefined pixel resolution will be used.
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:611
ScanDirection
Specifies the scanning direction.
Definition: calibration_line_scan.hpp:30
@ Y
Scans along the Y coordinate.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
@ X
Sensor pixel values are mirrored in X (or denoted by u), so that the columns of the range map will be...
@ Y
Sensor pixel values are mirrored in Y (or denoted by v), so that the range map pixel values will be f...