/// <summary> /// Finds lines in the input image. /// This is the output of the default parameters of the algorithm on the above shown image. /// </summary> /// <param name="image">A grayscale (CV_8UC1) input image. If only a roi needs to be /// selected, use: `fld_ptr-\>detect(image(roi), lines, ...); /// lines += Scalar(roi.x, roi.y, roi.x, roi.y);`</param> /// <returns>A vector of Vec4f elements specifying the beginning /// and ending point of a line. Where Vec4f is (x1, y1, x2, y2), /// point 1 is the start, point 2 - end.Returned lines are directed so that the /// brighter side is on their left.</returns> public virtual Vec4f[] Detect(InputArray image) { if (image == null) { throw new ArgumentNullException(nameof(image)); } image.ThrowIfDisposed(); using (var lines = new VectorOfVec4f()) { NativeMethods.ximgproc_FastLineDetector_detect_vector(ptr, image.CvPtr, lines.CvPtr); GC.KeepAlive(image); return(lines.ToArray()); } }
/// <summary> /// Draws the line segments on a given image. /// </summary> /// <param name="image">The image, where the lines will be drawn. Should be bigger or equal to the image, where the lines were found.</param> /// <param name="lines">A vector of the lines that needed to be drawn.</param> /// <param name="drawArrow">If true, arrow heads will be drawn.</param> public virtual void DrawSegments(InputOutputArray image, IEnumerable <Vec4f> lines, bool drawArrow = false) { if (image == null) { throw new ArgumentNullException(nameof(image)); } if (lines == null) { throw new ArgumentNullException(nameof(lines)); } using (var linesVec = new VectorOfVec4f(lines)) { NativeMethods.ximgproc_FastLineDetector_drawSegments_vector(ptr, image.CvPtr, linesVec.CvPtr, drawArrow ? 1 : 0); } image.Fix(); }
/// <summary> /// Draws the line segments on a given image. /// </summary> /// <param name="image">The image, where the lines will be drawn. Should be bigger or equal to the image, where the lines were found.</param> /// <param name="lines">A vector of the lines that needed to be drawn.</param> /// <param name="drawArrow">If true, arrow heads will be drawn.</param> public virtual void DrawSegments(InputOutputArray image, IEnumerable <Vec4f> lines, bool drawArrow = false) { ThrowIfDisposed(); if (image == null) { throw new ArgumentNullException(nameof(image)); } if (lines == null) { throw new ArgumentNullException(nameof(lines)); } using var linesVec = new VectorOfVec4f(lines); NativeMethods.HandleException( NativeMethods.ximgproc_FastLineDetector_drawSegments_vector( ptr, image.CvPtr, linesVec.CvPtr, drawArrow ? 1 : 0)); GC.KeepAlive(this); GC.KeepAlive(image); image.Fix(); }
/// <summary> /// Finds lines in the input image. /// This is the output of the default parameters of the algorithm on the above shown image. /// </summary> /// <param name="image">A grayscale (CV_8UC1) input image. </param> /// <param name="lines">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.</param> /// <param name="width">Vector of widths of the regions, where the lines are found. E.g. Width of line.</param> /// <param name="prec">Vector of precisions with which the lines are found.</param> /// <param name="nfa">Vector containing number of false alarms in the line region, /// with precision of 10%. The bigger the value, logarithmically better the detection.</param> public virtual void Detect(InputArray image, out Vec4f[] lines, out double[] width, out double[] prec, out double[] nfa) { if (image == null) throw new ArgumentNullException(nameof(image)); image.ThrowIfDisposed(); using (var linesVec = new VectorOfVec4f()) using (var widthVec = new VectorOfDouble()) using (var precVec = new VectorOfDouble()) using (var nfaVec = new VectorOfDouble()) { NativeMethods.imgproc_LineSegmentDetector_detect_vector(ptr, image.CvPtr, linesVec.CvPtr, widthVec.CvPtr, precVec.CvPtr, nfaVec.CvPtr); lines = linesVec.ToArray(); width = widthVec.ToArray(); prec = precVec.ToArray(); nfa = nfaVec.ToArray(); } GC.KeepAlive(image); }
/// <summary> /// /// </summary> /// <returns></returns> public Vec4f[] GetEdgeList() { if (disposed) throw new ObjectDisposedException("Subdiv2D", ""); IntPtr p; NativeMethods.imgproc_Subdiv2D_getEdgeList(ptr, out p); using (VectorOfVec4f vec = new VectorOfVec4f(p)) { return vec.ToArray(); } }