Skip to content

Commit 081bebd

Browse files
committed
improvements on EdgeDrawing
1 parent bcd47ed commit 081bebd

File tree

2 files changed

+48
-17
lines changed

2 files changed

+48
-17
lines changed

modules/ximgproc/include/opencv2/ximgproc/edge_drawing.hpp

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,69 +25,93 @@ class CV_EXPORTS_W EdgeDrawing : public Algorithm
2525
enum GradientOperator
2626
{
2727
PREWITT = 0,
28-
SOBEL = 1,
29-
SCHARR = 2,
30-
LSD = 3
28+
SOBEL = 1,
29+
SCHARR = 2,
30+
LSD = 3
3131
};
3232

3333
struct CV_EXPORTS_W_SIMPLE Params
3434
{
3535
CV_WRAP Params();
36-
//! Parameter Free mode will be activated when this value is true.
36+
//! Parameter Free mode will be activated when this value is set as true. Default value is false.
3737
CV_PROP_RW bool PFmode;
38-
//! indicates the operator used for gradient calculation.The following operation flags are available(cv::ximgproc::EdgeDrawing::GradientOperator)
38+
/** @brief indicates the operator used for gradient calculation.
39+
40+
one of the flags cv::ximgproc::EdgeDrawing::GradientOperator. Default value is PREWITT
41+
*/
3942
CV_PROP_RW int EdgeDetectionOperator;
40-
//! threshold value used to create gradient image.
43+
//! threshold value of gradiential difference between pixels. Used to create gradient image. Default value is 20
4144
CV_PROP_RW int GradientThresholdValue;
42-
//! threshold value used to create gradient image.
45+
//! threshold value used to select anchor points. Default value is 0
4346
CV_PROP_RW int AnchorThresholdValue;
47+
//! Default value is 1
4448
CV_PROP_RW int ScanInterval;
45-
//! minimun connected pixels length processed to create an edge segment.
49+
/** @brief minimun connected pixels length processed to create an edge segment.
50+
51+
in gradient image, minimum connected pixels length processed to create an edge segment. pixels having upper value than GradientThresholdValue
52+
will be processed. Default value is 10
53+
*/
4654
CV_PROP_RW int MinPathLength;
47-
//! sigma value for internal GaussianBlur() function.
55+
//! sigma value for internal GaussianBlur() function. Default value is 1.0
4856
CV_PROP_RW float Sigma;
4957
CV_PROP_RW bool SumFlag;
50-
//! when this value is true NFA (Number of False Alarms) algorithm will be used for line and ellipse validation.
58+
//! Default value is true. indicates if NFA (Number of False Alarms) algorithm will be used for line and ellipse validation.
5159
CV_PROP_RW bool NFAValidation;
5260
//! minimun line length to detect.
5361
CV_PROP_RW int MinLineLength;
62+
//! Default value is 6.0
5463
CV_PROP_RW double MaxDistanceBetweenTwoLines;
64+
//! Default value is 1.0
5565
CV_PROP_RW double LineFitErrorThreshold;
66+
//! Default value is 1.3
5667
CV_PROP_RW double MaxErrorThreshold;
5768

5869
void read(const FileNode& fn);
5970
void write(FileStorage& fs) const;
6071
};
6172

62-
/** @brief Detects edges and prepares them to detect lines and ellipses.
73+
/** @brief Detects edges in a grayscale image and prepares them to detect lines and ellipses.
6374
64-
@param src input image
75+
@param src 8-bit, single-channel, grayscale input image.
6576
*/
6677
CV_WRAP virtual void detectEdges(InputArray src) = 0;
78+
79+
/** @brief returns Edge Image prepared by detectEdges() function.
80+
81+
@param dst returns 8-bit, single-channel output image.
82+
*/
6783
CV_WRAP virtual void getEdgeImage(OutputArray dst) = 0;
84+
85+
/** @brief returns Gradient Image prepared by detectEdges() function.
86+
87+
@param dst returns 16-bit, single-channel output image.
88+
*/
6889
CV_WRAP virtual void getGradientImage(OutputArray dst) = 0;
6990

91+
/** @brief returns Edge Segments prepared by detectEdges() function.
92+
*/
7093
CV_WRAP virtual std::vector<std::vector<Point> > getSegments() = 0;
7194

7295
/** @brief Detects lines.
7396
74-
@param lines output Vec<4f> contains start point and end point of detected lines.
75-
@note you should call detectEdges() method before call this.
97+
@param lines output Vec<4f> contains the start point and the end point of detected lines.
98+
@note you should call detectEdges() before calling this function.
7699
*/
77100
CV_WRAP virtual void detectLines(OutputArray lines) = 0;
78101

79102
/** @brief Detects circles and ellipses.
80103
81-
@param ellipses output Vec<6d> contains center point and perimeter for circles.
82-
@note you should call detectEdges() method before call this.
104+
@param ellipses output Vec<6d> contains center point and perimeter for circles, center point, axes and angle for ellipses.
105+
@note you should call detectEdges() before calling this function.
83106
*/
84107
CV_WRAP virtual void detectEllipses(OutputArray ellipses) = 0;
85108

86109
CV_WRAP Params params;
87110

88111
/** @brief sets parameters.
89112
90-
this function is meant to be used for parameter setting in other languages than c++.
113+
this function is meant to be used for parameter setting in other languages than c++ like python.
114+
@param parameters
91115
*/
92116
CV_WRAP void setParams(const EdgeDrawing::Params& parameters);
93117
virtual ~EdgeDrawing() { }

modules/ximgproc/src/edge_drawing.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class EdgeDrawingImpl : public EdgeDrawing
112112
void detectLines(OutputArray lines) CV_OVERRIDE;
113113
void detectEllipses(OutputArray ellipses) CV_OVERRIDE;
114114

115+
virtual String getDefaultName() const CV_OVERRIDE;
115116
virtual void read(const FileNode& fn) CV_OVERRIDE;
116117
virtual void write(FileStorage& fs) const CV_OVERRIDE;
117118

@@ -315,6 +316,11 @@ void EdgeDrawing::Params::write(cv::FileStorage& fs) const
315316
fs << "MaxErrorThreshold" << MaxErrorThreshold;
316317
}
317318

319+
String EdgeDrawingImpl::getDefaultName() const
320+
{
321+
return String("EdgeDrawing");
322+
}
323+
318324
void EdgeDrawingImpl::read(const cv::FileNode& fn)
319325
{
320326
params.read(fn);
@@ -343,6 +349,7 @@ EdgeDrawingImpl::~EdgeDrawingImpl()
343349

344350
void EdgeDrawingImpl::detectEdges(InputArray src)
345351
{
352+
CV_Assert(!src.empty() && src.type() == CV_8UC1);
346353
gradThresh = params.GradientThresholdValue;
347354
anchorThresh = params.AnchorThresholdValue;
348355
op = params.EdgeDetectionOperator;

0 commit comments

Comments
 (0)