CVB++ 15.0
EdgeDetectionResult Class Referencefinal

Result of the function DetectEdgesOfStripeTarget. More...

#include <cvb/foundation/calibration_line_scan.hpp>

Public Member Functions

std::vector< int > ScanLineIndices () const noexcept
 Gets the indices of the scan lines. More...
 
std::vector< double > EdgeIndices () const noexcept
 Gets the indices of edges for each scan line. More...
 
int NumProfiles () const noexcept
 Gets the number of scan lines where edges are correctly detected. More...
 
int NumEdgesPerProfile () const noexcept
 Gets the number of edges per profile (scan line). More...
 

Friends

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

Result of the function DetectEdgesOfStripeTarget.

The DetectEdgesOfStripeTarget function identifies edges within an image depicting a target with alternating black and white stripes. The image is scanned line by line and the results, including edge indices and scan lines are stored within this class.

Subsequently, the instance of this class serves as input for the linescan calibration process executed by the CreateLineScanCalibration function.

Member Function Documentation

◆ EdgeIndices()

std::vector< double > EdgeIndices ( ) const
inlinenoexcept

Gets the indices of edges for each scan line.

Note, that the size of the returned vector does not represent the actual dimensions. The size depends on the allocated memory determined by the image height and the given number of stripes given in function DetectEdgesOfStripeTarget. The edge indices are stored subsequently scan line by scan line. Only values up to elements with index #NumEdgesPerProfile*#NumProfiles-1 are valid.

The following code snippet prints ScanLineIndices and EdgeIndices in a more readable format:

EdgeDetectionResult detectedEdges = ...
std::cout << "Scanline and edge indices:\n";
auto scanLines = detectedEdges.ScanLineIndices();
auto itSL = scanLines.begin();
auto edges = detectedEdges.EdgeIndices();
auto itE = edges.begin();
for (int i = 0; i < detectedEdges.NumProfiles(); i++)
{
std::cout << "scan line " << *itSL++ << " with edges at: ";
for (int j = 0; j < detectedEdges.NumEdgesPerProfile(); j++)
{
std::cout << *itE++ << " ";
}
std::cout << "\n";
}
std::cout << "\n";
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
Returns
The indices of edges for each scan line.
Exceptions
Doesnot throw any exception.

◆ NumEdgesPerProfile()

int NumEdgesPerProfile ( ) const
inlinenoexcept

Gets the number of edges per profile (scan line).

Returns
The number of edges per profile (scan line).
Exceptions
Doesnot throw any exception.

◆ NumProfiles()

int NumProfiles ( ) const
inlinenoexcept

Gets the number of scan lines where edges are correctly detected.

Note, that only profiles, where the same number of edges are found, are stored to EdgeDetectionResult.

Returns
The number of scan lines where edges are correctly detected.
Exceptions
Doesnot throw any exception.

◆ ScanLineIndices()

std::vector< int > ScanLineIndices ( ) const
inlinenoexcept

Gets the indices of the scan lines.

Note, that the size of the returned vector does not represent the actual number of indices. The size depends on the allocated memory determined by the image height given in function DetectEdgesOfStripeTarget. Only values up to elements with index #NumProfiles-1 are valid.

Returns
The indices of the scan lines.
Exceptions
Doesnot throw any exception.

Friends And Related Function Documentation

◆ CreateLineScanCalibration

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

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.