31 #ifndef VP_CANNY_EDGE_DETECTION_H
32 #define VP_CANNY_EDGE_DETECTION_H
39 #include <visp3/core/vpConfig.h>
40 #include <visp3/core/vpImage.h>
41 #include <visp3/core/vpImageFilter.h>
44 #ifdef VISP_HAVE_NLOHMANN_JSON
45 #include <nlohmann/json.hpp>
85 vpCannyEdgeDetection(
const int &gaussianKernelSize,
const float &gaussianStdev,
const unsigned int &sobelAperture,
86 const float &lowerThreshold = -1.f,
const float &upperThreshold = -1.f,
87 const float &lowerThresholdRatio = 0.6f,
const float &upperThresholdRatio = 0.8f,
91 #ifdef VISP_HAVE_NLOHMANN_JSON
106 void initFromJSON(
const std::string &jsonPath);
129 #ifdef HAVE_OPENCV_CORE
167 m_filteringAndGradientType = type;
168 initGradientFilters();
181 m_areGradientAvailable =
true;
197 m_lowerThreshold = lowerThresh;
198 m_upperThreshold = upperThresh;
215 m_lowerThresholdRatio = lowerThreshRatio;
216 m_upperThresholdRatio = upperThreshRatio;
229 m_gaussianKernelSize = kernelSize;
230 m_gaussianStdev = stdev;
231 initGaussianFilters();
241 m_gradientFilterKernelSize = apertureSize;
242 initGradientFilters();
261 typedef enum EdgeType
273 int m_gaussianKernelSize;
274 float m_gaussianStdev;
278 bool m_areGradientAvailable;
279 unsigned int m_gradientFilterKernelSize;
286 std::map<std::pair<unsigned int, unsigned int>,
float> m_edgeCandidateAndGradient;
289 float m_lowerThreshold;
291 float m_lowerThresholdRatio;
293 float m_upperThreshold;
294 float m_upperThresholdRatio;
298 std::map<std::pair<unsigned int, unsigned int>, EdgeType> m_edgePointsCandidates;
308 void initGaussianFilters();
313 void initGradientFilters();
332 void performEdgeThinning(
const float &lowerThreshold);
347 void performHysteresisThresholding(
const float &lowerThreshold,
const float &upperThreshold);
356 bool recursiveSearchForStrongEdge(
const std::pair<unsigned int, unsigned int> &coordinates);
364 void performEdgeTracking();
Class that implements the Canny's edge detector. It is possible to use a boolean mask to ignore some ...
void setFilteringAndGradientType(const vpImageFilter::vpCannyFilteringAndGradientType &type)
Set the Filtering And Gradient operators to apply to the image before the edge detection operation.
void setMask(const vpImage< bool > *p_mask)
Set a mask to ignore pixels for which the mask is false.
void setCannyThresholdsRatio(const float &lowerThreshRatio, const float &upperThreshRatio)
Set the lower and upper Canny Thresholds ratio that are used to compute them automatically....
void setGradients(const vpImage< float > &dIx, const vpImage< float > &dIy)
Set the Gradients of the image that will be processed.
void setCannyThresholds(const float &lowerThresh, const float &upperThresh)
Set the lower and upper Canny Thresholds used to qualify the edge point candidates....
void setGradientFilterAperture(const unsigned int &apertureSize)
Set the parameters of the gradient filter (Sobel or Scharr) kernel size filters.
void setGaussianFilterParameters(const int &kernelSize, const float &stdev)
Set the Gaussian Filters kernel size and standard deviation and initialize the aforementioned filters...
vpCannyFilteringAndGradientType
Canny filter and gradient operators to apply on the image before the edge detection stage.
@ CANNY_GBLUR_SOBEL_FILTERING
Apply Gaussian blur + Sobel operator on the input image.