mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-18 17:24:28 +08:00
Merge pull request #3159 from sturkmen72:edge_drawing
This commit is contained in:
@@ -25,61 +25,84 @@ public:
|
|||||||
enum GradientOperator
|
enum GradientOperator
|
||||||
{
|
{
|
||||||
PREWITT = 0,
|
PREWITT = 0,
|
||||||
SOBEL = 1,
|
SOBEL = 1,
|
||||||
SCHARR = 2,
|
SCHARR = 2,
|
||||||
LSD = 3
|
LSD = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CV_EXPORTS_W_SIMPLE Params
|
struct CV_EXPORTS_W_SIMPLE Params
|
||||||
{
|
{
|
||||||
CV_WRAP Params();
|
CV_WRAP Params();
|
||||||
//! Parameter Free mode will be activated when this value is true.
|
//! Parameter Free mode will be activated when this value is set as true. Default value is false.
|
||||||
CV_PROP_RW bool PFmode;
|
CV_PROP_RW bool PFmode;
|
||||||
//! indicates the operator used for gradient calculation.The following operation flags are available(cv::ximgproc::EdgeDrawing::GradientOperator)
|
/** @brief indicates the operator used for gradient calculation.
|
||||||
|
|
||||||
|
one of the flags cv::ximgproc::EdgeDrawing::GradientOperator. Default value is PREWITT
|
||||||
|
*/
|
||||||
CV_PROP_RW int EdgeDetectionOperator;
|
CV_PROP_RW int EdgeDetectionOperator;
|
||||||
//! threshold value used to create gradient image.
|
//! threshold value of gradiential difference between pixels. Used to create gradient image. Default value is 20
|
||||||
CV_PROP_RW int GradientThresholdValue;
|
CV_PROP_RW int GradientThresholdValue;
|
||||||
//! threshold value used to create gradient image.
|
//! threshold value used to select anchor points. Default value is 0
|
||||||
CV_PROP_RW int AnchorThresholdValue;
|
CV_PROP_RW int AnchorThresholdValue;
|
||||||
|
//! Default value is 1
|
||||||
CV_PROP_RW int ScanInterval;
|
CV_PROP_RW int ScanInterval;
|
||||||
//! minimun connected pixels length processed to create an edge segment.
|
/** @brief minimun connected pixels length processed to create an edge segment.
|
||||||
|
|
||||||
|
in gradient image, minimum connected pixels length processed to create an edge segment. pixels having upper value than GradientThresholdValue
|
||||||
|
will be processed. Default value is 10
|
||||||
|
*/
|
||||||
CV_PROP_RW int MinPathLength;
|
CV_PROP_RW int MinPathLength;
|
||||||
//! sigma value for internal GaussianBlur() function.
|
//! sigma value for internal GaussianBlur() function. Default value is 1.0
|
||||||
CV_PROP_RW float Sigma;
|
CV_PROP_RW float Sigma;
|
||||||
CV_PROP_RW bool SumFlag;
|
CV_PROP_RW bool SumFlag;
|
||||||
//! when this value is true NFA (Number of False Alarms) algorithm will be used for line and ellipse validation.
|
//! Default value is true. indicates if NFA (Number of False Alarms) algorithm will be used for line and ellipse validation.
|
||||||
CV_PROP_RW bool NFAValidation;
|
CV_PROP_RW bool NFAValidation;
|
||||||
//! minimun line length to detect.
|
//! minimun line length to detect.
|
||||||
CV_PROP_RW int MinLineLength;
|
CV_PROP_RW int MinLineLength;
|
||||||
|
//! Default value is 6.0
|
||||||
CV_PROP_RW double MaxDistanceBetweenTwoLines;
|
CV_PROP_RW double MaxDistanceBetweenTwoLines;
|
||||||
|
//! Default value is 1.0
|
||||||
CV_PROP_RW double LineFitErrorThreshold;
|
CV_PROP_RW double LineFitErrorThreshold;
|
||||||
|
//! Default value is 1.3
|
||||||
CV_PROP_RW double MaxErrorThreshold;
|
CV_PROP_RW double MaxErrorThreshold;
|
||||||
|
|
||||||
void read(const FileNode& fn);
|
void read(const FileNode& fn);
|
||||||
void write(FileStorage& fs) const;
|
void write(FileStorage& fs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Detects edges and prepares them to detect lines and ellipses.
|
/** @brief Detects edges in a grayscale image and prepares them to detect lines and ellipses.
|
||||||
|
|
||||||
@param src input image
|
@param src 8-bit, single-channel, grayscale input image.
|
||||||
*/
|
*/
|
||||||
CV_WRAP virtual void detectEdges(InputArray src) = 0;
|
CV_WRAP virtual void detectEdges(InputArray src) = 0;
|
||||||
|
|
||||||
|
/** @brief returns Edge Image prepared by detectEdges() function.
|
||||||
|
|
||||||
|
@param dst returns 8-bit, single-channel output image.
|
||||||
|
*/
|
||||||
CV_WRAP virtual void getEdgeImage(OutputArray dst) = 0;
|
CV_WRAP virtual void getEdgeImage(OutputArray dst) = 0;
|
||||||
|
|
||||||
|
/** @brief returns Gradient Image prepared by detectEdges() function.
|
||||||
|
|
||||||
|
@param dst returns 16-bit, single-channel output image.
|
||||||
|
*/
|
||||||
CV_WRAP virtual void getGradientImage(OutputArray dst) = 0;
|
CV_WRAP virtual void getGradientImage(OutputArray dst) = 0;
|
||||||
|
|
||||||
|
/** @brief returns Edge Segments prepared by detectEdges() function.
|
||||||
|
*/
|
||||||
CV_WRAP virtual std::vector<std::vector<Point> > getSegments() = 0;
|
CV_WRAP virtual std::vector<std::vector<Point> > getSegments() = 0;
|
||||||
|
|
||||||
/** @brief Detects lines.
|
/** @brief Detects lines.
|
||||||
|
|
||||||
@param lines output Vec<4f> contains start point and end point of detected lines.
|
@param lines output Vec<4f> contains the start point and the end point of detected lines.
|
||||||
@note you should call detectEdges() method before call this.
|
@note you should call detectEdges() before calling this function.
|
||||||
*/
|
*/
|
||||||
CV_WRAP virtual void detectLines(OutputArray lines) = 0;
|
CV_WRAP virtual void detectLines(OutputArray lines) = 0;
|
||||||
|
|
||||||
/** @brief Detects circles and ellipses.
|
/** @brief Detects circles and ellipses.
|
||||||
|
|
||||||
@param ellipses output Vec<6d> contains center point and perimeter for circles.
|
@param ellipses output Vec<6d> contains center point and perimeter for circles, center point, axes and angle for ellipses.
|
||||||
@note you should call detectEdges() method before call this.
|
@note you should call detectEdges() before calling this function.
|
||||||
*/
|
*/
|
||||||
CV_WRAP virtual void detectEllipses(OutputArray ellipses) = 0;
|
CV_WRAP virtual void detectEllipses(OutputArray ellipses) = 0;
|
||||||
|
|
||||||
@@ -87,7 +110,8 @@ public:
|
|||||||
|
|
||||||
/** @brief sets parameters.
|
/** @brief sets parameters.
|
||||||
|
|
||||||
this function is meant to be used for parameter setting in other languages than c++.
|
this function is meant to be used for parameter setting in other languages than c++ like python.
|
||||||
|
@param parameters
|
||||||
*/
|
*/
|
||||||
CV_WRAP void setParams(const EdgeDrawing::Params& parameters);
|
CV_WRAP void setParams(const EdgeDrawing::Params& parameters);
|
||||||
virtual ~EdgeDrawing() { }
|
virtual ~EdgeDrawing() { }
|
||||||
|
@@ -112,6 +112,7 @@ public:
|
|||||||
void detectLines(OutputArray lines) CV_OVERRIDE;
|
void detectLines(OutputArray lines) CV_OVERRIDE;
|
||||||
void detectEllipses(OutputArray ellipses) CV_OVERRIDE;
|
void detectEllipses(OutputArray ellipses) CV_OVERRIDE;
|
||||||
|
|
||||||
|
virtual String getDefaultName() const CV_OVERRIDE;
|
||||||
virtual void read(const FileNode& fn) CV_OVERRIDE;
|
virtual void read(const FileNode& fn) CV_OVERRIDE;
|
||||||
virtual void write(FileStorage& fs) const CV_OVERRIDE;
|
virtual void write(FileStorage& fs) const CV_OVERRIDE;
|
||||||
|
|
||||||
@@ -315,6 +316,11 @@ void EdgeDrawing::Params::write(cv::FileStorage& fs) const
|
|||||||
fs << "MaxErrorThreshold" << MaxErrorThreshold;
|
fs << "MaxErrorThreshold" << MaxErrorThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String EdgeDrawingImpl::getDefaultName() const
|
||||||
|
{
|
||||||
|
return String("EdgeDrawing");
|
||||||
|
}
|
||||||
|
|
||||||
void EdgeDrawingImpl::read(const cv::FileNode& fn)
|
void EdgeDrawingImpl::read(const cv::FileNode& fn)
|
||||||
{
|
{
|
||||||
params.read(fn);
|
params.read(fn);
|
||||||
@@ -343,6 +349,7 @@ EdgeDrawingImpl::~EdgeDrawingImpl()
|
|||||||
|
|
||||||
void EdgeDrawingImpl::detectEdges(InputArray src)
|
void EdgeDrawingImpl::detectEdges(InputArray src)
|
||||||
{
|
{
|
||||||
|
CV_Assert(!src.empty() && src.type() == CV_8UC1);
|
||||||
gradThresh = params.GradientThresholdValue;
|
gradThresh = params.GradientThresholdValue;
|
||||||
anchorThresh = params.AnchorThresholdValue;
|
anchorThresh = params.AnchorThresholdValue;
|
||||||
op = params.EdgeDetectionOperator;
|
op = params.EdgeDetectionOperator;
|
||||||
|
Reference in New Issue
Block a user