Skip to content

Commit

Permalink
[FIX] Fix OpenCV automatic Canny threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
LAGNEAU Romain committed Oct 30, 2024
1 parent 1843fcb commit cc3881e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/core/src/image/vpImageFilter_canny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ float vpImageFilter::computeCannyThreshold(const cv::Mat &cv_I, const cv::Mat *p
const float &lowerThresholdRatio, const float &upperThresholdRatio,
const vpImageFilter::vpCannyFilteringAndGradientType &filteringType)
{
if ((lowerThresholdRatio <= 0.f) || (lowerThresholdRatio >= 1.f)) {
std::stringstream errMsg;
errMsg << "Lower ratio (" << lowerThresholdRatio << ") " << (lowerThresholdRatio < 0.f ? "should be greater than 0 !" : "should be lower than 1 !");
throw(vpException(vpException::fatalError, errMsg.str()));
}

if ((upperThresholdRatio <= 0.f) || (upperThresholdRatio >= 1.f)) {
std::stringstream errMsg;
errMsg << "Upper ratio (" << upperThresholdRatio << ") " << (upperThresholdRatio < 0.f ? "should be greater than 0 !" : "should be lower than 1 !");
throw(vpException(vpException::fatalError, errMsg.str()));
}

double w = cv_I.cols;
double h = cv_I.rows;
int bins = 256;
Expand Down

0 comments on commit cc3881e

Please sign in to comment.