fast_line_detector.hpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef __OPENCV_FAST_LINE_DETECTOR_HPP__
  5. #define __OPENCV_FAST_LINE_DETECTOR_HPP__
  6. #include <opencv2/core.hpp>
  7. namespace cv
  8. {
  9. namespace ximgproc
  10. {
  11. //! @addtogroup ximgproc_fast_line_detector
  12. //! @{
  13. /** @brief Class implementing the FLD (Fast Line Detector) algorithm described
  14. in @cite Lee14 .
  15. */
  16. //! @include samples/fld_lines.cpp
  17. class CV_EXPORTS_W FastLineDetector : public Algorithm
  18. {
  19. public:
  20. /** @example fld_lines.cpp
  21. An example using the FastLineDetector
  22. */
  23. /** @brief Finds lines in the input image.
  24. This is the output of the default parameters of the algorithm on the above
  25. shown image.
  26. ![image](pics/corridor_fld.jpg)
  27. @param image A grayscale (CV_8UC1) input image. If only a roi needs to be
  28. selected, use: `fld_ptr-\>detect(image(roi), lines, ...);
  29. lines += Scalar(roi.x, roi.y, roi.x, roi.y);`
  30. @param lines A vector of Vec4f elements specifying the beginning
  31. and ending point of a line. Where Vec4f is (x1, y1, x2, y2), point
  32. 1 is the start, point 2 - end. Returned lines are directed so that the
  33. brighter side is on their left.
  34. */
  35. CV_WRAP virtual void detect(InputArray image, OutputArray lines) = 0;
  36. /** @brief Draws the line segments on a given image.
  37. @param image The image, where the lines will be drawn. Should be bigger
  38. or equal to the image, where the lines were found.
  39. @param lines A vector of the lines that needed to be drawn.
  40. @param draw_arrow If true, arrow heads will be drawn.
  41. @param linecolor Line color.
  42. @param linethickness Line thickness.
  43. */
  44. CV_WRAP virtual void drawSegments(InputOutputArray image, InputArray lines,
  45. bool draw_arrow = false, Scalar linecolor = Scalar(0, 0, 255), int linethickness = 1) = 0;
  46. virtual ~FastLineDetector() { }
  47. };
  48. /** @brief Creates a smart pointer to a FastLineDetector object and initializes it
  49. @param length_threshold Segment shorter than this will be discarded
  50. @param distance_threshold A point placed from a hypothesis line
  51. segment farther than this will be regarded as an outlier
  52. @param canny_th1 First threshold for hysteresis procedure in Canny()
  53. @param canny_th2 Second threshold for hysteresis procedure in Canny()
  54. @param canny_aperture_size Aperturesize for the sobel operator in Canny().
  55. If zero, Canny() is not applied and the input image is taken as an edge image.
  56. @param do_merge If true, incremental merging of segments will be performed
  57. */
  58. CV_EXPORTS_W Ptr<FastLineDetector> createFastLineDetector(
  59. int length_threshold = 10, float distance_threshold = 1.414213562f,
  60. double canny_th1 = 50.0, double canny_th2 = 50.0, int canny_aperture_size = 3,
  61. bool do_merge = false);
  62. //! @} ximgproc_fast_line_detector
  63. }
  64. }
  65. #endif