From 476ee4c5be603fcb1310f364a8addf1673b738d7 Mon Sep 17 00:00:00 2001 From: Samuel Felton Date: Wed, 7 Feb 2024 15:49:21 +0100 Subject: [PATCH] fix link error with static variables of vpCircleHoughTransform --- .../visp3/imgproc/vpCircleHoughTransform.h | 4 +- .../imgproc/src/vpCircleHoughTransform.cpp | 38 ++++++++++--------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h index 42ecd57ffb..e95d14ee0a 100644 --- a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h +++ b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h @@ -1160,8 +1160,8 @@ class VISP_EXPORT vpCircleHoughTransform */ friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCircleHoughTransform &detector); - static const unsigned char edgeMapOn = 255; - static const unsigned char edgeMapOff = 0; + static const unsigned char edgeMapOn; + static const unsigned char edgeMapOff; protected: /** diff --git a/modules/imgproc/src/vpCircleHoughTransform.cpp b/modules/imgproc/src/vpCircleHoughTransform.cpp index 19ae63040a..7555905048 100644 --- a/modules/imgproc/src/vpCircleHoughTransform.cpp +++ b/modules/imgproc/src/vpCircleHoughTransform.cpp @@ -33,6 +33,10 @@ #include +// Static variables +const unsigned char vpCircleHoughTransform::edgeMapOn = 255; +const unsigned char vpCircleHoughTransform::edgeMapOff = 0; + #if (VISP_CXX_STANDARD == VISP_CXX_STANDARD_98) namespace { @@ -249,7 +253,7 @@ vpCircleHoughTransform::detect(const vpImage &I, const int &nbCir auto hasBetterProba = [](std::pair a, std::pair b) { return (a.second > b.second); - }; + }; #endif std::sort(v_id_proba.begin(), v_id_proba.end(), hasBetterProba); @@ -694,19 +698,19 @@ vpCircleHoughTransform::computeCenterCandidates() const int &offsetX, const int &offsetY, const int &nbCols, const int &nbRows, vpImage &accum, bool &hasToStop) { - if (((x - offsetX) < 0) || - ((x - offsetX) >= nbCols) || - ((y - offsetY) < 0) || - ((y - offsetY) >= nbRows) - ) { - hasToStop = true; - } - else { - float dx = (x_orig - static_cast(x)); - float dy = (y_orig - static_cast(y)); - accum[y - offsetY][x - offsetX] += std::abs(dx) + std::abs(dy); - } - }; + if (((x - offsetX) < 0) || + ((x - offsetX) >= nbCols) || + ((y - offsetY) < 0) || + ((y - offsetY) >= nbRows) + ) { + hasToStop = true; + } + else { + float dx = (x_orig - static_cast(x)); + float dy = (y_orig - static_cast(y)); + accum[y - offsetY][x - offsetX] += std::abs(dx) + std::abs(dy); + } + }; #endif updateAccumulator(x1, y1, x_low, y_low, @@ -851,8 +855,8 @@ vpCircleHoughTransform::computeCenterCandidates() #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) auto sortingCenters = [](const std::pair, float> &position_vote_a, const std::pair, float> &position_vote_b) { - return position_vote_a.second > position_vote_b.second; - }; + return position_vote_a.second > position_vote_b.second; + }; #endif std::sort(merged_peaks_position_votes.begin(), merged_peaks_position_votes.end(), sortingCenters); @@ -988,7 +992,7 @@ vpCircleHoughTransform::computeCircleCandidates() r_effective = weigthedSumRadius / votes; } return r_effective; - }; + }; #endif // Merging similar candidates