31#ifndef _vpCannyEdgeDetection_h_
32#define _vpCannyEdgeDetection_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>
46using json = nlohmann::json;
60 int m_gaussianKernelSize;
61 float m_gaussianStdev;
64 bool m_areGradientAvailable;
71 std::map<std::pair<unsigned int, unsigned int>,
float> m_edgeCandidateAndGradient;
74 float m_lowerThreshold;
75 float m_upperThreshold;
78 std::map<std::pair<unsigned int, unsigned int>, EdgeType> m_edgePointsCandidates;
88 void initGaussianFilters();
105 void performEdgeThining();
120 void performHysteresisThresholding(
const float &lowerThreshold,
const float &upperThreshold);
129 bool recursiveSearchForStrongEdge(
const std::pair<unsigned int, unsigned int> &coordinates);
137 void performEdgeTracking();
158 const float &lowerThreshold = -1.,
const float &upperThreshold = -1.);
161#ifdef VISP_HAVE_NLOHMANN_JSON
187 detector.m_gaussianKernelSize = j.value(
"gaussianSize", detector.m_gaussianKernelSize);
188 detector.m_gaussianStdev = j.value(
"gaussianStdev", detector.m_gaussianStdev);
189 detector.m_lowerThreshold = j.value(
"lowerThreshold", detector.m_lowerThreshold);
190 detector.m_upperThreshold = j.value(
"upperThreshold", detector.m_upperThreshold);
202 {
"gaussianSize", detector.m_gaussianKernelSize},
203 {
"gaussianStdev", detector.m_gaussianStdev},
204 {
"lowerThreshold", detector.m_lowerThreshold},
205 {
"upperThreshold", detector.m_upperThreshold} };
212#ifdef HAVE_OPENCV_CORE
253 m_areGradientAvailable =
true;
269 m_lowerThreshold = lowerThresh;
270 m_upperThreshold = upperThresh;
283 m_gaussianKernelSize = kernelSize;
284 m_gaussianStdev = stdev;
285 initGaussianFilters();
Implementation of a generic 2D array used as base class for matrices and vectors.
friend void to_json(json &j, const vpCannyEdgeDetection &detector)
Parse a vpCannyEdgeDetection object into JSON format.
friend void from_json(const json &j, vpCannyEdgeDetection &detector)
Read the detector configuration from JSON. All values are optional and if an argument is not present,...
void initFromJSON(const std::string &jsonPath)
Initialize all the algorithm parameters using the JSON file whose path is jsonPath....
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 setGaussianFilterParameters(const int &kernelSize, const float &stdev)
Set the Gaussian Filters kernel size and standard deviation and initialize the aforementioned filters...
vpCannyEdgeDetection()
Default constructor of the vpCannyEdgeDetection class. The thresholds used during the hysteresis thre...
Definition of the vpImage class member functions.