diff --git a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h index 7886fa53d7..0a82b9615e 100644 --- a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h +++ b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h @@ -722,8 +722,8 @@ class VISP_EXPORT vpCircleHoughTransform std::optional>>> &opt_votingPoints) const; #else void computeVotingMask(const vpImage &I, const std::vector &detections, - vpImage *mask, - std::vector>> *opt_votingPoints) const; + vpImage **mask, + std::vector>> **opt_votingPoints) const; #endif /** @name Configuration from files */ diff --git a/modules/imgproc/src/vpCircleHoughTransform.cpp b/modules/imgproc/src/vpCircleHoughTransform.cpp index a8e8cc40e1..1d86ea8f35 100644 --- a/modules/imgproc/src/vpCircleHoughTransform.cpp +++ b/modules/imgproc/src/vpCircleHoughTransform.cpp @@ -308,7 +308,7 @@ void vpCircleHoughTransform::computeVotingMask(const vpImage &I, std::optional< vpImage > &mask, std::optional>>> &opt_votingPoints) const #else void vpCircleHoughTransform::computeVotingMask(const vpImage &I, const std::vector &detections, - vpImage *mask, std::vector>> *opt_votingPoints) const + vpImage **mask, std::vector > > **opt_votingPoints) const #endif { if (!m_algoParams.m_recordVotingPoints) { @@ -317,11 +317,11 @@ void vpCircleHoughTransform::computeVotingMask(const vpImage &I, mask = std::nullopt; opt_votingPoints = std::nullopt; #elif (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) - mask = nullptr; - opt_votingPoints = nullptr; + *mask = nullptr; + *opt_votingPoints = nullptr; #else - mask = NULL; - opt_votingPoints = NULL; + *mask = NULL; + *opt_votingPoints = NULL; #endif return; } @@ -330,28 +330,45 @@ void vpCircleHoughTransform::computeVotingMask(const vpImage &I, mask = vpImage(I.getHeight(), I.getWidth(), false); opt_votingPoints = std::vector>>(); #else - mask = new vpImage(I.getHeight(), I.getWidth(), false); - opt_votingPoints = new std::vector>>(); + *mask = new vpImage(I.getHeight(), I.getWidth(), false); + *opt_votingPoints = new std::vector > >(); #endif - const unsigned int nbDetections = detections.size(); - for (unsigned int i = 0; i < nbDetections; ++i) { - const vpImageCircle &detection = detections[i]; +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + for (const auto &detection : detections) +#else + const size_t nbDetections = detections.size(); + for (size_t i = 0; i < nbDetections; ++i) +#endif + { bool hasFoundSimilarCircle = false; unsigned int nbPreviouslyDetected = m_finalCircles.size(); unsigned int id = 0; // Looking for a circle that was detected and is similar to the one given to the function while ((id < nbPreviouslyDetected) && (!hasFoundSimilarCircle)) { vpImageCircle previouslyDetected = m_finalCircles[id]; - if (previouslyDetected == detection) { +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + if (previouslyDetected == detection) +#else + if (previouslyDetected == detections[i]) +#endif + { hasFoundSimilarCircle = true; // We found a circle that is similar to the one given to the function => updating the mask const unsigned int nbVotingPoints = m_finalCirclesVotingPoints[id].size(); for (unsigned int idPoint = 0; idPoint < nbVotingPoints; ++idPoint) { const std::pair &votingPoint = m_finalCirclesVotingPoints[id][idPoint]; +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17) (*mask)[votingPoint.first][votingPoint.second] = true; +#else + (**mask)[votingPoint.first][votingPoint.second] = true; +#endif } +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17) opt_votingPoints->push_back(m_finalCirclesVotingPoints[id]); +#else + (**opt_votingPoints).push_back(m_finalCirclesVotingPoints[id]); +#endif } ++id; } diff --git a/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp b/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp index a8e6a3b43d..0b64f3c3d0 100644 --- a/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp +++ b/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp @@ -51,11 +51,13 @@ bool run_detection(const vpImage &I_src, vpCircleHoughTransform & #elif (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) vpImage *opt_mask = nullptr; std::vector>> *opt_votingPoints = nullptr; + detector.computeVotingMask(I_src, detectedCircles, opt_mask, opt_votingPoints); // Get, if available, the voting points #else vpImage *opt_mask = NULL; std::vector>> *opt_votingPoints = NULL; + detector.computeVotingMask(I_src, detectedCircles, &opt_mask, &opt_votingPoints); // Get, if available, the voting points #endif - detector.computeVotingMask(I_src, detectedCircles, opt_mask, opt_votingPoints); // Get, if available, the voting points + #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17) if (opt_votingPoints) #elif (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)