From 22aa4d75e23d5d81e200b5221d44ad288ccb3393 Mon Sep 17 00:00:00 2001 From: Souriya Trinh Date: Sun, 22 Dec 2024 02:24:24 +0100 Subject: [PATCH 1/4] Test to see if some code use these construction-copyable / copyable functions. --- modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h | 5 +++++ .../tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h | 5 +++++ .../tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h | 5 +++++ .../tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h | 5 +++++ modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h index 0a7a318131..7172008278 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h @@ -121,6 +121,11 @@ class VISP_EXPORT vpMbtDistanceCircle // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpMbtDistanceCircle(const vpMbtDistanceCircle &) = delete; // non construction-copyable + vpMbtDistanceCircle &operator=(const vpMbtDistanceCircle &) = delete; // non copyable +#endif + public: vpMbtDistanceCircle(); virtual ~vpMbtDistanceCircle(); diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h index 5d61fd88ad..495d3f5eb8 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h @@ -136,6 +136,11 @@ class VISP_EXPORT vpMbtDistanceCylinder // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpMbtDistanceCylinder(const vpMbtDistanceCylinder &) = delete; // non construction-copyable + vpMbtDistanceCylinder &operator=(const vpMbtDistanceCylinder &) = delete; // non copyable +#endif + public: vpMbtDistanceCylinder(); virtual ~vpMbtDistanceCylinder(); diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h index 983182afc6..be54314d5f 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h @@ -129,6 +129,11 @@ class VISP_EXPORT vpMbtDistanceKltCylinder // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpMbtDistanceKltCylinder(const vpMbtDistanceKltCylinder &) = delete; // non construction-copyable + vpMbtDistanceKltCylinder &operator=(const vpMbtDistanceKltCylinder &) = delete; // non copyable +#endif + public: vpMbtDistanceKltCylinder(); virtual ~vpMbtDistanceKltCylinder(); diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h index a64e753096..3d432e3ffe 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h @@ -130,6 +130,11 @@ class VISP_EXPORT vpMbtDistanceKltPoints // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpMbtDistanceKltPoints(const vpMbtDistanceKltPoints &) = delete; // non construction-copyable + vpMbtDistanceKltPoints &operator=(const vpMbtDistanceKltPoints &) = delete; // non copyable +#endif + public: vpMbtDistanceKltPoints(); virtual ~vpMbtDistanceKltPoints(); diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h index e8c385ef7e..c618a8f342 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h @@ -130,6 +130,11 @@ class VISP_EXPORT vpMbtDistanceLine // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpMbtDistanceLine(const vpMbtDistanceLine &) = delete; // non construction-copyable + vpMbtDistanceLine &operator=(const vpMbtDistanceLine &) = delete; // non copyable +#endif + public: vpMbtDistanceLine(); virtual ~vpMbtDistanceLine(); From 956aa51acad7c770f979efd660b9062f6c3ea5e7 Mon Sep 17 00:00:00 2001 From: Souriya Trinh Date: Sun, 22 Dec 2024 22:17:00 +0100 Subject: [PATCH 2/4] Test with more classes to see if the library still builds. --- modules/core/include/visp3/core/vpMoment.h | 5 +++++ modules/core/include/visp3/core/vpMomentCommon.h | 5 +++++ modules/core/include/visp3/core/vpMutex.h | 4 ++++ modules/sensor/include/visp3/sensor/vpV4l2Grabber.h | 5 +++++ .../tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMI.h | 5 +++++ .../tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIESM.h | 5 +++++ .../include/visp3/visual_features/vpFeatureMoment.h | 5 +++++ modules/vs/include/visp3/vs/vpServo.h | 5 +++++ 8 files changed, 39 insertions(+) diff --git a/modules/core/include/visp3/core/vpMoment.h b/modules/core/include/visp3/core/vpMoment.h index 1adcadac59..26819f01a5 100644 --- a/modules/core/include/visp3/core/vpMoment.h +++ b/modules/core/include/visp3/core/vpMoment.h @@ -131,6 +131,11 @@ class VISP_EXPORT vpMoment // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpMoment(const vpMoment &) = delete; // non construction-copyable + vpMoment &operator=(const vpMoment &) = delete; // non copyable +#endif + public: vpMoment(); diff --git a/modules/core/include/visp3/core/vpMomentCommon.h b/modules/core/include/visp3/core/vpMomentCommon.h index 91b6138e4e..ada3fccf14 100644 --- a/modules/core/include/visp3/core/vpMomentCommon.h +++ b/modules/core/include/visp3/core/vpMomentCommon.h @@ -126,6 +126,11 @@ class VISP_EXPORT vpMomentCommon : public vpMomentDatabase // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpMomentCommon(const vpMomentCommon &) = delete; // non construction-copyable + vpMomentCommon &operator=(const vpMomentCommon &) = delete; // non copyable +#endif + public: vpMomentCommon(double dstSurface, const std::vector &ref, double refAlpha, double dstZ = 1.0, bool flg_sxsyfromnormalized = false); diff --git a/modules/core/include/visp3/core/vpMutex.h b/modules/core/include/visp3/core/vpMutex.h index b5f3695f31..5c29171bb7 100644 --- a/modules/core/include/visp3/core/vpMutex.h +++ b/modules/core/include/visp3/core/vpMutex.h @@ -182,6 +182,10 @@ class VP_DEPRECATED vpMutex // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpScopedLock &operator=(const vpScopedLock &) = delete; // non copyable +#endif + public: //! Constructor that locks the mutex. vpScopedLock(vpMutex &mutex) : _mutex(mutex) { _mutex.lock(); } diff --git a/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h b/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h index 155411138a..109dda0506 100644 --- a/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h +++ b/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h @@ -211,6 +211,11 @@ class VISP_EXPORT vpV4l2Grabber : public vpFrameGrabber // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpV4l2Grabber(const vpV4l2Grabber &) = delete; // non construction-copyable + vpV4l2Grabber &operator=(const vpV4l2Grabber &) = delete; // non copyable +#endif + public: vpV4l2Grabber(); VP_EXPLICIT vpV4l2Grabber(bool verbose); diff --git a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMI.h b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMI.h index 54b4783214..5cd39eb6a1 100644 --- a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMI.h +++ b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMI.h @@ -142,6 +142,11 @@ class VISP_EXPORT vpTemplateTrackerMI : public vpTemplateTracker // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpTemplateTrackerMI(const vpTemplateTrackerMI &) = delete; // non construction-copyable + vpTemplateTrackerMI &operator=(const vpTemplateTrackerMI &) = delete; // non copyable +#endif + public: //! Default constructor. vpTemplateTrackerMI() diff --git a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIESM.h b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIESM.h index 6d30fe65f6..de11022f36 100644 --- a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIESM.h +++ b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIESM.h @@ -96,6 +96,11 @@ class VISP_EXPORT vpTemplateTrackerMIESM : public vpTemplateTrackerMI // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpTemplateTrackerMIESM(const vpTemplateTrackerMIESM &) = delete; // non construction-copyable + vpTemplateTrackerMIESM &operator=(const vpTemplateTrackerMIESM &) = delete; // non copyable +#endif + public: //! Default constructor. vpTemplateTrackerMIESM() diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h index 2dfb2b1781..eb20946215 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h @@ -188,6 +188,11 @@ class VISP_EXPORT vpFeatureMoment : public vpBasicFeature // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpFeatureMoment(const vpFeatureMoment &) = delete; // non construction-copyable + vpFeatureMoment &operator=(const vpFeatureMoment &) = delete; // non copyable +#endif + public: /*! * Initializes the feature with information about the database of moment diff --git a/modules/vs/include/visp3/vs/vpServo.h b/modules/vs/include/visp3/vs/vpServo.h index b8cfc55ace..b130e04efa 100644 --- a/modules/vs/include/visp3/vs/vpServo.h +++ b/modules/vs/include/visp3/vs/vpServo.h @@ -273,6 +273,11 @@ class VISP_EXPORT vpServo // } //#endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpServo(const vpServo &) = delete; // non construction-copyable + vpServo &operator=(const vpServo &) = delete; // non copyable +#endif + public: /*! * Default constructor that initializes the following settings: From 146a70b769ace520d8fea47088c10c4ec608f78e Mon Sep 17 00:00:00 2001 From: Souriya Trinh Date: Sat, 4 Jan 2025 23:10:34 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Fix=20warnings=20detected=20with=20"-Wnon-v?= =?UTF-8?q?irtual-dtor"=20flag,=20e.g.:=20=20=20-=20"warning:=20=E2=80=98c?= =?UTF-8?q?lass=20vpImageMorphology::vpPixelOperationMax?= =?UTF-8?q?=E2=80=99=20has=20virtual=20functions=20and=20accessible=20non-?= =?UTF-8?q?virtual=20destructor=20[-Wnon-virtual-dtor]"=20=20=20-=20"warni?= =?UTF-8?q?ng:=20=E2=80=98class=20vpUKSigmaDrawerAbstract=E2=80=99=20has?= =?UTF-8?q?=20virtual=20functions=20and=20accessible=20non-virtual=20destr?= =?UTF-8?q?uctor=20[-Wnon-virtual-dtor]"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/core/include/visp3/core/vpImageMorphology.h | 4 ++++ modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/modules/core/include/visp3/core/vpImageMorphology.h b/modules/core/include/visp3/core/vpImageMorphology.h index b73848a3c9..ac992920dd 100644 --- a/modules/core/include/visp3/core/vpImageMorphology.h +++ b/modules/core/include/visp3/core/vpImageMorphology.h @@ -143,6 +143,10 @@ class VISP_EXPORT vpImageMorphology public: vpPixelOperation() { } +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + virtual ~vpPixelOperation() = default; +#endif + virtual T operator()(const T &, const T &) = 0; }; diff --git a/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h b/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h index f6313fed8d..76c225cc1f 100644 --- a/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h +++ b/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h @@ -61,6 +61,8 @@ class VISP_EXPORT vpUKSigmaDrawerAbstract inline vpUKSigmaDrawerAbstract(const unsigned int &n) : m_n(n) { } + virtual ~vpUKSigmaDrawerAbstract() = default; + /** * \brief Draw the sigma points according to the current mean and covariance of the state * of the Unscented Kalman filter. From a82c454eaf96ddcfe802c01a47a739a187f3f0f9 Mon Sep 17 00:00:00 2001 From: Souriya Trinh Date: Sun, 5 Jan 2025 23:28:53 +0100 Subject: [PATCH 4/4] Check the image size wrt. the Gaussian kernel size and throw an exception if the image dimension is too small. --- modules/core/src/image/vpImageFilter.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/core/src/image/vpImageFilter.cpp b/modules/core/src/image/vpImageFilter.cpp index 299ddcc732..cc42965c63 100644 --- a/modules/core/src/image/vpImageFilter.cpp +++ b/modules/core/src/image/vpImageFilter.cpp @@ -320,6 +320,13 @@ void vpImageFilter::gaussianBlur(const vpImage &I, vpIma void vpImageFilter::gaussianBlur(const vpImage &I, vpImage &GI, unsigned int size, double sigma, bool normalize, const vpImage *p_mask) { + if (size-1 > I.getWidth() || size-1 > I.getHeight()) { + std::ostringstream oss; + oss << "Image size (" << I.getWidth() << "x" << I.getHeight() << ") is too small for the Gaussian kernel (" + << "size=" << size << "), min size is " << (size-1); + throw vpException(vpException::dimensionError, oss.str()); + } + double *fg = new double[(size + 1) / 2]; vpImageFilter::getGaussianKernel(fg, size, sigma, normalize); vpImage GIx;