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
28 X = CExports::CVFScanDirection::CVFSD_X,
30 Y = CExports::CVFScanDirection::CVFSD_Y
73 : maxIterations_(maxIterations)
74 , polyDegree_(polyDegree)
75 , tolerance_(tolerance)
76 , scanDirection_(scanDirection)
77 , preDefinedPixelSizeMode_(preDefinedPixelSizeMode)
78 , pixelSize_(pixelSize)
98 return maxIterations_;
110 maxIterations_ = maxIterations;
134 polyDegree_ = polyDegree;
157 tolerance_ = tolerance;
167 return scanDirection_;
178 scanDirection_ = scanDirection;
191 return preDefinedPixelSizeMode_;
203 preDefinedPixelSizeMode_ = preDefinedPixelSize;
227 pixelSize_ = pixelSize;
259 CalibrationPatternContrast contrast,
int minContrast,
263 Internal::DoResCall([&]() {
264 return CVB_CALL_CAPI(CVFGet2PointsForCalibrationOfMovement(
265 imagePlane.
Parent().
Handle(),
static_cast<CExports::cvbdim_t
>(imagePlane.
Plane()),
reinterpret_cast<const CExports::TArea&
>(aoi),
266 static_cast<CExports::TCalibrationPatternContrast
>(contrast), minContrast,
267 pointSizeRange.
Min(), pointSizeRange.
Max(),
static_cast<CExports::CVFScanDirection
>(scanDirection),
268 reinterpret_cast<CExports::CVIPointD&
>(points.first),
269 reinterpret_cast<CExports::CVIPointD&
>(points.second));
284 double referenceDistanceCalibrationPoints,
286 double referenceWidthStripes,
293 : scanLineIndices_(std::move(scanLineIndices))
294 , edgeIndices_(std::move(edgeIndices))
295 , numProfiles_(numProfiles)
296 , numEdgesPerProfile_(numEdgesPerProfile)
307 return scanLineIndices_;
337 return numEdgesPerProfile_;
345 int numEdgesPerProfile_;
370 size_t numProfiles = 0;
371 size_t numEdgesPerProfile = 0;
372 Internal::DoResCall([&]() {
373 auto left = aoi.P0().
X();
374 auto top = aoi.P0().
Y();
375 auto right = aoi.P3().
X();
376 auto bottom = aoi.P3().
Y();
377 return CVB_CALL_CAPI(
378 CVFDetectEdgesOfStripeTarget(imageStripes.
Handle(),
static_cast<CExports::cvbdim_t
>(left),
379 static_cast<CExports::cvbdim_t
>(top),
static_cast<CExports::cvbdim_t
>(right),
380 static_cast<CExports::cvbdim_t
>(bottom), numStripes,
381 static_cast<CExports::CVFScanDirection
>(scanDirection), threshold,
382 scanLineIndices.data(), edgeIndices.data(), numProfiles, numEdgesPerProfile);
384 return { std::move(scanLineIndices), std::move(edgeIndices),
static_cast<int>(numProfiles),
static_cast<int>(numEdgesPerProfile) };
393 double referenceDistanceCalibrationPoints,
395 double referenceWidthStripes,
400 struct PrivateTag {};
404 LineScanCalibrator(
const NonLinearTransformationPtr& transformation,
double pixelSize,
double meanError,
double standardDeviation, PrivateTag)
405 : transformation_(transformation)
406 , pixelSize_(pixelSize)
407 , meanError_(meanError)
408 , standardDeviation_(standardDeviation)
419 return transformation_;
453 return standardDeviation_;
458 NonLinearTransformationPtr transformation_;
461 double standardDeviation_;
498 double referenceDistanceCalibrationPoints,
500 double referenceWidthStripes,
503 void *transformation =
nullptr;
504 double pixelSize = 0;
505 double meanError = 0;
506 double standardDeviation = 0;
507 Internal::DoResCall([&]() {
508 return CVB_CALL_CAPI(CVFCreateLineScanCalibration(*
reinterpret_cast<const CExports::CVIPointD*
>(&calibrationPoint1),
509 *
reinterpret_cast<const CExports::CVIPointD*
>(&calibrationPoint2),
510 referenceDistanceCalibrationPoints,
511 const_cast<int*
>(
reinterpret_cast<const int*
>(edgeDetectionResult.scanLineIndices_.data())),
512 const_cast<double*
>(
reinterpret_cast<const double*
>(edgeDetectionResult.edgeIndices_.data())),
513 edgeDetectionResult.numProfiles_,
514 edgeDetectionResult.numEdgesPerProfile_,
515 referenceWidthStripes,
516 *
reinterpret_cast<const CExports::CVFLineScanCalibrationConfiguration*
>(&configuration),
517 transformation, pixelSize, meanError, standardDeviation);
520 meanError, standardDeviation, LineScanCalibrator::PrivateTag{});
Structure that represents an area of interest in the image.
Definition: area_2d.hpp:21
A set of parameters that stores the result from an edge detection.
Definition: calibration_line_scan.hpp:281
int NumProfiles() const noexcept
Gets the number of scan-line where edges are correctly detected.
Definition: calibration_line_scan.hpp:325
int NumEdgesPerProfile() const noexcept
Gets the number of edges per unit profile.
Definition: calibration_line_scan.hpp:335
std::vector< double > EdgeIndices() const noexcept
Gets the indices of edges for each scan-line.
Definition: calibration_line_scan.hpp:315
std::vector< int > ScanLineIndices() const noexcept
Gets the indices of the scan-lines.
Definition: calibration_line_scan.hpp:305
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 line-scan cameras.
Definition: calibration_line_scan.hpp:496
A set of parameters, which is used to configure line-scan calibration.
Definition: calibration_line_scan.hpp:46
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:132
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:96
void SetScanDirection(Foundation::CalibrationLineScan::ScanDirection scanDirection) noexcept
Sets the scanning direction of camera.
Definition: calibration_line_scan.hpp:176
double Tolerance() const noexcept
Gets the value for early stopping criteria.
Definition: calibration_line_scan.hpp:144
void SetTolerance(double tolerance) noexcept
Sets the value for early stopping criteria.
Definition: calibration_line_scan.hpp:155
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:108
Foundation::CalibrationLineScan::ScanDirection ScanDirection() const noexcept
Gets the scanning direction of camera.
Definition: calibration_line_scan.hpp:165
void SetPreDefinedPixelSizeMode(Foundation::CalibrationLineScan::PreDefinedPixelSizeMode preDefinedPixelSize) noexcept
Sets the decision if predefined pixel size needs to be used.
Definition: calibration_line_scan.hpp:200
double PixelSize() const noexcept
Gets the pixel size of transformed image.
Definition: calibration_line_scan.hpp:214
Foundation::CalibrationLineScan::PreDefinedPixelSizeMode PreDefinedPixelSizeMode() const noexcept
Gets the decision if the calibrator uses predefined pixel size.
Definition: calibration_line_scan.hpp:189
void SetPixelSize(double pixelSize) noexcept
Sets the pixel size of transformed image.
Definition: calibration_line_scan.hpp:225
LineScanCalibrationConfiguration(std::uint32_t maxIterations, std::uint32_t polyDegree, double tolerance, Foundation::CalibrationLineScan::ScanDirection scanDirection, Foundation::CalibrationLineScan::PreDefinedPixelSizeMode preDefinedPixelSizeMode, double pixelSize) noexcept
Constructor for line-scan calibration configuration.
Definition: calibration_line_scan.hpp:69
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:120
A set of parameters that is required by the following data transformation to get the final result.
Definition: calibration_line_scan.hpp:390
double PixelSize() const noexcept
Gets the pixel size after transformation.
Definition: calibration_line_scan.hpp:429
double MeanError() const noexcept
Gets the mean difference between stripe width in the transformed image and reference.
Definition: calibration_line_scan.hpp:441
NonLinearTransformationPtr Transformation() const noexcept
Gets the transformation.
Definition: calibration_line_scan.hpp:417
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 line-scan cameras.
Definition: calibration_line_scan.hpp:496
double StandardDeviation() const noexcept
Gets the standard deviation of the mean error.
Definition: calibration_line_scan.hpp:451
The Common Vision Blox image.
Definition: decl_image.hpp:45
int Width() const noexcept
Width of the image in pixels.
Definition: decl_image.hpp:285
void * Handle() const noexcept
Classic API image handle.
Definition: decl_image.hpp:223
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:169
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 Area2D &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:365
PreDefinedPixelSizeMode
Specifies if the predefined pixel resolution is used for the metric calibration.
Definition: calibration_line_scan.hpp:35
@ 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 line-scan cameras.
Definition: calibration_line_scan.hpp:496
std::pair< Point2D< double >, Point2D< double > > CalculateTwoPointsForCalibrationOfMovement(const ImagePlane &imagePlane, const Area2D &aoi, 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 line-scan cameras.
Definition: calibration_line_scan.hpp:258
ScanDirection
Specifies the scanning direction.
Definition: calibration_line_scan.hpp:26
@ 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...