edge_drawing.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_EDGE_DRAWING_HPP__
  5. #define __OPENCV_EDGE_DRAWING_HPP__
  6. #include <opencv2/core.hpp>
  7. namespace cv
  8. {
  9. namespace ximgproc
  10. {
  11. //! @addtogroup ximgproc_edge_drawing
  12. //! @{
  13. /** @brief Class implementing the ED (EdgeDrawing) @cite topal2012edge, EDLines @cite akinlar2011edlines, EDPF @cite akinlar2012edpf and EDCircles @cite akinlar2013edcircles algorithms
  14. */
  15. class CV_EXPORTS_W EdgeDrawing : public Algorithm
  16. {
  17. public:
  18. enum GradientOperator
  19. {
  20. PREWITT = 0,
  21. SOBEL = 1,
  22. SCHARR = 2,
  23. LSD = 3
  24. };
  25. struct CV_EXPORTS_W_SIMPLE Params
  26. {
  27. CV_WRAP Params();
  28. //! Parameter Free mode will be activated when this value is true.
  29. CV_PROP_RW bool PFmode;
  30. //! indicates the operator used for gradient calculation.The following operation flags are available(cv::ximgproc::EdgeDrawing::GradientOperator)
  31. CV_PROP_RW int EdgeDetectionOperator;
  32. //! threshold value used to create gradient image.
  33. CV_PROP_RW int GradientThresholdValue;
  34. //! threshold value used to create gradient image.
  35. CV_PROP_RW int AnchorThresholdValue;
  36. CV_PROP_RW int ScanInterval;
  37. //! minimun connected pixels length processed to create an edge segment.
  38. CV_PROP_RW int MinPathLength;
  39. //! sigma value for internal GaussianBlur() function.
  40. CV_PROP_RW float Sigma;
  41. CV_PROP_RW bool SumFlag;
  42. //! when this value is true NFA (Number of False Alarms) algorithm will be used for line and ellipse validation.
  43. CV_PROP_RW bool NFAValidation;
  44. //! minimun line length to detect.
  45. CV_PROP_RW int MinLineLength;
  46. CV_PROP_RW double MaxDistanceBetweenTwoLines;
  47. CV_PROP_RW double LineFitErrorThreshold;
  48. CV_PROP_RW double MaxErrorThreshold;
  49. void read(const FileNode& fn);
  50. void write(FileStorage& fs) const;
  51. };
  52. /** @brief Detects edges and prepares them to detect lines and ellipses.
  53. @param src input image
  54. */
  55. CV_WRAP virtual void detectEdges(InputArray src) = 0;
  56. CV_WRAP virtual void getEdgeImage(OutputArray dst) = 0;
  57. CV_WRAP virtual void getGradientImage(OutputArray dst) = 0;
  58. /** @brief Returns std::vector<std::vector<Point>> of detected edge segments, see detectEdges()
  59. */
  60. CV_WRAP virtual std::vector<std::vector<Point> > getSegments() = 0;
  61. /** @brief Returns for each line found in detectLines() its edge segment index in getSegments()
  62. */
  63. CV_WRAP virtual std::vector<int> getSegmentIndicesOfLines() const = 0;
  64. /** @brief Detects lines.
  65. @param lines output Vec<4f> contains start point and end point of detected lines.
  66. @note you should call detectEdges() method before call this.
  67. */
  68. CV_WRAP virtual void detectLines(OutputArray lines) = 0;
  69. /** @brief Detects circles and ellipses.
  70. @param ellipses output Vec<6d> contains center point and perimeter for circles.
  71. @note you should call detectEdges() method before call this.
  72. */
  73. CV_WRAP virtual void detectEllipses(OutputArray ellipses) = 0;
  74. CV_WRAP Params params;
  75. /** @brief sets parameters.
  76. this function is meant to be used for parameter setting in other languages than c++.
  77. */
  78. CV_WRAP void setParams(const EdgeDrawing::Params& parameters);
  79. virtual ~EdgeDrawing() { }
  80. };
  81. /** @brief Creates a smart pointer to a EdgeDrawing object and initializes it
  82. */
  83. CV_EXPORTS_W Ptr<EdgeDrawing> createEdgeDrawing();
  84. //! @}
  85. }
  86. }
  87. #endif /* __OPENCV_EDGE_DRAWING_HPP__ */