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"
35 X = CExports::CVFScanDirection::CVFSD_X,
40 Y = CExports::CVFScanDirection::CVFSD_Y
56 class LineScanCalibrationConfiguration final
59 LineScanCalibrationConfiguration() noexcept
84 double pixelSize) noexcept
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;
56 class LineScanCalibrationConfiguration final {
…};
296 Internal::DoResCall([&]() {
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));
321 class EdgeDetectionResult final
325 double referenceDistanceCalibrationPoints,
326 const EdgeDetectionResult &edgeDetectionResult,
double referenceWidthStripes,
330 EdgeDetectionResult() =
default;
333 int numEdgesPerProfile)
334 : scanLineIndices_(
std::move(scanLineIndices))
336 , numProfiles_(numProfiles)
337 , numEdgesPerProfile_(numEdgesPerProfile)
352 return scanLineIndices_;
414 return numEdgesPerProfile_;
421 int numEdgesPerProfile_;
321 class EdgeDetectionResult final {
…};
451 * (
static_cast<size_t>(numStripes) + 1));
452 size_t numProfiles = 0;
453 size_t numEdgesPerProfile = 0;
454 Internal::DoResCall([&]() {
455 return CVB_CALL_CAPI(
457 static_cast<CExports::cvbdim_t
>(aoi.Top()),
static_cast<CExports::cvbdim_t
>(aoi.Right()),
458 static_cast<CExports::cvbdim_t
>(aoi.Bottom()), numStripes,
459 static_cast<CExports::CVFScanDirection
>(scanDirection), threshold,
460 scanLineIndices.data(), edgeIndices.data(), numProfiles, numEdgesPerProfile);
462 return {
std::move(scanLineIndices),
std::move(edgeIndices),
static_cast<int>(numProfiles),
463 static_cast<int>(numEdgesPerProfile)};
468 class LineScanCalibrator final
472 double referenceDistanceCalibrationPoints,
483 double standardDeviation, PrivateTag)
484 : transformation_(transformation)
485 , pixelSize_(pixelSize)
486 , meanError_(meanError)
487 , standardDeviation_(standardDeviation)
530 return transformation_;
565 return standardDeviation_;
572 double standardDeviation_;
468 class LineScanCalibrator final {
…};
614 double referenceDistanceCalibrationPoints,
615 const EdgeDetectionResult &edgeDetectionResult,
double referenceWidthStripes,
618 void *transformation =
nullptr;
619 double pixelSize = 0;
620 double meanError = 0;
621 double standardDeviation = 0;
622 Internal::DoResCall([&]() {
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);
634 return std::make_unique<LineScanCalibrator>(
636 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:613
A set of parameters, which is used to configure linescan calibration calculated with function CreateL...
Definition calibration_line_scan.hpp:57
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:82
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:469
double PixelSize() const noexcept
Gets the pixel size after transformation.
Definition calibration_line_scan.hpp:541
double MeanError() const noexcept
Gets the mean difference between stripe width in the transformed image and reference.
Definition calibration_line_scan.hpp:553
NonLinearTransformationPtr Transformation() const noexcept
Gets the transformation.
Definition calibration_line_scan.hpp:528
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:613
double StandardDeviation() const noexcept
Gets the standard deviation of the mean error.
Definition calibration_line_scan.hpp:563
The Common Vision Blox image.
Definition decl_image.hpp:45
int Width() const noexcept
Width of the image in pixels.
Definition decl_image.hpp:304
void * Handle() const noexcept
Classic API image handle.
Definition decl_image.hpp:232
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
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:23
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:445
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
std::shared_ptr< LineScanCalibrator > LineScanCalibratorPtr
Convenience shared pointer for LineScanCalibrator.
Definition calibration_line_scan.hpp:309
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.
Definition calibration_line_scan.hpp:47
@ Use
Predefined pixel resolution will be used.
Definition calibration_line_scan.hpp:49
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:613
ScanDirection
Specifies the scanning direction.
Definition calibration_line_scan.hpp:30
@ X
Scans along the X coordinate.
Definition calibration_line_scan.hpp:35
@ Y
Scans along the Y coordinate.
Definition calibration_line_scan.hpp:40
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