fast_line_detector.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. */
  42. CV_WRAP virtual void drawSegments(InputOutputArray _image, InputArray lines,
  43. bool draw_arrow = false) = 0;
  44. virtual ~FastLineDetector() { }
  45. };
  46. /** @brief Creates a smart pointer to a FastLineDetector object and initializes it
  47. @param _length_threshold 10 - Segment shorter than this will be discarded
  48. @param _distance_threshold 1.41421356 - A point placed from a hypothesis line
  49. segment farther than this will be
  50. regarded as an outlier
  51. @param _canny_th1 50 - First threshold for
  52. hysteresis procedure in Canny()
  53. @param _canny_th2 50 - Second threshold for
  54. hysteresis procedure in Canny()
  55. @param _canny_aperture_size 3 - Aperturesize for the sobel
  56. operator in Canny()
  57. @param _do_merge false - If true, incremental merging of segments
  58. will be perfomred
  59. */
  60. CV_EXPORTS_W Ptr<FastLineDetector> createFastLineDetector(
  61. int _length_threshold = 10, float _distance_threshold = 1.414213562f,
  62. double _canny_th1 = 50.0, double _canny_th2 = 50.0, int _canny_aperture_size = 3,
  63. bool _do_merge = false);
  64. //! @} ximgproc_fast_line_detector
  65. }
  66. }
  67. #endif