Class LineSegmentDetector
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Line segment detector class
public class LineSegmentDetector : Algorithm, IDisposable, ICvPtrHolder
- Inheritance
-
LineSegmentDetector
- Implements
- Inherited Members
Constructors
LineSegmentDetector(nint)
protected LineSegmentDetector(nint p)
Parameters
pnint
Methods
CompareSegments(Size, InputArray, InputArray, InputOutputArray?)
Draws two groups of lines in blue and red, counting the non overlapping (mismatching) pixels.
public virtual int CompareSegments(Size size, InputArray lines1, InputArray lines2, InputOutputArray? image = null)
Parameters
sizeSizeThe size of the image, where lines1 and lines2 were found.
lines1InputArrayThe first group of lines that needs to be drawn. It is visualized in blue color.
lines2InputArrayThe second group of lines. They visualized in red color.
imageInputOutputArrayOptional image, where the lines will be drawn. The image should be color(3-channel) in order for lines1 and lines2 to be drawn in the above mentioned colors.
Returns
Create(LineSegmentDetectorModes, double, double, double, double, double, double, int)
Creates a smart pointer to a LineSegmentDetector object and initializes it.
public static LineSegmentDetector Create(LineSegmentDetectorModes refine = LineSegmentDetectorModes.RefineNone, double scale = 0.8, double sigmaScale = 0.6, double quant = 2, double angTh = 22.5, double logEps = 0, double densityTh = 0.7, int nBins = 1024)
Parameters
refineLineSegmentDetectorModesThe way found lines will be refined, see cv::LineSegmentDetectorModes
scaledoubleThe scale of the image that will be used to find the lines. Range (0..1].
sigmaScaledoubleSigma for Gaussian filter. It is computed as sigma = _sigma_scale/_scale.
quantdoubleBound to the quantization error on the gradient norm.
angThdoubleGradient angle tolerance in degrees.
logEpsdoubleDetection threshold: -log10(NFA) > log_eps. Used only when advancent refinement is chosen.
densityThdoubleMinimal density of aligned region points in the enclosing rectangle.
nBinsintNumber of bins in pseudo-ordering of gradient modulus.
Returns
Detect(InputArray, OutputArray, OutputArray?, OutputArray?, OutputArray?)
Finds lines in the input image. This is the output of the default parameters of the algorithm on the above shown image.
public virtual void Detect(InputArray image, OutputArray lines, OutputArray? width = null, OutputArray? prec = null, OutputArray? nfa = null)
Parameters
imageInputArrayA grayscale (CV_8UC1) input image.
linesOutputArrayA vector of Vec4i or Vec4f elements specifying the beginning and ending point of a line. Where Vec4i/Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly oriented depending on the gradient.
widthOutputArrayVector of widths of the regions, where the lines are found. E.g. Width of line.
precOutputArrayVector of precisions with which the lines are found.
nfaOutputArrayVector containing number of false alarms in the line region, with precision of 10%. The bigger the value, logarithmically better the detection.
Detect(InputArray, out Vec4f[], out double[], out double[], out double[])
Finds lines in the input image. This is the output of the default parameters of the algorithm on the above shown image.
public virtual void Detect(InputArray image, out Vec4f[] lines, out double[] width, out double[] prec, out double[] nfa)
Parameters
imageInputArrayA grayscale (CV_8UC1) input image.
linesVec4f[]A vector of Vec4i or Vec4f elements specifying the beginning and ending point of a line. Where Vec4i/Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly oriented depending on the gradient.
widthdouble[]Vector of widths of the regions, where the lines are found. E.g. Width of line.
precdouble[]Vector of precisions with which the lines are found.
nfadouble[]Vector containing number of false alarms in the line region, with precision of 10%. The bigger the value, logarithmically better the detection.
DisposeManaged()
Releases managed resources
protected override void DisposeManaged()
DrawSegments(InputOutputArray, InputArray)
Draws the line segments on a given image.
public virtual void DrawSegments(InputOutputArray image, InputArray lines)
Parameters
imageInputOutputArrayThe image, where the liens will be drawn. Should be bigger or equal to the image, where the lines were found.
linesInputArrayA vector of the lines that needed to be drawn.