Back to Aurora Vision Library website

You are here: Start » Function Reference » Computer Vision » Line Finder » FindSingleLine

FindSingleLine


Header: AVL.h
Namespace: avl
Module: MetrologyPro

Finds a single straight line within a rectangular scan field.

Applications: Detection of a single straight line in the presence of multiple competing lines or noisy backgrounds.

Syntax

C++
C#
Python
 
void avl::FindSingleLine
(
	const avl::Image& inImage,
	const avl::SegmentScanField& inScanField,
	atl::Optional<const avl::CoordinateSystem2D&> inScanFieldAlignment,
	int inScanWidth,
	int inScanStep,
	int inScanLimit,
	const avl::EdgeScanParams& inEdgeScanParams,
	float inPointBlindness,
	float inMaxSlant,
	float inMinLength,
	float inMaxGap,
	int inMinPointCount,
	avl::LineSelection::Type inLineSelection,
	float inLineBlindness,
	avl::EdgeMeasure::Type inEdgeMeasure,
	avl::LineFinderMethod::Type inLineFinderMethod,
	float inMaxPointDeviation,
	float inMaxTurnAngle,
	atl::Optional<avl::LineMEstimator::Type> inOutlierSuppression,
	bool inRefineEndpoints,
	atl::Conditional<avl::Segment2D>& outLine,
	atl::Optional<float&> outLineStrength,
	atl::Array<avl::Profile>& outResponseProfiles,
	atl::Optional<avl::SegmentScanField&> outAlignedScanField,
	atl::Array<avl::Point2D>& outSelectedPoints,
	atl::Array<avl::Segment2D>& diagScanLines,
	atl::Array<avl::Point2D>& diagCandidatePoints
)

Parameters

Name Type Range Default Description
Input value inImage const Image& Input image
Input value inScanField const SegmentScanField& Region where the scans are performed
Input value inScanFieldAlignment Optional<const CoordinateSystem2D&> NIL
Input value inScanWidth int 1 - 5 How many pixels are sampled perpendicularly at each scan line's positions
Input value inScanStep int 1 - 10 Pixel distance between the centers of consecutive scan lines
Input value inScanLimit int 1 - 50 Maximum number of scan lines
Input value inEdgeScanParams const EdgeScanParams& EdgeScanParams ( ProfileInterpolation: Quadratic4 SmoothingStdDev: 1.2f MinMagnitude: 5.0f EdgeTransition: Any ) Parameters of 1D edge detection along a single scan line
Input value inPointBlindness float 0.0 - 1.0 0.3f Defines a threshold for rejecting edge points that are weaker than a certain portion of the strongest edge point
Input value inMaxSlant float 0.0 - 45.0 30.0f Maximum angle deviation of the resulting line from 90 degrees to the scan axis
Input value inMinLength float 0.0 - 10.0f Minimum length of the resulting line
Input value inMaxGap float 0.0 - 50.0f Maximum gap within a resulting line
Input value inMinPointCount int 2 - 3 Minimum number of edge points that a resulting line must contain (otherwise it is rejected)
Input value inLineSelection LineSelection::Type Fittest Selection criteria for edge lines
Input value inLineBlindness float 0.0 - 1.0 0.4f Defines a threshold for rejecting entire lines that are weaker than a certain portion of the strongest line
Input value inEdgeMeasure EdgeMeasure::Type LogMagnitude Several options for measuring a single edge point
Input value inLineFinderMethod LineFinderMethod::Type Hough Several alternative algorithms for finding lines within the detected cloud of edge points
Input value inMaxPointDeviation float 0.0 - 2.5f Maximum pixel distance between a detected line and its supporting edge points
Input value inMaxTurnAngle float 0.0 - 90.0 10.0f Maximum turn angle at any interior vertex of the line path
Input value inOutlierSuppression Optional<LineMEstimator::Type> TheilSen A method for removing outlying points
Input value inRefineEndpoints bool True Turns on a method for refining the length of the detected line
Output value outLine Conditional<Segment2D>&
Output value outLineStrength Optional<float&>
Output value outResponseProfiles Array<Profile>& Edge response profiles, one per scan line
Output value outAlignedScanField Optional<SegmentScanField&>
Output value outSelectedPoints Array<Point2D>& List of points associated with the returned line
Diagnostic input diagScanLines Array<Segment2D>& Positions of the scan lines placed within the scan field
Diagnostic input diagCandidatePoints Array<Point2D>& Edge points detected on the scan lines, after inPointBlindness filtering

Optional Outputs

The computation of following outputs can be switched off by passing value atl::NIL to these parameters: outLineStrength, outAlignedScanField.

Read more about Optional Outputs.

Description

The operation finds the best-fitting straight line within the inScanField. Internally, it places up to inScanLimit scan lines perpendicular to the field axis, spaced inScanStep pixels apart, and detects candidate edge points on each line using inEdgeScanParams. The candidate points are assembled into straight-line hypotheses by the algorithm selected with inLineFinderMethod, and the best hypothesis is chosen according to inLineSelection and refined into a subpixel-precise segment. If no line satisfying the detection constraints is found, outLine is set to NIL.

Hints

  • Activate diagCandidatePoints and diagScanLines during development to verify that candidates appear on the right scan lines before adjusting higher-level parameters.
  • Adjust inEdgeScanParams.MinMagnitude first: a value that is too high misses real edges; too low fills the result with noise candidates.
  • Increase inScanStep to speed up execution on large scan fields. Keep it small (5–10 px) when the line is short or its position varies rapidly across the field.
  • inPointBlindness suppresses weak per-scan-line candidates relative to the strongest response on that line. A value of 0.3 discards candidates below 30 % of the highest value on that scan line.
  • If a detected segment is shorter than the actual line, try increasing inMaxGap, widening inMaxPointDeviation.
  • Set inMaxSlant to the maximum expected deviation of the line from the direction perpendicular to the scan field axis. Narrowing this range reduces false positives.
  • Use inLineSelection = Fittest for the straightest line, Strongest for the highest-contrast line, and Smoothest for gently curved or slightly wavy lines.
  • Connect inScanFieldAlignment to a coordinate system to automatically adapt the measurement to the object position in each frame.

Examples

FindSingleLine locating a single line with inLineSelection = Brightest. The dashed rectangle is the scan field, blue lines are the scan lines, green dots are the candidate edge points, and the blue line is the detected line.

Remarks

Read more about Local Coordinate Systems in Machine Vision Guide: Local Coordinate Systems.

Hardware Acceleration

This operation supports automatic parallelization for multicore and multiprocessor systems.

See Also

  • FindMultipleLines – Finds multiple straight lines within a rectangular scan field, ordered from highest-scoring to lowest.
  • FitSegmentToEdges – Performs a series of 1D edge detections and finds a segment that best matches the detected points.