CVB++ 15.0
Cvb::Foundation::CalibrationLineScan Namespace Reference

Namespace for collection of calibration linescan functions from the Foundation package. More...

Classes

class  EdgeDetectionResult
 Result of the function DetectEdgesOfStripeTarget. More...
 
class  LineScanCalibrationConfiguration
 A set of parameters, which is used to configure linescan calibration calculated with function CreateLineScanCalibration. More...
 
class  LineScanCalibrator
 Result of the linescan calibration executed by the CreateLineScanCalibration function. More...
 

Typedefs

using LineScanCalibratorPtr = std::shared_ptr< LineScanCalibrator >
 Convenience shared pointer for LineScanCalibrator.
 

Enumerations

enum class  ScanDirection { X = CExports::CVFScanDirection::CVFSD_X , Y = CExports::CVFScanDirection::CVFSD_Y }
 Specifies the scanning direction. More...
 
enum class  PreDefinedPixelSizeMode { DoNotUse , Use }
 Specifies if the predefined pixel resolution is used for the metric calibration. More...
 

Functions

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. More...
 
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. More...
 
std::unique_ptr< LineScanCalibratorCreateLineScanCalibration (const Point2D< double > &calibrationPoint1, const Point2D< double > &calibrationPoint2, double referenceDistanceCalibrationPoints, const EdgeDetectionResult &edgeDetectionResult, double referenceWidthStripes, const LineScanCalibrationConfiguration &configuration)
 Calibrates linescan cameras. More...
 

Detailed Description

Namespace for collection of calibration linescan functions from the Foundation package.

Remarks
CMake users: Link to imported target CVB::CvbFoundationCalibrationLineScan.

Enumeration Type Documentation

◆ PreDefinedPixelSizeMode

enum class PreDefinedPixelSizeMode
strong

Specifies if the predefined pixel resolution is used for the metric calibration.

Enumerator
DoNotUse 

Predefined pixel resolution will not be used.

Use 

Predefined pixel resolution will be used.

◆ ScanDirection

enum class ScanDirection
strong

Specifies the scanning direction.

The scanning direction has to be set in the configuration object LineScanCalibrationConfiguration used by the linescan calibration CreateLineScanCalibration.

Enumerator

Scans along the X coordinate.

Scans along the Y coordinate.

Function Documentation

◆ CalculateTwoPointsForCalibrationOfMovement()

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 
)
inline

Extracts two points which can be used for the calibration of the movement of linescan cameras.

The output of this function serves as input for the linescan calibration process executed by the CreateLineScanCalibration function.

If the image contains more than two points, the points which are nearest to the top and bottom edge (or left and right edge if ScanDirection is Y) are chosen.

Parameters
[in]imagePlaneAn image plane containing the calibration points.
[in]aoiArea of interest where the calibration points can be found.
[in]contrastSelects whether the image shows white on black or black on white dots.
[in]minContrastMinimum gray value contrast between the object and the background of the calibration points. Value to be set depends on the quality of the image taken.
[in]pointSizeRangeThe minimum and maximum size of the markers in the image in [number of pixels].
[in]scanDirectionScan direction of the camera.
Returns
first: X and Y coordinate of top calibration point if the ScanDirection is X, otherwise left point.
second: X and Y coordinate of bottom calibration point if the ScanDirection is X, otherwise right point.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ CreateLineScanCalibration()

std::unique_ptr< LineScanCalibrator > CreateLineScanCalibration ( const Point2D< double > &  calibrationPoint1,
const Point2D< double > &  calibrationPoint2,
double  referenceDistanceCalibrationPoints,
const EdgeDetectionResult edgeDetectionResult,
double  referenceWidthStripes,
const LineScanCalibrationConfiguration configuration 
)
inline

Calibrates linescan cameras.

This function estimates coefficients of a 3rd order polynomial which calibrates linescan cameras. The polynomial corrects lens distortion as well as the camera's direction of movement (described by a scaling factor).

For the estimation of the lens distortion correction a pattern with alternating black and white stripes where the width of the stripes referenceWidthStripes is precisely known has to be acquired. For the camera's direction of movement a target with two circular markers can be used. The distance between the calibration points referenceDistanceCalibrationPoints has to be known, too. Note, that referenceWidthStripes and referenceDistanceCalibrationPoints must be provided in the same units.

In a first step the edges of the stripe target have to be detected via function DetectEdgesOfStripeTarget.

Second the two markers have to be extracted from the image via function CalculateTwoPointsForCalibrationOfMovement. Note, that if the encoder step of your setup is precisely known (e.g. in [mm/scanline]), you do not need to acquire an image with markers. You may manually define fictive calibration points and the corresponding reference distance:

double encoderStep = ... // mm/scanline
auto calibrationPoint1 = Cvb::Point2D<double>(0, 0); // first point
auto calibrationPoint2 = Cvb::Point2D<double>(1, 0); // second point
referenceDistanceCalibrationPoints = encoderStep; // reference distance between calibration points in[mm]
Parameters
[in]calibrationPoint1First calibration point (left or top).
[in]calibrationPoint2Second calibration point (right or bottom).
[in]referenceDistanceCalibrationPointsReference distance between the two calibration points (same units as referenceWidthStripes).
[in]edgeDetectionResultResult returned by DetectEdgesOfStripeTarget.
[in]referenceWidthStripesReference width of stripes in calibration pattern (same units as referenceDistanceCalibrationPoints).
[in]configurationConfiguration of linescan calibration.
Returns
A linescan calibrator including a transformation and its quality.

◆ DetectEdgesOfStripeTarget()

EdgeDetectionResult DetectEdgesOfStripeTarget ( const Image imageStripes,
const Rect< int > &  aoi,
int  numStripes,
const ScanDirection scanDirection,
double  threshold 
)
inline

This function detects edges from a calibration pattern with alternating black and white stripes.

The output of this function is used by function CreateLineScanCalibration calculating the linescan calibration. This function internally calls Edge::FindAllEdges, where all input parameter are described, too. For detailed information see the documentation of the CVB edge tool.

Note, that the given area of interest aoi must only cover areas with stripes.

Note
The given number of stripes numStripes is only used for memory allocation. It does not necessarily have to precisely match the number of stripes, but it must be equal to or greater than the actual number of stripes. If the selected value is too low, an error is thrown ("bad allocation").
Parameters
[in]imageStripesCalibration pattern with alternating black and white stripes.
[in]aoiArea of interest in the given image.
[in]numStripesNumber of stripes in the calibration pattern.
[in]scanDirectionScan direction of the camera.
[in]thresholdThreshold for gray value change.
Returns
Result of the edge detection.