From 796cfac9fc171769b7f051ba21806e2123d32c63 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Tue, 21 May 2024 15:25:04 +0200 Subject: [PATCH 01/64] Start introduction of visp namespace --- CMakeLists.txt | 4 + cmake/templates/VISPConfig.cmake.in | 1 + cmake/templates/vpConfig.h.in | 3 + modules/core/include/visp3/core/vpArray2D.h | 54 ++++- .../core/include/visp3/core/vpCPUFeatures.h | 14 +- .../include/visp3/core/vpCameraParameters.h | 53 ++++- .../include/visp3/core/vpCannyEdgeDetection.h | 224 +++++++++--------- modules/core/include/visp3/core/vpCircle.h | 19 +- modules/core/include/visp3/core/vpColVector.h | 89 +++++-- modules/core/include/visp3/core/vpColor.h | 27 ++- .../visp3/core/vpColorDepthConversion.h | 7 + modules/core/include/visp3/core/vpDebug.h | 28 ++- modules/core/include/visp3/core/vpDisplay.h | 50 ++-- .../include/visp3/core/vpDisplayException.h | 14 +- .../include/visp3/core/vpEigenConversion.h | 8 +- modules/core/include/visp3/core/vpEndian.h | 12 +- modules/core/include/visp3/core/vpException.h | 35 +-- .../include/visp3/core/vpExponentialMap.h | 12 +- .../include/visp3/core/vpFeatureDisplay.h | 16 +- .../include/visp3/core/vpForceTwistMatrix.h | 25 +- .../include/visp3/core/vpForwardProjection.h | 34 ++- .../core/include/visp3/core/vpFrameGrabber.h | 29 ++- .../visp3/core/vpFrameGrabberException.h | 15 +- modules/core/include/visp3/core/vpGEMM.h | 8 +- .../include/visp3/core/vpGaussianFilter.h | 15 +- modules/core/include/visp3/core/vpHistogram.h | 13 +- .../core/include/visp3/core/vpHistogramPeak.h | 14 +- .../include/visp3/core/vpHistogramValey.h | 12 +- .../include/visp3/core/vpHomogeneousMatrix.h | 52 +++- modules/core/include/visp3/core/vpImage.h | 16 +- .../core/include/visp3/core/vpImageCircle.h | 7 + .../core/include/visp3/core/vpImageConvert.h | 16 +- .../include/visp3/core/vpImageException.h | 15 +- .../core/include/visp3/core/vpImageFilter.h | 150 ++++++------ .../include/visp3/core/vpImageMorphology.h | 70 +++--- .../core/include/visp3/core/vpImagePoint.h | 14 +- .../core/include/visp3/core/vpImageTools.h | 14 +- .../core/include/visp3/core/vpIoException.h | 14 +- modules/core/include/visp3/core/vpIoTools.h | 13 +- .../core/include/visp3/core/vpJsonParsing.h | 31 ++- modules/core/include/visp3/core/vpLine.h | 15 +- modules/core/include/visp3/core/vpList.h | 14 +- modules/core/include/visp3/core/vpMath.h | 17 +- modules/core/include/visp3/core/vpMatrix.h | 46 ++-- .../include/visp3/core/vpMatrixException.h | 8 +- .../visp3/core/vpMeterPixelConversion.h | 19 +- .../core/include/visp3/core/vpMouseButton.h | 15 +- .../visp3/core/vpPixelMeterConversion.h | 16 +- modules/core/include/visp3/core/vpPlane.h | 12 +- modules/core/include/visp3/core/vpPoint.h | 16 +- modules/core/include/visp3/core/vpPolygon.h | 35 +-- .../core/include/visp3/core/vpPoseVector.h | 59 ++++- .../include/visp3/core/vpQuaternionVector.h | 21 +- modules/core/include/visp3/core/vpRGBa.h | 15 +- modules/core/include/visp3/core/vpRGBf.h | 15 +- modules/core/include/visp3/core/vpRansac.h | 13 +- modules/core/include/visp3/core/vpRect.h | 28 ++- .../core/include/visp3/core/vpRectOriented.h | 21 +- modules/core/include/visp3/core/vpRobust.h | 50 ++-- .../include/visp3/core/vpRotationMatrix.h | 14 +- .../include/visp3/core/vpRotationVector.h | 15 +- modules/core/include/visp3/core/vpRowVector.h | 14 +- .../core/include/visp3/core/vpRxyzVector.h | 15 +- .../core/include/visp3/core/vpRzyxVector.h | 19 +- .../core/include/visp3/core/vpRzyzVector.h | 18 +- modules/core/include/visp3/core/vpSphere.h | 20 +- .../core/include/visp3/core/vpSubColVector.h | 41 ++-- modules/core/include/visp3/core/vpSubMatrix.h | 44 ++-- .../core/include/visp3/core/vpSubRowVector.h | 38 +-- .../core/include/visp3/core/vpThetaUVector.h | 39 +-- modules/core/include/visp3/core/vpTime.h | 15 +- modules/core/include/visp3/core/vpTracker.h | 17 +- .../include/visp3/core/vpTrackingException.h | 16 +- .../include/visp3/core/vpTranslationVector.h | 17 +- modules/core/include/visp3/core/vpUniRand.h | 35 +-- .../visp3/core/vpVelocityTwistMatrix.h | 16 +- .../include/visp3/core/vpXmlParserCamera.h | 11 +- .../visp3/core/vpXmlParserHomogeneousMatrix.h | 11 +- .../visp3/core/vpXmlParserRectOriented.h | 11 +- .../core/src/camera/vpCameraParameters.cpp | 9 + .../src/camera/vpColorDepthConversion.cpp | 7 + .../src/camera/vpMeterPixelConversion.cpp | 7 + .../src/camera/vpPixelMeterConversion.cpp | 7 + modules/core/src/camera/vpXmlParserCamera.cpp | 8 +- modules/core/src/display/vpColor.cpp | 13 +- modules/core/src/display/vpDisplay.cpp | 19 +- modules/core/src/display/vpDisplay_impl.h | 7 + modules/core/src/display/vpDisplay_rgba.cpp | 8 +- modules/core/src/display/vpDisplay_uchar.cpp | 8 +- modules/core/src/display/vpFeatureDisplay.cpp | 7 + .../core/src/framegrabber/vpFrameGrabber.cpp | 7 + .../src/image/private/vpImageConvert_impl.h | 63 +++-- .../core/src/image/vpCannyEdgeDetection.cpp | 13 +- modules/core/src/image/vpGaussianFilter.cpp | 8 +- modules/core/src/image/vpImageCircle.cpp | 7 + modules/core/src/image/vpImageConvert.cpp | 40 ++-- modules/core/src/image/vpImageConvert_hsv.cpp | 7 + modules/core/src/image/vpImageConvert_pcl.cpp | 7 + modules/core/src/image/vpImageConvert_yuv.cpp | 7 + modules/core/src/image/vpImageFilter.cpp | 7 + modules/core/src/image/vpImagePoint.cpp | 7 + modules/core/src/image/vpImageTools.cpp | 46 ++-- modules/core/src/image/vpRGBa.cpp | 7 + modules/core/src/image/vpRGBf.cpp | 7 + modules/core/src/math/matrix/vpColVector.cpp | 7 + .../src/math/matrix/vpEigenConversion.cpp | 2 +- modules/core/src/math/matrix/vpMatrix.cpp | 17 +- .../src/math/matrix/vpMatrix_cholesky.cpp | 132 ++++++----- .../src/math/matrix/vpMatrix_covariance.cpp | 7 + modules/core/src/math/matrix/vpMatrix_lu.cpp | 7 + modules/core/src/math/matrix/vpMatrix_mul.cpp | 9 +- modules/core/src/math/matrix/vpMatrix_qr.cpp | 7 + modules/core/src/math/matrix/vpMatrix_svd.cpp | 8 + modules/core/src/math/matrix/vpRowVector.cpp | 11 +- .../core/src/math/matrix/vpSubColVector.cpp | 7 + modules/core/src/math/matrix/vpSubMatrix.cpp | 7 + .../core/src/math/matrix/vpSubRowVector.cpp | 7 + modules/core/src/math/misc/vpMath.cpp | 7 + .../src/math/random-generator/vpUniRand.cpp | 7 + modules/core/src/math/robust/vpRobust.cpp | 7 + .../math/transformation/vpExponentialMap.cpp | 7 + .../transformation/vpForceTwistMatrix.cpp | 22 +- .../transformation/vpHomogeneousMatrix.cpp | 10 + .../src/math/transformation/vpPoseVector.cpp | 11 + .../transformation/vpQuaternionVector.cpp | 7 + .../math/transformation/vpRotationMatrix.cpp | 7 + .../math/transformation/vpRotationVector.cpp | 21 +- .../src/math/transformation/vpRxyzVector.cpp | 15 +- .../src/math/transformation/vpRzyxVector.cpp | 12 +- .../src/math/transformation/vpRzyzVector.cpp | 13 +- .../math/transformation/vpThetaUVector.cpp | 7 + .../transformation/vpTranslationVector.cpp | 17 +- .../transformation/vpVelocityTwistMatrix.cpp | 19 +- .../vpXmlParserHomogeneousMatrix.cpp | 8 +- .../src/tools/cpu-features/vpCPUFeatures.cpp | 7 + modules/core/src/tools/endian/vpEndian.cpp | 13 +- .../core/src/tools/exceptions/vpException.cpp | 11 +- modules/core/src/tools/file/vpIoTools.cpp | 50 ++-- modules/core/src/tools/geometry/vpPlane.cpp | 7 + modules/core/src/tools/geometry/vpPolygon.cpp | 7 + modules/core/src/tools/geometry/vpRect.cpp | 7 + .../src/tools/geometry/vpRectOriented.cpp | 7 + .../geometry/vpXmlParserRectOriented.cpp | 8 +- .../core/src/tools/histogram/vpHistogram.cpp | 7 + .../src/tools/histogram/vpHistogramPeak.cpp | 12 +- .../src/tools/histogram/vpHistogramValey.cpp | 8 +- modules/core/src/tools/time/vpTime.cpp | 41 ++-- .../tracking/forward-projection/vpCircle.cpp | 7 + .../vpForwardProjection.cpp | 13 +- .../tracking/forward-projection/vpLine.cpp | 17 +- .../tracking/forward-projection/vpPoint.cpp | 15 +- .../tracking/forward-projection/vpSphere.cpp | 7 + modules/core/src/tracking/vpTracker.cpp | 17 +- .../visp3/detection/vpDetectorAprilTag.h | 9 + .../include/visp3/detection/vpDetectorBase.h | 9 + .../detection/src/tag/vpDetectorAprilTag.cpp | 9 + modules/detection/src/vpDetectorBase.cpp | 10 +- modules/gui/include/visp3/gui/vpD3DRenderer.h | 17 +- modules/gui/include/visp3/gui/vpDisplayD3D.h | 17 +- modules/gui/include/visp3/gui/vpDisplayGDI.h | 16 +- modules/gui/include/visp3/gui/vpDisplayGTK.h | 8 + .../gui/include/visp3/gui/vpDisplayOpenCV.h | 8 + .../gui/include/visp3/gui/vpDisplayWin32.h | 16 +- modules/gui/include/visp3/gui/vpDisplayX.h | 8 + modules/gui/include/visp3/gui/vpGDIRenderer.h | 15 +- modules/gui/include/visp3/gui/vpPlot.h | 10 + modules/gui/include/visp3/gui/vpPlotCurve.h | 9 + modules/gui/include/visp3/gui/vpPlotGraph.h | 15 +- .../include/visp3/gui/vpProjectionDisplay.h | 23 +- modules/gui/include/visp3/gui/vpWin32API.h | 9 + .../gui/include/visp3/gui/vpWin32Renderer.h | 20 +- modules/gui/include/visp3/gui/vpWin32Window.h | 13 +- modules/gui/src/display/vpDisplayGTK.cpp | 11 +- modules/gui/src/display/vpDisplayOpenCV.cpp | 11 +- modules/gui/src/display/vpDisplayX.cpp | 11 +- .../gui/src/display/windows/vpD3DRenderer.cpp | 14 +- .../gui/src/display/windows/vpDisplayD3D.cpp | 10 +- .../gui/src/display/windows/vpDisplayGDI.cpp | 11 +- .../src/display/windows/vpDisplayWin32.cpp | 12 +- .../gui/src/display/windows/vpGDIRenderer.cpp | 11 +- .../gui/src/display/windows/vpWin32API.cpp | 12 +- .../gui/src/display/windows/vpWin32Window.cpp | 11 +- .../vpProjectionDisplay.cpp | 15 +- modules/gui/src/plot/vpPlot.cpp | 11 +- modules/gui/src/plot/vpPlotCurve.cpp | 12 +- modules/gui/src/plot/vpPlotGraph.cpp | 11 +- .../visp3/imgproc/vpCircleHoughTransform.h | 10 + .../include/visp3/imgproc/vpContours.h | 44 ++-- .../imgproc/include/visp3/imgproc/vpImgproc.h | 40 ++-- modules/imgproc/src/vpCLAHE.cpp | 13 +- .../imgproc/src/vpCircleHoughTransform.cpp | 12 +- modules/imgproc/src/vpConnectedComponents.cpp | 13 +- modules/imgproc/src/vpContours.cpp | 39 +-- modules/imgproc/src/vpFloodFill.cpp | 8 +- modules/imgproc/src/vpImgproc.cpp | 80 +++---- modules/imgproc/src/vpMorph.cpp | 9 +- modules/imgproc/src/vpRetinex.cpp | 28 ++- modules/imgproc/src/vpThreshold.cpp | 13 +- modules/io/include/visp3/io/vpDiskGrabber.h | 9 + modules/io/include/visp3/io/vpImageIo.h | 10 + .../include/visp3/io/vpJsonArgumentParser.h | 77 +++--- modules/io/include/visp3/io/vpParseArgv.h | 186 ++++++++------- modules/io/include/visp3/io/vpVideoReader.h | 9 + modules/io/include/visp3/io/vpVideoWriter.h | 9 + .../io/src/image/private/vpImageIoBackend.h | 9 + .../io/src/image/private/vpImageIoLibjpeg.cpp | 9 + .../io/src/image/private/vpImageIoLibpng.cpp | 9 + .../io/src/image/private/vpImageIoOpenCV.cpp | 8 + .../src/image/private/vpImageIoPortable.cpp | 9 + .../io/src/image/private/vpImageIoSimd.cpp | 10 + modules/io/src/image/private/vpImageIoStb.cpp | 10 + .../io/src/image/private/vpImageIoTinyEXR.cpp | 9 + modules/io/src/image/vpImageIo.cpp | 4 + modules/io/src/tools/vpJsonArgumentParser.cpp | 12 +- modules/io/src/tools/vpParseArgv.cpp | 74 ++++-- modules/io/src/video/vpDiskGrabber.cpp | 9 + modules/io/src/video/vpVideoReader.cpp | 9 + modules/io/src/video/vpVideoWriter.cpp | 33 ++- .../tracker/blob/include/visp3/blob/vpDot.h | 8 + .../tracker/blob/include/visp3/blob/vpDot2.h | 45 ++-- modules/tracker/blob/src/dots/vpDot.cpp | 9 + modules/tracker/blob/src/dots/vpDot2.cpp | 9 + modules/tracker/me/include/visp3/me/vpMe.h | 64 ++--- .../tracker/me/include/visp3/me/vpMeEllipse.h | 9 + .../tracker/me/include/visp3/me/vpMeSite.h | 9 + .../tracker/me/include/visp3/me/vpMeTracker.h | 50 ++-- modules/tracker/me/src/moving-edges/vpMe.cpp | 9 + .../me/src/moving-edges/vpMeEllipse.cpp | 9 + .../tracker/me/src/moving-edges/vpMeSite.cpp | 9 + .../me/src/moving-edges/vpMeTracker.cpp | 9 + .../include/visp3/vision/vpHomography.h | 11 +- modules/vision/include/visp3/vision/vpPose.h | 19 +- .../include/visp3/vision/vpPoseException.h | 9 + .../homography-estimation/vpHomography.cpp | 9 + .../homography-estimation/vpHomographyDLT.cpp | 9 + .../vpHomographyExtract.cpp | 102 +++++--- .../vpHomographyMalis.cpp | 10 +- .../vpHomographyRansac.cpp | 9 + .../homography-estimation/vpHomographyVVS.cpp | 9 + .../private/vpLevenbergMarquartd.cpp | 9 + .../private/vpLevenbergMarquartd.h | 9 + modules/vision/src/pose-estimation/vpPose.cpp | 12 +- .../src/pose-estimation/vpPoseDementhon.cpp | 9 + .../src/pose-estimation/vpPoseLagrange.cpp | 9 + .../vision/src/pose-estimation/vpPoseLowe.cpp | 9 + .../vision/src/pose-estimation/vpPoseRGBD.cpp | 11 +- .../src/pose-estimation/vpPoseRansac.cpp | 8 + .../vpPoseVirtualVisualServoing.cpp | 9 + 248 files changed, 3488 insertions(+), 1377 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34ac969235..bb35966907 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -541,6 +541,9 @@ VP_OPTION(ENABLE_MOMENTS_COMBINE_MATRICES "" "" "Use linear combination of matr VP_OPTION(ENABLE_TEST_WITHOUT_DISPLAY "" "" "Don't use display feature when testing" "" ON) VP_OPTION(ENABLE_FULL_DOC "" "" "Build doc with internal classes that are by default not part of the doc" "" OFF) +# Allow introduction of "visp" namespace. By default disabled to keep compat with previous versions +VP_OPTION(ENABLE_VISP_NAMESPACE "" "" "Enable visp namespace" "" OFF) + if(ENABLE_SOLUTION_FOLDERS) set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets") @@ -1603,6 +1606,7 @@ status(" To be built:" VISP_MODULES_BUILD THEN ${VISP_MOD status(" Disabled:" VISP_MODULES_DISABLED_USER THEN ${VISP_MODULES_DISABLED_USER_ST} ELSE "-") status(" Disabled by dependency:" VISP_MODULES_DISABLED_AUTO THEN ${VISP_MODULES_DISABLED_AUTO_ST} ELSE "-") status(" Unavailable:" VISP_MODULES_DISABLED_FORCE THEN ${VISP_MODULES_DISABLED_FORCE_ST} ELSE "-") +status(" Enable visp namespace:" ENABLE_VISP_NAMESPACE THEN "yes" ELSE "no") # ========================== Android details ========================== if(ANDROID) diff --git a/cmake/templates/VISPConfig.cmake.in b/cmake/templates/VISPConfig.cmake.in index b51ca8afa2..23c27cebe5 100644 --- a/cmake/templates/VISPConfig.cmake.in +++ b/cmake/templates/VISPConfig.cmake.in @@ -189,6 +189,7 @@ set(VISP_BIN_INSTALL_PATH "@VISP_BIN_INSTALL_PATH@") #---------------------------------------------------------------------- # Remember VISP third party libs configuration #---------------------------------------------------------------------- +set(ENABLE_VISP_NAMESPACE "@ENABLE_VISP_NAMESPACE@") set(VISP_HAVE_AFMA4 "@VISP_HAVE_AFMA4@") set(VISP_HAVE_AFMA6 "@VISP_HAVE_AFMA6@") set(VISP_HAVE_APRILTAG "@VISP_HAVE_APRILTAG@") diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index fcfc2df44d..2bdcb71606 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -112,6 +112,9 @@ VISP_VERSION_MINOR, \ VISP_VERSION_PATCH) +// Defined if the user wants to protect the classes in a dedicated visp namespace +#cmakedefine ENABLE_VISP_NAMESPACE + // Enable debug and trace printings #cmakedefine VP_TRACE #cmakedefine VP_DEBUG diff --git a/modules/core/include/visp3/core/vpArray2D.h b/modules/core/include/visp3/core/vpArray2D.h index d466f451b6..ca5342de7d 100644 --- a/modules/core/include/visp3/core/vpArray2D.h +++ b/modules/core/include/visp3/core/vpArray2D.h @@ -46,8 +46,23 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +template class vpArray2D; +} +#endif + #ifdef VISP_HAVE_NLOHMANN_JSON #include +#if defined(ENABLE_VISP_NAMESPACE) +//template +template +void from_json(const nlohmann::json &j, visp::vpArray2D &array); +//template +template +void to_json(nlohmann::json &j, const visp::vpArray2D &array); +#endif #endif /*! @@ -122,7 +137,11 @@ * } * \endcode */ -template class vpArray2D +template class +#if defined(ENABLE_VISP_NAMESPACE) +visp:: +#endif +vpArray2D { protected: //! Number of rows in the array @@ -1018,10 +1037,10 @@ template class vpArray2D #ifdef VISP_HAVE_NLOHMANN_JSON //template template - friend void from_json(const nlohmann::json &j, vpArray2D &array); + friend void ::from_json(const nlohmann::json &j, vpArray2D &array); //template template - friend void to_json(nlohmann::json &j, const vpArray2D &array); + friend void ::to_json(nlohmann::json &j, const vpArray2D &array); #endif /*! @@ -1082,6 +1101,11 @@ template class vpArray2D //@} }; +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! Return the array min value. */ @@ -1323,13 +1347,23 @@ template <> inline bool vpArray2D::operator==(const vpArray2D &A) * \relates vpArray2D */ template bool vpArray2D::operator!=(const vpArray2D &A) const { return !(*this == A); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #ifdef VISP_HAVE_NLOHMANN_JSON - - template -inline void from_json(const nlohmann::json &j, vpArray2D &array) +inline void from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +visp::vpArray2D &array +#else +vpArray2D &array +#endif +) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace visp; +#endif if (j.is_array()) { const unsigned int nrows = static_cast(j.size()); if (nrows == 0) { // Initialize an empty array, Finished @@ -1381,7 +1415,13 @@ inline void from_json(const nlohmann::json &j, vpArray2D &array) template -inline void to_json(nlohmann::json &j, const vpArray2D &array) +inline void to_json(nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +const visp::vpArray2D &array +#else +const vpArray2D &array +#endif +) { j = { {"cols", array.colNum}, diff --git a/modules/core/include/visp3/core/vpCPUFeatures.h b/modules/core/include/visp3/core/vpCPUFeatures.h index 53878cf6b4..1decf4e2df 100644 --- a/modules/core/include/visp3/core/vpCPUFeatures.h +++ b/modules/core/include/visp3/core/vpCPUFeatures.h @@ -31,16 +31,20 @@ * CPU features (hardware capabilities). */ -#ifndef _vpCPUFeatures_h_ -#define _vpCPUFeatures_h_ - /*! \file vpCPUFeatures.h \brief Check CPU features (hardware capabilities). */ +#ifndef _vpCPUFeatures_h_ +#define _vpCPUFeatures_h_ + #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \ingroup group_core_cpu_features \brief Check CPU features (hardware capabilities). @@ -77,5 +81,7 @@ VISP_EXPORT size_t getCPUCacheL3(); #endif VISP_EXPORT void printCPUInfo(); } // namespace vpCPUFeatures - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpCameraParameters.h b/modules/core/include/visp3/core/vpCameraParameters.h index 1a9f2b283d..649a4567f3 100644 --- a/modules/core/include/visp3/core/vpCameraParameters.h +++ b/modules/core/include/visp3/core/vpCameraParameters.h @@ -48,8 +48,19 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +class vpCameraParameters; +} +#endif + #ifdef VISP_HAVE_NLOHMANN_JSON #include +#if defined(ENABLE_VISP_NAMESPACE) +void to_json(nlohmann::json &j, const visp::vpCameraParameters &cam); +void from_json(const nlohmann::json &j, visp::vpCameraParameters &cam); +#endif #endif /*! @@ -300,7 +311,12 @@ {"model":"perspectiveWithoutDistortion","px":801.0,"py":802.0,"u0":325.0,"v0":245.0} \endcode */ -class VISP_EXPORT vpCameraParameters + +class VISP_EXPORT +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpCameraParameters { friend class vpMeterPixelConversion; friend class vpPixelMeterConversion; @@ -442,18 +458,26 @@ class VISP_EXPORT vpCameraParameters vpCameraParametersProjType m_projModel; //!< used projection model #ifdef VISP_HAVE_NLOHMANN_JSON - friend void to_json(nlohmann::json &j, const vpCameraParameters &cam); - friend void from_json(const nlohmann::json &j, vpCameraParameters &cam); + friend void ::to_json(nlohmann::json &j, const vpCameraParameters &cam); + friend void ::from_json(const nlohmann::json &j, vpCameraParameters &cam); #endif }; #ifdef VISP_HAVE_NLOHMANN_JSON #include +#if defined(ENABLE_VISP_NAMESPACE) +NLOHMANN_JSON_SERIALIZE_ENUM(visp::vpCameraParameters::vpCameraParametersProjType, { + {visp::vpCameraParameters::perspectiveProjWithoutDistortion, "perspectiveWithoutDistortion"}, + {visp::vpCameraParameters::perspectiveProjWithDistortion, "perspectiveWithDistortion"}, + {visp::vpCameraParameters::ProjWithKannalaBrandtDistortion, "kannalaBrandtDistortion"} + }); +#else NLOHMANN_JSON_SERIALIZE_ENUM(vpCameraParameters::vpCameraParametersProjType, { {vpCameraParameters::perspectiveProjWithoutDistortion, "perspectiveWithoutDistortion"}, {vpCameraParameters::perspectiveProjWithDistortion, "perspectiveWithDistortion"}, {vpCameraParameters::ProjWithKannalaBrandtDistortion, "kannalaBrandtDistortion"} }); +#endif /** * \brief Converts camera parameters into a JSON representation. @@ -461,8 +485,17 @@ NLOHMANN_JSON_SERIALIZE_ENUM(vpCameraParameters::vpCameraParametersProjType, { * \param j The resulting JSON object. * \param cam The camera to serialize. */ -inline void to_json(nlohmann::json &j, const vpCameraParameters &cam) +inline void to_json(nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +const visp::vpCameraParameters &cam +#else +const vpCameraParameters &cam +#endif +) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace visp; +#endif j["px"] = cam.m_px; j["py"] = cam.m_py; j["u0"] = cam.m_u0; @@ -514,8 +547,17 @@ inline void to_json(nlohmann::json &j, const vpCameraParameters &cam) * \param j The json object to deserialize. * \param cam The modified camera. */ -inline void from_json(const nlohmann::json &j, vpCameraParameters &cam) +inline void from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +visp::vpCameraParameters &cam +#else +vpCameraParameters &cam +#endif +) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace visp; +#endif const double px = j.at("px").get(); const double py = j.at("py").get(); const double u0 = j.at("u0").get(); @@ -544,5 +586,4 @@ inline void from_json(const nlohmann::json &j, vpCameraParameters &cam) } } #endif - #endif diff --git a/modules/core/include/visp3/core/vpCannyEdgeDetection.h b/modules/core/include/visp3/core/vpCannyEdgeDetection.h index c9f7228fc4..2f319d770c 100644 --- a/modules/core/include/visp3/core/vpCannyEdgeDetection.h +++ b/modules/core/include/visp3/core/vpCannyEdgeDetection.h @@ -45,114 +45,17 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif +/** + * \brief Class that implements the Canny's edge detector. + * It is possible to use a boolean mask to ignore some pixels of + * the input gray-scale image. + */ class VISP_EXPORT vpCannyEdgeDetection { -private: - typedef enum EdgeType - { - STRONG_EDGE, /*!< This pixel exceeds the upper threshold of the double hysteresis phase, it is thus for sure an edge point.*/ - WEAK_EDGE,/*!< This pixel is between the lower and upper threshold of the double hysteresis phase, it is an edge point only if it is linked at some point to an edge point.*/ - ON_CHECK /*!< This pixel is currently tested to know if it is linked to a strong edge point.*/ - } EdgeType; - - // Filtering + gradient methods choice - vpImageFilter::vpCannyFilteringAndGradientType m_filteringAndGradientType; /*!< Choice of the filter and - gradient operator to apply before the edge detection step*/ - - // // Gaussian smoothing attributes - int m_gaussianKernelSize; /*!< Size of the Gaussian filter kernel used to smooth the input image. Must be an odd number.*/ - float m_gaussianStdev; /*!< Standard deviation of the Gaussian filter.*/ - vpArray2D m_fg; /*!< Array that contains the Gaussian kernel.*/ - - // // Gradient computation attributes - bool m_areGradientAvailable; /*!< Set to true if the user provides the gradient images, false otherwise. In the latter case, the class will compute the gradients.*/ - unsigned int m_gradientFilterKernelSize; /*!< The size of the Sobel kernels used to compute the gradients of the image.*/ - vpArray2D m_gradientFilterX; /*!< Array that contains the gradient filter kernel (Sobel or Scharr) along the X-axis.*/ - vpArray2D m_gradientFilterY; /*!< Array that contains the gradient filter kernel (Sobel or Scharr) along the Y-axis.*/ - vpImage m_dIx; /*!< X-axis gradient.*/ - vpImage m_dIy; /*!< Y-axis gradient.*/ - - // // Edge thining attributes - std::map, float> m_edgeCandidateAndGradient; /*!< Map that contains point image coordinates and corresponding gradient value.*/ - - // // Hysteresis thresholding attributes - float m_lowerThreshold; /*!< Lower threshold for the hysteresis step. If negative, it will be deduced - as from m_upperThreshold. */ - float m_lowerThresholdRatio; /*!< If the thresholds must be computed, the ratio of the upper threshold the lower - threshold is equal: m_lowerThreshold = m_lowerThresholdRatio * m_upperThreshold. */ - float m_upperThreshold; /*!< Upper threshold for the hysteresis step.*/ - float m_upperThresholdRatio; /*!< If the thresholds must be computed, the ratio of pixels of the gradient image that - must be lower than the upper threshold \b m_upperThreshold.*/ - - // // Edge tracking attributes - std::map, EdgeType> m_edgePointsCandidates; /*!< Map that contains the strong edge points, i.e. the points for which we know for sure they are edge points, - and the weak edge points, i.e. the points for which we still must determine if they are actual edge points.*/ - vpImage m_edgeMap; /*!< Final edge map that results from the whole Canny algorithm.*/ - const vpImage *mp_mask; /*!< Mask that permits to consider only the pixels for which the mask is true.*/ - - /** @name Constructors and initialization */ - //@{ - /** - * \brief Initialize the Gaussian filters used to filter the input image. - */ - void initGaussianFilters(); - - /** - * \brief Initialize the gradient filters (Sobel or Scharr) used to compute the input image gradients. - */ - void initGradientFilters(); - //@} - - /** @name Different steps methods */ - /** - * \brief Step 1: filtering + Step 2: gradient computation - * \details First, perform Gaussian blur to the input image. - * Then, compute the x-axis and y-axis gradients of the image. - * \param[in] I : The image we want to compute the gradients. - */ - void computeFilteringAndGradient(const vpImage &I); - - /** - * \brief Step 3: Edge thining. - * \details Perform the edge thining step. - * Perform a non-maximum suppression to keep only local maxima as edge candidates. - * \param[in] lowerThreshold Edge candidates that are below this threshold are definitely not - * edges. - */ - void performEdgeThinning(const float &lowerThreshold); - - /** - * \brief Perform hysteresis thresholding. - * \details Edge candidates that are greater than \b m_upperThreshold are saved in \b m_strongEdgePoints - * and will be kept in the final edge map. - * Edge candidates that are between \b m_lowerThreshold and \b m_upperThreshold are saved in - * \b m_weakEdgePoints and will be kept in the final edge map only if they are connected - * to a strong edge point. - * Edge candidates that are below \b m_lowerThreshold are discarded. - * \param[in] lowerThreshold Edge candidates that are below this threshold are definitely not - * edges. - * \param[in] upperThreshold Edge candidates that are greater than this threshold are classified - * as strong edges. - */ - void performHysteresisThresholding(const float &lowerThreshold, const float &upperThreshold); - - /** - * \brief Search recursively for a strong edge in the neighborhood of a weak edge. - * - * \param[in] coordinates : The coordinates we are checking. - * \return true We found a strong edge point in its 8-connected neighborhood. - * \return false We did not found a strong edge point in its 8-connected neighborhood. - */ - bool recursiveSearchForStrongEdge(const std::pair &coordinates); - - /** - * \brief Perform edge tracking. - * \details For each weak edge, we will recursively check if they are 8-connected to a strong edge point. - * If so, the weak edge will be saved in \b m_strongEdgePoints and will be kept in the final edge map. - * Otherwise, the edge point will be discarded. - */ - void performEdgeTracking(); - //@} public: /** @name Constructors and initialization */ @@ -382,5 +285,114 @@ class VISP_EXPORT vpCannyEdgeDetection mp_mask = p_mask; } //@} +private: + typedef enum EdgeType + { + STRONG_EDGE, /*!< This pixel exceeds the upper threshold of the double hysteresis phase, it is thus for sure an edge point.*/ + WEAK_EDGE,/*!< This pixel is between the lower and upper threshold of the double hysteresis phase, it is an edge point only if it is linked at some point to an edge point.*/ + ON_CHECK /*!< This pixel is currently tested to know if it is linked to a strong edge point.*/ + } EdgeType; + + // Filtering + gradient methods choice + vpImageFilter::vpCannyFilteringAndGradientType m_filteringAndGradientType; /*!< Choice of the filter and + gradient operator to apply before the edge detection step*/ + + // // Gaussian smoothing attributes + int m_gaussianKernelSize; /*!< Size of the Gaussian filter kernel used to smooth the input image. Must be an odd number.*/ + float m_gaussianStdev; /*!< Standard deviation of the Gaussian filter.*/ + vpArray2D m_fg; /*!< Array that contains the Gaussian kernel.*/ + + // // Gradient computation attributes + bool m_areGradientAvailable; /*!< Set to true if the user provides the gradient images, false otherwise. In the latter case, the class will compute the gradients.*/ + unsigned int m_gradientFilterKernelSize; /*!< The size of the Sobel kernels used to compute the gradients of the image.*/ + vpArray2D m_gradientFilterX; /*!< Array that contains the gradient filter kernel (Sobel or Scharr) along the X-axis.*/ + vpArray2D m_gradientFilterY; /*!< Array that contains the gradient filter kernel (Sobel or Scharr) along the Y-axis.*/ + vpImage m_dIx; /*!< X-axis gradient.*/ + vpImage m_dIy; /*!< Y-axis gradient.*/ + + // // Edge thining attributes + std::map, float> m_edgeCandidateAndGradient; /*!< Map that contains point image coordinates and corresponding gradient value.*/ + + // // Hysteresis thresholding attributes + float m_lowerThreshold; /*!< Lower threshold for the hysteresis step. If negative, it will be deduced + as from m_upperThreshold. */ + float m_lowerThresholdRatio; /*!< If the thresholds must be computed, the ratio of the upper threshold the lower + threshold is equal: m_lowerThreshold = m_lowerThresholdRatio * m_upperThreshold. */ + float m_upperThreshold; /*!< Upper threshold for the hysteresis step.*/ + float m_upperThresholdRatio; /*!< If the thresholds must be computed, the ratio of pixels of the gradient image that + must be lower than the upper threshold \b m_upperThreshold.*/ + + // // Edge tracking attributes + std::map, EdgeType> m_edgePointsCandidates; /*!< Map that contains the strong edge points, i.e. the points for which we know for sure they are edge points, + and the weak edge points, i.e. the points for which we still must determine if they are actual edge points.*/ + vpImage m_edgeMap; /*!< Final edge map that results from the whole Canny algorithm.*/ + const vpImage *mp_mask; /*!< Mask that permits to consider only the pixels for which the mask is true.*/ + + /** @name Constructors and initialization */ + //@{ + /** + * \brief Initialize the Gaussian filters used to filter the input image. + */ + void initGaussianFilters(); + + /** + * \brief Initialize the gradient filters (Sobel or Scharr) used to compute the input image gradients. + */ + void initGradientFilters(); + //@} + + /** @name Different steps methods */ + /** + * \brief Step 1: filtering + Step 2: gradient computation + * \details First, perform Gaussian blur to the input image. + * Then, compute the x-axis and y-axis gradients of the image. + * \param[in] I : The image we want to compute the gradients. + */ + void computeFilteringAndGradient(const vpImage &I); + + /** + * \brief Step 3: Edge thining. + * \details Perform the edge thining step. + * Perform a non-maximum suppression to keep only local maxima as edge candidates. + * \param[in] lowerThreshold Edge candidates that are below this threshold are definitely not + * edges. + */ + void performEdgeThinning(const float &lowerThreshold); + + /** + * \brief Perform hysteresis thresholding. + * \details Edge candidates that are greater than \b m_upperThreshold are saved in \b m_strongEdgePoints + * and will be kept in the final edge map. + * Edge candidates that are between \b m_lowerThreshold and \b m_upperThreshold are saved in + * \b m_weakEdgePoints and will be kept in the final edge map only if they are connected + * to a strong edge point. + * Edge candidates that are below \b m_lowerThreshold are discarded. + * \param[in] lowerThreshold Edge candidates that are below this threshold are definitely not + * edges. + * \param[in] upperThreshold Edge candidates that are greater than this threshold are classified + * as strong edges. + */ + void performHysteresisThresholding(const float &lowerThreshold, const float &upperThreshold); + + /** + * \brief Search recursively for a strong edge in the neighborhood of a weak edge. + * + * \param[in] coordinates : The coordinates we are checking. + * \return true We found a strong edge point in its 8-connected neighborhood. + * \return false We did not found a strong edge point in its 8-connected neighborhood. + */ + bool recursiveSearchForStrongEdge(const std::pair &coordinates); + + /** + * \brief Perform edge tracking. + * \details For each weak edge, we will recursively check if they are 8-connected to a strong edge point. + * If so, the weak edge will be saved in \b m_strongEdgePoints and will be kept in the final edge map. + * Otherwise, the edge point will be discarded. + */ + void performEdgeTracking(); + //@} }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpCircle.h b/modules/core/include/visp3/core/vpCircle.h index 5e76dded5f..eb382d9cd2 100644 --- a/modules/core/include/visp3/core/vpCircle.h +++ b/modules/core/include/visp3/core/vpCircle.h @@ -36,15 +36,20 @@ \brief class that defines what is a circle */ -#ifndef vpCircle_hh -#define vpCircle_hh +#ifndef _vpCircle_h_ +#define _vpCircle_h_ #include +#include #include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpCircle * \ingroup group_core_geometry @@ -133,9 +138,6 @@ class VISP_EXPORT vpCircle : public vpForwardProjection static void computeIntersectionPoint(const vpCircle &circle, const vpCameraParameters &cam, const double &rho, const double &theta, double &i, double &j); -protected: - void init() vp_override; - public: #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) /*! @@ -165,6 +167,11 @@ class VISP_EXPORT vpCircle : public vpForwardProjection vp_deprecated double get_mu02() const { return p[4]; } //@} #endif -}; +protected: + void init() vp_override; +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpColVector.h b/modules/core/include/visp3/core/vpColVector.h index 18906e6522..6156651646 100644 --- a/modules/core/include/visp3/core/vpColVector.h +++ b/modules/core/include/visp3/core/vpColVector.h @@ -31,26 +31,49 @@ * Provide some simple operation on column vectors. */ +/*! + * \file vpColVector.h + * \brief definition of column vector class as well + * as a set of operations on these vector + */ + #ifndef _vpColVector_h_ #define _vpColVector_h_ -#include -#include -#include -#include -#include +#include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +class vpColVector; +} +#endif + +#ifdef VISP_HAVE_NLOHMANN_JSON +#include +#if defined(ENABLE_VISP_NAMESPACE) +void to_json(nlohmann::json &j, const visp::vpColVector &pose); +void from_json(const nlohmann::json &j, visp::vpColVector &pose); +#endif +#endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif class vpMatrix; class vpRowVector; class vpRotationVector; class vpTranslationVector; class vpPoseVector; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif -/*! - * \file vpColVector.h - * \brief definition of column vector class as well - * as a set of operations on these vector - */ +#include +#include +#include +#include +#include /*! * \class vpColVector @@ -159,7 +182,11 @@ class vpPoseVector; * {"cols":1,"data":[1.0,2.0,3.0,4.0],"rows":4,"type":"vpColVector"} * \endcode */ -class VISP_EXPORT vpColVector : public vpArray2D +class VISP_EXPORT +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif +vpColVector: public vpArray2D { friend class vpMatrix; @@ -270,7 +297,9 @@ class VISP_EXPORT vpColVector : public vpArray2D free(rowPtrs); rowPtrs = nullptr; } - rowNum = colNum = dsize = 0; + rowNum = 0; + colNum = 0; + dsize = 0; } /*! @@ -1332,7 +1361,7 @@ class VISP_EXPORT vpColVector : public vpArray2D * @param j : Resulting json object. * @param v : The object to convert. */ - friend void to_json(nlohmann::json &j, const vpColVector &v); + friend void ::to_json(nlohmann::json &j, const vpColVector &v); /*! * Retrieve a vpColVector object from a JSON representation. @@ -1340,7 +1369,7 @@ class VISP_EXPORT vpColVector : public vpArray2D * @param j : JSON representation to convert. * @param v : Converted object. */ - friend void from_json(const nlohmann::json &j, vpColVector &v); + friend void ::from_json(const nlohmann::json &j, vpColVector &v); #endif #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) @@ -1446,6 +1475,10 @@ class VISP_EXPORT vpColVector : public vpArray2D #endif }; +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \relates vpColVector * Allows to multiply a scalar by a column vector. @@ -1454,24 +1487,42 @@ class VISP_EXPORT vpColVector : public vpArray2D VISP_EXPORT #endif vpColVector operator*(const double &x, const vpColVector &v); +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #ifdef VISP_HAVE_NLOHMANN_JSON -inline void to_json(nlohmann::json &j, const vpColVector &v) +inline void to_json(nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +const visp::vpColVector &v +#else +const vpColVector &v +#endif +) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace visp; +#endif const vpArray2D *asArray = (vpArray2D*) & v; to_json(j, *asArray); j["type"] = "vpColVector"; } -inline void from_json(const nlohmann::json &j, vpColVector &v) +inline void from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +visp::vpColVector &v +#else +vpColVector &v +#endif +) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace visp; +#endif vpArray2D *asArray = (vpArray2D*) & v; from_json(j, *asArray); if (v.getCols() != 1) { throw vpException(vpException::badValue, "From JSON, tried to read a 2D array into a vpColVector"); } } - - #endif - #endif diff --git a/modules/core/include/visp3/core/vpColor.h b/modules/core/include/visp3/core/vpColor.h index 509a736aa8..2f135449df 100644 --- a/modules/core/include/visp3/core/vpColor.h +++ b/modules/core/include/visp3/core/vpColor.h @@ -37,6 +37,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpColor @@ -152,7 +156,8 @@ class VISP_EXPORT vpColor : public vpRGBa { public: /*! Predefined colors identifier. */ - typedef enum { + typedef enum + { id_black = 0, /*!< Identifier associated to the predefined vpColor::black color. */ id_white, /*!< Identifier associated to the predefined vpColor::white @@ -232,7 +237,7 @@ class VISP_EXPORT vpColor : public vpRGBa that this color is not a predefined one. */ - inline vpColor() : vpRGBa(), id(id_unknown) {} + inline vpColor() : vpRGBa(), id(id_unknown) { } /*! Construct a color from its RGB values. @@ -246,8 +251,7 @@ class VISP_EXPORT vpColor : public vpRGBa inline vpColor(unsigned char r, unsigned char g, unsigned char b, vpColor::vpColorIdentifier cid = vpColor::id_unknown) : vpRGBa(r, g, b), id(cid) - { - } + { } /*! Construct a color from its RGB values and alpha channel. @@ -262,18 +266,17 @@ class VISP_EXPORT vpColor : public vpRGBa inline vpColor(unsigned char r, unsigned char g, unsigned char b, unsigned char alpha, vpColor::vpColorIdentifier cid = vpColor::id_unknown) : vpRGBa(r, g, b, alpha), id(cid) - { - } + { } /*! Construct a color with an alpha channel. \param color : RGB color. \param alpha : Alpha channel for transparency. */ - inline vpColor(const vpColor &color, unsigned char alpha) : vpRGBa(color.R, color.G, color.B, alpha), id(color.id) {} + inline vpColor(const vpColor &color, unsigned char alpha) : vpRGBa(color.R, color.G, color.B, alpha), id(color.id) { } /*! Default destructor. */ - inline virtual ~vpColor() {} + inline virtual ~vpColor() { } friend VISP_EXPORT bool operator==(const vpColor &c1, const vpColor &c2); friend VISP_EXPORT bool operator!=(const vpColor &c1, const vpColor &c2); @@ -367,7 +370,7 @@ vpColor const __declspec(selectany) vpColor::none = vpColor(0, 0, 0, id_unknown) const __declspec(selectany) unsigned int vpColor::nbColors = 18; /*!< Array of available colors. */ -vpColor const __declspec(selectany) vpColor::allColors[vpColor::nbColors] = {vpColor::blue, // 12 +vpColor const __declspec(selectany) vpColor::allColors[vpColor::nbColors] = { vpColor::blue, // 12 vpColor::green, // 9 vpColor::red, // 6 vpColor::cyan, // 15 @@ -384,8 +387,10 @@ vpColor const __declspec(selectany) vpColor::allColors[vpColor::nbColors] = {vpC vpColor::gray, // 3 vpColor::darkGray, // 4 vpColor::black, // 0 - vpColor::white}; // 17 + vpColor::white }; // 17 #endif - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpColorDepthConversion.h b/modules/core/include/visp3/core/vpColorDepthConversion.h index 5b34e0739d..7a5c591528 100644 --- a/modules/core/include/visp3/core/vpColorDepthConversion.h +++ b/modules/core/include/visp3/core/vpColorDepthConversion.h @@ -39,6 +39,10 @@ #include "vpCameraParameters.h" #include "vpImage.h" +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif class VISP_EXPORT vpColorDepthConversion { public: @@ -54,3 +58,6 @@ class VISP_EXPORT vpColorDepthConversion const vpHomogeneousMatrix &color_M_depth, const vpHomogeneousMatrix &depth_M_color, const vpImagePoint &from_pixel); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/include/visp3/core/vpDebug.h b/modules/core/include/visp3/core/vpDebug.h index a9329f5be6..81f648a4a8 100644 --- a/modules/core/include/visp3/core/vpDebug.h +++ b/modules/core/include/visp3/core/vpDebug.h @@ -61,6 +61,10 @@ #define VP_DEBUG_MODE 0 #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpTraceOutput @@ -131,16 +135,6 @@ */ class vpTraceOutput { -private: - const char *currentFile; // Name of the file to use in the displays - const char *currentFunc; // Name of the function to use in the displays - int currentLine; // Line to use in the displays - - // if true, output to std::cerr/stderr else std::cout/stdout - bool err; - // string to display before anything else - const char *header; - public: /*! Constructor. @@ -242,6 +236,16 @@ class vpTraceOutput fflush(stdout); } } +private: + const char *currentFile; // Name of the file to use in the displays + const char *currentFunc; // Name of the function to use in the displays + int currentLine; // Line to use in the displays + + // if true, output to std::cerr/stderr else std::cout/stdout + bool err; + // string to display before anything else + const char *header; + }; /* ------------------------------------------------------------------------- */ @@ -547,5 +551,7 @@ inline void vpDEBUG_TRACE(int /* level */, const char * /* a */, ...) { } #else #define DEFENSIF(a) (0) #endif /*#ifdef DEFENSIF*/ - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif /* #ifdef __DEBUG_HH */ diff --git a/modules/core/include/visp3/core/vpDisplay.h b/modules/core/include/visp3/core/vpDisplay.h index 822256aaf2..0b4a1fc8b8 100644 --- a/modules/core/include/visp3/core/vpDisplay.h +++ b/modules/core/include/visp3/core/vpDisplay.h @@ -31,6 +31,12 @@ * Image display. */ +/*! + * \file vpDisplay.h + * \brief Generic class for image display, also provide the interface + * with the image. + */ + #ifndef _vpDisplay_h_ #define _vpDisplay_h_ @@ -48,12 +54,10 @@ #include #include -/*! - * \file vpDisplay.h - * \brief Generic class for image display, also provide the interface - * with the image. - */ - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpDisplay * @@ -201,21 +205,6 @@ class VISP_EXPORT vpDisplay vpDisplay::SCALE_1. */ } vpScaleType; -protected: - //! display has been initialized - bool m_displayHasBeenInitialized; - //! display position - int m_windowXPosition; - //! display position - int m_windowYPosition; - unsigned int m_width; - unsigned int m_height; - std::string m_title; - unsigned int m_scale; - vpScaleType m_scaleType; - - void setScale(vpScaleType scaleType, unsigned int width, unsigned int height); - public: vpDisplay(); vpDisplay(const vpDisplay &d); @@ -925,9 +914,26 @@ class VISP_EXPORT vpDisplay //@} #endif +protected: + //! display has been initialized + bool m_displayHasBeenInitialized; + //! display position + int m_windowXPosition; + //! display position + int m_windowYPosition; + unsigned int m_width; + unsigned int m_height; + std::string m_title; + unsigned int m_scale; + vpScaleType m_scaleType; + + void setScale(vpScaleType scaleType, unsigned int width, unsigned int height); + private: //! Get the window pixmap and put it in vpRGBa image. virtual void getImage(vpImage &I) = 0; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpDisplayException.h b/modules/core/include/visp3/core/vpDisplayException.h index 4214b7eaf3..8aa630df69 100644 --- a/modules/core/include/visp3/core/vpDisplayException.h +++ b/modules/core/include/visp3/core/vpDisplayException.h @@ -31,19 +31,23 @@ * Exception that can be emitted by the vpDisplay class and its derivatives. */ -#ifndef _vpDisplayException_h_ -#define _vpDisplayException_h_ - /*! * \file vpDisplayException.h * \brief error that can be emitted by the vpDisplay class and its derivatives */ +#ifndef _vpDisplayException_h_ +#define _vpDisplayException_h_ + #include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpDisplayException * \ingroup group_core_debug @@ -90,5 +94,7 @@ class VISP_EXPORT vpDisplayException : public vpException */ explicit vpDisplayException(int id) : vpException(id) { } }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpEigenConversion.h b/modules/core/include/visp3/core/vpEigenConversion.h index a5463b6bdc..8c1d898e4a 100644 --- a/modules/core/include/visp3/core/vpEigenConversion.h +++ b/modules/core/include/visp3/core/vpEigenConversion.h @@ -40,7 +40,13 @@ #endif #include -namespace vp +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +#define VISP_EIGEN_CONVERSION_NAMESPACE vp +#else +#define VISP_EIGEN_CONVERSION_NAMESPACE visp +#endif + +namespace VISP_EIGEN_CONVERSION_NAMESPACE { #ifdef VISP_HAVE_EIGEN3 /* Eigen to ViSP */ diff --git a/modules/core/include/visp3/core/vpEndian.h b/modules/core/include/visp3/core/vpEndian.h index a55ec06854..2ea849e449 100644 --- a/modules/core/include/visp3/core/vpEndian.h +++ b/modules/core/include/visp3/core/vpEndian.h @@ -36,8 +36,8 @@ \brief Determine machine endianness and define VISP_LITTLE_ENDIAN, VISP_BIG_ENDIAN and VISP_PDP_ENDIAN macros. */ -#ifndef vpEndian_h -#define vpEndian_h +#ifndef _vpEndian_h_ +#define _vpEndian_h_ // Visual Studio 2010 or previous is missing inttypes.h #if defined(_MSC_VER) && (_MSC_VER < 1700) @@ -86,6 +86,10 @@ typedef unsigned short uint16_t; #error Cannot detect host machine endianness. #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif namespace vpEndian { VISP_EXPORT uint16_t swap16bits(uint16_t val); @@ -98,5 +102,7 @@ VISP_EXPORT double swapDouble(double d); VISP_EXPORT uint16_t reinterpret_cast_uchar_to_uint16_LE(unsigned char *const ptr); } // namespace vpEndian - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpException.h b/modules/core/include/visp3/core/vpException.h index 0eedfb374c..96b40e17be 100644 --- a/modules/core/include/visp3/core/vpException.h +++ b/modules/core/include/visp3/core/vpException.h @@ -45,6 +45,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpException * \ingroup group_core_debug @@ -57,19 +61,6 @@ */ class VISP_EXPORT vpException : public std::exception { -protected: - //! Contains the error code, see the errorCodeEnum table for details. - int code; - - //! Contains an error message (can be empty) - std::string message; - - //! Set the message container - void setMessage(const char *format, va_list args); - - //! forbid the empty constructor (protected) - vpException() : code(notInitialized), message("") { } - public: enum generalExceptionEnum { @@ -143,6 +134,22 @@ class VISP_EXPORT vpException : public std::exception * Print the error structure. */ friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpException &art); -}; +protected: + //! Contains the error code, see the errorCodeEnum table for details. + int code; + + //! Contains an error message (can be empty) + std::string message; + + //! Set the message container + void setMessage(const char *format, va_list args); + + //! forbid the empty constructor (protected) + vpException() : code(notInitialized), message("") { } + +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpExponentialMap.h b/modules/core/include/visp3/core/vpExponentialMap.h index 95637be0f4..e5c3e71555 100644 --- a/modules/core/include/visp3/core/vpExponentialMap.h +++ b/modules/core/include/visp3/core/vpExponentialMap.h @@ -36,12 +36,17 @@ \brief Provides exponential map computation */ -#ifndef vpExponentialMap_h -#define vpExponentialMap_h +#ifndef _vpExponentialMap_h_ +#define _vpExponentialMap_h_ +#include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpExponentialMap @@ -92,4 +97,7 @@ class VISP_EXPORT vpExponentialMap static vpColVector inverse(const vpHomogeneousMatrix &M); static vpColVector inverse(const vpHomogeneousMatrix &M, const double &delta_t); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpFeatureDisplay.h b/modules/core/include/visp3/core/vpFeatureDisplay.h index 66c3af9643..2ec64cf9c0 100644 --- a/modules/core/include/visp3/core/vpFeatureDisplay.h +++ b/modules/core/include/visp3/core/vpFeatureDisplay.h @@ -31,14 +31,16 @@ * Interface with the image for feature display. */ -#ifndef vpFeatureDisplay_H -#define vpFeatureDisplay_H - /*! \file vpFeatureDisplay.h \brief interface with the image for feature display */ +#ifndef _vpFeatureDisplay_H_ +#define _vpFeatureDisplay_H_ + +#include + // Color / image / display #include #include @@ -47,6 +49,10 @@ // Meter/pixel conversion #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpFeatureDisplay @@ -82,5 +88,7 @@ class VISP_EXPORT vpFeatureDisplay static void displayPoint(double x, double y, const vpCameraParameters &cam, const vpImage &I, const vpColor &color = vpColor::green, unsigned int thickness = 1); }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpForceTwistMatrix.h b/modules/core/include/visp3/core/vpForceTwistMatrix.h index b7da80e2f7..f1635b7ca7 100644 --- a/modules/core/include/visp3/core/vpForceTwistMatrix.h +++ b/modules/core/include/visp3/core/vpForceTwistMatrix.h @@ -32,8 +32,19 @@ * frame to an other. */ -#ifndef vpForceTwistMatrix_h -#define vpForceTwistMatrix_h +#ifndef _vpForceTwistMatrix_h_ +#define _vpForceTwistMatrix_h_ + +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif +class vpMatrix; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #include #include @@ -41,6 +52,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpForceTwistMatrix @@ -235,6 +250,8 @@ class VISP_EXPORT vpForceTwistMatrix : public vpArray2D vp_deprecated void setIdentity(); //@} #endif -}; - + }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpForwardProjection.h b/modules/core/include/visp3/core/vpForwardProjection.h index 97e98c2cf6..845ce10209 100644 --- a/modules/core/include/visp3/core/vpForwardProjection.h +++ b/modules/core/include/visp3/core/vpForwardProjection.h @@ -31,20 +31,25 @@ * Forward projection. */ -#ifndef vpForwardProjection_H -#define vpForwardProjection_H - /*! * \file vpForwardProjection.h * \brief class that defines what is a generic geometric feature */ +#ifndef _vpForwardProjection_H_ +#define _vpForwardProjection_H_ + +#include #include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpForwardProjection * \brief Class that defines what is a generic geometric feature. @@ -193,6 +198,16 @@ class VISP_EXPORT vpForwardProjection : public vpTracker void track(const vpHomogeneousMatrix &cMo); //@} + +public: + /** @name Public Attributes Inherited from vpForwardProjection */ + //@{ + /*! + * Feature coordinates expressed in the object frame. + */ + vpColVector oP; + //@} + protected: /** @name Protected Member Functions Inherited from vpForwardProjection */ //@{ @@ -205,17 +220,10 @@ class VISP_EXPORT vpForwardProjection : public vpTracker virtual void init() = 0; //@} -public: - /** @name Public Attributes Inherited from vpForwardProjection */ - //@{ - /*! - * Feature coordinates expressed in the object frame. - */ - vpColVector oP; - //@} - private: vpForwardProjectionDeallocatorType deallocate; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpFrameGrabber.h b/modules/core/include/visp3/core/vpFrameGrabber.h index b13af19f45..fbb84085c9 100644 --- a/modules/core/include/visp3/core/vpFrameGrabber.h +++ b/modules/core/include/visp3/core/vpFrameGrabber.h @@ -31,18 +31,23 @@ * Frame grabbing. */ -#ifndef vpFrameGrabber_hh -#define vpFrameGrabber_hh - -#include -#include - /*! * \file vpFrameGrabber.h * \brief Base class for all video devices. It is * designed to provide a generic front end to video sources. */ +#ifndef _vpFrameGrabber_h_ +#define _vpFrameGrabber_h_ + +#include +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpFrameGrabber * @@ -95,10 +100,6 @@ class VISP_EXPORT vpFrameGrabber public: bool init; //!< Set to true if the frame grabber has been initialized. -protected: - unsigned int height; //!< Number of rows in the image. - unsigned int width; //!< Number of columns in the image. - public: /** @name Inherited functionalities from vpFramegrabber */ //@{ @@ -127,6 +128,12 @@ class VISP_EXPORT vpFrameGrabber * the memory used by a specific frame grabber */ virtual void close() = 0; -}; +protected: + unsigned int height; //!< Number of rows in the image. + unsigned int width; //!< Number of columns in the image. +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpFrameGrabberException.h b/modules/core/include/visp3/core/vpFrameGrabberException.h index 1229b44cb5..a8c29ea6b0 100644 --- a/modules/core/include/visp3/core/vpFrameGrabberException.h +++ b/modules/core/include/visp3/core/vpFrameGrabberException.h @@ -32,21 +32,24 @@ * derivates. */ -#ifndef _vpFrameGrabberException_h_ -#define _vpFrameGrabberException_h_ - /*! * \file vpFrameGrabberException.h * \brief error that can be emitted by the vpFrameGrabber class and its * derivates */ +#ifndef _vpFrameGrabberException_h_ +#define _vpFrameGrabberException_h_ + #include #include #include #include - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \brief Error that can be emitted by the vpFrameGrabber class and its * derivates. @@ -88,5 +91,7 @@ class VISP_EXPORT vpFrameGrabberException : public vpException */ explicit vpFrameGrabberException(int id) : vpException(id) { } }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpGEMM.h b/modules/core/include/visp3/core/vpGEMM.h index 23837d406b..982d4bb060 100644 --- a/modules/core/include/visp3/core/vpGEMM.h +++ b/modules/core/include/visp3/core/vpGEMM.h @@ -37,6 +37,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif const vpArray2D null(0, 0); /*! @@ -443,5 +447,7 @@ inline void vpGEMM(const vpArray2D &A, const vpArray2D &B, const break; } } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpGaussianFilter.h b/modules/core/include/visp3/core/vpGaussianFilter.h index 53135dff50..2209a48441 100644 --- a/modules/core/include/visp3/core/vpGaussianFilter.h +++ b/modules/core/include/visp3/core/vpGaussianFilter.h @@ -36,13 +36,18 @@ \brief Gaussian filter class */ -#ifndef vpGaussianFilter_H -#define vpGaussianFilter_H +#ifndef _vpGaussianFilter_H_ +#define _vpGaussianFilter_H_ +#include #include #if defined(VISP_HAVE_SIMDLIB) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpGaussianFilter @@ -63,12 +68,14 @@ class VISP_EXPORT vpGaussianFilter private: vpGaussianFilter(const vpGaussianFilter &gf); - vpGaussianFilter &operator=(const vpGaussianFilter &); + vpGaussianFilter &operator=(const vpGaussianFilter &gf); // PIMPL idiom class Impl; Impl *m_impl; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpHistogram.h b/modules/core/include/visp3/core/vpHistogram.h index 2e2b99fdb5..8c2d98a5d1 100644 --- a/modules/core/include/visp3/core/vpHistogram.h +++ b/modules/core/include/visp3/core/vpHistogram.h @@ -38,11 +38,12 @@ */ -#ifndef vpHistogram_h -#define vpHistogram_h +#ifndef _vpHistogram_h_ +#define _vpHistogram_h_ #include +#include #include #include #include @@ -54,6 +55,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpHistogram \ingroup group_core_histogram @@ -317,5 +322,7 @@ class VISP_EXPORT vpHistogram const vpImage *mp_mask; /*!< Mask that permits to consider only the pixels for which the mask is true.*/ unsigned int m_total; /*!< Cumulated number of pixels in the input image. */ }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpHistogramPeak.h b/modules/core/include/visp3/core/vpHistogramPeak.h index 8d5f63eb89..593cae001f 100644 --- a/modules/core/include/visp3/core/vpHistogramPeak.h +++ b/modules/core/include/visp3/core/vpHistogramPeak.h @@ -37,13 +37,17 @@ Class vpHistogramPeak defines a gray level histogram peak. */ -#ifndef vpHistogramPeak_h -#define vpHistogramPeak_h +#ifndef _vpHistogramPeak_h_ +#define _vpHistogramPeak_h_ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpHistogramPeak @@ -64,7 +68,7 @@ class VISP_EXPORT vpHistogramPeak vpHistogramPeak(const vpHistogramPeak &p); /*! Destructor that does nothing. */ - virtual ~vpHistogramPeak() {} + virtual ~vpHistogramPeak() { } vpHistogramPeak &operator=(const vpHistogramPeak &p); bool operator==(const vpHistogramPeak &p) const; @@ -145,5 +149,7 @@ class VISP_EXPORT vpHistogramPeak * c-basic-offset: 2 * End: */ - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpHistogramValey.h b/modules/core/include/visp3/core/vpHistogramValey.h index d0a753b17e..1ce432ef55 100644 --- a/modules/core/include/visp3/core/vpHistogramValey.h +++ b/modules/core/include/visp3/core/vpHistogramValey.h @@ -38,11 +38,15 @@ */ -#ifndef vpHistogramValey_h -#define vpHistogramValey_h +#ifndef _vpHistogramValey_h_ +#define _vpHistogramValey_h_ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpHistogramValey @@ -139,5 +143,7 @@ class VISP_EXPORT vpHistogramValey : vpHistogramPeak * c-basic-offset: 2 * End: */ - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpHomogeneousMatrix.h b/modules/core/include/visp3/core/vpHomogeneousMatrix.h index 6eb0e353de..10dcfbe7f7 100644 --- a/modules/core/include/visp3/core/vpHomogeneousMatrix.h +++ b/modules/core/include/visp3/core/vpHomogeneousMatrix.h @@ -39,6 +39,16 @@ #ifndef _vpHomogeneousMatrix_h_ #define _vpHomogeneousMatrix_h_ +#include +#include + +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpTranslationVector; class vpPoseVector; class vpMatrix; @@ -48,8 +58,9 @@ class vpThetaUVector; class vpQuaternionVector; class vpPoint; -#include -#include +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #include #include @@ -57,8 +68,19 @@ class vpPoint; #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +class vpHomogeneousMatrix; +} +#endif + #ifdef VISP_HAVE_NLOHMANN_JSON #include +#if defined(ENABLE_VISP_NAMESPACE) +void to_json(nlohmann::json &j, const visp::vpHomogeneousMatrix &T); +void from_json(const nlohmann::json &j, visp::vpHomogeneousMatrix &T); +#endif #endif /*! @@ -195,7 +217,11 @@ class vpPoint; {"cols":4,"data":[0.0,0.0,-1.0,0.1,0.0,-1.0,0.0,0.2,-1.0,0.0,0.0,0.3,0.0,0.0,0.0,1.0],"rows":4,"type":"vpHomogeneousMatrix"} \endcode */ -class VISP_EXPORT vpHomogeneousMatrix : public vpArray2D +class VISP_EXPORT +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif +vpHomogeneousMatrix: public vpArray2D { public: vpHomogeneousMatrix(); @@ -379,8 +405,8 @@ class VISP_EXPORT vpHomogeneousMatrix : public vpArray2D public: static const std::string jsonTypeName; private: - friend void to_json(nlohmann::json &j, const vpHomogeneousMatrix &cam); - friend void from_json(const nlohmann::json &j, vpHomogeneousMatrix &T); + friend void ::to_json(nlohmann::json &j, const vpHomogeneousMatrix &T); + friend void ::from_json(const nlohmann::json &j, vpHomogeneousMatrix &T); // Conversion helper function to avoid circular dependencies and MSVC errors that are not exported in the DLL void parse_json(const nlohmann::json &j); void convert_to_json(nlohmann::json &j) const; @@ -410,11 +436,23 @@ class VISP_EXPORT vpHomogeneousMatrix : public vpArray2D }; #ifdef VISP_HAVE_NLOHMANN_JSON -inline void to_json(nlohmann::json &j, const vpHomogeneousMatrix &T) +inline void to_json(nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +const visp::vpHomogeneousMatrix &T +#else +const vpHomogeneousMatrix &T +#endif +) { T.convert_to_json(j); } -inline void from_json(const nlohmann::json &j, vpHomogeneousMatrix &T) +inline void from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +visp::vpHomogeneousMatrix &T +#else +vpHomogeneousMatrix &T +#endif +) { T.parse_json(j); } diff --git a/modules/core/include/visp3/core/vpImage.h b/modules/core/include/visp3/core/vpImage.h index a3158ec9d9..7b971486fc 100644 --- a/modules/core/include/visp3/core/vpImage.h +++ b/modules/core/include/visp3/core/vpImage.h @@ -66,6 +66,10 @@ typedef unsigned short uint16_t; #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif class vpDisplay; /*! @@ -278,7 +282,7 @@ template class vpImage Set the value \e v of an image point with coordinates (i, j), with i the row position and j the column position. */ - inline void operator()(unsigned int i, unsigned int j, const Type &v) { bitmap[i * width + j] = v; } + inline void operator()(unsigned int i, unsigned int j, const Type &v) { bitmap[(i * width) + j] = v; } /*! Get the value of an image point. @@ -1974,8 +1978,8 @@ template <> inline unsigned char vpImage::getValue(double i, doub int64_t y_ = y >> 16; if (((y_ + 1) < height) && ((x_ + 1) < width)) { - uint16_t up = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap + y_ * width + x_); - uint16_t down = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap + (y_ + 1) * width + x_); + uint16_t up = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap + (y_ * width) + x_); + uint16_t down = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap + ((y_ + 1) * width) + x_); return static_cast((((up & 0x00FF) * rfrac + (down & 0x00FF) * rratio) * cfrac + ((up >> 8) * rfrac + (down >> 8) * rratio) * cratio) >> @@ -1985,7 +1989,7 @@ template <> inline unsigned char vpImage::getValue(double i, doub return static_cast(((row[y_][x_] * rfrac + row[y_ + 1][x_] * rratio)) >> 16); } else if ((x_ + 1) < width) { - uint16_t up = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap + y_ * width + x_); + uint16_t up = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap + (y_ * width) + x_); return static_cast(((up & 0x00FF) * cfrac + (up >> 8) * cratio) >> 16); } else { @@ -2560,5 +2564,7 @@ template void swap(vpImage &first, vpImage &second) swap(first.height, second.height); swap(first.row, second.row); } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImageCircle.h b/modules/core/include/visp3/core/vpImageCircle.h index 80a7f167a3..c3f651bd7c 100644 --- a/modules/core/include/visp3/core/vpImageCircle.h +++ b/modules/core/include/visp3/core/vpImageCircle.h @@ -49,6 +49,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /** * \brief Class that defines a 2D circle in an image. */ @@ -141,4 +145,7 @@ class VISP_EXPORT vpImageCircle vpImagePoint m_center; float m_radius; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImageConvert.h b/modules/core/include/visp3/core/vpImageConvert.h index ad871ac208..92159df084 100644 --- a/modules/core/include/visp3/core/vpImageConvert.h +++ b/modules/core/include/visp3/core/vpImageConvert.h @@ -75,6 +75,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpImageConvert @@ -182,9 +186,9 @@ class VISP_EXPORT vpImageConvert unsigned char &b) { double dr, dg, db; - dr = floor(0.9999695 * y - 0.0009508 * (u - 128) + 1.1359061 * (v - 128)); - dg = floor(0.9999695 * y - 0.3959609 * (u - 128) - 0.5782955 * (v - 128)); - db = floor(0.9999695 * y + 2.04112 * (u - 128) - 0.0016314 * (v - 128)); + dr = floor(((0.9999695 * y) - (0.0009508 * (u - 128))) + (1.1359061 * (v - 128))); + dg = floor(((0.9999695 * y) - (0.3959609 * (u - 128))) - (0.5782955 * (v - 128))); + db = floor(((0.9999695 * y) + (2.04112 * (u - 128))) - (0.0016314 * (v - 128))); dr = dr < 0. ? 0. : dr; dg = dg < 0. ? 0. : dg; @@ -270,6 +274,7 @@ class VISP_EXPORT vpImageConvert static void RGBToHSV(const unsigned char *rgb, unsigned char *hue, unsigned char *saturation, unsigned char *value, unsigned int size, bool h_full = true); +#ifndef VISP_SKIP_BAYER_CONVERSION static void demosaicBGGRToRGBaBilinear(const uint8_t *bggr, uint8_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads = 0); static void demosaicBGGRToRGBaBilinear(const uint16_t *bggr, uint16_t *rgba, unsigned int width, unsigned int height, @@ -309,6 +314,7 @@ class VISP_EXPORT vpImageConvert unsigned int nThreads = 0); static void demosaicRGGBToRGBaMalvar(const uint16_t *rggb, uint16_t *rgba, unsigned int width, unsigned int height, unsigned int nThreads = 0); +#endif private: static void computeYCbCrLUT(); @@ -329,5 +335,7 @@ class VISP_EXPORT vpImageConvert static int vpCgr[256]; static int vpCbb[256]; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImageException.h b/modules/core/include/visp3/core/vpImageException.h index 9770d62326..45ee9ab972 100644 --- a/modules/core/include/visp3/core/vpImageException.h +++ b/modules/core/include/visp3/core/vpImageException.h @@ -31,21 +31,24 @@ * Exceptions that can be emitted by the vpImage class and its derivatives. */ -#ifndef _vpImageException_h_ -#define _vpImageException_h_ - /*! * \file vpImageException.h * \brief error that can be emitted by the vpImage class and its derivatives */ +#ifndef _vpImageException_h_ +#define _vpImageException_h_ + #include #include #include #include - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpImageException * \ingroup group_core_debug @@ -90,5 +93,7 @@ class VISP_EXPORT vpImageException : public vpException */ explicit vpImageException(int id) : vpException(id) { } }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImageFilter.h b/modules/core/include/visp3/core/vpImageFilter.h index 4ed8c57ef7..265e930d36 100644 --- a/modules/core/include/visp3/core/vpImageFilter.h +++ b/modules/core/include/visp3/core/vpImageFilter.h @@ -31,14 +31,14 @@ * Various image tools, convolution, ... */ +/*! + * \file vpImageFilter.h + * \brief Various image filter, convolution, etc... + */ + #ifndef _vpImageFilter_h_ #define _vpImageFilter_h_ - /*! - * \file vpImageFilter.h - * \brief Various image filter, convolution, etc... - */ - #include #include #include @@ -59,6 +59,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpImageFilter * @@ -68,70 +72,6 @@ */ class VISP_EXPORT vpImageFilter { -private: - /** - * \brief Resize the image \b I to the desired size and, if \b p_mask is different from nullptr, initialize - * \b I with 0s. - * - * @tparam ImageType Any numerical type (int, float, ...) - * @param p_mask If different from nullptr, a boolean mask that tells which pixels must be computed. - * @param height The desired height. - * @param width The desired width. - * @param I The image that must be resized and potentially initialized. - */ - template - static void resizeAndInitializeIfNeeded(const vpImage *p_mask, const unsigned int height, const unsigned int width, vpImage &I) - { - if (p_mask == nullptr) { - // Just need to resize the output image, values will be computed and overwrite what is inside the image - I.resize(height, width); - } - else { - // Need to reset the image because some points will not be computed - I.resize(height, width, static_cast(0)); - } - } - -/** - * \brief Indicates if the boolean mask is true at the desired coordinates. - * - * \param[in] p_mask Pointer towards the boolean mask if any or nullptr. - * \param[in] r The row index in the boolean mask. - * \param[in] c The column index in the boolean mask. - * \return true If the boolean mask is true at the desired coordinates or if \b p_mask is equal to \b nullptr. - * \return false False otherwise. - */ - static bool checkBooleanMask(const vpImage *p_mask, const unsigned int &r, const unsigned int &c) - { - bool computeVal = true; -#if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher - if (p_mask != nullptr) -#else - if (p_mask != NULL) -#endif - { - computeVal = (*p_mask)[r][c]; - } - return computeVal; - } - -// Note that on ubuntu 12.04 __cplusplus is equal to 1 that's why in the next line we consider __cplusplus <= 199711L -// and not __cplusplus == 199711L -#if ((__cplusplus <= 199711L) || (defined(_MSVC_LANG) && (_MSVC_LANG == 199711L))) // Check if cxx98 - // Helper to apply the scale to the raw values of the filters - template - static void scaleFilter(vpArray2D &filter, const float &scale) - { - const unsigned int nbRows = filter.getRows(); - const unsigned int nbCols = filter.getCols(); - for (unsigned int r = 0; r < nbRows; ++r) { - for (unsigned int c = 0; c < nbCols; ++c) { - filter[r][c] = filter[r][c] * scale; - } - } - } -#endif - public: //! Canny filter backends for the edge detection operations typedef enum vpCannyBackendType @@ -259,7 +199,8 @@ class VISP_EXPORT vpImageFilter for (unsigned int c = 0; c < nbCols; ++c) { filter[r][c] = filter[r][c] * scale; } - }}; + } + }; #endif // Scales to apply to the filters to get a normalized gradient filter that gives a gradient @@ -1693,6 +1634,73 @@ class VISP_EXPORT vpImageFilter static float median(const vpImage &Isrc); static std::vector median(const vpImage &Isrc); #endif -}; +private: + /** + * \brief Resize the image \b I to the desired size and, if \b p_mask is different from nullptr, initialize + * \b I with 0s. + * + * @tparam ImageType Any numerical type (int, float, ...) + * @param p_mask If different from nullptr, a boolean mask that tells which pixels must be computed. + * @param height The desired height. + * @param width The desired width. + * @param I The image that must be resized and potentially initialized. + */ + template + static void resizeAndInitializeIfNeeded(const vpImage *p_mask, const unsigned int height, const unsigned int width, vpImage &I) + { + if (p_mask == nullptr) { + // Just need to resize the output image, values will be computed and overwrite what is inside the image + I.resize(height, width); + } + else { + // Need to reset the image because some points will not be computed + I.resize(height, width, static_cast(0)); + } + } + +/** + * \brief Indicates if the boolean mask is true at the desired coordinates. + * + * \param[in] p_mask Pointer towards the boolean mask if any or nullptr. + * \param[in] r The row index in the boolean mask. + * \param[in] c The column index in the boolean mask. + * \return true If the boolean mask is true at the desired coordinates or if \b p_mask is equal to \b nullptr. + * \return false False otherwise. + */ + static bool checkBooleanMask(const vpImage *p_mask, const unsigned int &r, const unsigned int &c) + { + bool computeVal = true; +#if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher + if (p_mask != nullptr) +#else + if (p_mask != NULL) +#endif + { + computeVal = (*p_mask)[r][c]; + } + return computeVal; + } + +// Note that on ubuntu 12.04 __cplusplus is equal to 1 that's why in the next line we consider __cplusplus <= 199711L +// and not __cplusplus == 199711L +#if ((__cplusplus <= 199711L) || (defined(_MSVC_LANG) && (_MSVC_LANG == 199711L))) // Check if cxx98 + // Helper to apply the scale to the raw values of the filters + template + static void scaleFilter(vpArray2D &filter, const float &scale) + { + const unsigned int nbRows = filter.getRows(); + const unsigned int nbCols = filter.getCols(); + for (unsigned int r = 0; r < nbRows; ++r) { + for (unsigned int c = 0; c < nbCols; ++c) { + filter[r][c] = filter[r][c] * scale; + } + } + } +#endif + +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImageMorphology.h b/modules/core/include/visp3/core/vpImageMorphology.h index e467f4cd2b..d7e57ed5de 100644 --- a/modules/core/include/visp3/core/vpImageMorphology.h +++ b/modules/core/include/visp3/core/vpImageMorphology.h @@ -31,14 +31,16 @@ * Morphology tools. */ -#ifndef _vpImageMorphology_h_ -#define _vpImageMorphology_h_ - /*! \file vpImageMorphology.h \brief Various mathematical morphology tools, erosion, dilatation... */ + +#ifndef _vpImageMorphology_h_ +#define _vpImageMorphology_h_ + +#include #include #include #include @@ -48,6 +50,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpImageMorphology @@ -74,33 +80,6 @@ class VISP_EXPORT vpImageMorphology diagonal) */ } vpConnexityType; -private: - /** - * \brief Modify the image by applying the \b operation on each of its elements on a 3x3 - * grid. - * - * \tparam T Either a class such as vpRGBa or a type such as double, unsigned char ... - * \param[out] I The image we want to modify. - * \param[in] null_value The value that is padded to the input image to manage the borders. - * \param[in] operation The operation to apply to its elements on a 3x3 grid. - * \param[in] connexity Either a 4-connexity, if we want to take into account only the horizontal - * and vertical neighbors, or a 8-connexity, if we want to also take into account the diagonal neighbors. - */ - template - static void imageOperation(vpImage &I, const T &null_value, const T &(*operation)(const T &, const T &), const vpConnexityType &connexity = CONNEXITY_4); - - /** - * \brief Modify the image by applying the \b operation on each of its elements on a \b size x \b size - * grid. - * - * \tparam T Any type such as double, unsigned char ... - * \param[out] I The image we want to modify. - * \param[in] operation The operation to apply to its elements on a the grid. - * \param[in] size Size of the kernel of the operation. - */ - template - static void imageOperation(vpImage &I, const T &(*operation)(const T &, const T &), const int &size = 3); - public: template static void erosion(vpImage &I, Type value, Type value_out, vpConnexityType connexity = CONNEXITY_4); @@ -159,6 +138,34 @@ class VISP_EXPORT vpImageMorphology } //@} #endif + +private: + /** + * \brief Modify the image by applying the \b operation on each of its elements on a 3x3 + * grid. + * + * \tparam T Either a class such as vpRGBa or a type such as double, unsigned char ... + * \param[out] I The image we want to modify. + * \param[in] null_value The value that is padded to the input image to manage the borders. + * \param[in] operation The operation to apply to its elements on a 3x3 grid. + * \param[in] connexity Either a 4-connexity, if we want to take into account only the horizontal + * and vertical neighbors, or a 8-connexity, if we want to also take into account the diagonal neighbors. + */ + template + static void imageOperation(vpImage &I, const T &null_value, const T &(*operation)(const T &, const T &), const vpConnexityType &connexity = CONNEXITY_4); + + /** + * \brief Modify the image by applying the \b operation on each of its elements on a \b size x \b size + * grid. + * + * \tparam T Any type such as double, unsigned char ... + * \param[out] I The image we want to modify. + * \param[in] operation The operation to apply to its elements on a the grid. + * \param[in] size Size of the kernel of the operation. + */ + template + static void imageOperation(vpImage &I, const T &(*operation)(const T &, const T &), const int &size = 3); + }; /*! @@ -529,6 +536,9 @@ void vpImageMorphology::dilatation(vpImage &I, const int &size) const T &(*operation)(const T & a, const T & b) = std::max; vpImageMorphology::imageOperation(I, operation, size); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif /* diff --git a/modules/core/include/visp3/core/vpImagePoint.h b/modules/core/include/visp3/core/vpImagePoint.h index 120385f7b1..037434d7f8 100644 --- a/modules/core/include/visp3/core/vpImagePoint.h +++ b/modules/core/include/visp3/core/vpImagePoint.h @@ -31,15 +31,15 @@ * 2D point useful for image processing */ -#ifndef _vpImagePoint_h_ -#define _vpImagePoint_h_ - /*! \file vpImagePoint.h \brief Class that defines a 2D point in an image. This class is useful for image processing */ +#ifndef _vpImagePoint_h_ +#define _vpImagePoint_h_ + #include #include // std::fabs @@ -47,6 +47,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif class vpRect; /*! @@ -378,5 +382,7 @@ class VISP_EXPORT vpImagePoint private: double i, j; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImageTools.h b/modules/core/include/visp3/core/vpImageTools.h index a9b0acbd33..0308b49396 100644 --- a/modules/core/include/visp3/core/vpImageTools.h +++ b/modules/core/include/visp3/core/vpImageTools.h @@ -31,9 +31,6 @@ * Image tools. */ -#ifndef vpImageTools_H -#define vpImageTools_H - /*! \file vpImageTools.h @@ -41,6 +38,9 @@ the look up table, binarisation... */ +#ifndef _vpImageTools_H_ +#define _vpImageTools_H_ + #include #ifdef VISP_HAVE_THREADS @@ -63,6 +63,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpImageTools @@ -1937,5 +1941,7 @@ inline void vpImageTools::warpLinear(const vpImage &src, const vpMatrix } } } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpIoException.h b/modules/core/include/visp3/core/vpIoException.h index 55cf163360..3c4a9e2ce7 100644 --- a/modules/core/include/visp3/core/vpIoException.h +++ b/modules/core/include/visp3/core/vpIoException.h @@ -31,20 +31,24 @@ * Exceptions that can be emitted by the vpIo class and its derivatives. */ -#ifndef _vpIoException_h_ -#define _vpIoException_h_ - /*! * \file vpIoException.h * \brief Error that can be emitted by the vpIoTools class and its derivatives. */ +#ifndef _vpIoException_h_ +#define _vpIoException_h_ + #include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpIoException * \ingroup group_core_debug @@ -88,5 +92,7 @@ class VISP_EXPORT vpIoException : public vpException */ explicit vpIoException(int id) : vpException(id) { } }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpIoTools.h b/modules/core/include/visp3/core/vpIoTools.h index b204c83c6e..dc12e89c6f 100644 --- a/modules/core/include/visp3/core/vpIoTools.h +++ b/modules/core/include/visp3/core/vpIoTools.h @@ -31,14 +31,14 @@ * Directory management. */ -#ifndef _vpIoTools_h_ -#define _vpIoTools_h_ - /*! * \file vpIoTools.h * \brief File and directories basic tools. */ +#ifndef _vpIoTools_h_ +#define _vpIoTools_h_ + #include #include @@ -487,6 +487,10 @@ template std::vector create_npy_header(const std::vector +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! -Parse the flag values defined in a JSON object. -if the flags are defined as an int, then this is int is directly returned. -If it is defined as a combination of options (defined from an enumeration E) then the logical or of theses enum values is returned. -Beware that invalid values may be defined in the JSON object: the int value may be invalid, or the parsing of enum values may fail. + Parse the flag values defined in a JSON object. + if the flags are defined as an int, then this is int is directly returned. + If it is defined as a combination of options (defined from an enumeration E) then the logical or of theses enum values is returned. + Beware that invalid values may be defined in the JSON object: the int value may be invalid, or the parsing of enum values may fail. -\param j: the JSON object to parse + \param j: the JSON object to parse -\return an int, corresponding to the combination of boolean flags + \return an int, corresponding to the combination of boolean flags */ template @@ -68,11 +72,11 @@ int flagsFromJSON(const nlohmann::json &j) } /*! - Serialize flag values as a json array. - \param flags the value to serialize - \param options the possible values that can be contained in flags. A flag i is set if flags & options[i] != 0. + Serialize flag values as a json array. + \param flags the value to serialize + \param options the possible values that can be contained in flags. A flag i is set if flags & options[i] != 0. - \return a json object (an array) that contains the different flags of the variable flags. + \return a json object (an array) that contains the different flags of the variable flags. */ template @@ -97,7 +101,8 @@ template bool convertFromTypeAndBuildFrom(const nlohmann::json &j, T &t) { if (j["type"] == O::jsonTypeName) { - O other = j; + O other; + from_json(j, other); t.build(other); return true; } @@ -105,6 +110,8 @@ bool convertFromTypeAndBuildFrom(const nlohmann::json &j, T &t) return convertFromTypeAndBuildFrom(j, t); } } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpLine.h b/modules/core/include/visp3/core/vpLine.h index 44082d8da2..f446976e24 100644 --- a/modules/core/include/visp3/core/vpLine.h +++ b/modules/core/include/visp3/core/vpLine.h @@ -31,19 +31,24 @@ * Line feature. */ -#ifndef vpLine_H -#define vpLine_H - /*! * \file vpLine.h * \brief class that defines what is a line */ +#ifndef _vpLine_H_ +#define _vpLine_H_ + +#include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpLine * \ingroup group_core_geometry @@ -172,5 +177,7 @@ class VISP_EXPORT vpLine : public vpForwardProjection protected: void init() vp_override; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpList.h b/modules/core/include/visp3/core/vpList.h index ac5ce23642..f9a8525030 100644 --- a/modules/core/include/visp3/core/vpList.h +++ b/modules/core/include/visp3/core/vpList.h @@ -31,14 +31,14 @@ * List data structure. */ -#ifndef VP_LIST_H -#define VP_LIST_H - /*! * \file vpList.h * \brief Definition of the list management class */ +#ifndef _VP_LIST_H_ +#define _VP_LIST_H_ + #include #include #include @@ -47,6 +47,10 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpListElement \brief Each element of a list @@ -704,7 +708,9 @@ template void vpList::display() } std::cout << std::endl << std::endl; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif /* #ifndef VP_LIST_H */ /* diff --git a/modules/core/include/visp3/core/vpMath.h b/modules/core/include/visp3/core/vpMath.h index 51144d17d0..017a5d8582 100644 --- a/modules/core/include/visp3/core/vpMath.h +++ b/modules/core/include/visp3/core/vpMath.h @@ -37,8 +37,8 @@ * the C mathematics library (math.h) */ -#ifndef vpMATH_HH -#define vpMATH_HH +#ifndef _vpMATH_H_ +#define _vpMATH_H_ #include @@ -92,6 +92,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpPoint; class vpHomogeneousMatrix; class vpColVector; @@ -345,8 +350,8 @@ class VISP_EXPORT vpMath double delta = (end - start) / (num - 1); - for (int i = 0; i < num - 1; ++i) { - linspaced.push_back(start + delta * i); + for (int i = 0; i < (num - 1); ++i) { + linspaced.push_back(start + (delta * i)); } linspaced.push_back(end); // I want to ensure that start and end // are exactly the same as the input @@ -662,5 +667,7 @@ template <> inline unsigned int vpMath::saturate(double v) { return static_cast(vpMath::round(v)); } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMatrix.h b/modules/core/include/visp3/core/vpMatrix.h index 00d2d8c080..aecc94bada 100644 --- a/modules/core/include/visp3/core/vpMatrix.h +++ b/modules/core/include/visp3/core/vpMatrix.h @@ -31,8 +31,30 @@ * Matrix manipulation. */ -#ifndef vpMatrix_H -#define vpMatrix_H +/*! + \file vpMatrix.h + + \brief Definition of matrix class as well as a set of operations on + these matrices. +*/ + +#ifndef _vpMatrix_H_ +#define _vpMatrix_H_ + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + +class vpRowVector; +class vpColVector; +class vpTranslationVector; +class vpHomogeneousMatrix; +class vpVelocityTwistMatrix; +class vpForceTwistMatrix; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #include #include @@ -46,19 +68,10 @@ #include #include -class vpRowVector; -class vpColVector; -class vpTranslationVector; -class vpHomogeneousMatrix; -class vpVelocityTwistMatrix; -class vpForceTwistMatrix; - -/*! - \file vpMatrix.h - - \brief Definition of matrix class as well as a set of operations on - these matrices. -*/ +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpMatrix @@ -1200,4 +1213,7 @@ __declspec(selectany) unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lap VISP_EXPORT #endif vpMatrix operator*(const double &x, const vpMatrix &A); +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMatrixException.h b/modules/core/include/visp3/core/vpMatrixException.h index edc9e136a1..a92505545e 100644 --- a/modules/core/include/visp3/core/vpMatrixException.h +++ b/modules/core/include/visp3/core/vpMatrixException.h @@ -40,6 +40,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpMatrixException * \ingroup group_core_debug @@ -99,5 +103,7 @@ class VISP_EXPORT vpMatrixException : public vpException */ explicit vpMatrixException(int id) : vpException(id) { } }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMeterPixelConversion.h b/modules/core/include/visp3/core/vpMeterPixelConversion.h index 23f14744d2..5666e0a62d 100644 --- a/modules/core/include/visp3/core/vpMeterPixelConversion.h +++ b/modules/core/include/visp3/core/vpMeterPixelConversion.h @@ -31,15 +31,14 @@ * Meter to pixel conversion. */ -#ifndef _vpMeterPixelConversion_h_ -#define _vpMeterPixelConversion_h_ - /*! \file vpMeterPixelConversion.h \brief Meter to pixel conversion. - */ +#ifndef _vpMeterPixelConversion_h_ +#define _vpMeterPixelConversion_h_ + #include #include #include @@ -51,6 +50,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpMeterPixelConversion @@ -321,9 +324,9 @@ class VISP_EXPORT vpMeterPixelConversion double theta2 = theta * theta, theta3 = theta2 * theta, theta4 = theta2 * theta2, theta5 = theta4 * theta, theta6 = theta3 * theta3, theta7 = theta6 * theta, theta8 = theta4 * theta4, theta9 = theta8 * theta; - double r_d = theta + k[0] * theta3 + k[1] * theta5 + k[2] * theta7 + k[3] * theta9; + double r_d = theta + (k[0] * theta3) + (k[1] * theta5) + (k[2] * theta7) + (k[3] * theta9); - double scale = (std::fabs(r) < std::numeric_limits::epsilon()) ? 1.0 : r_d / r; + double scale = (std::fabs(r) < std::numeric_limits::epsilon()) ? 1.0 : (r_d / r); double x_d = x * scale; double y_d = y * scale; @@ -353,5 +356,7 @@ class VISP_EXPORT vpMeterPixelConversion //@} #endif }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMouseButton.h b/modules/core/include/visp3/core/vpMouseButton.h index 3d68601f20..7eb197937b 100644 --- a/modules/core/include/visp3/core/vpMouseButton.h +++ b/modules/core/include/visp3/core/vpMouseButton.h @@ -31,11 +31,15 @@ * Color definition. */ -#ifndef vpMouseButton_h -#define vpMouseButton_h +#ifndef _vpMouseButton_h_ +#define _vpMouseButton_h_ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpMouseButton \ingroup group_gui_display @@ -44,12 +48,15 @@ class VISP_EXPORT vpMouseButton { public: - typedef enum { + typedef enum + { button1 = 1, /*!< Mouse left button. */ button2 = 2, /*!< Mouse middle button, or roll. */ button3 = 3, /*!< Mouse right button. */ none = 0 /*!< No button. */ } vpMouseButtonType; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpPixelMeterConversion.h b/modules/core/include/visp3/core/vpPixelMeterConversion.h index 5531eb231e..4af6db7267 100644 --- a/modules/core/include/visp3/core/vpPixelMeterConversion.h +++ b/modules/core/include/visp3/core/vpPixelMeterConversion.h @@ -31,14 +31,14 @@ * Pixel to meter conversion. */ -#ifndef _vpPixelMeterConversion_h_ -#define _vpPixelMeterConversion_h_ - /*! \file vpPixelMeterConversion.h \brief pixel to meter conversion - */ + +#ifndef _vpPixelMeterConversion_h_ +#define _vpPixelMeterConversion_h_ + #include #include #include @@ -50,6 +50,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpPixelMeterConversion @@ -384,5 +388,7 @@ class VISP_EXPORT vpPixelMeterConversion //@} #endif }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpPlane.h b/modules/core/include/visp3/core/vpPlane.h index 7c150a641f..0f1abb167c 100644 --- a/modules/core/include/visp3/core/vpPlane.h +++ b/modules/core/include/visp3/core/vpPlane.h @@ -31,13 +31,17 @@ * Plane geometrical structure. */ -#ifndef vpPlane_hh -#define vpPlane_hh +#ifndef _vpPlane_h_ +#define _vpPlane_h_ #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpPlane @@ -155,5 +159,7 @@ class VISP_EXPORT vpPlane double getIntersection(const vpColVector &M1, vpColVector &H) const; void changeFrame(const vpHomogeneousMatrix &cMo); }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpPoint.h b/modules/core/include/visp3/core/vpPoint.h index b2f4f069b3..2453ee3734 100644 --- a/modules/core/include/visp3/core/vpPoint.h +++ b/modules/core/include/visp3/core/vpPoint.h @@ -31,20 +31,24 @@ * Point feature. */ -#ifndef vpPoint_H -#define vpPoint_H - /*! \file vpPoint.h \brief class that defines what is a point */ -class vpHomogeneousMatrix; +#ifndef _vpPoint_H_ +#define _vpPoint_H_ #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif +class vpHomogeneousMatrix; + /*! \class vpPoint \ingroup group_core_geometry @@ -148,5 +152,7 @@ class VISP_EXPORT vpPoint : public vpForwardProjection //! Basic construction. void init() vp_override; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpPolygon.h b/modules/core/include/visp3/core/vpPolygon.h index c3652991e8..d9b055d9a3 100644 --- a/modules/core/include/visp3/core/vpPolygon.h +++ b/modules/core/include/visp3/core/vpPolygon.h @@ -45,6 +45,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpPolygon \ingroup group_core_geometry @@ -96,19 +100,6 @@ int main() */ class VISP_EXPORT vpPolygon { -protected: - //! Collection of image points containing the corners. - std::vector _corners; - //! Center of the polygon. It is automatically computed when the corners are - //! set. - vpImagePoint _center; - //! Area of the polygon. - double _area; - //! Flag set to true when the polygon is a good polygon (ie. it has more - //! than two corners) or false otherwise. - bool _goodPoly; - //! Bounding box containing the polygon. - vpRect _bbox; public: enum PointInPolygonMethod @@ -185,6 +176,20 @@ class VISP_EXPORT vpPolygon void updateCenter(); void updateBoundingBox(); +protected: + //! Collection of image points containing the corners. + std::vector _corners; + //! Center of the polygon. It is automatically computed when the corners are + //! set. + vpImagePoint _center; + //! Area of the polygon. + double _area; + //! Flag set to true when the polygon is a good polygon (ie. it has more + //! than two corners) or false otherwise. + bool _goodPoly; + //! Bounding box containing the polygon. + vpRect _bbox; + private: bool testIntersectionSegments(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpImagePoint &ip3, const vpImagePoint &ip4) const; @@ -201,5 +206,7 @@ class VISP_EXPORT vpPolygon static bool isInside(const std::vector &roi, const double &i, const double &j, const PointInPolygonMethod &method = PnPolyRayCasting); }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpPoseVector.h b/modules/core/include/visp3/core/vpPoseVector.h index 170b81459d..fc601b3987 100644 --- a/modules/core/include/visp3/core/vpPoseVector.h +++ b/modules/core/include/visp3/core/vpPoseVector.h @@ -32,9 +32,6 @@ * a rotation vector (theta u representation) and t is a translation vector. */ -#ifndef vpPOSEVECTOR_H -#define vpPOSEVECTOR_H - /*! \file vpPoseVector.h @@ -43,11 +40,8 @@ translation vector. */ -class vpRotationMatrix; -class vpHomogeneousMatrix; -class vpTranslationVector; -class vpThetaUVector; -class vpRowVector; +#ifndef _vpPOSEVECTOR_H_ +#define _vpPOSEVECTOR_H_ #include #include @@ -55,10 +49,33 @@ class vpRowVector; #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +class vpPoseVector; +} +#endif + #ifdef VISP_HAVE_NLOHMANN_JSON #include +#if defined(ENABLE_VISP_NAMESPACE) +void to_json(nlohmann::json &j, const visp::vpPoseVector &pose); +void from_json(const nlohmann::json &j, visp::vpPoseVector &pose); +#endif #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif +class vpRotationMatrix; +class vpHomogeneousMatrix; +class vpTranslationVector; +class vpThetaUVector; +class vpRowVector; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /*! \class vpPoseVector @@ -186,7 +203,11 @@ class vpRowVector; {"cols":1,"data":[0.1,0.2,0.3,3.141592653589793,1.5707963267948966,0.7853981633974483],"rows":6,"type":"vpPoseVector"} \endcode */ -class VISP_EXPORT vpPoseVector : public vpArray2D +class VISP_EXPORT +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif +vpPoseVector: public vpArray2D { public: // constructor @@ -303,8 +324,8 @@ class VISP_EXPORT vpPoseVector : public vpArray2D public: static const std::string jsonTypeName; private: - friend void to_json(nlohmann::json &j, const vpPoseVector &cam); - friend void from_json(const nlohmann::json &j, vpPoseVector &cam); + friend void ::to_json(nlohmann::json &j, const vpPoseVector &cam); + friend void ::from_json(const nlohmann::json &j, vpPoseVector &cam); // Conversion helper function to avoid circular dependencies and MSVC errors that are not exported in the DLL void parse_json(const nlohmann::json &j); void convert_to_json(nlohmann::json &j) const; @@ -327,11 +348,23 @@ class VISP_EXPORT vpPoseVector : public vpArray2D #ifdef VISP_HAVE_NLOHMANN_JSON #include -inline void to_json(nlohmann::json &j, const vpPoseVector &r) +inline void to_json(nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +const visp::vpPoseVector &r +#else +const vpPoseVector &r +#endif +) { r.convert_to_json(j); } -inline void from_json(const nlohmann::json &j, vpPoseVector &r) +inline void from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) +visp::vpPoseVector &r +#else +vpPoseVector &r +#endif +) { r.parse_json(j); } diff --git a/modules/core/include/visp3/core/vpQuaternionVector.h b/modules/core/include/visp3/core/vpQuaternionVector.h index 843656ed17..5a891f8d62 100644 --- a/modules/core/include/visp3/core/vpQuaternionVector.h +++ b/modules/core/include/visp3/core/vpQuaternionVector.h @@ -31,9 +31,6 @@ * Quaternion definition. */ -#ifndef _vpQuaternionVector_h_ -#define _vpQuaternionVector_h_ - /*! * \file vpQuaternionVector.h * @@ -41,11 +38,18 @@ * operations on it. */ +#ifndef _vpQuaternionVector_h_ +#define _vpQuaternionVector_h_ + #include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpQuaternionVector @@ -103,9 +107,6 @@ */ class VISP_EXPORT vpQuaternionVector : public vpRotationVector { -private: - static const double minimum; - public: vpQuaternionVector(); vpQuaternionVector(const vpQuaternionVector &q); @@ -162,6 +163,12 @@ class VISP_EXPORT vpQuaternionVector : public vpRotationVector static vpQuaternionVector lerp(const vpQuaternionVector &q0, const vpQuaternionVector &q1, double t); static vpQuaternionVector nlerp(const vpQuaternionVector &q0, const vpQuaternionVector &q1, double t); static vpQuaternionVector slerp(const vpQuaternionVector &q0, const vpQuaternionVector &q1, double t); -}; +private: + static const double minimum; + +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRGBa.h b/modules/core/include/visp3/core/vpRGBa.h index 772ba97f3a..aec295dbd1 100644 --- a/modules/core/include/visp3/core/vpRGBa.h +++ b/modules/core/include/visp3/core/vpRGBa.h @@ -31,17 +31,22 @@ * RGBA pixel. */ -#ifndef vpRGBa_h -#define vpRGBa_h - /*! \file vpRGBa.h \brief Define the object vpRGBa that is used to build color images (it defines a RGB 32 bits structure, fourth byte is not used) */ +#ifndef _vpRGBa_h_ +#define _vpRGBa_h_ + +#include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpRGBa @@ -141,5 +146,7 @@ class VISP_EXPORT vpRGBa friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb); }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRGBf.h b/modules/core/include/visp3/core/vpRGBf.h index 828a59b087..099d956094 100644 --- a/modules/core/include/visp3/core/vpRGBf.h +++ b/modules/core/include/visp3/core/vpRGBf.h @@ -31,17 +31,22 @@ * 32-bit floating point RGB pixel. */ -#ifndef vpRGBf_h -#define vpRGBf_h - /*! \file vpRGBf.h \brief Define the object vpRGBf that is used to build color images (it defines a RGB 32-bit floating point structure) */ +#ifndef _vpRGBf_h_ +#define _vpRGBf_h_ + +#include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpRGBf @@ -127,5 +132,7 @@ class VISP_EXPORT vpRGBf friend VISP_EXPORT vpRGBf operator*(double x, const vpRGBf &rgb); }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRansac.h b/modules/core/include/visp3/core/vpRansac.h index 2be17d461c..adfa6aaa20 100644 --- a/modules/core/include/visp3/core/vpRansac.h +++ b/modules/core/include/visp3/core/vpRansac.h @@ -35,15 +35,20 @@ \file vpRansac.h */ -#ifndef vpRANSAC_HH -#define vpRANSAC_HH +#ifndef _vpRANSAC_H_ +#define _vpRANSAC_H_ #include +#include #include #include // debug and trace #include #include // random number generation +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpRansac \ingroup group_core_robust @@ -241,5 +246,7 @@ bool vpRansac::ransac(unsigned int npts, const vpColVector &x, return true; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRect.h b/modules/core/include/visp3/core/vpRect.h index 207720d00e..ba1242e2c0 100644 --- a/modules/core/include/visp3/core/vpRect.h +++ b/modules/core/include/visp3/core/vpRect.h @@ -31,9 +31,20 @@ * Defines a rectangle in the plane. */ -#ifndef vpRect_h -#define vpRect_h +#ifndef _vpRect_h_ +#define _vpRect_h_ +#include +#include +#include +#include +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpRect \ingroup group_core_geometry @@ -65,13 +76,6 @@ setting sizes, e.g. setWidth(), setHeight() */ - -#include -#include -#include -#include -#include - class VISP_EXPORT vpRect { public: @@ -342,7 +346,7 @@ class VISP_EXPORT vpRect \sa setLeft() */ - inline void setRight(double pos) { this->width = pos - this->left + 1.0; } + inline void setRight(double pos) { this->width = (pos - this->left) + 1.0; } /*! Sets the top edge position of the rectangle to pos. May change the bottom @@ -408,5 +412,7 @@ class VISP_EXPORT vpRect double width; // Rectangle width double height; // Rectangle height }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRectOriented.h b/modules/core/include/visp3/core/vpRectOriented.h index afe8667a66..b1fe5d323e 100644 --- a/modules/core/include/visp3/core/vpRectOriented.h +++ b/modules/core/include/visp3/core/vpRectOriented.h @@ -31,18 +31,22 @@ * Defines a (possibly oriented) rectangle in the plane. */ -#ifndef vpRectOriented_h -#define vpRectOriented_h +#ifndef _vpRectOriented_h_ +#define _vpRectOriented_h_ +#include +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpRectOriented * \ingroup group_core_geometry * \brief Defines an oriented rectangle in the plane. */ - -#include -#include - class VISP_EXPORT vpRectOriented { public: @@ -105,4 +109,7 @@ class VISP_EXPORT vpRectOriented vpImagePoint m_bottomRight; bool isLeft(const vpImagePoint &pointToTest, const vpImagePoint &point1, const vpImagePoint &point2) const; }; -#endif // vpRectOriented_h +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif +#endif // _vpRectOriented_h_ diff --git a/modules/core/include/visp3/core/vpRobust.h b/modules/core/include/visp3/core/vpRobust.h index 5c52ef4e89..fa3282aef5 100644 --- a/modules/core/include/visp3/core/vpRobust.h +++ b/modules/core/include/visp3/core/vpRobust.h @@ -42,6 +42,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpRobust \ingroup group_core_robust @@ -90,27 +94,6 @@ class VISP_EXPORT vpRobust HUBER //!< Huber influence function. } vpRobustEstimatorType; -private: - //! Normalized residue - vpColVector m_normres; - //! Sorted normalized Residues - vpColVector m_sorted_normres; - //! Sorted residues - vpColVector m_sorted_residues; - - //! Min admissible value of residual vector Median Absolute Deviation - double m_mad_min; - //! Previous value of residual vector Median Absolute Deviation - double m_mad_prev; -#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) - //! Iteration, only used in deprecated simultMEstimator() - unsigned int m_iter; -#endif - //! Size of the containers - unsigned int m_size; - //! Residual vector Median Absolute Deviation - double m_mad; - public: vpRobust(); vpRobust(const vpRobust &other); @@ -181,6 +164,27 @@ class VISP_EXPORT vpRobust vp_deprecated vpColVector simultMEstimator(vpColVector &residues); //@} #endif +private: + //! Normalized residue + vpColVector m_normres; + //! Sorted normalized Residues + vpColVector m_sorted_normres; + //! Sorted residues + vpColVector m_sorted_residues; + + //! Min admissible value of residual vector Median Absolute Deviation + double m_mad_min; + //! Previous value of residual vector Median Absolute Deviation + double m_mad_prev; +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) + //! Iteration, only used in deprecated simultMEstimator() + unsigned int m_iter; +#endif + //! Size of the containers + unsigned int m_size; + //! Residual vector Median Absolute Deviation + double m_mad; + private: //! Resize containers for sort methods void resize(unsigned int n_data); @@ -244,5 +248,7 @@ class VISP_EXPORT vpRobust double select(vpColVector &a, int l, int r, int k); //@} }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRotationMatrix.h b/modules/core/include/visp3/core/vpRotationMatrix.h index 81fa71b15a..c7c4ca60b9 100644 --- a/modules/core/include/visp3/core/vpRotationMatrix.h +++ b/modules/core/include/visp3/core/vpRotationMatrix.h @@ -31,14 +31,14 @@ * Rotation matrix. */ -#ifndef _vpRotationMatrix_h_ -#define _vpRotationMatrix_h_ - /*! \file vpRotationMatrix.h \brief Class that consider the particular case of rotation matrix */ +#ifndef _vpRotationMatrix_h_ +#define _vpRotationMatrix_h_ + #include #include #include @@ -50,6 +50,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpRotationMatrix @@ -231,5 +235,7 @@ class VISP_EXPORT vpRotationMatrix : public vpArray2D VISP_EXPORT #endif vpRotationMatrix operator*(const double &x, const vpRotationMatrix &R); - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRotationVector.h b/modules/core/include/visp3/core/vpRotationVector.h index ac49de5431..b05d2e3e6d 100644 --- a/modules/core/include/visp3/core/vpRotationVector.h +++ b/modules/core/include/visp3/core/vpRotationVector.h @@ -31,20 +31,26 @@ * Generic rotation vector (cannot be used as is !). */ -#ifndef _vpRotationVector_h_ -#define _vpRotationVector_h_ - /*! \file vpRotationVector.h \brief class that consider the case of a generic rotation vector (cannot be used as is !) */ +#ifndef _vpRotationVector_h_ +#define _vpRotationVector_h_ + #include #include #include #include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif class vpRowVector; class vpColVector; @@ -157,4 +163,7 @@ VISP_EXPORT #endif vpColVector operator*(const double &x, const vpRotationVector &v); +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRowVector.h b/modules/core/include/visp3/core/vpRowVector.h index 3119f303da..9b9ac3060f 100644 --- a/modules/core/include/visp3/core/vpRowVector.h +++ b/modules/core/include/visp3/core/vpRowVector.h @@ -31,16 +31,22 @@ * Operation on row vectors. */ -#ifndef vpRowVector_H -#define vpRowVector_H +#ifndef _vpRowVector_H_ +#define _vpRowVector_H_ #include +#include #include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpMatrix; class vpColVector; @@ -335,5 +341,7 @@ class VISP_EXPORT vpRowVector : public vpArray2D }; VISP_EXPORT vpRowVector operator*(const double &x, const vpRowVector &v); - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRxyzVector.h b/modules/core/include/visp3/core/vpRxyzVector.h index 64a957b833..7e0598c82f 100644 --- a/modules/core/include/visp3/core/vpRxyzVector.h +++ b/modules/core/include/visp3/core/vpRxyzVector.h @@ -32,9 +32,6 @@ * Rxyz(phi,theta,psi) = Rot(x,phi)Rot(y,theta)Rot(z,psi). */ -#ifndef _vpRxyzVector_h_ -#define _vpRxyzVector_h_ - /*! \file vpRxyzVector.h @@ -44,10 +41,18 @@ Rxyz(phi,theta,psi) = Rot(x,phi)Rot(y,theta)Rot(z,psi) */ +#ifndef _vpRxyzVector_h_ +#define _vpRxyzVector_h_ + #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpRotationVector; class vpRotationMatrix; class vpThetaUVector; @@ -216,5 +221,7 @@ class VISP_EXPORT vpRxyzVector : public vpRotationVector vpRxyzVector &operator=(const std::initializer_list &list); #endif }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRzyxVector.h b/modules/core/include/visp3/core/vpRzyxVector.h index 0ed07dc55b..977a236cff 100644 --- a/modules/core/include/visp3/core/vpRzyxVector.h +++ b/modules/core/include/visp3/core/vpRzyxVector.h @@ -32,9 +32,6 @@ * Rzyx(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(x,psi) */ -#ifndef _vpRzyxVector_h_ -#define _vpRzyxVector_h_ - /*! \file vpRzyxVector.h @@ -44,13 +41,21 @@ Rzyx(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(x,psi) */ -class vpRotationMatrix; -class vpThetaUVector; +#ifndef _vpRzyxVector_h_ +#define _vpRzyxVector_h_ #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + +class vpRotationMatrix; +class vpThetaUVector; + /*! \class vpRzyxVector @@ -217,5 +222,7 @@ class VISP_EXPORT vpRzyxVector : public vpRotationVector vpRzyxVector &operator=(const std::initializer_list &list); #endif }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRzyzVector.h b/modules/core/include/visp3/core/vpRzyzVector.h index ae50e1f228..c5cf2b9b4a 100644 --- a/modules/core/include/visp3/core/vpRzyzVector.h +++ b/modules/core/include/visp3/core/vpRzyzVector.h @@ -32,9 +32,6 @@ * Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) */ -#ifndef _vpRzyzVector_h_ -#define _vpRzyzVector_h_ - /*! \file vpRzyzVector.h \brief class that consider the case of the Rzyz angles parameterization @@ -43,13 +40,21 @@ Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) */ -class vpRotationMatrix; -class vpThetaUVector; +#ifndef _vpRzyzVector_h_ +#define _vpRzyzVector_h_ #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + +class vpRotationMatrix; +class vpThetaUVector; + /*! \class vpRzyzVector @@ -216,4 +221,7 @@ class VISP_EXPORT vpRzyzVector : public vpRotationVector vpRzyzVector &operator=(const std::initializer_list &list); #endif }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpSphere.h b/modules/core/include/visp3/core/vpSphere.h index d28a723cab..bee076c35b 100644 --- a/modules/core/include/visp3/core/vpSphere.h +++ b/modules/core/include/visp3/core/vpSphere.h @@ -36,15 +36,21 @@ * \brief forward projection of a sphere */ -#ifndef vpSphere_hh -#define vpSphere_hh +#ifndef _vpSphere_h_ +#define _vpSphere_h_ +#include #include #include #include #include #include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpSphere * \ingroup group_core_geometry @@ -115,9 +121,6 @@ class VISP_EXPORT vpSphere : public vpForwardProjection void setWorldCoordinates(double oX, double oY, double oZ, double R); -protected: - void init() vp_override; - public: #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) /*! @@ -147,6 +150,11 @@ class VISP_EXPORT vpSphere : public vpForwardProjection vp_deprecated double get_mu02() const { return p[4]; } //@} #endif -}; +protected: + void init() vp_override; +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpSubColVector.h b/modules/core/include/visp3/core/vpSubColVector.h index ebfe81edc0..b78710511a 100644 --- a/modules/core/include/visp3/core/vpSubColVector.h +++ b/modules/core/include/visp3/core/vpSubColVector.h @@ -31,17 +31,22 @@ * Mask on a vpColVector. */ -#ifndef _vpSubColVector_h_ -#define _vpSubColVector_h_ - -#include - /*! * \file vpSubColVector.h * * \brief Definition of the vpSubColVector class */ +#ifndef _vpSubColVector_h_ +#define _vpSubColVector_h_ + +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpSubColVector * \ingroup group_core_matrices @@ -54,16 +59,6 @@ */ class VISP_EXPORT vpSubColVector : public vpColVector { -private: - //! Copy constructor unavailable - vpSubColVector(const vpSubColVector &v /* m */); - -protected: - //! Number of row of parent vpColVector at initialization - unsigned int m_pRowNum; - //! Parent vpColVector - vpColVector *m_parent; - public: vpSubColVector(); vpSubColVector(vpColVector &v, const unsigned int &offset, const unsigned int &nrows); @@ -82,6 +77,20 @@ class VISP_EXPORT vpSubColVector : public vpColVector vpSubColVector &operator=(const vpColVector &B); vpSubColVector &operator=(const vpMatrix &B); vpSubColVector &operator=(const double &x); -}; +protected: + //! Number of row of parent vpColVector at initialization + unsigned int m_pRowNum; + //! Parent vpColVector + vpColVector *m_parent; + +private: + //! Copy constructor unavailable + vpSubColVector(const vpSubColVector &v /* m */); + + +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpSubMatrix.h b/modules/core/include/visp3/core/vpSubMatrix.h index 8959603ba1..12237b21d5 100644 --- a/modules/core/include/visp3/core/vpSubMatrix.h +++ b/modules/core/include/visp3/core/vpSubMatrix.h @@ -31,17 +31,22 @@ * Mask on a vpMatrix. */ -#ifndef _vpSubMatrix_h_ -#define _vpSubMatrix_h_ - -#include - /*! * \file vpSubMatrix.h * * \brief Definition of the vpSubMatrix class */ +#ifndef _vpSubMatrix_h_ +#define _vpSubMatrix_h_ + +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpSubMatrix * \ingroup group_core_matrices @@ -53,18 +58,6 @@ */ class VISP_EXPORT vpSubMatrix : public vpMatrix { -private: - //! Eye method unavailable - void eye(unsigned int n); - //! Eye method unavailable - void eye(unsigned int m, unsigned int n); - //! Copy constructor unavailable - vpSubMatrix(const vpSubMatrix &m /* m */); - -protected: - unsigned int pRowNum; - unsigned int pColNum; - vpMatrix *parent; public: //! Default constructor @@ -88,6 +81,21 @@ class VISP_EXPORT vpSubMatrix : public vpMatrix vpSubMatrix &operator=(const vpMatrix &B); //! Operation such as subA = x vpSubMatrix &operator=(const double &x); -}; +protected: + unsigned int pRowNum; + unsigned int pColNum; + vpMatrix *parent; + +private: + //! Eye method unavailable + void eye(unsigned int n); + //! Eye method unavailable + void eye(unsigned int m, unsigned int n); + //! Copy constructor unavailable + vpSubMatrix(const vpSubMatrix &m /* m */); +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpSubRowVector.h b/modules/core/include/visp3/core/vpSubRowVector.h index ffd5e1b0c1..ba6be0fe83 100644 --- a/modules/core/include/visp3/core/vpSubRowVector.h +++ b/modules/core/include/visp3/core/vpSubRowVector.h @@ -31,17 +31,22 @@ * Mask on a vpRowVector. */ -#ifndef _vpSubRowVector_h_ -#define _vpSubRowVector_h_ - -#include - /*! * \file vpSubRowVector.h * * \brief Definition of the vpSubRowVector class */ +#ifndef _vpSubRowVector_h_ +#define _vpSubRowVector_h_ + +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpSubRowVector * \ingroup group_core_matrices @@ -54,15 +59,6 @@ */ class VISP_EXPORT vpSubRowVector : public vpRowVector { -private: - //! Copy constructor unavailable - vpSubRowVector(const vpSubRowVector &m /* m */); - -protected: - //! Number of row of parent vpColVector at initialization - unsigned int m_pColNum; - //! Parent vpColVector - vpRowVector *m_parent; public: vpSubRowVector(); @@ -77,6 +73,18 @@ class VISP_EXPORT vpSubRowVector : public vpRowVector vpSubRowVector &operator=(const vpRowVector &B); vpSubRowVector &operator=(const vpMatrix &B); vpSubRowVector &operator=(const double &x); -}; +protected: + //! Number of row of parent vpColVector at initialization + unsigned int m_pColNum; + //! Parent vpColVector + vpRowVector *m_parent; + +private: + //! Copy constructor unavailable + vpSubRowVector(const vpSubRowVector &m /* m */); +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpThetaUVector.h b/modules/core/include/visp3/core/vpThetaUVector.h index 21bd520383..5990620aa7 100644 --- a/modules/core/include/visp3/core/vpThetaUVector.h +++ b/modules/core/include/visp3/core/vpThetaUVector.h @@ -31,15 +31,28 @@ * Theta U parameterization for the rotation. */ -#ifndef _vpThetaUVector_h_ -#define _vpThetaUVector_h_ - /*! \file vpThetaUVector.h \brief class that consider the case of the Theta U parameterization for the rotation */ +#ifndef _vpThetaUVector_h_ +#define _vpThetaUVector_h_ + +#include +#include +#include +#include +#include +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpHomogeneousMatrix; class vpRotationMatrix; class vpPoseVector; @@ -50,15 +63,6 @@ class vpColVector; class vpRotationVector; class vpQuaternionVector; -#include -#include -#include -#include -#include -#include -#include -#include - /*! \class vpThetaUVector @@ -165,9 +169,6 @@ class vpQuaternionVector; */ class VISP_EXPORT vpThetaUVector : public vpRotationVector { -private: - static const double minimum; - public: vpThetaUVector(); vpThetaUVector(const vpThetaUVector &tu); @@ -239,6 +240,12 @@ class VISP_EXPORT vpThetaUVector : public vpRotationVector #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) vpThetaUVector &operator=(const std::initializer_list &list); #endif -}; +private: + static const double minimum; + +}; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpTime.h b/modules/core/include/visp3/core/vpTime.h index 78a3649b7f..3e348cccf5 100644 --- a/modules/core/include/visp3/core/vpTime.h +++ b/modules/core/include/visp3/core/vpTime.h @@ -31,13 +31,14 @@ * Time management and measurement. */ -#ifndef vpTime_h -#define vpTime_h - /*! \file vpTime.h \brief Time management and measurement */ + +#ifndef _vpTime_h_ +#define _vpTime_h_ + #include #include #include @@ -47,6 +48,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \ingroup group_core_time * \brief Time management and measurement. @@ -99,5 +104,7 @@ class VISP_EXPORT vpChrono double m_lastTimePoint; #endif }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpTracker.h b/modules/core/include/visp3/core/vpTracker.h index 0d0d6bd860..baaeeba60b 100644 --- a/modules/core/include/visp3/core/vpTracker.h +++ b/modules/core/include/visp3/core/vpTracker.h @@ -31,18 +31,23 @@ * Generic tracker. */ -#ifndef vpTracker_H -#define vpTracker_H - /*! * \file vpTracker.h * \brief Class that defines what is a generic tracker. */ +#ifndef _vpTracker_H_ +#define _vpTracker_H_ + +#include #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpTracker * \ingroup group_core_trackers @@ -83,7 +88,7 @@ class VISP_EXPORT vpTracker //! Copy constructor. vpTracker(const vpTracker &tracker); //! Destructor. - virtual ~vpTracker() { ; } + virtual ~vpTracker() { } /** @name Public Member Functions Inherited from vpTracker */ //@{ @@ -103,5 +108,7 @@ class VISP_EXPORT vpTracker void init(); //@} }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpTrackingException.h b/modules/core/include/visp3/core/vpTrackingException.h index c17e6bcd9a..761169a5b3 100644 --- a/modules/core/include/visp3/core/vpTrackingException.h +++ b/modules/core/include/visp3/core/vpTrackingException.h @@ -31,18 +31,24 @@ * Exceptions that can be emitted by the vpTracking class and its derivatives. */ -#ifndef _vpTrackingException_H -#define _vpTrackingException_H - /*! * \file vpTrackingException.h * \brief error that can be emitted by the vpTracker class and its derivatives */ +#ifndef _vpTrackingException_H_ +#define _vpTrackingException_H_ + #include #include +#include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpTrackingException * \ingroup group_core_debug @@ -87,5 +93,7 @@ class VISP_EXPORT vpTrackingException : public vpException */ explicit vpTrackingException(int id) : vpException(id) { } }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpTranslationVector.h b/modules/core/include/visp3/core/vpTranslationVector.h index 48e1a3b440..4481c10c2f 100644 --- a/modules/core/include/visp3/core/vpTranslationVector.h +++ b/modules/core/include/visp3/core/vpTranslationVector.h @@ -31,20 +31,25 @@ * Translation vector. */ -#ifndef vpTRANSLATIONVECTOR_H -#define vpTRANSLATIONVECTOR_H - /*! * \file vpTranslationVector.h * \brief Class that consider the case of a translation vector. */ +#ifndef _vpTRANSLATIONVECTOR_H_ +#define _vpTRANSLATIONVECTOR_H_ + #include #include #include -#include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif +class vpMatrix; + /*! \class vpTranslationVector @@ -207,5 +212,7 @@ class VISP_EXPORT vpTranslationVector : public vpArray2D protected: unsigned int m_index; // index used for operator<< and operator, to fill a vector }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpUniRand.h b/modules/core/include/visp3/core/vpUniRand.h index b57614149f..bec507bf08 100644 --- a/modules/core/include/visp3/core/vpUniRand.h +++ b/modules/core/include/visp3/core/vpUniRand.h @@ -82,6 +82,11 @@ typedef unsigned __int32 uint32_t; #endif #include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpUniRand @@ -121,19 +126,6 @@ typedef unsigned __int32 uint32_t; */ class VISP_EXPORT vpUniRand { -private: - struct vpPcgStateSetseq_64_t - { // Internals are *Private*. - uint64_t state; // RNG state. All values are possible. - uint64_t inc; // Controls which RNG sequence (stream) is - // selected. Must *always* be odd. - - vpPcgStateSetseq_64_t(uint64_t state_ = 0x853c49e6748fea9bULL, uint64_t inc_ = 0xda3e39cb94b95bdbULL) - : state(state_), inc(inc_) - { } - }; - typedef struct vpPcgStateSetseq_64_t pcg32_random_t; - public: vpUniRand(); vpUniRand(uint64_t seed, uint64_t seq = 0x123465789ULL); @@ -165,6 +157,19 @@ class VISP_EXPORT vpUniRand return shuffled; } +private: + struct vpPcgStateSetseq_64_t + { // Internals are *Private*. + uint64_t state; // RNG state. All values are possible. + uint64_t inc; // Controls which RNG sequence (stream) is + // selected. Must *always* be odd. + + vpPcgStateSetseq_64_t(uint64_t state_ = 0x853c49e6748fea9bULL, uint64_t inc_ = 0xda3e39cb94b95bdbULL) + : state(state_), inc(inc_) + { } + }; + typedef struct vpPcgStateSetseq_64_t pcg32_random_t; + private: uint32_t boundedRand(uint32_t bound); @@ -172,5 +177,7 @@ class VISP_EXPORT vpUniRand float m_maxInvFlt; pcg32_random_t m_rng; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpVelocityTwistMatrix.h b/modules/core/include/visp3/core/vpVelocityTwistMatrix.h index 8e954cf2fa..2a97a8525b 100644 --- a/modules/core/include/visp3/core/vpVelocityTwistMatrix.h +++ b/modules/core/include/visp3/core/vpVelocityTwistMatrix.h @@ -31,18 +31,22 @@ * Velocity twist transformation matrix. */ -#ifndef vpVelocityTwistMatrix_h -#define vpVelocityTwistMatrix_h +#ifndef _vpVelocityTwistMatrix_h_ +#define _vpVelocityTwistMatrix_h_ #include #include #include #include -#include #include -class vpHomogeneousMatrix; +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif class vpColVector; +class vpHomogeneousMatrix; +class vpMatrix; /*! \class vpVelocityTwistMatrix @@ -239,5 +243,7 @@ class VISP_EXPORT vpVelocityTwistMatrix : public vpArray2D //@} #endif }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpXmlParserCamera.h b/modules/core/include/visp3/core/vpXmlParserCamera.h index ebfb896dca..aa42d82b42 100644 --- a/modules/core/include/visp3/core/vpXmlParserCamera.h +++ b/modules/core/include/visp3/core/vpXmlParserCamera.h @@ -38,14 +38,18 @@ */ -#ifndef vpXMLPARSERCAMERA_H -#define vpXMLPARSERCAMERA_H +#ifndef _vpXMLPARSERCAMERA_H_ +#define _vpXMLPARSERCAMERA_H_ #include #if defined(VISP_HAVE_PUGIXML) #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpXmlParserCamera @@ -198,5 +202,8 @@ class VISP_EXPORT vpXmlParserCamera class Impl; Impl *m_impl; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h b/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h index b99d65609b..eb440b024f 100644 --- a/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h +++ b/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h @@ -39,14 +39,18 @@ */ -#ifndef VP_XMLPARSERHOMOGENEOUSMATRIX_H -#define VP_XMLPARSERHOMOGENEOUSMATRIX_H +#ifndef _VP_XMLPARSERHOMOGENEOUSMATRIX_H_ +#define _VP_XMLPARSERHOMOGENEOUSMATRIX_H_ #include #if defined(VISP_HAVE_PUGIXML) #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpXmlParserHomogeneousMatrix @@ -171,5 +175,8 @@ class VISP_EXPORT vpXmlParserHomogeneousMatrix class Impl; Impl *m_impl; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpXmlParserRectOriented.h b/modules/core/include/visp3/core/vpXmlParserRectOriented.h index 861546c013..329dc63fe7 100644 --- a/modules/core/include/visp3/core/vpXmlParserRectOriented.h +++ b/modules/core/include/visp3/core/vpXmlParserRectOriented.h @@ -37,14 +37,18 @@ Class vpXmlParserRectOriented allows to load and save oriented rectangles in a file XML */ -#ifndef vpXmlParserRectOriented_h -#define vpXmlParserRectOriented_h +#ifndef _vpXmlParserRectOriented_h_ +#define _vpXmlParserRectOriented_h_ #include #if defined(VISP_HAVE_PUGIXML) #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpXmlParserRectOriented @@ -108,5 +112,8 @@ class VISP_EXPORT vpXmlParserRectOriented class Impl; Impl *m_impl; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif // vpXmlParserRectOriented_h diff --git a/modules/core/src/camera/vpCameraParameters.cpp b/modules/core/src/camera/vpCameraParameters.cpp index 4b5d19b817..465b6dddd1 100644 --- a/modules/core/src/camera/vpCameraParameters.cpp +++ b/modules/core/src/camera/vpCameraParameters.cpp @@ -48,6 +48,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + const double vpCameraParameters::DEFAULT_PX_PARAMETER = 600.0; const double vpCameraParameters::DEFAULT_PY_PARAMETER = 600.0; const double vpCameraParameters::DEFAULT_U0_PARAMETER = 192.0; @@ -683,3 +688,7 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters } return os; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/camera/vpColorDepthConversion.cpp b/modules/core/src/camera/vpColorDepthConversion.cpp index f45bb1ed6c..b84a4360a9 100644 --- a/modules/core/src/camera/vpColorDepthConversion.cpp +++ b/modules/core/src/camera/vpColorDepthConversion.cpp @@ -46,6 +46,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif namespace { @@ -252,3 +256,6 @@ vpImagePoint vpColorDepthConversion::projectColorToDepth( #endif return depth_pixel; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/camera/vpMeterPixelConversion.cpp b/modules/core/src/camera/vpMeterPixelConversion.cpp index 05a3b8386d..840e02b198 100644 --- a/modules/core/src/camera/vpMeterPixelConversion.cpp +++ b/modules/core/src/camera/vpMeterPixelConversion.cpp @@ -44,6 +44,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Line parameters conversion from normalized coordinates \f$(\rho_m,\theta_m)\f$ expressed in the image plane to pixel coordinates \f$(\rho_p,\theta_p)\f$ using ViSP camera parameters. This function doesn't use distortion @@ -402,3 +406,6 @@ void vpMeterPixelConversion::convertPoint(const cv::Mat &cameraMatrix, const cv: iP.set_v(imagePoints_vec[0].y); } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/camera/vpPixelMeterConversion.cpp b/modules/core/src/camera/vpPixelMeterConversion.cpp index a116ca6651..0c4fcf9184 100644 --- a/modules/core/src/camera/vpPixelMeterConversion.cpp +++ b/modules/core/src/camera/vpPixelMeterConversion.cpp @@ -43,6 +43,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * Convert ellipse parameters (ie ellipse center and normalized centered moments) * from pixels \f$(u_c, v_c, n_{{20}_p}, n_{{11}_p}, n_{{02}_p})\f$ @@ -336,3 +340,6 @@ void vpPixelMeterConversion::convertPoint(const cv::Mat &cameraMatrix, const cv: } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/camera/vpXmlParserCamera.cpp b/modules/core/src/camera/vpXmlParserCamera.cpp index 42200c9530..2465884265 100644 --- a/modules/core/src/camera/vpXmlParserCamera.cpp +++ b/modules/core/src/camera/vpXmlParserCamera.cpp @@ -81,6 +81,10 @@ #define LABEL_XML_ADDITIONAL_INFO "additional_information" +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpXmlParserCamera::Impl { @@ -1227,7 +1231,9 @@ void vpXmlParserCamera::setSubsampling_width(unsigned int subsampling) { m_impl- void vpXmlParserCamera::setSubsampling_height(unsigned int subsampling) { m_impl->setSubsampling_height(subsampling); } void vpXmlParserCamera::setWidth(unsigned int width) { m_impl->setWidth(width); } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpXmlParserCamera.cpp.o) has no symbols void dummy_vpXmlParserCamera() { }; diff --git a/modules/core/src/display/vpColor.cpp b/modules/core/src/display/vpColor.cpp index 0af91b46ff..cfeff37f8b 100644 --- a/modules/core/src/display/vpColor.cpp +++ b/modules/core/src/display/vpColor.cpp @@ -35,6 +35,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif // FS: Sould be improved to avoid the #if preprocessor line. Not a good idea // to define colors in static. // See also vpColor.h where things need to be improved. @@ -98,7 +102,7 @@ vpColor const vpColor::none = vpColor(0, 0, 0, id_unknown); const unsigned int vpColor::nbColors = 18; /*!< Array of available colors. */ -vpColor const vpColor::allColors[vpColor::nbColors] = {vpColor::blue, // 12 +vpColor const vpColor::allColors[vpColor::nbColors] = { vpColor::blue, // 12 vpColor::green, // 9 vpColor::red, // 6 vpColor::cyan, // 15 @@ -115,10 +119,10 @@ vpColor const vpColor::allColors[vpColor::nbColors] = {vpColor::blue, // 1 vpColor::gray, // 3 vpColor::darkGray, // 4 vpColor::black, // 0 - vpColor::white}; // 17 + vpColor::white }; // 17 #endif -vpColor colors[6] = {vpColor::blue, vpColor::green, vpColor::red, vpColor::cyan, vpColor::orange, vpColor::purple}; +vpColor colors[6] = { vpColor::blue, vpColor::green, vpColor::red, vpColor::cyan, vpColor::orange, vpColor::purple }; /*! Compare two colors. @@ -144,3 +148,6 @@ VISP_EXPORT bool operator!=(const vpColor &c1, const vpColor &c2) { return ((c1.R != c2.R) || (c1.G != c2.G) || (c1.B == c2.B)); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/display/vpDisplay.cpp b/modules/core/src/display/vpDisplay.cpp index 7b430151a3..c727dade04 100644 --- a/modules/core/src/display/vpDisplay.cpp +++ b/modules/core/src/display/vpDisplay.cpp @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + \file vpDisplay.cpp + \brief Generic class for image display. +*/ + #include #include @@ -43,11 +48,10 @@ #include #include -/*! - \file vpDisplay.cpp - \brief Generic class for image display. -*/ - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Default constructor. */ @@ -326,5 +330,8 @@ void vpDisplay::setDownScalingFactor(vpScaleType scaleType) { if (!m_displayHasBeenInitialized) { m_scaleType = scaleType; - } } +} +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/display/vpDisplay_impl.h b/modules/core/src/display/vpDisplay_impl.h index 253027b7ac..05f4331e34 100644 --- a/modules/core/src/display/vpDisplay_impl.h +++ b/modules/core/src/display/vpDisplay_impl.h @@ -37,6 +37,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif template void vp_display_close(vpImage &I) { if (I.display != nullptr) { @@ -724,3 +728,6 @@ template unsigned int vp_display_get_down_scaling_factor(const vpIm return 1; } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/display/vpDisplay_rgba.cpp b/modules/core/src/display/vpDisplay_rgba.cpp index 2a3a069823..0e363fd2dd 100644 --- a/modules/core/src/display/vpDisplay_rgba.cpp +++ b/modules/core/src/display/vpDisplay_rgba.cpp @@ -41,7 +41,10 @@ // Modifications done in this file should be reported in all vpDisplay_*.cpp // files that implement other types (unsigned char, vpRGB, vpRGBa) //************************************************************************ - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Close the display attached to I. */ @@ -1326,3 +1329,6 @@ void vpDisplay::setWindowPosition(const vpImage &I, int winx, int winy) \param I : Image associated to the display window. */ unsigned int vpDisplay::getDownScalingFactor(const vpImage &I) { return vp_display_get_down_scaling_factor(I); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/display/vpDisplay_uchar.cpp b/modules/core/src/display/vpDisplay_uchar.cpp index 6080fa4025..74a10f8e63 100644 --- a/modules/core/src/display/vpDisplay_uchar.cpp +++ b/modules/core/src/display/vpDisplay_uchar.cpp @@ -41,7 +41,10 @@ // Modifications done in this file should be reported in all vpDisplay_*.cpp // files that implement other types (unsigned char, vpRGB, vpRGBa) //************************************************************************ - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Close the display attached to I. */ @@ -1336,3 +1339,6 @@ unsigned int vpDisplay::getDownScalingFactor(const vpImage &I) { return vp_display_get_down_scaling_factor(I); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/display/vpFeatureDisplay.cpp b/modules/core/src/display/vpFeatureDisplay.cpp index a764d6c8bb..2f083a14ea 100644 --- a/modules/core/src/display/vpFeatureDisplay.cpp +++ b/modules/core/src/display/vpFeatureDisplay.cpp @@ -49,6 +49,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Display a 2D point with coordinates (x, y) expressed in the image plane. These coordinates are obtained after perspective projection of the point. @@ -273,3 +277,6 @@ void vpFeatureDisplay::displayEllipse(double x, double y, double n20, double n11 vpMeterPixelConversion::convertEllipse(cam, circle, center, n20_p, n11_p, n02_p); vpDisplay::displayEllipse(I, center, n20_p, n11_p, n02_p, true, color, thickness); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/framegrabber/vpFrameGrabber.cpp b/modules/core/src/framegrabber/vpFrameGrabber.cpp index 2514ea5648..5740f5dd7b 100644 --- a/modules/core/src/framegrabber/vpFrameGrabber.cpp +++ b/modules/core/src/framegrabber/vpFrameGrabber.cpp @@ -34,6 +34,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif unsigned int vpFrameGrabber::getHeight() const { return height; @@ -43,3 +47,6 @@ unsigned int vpFrameGrabber::getWidth() const { return width; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/private/vpImageConvert_impl.h b/modules/core/src/image/private/vpImageConvert_impl.h index da34f3f0a8..177e8061f3 100644 --- a/modules/core/src/image/private/vpImageConvert_impl.h +++ b/modules/core/src/image/private/vpImageConvert_impl.h @@ -38,17 +38,22 @@ \brief Image conversion tools */ -#ifndef vpIMAGECONVERT_impl_H -#define vpIMAGECONVERT_impl_H +#ifndef _vpIMAGECONVERT_impl_H_ +#define _vpIMAGECONVERT_impl_H_ #if defined(VISP_HAVE_OPENMP) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) #include #include #endif +#include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Convert the input float depth image to a 8-bits depth image. The input depth value is assigned a value proportional to its frequency. @@ -60,6 +65,9 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage(src_depth.getSize()); + #if defined(VISP_HAVE_OPENMP) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) int nThreads = omp_get_max_threads(); std::vector > histograms(nThreads); @@ -68,7 +76,8 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage(src_depth.getSize()); ++i) { + + for (int i = 0; i < src_depth_size; ++i) { if (!vpMath::isNaN(src_depth.bitmap[i])) { ++(histograms[omp_get_thread_num()][static_cast(src_depth.bitmap[i])]); } @@ -81,26 +90,26 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage(src_depth.getSize()); ++i) { + for (int i = 0; i < src_depth_size; ++i) { if (!vpMath::isNaN(src_depth.bitmap[i])) { ++histogram[static_cast(src_depth.bitmap[i])]; } } #endif - for (int i = 2; i < 0x10000; ++i) + for (int i = 2; i < 0x10000; ++i) { histogram[i] += histogram[i - 1]; // Build a cumulative histogram for the indices in [1,0xFFFF] - + } dest_depth.resize(src_depth.getHeight(), src_depth.getWidth()); #ifdef VISP_HAVE_OPENMP #pragma omp parallel for #endif - for (int i = 0; i < static_cast(src_depth.getSize()); ++i) { + for (int i = 0; i < src_depth_size; ++i) { uint16_t d = static_cast(src_depth.bitmap[i]); if (d) { unsigned char f = - static_cast(histogram[d] * 255 / histogram[0xFFFF]); // 0-255 based on histogram location + static_cast((histogram[d] * 255) / histogram[0xFFFF]); // 0-255 based on histogram location dest_depth.bitmap[i] = f; } else { @@ -119,6 +128,7 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage(src_depth.getSize()); #if defined(VISP_HAVE_OPENMP) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) int nThreads = omp_get_max_threads(); @@ -128,7 +138,7 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage(src_depth.getSize()); ++i) { + for (int i = 0; i < src_depth_size; ++i) { ++(histograms[omp_get_thread_num()][static_cast(src_depth.bitmap[i])]); } @@ -144,19 +154,20 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage(src_depth.getSize()); ++i) { + + for (int i = 0; i < src_depth_size; ++i) { uint16_t d = src_depth.bitmap[i]; if (d) { unsigned char f = - static_cast(histogram[d] * 255 / histogram[0xFFFF]); // 0-255 based on histogram location + static_cast((histogram[d] * 255) / histogram[0xFFFF]); // 0-255 based on histogram location dest_depth.bitmap[i] = f; } else { @@ -176,26 +187,27 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage &d dest_depth.resize(src_depth.getHeight(), src_depth.getWidth()); uint32_t histogram[0x10000]; memset(histogram, 0, sizeof(histogram)); + int src_depth_size = static_cast(src_depth.getSize()); #ifdef VISP_HAVE_OPENMP #pragma omp parallel for #endif - for (int i = 0; i < static_cast(src_depth.getSize()); ++i) { + for (int i = 0; i < src_depth_size; ++i) { if (!vpMath::isNaN(src_depth.bitmap[i])) { ++histogram[static_cast(src_depth.bitmap[i])]; } } - for (int i = 2; i < 0x10000; ++i) + for (int i = 2; i < 0x10000; ++i) { histogram[i] += histogram[i - 1]; // Build a cumulative histogram for the indices in [1,0xFFFF] - + } #ifdef VISP_HAVE_OPENMP #pragma omp parallel for #endif - for (int i = 0; i < static_cast(src_depth.getSize()); ++i) { + for (int i = 0; i < src_depth_size; ++i) { uint16_t d = static_cast(src_depth.bitmap[i]); if (d) { - unsigned char f = (unsigned char)(histogram[d] * 255 / histogram[0xFFFF]); // 0-255 based on histogram location + unsigned char f = static_cast((histogram[d] * 255) / histogram[0xFFFF]); // 0-255 based on histogram location dest_depth.bitmap[i].R = 255 - f; dest_depth.bitmap[i].G = 0; dest_depth.bitmap[i].B = f; @@ -221,24 +233,27 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage dest_depth.resize(src_depth.getHeight(), src_depth.getWidth()); uint32_t histogram[0x10000]; memset(histogram, 0, sizeof(histogram)); + int src_depth_size = static_cast(src_depth.getSize()); #ifdef VISP_HAVE_OPENMP #pragma omp parallel for #endif - for (int i = 0; i < static_cast(src_depth.getSize()); ++i) { + for (int i = 0; i < src_depth_size; ++i) { ++histogram[static_cast(src_depth.bitmap[i])]; } - for (unsigned int i = 2; i < 0x10000; ++i) + for (unsigned int i = 2; i < 0x10000; ++i) { histogram[i] += histogram[i - 1]; // Build a cumulative histogram for the indices in [1,0xFFFF] + } #ifdef VISP_HAVE_OPENMP #pragma omp parallel for #endif - for (int i = 0; i < static_cast(src_depth.getSize()); ++i) { + + for (int i = 0; i < src_depth_size; ++i) { uint16_t d = src_depth.bitmap[i]; if (d) { - unsigned char f = (unsigned char)(histogram[d] * 255 / histogram[0xFFFF]); // 0-255 based on histogram location + unsigned char f = static_cast((histogram[d] * 255) / histogram[0xFFFF]); // 0-255 based on histogram location dest_depth.bitmap[i].R = 255 - f; dest_depth.bitmap[i].G = 0; dest_depth.bitmap[i].B = f; @@ -252,5 +267,7 @@ void vp_createDepthHistogram(const vpImage &src_depth, vpImage } } } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/src/image/vpCannyEdgeDetection.cpp b/modules/core/src/image/vpCannyEdgeDetection.cpp index c1f55dcec6..0fd696bec0 100644 --- a/modules/core/src/image/vpCannyEdgeDetection.cpp +++ b/modules/core/src/image/vpCannyEdgeDetection.cpp @@ -39,7 +39,11 @@ namespace { // Helper to apply the scale to the raw values of the filters template -static void scaleFilter(vpArray2D &filter, const float &scale) +static void scaleFilter( +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpArray2D &filter, const float &scale) { const unsigned int nbRows = filter.getRows(); const unsigned int nbCols = filter.getCols(); @@ -52,6 +56,10 @@ static void scaleFilter(vpArray2D &filter, const float &scale) }; #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif // // Initialization methods vpCannyEdgeDetection::vpCannyEdgeDetection() @@ -523,3 +531,6 @@ vpCannyEdgeDetection::recursiveSearchForStrongEdge(const std::pair #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpGaussianFilter::Impl { @@ -147,7 +151,9 @@ void vpGaussianFilter::apply(const vpImage &I, vpImage &I, vpImage &I_blur) { m_impl->apply(I, I_blur); } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpGaussianFilter.cpp.o) has no symbols void dummy_vpGaussianFilter() { }; diff --git a/modules/core/src/image/vpImageCircle.cpp b/modules/core/src/image/vpImageCircle.cpp index d21fbe1a00..ce35034320 100644 --- a/modules/core/src/image/vpImageCircle.cpp +++ b/modules/core/src/image/vpImageCircle.cpp @@ -34,6 +34,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif vpImageCircle::vpImageCircle() : m_center() , m_radius(0.) @@ -1164,3 +1168,6 @@ float vpImageCircle::get_n11() const { return 0.; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpImageConvert.cpp b/modules/core/src/image/vpImageConvert.cpp index 8328ff8bb3..d6abbd7306 100644 --- a/modules/core/src/image/vpImageConvert.cpp +++ b/modules/core/src/image/vpImageConvert.cpp @@ -30,8 +30,7 @@ * * Description: * Convert image types. - * -*****************************************************************************/ + */ /*! \file vpImageConvert.cpp @@ -47,14 +46,20 @@ #include -// image + +#ifndef VISP_SKIP_BAYER_CONVERSION #include "private/vpBayerConversion.h" +#endif #include "private/vpImageConvert_impl.h" #if defined(VISP_HAVE_SIMDLIB) #include #endif #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif bool vpImageConvert::YCbCrLUTcomputed = false; int vpImageConvert::vpCrr[256]; int vpImageConvert::vpCgb[256]; @@ -1133,7 +1138,7 @@ void vpImageConvert::RGBaToRGB(unsigned char *rgba, unsigned char *rgb, unsigned *(++pt_output) = *(++pt_input); // R *(++pt_output) = *(++pt_input); // G *(++pt_output) = *(++pt_input); // B - pt_input++; + ++pt_input; } #endif } @@ -1273,7 +1278,7 @@ void vpImageConvert::RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsign while (pt_input != pt_end) { *pt_output = static_cast((0.2126 * (*pt_input)) + (0.7152 * (*(pt_input + 1))) + (0.0722 * (*(pt_input + 2)))); pt_input += 4; - pt_output++; + ++pt_output; } #endif } @@ -1321,12 +1326,12 @@ void vpImageConvert::GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsign while (pt_input != pt_end) { unsigned char p = *pt_input; - *(pt_output) = p; // R + *pt_output = p; // R *(pt_output + 1) = p; // G *(pt_output + 2) = p; // B *(pt_output + 3) = vpRGBa::alpha_default; // A - pt_input++; + ++pt_input; pt_output += 4; } #endif @@ -1353,11 +1358,11 @@ void vpImageConvert::GreyToRGB(unsigned char *grey, unsigned char *rgb, unsigned while (pt_input != pt_end) { unsigned char p = *pt_input; - *(pt_output) = p; // R + *pt_output = p; // R *(pt_output + 1) = p; // G *(pt_output + 2) = p; // B - pt_input++; + ++pt_input; pt_output += 3; } #endif @@ -1972,7 +1977,7 @@ void vpImageConvert::split(const vpImage &src, vpImage *p if ((tabChannel[j]->getHeight() != height) || (tabChannel[j]->getWidth() != width)) { tabChannel[j]->resize(height, width); } - dst = (unsigned char *)tabChannel[j]->bitmap; + dst = static_cast(tabChannel[j]->bitmap); input = (unsigned char *)src.bitmap + j; i = 0; @@ -1982,16 +1987,16 @@ void vpImageConvert::split(const vpImage &src, vpImage *p for (; i < n; i += 4) { *dst = *input; input += 4; - dst++; + ++dst; *dst = *input; input += 4; - dst++; + ++dst; *dst = *input; input += 4; dst++; *dst = *input; input += 4; - dst++; + ++dst; } n += 3; } @@ -1999,7 +2004,7 @@ void vpImageConvert::split(const vpImage &src, vpImage *p for (; i < n; ++i) { *dst = *input; input += 4; - dst++; + ++dst; } } } @@ -2132,7 +2137,7 @@ void vpImageConvert::MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, un } // Bilinear - +#ifndef VISP_SKIP_BAYER_CONVERSION /*! Converts an array of uint8 Bayer data to an array of interleaved R, G, B and A values using bilinear demosaicing method. @@ -2422,3 +2427,8 @@ void vpImageConvert::demosaicRGGBToRGBaMalvar(const uint16_t *rggb, uint16_t *rg { demosaicRGGBToRGBaMalvarTpl(rggb, rgba, width, height, nThreads); } +#endif // VISP_SKIP_BAYER_CONVERSION + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpImageConvert_hsv.cpp b/modules/core/src/image/vpImageConvert_hsv.cpp index 187cba2c64..647093e36f 100644 --- a/modules/core/src/image/vpImageConvert_hsv.cpp +++ b/modules/core/src/image/vpImageConvert_hsv.cpp @@ -45,6 +45,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * Convert an HSV image to a RGB or RGBa image depending on the value of \e step. * \param[in] hue_ : Image hue channel in range [0,1]. @@ -555,3 +559,6 @@ void vpImageConvert::RGBToHSV(const unsigned char *rgb, unsigned char *hue, unsi { vpImageConvert::RGB2HSV(rgb, hue, saturation, value, size, 3, h_full); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpImageConvert_pcl.cpp b/modules/core/src/image/vpImageConvert_pcl.cpp index 072ec4814e..d588f81dbd 100644 --- a/modules/core/src/image/vpImageConvert_pcl.cpp +++ b/modules/core/src/image/vpImageConvert_pcl.cpp @@ -48,6 +48,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * Create a point cloud from a depth image. * @@ -281,4 +285,7 @@ int vpImageConvert::depthToPointCloud(const vpImage &color, const vpImag return pcl_size; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/src/image/vpImageConvert_yuv.cpp b/modules/core/src/image/vpImageConvert_yuv.cpp index bec8f5a03a..c0a1f11dfb 100644 --- a/modules/core/src/image/vpImageConvert_yuv.cpp +++ b/modules/core/src/image/vpImageConvert_yuv.cpp @@ -54,6 +54,10 @@ void vpSAT(int &c) } }; +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Convert an image from YUYV 4:2:2 (y0 u01 y1 v01 y2 u23 y3 v23 ...) to RGB32. Destination rgba memory area has to be allocated before. @@ -1662,3 +1666,6 @@ void vpImageConvert::YVU9ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned rgb += 9 * width; } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpImageFilter.cpp b/modules/core/src/image/vpImageFilter.cpp index 6658d1f44c..a4070fc528 100644 --- a/modules/core/src/image/vpImageFilter.cpp +++ b/modules/core/src/image/vpImageFilter.cpp @@ -36,6 +36,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /** * \brief Get the list of available vpCannyBackendType. * @@ -1128,3 +1132,6 @@ void vpImageFilter::canny(const vpImage &Isrc, vpImage #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Check if an image point belongs to a rectangle. @@ -451,3 +455,6 @@ double vpImagePoint::sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP { return vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j()); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpImageTools.cpp b/modules/core/src/image/vpImageTools.cpp index b4f180d622..e2867bfa7c 100644 --- a/modules/core/src/image/vpImageTools.cpp +++ b/modules/core/src/image/vpImageTools.cpp @@ -42,6 +42,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Change the look up table (LUT) of an image. Considering pixel gray level values \f$ l \f$ in the range \f$[A, B]\f$, this method allows @@ -155,7 +159,7 @@ void vpImageTools::imageDifference(const vpImage &I1, const vpIma SimdImageDifference(I1.bitmap, I2.bitmap, I1.getSize(), Idiff.bitmap); #else for (unsigned int i = 0; i < I1.getSize(); ++i) { - int diff = I1.bitmap[i] - I2.bitmap[i] + 128; + int diff = (I1.bitmap[i] - I2.bitmap[i]) + 128; Idiff.bitmap[i] = static_cast(std::max(std::min(diff, 255), 0)); } #endif @@ -191,11 +195,12 @@ void vpImageTools::imageDifference(const vpImage &I1, const vpImage(I1.bitmap), reinterpret_cast(I2.bitmap), I1.getSize() * 4, reinterpret_cast(Idiff.bitmap)); #else - for (unsigned int i = 0; i < I1.getSize() * 4; ++i) { - int diffR = I1.bitmap[i].R - I2.bitmap[i].R + 128; - int diffG = I1.bitmap[i].G - I2.bitmap[i].G + 128; - int diffB = I1.bitmap[i].B - I2.bitmap[i].B + 128; - int diffA = I1.bitmap[i].A - I2.bitmap[i].A + 128; + unsigned int i1_size = I1.getSize(); + for (unsigned int i = 0; i < (i1_size * 4); ++i) { + int diffR = (I1.bitmap[i].R - I2.bitmap[i].R) + 128; + int diffG = (I1.bitmap[i].G - I2.bitmap[i].G) + 128; + int diffB = (I1.bitmap[i].B - I2.bitmap[i].B) + 128; + int diffA = (I1.bitmap[i].A - I2.bitmap[i].A) + 128; Idiff.bitmap[i].R = static_cast(vpMath::maximum(vpMath::minimum(diffR, 255), 0)); Idiff.bitmap[i].G = static_cast(vpMath::maximum(vpMath::minimum(diffG, 255), 0)); Idiff.bitmap[i].B = static_cast(vpMath::maximum(vpMath::minimum(diffB, 255), 0)); @@ -328,8 +333,9 @@ void vpImageTools::imageAdd(const vpImage &I1, const vpImage((short int)*ptr_I1 + (short int)*ptr_I2) : *ptr_I1 + *ptr_I2; + unsigned int ires_size = Ires.getSize(); + for (unsigned int cpt = 0; cpt < ires_size; ++cpt, ++ptr_I1, ++ptr_I2, ++ptr_Ires) { + *ptr_Ires = saturate ? vpMath::saturate(static_cast(*ptr_I1) + static_cast(*ptr_I2)) : ((*ptr_I1) + (*ptr_I2)); } #endif } @@ -370,10 +376,11 @@ void vpImageTools::imageSubtract(const vpImage &I1, const vpImage unsigned char *ptr_I1 = I1.bitmap; unsigned char *ptr_I2 = I2.bitmap; unsigned char *ptr_Ires = Ires.bitmap; - for (unsigned int cpt = 0; cpt < Ires.getSize(); cpt++, ++ptr_I1, ++ptr_I2, ++ptr_Ires) { + unsigned int ires_size = Ires.getSize(); + for (unsigned int cpt = 0; cpt < ires_size; ++cpt, ++ptr_I1, ++ptr_I2, ++ptr_Ires) { *ptr_Ires = saturate ? vpMath::saturate(static_cast(*ptr_I1) - static_cast(*ptr_I2)) : - *ptr_I1 - *ptr_I2; + ((*ptr_I1) - (*ptr_I2)); } #endif } @@ -556,7 +563,8 @@ double vpImageTools::normalizedCorrelation(const vpImage &I1, const vpIm #if defined(VISP_HAVE_SIMDLIB) SimdNormalizedCorrelation(I1.bitmap, a, I2.bitmap, b, I1.getSize(), a2, b2, ab, useOptimized); #else - for (unsigned int cpt = 0; cpt < I1.getSize(); ++cpt) { + unsigned int i1_size = I1.getSize(); + for (unsigned int cpt = 0; cpt < i1_size; ++cpt) { ab += (I1.bitmap[cpt] - a) * (I2.bitmap[cpt] - b); a2 += vpMath::sqr(I1.bitmap[cpt] - a); b2 += vpMath::sqr(I2.bitmap[cpt] - b); @@ -833,8 +841,10 @@ double vpImageTools::normalizedCorrelation(const vpImage &I1, const vpIm #if defined(VISP_HAVE_SIMDLIB) SimdNormalizedCorrelation2(I1.bitmap, I1.getWidth(), I2.bitmap, I2.getWidth(), I2.getHeight(), i0, j0, ab); #else - for (unsigned int i = 0; i < I2.getHeight(); ++i) { - for (unsigned int j = 0; j < I2.getWidth(); ++j) { + unsigned int i2_height = I2.getHeight(); + unsigned int i2_width = I2.getWidth(); + for (unsigned int i = 0; i < i2_height; ++i) { + for (unsigned int j = 0; j < i2_width; ++j) { ab += (I1[i0 + i][j0 + j]) * I2[i][j]; } } @@ -924,7 +934,8 @@ void vpImageTools::remap(const vpImage &I, const vpArray2D &mapU, c mapV.data, mapDu.data, mapDv.data, reinterpret_cast(Iundist.bitmap)); #else const unsigned int i_ = static_cast(i); - for (unsigned int j = 0; j < I.getWidth(); ++j) { + unsigned int i_width = I.getWidth(); + for (unsigned int j = 0; j < i_width; ++j) { int u_round = mapU[i_][j]; int v_round = mapV[i_][j]; @@ -932,8 +943,8 @@ void vpImageTools::remap(const vpImage &I, const vpArray2D &mapU, c float du = mapDu[i_][j]; float dv = mapDv[i_][j]; - if (0 <= u_round && 0 <= v_round && u_round < static_cast(I.getWidth()) - 1 - && v_round < static_cast(I.getHeight()) - 1) { + if ((0 <= u_round) && (0 <= v_round) && (u_round < (static_cast(I.getWidth()) - 1)) + && (v_round < (static_cast(I.getHeight()) - 1))) { // process interpolation float col0 = lerp(I[v_round][u_round].R, I[v_round][u_round + 1].R, du); float col1 = lerp(I[v_round + 1][u_round].R, I[v_round + 1][u_round + 1].R, du); @@ -1184,3 +1195,6 @@ int vpImageTools::inRange(const unsigned char *hue, const unsigned char *saturat } return cpt_in_range; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpRGBa.cpp b/modules/core/src/image/vpRGBa.cpp index 3e8ec6a227..a46d1f5231 100644 --- a/modules/core/src/image/vpRGBa.cpp +++ b/modules/core/src/image/vpRGBa.cpp @@ -44,6 +44,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Copy operator (from an unsigned char value) @@ -258,3 +262,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba) os << "(" << static_cast(rgba.R) << "," << static_cast(rgba.G) << "," << static_cast(rgba.B) << "," << static_cast(rgba.A) << ")"; return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpRGBf.cpp b/modules/core/src/image/vpRGBf.cpp index 2979de6f81..ab4c977760 100644 --- a/modules/core/src/image/vpRGBf.cpp +++ b/modules/core/src/image/vpRGBf.cpp @@ -45,6 +45,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Copy operator (from a floating-point value) @@ -262,3 +266,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBf &rgb) os << "(" << rgb.R << "," << rgb.G << "," << rgb.B << ")"; return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpColVector.cpp b/modules/core/src/math/matrix/vpColVector.cpp index 35157bb1ae..0c72b2cd9a 100644 --- a/modules/core/src/math/matrix/vpColVector.cpp +++ b/modules/core/src/math/matrix/vpColVector.cpp @@ -57,6 +57,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif vpColVector vpColVector::operator+(const vpColVector &v) const { if (getRows() != v.getRows()) { @@ -1012,3 +1016,6 @@ void vpColVector::insert(const vpColVector &v, unsigned int r, unsigned int c) double vpColVector::euclideanNorm() const { return frobeniusNorm(); } #endif // defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpEigenConversion.cpp b/modules/core/src/math/matrix/vpEigenConversion.cpp index 075b99bd74..ee2e306856 100644 --- a/modules/core/src/math/matrix/vpEigenConversion.cpp +++ b/modules/core/src/math/matrix/vpEigenConversion.cpp @@ -35,7 +35,7 @@ #include -namespace vp +namespace VISP_EIGEN_CONVERSION_NAMESPACE { #ifdef VISP_HAVE_EIGEN3 /* Eigen to ViSP */ diff --git a/modules/core/src/math/matrix/vpMatrix.cpp b/modules/core/src/math/matrix/vpMatrix.cpp index 18fec0aecd..1ec2ee4f16 100644 --- a/modules/core/src/math/matrix/vpMatrix.cpp +++ b/modules/core/src/math/matrix/vpMatrix.cpp @@ -62,6 +62,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifdef VISP_HAVE_LAPACK #ifdef VISP_HAVE_GSL #include @@ -499,8 +503,8 @@ void vpMatrix::transpose(vpMatrix &At) const // https://stackoverflow.com/a/21548079 const int tileSize = 32; for (unsigned int i = 0; i < rowNum; i += tileSize) { - for (unsigned int j = 0; j < colNum; j++) { - for (unsigned int b = 0; b < static_cast(tileSize) && i + b < rowNum; b++) { + for (unsigned int j = 0; j < colNum; ++j) { + for (unsigned int b = 0; ((b < static_cast(tileSize)) && ((i + b) < rowNum)); ++b) { At[j][i + b] = (*this)[i + b][j]; } } @@ -4995,10 +4999,10 @@ vpColVector vpMatrix::getCol(unsigned int j) const { return getCol(j, 0, rowNum) A.print(std::cout, 4); - vpRowVector rv = A.getRow(1); - std::cout << "Row vector: \n" << rv << std::endl; +vpRowVector rv = A.getRow(1); +std::cout << "Row vector: \n" << rv << std::endl; } - \endcode +\endcode It produces the following output : \code [4, 4] = @@ -6722,3 +6726,6 @@ void vpMatrix::setIdentity(const double &val) } #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpMatrix_cholesky.cpp b/modules/core/src/math/matrix/vpMatrix_cholesky.cpp index 30ae5de122..a68d19f570 100644 --- a/modules/core/src/math/matrix/vpMatrix_cholesky.cpp +++ b/modules/core/src/math/matrix/vpMatrix_cholesky.cpp @@ -30,11 +30,7 @@ * * Description: * Matrix Cholesky decomposition. - * - * Authors: - * Filip Novotny - * -*****************************************************************************/ + */ #include @@ -71,6 +67,14 @@ extern "C" int dpotri_(char *uplo, integer *n, double *a, integer *lda, integer #endif #endif +#if defined(VISP_HAVE_EIGEN3) +#include +#endif + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Compute the inverse of a n-by-n matrix using the Cholesky decomposition. The matrix must be real symmetric positive defined. @@ -85,30 +89,29 @@ extern "C" int dpotri_(char *uplo, integer *n, double *a, integer *lda, integer Here an example: \code -#include + #include -int main() -{ - vpMatrix A(4,4); + int main() + { + vpMatrix A(4,4); - // Symmetric matrix - A[0][0] = 1/1.; A[0][1] = 1/5.; A[0][2] = 1/6.; A[0][3] = 1/7.; - A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.; - A[2][0] = 1/6.; A[2][1] = 1/3.; A[2][2] = 1/2.; A[2][3] = 1/6.; - A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.; + // Symmetric matrix + A[0][0] = 1/1.; A[0][1] = 1/5.; A[0][2] = 1/6.; A[0][3] = 1/7.; + A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.; + A[2][0] = 1/6.; A[2][1] = 1/3.; A[2][2] = 1/2.; A[2][3] = 1/6.; + A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.; - // Compute the inverse - vpMatrix A_1; // A^-1 - A_1 = A.inverseByCholesky(); - std::cout << "Inverse by Cholesky: \n" << A_1 << std::endl; + // Compute the inverse + vpMatrix A_1; // A^-1 + A_1 = A.inverseByCholesky(); + std::cout << "Inverse by Cholesky: \n" << A_1 << std::endl; - std::cout << "A*A^-1: \n" << A * A_1 << std::endl; -} + std::cout << "A*A^-1: \n" << A * A_1 << std::endl; + } \endcode \sa pseudoInverse() */ - vpMatrix vpMatrix::inverseByCholesky() const { #if defined(VISP_HAVE_LAPACK) @@ -123,36 +126,36 @@ vpMatrix vpMatrix::inverseByCholesky() const #if defined(VISP_HAVE_LAPACK) /*! Compute the inverse of a n-by-n matrix using the Cholesky decomposition with -Lapack 3rd party. The matrix must be real symmetric positive defined. + Lapack 3rd party. The matrix must be real symmetric positive defined. \return The inverse matrix. Here an example: \code -#include + #include -int main() -{ - unsigned int n = 4; - vpMatrix A(n, n); - vpMatrix I; - I.eye(4); + int main() + { + unsigned int n = 4; + vpMatrix A(n, n); + vpMatrix I; + I.eye(4); - A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.; - A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.; - A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.; - A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.; + A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.; + A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.; + A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.; + A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.; - // Make matrix symmetric positive - A = 0.5*(A+A.t()); - A = A + n*I; + // Make matrix symmetric positive + A = 0.5*(A+A.t()); + A = A + n*I; - // Compute the inverse - vpMatrix A_1 = A.inverseByCholeskyLapack(); - std::cout << "Inverse by Cholesky (Lapack): \n" << A_1 << std::endl; + // Compute the inverse + vpMatrix A_1 = A.inverseByCholeskyLapack(); + std::cout << "Inverse by Cholesky (Lapack): \n" << A_1 << std::endl; - std::cout << "A*A^-1: \n" << A * A_1 << std::endl; -} + std::cout << "A*A^-1: \n" << A * A_1 << std::endl; + } \endcode \sa inverseByCholesky(), inverseByCholeskyOpenCV() @@ -267,7 +270,7 @@ vpMatrix vpMatrix::choleskyByLapack()const } return L; } -#endif +#endif // VISP_HAVE_LAPACK #if defined(VISP_HAVE_OPENCV) /*! @@ -278,30 +281,30 @@ vpMatrix vpMatrix::choleskyByLapack()const Here an example: \code -#include + #include -int main() -{ - unsigned int n = 4; - vpMatrix A(n, n); - vpMatrix I; - I.eye(4); + int main() + { + unsigned int n = 4; + vpMatrix A(n, n); + vpMatrix I; + I.eye(4); - A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.; - A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.; - A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.; - A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.; + A[0][0] = 1/1.; A[0][1] = 1/2.; A[0][2] = 1/3.; A[0][3] = 1/4.; + A[1][0] = 1/5.; A[1][1] = 1/3.; A[1][2] = 1/3.; A[1][3] = 1/5.; + A[2][0] = 1/6.; A[2][1] = 1/4.; A[2][2] = 1/2.; A[2][3] = 1/6.; + A[3][0] = 1/7.; A[3][1] = 1/5.; A[3][2] = 1/6.; A[3][3] = 1/7.; - // Make matrix symmetric positive - A = 0.5*(A+A.t()); - A = A + n*I; + // Make matrix symmetric positive + A = 0.5*(A+A.t()); + A = A + n*I; - // Compute the inverse - vpMatrix A_1 = A.inverseByCholeskyOpenCV(); - std::cout << "Inverse by Cholesky (OpenCV): \n" << A_1 << std::endl; + // Compute the inverse + vpMatrix A_1 = A.inverseByCholeskyOpenCV(); + std::cout << "Inverse by Cholesky (OpenCV): \n" << A_1 << std::endl; - std::cout << "A*A^-1: \n" << A * A_1 << std::endl; -} + std::cout << "A*A^-1: \n" << A * A_1 << std::endl; + } \endcode \sa inverseByCholesky(), inverseByCholeskyLapack() @@ -349,10 +352,9 @@ vpMatrix vpMatrix::choleskyByOpenCV() const } return L; } -#endif +#endif // VISP_HAVE_OPENCV #if defined(VISP_HAVE_EIGEN3) -#include /*! * \brief Compute the Cholesky decomposition of a Hermitian positive-definite matrix * using Eigen3 library. @@ -378,4 +380,8 @@ vpMatrix vpMatrix::choleskyByEigen3() const } return Lvisp; } +#endif // VISP_HAVE_EIGEN3 + +#if defined(ENABLE_VISP_NAMESPACE) +} #endif diff --git a/modules/core/src/math/matrix/vpMatrix_covariance.cpp b/modules/core/src/math/matrix/vpMatrix_covariance.cpp index 1caa73ec38..9e3b044aef 100644 --- a/modules/core/src/math/matrix/vpMatrix_covariance.cpp +++ b/modules/core/src/math/matrix/vpMatrix_covariance.cpp @@ -46,6 +46,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Compute the covariance matrix of the parameters x from a least squares minimization defined as: Ax = b @@ -231,3 +235,6 @@ void vpMatrix::computeCovarianceMatrixVVS(const vpHomogeneousMatrix &cMo, const // building deltaP deltaP = Js.pseudoInverse(Js.getRows() * std::numeric_limits::epsilon()) * deltaS; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpMatrix_lu.cpp b/modules/core/src/math/matrix/vpMatrix_lu.cpp index 6b265f1f9f..7c42b094ae 100644 --- a/modules/core/src/math/matrix/vpMatrix_lu.cpp +++ b/modules/core/src/math/matrix/vpMatrix_lu.cpp @@ -74,6 +74,10 @@ extern "C" void dgetri_(integer *n, double *a, integer *lda, integer *ipiv, doub #include // std::fabs #include // numeric_limits +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*-------------------------------------------------------------------- LU Decomposition related functions -------------------------------------------------------------------- */ @@ -625,3 +629,6 @@ double vpMatrix::detByLUEigen3() const return M.determinant(); } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpMatrix_mul.cpp b/modules/core/src/math/matrix/vpMatrix_mul.cpp index 15a61f61f1..e0aecb1430 100644 --- a/modules/core/src/math/matrix/vpMatrix_mul.cpp +++ b/modules/core/src/math/matrix/vpMatrix_mul.cpp @@ -44,6 +44,10 @@ // or vector content in a gsl_matrix or gsl_vector. This is not acceptable here. // that's why we prefer use naive code when VISP_HAVE_GSL is defined. #if defined(VISP_HAVE_LAPACK) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifdef VISP_HAVE_MKL #include typedef MKL_INT integer; @@ -112,10 +116,13 @@ void vpMatrix::blas_dgemv(char trans, unsigned int M_, unsigned int N_, double a dgemv_(&trans, &M, &N, &alpha, a_data, &lda, x_data, &incx, &beta, y_data, &incy); } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #else // Work around to avoid warning LNK4221: This object file does not define any // previously undefined public symbols -void dummy_vpMatrix_blas(){}; +void dummy_vpMatrix_blas() { }; #endif #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/src/math/matrix/vpMatrix_qr.cpp b/modules/core/src/math/matrix/vpMatrix_qr.cpp index b770626cd3..f80a2e6b72 100644 --- a/modules/core/src/math/matrix/vpMatrix_qr.cpp +++ b/modules/core/src/math/matrix/vpMatrix_qr.cpp @@ -52,6 +52,10 @@ // Debug trace #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifdef VISP_HAVE_LAPACK #ifdef VISP_HAVE_GSL #if !(GSL_MAJOR_VERSION >= 2 && GSL_MINOR_VERSION >= 2) @@ -1208,3 +1212,6 @@ vpColVector vpMatrix::solveByQR(const vpColVector &b) const solveByQR(b, x); return x; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpMatrix_svd.cpp b/modules/core/src/math/matrix/vpMatrix_svd.cpp index f45551e674..7f5f5ec57a 100644 --- a/modules/core/src/math/matrix/vpMatrix_svd.cpp +++ b/modules/core/src/math/matrix/vpMatrix_svd.cpp @@ -73,6 +73,11 @@ extern "C" int dgesdd_(char *jobz, integer *m, integer *n, double *a, integer *l #include #endif #endif + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*--------------------------------------------------------------------- SVD related functions @@ -466,3 +471,6 @@ void vpMatrix::svdEigen3(vpColVector &w, vpMatrix &V) U_ = svd.matrixU(); } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpRowVector.cpp b/modules/core/src/math/matrix/vpRowVector.cpp index 464ff165c8..fb488de875 100644 --- a/modules/core/src/math/matrix/vpRowVector.cpp +++ b/modules/core/src/math/matrix/vpRowVector.cpp @@ -51,6 +51,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif //! Copy operator. Allow operation such as A = v vpRowVector &vpRowVector::operator=(const vpRowVector &v) { @@ -769,7 +773,7 @@ v: 0 10 11 3 */ void vpRowVector::insert(unsigned int i, const vpRowVector &v) { - if ( (i + v.size()) > this->size()) { + if ((i + v.size()) > this->size()) { throw(vpException(vpException::dimensionError, "Unable to insert (1x%d) row vector in (1x%d) row " "vector at position (%d)", @@ -1067,7 +1071,7 @@ int vpRowVector::print(std::ostream &s, unsigned int length, char const *intro) } else { assert(maxAfter > 1); - s.width( static_cast (maxAfter)); + s.width(static_cast (maxAfter)); s << ".0"; } } @@ -1366,3 +1370,6 @@ std::ostream &vpRowVector::matlabPrint(std::ostream &os) const os << "]" << std::endl; return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpSubColVector.cpp b/modules/core/src/math/matrix/vpSubColVector.cpp index bdebd53e90..b458ab47f0 100644 --- a/modules/core/src/math/matrix/vpSubColVector.cpp +++ b/modules/core/src/math/matrix/vpSubColVector.cpp @@ -41,6 +41,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif //! Default constructor that creates an empty vector. vpSubColVector::vpSubColVector() : vpColVector(), m_pRowNum(0), m_parent(nullptr) { } @@ -247,3 +251,6 @@ vpSubColVector &vpSubColVector::operator=(const vpPoseVector &p) memcpy(data, p.data, rowNum * sizeof(double)); return *this; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpSubMatrix.cpp b/modules/core/src/math/matrix/vpSubMatrix.cpp index 763980f7f4..2760aefcb4 100644 --- a/modules/core/src/math/matrix/vpSubMatrix.cpp +++ b/modules/core/src/math/matrix/vpSubMatrix.cpp @@ -42,6 +42,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif vpSubMatrix::vpSubMatrix() : pRowNum(0), pColNum(0), parent(nullptr) { } /*! @@ -180,3 +184,6 @@ vpSubMatrix &vpSubMatrix::operator=(const double &x) } vpSubMatrix::~vpSubMatrix() { data = nullptr; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpSubRowVector.cpp b/modules/core/src/math/matrix/vpSubRowVector.cpp index f826982e6d..6fb6181788 100644 --- a/modules/core/src/math/matrix/vpSubRowVector.cpp +++ b/modules/core/src/math/matrix/vpSubRowVector.cpp @@ -36,6 +36,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif //! Default constructor that creates an empty vector. vpSubRowVector::vpSubRowVector() : vpRowVector(), m_pColNum(0), m_parent(nullptr) { } @@ -181,3 +185,6 @@ vpSubRowVector &vpSubRowVector::operator=(const double &x) } return *this; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/misc/vpMath.cpp b/modules/core/src/math/misc/vpMath.cpp index 2e6683d478..b025958c7a 100644 --- a/modules/core/src/math/misc/vpMath.cpp +++ b/modules/core/src/math/misc/vpMath.cpp @@ -54,6 +54,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #if !(defined(VISP_HAVE_FUNC_ISNAN) || defined(VISP_HAVE_FUNC_STD_ISNAN)) || \ !(defined(VISP_HAVE_FUNC_ISINF) || defined(VISP_HAVE_FUNC_STD_ISINF)) || \ !(defined(VISP_HAVE_FUNC_ISFINITE) || defined(VISP_HAVE_FUNC_STD_ISFINITE) || defined(VISP_HAVE_FUNC__FINITE)) @@ -762,3 +766,6 @@ vpHomogeneousMatrix vpMath::enu2ned(const vpHomogeneousMatrix &enu_M) vpHomogeneousMatrix ned_M = ned_M_enu * enu_M; return ned_M; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/random-generator/vpUniRand.cpp b/modules/core/src/math/random-generator/vpUniRand.cpp index 10335a504a..31d2dfcbb7 100644 --- a/modules/core/src/math/random-generator/vpUniRand.cpp +++ b/modules/core/src/math/random-generator/vpUniRand.cpp @@ -69,6 +69,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif vpUniRand::vpUniRand() : m_maxInvDbl(1.0 / static_cast(UINT32_MAX)), m_maxInvFlt(1.0f / static_cast(UINT32_MAX)), m_rng() { } @@ -207,3 +211,6 @@ void vpUniRand::setSeed(uint64_t initstate, uint64_t initseq) m_rng.state += initstate; next(); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/robust/vpRobust.cpp b/modules/core/src/math/robust/vpRobust.cpp index c781df403b..b178661c48 100644 --- a/modules/core/src/math/robust/vpRobust.cpp +++ b/modules/core/src/math/robust/vpRobust.cpp @@ -53,6 +53,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Default constructor. */ @@ -705,3 +709,6 @@ double vpRobust::gammln(double xx) #undef vpEPS #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpExponentialMap.cpp b/modules/core/src/math/transformation/vpExponentialMap.cpp index 0fe64c478d..f1472dde02 100644 --- a/modules/core/src/math/transformation/vpExponentialMap.cpp +++ b/modules/core/src/math/transformation/vpExponentialMap.cpp @@ -38,6 +38,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Compute the exponential map. The inverse function is inverse(). The @@ -285,3 +289,6 @@ vpColVector vpExponentialMap::inverse(const vpHomogeneousMatrix &M, const double return v; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpForceTwistMatrix.cpp b/modules/core/src/math/transformation/vpForceTwistMatrix.cpp index 351d127eec..b97e0e8c77 100644 --- a/modules/core/src/math/transformation/vpForceTwistMatrix.cpp +++ b/modules/core/src/math/transformation/vpForceTwistMatrix.cpp @@ -34,13 +34,6 @@ * *****************************************************************************/ -#include -#include - -#include -#include -#include - /*! \file vpForceTwistMatrix.cpp @@ -49,6 +42,18 @@ transform a force/torque skew from one frame to an other. */ +#include +#include + +#include +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! Copy operator. @@ -788,3 +793,6 @@ int vpForceTwistMatrix::print(std::ostream &s, unsigned int length, char const * void vpForceTwistMatrix::setIdentity() { eye(); } #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +#if defined(ENABLE_VISP_NAMESPACE) + } +#endif diff --git a/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp b/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp index 206919ad22..8db2b1ab77 100644 --- a/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp +++ b/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp @@ -46,6 +46,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Construct an homogeneous matrix from a translation vector and quaternion rotation vector. @@ -1379,6 +1383,9 @@ void vpHomogeneousMatrix::convert_to_json(nlohmann::json &j) const void vpHomogeneousMatrix::parse_json(const nlohmann::json &j) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace visp; +#endif vpArray2D *asArray = (vpArray2D*) this; if (j.is_object() && j.contains("type")) { // Specific conversions const bool converted = convertFromTypeAndBuildFrom(j, *this); @@ -1398,3 +1405,6 @@ void vpHomogeneousMatrix::parse_json(const nlohmann::json &j) } } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpPoseVector.cpp b/modules/core/src/math/transformation/vpPoseVector.cpp index e2e517ce95..f2461ec9d2 100644 --- a/modules/core/src/math/transformation/vpPoseVector.cpp +++ b/modules/core/src/math/transformation/vpPoseVector.cpp @@ -49,6 +49,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! Default constructor that construct a 6 dimension pose vector \f$ [\bf t, @@ -610,6 +615,9 @@ void vpPoseVector::convert_to_json(nlohmann::json &j) const } void vpPoseVector::parse_json(const nlohmann::json &j) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace visp; +#endif vpArray2D *asArray = (vpArray2D*) this; if (j.is_object() && j.contains("type")) { // Specific conversions const bool converted = convertFromTypeAndBuildFrom(j, *this); @@ -626,3 +634,6 @@ void vpPoseVector::parse_json(const nlohmann::json &j) } } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpQuaternionVector.cpp b/modules/core/src/math/transformation/vpQuaternionVector.cpp index 53a9731800..2cd55c12a4 100644 --- a/modules/core/src/math/transformation/vpQuaternionVector.cpp +++ b/modules/core/src/math/transformation/vpQuaternionVector.cpp @@ -43,6 +43,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif // minimum value of sine const double vpQuaternionVector::minimum = 0.0001; @@ -549,3 +553,6 @@ vpQuaternionVector vpQuaternionVector::slerp(const vpQuaternionVector &q0, const return qSlerp; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpRotationMatrix.cpp b/modules/core/src/math/transformation/vpRotationMatrix.cpp index a0ca634dff..209d6a7e7b 100644 --- a/modules/core/src/math/transformation/vpRotationMatrix.cpp +++ b/modules/core/src/math/transformation/vpRotationMatrix.cpp @@ -52,6 +52,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Initialize the rotation matrix as identity. @@ -1138,3 +1142,6 @@ void vpRotationMatrix::orthogonalize() void vpRotationMatrix::setIdentity() { eye(); } #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpRotationVector.cpp b/modules/core/src/math/transformation/vpRotationVector.cpp index 3c895fccfd..e26688380d 100644 --- a/modules/core/src/math/transformation/vpRotationVector.cpp +++ b/modules/core/src/math/transformation/vpRotationVector.cpp @@ -33,6 +33,12 @@ * *****************************************************************************/ +/*! + \file vpRotationVector.cpp + \brief Class that consider the case of a generic rotation vector + (cannot be used as is !). +*/ + #include #include @@ -40,12 +46,10 @@ #include #include -/*! - \file vpRotationVector.cpp - \brief Class that consider the case of a generic rotation vector - (cannot be used as is !). -*/ - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Return the transpose of the rotation vector. @@ -162,7 +166,7 @@ tu: 0 1.570796327 3.141592654 */ vpRotationVector &vpRotationVector::operator,(double val) { - m_index++; + ++m_index; if (m_index >= size()) { throw(vpException(vpException::dimensionError, "Cannot set rotation vector out of bounds. It has only %d elements while you try to initialize " @@ -190,3 +194,6 @@ double vpRotationVector::sumSquare() const return sum_square; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpRxyzVector.cpp b/modules/core/src/math/transformation/vpRxyzVector.cpp index 144b236ea9..bc4a936f20 100644 --- a/modules/core/src/math/transformation/vpRxyzVector.cpp +++ b/modules/core/src/math/transformation/vpRxyzVector.cpp @@ -33,16 +33,20 @@ * Rxyz(phi,theta,psi) = Rot(x,phi)Rot(y,theta)Rot(z,psi). */ -#include - -#include - /*! \file vpRxyzVector.cpp \brief class that consider the case of the Rxyz angle parameterization for the rotation : Rxyz(phi,theta,psi) = Rot(x,phi)Rot(y,theta)Rot(z,psi) */ +#include + +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Default constructor that initialize all the 3 angles to zero. */ vpRxyzVector::vpRxyzVector() : vpRotationVector(3) { } @@ -322,3 +326,6 @@ vpRxyzVector &vpRxyzVector::operator=(const std::initializer_list &list) return *this; } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpRzyxVector.cpp b/modules/core/src/math/transformation/vpRzyxVector.cpp index 4dfc849933..b12de39431 100644 --- a/modules/core/src/math/transformation/vpRzyxVector.cpp +++ b/modules/core/src/math/transformation/vpRzyxVector.cpp @@ -34,8 +34,6 @@ * *****************************************************************************/ -#include -#include /*! \file vpRzyxVector.cpp \brief class that consider the case of the Rzyx angle parameterization for @@ -43,6 +41,13 @@ */ +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Default constructor that initialize all the 3 angles to zero. */ vpRzyxVector::vpRzyxVector() : vpRotationVector(3) { } @@ -338,3 +343,6 @@ vpRzyxVector &vpRzyxVector::operator=(const std::initializer_list &list) return *this; } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpRzyzVector.cpp b/modules/core/src/math/transformation/vpRzyzVector.cpp index 4de914d006..339533d40a 100644 --- a/modules/core/src/math/transformation/vpRzyzVector.cpp +++ b/modules/core/src/math/transformation/vpRzyzVector.cpp @@ -33,15 +33,19 @@ * Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) */ -#include -#include - /*! \file vpRzyzVector.cpp \brief class that consider the case of the Rzyz angle parameterization for the rotation : Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) */ +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Default constructor that initialize all the 3 angles to zero. */ vpRzyzVector::vpRzyzVector() : vpRotationVector(3) { } /*! Copy constructor. */ @@ -319,3 +323,6 @@ vpRzyzVector &vpRzyzVector::operator=(const std::initializer_list &list) return *this; } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpThetaUVector.cpp b/modules/core/src/math/transformation/vpThetaUVector.cpp index 7a6758ebcd..b4cc60c079 100644 --- a/modules/core/src/math/transformation/vpThetaUVector.cpp +++ b/modules/core/src/math/transformation/vpThetaUVector.cpp @@ -42,6 +42,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif const double vpThetaUVector::minimum = 0.0001; /*! Default constructor that initialize all the 3 angles to zero. */ @@ -616,3 +620,6 @@ vpThetaUVector &vpThetaUVector::operator=(const std::initializer_list &l return *this; } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpTranslationVector.cpp b/modules/core/src/math/transformation/vpTranslationVector.cpp index 32e71f7bc0..3082c0148d 100644 --- a/modules/core/src/math/transformation/vpTranslationVector.cpp +++ b/modules/core/src/math/transformation/vpTranslationVector.cpp @@ -32,16 +32,20 @@ * Translation vector. */ -#include -#include - -#include - /*! \file vpTranslationVector.cpp \brief Class that consider the case of a translation vector. */ +#include +#include + +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Construct a translation vector \f$ \bf t \f$ from 3 doubles. @@ -868,3 +872,6 @@ vpTranslationVector vpTranslationVector::mean(const std::vector -#include - -#include -#include - /*! \file vpVelocityTwistMatrix.cpp @@ -47,6 +41,16 @@ transform a velocity skew from one frame to an other. */ +#include +#include + +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Copy operator that allow to set a velocity twist matrix from an other one. @@ -719,3 +723,6 @@ int vpVelocityTwistMatrix::print(std::ostream &s, unsigned int length, char cons void vpVelocityTwistMatrix::setIdentity() { eye(); } #endif // #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp b/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp index edcff25c1d..42ea6c2d0b 100644 --- a/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp +++ b/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp @@ -62,6 +62,10 @@ #define LABEL_XML_TUY "theta_uy" #define LABEL_XML_TUZ "theta_uz" +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpXmlParserHomogeneousMatrix::Impl { @@ -556,7 +560,9 @@ void vpXmlParserHomogeneousMatrix::setHomogeneousMatrixName(const std::string &n { m_impl->setHomogeneousMatrixName(name); } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpXmlParserHomogeneousMatrix.cpp.o) has no symbols void dummy_vpXmlParserHomogeneousMatrix() { }; diff --git a/modules/core/src/tools/cpu-features/vpCPUFeatures.cpp b/modules/core/src/tools/cpu-features/vpCPUFeatures.cpp index 333d586e08..fa593cfb31 100644 --- a/modules/core/src/tools/cpu-features/vpCPUFeatures.cpp +++ b/modules/core/src/tools/cpu-features/vpCPUFeatures.cpp @@ -40,6 +40,10 @@ #endif #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif namespace vpCPUFeatures { // TODO: try to refactor to keep only SimdCpuInfo code and remove cpu_x86 code? @@ -71,3 +75,6 @@ bool checkNeon() { return SimdCpuInfo(SimdCpuInfoNeon) != 0; } void printCPUInfo() { cpu_features.print(); } } // namespace vpCPUFeatures +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/endian/vpEndian.cpp b/modules/core/src/tools/endian/vpEndian.cpp index 234e19f1c8..5166911f22 100644 --- a/modules/core/src/tools/endian/vpEndian.cpp +++ b/modules/core/src/tools/endian/vpEndian.cpp @@ -40,6 +40,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif namespace vpEndian { /*! @@ -64,7 +68,8 @@ uint32_t swap32bits(uint32_t val) */ float swapFloat(float f) { - union { + union + { float f; unsigned char b[4]; } dat1, dat2; @@ -83,7 +88,8 @@ float swapFloat(float f) */ double swapDouble(double d) { - union { + union + { double d; unsigned char b[8]; } dat1, dat2; @@ -116,3 +122,6 @@ uint16_t reinterpret_cast_uchar_to_uint16_LE(unsigned char *const ptr) #endif } } // namespace vpEndian +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/exceptions/vpException.cpp b/modules/core/src/tools/exceptions/vpException.cpp index 8dd97bf362..2c2ee7df09 100644 --- a/modules/core/src/tools/exceptions/vpException.cpp +++ b/modules/core/src/tools/exceptions/vpException.cpp @@ -39,9 +39,13 @@ #include "visp3/core/vpException.h" #include -vpException::vpException(int id) : code(id), message() {} +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif +vpException::vpException(int id) : code(id), message() { } -vpException::vpException(int id, const std::string &msg) : code(id), message(msg) {} +vpException::vpException(int id, const std::string &msg) : code(id), message(msg) { } vpException::vpException(int id, const char *format, ...) : code(id), message() { @@ -75,3 +79,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpException &error) return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/file/vpIoTools.cpp b/modules/core/src/tools/file/vpIoTools.cpp index 42cbd30975..cfdbb9c5e1 100644 --- a/modules/core/src/tools/file/vpIoTools.cpp +++ b/modules/core/src/tools/file/vpIoTools.cpp @@ -486,6 +486,10 @@ visp::cnpy::NpyArray visp::cnpy::npy_load(std::string fname) #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif std::string vpIoTools::baseName = ""; std::string vpIoTools::baseDir = ""; std::string vpIoTools::configFile = ""; @@ -498,6 +502,9 @@ const char vpIoTools::separator = #else '/'; #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif namespace { @@ -538,6 +545,10 @@ std::string &rtrim(std::string &s) } } // namespace +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Return build informations (OS, compiler, build flags, used 3rd parties...). */ @@ -2121,16 +2132,16 @@ std::string vpIoTools::toLowerCase(const std::string &input) out += std::tolower(*it); } return out; -} + } -/** - * @brief Return a upper-case version of the string \b input . - * Numbers and special characters stay the same - * - * @param input The input string for which we want to ensure that all the characters are in upper case. - * @return std::string A upper-case version of the string \b input, where - * numbers and special characters stay the same - */ + /** + * @brief Return a upper-case version of the string \b input . + * Numbers and special characters stay the same + * + * @param input The input string for which we want to ensure that all the characters are in upper case. + * @return std::string A upper-case version of the string \b input, where + * numbers and special characters stay the same + */ std::string vpIoTools::toUpperCase(const std::string &input) { std::string out; @@ -2142,16 +2153,16 @@ std::string vpIoTools::toUpperCase(const std::string &input) out += std::toupper(*it); } return out; -} + } -/*! - Returns the absolute path using realpath() on Unix systems or - GetFullPathName() on Windows systems. \return According to realpath() - manual, returns an absolute pathname that names the same file, whose - resolution does not involve '.', '..', or symbolic links for Unix systems. - According to GetFullPathName() documentation, retrieves the full path of the - specified file for Windows systems. - */ + /*! + Returns the absolute path using realpath() on Unix systems or + GetFullPathName() on Windows systems. \return According to realpath() + manual, returns an absolute pathname that names the same file, whose + resolution does not involve '.', '..', or symbolic links for Unix systems. + According to GetFullPathName() documentation, retrieves the full path of the + specified file for Windows systems. + */ std::string vpIoTools::getAbsolutePathname(const std::string &pathname) { @@ -2693,3 +2704,6 @@ bool vpIoTools::parseBoolean(std::string input) Remove leading and trailing whitespaces from a string. */ std::string vpIoTools::trim(std::string s) { return ltrim(rtrim(s)); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/geometry/vpPlane.cpp b/modules/core/src/tools/geometry/vpPlane.cpp index 1abdd1c96a..8837153155 100644 --- a/modules/core/src/tools/geometry/vpPlane.cpp +++ b/modules/core/src/tools/geometry/vpPlane.cpp @@ -43,6 +43,10 @@ #include // std::fabs #include // numeric_limits +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Copy operator. */ @@ -389,3 +393,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpPlane &p) { return (os << "(" << p.getA() << "," << p.getB() << "," << p.getC() << "," << p.getD() << ") "); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/geometry/vpPolygon.cpp b/modules/core/src/tools/geometry/vpPolygon.cpp index 1bc06c352a..969b6e4cbc 100644 --- a/modules/core/src/tools/geometry/vpPolygon.cpp +++ b/modules/core/src/tools/geometry/vpPolygon.cpp @@ -44,6 +44,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif // Local helper #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) @@ -696,3 +700,6 @@ unsigned int vpPolygon::getSize() const { return (static_cast(_corners.size())); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/geometry/vpRect.cpp b/modules/core/src/tools/geometry/vpRect.cpp index 8540789159..6bbe4c053e 100644 --- a/modules/core/src/tools/geometry/vpRect.cpp +++ b/modules/core/src/tools/geometry/vpRect.cpp @@ -42,6 +42,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Constructs a default rectangle with the \e top, \e left corner set to (0,0) and \e width and \e height set to 1. @@ -271,3 +275,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRect &r) os << r.getLeft() << ", " << r.getTop() << ", " << r.getWidth() << ", " << r.getHeight(); return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/geometry/vpRectOriented.cpp b/modules/core/src/tools/geometry/vpRectOriented.cpp index 794edeebec..fff4d2ca29 100644 --- a/modules/core/src/tools/geometry/vpRectOriented.cpp +++ b/modules/core/src/tools/geometry/vpRectOriented.cpp @@ -36,6 +36,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /// Default constructor. vpRectOriented::vpRectOriented() : m_center(), m_width(), m_height(), m_theta(), m_topLeft(), m_topRight(), m_bottomLeft(), m_bottomRight() @@ -246,3 +250,6 @@ bool vpRectOriented::isLeft(const vpImagePoint &pointToTest, const vpImagePoint double d = (a * pointToTest.get_i()) + (b * pointToTest.get_j()) + c; return (d > 0); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp b/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp index 8aca50972f..ce0445330e 100644 --- a/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp +++ b/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp @@ -50,6 +50,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpXmlParserRectOriented::Impl { @@ -203,7 +207,9 @@ void vpXmlParserRectOriented::save(const std::string &filename, bool append) { m vpRectOriented vpXmlParserRectOriented::getRectangle() const { return m_impl->getRectangle(); } void vpXmlParserRectOriented::setRectangle(const vpRectOriented &rectangle) { m_impl->setRectangle(rectangle); } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpXmlParserRectOriented.cpp.o) has no symbols void dummy_vpXmlParserRectOriented() { }; diff --git a/modules/core/src/tools/histogram/vpHistogram.cpp b/modules/core/src/tools/histogram/vpHistogram.cpp index ff93dc2f48..4c793a6b95 100644 --- a/modules/core/src/tools/histogram/vpHistogram.cpp +++ b/modules/core/src/tools/histogram/vpHistogram.cpp @@ -47,6 +47,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #if defined(VISP_HAVE_THREADS) #include @@ -1194,3 +1198,6 @@ bool vpHistogram::write(const char *filename) return true; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/histogram/vpHistogramPeak.cpp b/modules/core/src/tools/histogram/vpHistogramPeak.cpp index 42804768f6..ce74255e0a 100644 --- a/modules/core/src/tools/histogram/vpHistogramPeak.cpp +++ b/modules/core/src/tools/histogram/vpHistogramPeak.cpp @@ -43,15 +43,19 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Default constructor for a gray level histogram peak. */ -vpHistogramPeak::vpHistogramPeak() : level(0), value(0) {} +vpHistogramPeak::vpHistogramPeak() : level(0), value(0) { } /*! Default constructor for a gray level histogram peak. */ -vpHistogramPeak::vpHistogramPeak(unsigned char lvl, unsigned val) : level(lvl), value(val) {} +vpHistogramPeak::vpHistogramPeak(unsigned char lvl, unsigned val) : level(lvl), value(val) { } /*! Copy constructor of a gray level histogram peak. @@ -96,7 +100,9 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramPeak &p) return s; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/core/src/tools/histogram/vpHistogramValey.cpp b/modules/core/src/tools/histogram/vpHistogramValey.cpp index 2a0f14f78f..e980cd4b94 100644 --- a/modules/core/src/tools/histogram/vpHistogramValey.cpp +++ b/modules/core/src/tools/histogram/vpHistogramValey.cpp @@ -43,6 +43,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Copy operator. @@ -84,7 +88,9 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramValey &v) return s; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/core/src/tools/time/vpTime.cpp b/modules/core/src/tools/time/vpTime.cpp index d4250259d8..be8c492df6 100644 --- a/modules/core/src/tools/time/vpTime.cpp +++ b/modules/core/src/tools/time/vpTime.cpp @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + \file vpTime.cpp + \brief Time management and measurement +*/ + #include #include @@ -46,11 +51,6 @@ #define USE_CXX11_CHRONO 0 #endif -/*! - \file vpTime.cpp - \brief Time management and measurement -*/ - // Unix depend version #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX @@ -61,6 +61,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS namespace vpTime { @@ -210,17 +214,17 @@ int wait(double t0, double t) "vpTime::wait() is not implemented on Windows Phone 8.0")); #endif #endif + } } -} -/*! - Wait t miliseconds from now. + /*! + Wait t miliseconds from now. - The waiting is done by a call to usleep() if the time to wait is greater - than vpTime::minTimeForUsleepCall. + The waiting is done by a call to usleep() if the time to wait is greater + than vpTime::minTimeForUsleepCall. - \param t : Time to wait in ms. -*/ + \param t : Time to wait in ms. + */ void wait(double t) { double timeToWait = t; @@ -261,14 +265,14 @@ void wait(double t) "vpTime::wait() is not implemented on Windows Phone 8.0")); #endif #endif + } } -} -/*! - Sleep t miliseconds from now. + /*! + Sleep t miliseconds from now. - \param t : Time to sleep in ms. -*/ + \param t : Time to sleep in ms. + */ void sleepMs(double t) { #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX @@ -419,3 +423,6 @@ void vpChrono::stop() m_durationMs += vpTime::measureTimeMs() - m_lastTimePoint; #endif } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tracking/forward-projection/vpCircle.cpp b/modules/core/src/tracking/forward-projection/vpCircle.cpp index a5674ba4fa..e3b3c6805f 100644 --- a/modules/core/src/tracking/forward-projection/vpCircle.cpp +++ b/modules/core/src/tracking/forward-projection/vpCircle.cpp @@ -37,6 +37,10 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif void vpCircle::init() { oP.resize(7); @@ -432,3 +436,6 @@ void vpCircle::computeIntersectionPoint(const vpCircle &circle, const vpCameraPa (ctheta * n11 * Yg)) + (ctheta3 * n11 * Yg) + (ctheta * n02 * Xg)) - (ctheta3 * n02 * Xg)) / (((n20 * ctheta2) + (2.0 * n11 * stheta * ctheta) + n02) - (n02 * ctheta2)) / stheta); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp b/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp index 285008782e..cd9792d3c4 100644 --- a/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp +++ b/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp @@ -33,14 +33,18 @@ * *****************************************************************************/ -#include -#include - /*! \file vpForwardProjection.cpp \brief class that defines what is a point */ +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Print to stdout the feature parameters in: - the object frame @@ -101,3 +105,6 @@ void vpForwardProjection::project(const vpHomogeneousMatrix &cMo) */ void vpForwardProjection::track(const vpHomogeneousMatrix &cMo) { project(cMo); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tracking/forward-projection/vpLine.cpp b/modules/core/src/tracking/forward-projection/vpLine.cpp index 2d7a7113c3..b94db57cc5 100644 --- a/modules/core/src/tracking/forward-projection/vpLine.cpp +++ b/modules/core/src/tracking/forward-projection/vpLine.cpp @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + \file vpLine.cpp + \brief class that defines what is a line +*/ + #include #include @@ -40,11 +45,10 @@ #include -/*! - \file vpLine.cpp - \brief class that defines what is a line -*/ - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Initialize the memory space requested for the 2D line parameters (\e @@ -549,3 +553,6 @@ vpLine *vpLine::duplicate() const vpLine *feature = new vpLine(*this); return feature; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tracking/forward-projection/vpPoint.cpp b/modules/core/src/tracking/forward-projection/vpPoint.cpp index 2767575b43..a630200556 100644 --- a/modules/core/src/tracking/forward-projection/vpPoint.cpp +++ b/modules/core/src/tracking/forward-projection/vpPoint.cpp @@ -33,15 +33,19 @@ * *****************************************************************************/ -#include -#include -#include - /*! \file vpPoint.cpp \brief Class that defines what is a 3D point. */ +#include +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif void vpPoint::init() { p.resize(3); @@ -506,3 +510,6 @@ void vpPoint::set_x(double x) { p[0] = x; } void vpPoint::set_y(double y) { p[1] = y; } //! Set the point w coordinate in the image plane. void vpPoint::set_w(double w) { p[2] = w; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tracking/forward-projection/vpSphere.cpp b/modules/core/src/tracking/forward-projection/vpSphere.cpp index 1f892dd383..93185d70b9 100644 --- a/modules/core/src/tracking/forward-projection/vpSphere.cpp +++ b/modules/core/src/tracking/forward-projection/vpSphere.cpp @@ -36,6 +36,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * Initialize internal sphere parameters. */ @@ -297,3 +301,6 @@ void vpSphere::display(const vpImage &I, const vpCameraParameters &cam, { vpFeatureDisplay::displayEllipse(p[0], p[1], p[2], p[3], p[4], cam, I, color, thickness); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tracking/vpTracker.cpp b/modules/core/src/tracking/vpTracker.cpp index e0ec1f0e6f..9562d74b8c 100644 --- a/modules/core/src/tracking/vpTracker.cpp +++ b/modules/core/src/tracking/vpTracker.cpp @@ -33,17 +33,22 @@ * *****************************************************************************/ -#include -#include - /*! \file vpTracker.cpp \brief Class that defines what is a generic tracker. */ +#include +#include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + void vpTracker::init() { cPAvailable = false; } -vpTracker::vpTracker() : p(), cP(), cPAvailable(false) {} +vpTracker::vpTracker() : p(), cP(), cPAvailable(false) { } vpTracker::vpTracker(const vpTracker &tracker) : p(), cP(), cPAvailable(false) { *this = tracker; } @@ -55,7 +60,9 @@ vpTracker &vpTracker::operator=(const vpTracker &tracker) return *this; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/detection/include/visp3/detection/vpDetectorAprilTag.h b/modules/detection/include/visp3/detection/vpDetectorAprilTag.h index 7169c5007b..8cb4ee8bd1 100644 --- a/modules/detection/include/visp3/detection/vpDetectorAprilTag.h +++ b/modules/detection/include/visp3/detection/vpDetectorAprilTag.h @@ -46,6 +46,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpDetectorAprilTag * \ingroup group_detection_tag @@ -418,5 +423,9 @@ inline std::ostream &operator<<(std::ostream &os, const vpDetectorAprilTag::vpAp return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif #endif diff --git a/modules/detection/include/visp3/detection/vpDetectorBase.h b/modules/detection/include/visp3/detection/vpDetectorBase.h index ceb1496a7c..19d663fae2 100644 --- a/modules/detection/include/visp3/detection/vpDetectorBase.h +++ b/modules/detection/include/visp3/detection/vpDetectorBase.h @@ -45,6 +45,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpDetectorBase * \ingroup group_detection_barcode group_detection_face @@ -131,4 +136,8 @@ class VISP_EXPORT vpDetectorBase //@} }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/detection/src/tag/vpDetectorAprilTag.cpp b/modules/detection/src/tag/vpDetectorAprilTag.cpp index eeea0d89b8..f06310baf5 100644 --- a/modules/detection/src/tag/vpDetectorAprilTag.cpp +++ b/modules/detection/src/tag/vpDetectorAprilTag.cpp @@ -60,6 +60,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpDetectorAprilTag::Impl { @@ -1203,6 +1208,10 @@ void vpDetectorAprilTag::setZAlignedWithCameraAxis(bool zAlignedWithCameraFrame) m_impl->setZAlignedWithCameraAxis(zAlignedWithCameraFrame); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpDetectorAprilTag.cpp.o) has // no symbols diff --git a/modules/detection/src/vpDetectorBase.cpp b/modules/detection/src/vpDetectorBase.cpp index f69d44149f..a070e8380a 100644 --- a/modules/detection/src/vpDetectorBase.cpp +++ b/modules/detection/src/vpDetectorBase.cpp @@ -35,9 +35,13 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! - Default constructor. + Default constructor. */ vpDetectorBase::vpDetectorBase() : m_polygon(), m_message(), m_nb_objects(0), m_timeout_ms(0) { } @@ -120,3 +124,7 @@ vpRect vpDetectorBase::getBBox(size_t i) const vpRect roi(vpImagePoint(top, left), vpImagePoint(bottom, right)); return roi; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/gui/include/visp3/gui/vpD3DRenderer.h b/modules/gui/include/visp3/gui/vpD3DRenderer.h index e3629d060c..38e4d17bb6 100644 --- a/modules/gui/include/visp3/gui/vpD3DRenderer.h +++ b/modules/gui/include/visp3/gui/vpD3DRenderer.h @@ -31,15 +31,14 @@ * D3D renderer for windows 32 display */ -#ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifndef VPD3DRENDERER_HH +#define VPD3DRENDERER_HH #include +#ifndef DOXYGEN_SHOULD_SKIP_THIS #if (defined(VISP_HAVE_D3D9)) -#ifndef VPD3DRENDERER_HH -#define VPD3DRENDERER_HH - // Include WinSock2.h before windows.h to ensure that winsock.h is not // included by windows.h since winsock.h and winsock2.h are incompatible #include @@ -50,6 +49,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpD3DRenderer.h * @@ -189,5 +193,10 @@ class VISP_EXPORT vpD3DRenderer : public vpWin32Renderer unsigned int supPowerOf2(unsigned int n); }; #endif + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayD3D.h b/modules/gui/include/visp3/gui/vpDisplayD3D.h index b2cde98f8b..6b9318da08 100644 --- a/modules/gui/include/visp3/gui/vpDisplayD3D.h +++ b/modules/gui/include/visp3/gui/vpDisplayD3D.h @@ -31,15 +31,20 @@ * Windows 32 display using D3D */ -#include -#include -#if (defined(VISP_HAVE_D3D9)) - #ifndef VPDISPLAYD3D_HH #define VPDISPLAYD3D_HH +#include +#if (defined(VISP_HAVE_D3D9)) + +#include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpDisplayD3D * @@ -110,5 +115,9 @@ class VISP_EXPORT vpDisplayD3D : public vpDisplayWin32 vpScaleType type = SCALE_DEFAULT); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayGDI.h b/modules/gui/include/visp3/gui/vpDisplayGDI.h index 83477dd799..a250f4a3dd 100644 --- a/modules/gui/include/visp3/gui/vpDisplayGDI.h +++ b/modules/gui/include/visp3/gui/vpDisplayGDI.h @@ -35,16 +35,23 @@ * Bruno Renier * *****************************************************************************/ -#include -#include -#if (defined(VISP_HAVE_GDI)) #ifndef vpDisplayGDI_HH #define vpDisplayGDI_HH +#include + +#if (defined(VISP_HAVE_GDI)) + +#include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpDisplayGDI * @@ -137,5 +144,8 @@ class VISP_EXPORT vpDisplayGDI : public vpDisplayWin32 vpScaleType type = SCALE_DEFAULT); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayGTK.h b/modules/gui/include/visp3/gui/vpDisplayGTK.h index ea4b093bc7..a32b26b578 100644 --- a/modules/gui/include/visp3/gui/vpDisplayGTK.h +++ b/modules/gui/include/visp3/gui/vpDisplayGTK.h @@ -40,6 +40,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \file vpDisplayGTK.h * \brief Define the GTK console to display images. @@ -228,5 +233,8 @@ class VISP_EXPORT vpDisplayGTK : public vpDisplay Impl *m_impl; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayOpenCV.h b/modules/gui/include/visp3/gui/vpDisplayOpenCV.h index 30d552c592..c3a5e76d96 100644 --- a/modules/gui/include/visp3/gui/vpDisplayOpenCV.h +++ b/modules/gui/include/visp3/gui/vpDisplayOpenCV.h @@ -47,6 +47,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \file vpDisplayOpenCV.h * \brief Define the OpenCV console to display images. @@ -262,5 +267,8 @@ class VISP_EXPORT vpDisplayOpenCV : public vpDisplay void overlay(std::function overlay_function, double opacity); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayWin32.h b/modules/gui/include/visp3/gui/vpDisplayWin32.h index 958a3fbd96..d2cc1a2d3c 100644 --- a/modules/gui/include/visp3/gui/vpDisplayWin32.h +++ b/modules/gui/include/visp3/gui/vpDisplayWin32.h @@ -31,13 +31,14 @@ * Windows 32 display base class */ -#include - -#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9)) #ifndef vpDisplayWin32_hh #define vpDisplayWin32_hh +#include + +#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9)) + #include #include @@ -51,6 +52,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS /*! * Used to pass parameters to the window's thread. @@ -187,5 +193,9 @@ class VISP_EXPORT vpDisplayWin32 : public vpDisplay void waitForInit(); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayX.h b/modules/gui/include/visp3/gui/vpDisplayX.h index b7582422da..4482aae482 100644 --- a/modules/gui/include/visp3/gui/vpDisplayX.h +++ b/modules/gui/include/visp3/gui/vpDisplayX.h @@ -40,6 +40,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \file vpDisplayX.h * \brief Define the X11 console to display images. @@ -224,5 +229,8 @@ class VISP_EXPORT vpDisplayX : public vpDisplay Impl *m_impl; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpGDIRenderer.h b/modules/gui/include/visp3/gui/vpGDIRenderer.h index ea195e1e9f..54d19d4703 100644 --- a/modules/gui/include/visp3/gui/vpGDIRenderer.h +++ b/modules/gui/include/visp3/gui/vpGDIRenderer.h @@ -36,12 +36,14 @@ * *****************************************************************************/ -#include -#if (defined(VISP_HAVE_GDI)) #ifndef vpGDIRenderer_HH #define vpGDIRenderer_HH +#include + +#if (defined(VISP_HAVE_GDI)) + #ifndef DOXYGEN_SHOULD_SKIP_THIS // Include WinSock2.h before windows.h to ensure that winsock.h is not @@ -56,6 +58,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class VISP_EXPORT vpGDIRenderer : public vpWin32Renderer { // the handle of the associated window @@ -130,6 +137,10 @@ class VISP_EXPORT vpGDIRenderer : public vpWin32Renderer // converst a vpImage into a HBITMAP . void convertROI(const vpImage &I, const vpImagePoint &iP, unsigned int width, unsigned int height); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpPlot.h b/modules/gui/include/visp3/gui/vpPlot.h index 1124417aeb..088025d02e 100644 --- a/modules/gui/include/visp3/gui/vpPlot.h +++ b/modules/gui/include/visp3/gui/vpPlot.h @@ -44,6 +44,12 @@ #include #if defined(VISP_HAVE_DISPLAY) + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpPlot * \ingroup group_gui_plotter @@ -192,6 +198,10 @@ class VISP_EXPORT vpPlot void initNbGraph(unsigned int nbGraph); void displayGrid(); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpPlotCurve.h b/modules/gui/include/visp3/gui/vpPlotCurve.h index 51f2a868a8..f811c3cd7a 100644 --- a/modules/gui/include/visp3/gui/vpPlotCurve.h +++ b/modules/gui/include/visp3/gui/vpPlotCurve.h @@ -51,6 +51,11 @@ #if defined(VISP_HAVE_DISPLAY) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpPlotCurve { public: @@ -80,6 +85,10 @@ class vpPlotCurve void plotList(const vpImage &I, double xorg, double yorg, double zoomx, double zoomy); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpPlotGraph.h b/modules/gui/include/visp3/gui/vpPlotGraph.h index 935e4c15f9..b87f052d8d 100644 --- a/modules/gui/include/visp3/gui/vpPlotGraph.h +++ b/modules/gui/include/visp3/gui/vpPlotGraph.h @@ -33,11 +33,13 @@ * *****************************************************************************/ -#ifndef DOXYGEN_SHOULD_SKIP_THIS - #ifndef vpPlotGraph_H #define vpPlotGraph_H +#include + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + #include #include @@ -52,6 +54,11 @@ #if defined(VISP_HAVE_DISPLAY) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpPlotGraph { public: @@ -216,6 +223,10 @@ class vpPlotGraph void setUnitZ(const std::string &unitz); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpProjectionDisplay.h b/modules/gui/include/visp3/gui/vpProjectionDisplay.h index 77adced801..4fcd663d80 100644 --- a/modules/gui/include/visp3/gui/vpProjectionDisplay.h +++ b/modules/gui/include/visp3/gui/vpProjectionDisplay.h @@ -57,6 +57,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! \class vpProjectionDisplay \ingroup group_gui_projection @@ -95,18 +100,18 @@ class VISP_EXPORT vpProjectionDisplay vpProjectionDisplay() : Icam(), Iext(), #if defined(VISP_HAVE_DISPLAY) - dIcam(), dIext(), + dIcam(), dIext(), #endif - listFp(), o(), x(), y(), z(), traj() + listFp(), o(), x(), y(), z(), traj() { init(); } explicit vpProjectionDisplay(int select) : Icam(), Iext(), #if defined(VISP_HAVE_DISPLAY) - dIcam(), dIext(), + dIcam(), dIext(), #endif - listFp(), o(), x(), y(), z(), traj() + listFp(), o(), x(), y(), z(), traj() { init(select); } @@ -127,11 +132,9 @@ class VISP_EXPORT vpProjectionDisplay vpMatrix traj; }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff --git a/modules/gui/include/visp3/gui/vpWin32API.h b/modules/gui/include/visp3/gui/vpWin32API.h index fa11987a69..8d8c36a2b4 100644 --- a/modules/gui/include/visp3/gui/vpWin32API.h +++ b/modules/gui/include/visp3/gui/vpWin32API.h @@ -49,6 +49,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + DWORD vpProcessErrors(const std::string &api_name); void vpSelectObject(HWND hWnd, HDC hDC, HDC hDCMem, HGDIOBJ h); void vpPrepareImageWithPen(CRITICAL_SECTION *CriticalSection, HWND hWnd, HBITMAP bmp, COLORREF color, @@ -63,5 +68,9 @@ BOOL vpBitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC BOOL vpInvalidateRect(HWND hWnd, const RECT *lpRect, BOOL bErase); COLORREF vpSetPixel(HDC hdc, int X, int Y, COLORREF crColor); HBITMAP vpCreateBitmap(int nWidth, int nHeight, UINT cPlanes, UINT cBitsPerPel, const VOID *lpvBits); + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpWin32Renderer.h b/modules/gui/include/visp3/gui/vpWin32Renderer.h index b169c57b4f..90231c57ae 100644 --- a/modules/gui/include/visp3/gui/vpWin32Renderer.h +++ b/modules/gui/include/visp3/gui/vpWin32Renderer.h @@ -36,13 +36,14 @@ * *****************************************************************************/ -#include - -#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9)) #ifndef vpWin32Renderer_HH #define vpWin32Renderer_HH +#include + +#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9)) + #ifndef DOXYGEN_SHOULD_SKIP_THIS #include @@ -53,6 +54,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class VISP_EXPORT vpWin32Renderer { @@ -63,9 +69,9 @@ class VISP_EXPORT vpWin32Renderer unsigned int m_rscale; public: - vpWin32Renderer() : m_rwidth(0), m_rheight(0), m_rscale(1){}; + vpWin32Renderer() : m_rwidth(0), m_rheight(0), m_rscale(1) { }; //! Destructor. - virtual ~vpWin32Renderer(){}; + virtual ~vpWin32Renderer() { }; //! Inits the display . virtual bool init(HWND hWnd, unsigned int w, unsigned int h) = 0; @@ -171,6 +177,10 @@ class VISP_EXPORT vpWin32Renderer virtual void getImage(vpImage &I) = 0; }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpWin32Window.h b/modules/gui/include/visp3/gui/vpWin32Window.h index 1e97ad6e0f..2b7c35863a 100644 --- a/modules/gui/include/visp3/gui/vpWin32Window.h +++ b/modules/gui/include/visp3/gui/vpWin32Window.h @@ -37,11 +37,12 @@ * *****************************************************************************/ +#ifndef vpWin32Window_HH +#define vpWin32Window_HH + #include #if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9)) -#ifndef vpWin32Window_HH -#define vpWin32Window_HH #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -54,6 +55,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + // ViSP-defined messages for window's callback function #define vpWM_GETCLICK WM_USER + 1 #define vpWM_DISPLAY WM_USER + 2 @@ -134,6 +140,9 @@ class VISP_EXPORT vpWin32Window friend LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif #endif diff --git a/modules/gui/src/display/vpDisplayGTK.cpp b/modules/gui/src/display/vpDisplayGTK.cpp index 8ce48e314b..19b4bda8f8 100644 --- a/modules/gui/src/display/vpDisplayGTK.cpp +++ b/modules/gui/src/display/vpDisplayGTK.cpp @@ -68,6 +68,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + class vpDisplayGTK::Impl { public: @@ -1588,7 +1593,11 @@ unsigned int vpDisplayGTK::getScreenHeight() return height; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpDisplayGTK.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpDisplayGTK.cpp.o) has no symbols void dummy_vpDisplayGTK() { }; #endif diff --git a/modules/gui/src/display/vpDisplayOpenCV.cpp b/modules/gui/src/display/vpDisplayOpenCV.cpp index 73f3a52d91..69b66b627f 100644 --- a/modules/gui/src/display/vpDisplayOpenCV.cpp +++ b/modules/gui/src/display/vpDisplayOpenCV.cpp @@ -65,6 +65,11 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #ifndef CV_RGB #define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0) #endif @@ -1789,7 +1794,11 @@ void vpDisplayOpenCV::overlay(std::function overlay_function, d } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpDisplayOpenCV.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpDisplayOpenCV.cpp.o) has no symbols void dummy_vpDisplayOpenCV() { }; #endif diff --git a/modules/gui/src/display/vpDisplayX.cpp b/modules/gui/src/display/vpDisplayX.cpp index 8f4517c4a0..7390c30073 100644 --- a/modules/gui/src/display/vpDisplayX.cpp +++ b/modules/gui/src/display/vpDisplayX.cpp @@ -66,6 +66,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + // Work around to use this class with Eigen3 #ifdef Success #undef Success // See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=253 @@ -2660,7 +2665,11 @@ bool vpDisplayX::getPointerPosition(vpImagePoint &ip) return ret; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpDisplayX.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpDisplayX.cpp.o) has no symbols void dummy_vpDisplayX() { }; #endif diff --git a/modules/gui/src/display/windows/vpD3DRenderer.cpp b/modules/gui/src/display/windows/vpD3DRenderer.cpp index 0ab06eb0e1..5f72aeb4a6 100644 --- a/modules/gui/src/display/windows/vpD3DRenderer.cpp +++ b/modules/gui/src/display/windows/vpD3DRenderer.cpp @@ -35,17 +35,23 @@ * Bruno Renier * *****************************************************************************/ -#ifndef DOXYGEN_SHOULD_SKIP_THIS #include #include + #if (defined(_WIN32) & defined(VISP_HAVE_D3D9)) +#ifndef DOXYGEN_SHOULD_SKIP_THIS #include #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /* Be careful, when using : @@ -1190,8 +1196,12 @@ void vpD3DRenderer::getImage(vpImage &I) } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpD3DRenderer.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpD3DRenderer.cpp.o) has no symbols void dummy_vpD3DRenderer() { }; #endif #endif diff --git a/modules/gui/src/display/windows/vpDisplayD3D.cpp b/modules/gui/src/display/windows/vpDisplayD3D.cpp index 2d13fb9151..60914444c0 100644 --- a/modules/gui/src/display/windows/vpDisplayD3D.cpp +++ b/modules/gui/src/display/windows/vpDisplayD3D.cpp @@ -47,6 +47,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \brief Basic constructor. */ @@ -188,7 +192,11 @@ vpDisplayD3D::vpDisplayD3D(vpImage &I, int winx, int winy, const init(I, winx, winy, title); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpDisplayD3D.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpDisplayD3D.cpp.o) has no symbols void dummy_vpDisplayD3D() { }; #endif diff --git a/modules/gui/src/display/windows/vpDisplayGDI.cpp b/modules/gui/src/display/windows/vpDisplayGDI.cpp index b96086d321..048ebe993a 100644 --- a/modules/gui/src/display/windows/vpDisplayGDI.cpp +++ b/modules/gui/src/display/windows/vpDisplayGDI.cpp @@ -46,6 +46,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + // A vpDisplayGDI is just a vpDisplayWin32 which uses a vpGDIRenderer to do // the drawing. @@ -188,7 +193,11 @@ vpDisplayGDI::vpDisplayGDI(vpImage &I, int winx, int winy, const init(I, winx, winy, title); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpDisplayGDI.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpDisplayGDI.cpp.o) has no symbols void dummy_vpDisplayGDI() { }; #endif diff --git a/modules/gui/src/display/windows/vpDisplayWin32.cpp b/modules/gui/src/display/windows/vpDisplayWin32.cpp index 551fe65770..6c73236e57 100644 --- a/modules/gui/src/display/windows/vpDisplayWin32.cpp +++ b/modules/gui/src/display/windows/vpDisplayWin32.cpp @@ -43,6 +43,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + const int vpDisplayWin32::MAX_INIT_DELAY = 5000; /*! @@ -919,7 +924,12 @@ unsigned int vpDisplayWin32::getScreenHeight() getScreenSize(width, height); return height; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpDisplayWin32.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpDisplayWin32.cpp.o) has no symbols void dummy_vpDisplayWin32() { }; #endif diff --git a/modules/gui/src/display/windows/vpGDIRenderer.cpp b/modules/gui/src/display/windows/vpGDIRenderer.cpp index cea70d073f..b82667120c 100644 --- a/modules/gui/src/display/windows/vpGDIRenderer.cpp +++ b/modules/gui/src/display/windows/vpGDIRenderer.cpp @@ -44,6 +44,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! Constructor. */ @@ -1027,8 +1032,12 @@ void vpGDIRenderer::getImage(vpImage &I) delete[] imBuffer; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpGDIRenderer.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpGDIRenderer.cpp.o) has no symbols void dummy_vpGDIRenderer() { }; #endif diff --git a/modules/gui/src/display/windows/vpWin32API.cpp b/modules/gui/src/display/windows/vpWin32API.cpp index ca65e445bd..27d5d66637 100644 --- a/modules/gui/src/display/windows/vpWin32API.cpp +++ b/modules/gui/src/display/windows/vpWin32API.cpp @@ -42,6 +42,12 @@ #if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9)) #include #include + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + DWORD vpProcessErrors(const std::string &api_name) { LPVOID lpMsgBuf; @@ -135,7 +141,11 @@ HBITMAP vpCreateBitmap(int nWidth, int nHeight, UINT cPlanes, UINT cBitsPerPel, return ret; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpWin32API.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpWin32API.cpp.o) has no symbols void dummy_vpWin32API() { }; #endif diff --git a/modules/gui/src/display/windows/vpWin32Window.cpp b/modules/gui/src/display/windows/vpWin32Window.cpp index 2dd7d3c0d4..9102b6327a 100644 --- a/modules/gui/src/display/windows/vpWin32Window.cpp +++ b/modules/gui/src/display/windows/vpWin32Window.cpp @@ -48,6 +48,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + // Should be already defined ... #ifndef GET_X_LPARAM #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) @@ -311,8 +316,12 @@ void vpWin32Window::initWindow(const char *title, int posx, int posy, unsigned i } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpWin32Window.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpWin32Window.cpp.o) has no symbols void dummy_vpWin32Window() { }; #endif diff --git a/modules/gui/src/forward-projection/vpProjectionDisplay.cpp b/modules/gui/src/forward-projection/vpProjectionDisplay.cpp index 39d0db1553..e912f04d14 100644 --- a/modules/gui/src/forward-projection/vpProjectionDisplay.cpp +++ b/modules/gui/src/forward-projection/vpProjectionDisplay.cpp @@ -57,6 +57,11 @@ //#include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + void vpProjectionDisplay::insert(vpForwardProjection &fp) { // vpForwardProjection *f ; @@ -88,7 +93,7 @@ void vpProjectionDisplay::init(const int select) init(); } -void vpProjectionDisplay::close() {} +void vpProjectionDisplay::close() { } void vpProjectionDisplay::display(vpImage &I, const vpHomogeneousMatrix &cextMo, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &color, @@ -145,8 +150,12 @@ void vpProjectionDisplay::displayCamera(vpImage &I, const vpHomog vpDisplay::displayArrow(I, ipo, ip, vpColor::blue, 4 + thickness, 2 + thickness, thickness); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpProjectionDisplay.cpp.o) +// Work around to avoid warning: libvisp_gui.a(vpProjectionDisplay.cpp.o) // has no symbols -void dummy_vpProjectionDisplay(){}; +void dummy_vpProjectionDisplay() { }; #endif diff --git a/modules/gui/src/plot/vpPlot.cpp b/modules/gui/src/plot/vpPlot.cpp index da074c1a12..f4ff388c93 100644 --- a/modules/gui/src/plot/vpPlot.cpp +++ b/modules/gui/src/plot/vpPlot.cpp @@ -49,6 +49,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! Default constructor. @@ -727,7 +732,11 @@ void vpPlot::saveData(unsigned int graphNum, const std::string &dataFile, const fichier.close(); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpPlot.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpPlot.cpp.o) has no symbols void dummy_vpPlot() { }; #endif diff --git a/modules/gui/src/plot/vpPlotCurve.cpp b/modules/gui/src/plot/vpPlotCurve.cpp index ea4c221f73..98402c0ebb 100644 --- a/modules/gui/src/plot/vpPlotCurve.cpp +++ b/modules/gui/src/plot/vpPlotCurve.cpp @@ -44,6 +44,12 @@ #include #if defined(VISP_HAVE_DISPLAY) + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + vpPlotCurve::vpPlotCurve() : color(vpColor::red), curveStyle(point), thickness(1), nbPoint(0), lastPoint(), pointListx(), pointListy(), pointListz(), legend(), xmin(0), xmax(0), ymin(0), ymax(0) @@ -114,8 +120,12 @@ void vpPlotCurve::plotList(const vpImage &I, double xorg, double } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpPlotCurve.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpPlotCurve.cpp.o) has no symbols void dummy_vpPlotCurve() { }; #endif #endif diff --git a/modules/gui/src/plot/vpPlotGraph.cpp b/modules/gui/src/plot/vpPlotGraph.cpp index 40f68ff083..b543224bbc 100644 --- a/modules/gui/src/plot/vpPlotGraph.cpp +++ b/modules/gui/src/plot/vpPlotGraph.cpp @@ -54,6 +54,11 @@ #if defined(VISP_HAVE_DISPLAY) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + int laFonctionSansNom(double delta); void getGrid3DPoint(double pente, vpImagePoint &iPunit, vpImagePoint &ip1, vpImagePoint &ip2, vpImagePoint &ip3); @@ -1338,8 +1343,12 @@ vpHomogeneousMatrix vpPlotGraph::navigation(const vpImage &I, boo return mov; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) -// Work around to avoid warning: libvisp_core.a(vpPlotGraph.cpp.o) has no symbols +// Work around to avoid warning: libvisp_gui.a(vpPlotGraph.cpp.o) has no symbols void dummy_vpPlotGraph() { }; #endif #endif diff --git a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h index d006d836c4..97dd15945a 100644 --- a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h +++ b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h @@ -51,6 +51,11 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /** * \ingroup group_hough_transform * \brief Class that permits to detect 2D circles in a image using @@ -1281,4 +1286,9 @@ class VISP_EXPORT vpCircleHoughTransform std::vector m_finalCircleVotes; /*!< Number of votes for the final circles.*/ std::vector > > m_finalCirclesVotingPoints; /*!< Points that voted for each final circle.*/ }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/imgproc/include/visp3/imgproc/vpContours.h b/modules/imgproc/include/visp3/imgproc/vpContours.h index 8531f0c0f0..743ff1952b 100644 --- a/modules/imgproc/include/visp3/imgproc/vpContours.h +++ b/modules/imgproc/include/visp3/imgproc/vpContours.h @@ -74,9 +74,13 @@ #include #include - -namespace +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +namespace vp +#else +namespace visp +#endif { + /*! * Possible directions to find a contour. */ @@ -141,7 +145,7 @@ struct vpDirection { vpDirection direction; int directionSize = LAST_DIRECTION; - direction.m_direction = vpDirectionType(((int)m_direction + 1) % directionSize); + direction.m_direction = vpDirectionType((static_cast(m_direction) + 1) % directionSize); return direction; } @@ -153,8 +157,8 @@ struct vpDirection vpDirection counterClockwise() { vpDirection direction; - int directionSize = (int)LAST_DIRECTION; - int idx = vpMath::modulo((int)m_direction - 1, directionSize); + int directionSize = static_cast(LAST_DIRECTION); + int idx = vpMath::modulo(static_cast(m_direction) - 1, directionSize); direction.m_direction = vpDirectionType(idx); return direction; @@ -168,10 +172,10 @@ struct vpDirection */ vpImagePoint active(const vpImage &I, const vpImagePoint &point) { - int yy = (int)(point.get_i() + m_diry[(int)m_direction]); - int xx = (int)(point.get_j() + m_dirx[(int)m_direction]); + int yy = static_cast(point.get_i() + m_diry[static_cast(m_direction)]); + int xx = static_cast(point.get_j() + m_dirx[static_cast(m_direction)]); - if (xx < 0 || xx >= (int)I.getWidth() || yy < 0 || yy >= (int)I.getHeight()) { + if ((xx < 0) || (xx >= static_cast(I.getWidth())) || (yy < 0) || (yy >= static_cast(I.getHeight()))) { return vpImagePoint(-1, -1); } @@ -179,10 +183,7 @@ struct vpDirection return pixel != 0 ? vpImagePoint(yy, xx) : vpImagePoint(-1, -1); } }; -} // namespace -namespace vp -{ /*! * Type of contour. */ @@ -220,12 +221,12 @@ struct vpContour /*! * Default constructor. */ - vpContour() : m_children(), m_contourType(vp::CONTOUR_HOLE), m_parent(nullptr), m_points() { } + vpContour() : m_children(), m_contourType(CONTOUR_HOLE), m_parent(nullptr), m_points() { } /*! * Constructor of a given contour type. */ - vpContour(const vpContourType &type) : m_children(), m_contourType(type), m_parent(nullptr), m_points() { } + explicit vpContour(const vpContourType &type) : m_children(), m_contourType(type), m_parent(nullptr), m_points() { } /*! * Copy constructor. @@ -235,7 +236,8 @@ struct vpContour { // Copy the underlying contours - for (std::vector::const_iterator it = contour.m_children.begin(); it != contour.m_children.end(); + std::vector::const_iterator contour_m_children_end = contour.m_children.end(); + for (std::vector::const_iterator it = contour.m_children.begin(); it != contour_m_children_end; ++it) { vpContour *copy = new vpContour(**it); copy->m_parent = this; @@ -248,7 +250,8 @@ struct vpContour */ virtual ~vpContour() { - for (std::vector::iterator it = m_children.begin(); it != m_children.end(); ++it) { + std::vector::iterator m_children_end = m_children.end(); + for (std::vector::iterator it = m_children.begin(); it != m_children_end; ++it) { (*it)->m_parent = nullptr; if (*it != nullptr) { delete *it; @@ -266,7 +269,8 @@ struct vpContour if (m_parent == nullptr) { // We are a root or an uninitialized contour so delete everything - for (std::vector::iterator it = m_children.begin(); it != m_children.end(); ++it) { + std::vector::iterator m_children_end = m_children.end(); + for (std::vector::iterator it = m_children.begin(); it != m_children_end; ++it) { (*it)->m_parent = nullptr; if (*it != nullptr) { delete *it; @@ -281,7 +285,8 @@ struct vpContour } m_children.clear(); - for (std::vector::const_iterator it = other.m_children.begin(); it != other.m_children.end(); ++it) { + std::vector::const_iterator other_m_children_end = other.m_children.end(); + for (std::vector::const_iterator it = other.m_children.begin(); it != other_m_children_end; ++it) { vpContour *copy = new vpContour(**it); copy->m_parent = this; m_children.push_back(copy); @@ -340,7 +345,8 @@ VISP_EXPORT void drawContours(vpImage &I, const std::vector &I_original, vpContour &contours, std::vector > &contourPts, - const vpContourRetrievalType &retrievalMode = vp::CONTOUR_RETR_TREE); -} // namespace vp + const vpContourRetrievalType &retrievalMode = CONTOUR_RETR_TREE); + +} // namespace #endif diff --git a/modules/imgproc/include/visp3/imgproc/vpImgproc.h b/modules/imgproc/include/visp3/imgproc/vpImgproc.h index 45997739fe..a2c315ac5f 100644 --- a/modules/imgproc/include/visp3/imgproc/vpImgproc.h +++ b/modules/imgproc/include/visp3/imgproc/vpImgproc.h @@ -45,10 +45,17 @@ #include #include -#define USE_OLD_FILL_HOLE 0 +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS +#define VISP_IMGPROC_NAMESPACE vp +#else +#define VISP_IMGPROC_NAMESPACE visp +#endif -namespace vp +namespace VISP_IMGPROC_NAMESPACE { + +#define USE_OLD_FILL_HOLE 0 + /*! * Retinex level that allows to specifies distribution * of the Gaussian blurring kernel sizes for scale division values > 2. @@ -126,7 +133,7 @@ VISP_EXPORT std::string vpGammaMethodList(const std::string &pref = "<", const s const std::string &suf = ">"); /** - * \brief Cast a \b vp::vpGammaMethod into a string, to know its name. + * \brief Cast a \b vpGammaMethod into a string, to know its name. * * \param[in] type The type that must be casted into a string. * \return std::string The corresponding name. @@ -134,10 +141,10 @@ VISP_EXPORT std::string vpGammaMethodList(const std::string &pref = "<", const s VISP_EXPORT std::string vpGammaMethodToString(const vpGammaMethod &type); /** - * \brief Cast a string into a \b vp::vpGammaMethod. + * \brief Cast a string into a \b vpGammaMethod. * * \param[in] name The name of the backend. - * \return vp::vpGammaMethod The corresponding enumeration value. + * \return vpGammaMethod The corresponding enumeration value. */ VISP_EXPORT vpGammaMethod vpGammaMethodFromString(const std::string &name); @@ -164,7 +171,7 @@ VISP_EXPORT std::string vpGammaColorHandlingList(const std::string &pref = "<", const std::string &suf = ">"); /** - * \brief Cast a \b vp::vpGammaColorHandling into a string, to know its name. + * \brief Cast a \b vpGammaColorHandling into a string, to know its name. * * \param[in] type The type that must be casted into a string. * \return std::string The corresponding name. @@ -172,10 +179,10 @@ VISP_EXPORT std::string vpGammaColorHandlingList(const std::string &pref = "<", VISP_EXPORT std::string vpGammaColorHandlingToString(const vpGammaColorHandling &type); /** - * \brief Cast a string into a \b vp::vpGammaColorHandling. + * \brief Cast a string into a \b vpGammaColorHandling. * * \param[in] name The name of the backend. - * \return vp::vpGammaColorHandling The corresponding enumeration value. + * \return vpGammaColorHandling The corresponding enumeration value. */ VISP_EXPORT vpGammaColorHandling vpGammaColorHandlingFromString(const std::string &name); @@ -363,7 +370,7 @@ VISP_EXPORT void equalizeHistogram(const vpImage &I1, vpImage &I * \param[in] p_mask : If different from nullptr, permits to indicate which points must be taken into account by setting * them to true. */ -VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, const vpGammaMethod &method = vp::GAMMA_MANUAL, +VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, const vpGammaMethod &method = GAMMA_MANUAL, const vpImage *p_mask = nullptr); /*! @@ -383,7 +390,7 @@ VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, * them to true. */ VISP_EXPORT void gammaCorrection(const vpImage &I1, vpImage &I2, const float &gamma, - const vpGammaMethod &method = vp::GAMMA_MANUAL, const vpImage *p_mask = nullptr); + const vpGammaMethod &method = GAMMA_MANUAL, const vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_gamma @@ -398,8 +405,8 @@ VISP_EXPORT void gammaCorrection(const vpImage &I1, vpImage &I, const float &gamma, const vpGammaColorHandling &colorHandling = vp::GAMMA_RGB, - const vpGammaMethod &method = vp::GAMMA_MANUAL, const vpImage *p_mask = nullptr); +VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, const vpGammaColorHandling &colorHandling = GAMMA_RGB, + const vpGammaMethod &method = GAMMA_MANUAL, const vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_gamma @@ -416,8 +423,8 @@ VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, const v * them to true. */ VISP_EXPORT void gammaCorrection(const vpImage &I1, vpImage &I2, const float &gamma, - const vpGammaColorHandling &colorHandling = vp::GAMMA_RGB, - const vpGammaMethod &method = vp::GAMMA_MANUAL, const vpImage *p_mask = nullptr); + const vpGammaColorHandling &colorHandling = GAMMA_RGB, + const vpGammaMethod &method = GAMMA_MANUAL, const vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_retinex @@ -648,9 +655,10 @@ VISP_EXPORT void reconstruct(const vpImage &marker, const vpImage * \param backgroundValue : Value to set to the background. * \param foregroundValue : Value to set to the foreground. */ -VISP_EXPORT unsigned char autoThreshold(vpImage &I, const vp::vpAutoThresholdMethod &method, +VISP_EXPORT unsigned char autoThreshold(vpImage &I, const vpAutoThresholdMethod &method, const unsigned char backgroundValue = 0, const unsigned char foregroundValue = 255); -} // namespace vp + +} // namespace #endif diff --git a/modules/imgproc/src/vpCLAHE.cpp b/modules/imgproc/src/vpCLAHE.cpp index 5bea19d052..38ff57d97a 100644 --- a/modules/imgproc/src/vpCLAHE.cpp +++ b/modules/imgproc/src/vpCLAHE.cpp @@ -79,8 +79,13 @@ #include #include -namespace +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +namespace vp +#else +namespace visp +#endif { + int fastRound(float value) { return static_cast(value + 0.5f); } void clipHistogram(const std::vector &hist, std::vector &clippedHist, int limit) @@ -191,10 +196,7 @@ float transferValue(int v, const std::vector &hist, std::vector &clipp return transferValue(v, clippedHist); } -} // namespace -namespace vp -{ void clahe(const vpImage &I1, vpImage &I2, int blockRadius, int bins, float slope, bool fast) { if (blockRadius < 0) { @@ -481,4 +483,5 @@ void clahe(const vpImage &I1, vpImage &I2, int blockRadius, int ++cpt; } } -}; + +} // namespace diff --git a/modules/imgproc/src/vpCircleHoughTransform.cpp b/modules/imgproc/src/vpCircleHoughTransform.cpp index e88fa70ff7..ecc7fb43a1 100644 --- a/modules/imgproc/src/vpCircleHoughTransform.cpp +++ b/modules/imgproc/src/vpCircleHoughTransform.cpp @@ -33,13 +33,16 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + // Static variables const unsigned char vpCircleHoughTransform::edgeMapOn = 255; const unsigned char vpCircleHoughTransform::edgeMapOff = 0; #if (VISP_CXX_STANDARD == VISP_CXX_STANDARD_98) -namespace -{ // Sorting by decreasing probabilities bool hasBetterProba(std::pair a, std::pair b) { @@ -92,7 +95,6 @@ scaleFilter(vpArray2D &filter, const float &scale) } } } -}; #endif vpCircleHoughTransform::vpCircleHoughTransform() @@ -1203,3 +1205,7 @@ operator<<(std::ostream &os, const vpCircleHoughTransform &detector) os << detector.toString(); return os; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/imgproc/src/vpConnectedComponents.cpp b/modules/imgproc/src/vpConnectedComponents.cpp index be93d2e98e..aa0adb3f3b 100644 --- a/modules/imgproc/src/vpConnectedComponents.cpp +++ b/modules/imgproc/src/vpConnectedComponents.cpp @@ -39,8 +39,13 @@ #include #include -namespace +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +namespace vp +#else +namespace visp +#endif { + void getNeighbors(const vpImage &I, std::queue &listOfNeighbors, unsigned int i, unsigned int j, const vpImageMorphology::vpConnexityType &connexity) { @@ -100,10 +105,7 @@ void visitNeighbors(vpImage &I_copy, std::queue &li } } } -} // namespace -namespace vp -{ void connectedComponents(const vpImage &I, vpImage &labels, int &nbComponents, const vpImageMorphology::vpConnexityType &connexity) { if (I.getSize() == 0) { @@ -161,4 +163,5 @@ void connectedComponents(const vpImage &I, vpImage &labels, nbComponents = current_label - 1; } -}; + +} // namespace diff --git a/modules/imgproc/src/vpContours.cpp b/modules/imgproc/src/vpContours.cpp index b982b3669b..0a195f0208 100644 --- a/modules/imgproc/src/vpContours.cpp +++ b/modules/imgproc/src/vpContours.cpp @@ -70,8 +70,13 @@ #include #include -namespace +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +namespace vp +#else +namespace visp +#endif { + bool fromTo(const vpImagePoint &from, const vpImagePoint &to, vpDirection &direction) { if (from == to) { @@ -131,7 +136,7 @@ bool crossesEastBorder(const vpImage &I, bool checked[8], const vpImagePoin return (I[i][j] != 0) && ((static_cast(point.get_j()) == (I.getWidth() - 1)) || b); } -void addContourPoint(vpImage &I, vp::vpContour *border, const vpImagePoint &point, bool checked[8], int nbd) +void addContourPoint(vpImage &I, vpContour *border, const vpImagePoint &point, bool checked[8], int nbd) { border->m_points.push_back(vpImagePoint(point.get_i() - 1, point.get_j() - 1)); // remove 1-pixel padding @@ -147,7 +152,7 @@ void addContourPoint(vpImage &I, vp::vpContour *border, const vpImagePoint } // Otherwise leave it alone } -void followBorder(vpImage &I, const vpImagePoint &ij, vpImagePoint &i2j2, vp::vpContour *border, int nbd) +void followBorder(vpImage &I, const vpImagePoint &ij, vpImagePoint &i2j2, vpContour *border, int nbd) { vpDirection dir; if (!fromTo(ij, i2j2, dir)) { @@ -234,25 +239,22 @@ bool isHoleBorderStart(const vpImage &I, unsigned int i, unsigned int j) return ((I[i][j] >= 1) && ((j == (I.getWidth() - 1)) || (I[i][j + 1] == 0))); } -void getContoursList(const vp::vpContour &root, int level, vp::vpContour &contour_list) +void getContoursList(const vpContour &root, int level, vpContour &contour_list) { if ((level > 0) && (level < std::numeric_limits::max())) { - vp::vpContour *contour_node = new vp::vpContour; + vpContour *contour_node = new vpContour; contour_node->m_contourType = root.m_contourType; contour_node->m_points = root.m_points; contour_list.m_children.push_back(contour_node); } - std::vector::const_iterator root_m_children_end = root.m_children.end(); - for (std::vector::const_iterator it = root.m_children.begin(); it != root_m_children_end; ++it) { + std::vector::const_iterator root_m_children_end = root.m_children.end(); + for (std::vector::const_iterator it = root.m_children.begin(); it != root_m_children_end; ++it) { getContoursList(**it, level + 1, contour_list); } } -} // namespace -namespace vp -{ void drawContours(vpImage &I, const std::vector > &contours, unsigned char grayValue) { if (I.getSize() == 0) { @@ -325,7 +327,7 @@ void findContours(const vpImage &I_original, vpContour &contours, // Background contour // By default the root contour is a hole contour - vpContour *root = new vpContour(vp::CONTOUR_HOLE); + vpContour *root = new vpContour(CONTOUR_HOLE); std::map borderMap; borderMap[lnbd] = root; @@ -348,16 +350,16 @@ void findContours(const vpImage &I_original, vpContour &contours, //(1) (a) ++nbd; from.set_j(from.get_j() - 1); - border->m_contourType = vp::CONTOUR_OUTER; + border->m_contourType = CONTOUR_OUTER; borderPrime = borderMap[lnbd]; // Table 1 switch (borderPrime->m_contourType) { - case vp::CONTOUR_OUTER: + case CONTOUR_OUTER: border->setParent(borderPrime->m_parent); break; - case vp::CONTOUR_HOLE: + case CONTOUR_HOLE: border->setParent(borderPrime); break; @@ -375,15 +377,15 @@ void findContours(const vpImage &I_original, vpContour &contours, borderPrime = borderMap[lnbd]; from.set_j(from.get_j() + 1); - border->m_contourType = vp::CONTOUR_HOLE; + border->m_contourType = CONTOUR_HOLE; // Table 1 switch (borderPrime->m_contourType) { - case vp::CONTOUR_OUTER: + case CONTOUR_OUTER: border->setParent(borderPrime); break; - case vp::CONTOUR_HOLE: + case CONTOUR_HOLE: border->setParent(borderPrime->m_parent); break; @@ -469,4 +471,5 @@ void findContours(const vpImage &I_original, vpContour &contours, delete root; root = nullptr; } -}; + +} // namespace diff --git a/modules/imgproc/src/vpFloodFill.cpp b/modules/imgproc/src/vpFloodFill.cpp index 34cf9c037f..368b8e2a88 100644 --- a/modules/imgproc/src/vpFloodFill.cpp +++ b/modules/imgproc/src/vpFloodFill.cpp @@ -66,8 +66,13 @@ #include #include +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp +#else +namespace visp +#endif { + void floodFill(vpImage &I, const vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const vpImageMorphology::vpConnexityType &connexity) { @@ -159,4 +164,5 @@ void floodFill(vpImage &I, const vpImagePoint &seedPoint, const u } } } -}; + +} // namespace diff --git a/modules/imgproc/src/vpImgproc.cpp b/modules/imgproc/src/vpImgproc.cpp index ff25389262..91ebeb8f9c 100644 --- a/modules/imgproc/src/vpImgproc.cpp +++ b/modules/imgproc/src/vpImgproc.cpp @@ -64,8 +64,9 @@ #include #include -namespace vp +namespace VISP_IMGPROC_NAMESPACE { + std::string vpGammaMethodList(const std::string &pref, const std::string &sep, const std::string &suf) { std::string list(pref); @@ -87,22 +88,22 @@ std::string vpGammaMethodToString(const vpGammaMethod &type) case GAMMA_MANUAL: name = "gamma_manual"; break; - case GAMMA_LOG_BASED: + case GAMMA_LOG_BASED: name = "gamma_log"; break; - case GAMMA_NONLINEAR_BASED: + case GAMMA_NONLINEAR_BASED: name = "gamma_nonlinear"; break; - case GAMMA_CDF_BASED: + case GAMMA_CDF_BASED: name = "gamma_cdf"; break; - case GAMMA_CLASSIFICATION_BASED: + case GAMMA_CLASSIFICATION_BASED: name = "gamma_classification"; break; - case GAMMA_SPATIAL_VARIANT_BASED: + case GAMMA_SPATIAL_VARIANT_BASED: name = "gamma_spatial_variant"; break; - case GAMMA_METHOD_COUNT: + case GAMMA_METHOD_COUNT: default: name = "gamma_method_unknown"; } @@ -144,13 +145,13 @@ std::string vpGammaColorHandlingToString(const vpGammaColorHandling &type) { std::string name; switch (type) { - case GAMMA_RGB: + case GAMMA_RGB: name = "gamma_color_rgb"; break; - case GAMMA_HSV: + case GAMMA_HSV: name = "gamma_color_hsv"; break; - case GAMMA_COLOR_HANDLING_COUNT: + case GAMMA_COLOR_HANDLING_COUNT: default: name = "gamma_color_unknown"; } @@ -191,7 +192,7 @@ void adjust(const vpImage &I1, vpImage &I2, double // Copy I1 to I2 I2 = I1; - vp::adjust(I2, alpha, beta); + adjust(I2, alpha, beta); } void adjust(vpImage &I, double alpha, double beta) @@ -214,13 +215,13 @@ void adjust(const vpImage &I1, vpImage &I2, double alpha, double // Copy I1 to I2 I2 = I1; - vp::adjust(I2, alpha, beta); + adjust(I2, alpha, beta); } void equalizeHistogram(vpImage &I, const vpImage *p_mask) { vpImage Icpy = I; - vp::equalizeHistogram(Icpy, I, p_mask); + equalizeHistogram(Icpy, I, p_mask); } void equalizeHistogram(const vpImage &I1, vpImage &I2, @@ -252,11 +253,11 @@ void equalizeHistogram(vpImage &I, bool useHSV) vpImageConvert::split(I, &pR, &pG, &pB, &pa); // Apply histogram equalization for each channel - vp::equalizeHistogram(pR); - vp::equalizeHistogram(pG); - vp::equalizeHistogram(pB); + equalizeHistogram(pR); + equalizeHistogram(pG); + equalizeHistogram(pB); - // Merge the result in I + // Merge the result in I unsigned int size = I.getWidth() * I.getHeight(); unsigned char *ptrStart = reinterpret_cast(I.bitmap); unsigned char *ptrEnd = ptrStart + (size * 4); @@ -290,9 +291,9 @@ void equalizeHistogram(vpImage &I, bool useHSV) reinterpret_cast(saturation.bitmap), reinterpret_cast(value.bitmap), size); // Histogram equalization on the value plane - vp::equalizeHistogram(value); + equalizeHistogram(value); - // Convert from HSV to RGBa + // Convert from HSV to RGBa vpImageConvert::HSVToRGBa(reinterpret_cast(hue.bitmap), reinterpret_cast(saturation.bitmap), reinterpret_cast(value.bitmap), reinterpret_cast(I.bitmap), size); } @@ -301,11 +302,9 @@ void equalizeHistogram(vpImage &I, bool useHSV) void equalizeHistogram(const vpImage &I1, vpImage &I2, bool useHSV) { I2 = I1; - vp::equalizeHistogram(I2, useHSV); + equalizeHistogram(I2, useHSV); } -namespace -{ /** * \brief This method is an implementation of the article "Towards Real-time Hardware Gamma Correction * for Dynamic Contrast Enhancement" by Jesse Scott, Michael Pusateri, IEEE Applied Imagery Pattern Recognition @@ -596,12 +595,11 @@ void gammaCorrectionSpatialBased(vpImage &I, const vpImage *p_mask } } } -} void gammaCorrection(vpImage &I, const float &gamma, const vpGammaMethod &method, const vpImage *p_mask) { float inverse_gamma = 1.0; - if ((gamma > 0) && (method == GAMMA_MANUAL)) { + if ((gamma > 0) && (method == GAMMA_MANUAL)) { inverse_gamma = 1.0f / gamma; // Construct the look-up table unsigned char lut[256]; @@ -611,7 +609,7 @@ void gammaCorrection(vpImage &I, const float &gamma, const vpGamm I.performLut(lut); } - else if (method == GAMMA_MANUAL) { + else if (method == GAMMA_MANUAL) { std::stringstream errMsg; errMsg << "ERROR: gamma correction factor ("; errMsg << gamma << ") cannot be negative when using a constant user-defined factor." << std::endl; @@ -623,19 +621,19 @@ void gammaCorrection(vpImage &I, const float &gamma, const vpGamm throw(vpException(vpException::badValue, errMsg.str())); } else { - if (method == GAMMA_NONLINEAR_BASED) { + if (method == GAMMA_NONLINEAR_BASED) { gammaCorrectionNonLinearMethod(I, p_mask); } - else if (method == GAMMA_LOG_BASED) { + else if (method == GAMMA_LOG_BASED) { gammaCorrectionLogMethod(I, p_mask); } - else if (method == GAMMA_CLASSIFICATION_BASED) { + else if (method == GAMMA_CLASSIFICATION_BASED) { gammaCorrectionClassBasedMethod(I, p_mask); } - else if (method == GAMMA_CDF_BASED) { + else if (method == GAMMA_CDF_BASED) { gammaCorrectionProbBasedMethod(I, p_mask); } - else if (method == GAMMA_SPATIAL_VARIANT_BASED) { + else if (method == GAMMA_SPATIAL_VARIANT_BASED) { gammaCorrectionSpatialBased(I, p_mask); } else { @@ -650,17 +648,17 @@ void gammaCorrection(const vpImage &I1, vpImage &I const vpGammaMethod &method, const vpImage *p_mask) { I2 = I1; - vp::gammaCorrection(I2, gamma, method, p_mask); + gammaCorrection(I2, gamma, method, p_mask); } void gammaCorrection(vpImage &I, const float &gamma, const vpGammaColorHandling &colorHandling, const vpGammaMethod &method, const vpImage *p_mask) { - if (method == GAMMA_SPATIAL_VARIANT_BASED) { + if (method == GAMMA_SPATIAL_VARIANT_BASED) { gammaCorrectionSpatialBased(I, p_mask); } else { - if (colorHandling == GAMMA_HSV) { + if (colorHandling == GAMMA_HSV) { const unsigned int height = I.getHeight(), width = I.getWidth(); unsigned int size = height * width; std::vector hue(size); @@ -676,7 +674,7 @@ void gammaCorrection(vpImage &I, const float &gamma, const vpGammaColorH vpImageConvert::HSVToRGBa(I_hue.bitmap, I_saturation.bitmap, I_value.bitmap, reinterpret_cast(I.bitmap), size); } - else if (colorHandling == GAMMA_RGB) { + else if (colorHandling == GAMMA_RGB) { vpImage pR, pG, pB, pa; vpImageConvert::split(I, &pR, &pG, &pB, &pa); gammaCorrection(pR, gamma, method, p_mask); @@ -699,7 +697,7 @@ void gammaCorrection(const vpImage &I1, vpImage &I2, const float const vpImage *p_mask) { I2 = I1; - vp::gammaCorrection(I2, gamma, colorHandling, method, p_mask); + gammaCorrection(I2, gamma, colorHandling, method, p_mask); } void stretchContrast(vpImage &I) @@ -728,7 +726,7 @@ void stretchContrast(const vpImage &I1, vpImage &I { // Copy I1 to I2 I2 = I1; - vp::stretchContrast(I2); + stretchContrast(I2); } void stretchContrast(vpImage &I) @@ -810,7 +808,7 @@ void stretchContrast(const vpImage &I1, vpImage &I2) { // Copy I1 to I2 I2 = I1; - vp::stretchContrast(I2); + stretchContrast(I2); } void stretchContrastHSV(vpImage &I) @@ -861,7 +859,7 @@ void stretchContrastHSV(const vpImage &I1, vpImage &I2) { // Copy I1 to I2 I2 = I1; - vp::stretchContrastHSV(I2); + stretchContrastHSV(I2); } void unsharpMask(vpImage &I, float sigma, double weight) @@ -893,7 +891,7 @@ void unsharpMask(const vpImage &I, vpImage &Ires, { // Copy I to Ires Ires = I; - vp::unsharpMask(Ires, sigma, weight); + unsharpMask(Ires, sigma, weight); } void unsharpMask(vpImage &I, float sigma, double weight) @@ -940,7 +938,7 @@ void unsharpMask(const vpImage &I, vpImage &Ires, float sigma, d { // Copy I to Ires Ires = I; - vp::unsharpMask(Ires, sigma, weight); + unsharpMask(Ires, sigma, weight); } -}; +} // namespace diff --git a/modules/imgproc/src/vpMorph.cpp b/modules/imgproc/src/vpMorph.cpp index f00b686d31..d252708a96 100644 --- a/modules/imgproc/src/vpMorph.cpp +++ b/modules/imgproc/src/vpMorph.cpp @@ -39,7 +39,11 @@ #include #include +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp +#else +namespace visp +#endif { void fillHoles(vpImage &I @@ -102,7 +106,7 @@ void fillHoles(vpImage &I } // Perform flood fill - vp::floodFill(flood_fill_mask, vpImagePoint(0, 0), 0, 255); + floodFill(flood_fill_mask, vpImagePoint(0, 0), 0, 255); // Get current mask vpImage mask(I.getHeight(), I.getWidth()); @@ -159,4 +163,5 @@ void reconstruct(const vpImage &marker, const vpImage - *Developed at Birmingham University, School of Dentistry. Supervised by - *Gabriel Landini - *@version 1.0 + * @author Jimenez-Hernandez Francisco + * Developed at Birmingham University, School of Dentistry. Supervised by + * Gabriel Landini + * @version 1.0 * * 8 July 2010 * @@ -88,6 +88,13 @@ #include #include +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +namespace vp +#else +namespace visp +#endif +{ + #define MAX_RETINEX_SCALES 8 std::vector retinexScalesDistribution(int scaleDiv, int level, int scale) @@ -106,20 +113,20 @@ std::vector retinexScalesDistribution(int scaleDiv, int level, int scale int i; switch (level) { - case vp::RETINEX_UNIFORM: + case RETINEX_UNIFORM: for (i = 0; i < scaleDiv; ++i) { scales[static_cast(i)] = 2.0 + (i * size_step); } break; - case vp::RETINEX_LOW: + case RETINEX_LOW: size_step = std::log(scale - 2.0) / static_cast(scaleDiv); for (i = 0; i < scaleDiv; ++i) { scales[static_cast(i)] = 2.0 + std::pow(10.0, (i * size_step) / std::log(10.0)); } break; - case vp::RETINEX_HIGH: + case RETINEX_HIGH: size_step = std::log(scale - 2.0) / static_cast(scaleDiv); for (i = 0; i < scaleDiv; ++i) { scales[static_cast(i)] = scale - std::pow(10.0, (i * size_step) / std::log(10.0)); @@ -239,8 +246,6 @@ void MSRCR(vpImage &I, int v_scale, int scaleDiv, int level, double dyna } } -namespace vp -{ void retinex(vpImage &I, int scale, int scaleDiv, int level, const double dynamic, int kernelSize) { // Assert scale @@ -266,6 +271,7 @@ void retinex(const vpImage &I1, vpImage &I2, int scale, int scal int kernelSize) { I2 = I1; - vp::retinex(I2, scale, scaleDiv, level, dynamic, kernelSize); + retinex(I2, scale, scaleDiv, level, dynamic, kernelSize); } -}; + +} // namespace diff --git a/modules/imgproc/src/vpThreshold.cpp b/modules/imgproc/src/vpThreshold.cpp index 6633127d3d..97351741b8 100644 --- a/modules/imgproc/src/vpThreshold.cpp +++ b/modules/imgproc/src/vpThreshold.cpp @@ -40,8 +40,13 @@ #include #include -namespace +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +namespace vp +#else +namespace visp +#endif { + bool isBimodal(const std::vector &hist_float) { int modes = 0; @@ -368,10 +373,7 @@ int computeThresholdTriangle(vpHistogram &hist) return threshold; } -} // namespace -namespace vp -{ unsigned char autoThreshold(vpImage &I, const vpAutoThresholdMethod &method, const unsigned char backgroundValue, const unsigned char foregroundValue) { @@ -420,4 +422,5 @@ unsigned char autoThreshold(vpImage &I, const vpAutoThresholdMeth return threshold; } -}; + +} // namespace diff --git a/modules/io/include/visp3/io/vpDiskGrabber.h b/modules/io/include/visp3/io/vpDiskGrabber.h index 221dc48806..df2d16677f 100644 --- a/modules/io/include/visp3/io/vpDiskGrabber.h +++ b/modules/io/include/visp3/io/vpDiskGrabber.h @@ -45,6 +45,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpDiskGrabber * @@ -269,4 +274,8 @@ class VISP_EXPORT vpDiskGrabber : public vpFrameGrabber void setStep(long step) { m_image_step = step; } }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/include/visp3/io/vpImageIo.h b/modules/io/include/visp3/io/vpImageIo.h index b2c400aa7f..4e7c72f9b0 100644 --- a/modules/io/include/visp3/io/vpImageIo.h +++ b/modules/io/include/visp3/io/vpImageIo.h @@ -46,6 +46,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! \class vpImageIo @@ -185,4 +190,9 @@ class VISP_EXPORT vpImageIo static void writePNGtoMem(const vpImage &I, std::vector &buffer, int backend = IO_DEFAULT_BACKEND, bool saveAlpha = false); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/include/visp3/io/vpJsonArgumentParser.h b/modules/io/include/visp3/io/vpJsonArgumentParser.h index 4cee71ee34..f15f8e9f07 100644 --- a/modules/io/include/visp3/io/vpJsonArgumentParser.h +++ b/modules/io/include/visp3/io/vpJsonArgumentParser.h @@ -33,6 +33,7 @@ #ifndef _vpJsonArgumentParser_h_ #define _vpJsonArgumentParser_h_ + #include #if defined(VISP_HAVE_NLOHMANN_JSON) @@ -66,6 +67,12 @@ nlohmann::json convertCommandLineArgument(const std::string &arg) nlohmann::json j = arg; return j; } + +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! \class vpJsonArgumentParser \ingroup module_io_cmd_parser @@ -78,53 +85,53 @@ nlohmann::json convertCommandLineArgument(const std::string &arg) A very basic program that uses both a JSON file and command line arguments can be found below: \code{.cpp} - #include - #include - int main(int argc, char* argv[]) - { - double d = 1.0; - std::string s = "Default"; - - vpJsonArgumentParser parser("Example program for arguments with vpJsonArgumentParser", "config", "/"); - - parser.add_argument("scalar", d, true, "An important value: must be defined by the user") - .add_argument("string", s, false, "An optional value: if left unspecified, will default to its initialized value (\"Default\")") - .parse(argc, argv); - - std::cout << "Scalar = " << d << std::endl; - std::cout << "String = " << s << std::endl; - } + #include + #include + int main(int argc, char* argv[]) + { + double d = 1.0; + std::string s = "Default"; + + vpJsonArgumentParser parser("Example program for arguments with vpJsonArgumentParser", "config", "/"); + + parser.add_argument("scalar", d, true, "An important value: must be defined by the user") + .add_argument("string", s, false, "An optional value: if left unspecified, will default to its initialized value (\"Default\")") + .parse(argc, argv); + + std::cout << "Scalar = " << d << std::endl; + std::cout << "String = " << s << std::endl; + } \endcode Compiling this sample and calling the program with the arguments from the command line would yield: \code{.sh} - $ ./program scalar 2.0 string "A new value" - Scalar = 2.0 - String = a new value - $ ./program scalar 2.0 - Scalar = 2.0 - String = default + $ ./program scalar 2.0 string "A new value" + Scalar = 2.0 + String = a new value + $ ./program scalar 2.0 + Scalar = 2.0 + String = default \endcode Here the arguments are specified from the command line. Since the "string" argument is optional, it does not have to be specified. For programs with more arguments it is helpful to use a JSON file that contains a base configuration. For the program above, a JSON file could look like: \code{.json} - { - "scalar": 3.0, - "string": "Some base value" - } + { + "scalar": 3.0, + "string": "Some base value" + } \endcode we could then call the program with: \code{.sh} - $ ./program config my_settings.json - Scalar = 3.0 - String = Some base value + $ ./program config my_settings.json + Scalar = 3.0 + String = Some base value \endcode The values contained in the JSON file can be overridden with command line arguments \code{.sh} - $ ./program config my_settings.json scalar 5 - Scalar = 5.0 - String = Some base value + $ ./program config my_settings.json scalar 5 + Scalar = 5.0 + String = Some base value \endcode The program can also be called with the "-h" or "--help" argument to display the help associated to the arguments, as well as an example json configuration file @@ -177,7 +184,7 @@ class VISP_EXPORT vpJsonArgumentParser template vpJsonArgumentParser &addArgument(const std::string &name, T ¶meter, const bool required = true, const std::string &help = "No description") { - const auto getter = [name, this](nlohmann::json &j, bool create) -> nlohmann::json *{ + const auto getter = [name, this](nlohmann::json &j, bool create) -> nlohmann::json * { size_t pos = 0; nlohmann::json *f = &j; std::string token; @@ -261,6 +268,10 @@ class VISP_EXPORT vpJsonArgumentParser nlohmann::json exampleJson; // Example JSON argument file: displayed when user calls for help }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif // VISP_HAVE_NLOHMANN_JSON #endif diff --git a/modules/io/include/visp3/io/vpParseArgv.h b/modules/io/include/visp3/io/vpParseArgv.h index aa83214d54..20fb09ded3 100644 --- a/modules/io/include/visp3/io/vpParseArgv.h +++ b/modules/io/include/visp3/io/vpParseArgv.h @@ -29,6 +29,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! \class vpParseArgv \ingroup module_io_cmd_parser @@ -39,102 +44,102 @@ name with more than one character. \code -#include -#include -#include + #include + #include + #include -// Usage : [-bool] [-int ] [-long ] -// [-float ] [-double ] [-string ] [-h] -int main(int argc, const char ** argv) -{ - // Variables to set by command line parsing - bool b_val = false; - int i_val = 10; - long l_val = 123456; - float f_val = 0.1f; - double d_val = M_PI; - char *s_val; - - // Parse the command line to set the variables - vpParseArgv::vpArgvInfo argTable[] = + // Usage : [-bool] [-int ] [-long ] + // [-float ] [-double ] [-string ] [-h] + int main(int argc, const char ** argv) { - {"-bool", vpParseArgv::ARGV_CONSTANT_BOOL, 0, (char *) &b_val, - "Flag enabled."}, - {"-int", vpParseArgv::ARGV_INT, (char*) nullptr, (char *) &i_val, - "An integer value."}, - {"-long", vpParseArgv::ARGV_LONG, (char*) nullptr, (char *) &l_val, - "An integer value."}, - {"-float", vpParseArgv::ARGV_FLOAT, (char*) nullptr, (char *) &f_val, - "A float value."}, - {"-double", vpParseArgv::ARGV_DOUBLE, (char*) nullptr, (char *) &d_val, - "A double value."}, - {"-string", vpParseArgv::ARGV_STRING, (char*) nullptr, (char *) &s_val, - "A string value."}, - {"-h", vpParseArgv::ARGV_HELP, (char*) nullptr, (char *) nullptr, - "Print the help."}, - {(char*) nullptr, vpParseArgv::ARGV_END, (char*) nullptr, (char*) nullptr, (char*) nullptr} } ; - - // Read the command line options - if(vpParseArgv::parse(&argc, argv, argTable, - vpParseArgv::ARGV_NO_LEFTOVERS | - vpParseArgv::ARGV_NO_ABBREV | - vpParseArgv::ARGV_NO_DEFAULTS)) { - return (false); - } + // Variables to set by command line parsing + bool b_val = false; + int i_val = 10; + long l_val = 123456; + float f_val = 0.1f; + double d_val = M_PI; + char *s_val; + + // Parse the command line to set the variables + vpParseArgv::vpArgvInfo argTable[] = + { + {"-bool", vpParseArgv::ARGV_CONSTANT_BOOL, 0, (char *) &b_val, + "Flag enabled."}, + {"-int", vpParseArgv::ARGV_INT, (char*) nullptr, (char *) &i_val, + "An integer value."}, + {"-long", vpParseArgv::ARGV_LONG, (char*) nullptr, (char *) &l_val, + "An integer value."}, + {"-float", vpParseArgv::ARGV_FLOAT, (char*) nullptr, (char *) &f_val, + "A float value."}, + {"-double", vpParseArgv::ARGV_DOUBLE, (char*) nullptr, (char *) &d_val, + "A double value."}, + {"-string", vpParseArgv::ARGV_STRING, (char*) nullptr, (char *) &s_val, + "A string value."}, + {"-h", vpParseArgv::ARGV_HELP, (char*) nullptr, (char *) nullptr, + "Print the help."}, + {(char*) nullptr, vpParseArgv::ARGV_END, (char*) nullptr, (char*) nullptr, (char*) nullptr} } ; + + // Read the command line options + if(vpParseArgv::parse(&argc, argv, argTable, + vpParseArgv::ARGV_NO_LEFTOVERS | + vpParseArgv::ARGV_NO_ABBREV | + vpParseArgv::ARGV_NO_DEFAULTS)) { + return (false); + } - // b_val, i_val, l_val, f_val, d_val, s_val may have new values -} + // b_val, i_val, l_val, f_val, d_val, s_val may have new values + } \endcode The code below shows an other way to parse command line arguments using vpParseArgv class. Here command line options are only one character long. \code -#include -#include -#include -#include + #include + #include + #include + #include -// List of allowed command line options -#define GETOPTARGS "bi:l:f:d:h" // double point mean here that the preceding option request an argument + // List of allowed command line options + #define GETOPTARGS "bi:l:f:d:h" // double point mean here that the preceding option request an argument -// Usage : [-b] [-i ] [-l ] -// [-f ] [-d ] [-s ] [-h] -int main(int argc, const char ** argv) -{ - // Variables to set by command line parsing - bool b_val = false; - int i_val = 10; - long l_val = 123456; - float f_val = 0.1f; - double d_val = M_PI; - std::string s_val; - - // Parse the command line to set the variables - const char *optarg; - int c; - while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { - - switch (c) { - case 'b': b_val = true; break; - case 'i': i_val = atoi(optarg); break; - case 'l': l_val = atol(optarg); break; - case 'f': f_val = static_cast(atof(optarg)); break; - case 'd': d_val = atof(optarg); break; - case 's': s_val = std::string(optarg); break; - case 'h': printf("Usage: ...\n"); return EXIT_SUCCESS; break; - - default: - printf("Usage: ...\n"); return EXIT_SUCCESS; break; + // Usage : [-b] [-i ] [-l ] + // [-f ] [-d ] [-s ] [-h] + int main(int argc, const char ** argv) + { + // Variables to set by command line parsing + bool b_val = false; + int i_val = 10; + long l_val = 123456; + float f_val = 0.1f; + double d_val = M_PI; + std::string s_val; + + // Parse the command line to set the variables + const char *optarg; + int c; + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg)) > 1) { + + switch (c) { + case 'b': b_val = true; break; + case 'i': i_val = atoi(optarg); break; + case 'l': l_val = atol(optarg); break; + case 'f': f_val = static_cast(atof(optarg)); break; + case 'd': d_val = atof(optarg); break; + case 's': s_val = std::string(optarg); break; + case 'h': printf("Usage: ...\n"); return EXIT_SUCCESS; break; + + default: + printf("Usage: ...\n"); return EXIT_SUCCESS; break; + } + } + if ((c == 1) || (c == -1)) { + // standalone param or error + printf("Usage: ...\n"); + return EXIT_FAILURE; } - } - if ((c == 1) || (c == -1)) { - // standalone param or error - printf("Usage: ...\n"); - return EXIT_FAILURE; - } - // b_val, i_val, l_val, f_val, d_val, s_val may have new values -} + // b_val, i_val, l_val, f_val, d_val, s_val may have new values + } \endcode */ @@ -145,7 +150,8 @@ class VISP_EXPORT vpParseArgv /*! Legal values for the type field of a vpArgvInfo. */ - typedef enum { + typedef enum + { ARGV_CONSTANT, ///< Stand alone argument. Same as vpParseArgv::ARGV_CONSTANT_INT. ARGV_CONSTANT_INT, ///< Stand alone argument associated to an int var that is set to 1. ARGV_CONSTANT_BOOL, ///< Stand alone argument associated to a bool var that is set to true. @@ -164,7 +170,8 @@ class VISP_EXPORT vpParseArgv /*! Flag bits. */ - typedef enum { + typedef enum + { ARGV_NO_DEFAULTS = 0x1, ///< No default options like -help. ARGV_NO_LEFTOVERS = 0x2, ///< Print an error message if an option is not in the argument list. ARGV_NO_ABBREV = 0x4, ///< No abrevation. Print an error message if an option is abrevated (ie "-i" in place of @@ -178,7 +185,8 @@ class VISP_EXPORT vpParseArgv Structure used to specify how to handle argv options. */ - typedef struct { + typedef struct + { const char *key; ///< The key string that flags the option in the argv array. vpArgvType type; ///< Indicates option type. const char *src; ///< Value to be used in setting dst; usage depends on type. @@ -196,4 +204,8 @@ class VISP_EXPORT vpParseArgv static void printUsage(vpArgvInfo *argTable, int flags); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/include/visp3/io/vpVideoReader.h b/modules/io/include/visp3/io/vpVideoReader.h index a6ea82161e..6a832019d8 100644 --- a/modules/io/include/visp3/io/vpVideoReader.h +++ b/modules/io/include/visp3/io/vpVideoReader.h @@ -43,6 +43,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_VIDEOIO) && defined(HAVE_OPENCV_HIGHGUI) #include #include @@ -375,4 +380,8 @@ class VISP_EXPORT vpVideoReader : public vpFrameGrabber void getProperties(); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/include/visp3/io/vpVideoWriter.h b/modules/io/include/visp3/io/vpVideoWriter.h index 85d6cdd977..594400d516 100644 --- a/modules/io/include/visp3/io/vpVideoWriter.h +++ b/modules/io/include/visp3/io/vpVideoWriter.h @@ -43,6 +43,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_VIDEOIO) && defined(HAVE_OPENCV_HIGHGUI) #include #include @@ -258,4 +263,8 @@ class VISP_EXPORT vpVideoWriter static std::string getExtension(const std::string &filename); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/image/private/vpImageIoBackend.h b/modules/io/src/image/private/vpImageIoBackend.h index 56fcc2e3ba..bd40585b8c 100644 --- a/modules/io/src/image/private/vpImageIoBackend.h +++ b/modules/io/src/image/private/vpImageIoBackend.h @@ -41,6 +41,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + // Portable FloatMap format (PFM) // Portable Graymap format (PGM) // Portable Pixmap format (PPM) @@ -133,4 +138,8 @@ void writePNGtoMemStb(const vpImage &I, std::vector &I, std::vector &buffer, bool saveAlpha); #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/image/private/vpImageIoLibjpeg.cpp b/modules/io/src/image/private/vpImageIoLibjpeg.cpp index 692183d742..029cc06804 100644 --- a/modules/io/src/image/private/vpImageIoLibjpeg.cpp +++ b/modules/io/src/image/private/vpImageIoLibjpeg.cpp @@ -50,6 +50,10 @@ #if defined(VISP_HAVE_JPEG) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Write the content of the image bitmap in the file which name is given by \e filename. This function writes a JPEG file. @@ -332,4 +336,9 @@ void readJPEGLibjpeg(vpImage &I, const std::string &filename) jpeg_destroy_decompress(&cinfo); fclose(file); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/image/private/vpImageIoLibpng.cpp b/modules/io/src/image/private/vpImageIoLibpng.cpp index e7b3afcc5b..03f54ae5d5 100644 --- a/modules/io/src/image/private/vpImageIoLibpng.cpp +++ b/modules/io/src/image/private/vpImageIoLibpng.cpp @@ -49,6 +49,10 @@ #if defined(VISP_HAVE_PNG) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Write the content of the image bitmap in the file which name is given by \e filename. This function writes a PNG file. @@ -598,4 +602,9 @@ void readPNGLibpng(vpImage &I, const std::string &filename) png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); fclose(file); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/image/private/vpImageIoOpenCV.cpp b/modules/io/src/image/private/vpImageIoOpenCV.cpp index dceed26214..45e92ea69f 100644 --- a/modules/io/src/image/private/vpImageIoOpenCV.cpp +++ b/modules/io/src/image/private/vpImageIoOpenCV.cpp @@ -59,6 +59,10 @@ #if ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_IMGCODECS)) || ((VISP_HAVE_OPENCV_VERSION < 0x030000) \ && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Read the contents of the image file, allocate memory for the corresponding gray level image, if necessary convert the data in @@ -302,4 +306,8 @@ void writePNGtoMemOpenCV(const vpImage &I_color, std::vector #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS /*! * Decode the PNM image header. @@ -837,3 +842,7 @@ void vp_writePPM(const vpImage &I, const std::string &filename) fflush(f); fclose(f); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/io/src/image/private/vpImageIoSimd.cpp b/modules/io/src/image/private/vpImageIoSimd.cpp index 261af7012f..a6d22e74ae 100644 --- a/modules/io/src/image/private/vpImageIoSimd.cpp +++ b/modules/io/src/image/private/vpImageIoSimd.cpp @@ -42,6 +42,11 @@ #include "vpImageIoBackend.h" #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + void readSimdlib(vpImage &I, const std::string &filename) { size_t stride = 0, width = 0, height = 0; @@ -91,4 +96,9 @@ void writePNGSimdlib(const vpImage &I, const std::string &filename) SimdImageSaveToFile((const uint8_t *)I.bitmap, I.getWidth() * 4, I.getWidth(), I.getHeight(), SimdPixelFormatRgba32, SimdImageFilePng, 90, filename.c_str()); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/image/private/vpImageIoStb.cpp b/modules/io/src/image/private/vpImageIoStb.cpp index 5db5a9f3bd..5d91698446 100644 --- a/modules/io/src/image/private/vpImageIoStb.cpp +++ b/modules/io/src/image/private/vpImageIoStb.cpp @@ -57,6 +57,11 @@ #define STB_IMAGE_WRITE_IMPLEMENTATION #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + void readStb(vpImage &I, const std::string &filename) { int width = 0, height = 0, channels = 0; @@ -266,4 +271,9 @@ void writePNGtoMemStb(const vpImage &I_color, std::vector #endif } } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/image/private/vpImageIoTinyEXR.cpp b/modules/io/src/image/private/vpImageIoTinyEXR.cpp index d26e5078aa..f03d204cdb 100644 --- a/modules/io/src/image/private/vpImageIoTinyEXR.cpp +++ b/modules/io/src/image/private/vpImageIoTinyEXR.cpp @@ -51,6 +51,11 @@ #define TINYEXR_IMPLEMENTATION #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + void readEXRTiny(vpImage &I, const std::string &filename) { EXRVersion exr_version; @@ -319,4 +324,8 @@ void writeEXRTiny(const vpImage &I, const std::string &filename) free(header.pixel_types); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/image/vpImageIo.cpp b/modules/io/src/image/vpImageIo.cpp index 567969e0d3..7d26b2b1af 100644 --- a/modules/io/src/image/vpImageIo.cpp +++ b/modules/io/src/image/vpImageIo.cpp @@ -41,6 +41,10 @@ #include "private/vpImageIoBackend.h" +#if defined(ENABLE_VISP_NAMESPACE) +using namespace visp; +#endif + vpImageIo::vpImageFormatType vpImageIo::getFormat(const std::string &filename) { std::string ext = vpImageIo::getExtension(filename); diff --git a/modules/io/src/tools/vpJsonArgumentParser.cpp b/modules/io/src/tools/vpJsonArgumentParser.cpp index 9c605fd767..bcf1029e82 100644 --- a/modules/io/src/tools/vpJsonArgumentParser.cpp +++ b/modules/io/src/tools/vpJsonArgumentParser.cpp @@ -27,13 +27,17 @@ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ + +#include #include #include -#include #include - #if defined(VISP_HAVE_NLOHMANN_JSON) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif using json = nlohmann::json; //! json namespace shortcut @@ -150,4 +154,8 @@ void vpJsonArgumentParser::parse(int argc, const char *argv[]) } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/io/src/tools/vpParseArgv.cpp b/modules/io/src/tools/vpParseArgv.cpp index 5dcc3755c1..e0b454ce86 100644 --- a/modules/io/src/tools/vpParseArgv.cpp +++ b/modules/io/src/tools/vpParseArgv.cpp @@ -32,6 +32,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /* * Default table of argument descriptors. These are normally available * in every application. @@ -39,7 +44,7 @@ vpParseArgv::vpArgvInfo vpParseArgv::defaultTable[2] = { {"-help", ARGV_HELP, (char *)nullptr, (char *)nullptr, "Print summary of command-line options and abort.\n"}, - {nullptr, ARGV_END, (char *)nullptr, (char *)nullptr, (char *)nullptr}}; + {nullptr, ARGV_END, (char *)nullptr, (char *)nullptr, (char *)nullptr} }; int (*handlerProc1)(const char *dst, const char *key, const char *argument); int (*handlerProc2)(const char *dst, const char *key, int valargc, const char **argument); @@ -94,7 +99,8 @@ bool vpParseArgv::parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, i if (flags & ARGV_DONT_SKIP_FIRST_ARG) { srcIndex = dstIndex = 0; argc = *argcPtr; - } else { + } + else { srcIndex = dstIndex = 1; argc = *argcPtr - 1; } @@ -116,7 +122,8 @@ bool vpParseArgv::parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, i for (unsigned int i = 0; i < 2; ++i) { if (i == 0) { infoPtr = argTable; - } else { + } + else { infoPtr = defaultTable; } for (; infoPtr->type != ARGV_END; ++infoPtr) { @@ -175,7 +182,8 @@ bool vpParseArgv::parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, i for (unsigned long i = 0; i < nargs; ++i) { if (argc == 0) { goto missingArg; - } else { + } + else { char *endPtr = nullptr; *(((int *)infoPtr->dst) + i) = (int)strtol(argv[srcIndex], &endPtr, 0); @@ -195,7 +203,8 @@ bool vpParseArgv::parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, i for (unsigned long i = 0; i < nargs; ++i) { if (argc == 0) { goto missingArg; - } else { + } + else { char *endPtr = nullptr; *(((long *)infoPtr->dst) + i) = strtol(argv[srcIndex], &endPtr, 0); @@ -215,7 +224,8 @@ bool vpParseArgv::parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, i for (unsigned long i = 0; i < nargs; ++i) { if (argc == 0) { goto missingArg; - } else { + } + else { *(((const char **)infoPtr->dst) + i) = argv[srcIndex]; srcIndex++; argc--; @@ -232,7 +242,8 @@ bool vpParseArgv::parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, i for (unsigned long i = 0; i < nargs; ++i) { if (argc == 0) { goto missingArg; - } else { + } + else { char *endPtr; *(((float *)infoPtr->dst) + i) = (float)strtod(argv[srcIndex], &endPtr); // Here we use strtod @@ -253,7 +264,8 @@ bool vpParseArgv::parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, i for (unsigned long i = 0; i < nargs; ++i) { if (argc == 0) { goto missingArg; - } else { + } + else { char *endPtr; *(((double *)infoPtr->dst) + i) = strtod(argv[srcIndex], &endPtr); @@ -379,7 +391,8 @@ void vpParseArgv::printUsage(vpArgvInfo *argTable, int flags) while (numSpaces > 0) { if (numSpaces >= NUM_SPACES) { FPRINTF(stderr, "%s", spaces); - } else { + } + else { FPRINTF(stderr, "%s", spaces + NUM_SPACES - numSpaces); } numSpaces -= NUM_SPACES; @@ -522,38 +535,45 @@ int vpParseArgv::parse(int argc, const char **argv, const char *validOpts, const // next argv is the param iArg++; pszParam = psz; - } else { - // reached end of args looking for param - // option specified without parameter + } + else { + // reached end of args looking for param + // option specified without parameter chOpt = -1; pszParam = &(argv[iArg][0]); } - } else { - // param is attached to option + } + else { + // param is attached to option pszParam = psz; } - } else { - // option is alone, has no parameter } - } else { - // option specified is not in list of valid options + else { + // option is alone, has no parameter + } + } + else { + // option specified is not in list of valid options chOpt = -1; pszParam = &(argv[iArg][0]); } - } else { - // though option specifier was given, option character - // is not alpha or was was not specified + } + else { + // though option specifier was given, option character + // is not alpha or was was not specified chOpt = -1; pszParam = &(argv[iArg][0]); } - } else { - // standalone arg given with no option specifier + } + else { + // standalone arg given with no option specifier chOpt = 1; pszParam = &(argv[iArg][0]); } - } else { - // end of argument list + } + else { + // end of argument list chOpt = 0; } @@ -561,3 +581,7 @@ int vpParseArgv::parse(int argc, const char **argv, const char *validOpts, const *param = pszParam; return (chOpt); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/io/src/video/vpDiskGrabber.cpp b/modules/io/src/video/vpDiskGrabber.cpp index f8c923d542..7f4a01bfb6 100644 --- a/modules/io/src/video/vpDiskGrabber.cpp +++ b/modules/io/src/video/vpDiskGrabber.cpp @@ -33,6 +33,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + vpDiskGrabber::vpDiskGrabber() : m_image_number(0), m_image_number_next(0), m_image_step(1), m_number_of_zero(0), m_directory("/tmp"), m_base_name("I"), m_extension("pgm"), m_use_generic_name(false), m_generic_name("empty") @@ -247,3 +252,7 @@ void vpDiskGrabber::setGenericName(const std::string &generic_name) m_generic_name = generic_name; m_use_generic_name = true; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/io/src/video/vpVideoReader.cpp b/modules/io/src/video/vpVideoReader.cpp index 600a63695c..e157bf1aef 100644 --- a/modules/io/src/video/vpVideoReader.cpp +++ b/modules/io/src/video/vpVideoReader.cpp @@ -45,6 +45,11 @@ #include #include // numeric_limits +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! Basic constructor. */ @@ -906,3 +911,7 @@ bool vpVideoReader::isVideoFormat() const return false; } } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/io/src/video/vpVideoWriter.cpp b/modules/io/src/video/vpVideoWriter.cpp index d21829e200..e05358dc7b 100644 --- a/modules/io/src/video/vpVideoWriter.cpp +++ b/modules/io/src/video/vpVideoWriter.cpp @@ -40,6 +40,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #if defined(HAVE_OPENCV_IMGPROC) #include #endif @@ -50,10 +55,10 @@ vpVideoWriter::vpVideoWriter() : #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO) - m_writer(), m_framerate(25.0), + m_writer(), m_framerate(25.0), #endif - m_formatType(FORMAT_UNKNOWN), m_videoName(), m_frameName(), m_initFileName(false), m_isOpen(false), m_frameCount(0), - m_firstFrame(0), m_width(0), m_height(0), m_frameStep(1) + m_formatType(FORMAT_UNKNOWN), m_videoName(), m_frameName(), m_initFileName(false), m_isOpen(false), m_frameCount(0), + m_firstFrame(0), m_width(0), m_height(0), m_frameStep(1) { #if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO) #if (VISP_HAVE_OPENCV_VERSION >= 0x030000) @@ -67,7 +72,7 @@ vpVideoWriter::vpVideoWriter() /*! Basic destructor. */ -vpVideoWriter::~vpVideoWriter() {} +vpVideoWriter::~vpVideoWriter() { } /*! It enables to set the path and the name of the video or sequence of images @@ -121,8 +126,9 @@ void vpVideoWriter::open(vpImage &I) m_formatType == FORMAT_PNG) { m_width = I.getWidth(); m_height = I.getHeight(); - } else if (m_formatType == FORMAT_AVI || m_formatType == FORMAT_MPEG || m_formatType == FORMAT_MPEG4 || - m_formatType == FORMAT_MOV) { + } + else if (m_formatType == FORMAT_AVI || m_formatType == FORMAT_MPEG || m_formatType == FORMAT_MPEG4 || + m_formatType == FORMAT_MOV) { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO) m_writer = cv::VideoWriter(m_videoName, m_fourcc, m_framerate, cv::Size(static_cast(I.getWidth()), static_cast(I.getHeight()))); @@ -160,8 +166,9 @@ void vpVideoWriter::open(vpImage &I) m_formatType == FORMAT_PNG) { m_width = I.getWidth(); m_height = I.getHeight(); - } else if (m_formatType == FORMAT_AVI || m_formatType == FORMAT_MPEG || m_formatType == FORMAT_MPEG4 || - m_formatType == FORMAT_MOV) { + } + else if (m_formatType == FORMAT_AVI || m_formatType == FORMAT_MPEG || m_formatType == FORMAT_MPEG4 || + m_formatType == FORMAT_MOV) { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO) m_writer = cv::VideoWriter(m_videoName, m_fourcc, m_framerate, cv::Size(static_cast(I.getWidth()), static_cast(I.getHeight()))); @@ -200,7 +207,8 @@ void vpVideoWriter::saveFrame(vpImage &I) snprintf(name, FILENAME_MAX, m_videoName.c_str(), m_frameCount); vpImageIo::write(I, name); m_frameName = std::string(name); - } else { + } + else { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO) cv::Mat matFrame; vpImageConvert::convert(I, matFrame); @@ -232,7 +240,8 @@ void vpVideoWriter::saveFrame(vpImage &I) snprintf(name, FILENAME_MAX, m_videoName.c_str(), m_frameCount); vpImageIo::write(I, name); m_frameName = std::string(name); - } else { + } + else { #if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO) #if (VISP_HAVE_OPENCV_VERSION >= 0x030000) cv::Mat matFrame, rgbMatFrame; @@ -339,3 +348,7 @@ void vpVideoWriter::setFirstFrameIndex(int first_frame) } m_firstFrame = first_frame; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/blob/include/visp3/blob/vpDot.h b/modules/tracker/blob/include/visp3/blob/vpDot.h index fb76621f56..bca93ec2f3 100644 --- a/modules/tracker/blob/include/visp3/blob/vpDot.h +++ b/modules/tracker/blob/include/visp3/blob/vpDot.h @@ -58,6 +58,11 @@ #pragma comment(linker, "/STACK:256000000") // Increase max recursion depth #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpDot * @@ -414,4 +419,7 @@ class VISP_EXPORT vpDot : public vpTracker vpColor color = vpColor::red, unsigned int thickness = 1); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/tracker/blob/include/visp3/blob/vpDot2.h b/modules/tracker/blob/include/visp3/blob/vpDot2.h index 128108d445..914164da39 100644 --- a/modules/tracker/blob/include/visp3/blob/vpDot2.h +++ b/modules/tracker/blob/include/visp3/blob/vpDot2.h @@ -51,6 +51,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpDot2 * @@ -162,10 +167,10 @@ class VISP_EXPORT vpDot2 : public vpTracker { vpRect bbox; - bbox.setRect(this->bbox_u_min, this->bbox_v_min, this->bbox_u_max - this->bbox_u_min + 1, - this->bbox_v_max - this->bbox_v_min + 1); + bbox.setRect(this->bbox_u_min, this->bbox_v_min, (this->bbox_u_max - this->bbox_u_min) + 1, + (this->bbox_v_max - this->bbox_v_min) + 1); - return (bbox); + return bbox; }; /*! @@ -192,7 +197,7 @@ class VISP_EXPORT vpDot2 : public vpTracker * \return The list of all the images points on the dot * border. This list is update after a call to track(). */ - std::list getEdges() const { return (this->ip_edges_list); }; + std::list getEdges() const { return this->ip_edges_list; }; /*! * Get the percentage of sampled points that are considered non conform @@ -284,12 +289,15 @@ class VISP_EXPORT vpDot2 : public vpTracker */ void setEllipsoidBadPointsPercentage(const double &percentage = 0.0) { - if (percentage < 0.) + if (percentage < 0.) { allowedBadPointsPercentage_ = 0.; - else if (percentage > 1.) + } + else if (percentage > 1.) { allowedBadPointsPercentage_ = 1.; - else + } + else { allowedBadPointsPercentage_ = percentage; + } } void setEllipsoidShapePrecision(const double &ellipsoidShapePrecision); @@ -329,10 +337,12 @@ class VISP_EXPORT vpDot2 : public vpTracker */ inline void setGrayLevelMin(const unsigned int &min) { - if (min > 255) + if (min > 255) { this->gray_level_min = 255; - else + } + else { this->gray_level_min = min; + } }; /*! @@ -365,6 +375,13 @@ class VISP_EXPORT vpDot2 : public vpTracker static void trackAndDisplay(vpDot2 dot[], const unsigned int &n, vpImage &I, std::vector &cogs, vpImagePoint *cogStar = nullptr); + // Static funtions + static void display(const vpImage &I, const vpImagePoint &cog, + const std::list &edges_list, vpColor color = vpColor::red, + unsigned int thickness = 1); + static void display(const vpImage &I, const vpImagePoint &cog, const std::list &edges_list, + vpColor color = vpColor::red, unsigned int thickness = 1); + #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS public: #else @@ -520,13 +537,9 @@ class VISP_EXPORT vpDot2 : public vpTracker unsigned int firstBorder_u; unsigned int firstBorder_v; - // Static funtions -public: - static void display(const vpImage &I, const vpImagePoint &cog, - const std::list &edges_list, vpColor color = vpColor::red, - unsigned int thickness = 1); - static void display(const vpImage &I, const vpImagePoint &cog, const std::list &edges_list, - vpColor color = vpColor::red, unsigned int thickness = 1); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/tracker/blob/src/dots/vpDot.cpp b/modules/tracker/blob/src/dots/vpDot.cpp index c87d4949d7..20124f9eb8 100644 --- a/modules/tracker/blob/src/dots/vpDot.cpp +++ b/modules/tracker/blob/src/dots/vpDot.cpp @@ -48,6 +48,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /* \class vpDot \brief Track a white dot @@ -947,3 +952,7 @@ void vpDot::display(const vpImage &I, const vpImagePoint &cog, const std documentation) to the stream \e os, and returns a reference to the stream. */ VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot &d) { return (os << "(" << d.getCog() << ")"); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/blob/src/dots/vpDot2.cpp b/modules/tracker/blob/src/dots/vpDot2.cpp index d4118dcc55..3275d469ba 100644 --- a/modules/tracker/blob/src/dots/vpDot2.cpp +++ b/modules/tracker/blob/src/dots/vpDot2.cpp @@ -54,6 +54,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /****************************************************************************** * * CONSTRUCTORS AND DESTRUCTORS @@ -2506,3 +2511,7 @@ void vpDot2::display(const vpImage &I, const vpImagePoint &cog, const st documentation) to the stream \e os, and returns a reference to the stream. */ VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot2 &d) { return (os << "(" << d.getCog() << ")"); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/me/include/visp3/me/vpMe.h b/modules/tracker/me/include/visp3/me/vpMe.h index 777a113aaa..070fba3fe5 100644 --- a/modules/tracker/me/include/visp3/me/vpMe.h +++ b/modules/tracker/me/include/visp3/me/vpMe.h @@ -43,6 +43,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpMe * \ingroup module_me @@ -135,31 +139,6 @@ class VISP_EXPORT vpMe NORMALIZED_THRESHOLD = 1 } vpLikelihoodThresholdType; -private: - vpLikelihoodThresholdType m_likelihood_threshold_type; //!< Likelihood threshold type - //! Old likelihood ratio threshold (to be avoided) or easy-to-use normalized threshold: minimal contrast - double m_threshold; - double m_thresholdMarginRatio; //!< The ratio of the initial contrast to use to initialize the contrast threshold of the vpMeSite. - double m_minThreshold; //!< The minimum moving-edge threshold in grey level used when the contrast threshold of the vpMeSites is automatically computed. - bool m_useAutomaticThreshold; //!< Set to true if the user wants to automatically compute the vpMeSite contrast thresholds, false if the user wants to use a global threshold. - double m_mu1; //!< Contrast continuity parameter (left boundary) - double m_mu2; //!< Contrast continuity parameter (right boundary) - double m_min_samplestep; - unsigned int m_anglestep; - int m_mask_sign; - unsigned int m_range; //! Seek range - on both sides of the reference pixel - double m_sample_step; //! Distance between sampled points in pixels - int m_ntotal_sample; - int m_points_to_track; //!< Expected number of points to track - //! Convolution masks' size in pixels (masks are square) - unsigned int m_mask_size; - //! The number of convolution masks available for tracking ; defines resolution - unsigned int m_mask_number; - //! Strip: defines a "security strip" such that when seeking extremities - //! cannot return a new extremity which is too close to the frame borders - int m_strip; - vpMatrix *m_mask; //!< Array of matrices defining the different masks (one for every angle step). - public: /*! * Default constructor. @@ -195,8 +174,9 @@ class VISP_EXPORT vpMe */ void checkSamplestep(double &sample_step) { - if (sample_step < m_min_samplestep) + if (sample_step < m_min_samplestep) { sample_step = m_min_samplestep; + } } /*! @@ -518,6 +498,31 @@ class VISP_EXPORT vpMe */ void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type) { m_likelihood_threshold_type = likelihood_threshold_type; } +private: + vpLikelihoodThresholdType m_likelihood_threshold_type; //!< Likelihood threshold type + //! Old likelihood ratio threshold (to be avoided) or easy-to-use normalized threshold: minimal contrast + double m_threshold; + double m_thresholdMarginRatio; //!< The ratio of the initial contrast to use to initialize the contrast threshold of the vpMeSite. + double m_minThreshold; //!< The minimum moving-edge threshold in grey level used when the contrast threshold of the vpMeSites is automatically computed. + bool m_useAutomaticThreshold; //!< Set to true if the user wants to automatically compute the vpMeSite contrast thresholds, false if the user wants to use a global threshold. + double m_mu1; //!< Contrast continuity parameter (left boundary) + double m_mu2; //!< Contrast continuity parameter (right boundary) + double m_min_samplestep; + unsigned int m_anglestep; + int m_mask_sign; + unsigned int m_range; //! Seek range - on both sides of the reference pixel + double m_sample_step; //! Distance between sampled points in pixels + int m_ntotal_sample; + int m_points_to_track; //!< Expected number of points to track + //! Convolution masks' size in pixels (masks are square) + unsigned int m_mask_size; + //! The number of convolution masks available for tracking ; defines resolution + unsigned int m_mask_number; + //! Strip: defines a "security strip" such that when seeking extremities + //! cannot return a new extremity which is too close to the frame borders + int m_strip; + vpMatrix *m_mask; //!< Array of matrices defining the different masks (one for every angle step). + #ifdef VISP_HAVE_NLOHMANN_JSON /*! * @brief Convert a vpMe object to a JSON representation. @@ -619,7 +624,7 @@ inline void from_json(const nlohmann::json &j, vpMe &me) assert((mus.size() == 2)); me.setMu1(mus[0]); me.setMu2(mus[1]); - } +} me.setMinSampleStep(j.value("minSampleStep", me.getMinSampleStep())); me.setSampleStep(j.value("sampleStep", me.getSampleStep())); me.setRange(j.value("range", me.getRange())); @@ -643,4 +648,9 @@ inline void from_json(const nlohmann::json &j, vpMe &me) #endif + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/tracker/me/include/visp3/me/vpMeEllipse.h b/modules/tracker/me/include/visp3/me/vpMeEllipse.h index c0cdab267f..0eadccaf06 100644 --- a/modules/tracker/me/include/visp3/me/vpMeEllipse.h +++ b/modules/tracker/me/include/visp3/me/vpMeEllipse.h @@ -53,6 +53,11 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpMeEllipse * \ingroup module_me @@ -589,4 +594,8 @@ class VISP_EXPORT vpMeEllipse : public vpMeTracker void updateTheta(); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/tracker/me/include/visp3/me/vpMeSite.h b/modules/tracker/me/include/visp3/me/vpMeSite.h index 97e85dac9e..3d0f9871f0 100644 --- a/modules/tracker/me/include/visp3/me/vpMeSite.h +++ b/modules/tracker/me/include/visp3/me/vpMeSite.h @@ -44,6 +44,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpMeSite * \ingroup module_me @@ -392,4 +397,8 @@ class VISP_EXPORT vpMeSite vpMeSiteState m_state; //!< Site state }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/tracker/me/include/visp3/me/vpMeTracker.h b/modules/tracker/me/include/visp3/me/vpMeTracker.h index c96c169ea3..f4e150440b 100644 --- a/modules/tracker/me/include/visp3/me/vpMeTracker.h +++ b/modules/tracker/me/include/visp3/me/vpMeTracker.h @@ -48,6 +48,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpMeTracker * @@ -58,26 +63,6 @@ */ class VISP_EXPORT vpMeTracker : public vpTracker { -protected: - /** @name Protected Attributes Inherited from vpMeTracker */ - //@{ - //! Tracking dependent variables/functions - //! List of tracked moving edges points. - std::list m_meList; - //! Moving edges initialisation parameters - vpMe *m_me; - //! Initial range - unsigned int m_init_range; - //! Number of good moving-edges that are tracked - int m_nGoodElement; - //! Mask used to disable tracking on a part of image - const vpImage *m_mask; - //! Mask used to determine candidate points for initialization in an image - const vpImage *m_maskCandidates; - //! Moving-edges display type - vpMeSite::vpMeSiteDisplayType m_selectDisplay; - //@} - public: /*! * Default constructor. @@ -320,6 +305,31 @@ class VISP_EXPORT vpMeTracker : public vpTracker } //@} #endif + +protected: + /** @name Protected Attributes Inherited from vpMeTracker */ + //@{ + //! Tracking dependent variables/functions + //! List of tracked moving edges points. + std::list m_meList; + //! Moving edges initialisation parameters + vpMe *m_me; + //! Initial range + unsigned int m_init_range; + //! Number of good moving-edges that are tracked + int m_nGoodElement; + //! Mask used to disable tracking on a part of image + const vpImage *m_mask; + //! Mask used to determine candidate points for initialization in an image + const vpImage *m_maskCandidates; + //! Moving-edges display type + vpMeSite::vpMeSiteDisplayType m_selectDisplay; + //@} + }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/tracker/me/src/moving-edges/vpMe.cpp b/modules/tracker/me/src/moving-edges/vpMe.cpp index d89476ca58..93d7278a03 100644 --- a/modules/tracker/me/src/moving-edges/vpMe.cpp +++ b/modules/tracker/me/src/moving-edges/vpMe.cpp @@ -41,6 +41,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS namespace { @@ -498,3 +503,7 @@ void vpMe::setMaskSize(const unsigned int &mask_size) m_mask_size = mask_size; initMask(); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp b/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp index 46fbc3896a..11f4c0c94f 100644 --- a/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp @@ -40,6 +40,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + // --comment: define the VP_ME_ELLIPSE_REGULAR_SAMPLING flag #ifndef VP_ME_ELLIPSE_REGULAR_SAMPLING #define VP_ME_ELLIPSE_TWO_CONCENTRIC_CIRCLES @@ -1438,3 +1443,7 @@ void vpMeEllipse::displayEllipse(const vpImage &I, const vpImagePoint &c { vpDisplay::displayEllipse(I, center, A, B, E, smallalpha, highalpha, false, color, thickness, true, true); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/me/src/moving-edges/vpMeSite.cpp b/modules/tracker/me/src/moving-edges/vpMeSite.cpp index 913805f3ad..56e12aec1c 100644 --- a/modules/tracker/me/src/moving-edges/vpMeSite.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeSite.cpp @@ -43,6 +43,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS static bool horsImage(int i, int j, int half, int rows, int cols) { @@ -444,3 +449,7 @@ void vpMeSite::display(const vpImage &I, const double &i, const double & vpDisplay::displayCross(I, vpImagePoint(i, j), 3, vpColor::yellow, 1); } } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/me/src/moving-edges/vpMeTracker.cpp b/modules/tracker/me/src/moving-edges/vpMeTracker.cpp index dcbc578560..6ff223c362 100644 --- a/modules/tracker/me/src/moving-edges/vpMeTracker.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeTracker.cpp @@ -44,6 +44,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #define DEBUG_LEVEL1 0 #define DEBUG_LEVEL2 0 @@ -291,3 +296,7 @@ void vpMeTracker::display(const vpImage &I, vpColVector &w, unsig #undef DEBUG_LEVEL1 #undef DEBUG_LEVEL2 + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/include/visp3/vision/vpHomography.h b/modules/vision/include/visp3/vision/vpHomography.h index b7bae14eeb..2e5e363bab 100644 --- a/modules/vision/include/visp3/vision/vpHomography.h +++ b/modules/vision/include/visp3/vision/vpHomography.h @@ -51,6 +51,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpHomography * \ingroup group_vision_homography @@ -654,7 +659,7 @@ class VISP_EXPORT vpHomography : public vpArray2D #endif // DOXYGEN_SHOULD_SKIP_THIS private: - static const double m_sing_threshold; // = 0.0001; + static const double m_sing_threshold; /* equals 0.0001 */ static const double m_threshold_rotation; static const double m_threshold_displacement; vpHomogeneousMatrix m_aMb; @@ -698,4 +703,8 @@ class VISP_EXPORT vpHomography : public vpArray2D static void initRansac(unsigned int n, double *xb, double *yb, double *xa, double *ya, vpColVector &x); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/vision/include/visp3/vision/vpPose.h b/modules/vision/include/visp3/vision/vpPose.h index 83bbfbfd5f..67d6dce801 100644 --- a/modules/vision/include/visp3/vision/vpPose.h +++ b/modules/vision/include/visp3/vision/vpPose.h @@ -62,6 +62,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpPose * \ingroup group_vision_pose @@ -125,7 +130,7 @@ class VISP_EXPORT vpPose /*! * Constructor from a vector of points. */ - vpPose(const std::vector &lP); + explicit vpPose(const std::vector &lP); /*! * Destructor that deletes the array of point (freed the memory). @@ -406,7 +411,7 @@ class VISP_EXPORT vpPose /*! * Get the number of inliers. */ - unsigned int getRansacNbInliers() const { return (unsigned int)ransacInliers.size(); } + unsigned int getRansacNbInliers() const { return static_cast(ransacInliers.size()); } /** * Get the vector of indexes corresponding to inliers. @@ -437,10 +442,10 @@ class VISP_EXPORT vpPose */ vpMatrix getCovarianceMatrix() const { - if (!computeCovariance) + if (!computeCovariance) { vpTRACE("Warning : The covariance matrix has not been computed. See " "setCovarianceComputation() to do it."); - + } return covarianceMatrix; } @@ -693,7 +698,7 @@ class VISP_EXPORT vpPose const std::map &ips, const vpCameraParameters &camera_intrinsics, std::optional cMo_init = std::nullopt, bool enable_vvs = true) { - if (cMo_init && !enable_vvs) { + if (cMo_init && (!enable_vvs)) { throw(vpException( vpException::fatalError, "It doesn't make sense to use an initialized pose without enabling VVS to compute the pose from 4 points")); @@ -881,4 +886,8 @@ class VISP_EXPORT vpPose }; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/vision/include/visp3/vision/vpPoseException.h b/modules/vision/include/visp3/vision/vpPoseException.h index ed749e1d82..de51ec66ad 100644 --- a/modules/vision/include/visp3/vision/vpPoseException.h +++ b/modules/vision/include/visp3/vision/vpPoseException.h @@ -39,6 +39,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * \class vpPoseException * \ingroup group_vision_pose @@ -89,4 +94,8 @@ class VISP_EXPORT vpPoseException : public vpException explicit vpPoseException(int id) : vpException(id) { } }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/vision/src/homography-estimation/vpHomography.cpp b/modules/vision/src/homography-estimation/vpHomography.cpp index 9b9dd5d1ff..48c344c589 100644 --- a/modules/vision/src/homography-estimation/vpHomography.cpp +++ b/modules/vision/src/homography-estimation/vpHomography.cpp @@ -48,6 +48,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + vpHomography::vpHomography() : vpArray2D(3, 3), m_aMb(), m_bP() { eye(); } vpHomography::vpHomography(const vpHomography &H) : vpArray2D(3, 3), m_aMb(), m_bP() { *this = H; } @@ -713,3 +718,7 @@ vpHomography vpHomography::homography2collineation(const vpCameraParameters &cam return H; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/homography-estimation/vpHomographyDLT.cpp b/modules/vision/src/homography-estimation/vpHomographyDLT.cpp index 7025c9f5c5..66d3f8d8f3 100644 --- a/modules/vision/src/homography-estimation/vpHomographyDLT.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyDLT.cpp @@ -45,6 +45,11 @@ #include // std::fabs #include // numeric_limits +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS void vpHomography::hartleyNormalization(const std::vector &x, const std::vector &y, @@ -308,3 +313,7 @@ void vpHomography::DLT(const std::vector &xb, const std::vector aHb = aHbn; } } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/homography-estimation/vpHomographyExtract.cpp b/modules/vision/src/homography-estimation/vpHomographyExtract.cpp index 3af2843954..b238259ec1 100644 --- a/modules/vision/src/homography-estimation/vpHomographyExtract.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyExtract.cpp @@ -35,6 +35,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + //#define DEBUG_Homographie 0 /* ---------------------------------------------------------------------- */ @@ -137,28 +142,33 @@ void vpHomography::computeDisplacement(const vpHomography &aHb, const vpColVecto vOrdre[0] = 0; vOrdre[1] = 1; vOrdre[2] = 2; - } else { + } + else { vOrdre[0] = 0; vOrdre[1] = 2; vOrdre[2] = 1; } - } else { + } + else { vOrdre[0] = 2; vOrdre[1] = 0; vOrdre[2] = 1; } - } else { + } + else { if (svTemp[1] >= svTemp[2]) { if (svTemp[0] > svTemp[2]) { vOrdre[0] = 1; vOrdre[1] = 0; vOrdre[2] = 2; - } else { + } + else { vOrdre[0] = 1; vOrdre[1] = 2; vOrdre[2] = 0; } - } else { + } + else { vOrdre[0] = 2; vOrdre[1] = 1; vOrdre[2] = 0; @@ -220,7 +230,8 @@ void vpHomography::computeDisplacement(const vpHomography &aHb, const vpColVecto n[0] = normaleDesiree[0]; n[1] = normaleDesiree[1]; n[2] = normaleDesiree[2]; - } else { + } + else { #ifdef DEBUG_Homographie printf("\nCas general\n"); #endif @@ -318,7 +329,7 @@ void vpHomography::computeDisplacement(const vpHomography &aHb, const vpColVecto de la solution retenue (cf. ci-dessous) *****/ sinusTheta = - (signeSinus * sqrt(((sv[0] * sv[0]) - (sv[1] * sv[1])) * ((sv[1] * sv[1]) - (sv[2] * sv[2])))) / ((sv[0] + sv[2]) * sv[1]); + (signeSinus * sqrt(((sv[0] * sv[0]) - (sv[1] * sv[1])) * ((sv[1] * sv[1]) - (sv[2] * sv[2])))) / ((sv[0] + sv[2]) * sv[1]); cosinusTheta = ((sv[1] * sv[1]) + (sv[0] * sv[2])) / ((sv[0] + sv[2]) * sv[1]); @@ -434,28 +445,33 @@ void vpHomography::computeDisplacement(const vpHomography &aHb, vpRotationMatrix vOrdre[0] = 0; vOrdre[1] = 1; vOrdre[2] = 2; - } else { + } + else { vOrdre[0] = 0; vOrdre[1] = 2; vOrdre[2] = 1; } - } else { + } + else { vOrdre[0] = 2; vOrdre[1] = 0; vOrdre[2] = 1; } - } else { + } + else { if (svTemp[1] >= svTemp[2]) { if (svTemp[0] > svTemp[2]) { vOrdre[0] = 1; vOrdre[1] = 0; vOrdre[2] = 2; - } else { + } + else { vOrdre[0] = 1; vOrdre[1] = 2; vOrdre[2] = 0; } - } else { + } + else { vOrdre[0] = 2; vOrdre[1] = 1; vOrdre[2] = 0; @@ -517,7 +533,8 @@ void vpHomography::computeDisplacement(const vpHomography &aHb, vpRotationMatrix n[0] = normaleDesiree[0]; n[1] = normaleDesiree[1]; n[2] = normaleDesiree[2]; - } else { + } + else { #ifdef DEBUG_Homographie printf("\nCas general\n"); #endif @@ -550,7 +567,7 @@ void vpHomography::computeDisplacement(const vpHomography &aHb, vpRotationMatrix for (unsigned int i = 0; i < 3; ++i) { normaleEstimee[i] = 0.0; for (unsigned int j = 0; j < 3; ++j) { - normaleEstimee[i] += ((2.0 * k )- 1.0) * mV[i][j] * mX[j][w]; + normaleEstimee[i] += ((2.0 * k)- 1.0) * mV[i][j] * mX[j][w]; } } @@ -615,7 +632,7 @@ void vpHomography::computeDisplacement(const vpHomography &aHb, vpRotationMatrix de la solution retenue (cf. ci-dessous) *****/ sinusTheta = - (signeSinus * sqrt(((sv[0] * sv[0]) - (sv[1] * sv[1])) * ((sv[1] * sv[1]) - (sv[2] * sv[2])))) / ((sv[0] + sv[2]) * sv[1]); + (signeSinus * sqrt(((sv[0] * sv[0]) - (sv[1] * sv[1])) * ((sv[1] * sv[1]) - (sv[2] * sv[2])))) / ((sv[0] + sv[2]) * sv[1]); cosinusTheta = ((sv[1] * sv[1]) + (sv[0] * sv[2])) / ((sv[0] + sv[2]) * sv[1]); @@ -713,28 +730,33 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y vOrdre[0] = 0; vOrdre[1] = 1; vOrdre[2] = 2; - } else { + } + else { vOrdre[0] = 0; vOrdre[1] = 2; vOrdre[2] = 1; } - } else { + } + else { vOrdre[0] = 2; vOrdre[1] = 0; vOrdre[2] = 1; } - } else { + } + else { if (svTemp[1] >= svTemp[2]) { if (svTemp[0] > svTemp[2]) { vOrdre[0] = 1; vOrdre[1] = 0; vOrdre[2] = 2; - } else { + } + else { vOrdre[0] = 1; vOrdre[1] = 2; vOrdre[2] = 0; } - } else { + } + else { vOrdre[0] = 2; vOrdre[1] = 1; vOrdre[2] = 0; @@ -764,10 +786,10 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // calcul du determinant de U et V determinantU = (U[0][0] * ((U[1][1] * U[2][2]) - (U[1][2] * U[2][1]))) + (U[0][1] * ((U[1][2] * U[2][0]) - (U[1][0] * U[2][2]))) + - (U[0][2] * ((U[1][0] * U[2][1]) - (U[1][1] * U[2][0]))); + (U[0][2] * ((U[1][0] * U[2][1]) - (U[1][1] * U[2][0]))); determinantV = (V[0][0] * ((V[1][1] * V[2][2]) - (V[1][2] * V[2][1]))) + (V[0][1] * ((V[1][2] * V[2][0]) - (V[1][0] * V[2][2]))) + - (V[0][2] * ((V[1][0] * V[2][1]) - (V[1][1] * V[2][0]))); + (V[0][2] * ((V[1][0] * V[2][1]) - (V[1][1] * V[2][0]))); s = determinantU * determinantV; @@ -807,7 +829,8 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y else { cas = cas2; } - } else { + } + else { if ((sv[1] - sv[2]) < m_sing_threshold) { cas = cas3; } @@ -930,7 +953,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim1[2][0] = (sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] + sv[2]) * sv[1]); + ((sv[0] + sv[2]) * sv[1]); Rprim1[0][2] = -Rprim1[2][0]; @@ -952,7 +975,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim2[2][0] = -(sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] + sv[2]) * sv[1]); + ((sv[0] + sv[2]) * sv[1]); Rprim2[0][2] = -Rprim2[2][0]; @@ -974,7 +997,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim3[2][0] = -(sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] + sv[2]) * sv[1]); + ((sv[0] + sv[2]) * sv[1]); Rprim3[0][2] = -Rprim3[2][0]; @@ -996,7 +1019,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim4[2][0] = (sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] + sv[2]) * sv[1]); + ((sv[0] + sv[2]) * sv[1]); Rprim4[0][2] = -Rprim4[2][0]; @@ -1061,7 +1084,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim1[2][0] = (sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] - sv[2]) * sv[1]); + ((sv[0] - sv[2]) * sv[1]); Rprim1[0][2] = Rprim1[2][0]; @@ -1083,7 +1106,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim2[2][0] = -(sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] - sv[2]) * sv[1]); + ((sv[0] - sv[2]) * sv[1]); Rprim2[0][2] = Rprim2[2][0]; @@ -1105,7 +1128,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim3[2][0] = -(sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] - sv[2]) * sv[1]); + ((sv[0] - sv[2]) * sv[1]); Rprim3[0][2] = Rprim3[2][0]; @@ -1126,7 +1149,7 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y // sin theta Rprim4[2][0] = (sqrt((vpMath::sqr(sv[0]) - vpMath::sqr(sv[1])) * (vpMath::sqr(sv[1]) - vpMath::sqr(sv[2])))) / - ((sv[0] - sv[2]) * sv[1]); + ((sv[0] - sv[2]) * sv[1]); Rprim4[0][2] = Rprim4[2][0]; @@ -1232,14 +1255,15 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y vT.push_back(T4); vN.push_back(N4); } - } else { + } + else { std::cout << "On tombe dans le cas particulier ou le mouvement n'est pas " - "estimable!" - << std::endl; + "estimable!" + << std::endl; } - #ifdef DEBUG_Homographie - // on peut ensuite afficher les resultats... +#ifdef DEBUG_Homographie +// on peut ensuite afficher les resultats... std::cout << "Analyse des resultats : "<< std::endl; if (cas==cas1) { std::cout << "On est dans le cas 1" << std::endl; @@ -1260,10 +1284,14 @@ void vpHomography::computeDisplacement(const vpHomography &H, double x, double y else { std::cout << "d'>0" << std::endl; } - #endif +#endif #ifdef DEBUG_Homographie printf("fin : Homographie_EstimationDeplacementCamera\n"); #endif } #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/homography-estimation/vpHomographyMalis.cpp b/modules/vision/src/homography-estimation/vpHomographyMalis.cpp index 69fb836691..f587e34d96 100644 --- a/modules/vision/src/homography-estimation/vpHomographyMalis.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyMalis.cpp @@ -49,6 +49,10 @@ #include // std::fabs #include // numeric_limits +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS namespace @@ -623,7 +627,11 @@ void vpHomography::HLM(const std::vector &xb, const std::vector q_cible = 3; } - ::hlm(q_cible, xa, ya, xb, yb, H); + hlm(q_cible, xa, ya, xb, yb, H); aHb = H; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/homography-estimation/vpHomographyRansac.cpp b/modules/vision/src/homography-estimation/vpHomographyRansac.cpp index bd0e5fae50..ad2e2c6f3b 100644 --- a/modules/vision/src/homography-estimation/vpHomographyRansac.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyRansac.cpp @@ -39,6 +39,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #define VPEPS 1e-6 /*! @@ -528,3 +533,7 @@ bool vpHomography::ransac(const std::vector &xb, const std::vector #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + const double vpHomography::m_threshold_rotation = 1e-7; const double vpHomography::m_threshold_displacement = 1e-18; @@ -696,3 +701,7 @@ double vpHomography::computeDisplacement(unsigned int nbpoint, vpPoint *c1P, vpP } #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp index a6e091c56e..4de8e57cbc 100644 --- a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp +++ b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp @@ -39,6 +39,11 @@ #include #include "vpLevenbergMarquartd.h" +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #define SIGN(x) ((x) < 0 ? -1 : 1) #define SWAP(a, b, c) \ { \ @@ -1205,3 +1210,7 @@ int lmder1(void (*ptr_fcn)(int m, int n, double *xc, double *fvecc, double *jac, #undef TRUE #undef FALSE + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h index 768dcba371..5ab0e298d0 100644 --- a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h +++ b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h @@ -43,6 +43,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + /*! * ENTREE : * n Ordre de la matrice "r". @@ -459,4 +464,8 @@ int VISP_EXPORT lmder1(void (*ptr_fcn)(int m, int n, double *xc, double *fvecc, int m, int n, double *x, double *fvec, double *fjac, int ldfjac, double tol, int *info, int *ipvt, int lwa, double *wa); +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/vision/src/pose-estimation/vpPose.cpp b/modules/vision/src/pose-estimation/vpPose.cpp index 10ecac0f53..787d09752e 100644 --- a/modules/vision/src/pose-estimation/vpPose.cpp +++ b/modules/vision/src/pose-estimation/vpPose.cpp @@ -49,6 +49,11 @@ #include // std::fabs #include // numeric_limits +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #define DEBUG_LEVEL1 0 vpPose::vpPose() @@ -331,7 +336,8 @@ double vpPose::computeResidual(const vpHomogeneousMatrix &cMo, const vpCameraPar vpMeterPixelConversion::convertPoint(cam, P.get_x(), P.get_y(), u_moved, v_moved); double squaredResidual = vpMath::sqr(u_moved - u_initial) + vpMath::sqr(v_moved - v_initial); - residuals[i++] = squaredResidual; + residuals[i] = squaredResidual; + i++; squared_error += squaredResidual; } return squared_error; @@ -662,3 +668,7 @@ double vpPose::poseFromRectangle(vpPoint &p1, vpPoint &p2, vpPoint &p3, vpPoint P.computePose(vpPose::DEMENTHON_LOWE, cMo); return lx / s; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/vpPoseDementhon.cpp b/modules/vision/src/pose-estimation/vpPoseDementhon.cpp index cfa8763aeb..2fcc251d59 100644 --- a/modules/vision/src/pose-estimation/vpPoseDementhon.cpp +++ b/modules/vision/src/pose-estimation/vpPoseDementhon.cpp @@ -34,6 +34,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #define DEBUG_LEVEL1 0 #define DEBUG_LEVEL2 0 #define DEBUG_LEVEL3 0 @@ -612,3 +617,7 @@ double vpPose::computeResidualDementhon(const vpHomogeneousMatrix &cMo) #undef DEBUG_LEVEL1 #undef DEBUG_LEVEL2 #undef DEBUG_LEVEL3 + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/vpPoseLagrange.cpp b/modules/vision/src/pose-estimation/vpPoseLagrange.cpp index e0d778dbac..98a4542fda 100644 --- a/modules/vision/src/pose-estimation/vpPoseLagrange.cpp +++ b/modules/vision/src/pose-estimation/vpPoseLagrange.cpp @@ -33,6 +33,11 @@ #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #define DEBUG_LEVEL1 0 #define DEBUG_LEVEL2 0 @@ -586,3 +591,7 @@ void vpPose::poseLagrangeNonPlan(vpHomogeneousMatrix &cMo) #undef DEBUG_LEVEL1 #undef DEBUG_LEVEL2 + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/vpPoseLowe.cpp b/modules/vision/src/pose-estimation/vpPoseLowe.cpp index 1544b01bcc..79d9a55e2d 100644 --- a/modules/vision/src/pose-estimation/vpPoseLowe.cpp +++ b/modules/vision/src/pose-estimation/vpPoseLowe.cpp @@ -41,6 +41,11 @@ #include "private/vpLevenbergMarquartd.h" #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + #define NBR_PAR 6 #define X3_SIZE 3 #define MINIMUM 0.000001 @@ -329,3 +334,7 @@ void vpPose::poseLowe(vpHomogeneousMatrix &cMo) #undef MINIMUM #undef DEBUG_LEVEL1 + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/vpPoseRGBD.cpp b/modules/vision/src/pose-estimation/vpPoseRGBD.cpp index bd519fccc4..c9af47f58f 100644 --- a/modules/vision/src/pose-estimation/vpPoseRGBD.cpp +++ b/modules/vision/src/pose-estimation/vpPoseRGBD.cpp @@ -37,8 +37,11 @@ #include #include -namespace +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp { +#endif + // See also vpPlaneEstimation.cpp that implements the same functionaly in c++17 void estimatePlaneEquationSVD(const std::vector &point_cloud_face, vpPlane &plane_equation_estimated, vpColVector ¢roid, double &normalized_weights) @@ -146,8 +149,6 @@ void estimatePlaneEquationSVD(const std::vector &point_cloud_face, vpPla normalized_weights = total_w / nPoints; } -} // namespace - bool vpPose::computePlanarObjectPoseFromRGBD(const vpImage &depthMap, const std::vector &corners, const vpCameraParameters &colorIntrinsics, const std::vector &point3d, vpHomogeneousMatrix &cMo, @@ -445,3 +446,7 @@ bool vpPose::computePlanarObjectPoseFromRGBD(const vpImage &depthMap, } return false; } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/vpPoseRansac.cpp b/modules/vision/src/pose-estimation/vpPoseRansac.cpp index 89ebc2ffb8..a0f6c5ea7e 100644 --- a/modules/vision/src/pose-estimation/vpPoseRansac.cpp +++ b/modules/vision/src/pose-estimation/vpPoseRansac.cpp @@ -53,6 +53,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #define EPS 1e-6 namespace @@ -592,3 +596,7 @@ void vpPose::findMatch(std::vector &p2D, std::vector &p3D, listInliers = pose.getRansacInliers(); } } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp b/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp index 5a47dd1103..7727de8106 100644 --- a/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp +++ b/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp @@ -42,6 +42,11 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif + void vpPose::poseVirtualVS(vpHomogeneousMatrix &cMo) { try { @@ -354,3 +359,7 @@ std::optional vpPose::poseVirtualVSWithDepth(const std::vec } #endif + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif From 66eb0bbc9bd49772d2fb98251dcb2f99403cb06c Mon Sep 17 00:00:00 2001 From: rlagneau Date: Wed, 22 May 2024 09:59:47 +0200 Subject: [PATCH 02/64] [WIP] Put the to and from json in the global namespace --- .../include/visp3/core/vpCameraParameters.h | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/core/include/visp3/core/vpCameraParameters.h b/modules/core/include/visp3/core/vpCameraParameters.h index 649a4567f3..a5f622c06e 100644 --- a/modules/core/include/visp3/core/vpCameraParameters.h +++ b/modules/core/include/visp3/core/vpCameraParameters.h @@ -41,6 +41,7 @@ #ifndef _vpCameraParameters_h_ #define _vpCameraParameters_h_ +#include #include #include @@ -55,12 +56,28 @@ class vpCameraParameters; } #endif +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpCameraParameters &cam); + #ifdef VISP_HAVE_NLOHMANN_JSON #include +// Forward declaration to have the to_json in the global namespace +void to_json(nlohmann::json &j, const #if defined(ENABLE_VISP_NAMESPACE) -void to_json(nlohmann::json &j, const visp::vpCameraParameters &cam); -void from_json(const nlohmann::json &j, visp::vpCameraParameters &cam); + visp:: +#endif + vpCameraParameters &cam); + +// Forward declaration to have the from_json in the global namespace +void from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) + visp:: #endif + vpCameraParameters &cam); #endif /*! @@ -430,7 +447,7 @@ class VISP_EXPORT vpMatrix get_K_inverse() const; void printParameters(); - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpCameraParameters &cam); private: static const double DEFAULT_U0_PARAMETER; From 785de1f881fcbb5a5172f0cab91c0adbcc9ea97b Mon Sep 17 00:00:00 2001 From: rlagneau Date: Wed, 22 May 2024 10:01:28 +0200 Subject: [PATCH 03/64] [WIP] Added namespace in core/image --- .../include/visp3/core/vpCannyEdgeDetection.h | 49 ++++++++--------- modules/core/include/visp3/core/vpColormap.h | 15 +++-- modules/core/include/visp3/core/vpConvert.h | 6 +- modules/core/include/visp3/core/vpFont.h | 14 +++-- modules/core/include/visp3/core/vpImageDraw.h | 15 +++-- .../core/include/visp3/core/vpImagePoint.h | 55 ++++++++++++++----- modules/core/include/visp3/core/vpRGBa.h | 20 ++++++- modules/core/include/visp3/core/vpRGBf.h | 15 +++++ .../core/src/image/vpCannyEdgeDetection.cpp | 51 +++++++++++++++++ modules/core/src/image/vpColormap.cpp | 7 +++ modules/core/src/image/vpFont.cpp | 7 +++ modules/core/src/image/vpImageDraw.cpp | 7 +++ 12 files changed, 202 insertions(+), 59 deletions(-) diff --git a/modules/core/include/visp3/core/vpCannyEdgeDetection.h b/modules/core/include/visp3/core/vpCannyEdgeDetection.h index 2f319d770c..84d08cfe64 100644 --- a/modules/core/include/visp3/core/vpCannyEdgeDetection.h +++ b/modules/core/include/visp3/core/vpCannyEdgeDetection.h @@ -40,9 +40,29 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +class vpCannyEdgeDetection; +} +#endif + // 3rd parties include #ifdef VISP_HAVE_NLOHMANN_JSON #include + +// Forward declaration to have the methods in the global namespace +void from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpCannyEdgeDetection &detector); + +void to_json(nlohmann::json &j, const +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpCannyEdgeDetection &detector); #endif #if defined(ENABLE_VISP_NAMESPACE) @@ -115,19 +135,7 @@ class VISP_EXPORT vpCannyEdgeDetection * \param[in] j : The JSON object, resulting from the parsing of a JSON file. * \param[out] detector : The detector that will be initialized from the JSON data. */ - friend inline void from_json(const nlohmann::json &j, vpCannyEdgeDetection &detector) - { - std::string filteringAndGradientName = vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); - filteringAndGradientName = j.value("filteringAndGradientType", filteringAndGradientName); - detector.m_filteringAndGradientType = vpImageFilter::vpCannyFiltAndGradTypeFromStr(filteringAndGradientName); - detector.m_gaussianKernelSize = j.value("gaussianSize", detector.m_gaussianKernelSize); - detector.m_gaussianStdev = j.value("gaussianStdev", detector.m_gaussianStdev); - detector.m_lowerThreshold = j.value("lowerThreshold", detector.m_lowerThreshold); - detector.m_lowerThresholdRatio = j.value("lowerThresholdRatio", detector.m_lowerThresholdRatio); - detector.m_gradientFilterKernelSize = j.value("gradientFilterKernelSize", detector.m_gradientFilterKernelSize); - detector.m_upperThreshold = j.value("upperThreshold", detector.m_upperThreshold); - detector.m_upperThresholdRatio = j.value("upperThresholdRatio", detector.m_upperThresholdRatio); - } + friend void ::from_json(const nlohmann::json &j, vpCannyEdgeDetection &detector); /** * \brief Parse a vpCannyEdgeDetection object into JSON format. @@ -135,20 +143,7 @@ class VISP_EXPORT vpCannyEdgeDetection * \param[out] j : A JSON parser object. * \param[in] detector : The vpCannyEdgeDetection object that must be parsed into JSON format. */ - friend inline void to_json(nlohmann::json &j, const vpCannyEdgeDetection &detector) - { - std::string filteringAndGradientName = vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); - j = nlohmann::json { - {"filteringAndGradientType", filteringAndGradientName}, - {"gaussianSize", detector.m_gaussianKernelSize}, - {"gaussianStdev", detector.m_gaussianStdev}, - {"lowerThreshold", detector.m_lowerThreshold}, - {"lowerThresholdRatio", detector.m_lowerThresholdRatio}, - {"gradientFilterKernelSize", detector.m_gradientFilterKernelSize}, - {"upperThreshold", detector.m_upperThreshold}, - {"upperThresholdRatio", detector.m_upperThresholdRatio} - }; - } + friend inline void ::to_json(nlohmann::json &j, const vpCannyEdgeDetection &detector); #endif //@} diff --git a/modules/core/include/visp3/core/vpColormap.h b/modules/core/include/visp3/core/vpColormap.h index 74147bcdcd..0d8d737628 100644 --- a/modules/core/include/visp3/core/vpColormap.h +++ b/modules/core/include/visp3/core/vpColormap.h @@ -32,20 +32,23 @@ * some corresponding color values, for better visualization for example. */ -#ifndef _vpColormap_h_ -#define _vpColormap_h_ - /*! * \file vpColormap.h * * \brief Colormap tool to have a mapping between 256 values and RGB values. */ +#ifndef _vpColormap_h_ +#define _vpColormap_h_ + #include #include #include - +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * \class vpColormap * @@ -99,5 +102,7 @@ class VISP_EXPORT vpColormap unsigned char m_colormapSrgbBytes[256][3]; #endif }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpConvert.h b/modules/core/include/visp3/core/vpConvert.h index b87095f7bc..a6def4962c 100644 --- a/modules/core/include/visp3/core/vpConvert.h +++ b/modules/core/include/visp3/core/vpConvert.h @@ -31,14 +31,14 @@ * Directory management. */ -#ifndef _vpConvert_h_ -#define _vpConvert_h_ - /*! \file vpConvert.h \brief Tools for type or general conversion. */ +#ifndef _vpConvert_h_ +#define _vpConvert_h_ + #include #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_FEATURES2D) diff --git a/modules/core/include/visp3/core/vpFont.h b/modules/core/include/visp3/core/vpFont.h index 39031505c2..de15cb3c81 100644 --- a/modules/core/include/visp3/core/vpFont.h +++ b/modules/core/include/visp3/core/vpFont.h @@ -31,18 +31,22 @@ * Draw text in an image. */ -#ifndef _vpFont_h_ -#define _vpFont_h_ - /*! \file vpFont.h \brief Draw text in an image. */ +#ifndef _vpFont_h_ +#define _vpFont_h_ + #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpFont @@ -80,5 +84,7 @@ class VISP_EXPORT vpFont class Impl; Impl *m_impl; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImageDraw.h b/modules/core/include/visp3/core/vpImageDraw.h index 88425623a6..84af344082 100644 --- a/modules/core/include/visp3/core/vpImageDraw.h +++ b/modules/core/include/visp3/core/vpImageDraw.h @@ -31,15 +31,16 @@ * Drawing functions. */ -#ifndef _vpImageDraw_h_ -#define _vpImageDraw_h_ - /*! \file vpImageDraw.h \brief Drawing functions for image. */ +#ifndef _vpImageDraw_h_ +#define _vpImageDraw_h_ + +#include #include #include #include @@ -47,6 +48,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpImageDraw @@ -115,5 +120,7 @@ class VISP_EXPORT vpImageDraw static void drawRectangle(vpImage &I, const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness = 1); }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpImagePoint.h b/modules/core/include/visp3/core/vpImagePoint.h index 037434d7f8..e87dba4a9e 100644 --- a/modules/core/include/visp3/core/vpImagePoint.h +++ b/modules/core/include/visp3/core/vpImagePoint.h @@ -48,11 +48,38 @@ #include #if defined(ENABLE_VISP_NAMESPACE) +#define VISP_VPIMAGEPOINT_NAMESPACE visp:: namespace visp { +#else +#define VISP_VPIMAGEPOINT_NAMESPACE #endif +class vpImagePoint; class vpRect; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +// Forward declaration to have the operators in the global namespace when using ViSP namespace +bool operator==(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); +bool operator!=(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+=(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, int offset); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, unsigned int offset); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double offset); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, int offset); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, unsigned int offset); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double offset); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator*(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double scale); +VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator/(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double scale); +std::ostream &operator<<(std::ostream &os, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip); +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpImagePoint \ingroup group_core_image @@ -364,20 +391,20 @@ class VISP_EXPORT vpImagePoint static vpRect getBBox(const std::vector &ipVec); static double sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP2); - friend VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint operator+=(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, int offset); - friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, unsigned int offset); - friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, double offset); - friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, int offset); - friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, unsigned int offset); - friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, double offset); - friend VISP_EXPORT vpImagePoint operator*(const vpImagePoint &ip1, double scale); - friend VISP_EXPORT vpImagePoint operator/(const vpImagePoint &ip1, double scale); - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpImagePoint &ip); + friend VISP_EXPORT bool ::operator==(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT bool ::operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint ::operator+=(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, int offset); + friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, unsigned int offset); + friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, double offset); + friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, int offset); + friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, unsigned int offset); + friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, double offset); + friend VISP_EXPORT vpImagePoint ::operator*(const vpImagePoint &ip1, double scale); + friend VISP_EXPORT vpImagePoint ::operator/(const vpImagePoint &ip1, double scale); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpImagePoint &ip); private: double i, j; diff --git a/modules/core/include/visp3/core/vpRGBa.h b/modules/core/include/visp3/core/vpRGBa.h index aec295dbd1..1703078d64 100644 --- a/modules/core/include/visp3/core/vpRGBa.h +++ b/modules/core/include/visp3/core/vpRGBa.h @@ -43,6 +43,22 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +#define VISP_VPRGBA_NAMESPACE visp:: +namespace visp +{ +#else +#define VISP_VPRGBA_NAMESPACE +#endif +class vpRGBa; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +// Forward declaration to have the operators in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_VPRGBA_NAMESPACE vpRGBa &rgba); +VISP_VPRGBA_NAMESPACE vpRGBa operator*(const double &x, const VISP_VPRGBA_NAMESPACE vpRGBa &rgb); + #if defined(ENABLE_VISP_NAMESPACE) namespace visp { @@ -136,7 +152,7 @@ class VISP_EXPORT vpRGBa bool operator<(const vpRGBa &v) const; bool operator>(const vpRGBa &v) const; - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpRGBa &rgba); public: unsigned char R; //!< Red component. @@ -144,7 +160,7 @@ class VISP_EXPORT vpRGBa unsigned char B; //!< Blue component. unsigned char A; //!< Additionnal component. - friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb); + friend VISP_EXPORT vpRGBa ::operator*(const double &x, const vpRGBa &rgb); }; #if defined(ENABLE_VISP_NAMESPACE) } diff --git a/modules/core/include/visp3/core/vpRGBf.h b/modules/core/include/visp3/core/vpRGBf.h index 099d956094..4550516063 100644 --- a/modules/core/include/visp3/core/vpRGBf.h +++ b/modules/core/include/visp3/core/vpRGBf.h @@ -43,6 +43,21 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +#define VISP_VPRGBF_NAMESPACE visp:: +namespace visp +{ +#else +#define VISP_VPRGBF_NAMESPACE +#endif +class vpRGBf; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +std::ostream &operator<<(std::ostream &os, const VISP_VPRGBF_NAMESPACE vpRGBf &rgb); +VISP_VPRGBF_NAMESPACE vpRGBf operator*(double x, const VISP_VPRGBF_NAMESPACE vpRGBf &rgb); + #if defined(ENABLE_VISP_NAMESPACE) namespace visp { diff --git a/modules/core/src/image/vpCannyEdgeDetection.cpp b/modules/core/src/image/vpCannyEdgeDetection.cpp index 0fd696bec0..78a5ab0783 100644 --- a/modules/core/src/image/vpCannyEdgeDetection.cpp +++ b/modules/core/src/image/vpCannyEdgeDetection.cpp @@ -56,6 +56,57 @@ static void scaleFilter( }; #endif +#ifdef VISP_HAVE_NLOHMANN_JSON +void ::from_json(const nlohmann::json &j, +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpCannyEdgeDetection &detector) +{ + std::string filteringAndGradientName = +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); + filteringAndGradientName = j.value("filteringAndGradientType", filteringAndGradientName); + detector.m_filteringAndGradientType = +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpImageFilter::vpCannyFiltAndGradTypeFromStr(filteringAndGradientName); + detector.m_gaussianKernelSize = j.value("gaussianSize", detector.m_gaussianKernelSize); + detector.m_gaussianStdev = j.value("gaussianStdev", detector.m_gaussianStdev); + detector.m_lowerThreshold = j.value("lowerThreshold", detector.m_lowerThreshold); + detector.m_lowerThresholdRatio = j.value("lowerThresholdRatio", detector.m_lowerThresholdRatio); + detector.m_gradientFilterKernelSize = j.value("gradientFilterKernelSize", detector.m_gradientFilterKernelSize); + detector.m_upperThreshold = j.value("upperThreshold", detector.m_upperThreshold); + detector.m_upperThresholdRatio = j.value("upperThresholdRatio", detector.m_upperThresholdRatio); +} + +void ::to_json(nlohmann::json &j, const +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif +vpCannyEdgeDetection &detector) +{ + std::string filteringAndGradientName = +#if defined(ENABLE_VISP_NAMESPACE) + visp:: +#endif + vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); + j = nlohmann::json { + {"filteringAndGradientType", filteringAndGradientName}, + {"gaussianSize", detector.m_gaussianKernelSize}, + {"gaussianStdev", detector.m_gaussianStdev}, + {"lowerThreshold", detector.m_lowerThreshold}, + {"lowerThresholdRatio", detector.m_lowerThresholdRatio}, + {"gradientFilterKernelSize", detector.m_gradientFilterKernelSize}, + {"upperThreshold", detector.m_upperThreshold}, + {"upperThresholdRatio", detector.m_upperThresholdRatio} + }; +} +#endif + #if defined(ENABLE_VISP_NAMESPACE) namespace visp { diff --git a/modules/core/src/image/vpColormap.cpp b/modules/core/src/image/vpColormap.cpp index 2c1ff37eba..1cb501b5a6 100644 --- a/modules/core/src/image/vpColormap.cpp +++ b/modules/core/src/image/vpColormap.cpp @@ -1007,6 +1007,10 @@ unsigned char m_winterSrgbBytes[256][3] = { }; }; +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Creates a colormap class to be able to recolor an image with different grayscale values into some corresponding color values, for better visualization for example. @@ -1217,3 +1221,6 @@ void vpColormap::convert(const vpImage &I, vpImage &Icolor) } convert(I_float, Icolor); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpFont.cpp b/modules/core/src/image/vpFont.cpp index fd706e8afb..6b9b3e99c8 100644 --- a/modules/core/src/image/vpFont.cpp +++ b/modules/core/src/image/vpFont.cpp @@ -67,6 +67,10 @@ #define STB_TRUETYPE_IMPLEMENTATION #include "private/stb_truetype.h" +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpFont::Impl { @@ -2692,3 +2696,6 @@ vpImagePoint vpFont::getMeasure(const std::string &text) const { return m_impl-> \return A result of the operation. */ bool vpFont::setHeight(unsigned int height) { return m_impl->Resize(height); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpImageDraw.cpp b/modules/core/src/image/vpImageDraw.cpp index ce28d0e698..fe146e9444 100644 --- a/modules/core/src/image/vpImageDraw.cpp +++ b/modules/core/src/image/vpImageDraw.cpp @@ -234,6 +234,10 @@ void DrawRectangle(vpImage &canvas, const vpRect &rect, const Type &color, } } // namespace +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! Draw an arrow from image point \e ip1 to image point \e ip2. \param[in,out] I : Image where to draw the arrow. @@ -976,3 +980,6 @@ void vpImageDraw::drawRectangle(vpImage &I, const vpRect &rectangle, con DrawRectangle(I, rectangle, vpRGBa(color.R, color.G, color.B), thickness); } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif From ada9e77f7cc05438d3d03b6c4cdf9a02a2985db8 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Wed, 22 May 2024 10:27:14 +0200 Subject: [PATCH 04/64] [WIP] Added namespace in vpMunkres --- modules/core/include/visp3/core/vpMunkres.h | 8 +++++++- modules/core/src/munkres/vpMunkres.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/core/include/visp3/core/vpMunkres.h b/modules/core/include/visp3/core/vpMunkres.h index 27d9c0c2a7..221dd0a97e 100644 --- a/modules/core/include/visp3/core/vpMunkres.h +++ b/modules/core/include/visp3/core/vpMunkres.h @@ -46,6 +46,10 @@ // Internal #include "vpMath.h" +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! \class vpMunkres \ingroup group_core_munkres @@ -369,5 +373,7 @@ inline std::vector > vpMunkres::run(std::v return ret; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/src/munkres/vpMunkres.cpp b/modules/core/src/munkres/vpMunkres.cpp index fc8b3c3ec3..7af19d50f1 100644 --- a/modules/core/src/munkres/vpMunkres.cpp +++ b/modules/core/src/munkres/vpMunkres.cpp @@ -42,6 +42,10 @@ // Check if std:c++17 or higher #if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))) +#if defined(ENABLE_VISP_NAMESPACE) +namespace visp +{ +#endif /*! * Find a starred zero in a specific mask matrix row. * @@ -191,5 +195,7 @@ vpMunkres::STEP_T vpMunkres::stepFive(std::vector } } } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif From c6189b06da2e6d9dc37b9a92d6c4cf6bec2cc4b0 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Wed, 22 May 2024 16:04:29 +0200 Subject: [PATCH 05/64] [CORE] visp_core compile in standalone using 'make visp_core' command --- .vscode/settings.json | 1 + cmake/templates/vpConfig.h.in | 7 + modules/core/include/visp3/core/vpArray2D.h | 102 +++++----- modules/core/include/visp3/core/vpBSpline.h | 14 +- .../core/include/visp3/core/vpCPUFeatures.h | 2 +- .../include/visp3/core/vpCameraParameters.h | 27 +-- .../include/visp3/core/vpCannyEdgeDetection.h | 22 +- modules/core/include/visp3/core/vpCircle.h | 2 +- modules/core/include/visp3/core/vpClient.h | 8 +- modules/core/include/visp3/core/vpColVector.h | 20 +- modules/core/include/visp3/core/vpColor.h | 22 +- .../visp3/core/vpColorDepthConversion.h | 2 +- modules/core/include/visp3/core/vpColormap.h | 2 +- modules/core/include/visp3/core/vpConvert.h | 8 +- modules/core/include/visp3/core/vpCylinder.h | 8 +- modules/core/include/visp3/core/vpDebug.h | 2 +- modules/core/include/visp3/core/vpDisplay.h | 2 +- .../include/visp3/core/vpDisplayException.h | 2 +- .../include/visp3/core/vpEigenConversion.h | 2 +- modules/core/include/visp3/core/vpEndian.h | 2 +- modules/core/include/visp3/core/vpException.h | 15 +- .../include/visp3/core/vpExponentialMap.h | 2 +- .../include/visp3/core/vpFeatureDisplay.h | 2 +- modules/core/include/visp3/core/vpFont.h | 2 +- .../include/visp3/core/vpForceTwistMatrix.h | 4 +- .../include/visp3/core/vpForwardProjection.h | 2 +- .../core/include/visp3/core/vpFrameGrabber.h | 2 +- .../visp3/core/vpFrameGrabberException.h | 2 +- modules/core/include/visp3/core/vpGEMM.h | 2 +- modules/core/include/visp3/core/vpGaussRand.h | 13 +- .../include/visp3/core/vpGaussianFilter.h | 2 +- modules/core/include/visp3/core/vpHinkley.h | 7 +- modules/core/include/visp3/core/vpHistogram.h | 2 +- .../core/include/visp3/core/vpHistogramPeak.h | 15 +- .../include/visp3/core/vpHistogramValey.h | 15 +- .../include/visp3/core/vpHomogeneousMatrix.h | 29 +-- modules/core/include/visp3/core/vpImage.h | 74 ++++--- .../core/include/visp3/core/vpImageCircle.h | 2 +- .../core/include/visp3/core/vpImageConvert.h | 2 +- modules/core/include/visp3/core/vpImageDraw.h | 2 +- .../include/visp3/core/vpImageException.h | 2 +- .../core/include/visp3/core/vpImageFilter.h | 2 +- .../include/visp3/core/vpImageMorphology.h | 2 +- .../core/include/visp3/core/vpImagePoint.h | 57 +++--- .../core/include/visp3/core/vpImageTools.h | 2 +- .../core/include/visp3/core/vpIoException.h | 2 +- modules/core/include/visp3/core/vpIoTools.h | 6 +- .../core/include/visp3/core/vpJsonParsing.h | 2 +- .../core/include/visp3/core/vpKalmanFilter.h | 20 +- modules/core/include/visp3/core/vpLinProg.h | 17 +- modules/core/include/visp3/core/vpLine.h | 2 +- .../core/vpLinearKalmanFilterInstantiation.h | 18 +- modules/core/include/visp3/core/vpList.h | 2 +- modules/core/include/visp3/core/vpMath.h | 2 +- modules/core/include/visp3/core/vpMatrix.h | 4 +- .../include/visp3/core/vpMatrixException.h | 2 +- .../visp3/core/vpMeterPixelConversion.h | 2 +- modules/core/include/visp3/core/vpMoment.h | 20 +- .../core/include/visp3/core/vpMomentAlpha.h | 23 ++- .../core/include/visp3/core/vpMomentArea.h | 22 +- .../visp3/core/vpMomentAreaNormalized.h | 22 +- .../core/include/visp3/core/vpMomentBasic.h | 22 +- .../include/visp3/core/vpMomentCInvariant.h | 21 +- .../include/visp3/core/vpMomentCentered.h | 32 ++- .../core/include/visp3/core/vpMomentCommon.h | 7 + .../include/visp3/core/vpMomentDatabase.h | 21 +- .../visp3/core/vpMomentGravityCenter.h | 22 +- .../core/vpMomentGravityCenterNormalized.h | 21 +- .../core/include/visp3/core/vpMomentObject.h | 21 +- .../core/include/visp3/core/vpMouseButton.h | 2 +- modules/core/include/visp3/core/vpMunkres.h | 2 +- modules/core/include/visp3/core/vpMutex.h | 8 +- modules/core/include/visp3/core/vpNetwork.h | 8 +- .../visp3/core/vpPixelMeterConversion.h | 2 +- modules/core/include/visp3/core/vpPlane.h | 17 +- modules/core/include/visp3/core/vpPoint.h | 15 +- modules/core/include/visp3/core/vpPolygon.h | 2 +- modules/core/include/visp3/core/vpPolygon3D.h | 42 ++-- .../core/include/visp3/core/vpPoseVector.h | 57 ++---- modules/core/include/visp3/core/vpQuadProg.h | 17 +- .../include/visp3/core/vpQuaternionVector.h | 2 +- modules/core/include/visp3/core/vpRGBa.h | 13 +- modules/core/include/visp3/core/vpRGBf.h | 16 +- modules/core/include/visp3/core/vpRansac.h | 2 +- modules/core/include/visp3/core/vpRect.h | 19 +- .../core/include/visp3/core/vpRectOriented.h | 2 +- modules/core/include/visp3/core/vpRequest.h | 8 +- modules/core/include/visp3/core/vpRobust.h | 2 +- .../include/visp3/core/vpRotationMatrix.h | 2 +- .../include/visp3/core/vpRotationVector.h | 2 +- modules/core/include/visp3/core/vpRowVector.h | 2 +- .../core/include/visp3/core/vpRxyzVector.h | 2 +- .../core/include/visp3/core/vpRzyxVector.h | 2 +- .../core/include/visp3/core/vpRzyzVector.h | 2 +- modules/core/include/visp3/core/vpScale.h | 8 +- modules/core/include/visp3/core/vpSerial.h | 20 +- modules/core/include/visp3/core/vpServer.h | 8 +- modules/core/include/visp3/core/vpSphere.h | 2 +- .../visp3/core/vpStatisticalTestAbstract.h | 8 +- .../visp3/core/vpStatisticalTestEWMA.h | 7 + .../visp3/core/vpStatisticalTestHinkley.h | 8 +- .../core/vpStatisticalTestMeanAdjustedCUSUM.h | 7 + .../visp3/core/vpStatisticalTestShewhart.h | 8 +- .../visp3/core/vpStatisticalTestSigma.h | 8 +- .../core/include/visp3/core/vpSubColVector.h | 2 +- modules/core/include/visp3/core/vpSubMatrix.h | 2 +- .../core/include/visp3/core/vpSubRowVector.h | 2 +- .../core/include/visp3/core/vpThetaUVector.h | 2 +- modules/core/include/visp3/core/vpThread.h | 8 +- modules/core/include/visp3/core/vpTime.h | 2 +- modules/core/include/visp3/core/vpTracker.h | 2 +- .../include/visp3/core/vpTrackingException.h | 2 +- .../include/visp3/core/vpTranslationVector.h | 2 +- modules/core/include/visp3/core/vpTriangle.h | 17 +- modules/core/include/visp3/core/vpUDPClient.h | 8 +- modules/core/include/visp3/core/vpUDPServer.h | 8 +- .../visp3/core/vpUKSigmaDrawerAbstract.h | 7 + .../include/visp3/core/vpUKSigmaDrawerMerwe.h | 7 + modules/core/include/visp3/core/vpUniRand.h | 2 +- .../include/visp3/core/vpUnscentedKalman.h | 8 +- .../visp3/core/vpVelocityTwistMatrix.h | 2 +- modules/core/include/visp3/core/vpXmlParser.h | 14 +- .../include/visp3/core/vpXmlParserCamera.h | 2 +- .../visp3/core/vpXmlParserHomogeneousMatrix.h | 2 +- .../visp3/core/vpXmlParserRectOriented.h | 2 +- .../core/src/camera/vpCameraParameters.cpp | 19 +- .../src/camera/vpColorDepthConversion.cpp | 2 +- .../src/camera/vpMeterPixelConversion.cpp | 2 +- .../src/camera/vpPixelMeterConversion.cpp | 2 +- modules/core/src/camera/vpXmlParserCamera.cpp | 2 +- modules/core/src/display/vpColor.cpp | 13 +- modules/core/src/display/vpDisplay.cpp | 2 +- modules/core/src/display/vpDisplay_impl.h | 2 +- modules/core/src/display/vpDisplay_rgba.cpp | 2 +- modules/core/src/display/vpDisplay_uchar.cpp | 2 +- modules/core/src/display/vpFeatureDisplay.cpp | 2 +- .../core/src/framegrabber/vpFrameGrabber.cpp | 2 +- .../src/image/private/vpBayerConversion.h | 20 +- .../src/image/private/vpImageConvert_impl.h | 2 +- .../core/src/image/vpCannyEdgeDetection.cpp | 31 +-- modules/core/src/image/vpColormap.cpp | 2 +- modules/core/src/image/vpFont.cpp | 2 +- modules/core/src/image/vpGaussianFilter.cpp | 2 +- modules/core/src/image/vpImageCircle.cpp | 2 +- modules/core/src/image/vpImageConvert.cpp | 2 +- modules/core/src/image/vpImageConvert_hsv.cpp | 2 +- modules/core/src/image/vpImageConvert_pcl.cpp | 2 +- modules/core/src/image/vpImageConvert_yuv.cpp | 2 +- modules/core/src/image/vpImageDraw.cpp | 5 +- modules/core/src/image/vpImageFilter.cpp | 2 +- modules/core/src/image/vpImagePoint.cpp | 144 ++++++------- modules/core/src/image/vpImageTools.cpp | 2 +- modules/core/src/image/vpRGBa.cpp | 12 +- modules/core/src/image/vpRGBf.cpp | 12 +- .../core/src/math/kalman/vpKalmanFilter.cpp | 189 +++++++++--------- .../vpLinearKalmanFilterInstantiation.cpp | 10 +- .../src/math/kalman/vpUKSigmaDrawerMerwe.cpp | 7 + .../src/math/kalman/vpUnscentedKalman.cpp | 7 + modules/core/src/math/matrix/vpColVector.cpp | 2 +- modules/core/src/math/matrix/vpMatrix.cpp | 2 +- .../src/math/matrix/vpMatrix_cholesky.cpp | 2 +- .../src/math/matrix/vpMatrix_covariance.cpp | 2 +- modules/core/src/math/matrix/vpMatrix_lu.cpp | 2 +- modules/core/src/math/matrix/vpMatrix_mul.cpp | 2 +- modules/core/src/math/matrix/vpMatrix_qr.cpp | 2 +- modules/core/src/math/matrix/vpMatrix_svd.cpp | 2 +- modules/core/src/math/matrix/vpRowVector.cpp | 2 +- .../core/src/math/matrix/vpSubColVector.cpp | 2 +- modules/core/src/math/matrix/vpSubMatrix.cpp | 2 +- .../core/src/math/matrix/vpSubRowVector.cpp | 2 +- modules/core/src/math/misc/vpHinkley.cpp | 7 + modules/core/src/math/misc/vpMath.cpp | 2 +- .../math/misc/vpStatisticalTestAbstract.cpp | 7 + .../src/math/misc/vpStatisticalTestEWMA.cpp | 7 + .../math/misc/vpStatisticalTestHinkley.cpp | 7 + .../vpStatisticalTestMeanAdjustedCUSUM.cpp | 7 + .../math/misc/vpStatisticalTestShewhart.cpp | 7 + .../src/math/misc/vpStatisticalTestSigma.cpp | 7 + .../src/math/random-generator/vpGaussRand.cpp | 7 + .../src/math/random-generator/vpUniRand.cpp | 2 +- modules/core/src/math/robust/vpRobust.cpp | 2 +- modules/core/src/math/robust/vpScale.cpp | 15 +- modules/core/src/math/spline/vpBSpline.cpp | 7 + .../math/transformation/vpExponentialMap.cpp | 2 +- .../transformation/vpForceTwistMatrix.cpp | 2 +- .../transformation/vpHomogeneousMatrix.cpp | 4 +- .../src/math/transformation/vpPoseVector.cpp | 4 +- .../transformation/vpQuaternionVector.cpp | 2 +- .../math/transformation/vpRotationMatrix.cpp | 2 +- .../math/transformation/vpRotationVector.cpp | 2 +- .../src/math/transformation/vpRxyzVector.cpp | 2 +- .../src/math/transformation/vpRzyxVector.cpp | 2 +- .../src/math/transformation/vpRzyzVector.cpp | 2 +- .../math/transformation/vpThetaUVector.cpp | 2 +- .../transformation/vpTranslationVector.cpp | 2 +- .../transformation/vpVelocityTwistMatrix.cpp | 2 +- .../vpXmlParserHomogeneousMatrix.cpp | 2 +- modules/core/src/munkres/vpMunkres.cpp | 2 +- modules/core/src/tools/convert/vpConvert.cpp | 7 + .../src/tools/cpu-features/vpCPUFeatures.cpp | 2 +- modules/core/src/tools/endian/vpEndian.cpp | 2 +- .../core/src/tools/exceptions/vpException.cpp | 10 +- modules/core/src/tools/file/vpIoTools.cpp | 70 +++---- modules/core/src/tools/geometry/vpPlane.cpp | 11 +- modules/core/src/tools/geometry/vpPolygon.cpp | 14 +- .../core/src/tools/geometry/vpPolygon3D.cpp | 43 ++-- modules/core/src/tools/geometry/vpRect.cpp | 12 +- .../src/tools/geometry/vpRectOriented.cpp | 2 +- .../core/src/tools/geometry/vpTriangle.cpp | 7 + .../geometry/vpXmlParserRectOriented.cpp | 2 +- .../core/src/tools/histogram/vpHistogram.cpp | 2 +- .../src/tools/histogram/vpHistogramPeak.cpp | 10 +- .../src/tools/histogram/vpHistogramValey.cpp | 12 +- modules/core/src/tools/network/vpClient.cpp | 35 ++-- modules/core/src/tools/network/vpNetwork.cpp | 9 +- modules/core/src/tools/network/vpRequest.cpp | 7 + modules/core/src/tools/network/vpServer.cpp | 26 ++- .../core/src/tools/network/vpUDPClient.cpp | 21 +- .../core/src/tools/network/vpUDPServer.cpp | 29 ++- .../core/src/tools/optimization/vpLinProg.cpp | 8 +- .../src/tools/optimization/vpQuadProg.cpp | 9 +- modules/core/src/tools/serial/vpSerial.cpp | 46 +++-- modules/core/src/tools/time/vpTime.cpp | 2 +- modules/core/src/tools/xml/vpXmlParser.cpp | 8 +- .../tracking/forward-projection/vpCircle.cpp | 2 +- .../forward-projection/vpCylinder.cpp | 7 + .../vpForwardProjection.cpp | 2 +- .../tracking/forward-projection/vpLine.cpp | 2 +- .../tracking/forward-projection/vpPoint.cpp | 6 +- .../tracking/forward-projection/vpSphere.cpp | 2 +- .../core/src/tracking/moments/vpMoment.cpp | 34 ++-- .../src/tracking/moments/vpMomentAlpha.cpp | 43 ++-- .../src/tracking/moments/vpMomentArea.cpp | 37 ++-- .../moments/vpMomentAreaNormalized.cpp | 29 ++- .../src/tracking/moments/vpMomentBasic.cpp | 39 ++-- .../tracking/moments/vpMomentCInvariant.cpp | 27 ++- .../src/tracking/moments/vpMomentCentered.cpp | 87 ++++---- .../src/tracking/moments/vpMomentCommon.cpp | 7 + .../src/tracking/moments/vpMomentDatabase.cpp | 12 +- .../moments/vpMomentGravityCenter.cpp | 28 ++- .../vpMomentGravityCenterNormalized.cpp | 35 ++-- .../src/tracking/moments/vpMomentObject.cpp | 83 ++++---- modules/core/src/tracking/vpTracker.cpp | 2 +- 243 files changed, 1798 insertions(+), 1031 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 26ebfdc369..e4c76f7c07 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -195,4 +195,5 @@ "editor.rulers": [ {"column": 120, "color": "#ffcc00"} ], + "C_Cpp.default.compilerPath": "/usr/bin/g++", } diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index 2bdcb71606..20a64ae3c1 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -114,6 +114,13 @@ // Defined if the user wants to protect the classes in a dedicated visp namespace #cmakedefine ENABLE_VISP_NAMESPACE +#ifdef ENABLE_VISP_NAMESPACE +#define VISP_NAMESPACE_NAME visp +#define VISP_NAMESPACE_ADDRESSING visp:: +#else +#define VISP_NAMESPACE_NAME +#define VISP_NAMESPACE_ADDRESSING +#endif // Enable debug and trace printings #cmakedefine VP_TRACE diff --git a/modules/core/include/visp3/core/vpArray2D.h b/modules/core/include/visp3/core/vpArray2D.h index ca5342de7d..bf91691201 100644 --- a/modules/core/include/visp3/core/vpArray2D.h +++ b/modules/core/include/visp3/core/vpArray2D.h @@ -47,24 +47,32 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { +#endif template class vpArray2D; +#if defined(ENABLE_VISP_NAMESPACE) } #endif +template +std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpArray2D &A); + #ifdef VISP_HAVE_NLOHMANN_JSON #include -#if defined(ENABLE_VISP_NAMESPACE) //template template -void from_json(const nlohmann::json &j, visp::vpArray2D &array); +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpArray2D &array); + //template template -void to_json(nlohmann::json &j, const visp::vpArray2D &array); -#endif +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpArray2D &array); #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpArray2D * \ingroup group_core_matrices @@ -137,11 +145,7 @@ void to_json(nlohmann::json &j, const visp::vpArray2D &array); * } * \endcode */ -template class -#if defined(ENABLE_VISP_NAMESPACE) -visp:: -#endif -vpArray2D +template class vpArray2D { protected: //! Number of rows in the array @@ -619,32 +623,7 @@ vpArray2D Writes the given array to the output stream and returns a reference to the output stream. */ - friend std::ostream &operator<<(std::ostream &s, const vpArray2D &A) - { - if ((A.data == nullptr) || (A.size() == 0)) { - return s; - } - std::ios_base::fmtflags original_flags = s.flags(); - - s.precision(10); - unsigned int a_rows = A.getRows(); - unsigned int a_cols = A.getCols(); - for (unsigned int i = 0; i < a_rows; ++i) { - for (unsigned int j = 0; j < (a_cols - 1); ++j) { - s << A[i][j] << " "; - } - // We don't add " " after the last row element - s << A[i][a_cols - 1]; - // We don't add a \n char on the end of the last array line - if (i < (a_rows - 1)) { - s << std::endl; - } - } - - s.flags(original_flags); // restore s to standard state - - return s; - } + friend std::ostream &::operator<< <>(std::ostream &s, const vpArray2D &A); vpArray2D hadamard(const vpArray2D &m) const; @@ -1100,9 +1079,40 @@ vpArray2D static void insert(const vpArray2D &A, const vpArray2D &B, vpArray2D &C, unsigned int r, unsigned int c); //@} }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +template +std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpArray2D &A) +{ + if ((A.data == nullptr) || (A.size() == 0)) { + return s; + } + std::ios_base::fmtflags original_flags = s.flags(); + + s.precision(10); + unsigned int a_rows = A.getRows(); + unsigned int a_cols = A.getCols(); + for (unsigned int i = 0; i < a_rows; ++i) { + for (unsigned int j = 0; j < (a_cols - 1); ++j) { + s << A[i][j] << " "; + } + // We don't add " " after the last row element + s << A[i][a_cols - 1]; + // We don't add a \n char on the end of the last array line + if (i < (a_rows - 1)) { + s << std::endl; + } + } + + s.flags(original_flags); // restore s to standard state + + return s; +} #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -1353,16 +1363,10 @@ template bool vpArray2D::operator!=(const vpArray2D &A) #ifdef VISP_HAVE_NLOHMANN_JSON template -inline void from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -visp::vpArray2D &array -#else -vpArray2D &array -#endif -) +inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpArray2D &array) { #if defined(ENABLE_VISP_NAMESPACE) - using namespace visp; + using namespace VISP_NAMESPACE_NAME; #endif if (j.is_array()) { const unsigned int nrows = static_cast(j.size()); @@ -1415,13 +1419,7 @@ vpArray2D &array template -inline void to_json(nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -const visp::vpArray2D &array -#else -const vpArray2D &array -#endif -) +inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpArray2D &array) { j = { {"cols", array.colNum}, diff --git a/modules/core/include/visp3/core/vpBSpline.h b/modules/core/include/visp3/core/vpBSpline.h index 7181f7f491..22fb5365cb 100644 --- a/modules/core/include/visp3/core/vpBSpline.h +++ b/modules/core/include/visp3/core/vpBSpline.h @@ -31,20 +31,24 @@ * This class implements the B-Spline */ -#ifndef vpBSpline_H -#define vpBSpline_H - /*! \file vpBSpline.h \brief Class that provides tools to compute and manipulate a B-Spline curve. */ +#ifndef vpBSpline_H +#define vpBSpline_H + #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS /*! @@ -234,5 +238,7 @@ public /*protected*/: const std::vector &l_knots, const std::vector &l_controlPoints); vpImagePoint *computeCurveDers(double u, unsigned int der) const; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpCPUFeatures.h b/modules/core/include/visp3/core/vpCPUFeatures.h index 1decf4e2df..bdda0e63b2 100644 --- a/modules/core/include/visp3/core/vpCPUFeatures.h +++ b/modules/core/include/visp3/core/vpCPUFeatures.h @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpCameraParameters.h b/modules/core/include/visp3/core/vpCameraParameters.h index a5f622c06e..dbcecd0eec 100644 --- a/modules/core/include/visp3/core/vpCameraParameters.h +++ b/modules/core/include/visp3/core/vpCameraParameters.h @@ -50,34 +50,25 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { +#endif + class vpCameraParameters; +#if defined(ENABLE_VISP_NAMESPACE) } #endif // Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpCameraParameters &cam); +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam); #ifdef VISP_HAVE_NLOHMANN_JSON #include // Forward declaration to have the to_json in the global namespace -void to_json(nlohmann::json &j, const -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpCameraParameters &cam); +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam); // Forward declaration to have the from_json in the global namespace -void from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpCameraParameters &cam); +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam); #endif /*! @@ -511,7 +502,7 @@ const vpCameraParameters &cam ) { #if defined(ENABLE_VISP_NAMESPACE) - using namespace visp; + using namespace VISP_NAMESPACE_NAME; #endif j["px"] = cam.m_px; j["py"] = cam.m_py; @@ -573,7 +564,7 @@ vpCameraParameters &cam ) { #if defined(ENABLE_VISP_NAMESPACE) - using namespace visp; + using namespace VISP_NAMESPACE_NAME; #endif const double px = j.at("px").get(); const double py = j.at("py").get(); diff --git a/modules/core/include/visp3/core/vpCannyEdgeDetection.h b/modules/core/include/visp3/core/vpCannyEdgeDetection.h index 84d08cfe64..9a2acfa321 100644 --- a/modules/core/include/visp3/core/vpCannyEdgeDetection.h +++ b/modules/core/include/visp3/core/vpCannyEdgeDetection.h @@ -41,9 +41,12 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { +#endif + class vpCannyEdgeDetection; +#if defined(ENABLE_VISP_NAMESPACE) } #endif @@ -52,21 +55,12 @@ class vpCannyEdgeDetection; #include // Forward declaration to have the methods in the global namespace -void from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpCannyEdgeDetection &detector); - -void to_json(nlohmann::json &j, const -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpCannyEdgeDetection &detector); +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector); +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector); #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /** @@ -143,7 +137,7 @@ class VISP_EXPORT vpCannyEdgeDetection * \param[out] j : A JSON parser object. * \param[in] detector : The vpCannyEdgeDetection object that must be parsed into JSON format. */ - friend inline void ::to_json(nlohmann::json &j, const vpCannyEdgeDetection &detector); + friend void ::to_json(nlohmann::json &j, const vpCannyEdgeDetection &detector); #endif //@} diff --git a/modules/core/include/visp3/core/vpCircle.h b/modules/core/include/visp3/core/vpCircle.h index eb382d9cd2..d193f2e025 100644 --- a/modules/core/include/visp3/core/vpCircle.h +++ b/modules/core/include/visp3/core/vpCircle.h @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpClient.h b/modules/core/include/visp3/core/vpClient.h index ed64dc76a8..ca1f685ba6 100644 --- a/modules/core/include/visp3/core/vpClient.h +++ b/modules/core/include/visp3/core/vpClient.h @@ -44,6 +44,10 @@ // inet_ntop() not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpClient * @@ -203,6 +207,8 @@ class VISP_EXPORT vpClient : public vpNetwork void stop(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpColVector.h b/modules/core/include/visp3/core/vpColVector.h index 6156651646..ad78bfb146 100644 --- a/modules/core/include/visp3/core/vpColVector.h +++ b/modules/core/include/visp3/core/vpColVector.h @@ -43,21 +43,23 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { +#endif + class vpColVector; +#if defined(ENABLE_VISP_NAMESPACE) } #endif #ifdef VISP_HAVE_NLOHMANN_JSON #include -#if defined(ENABLE_VISP_NAMESPACE) -void to_json(nlohmann::json &j, const visp::vpColVector &pose); -void from_json(const nlohmann::json &j, visp::vpColVector &pose); -#endif +// Forward declaration to ensure that the methods are in the global namespace +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpColVector &pose); +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpColVector &pose); #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif class vpMatrix; @@ -1476,7 +1478,7 @@ vpColVector: public vpArray2D }; #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -1501,7 +1503,7 @@ const vpColVector &v ) { #if defined(ENABLE_VISP_NAMESPACE) - using namespace visp; + using namespace VISP_NAMESPACE_NAME; #endif const vpArray2D *asArray = (vpArray2D*) & v; to_json(j, *asArray); @@ -1516,7 +1518,7 @@ vpColVector &v ) { #if defined(ENABLE_VISP_NAMESPACE) - using namespace visp; + using namespace VISP_NAMESPACE_NAME; #endif vpArray2D *asArray = (vpArray2D*) & v; from_json(j, *asArray); diff --git a/modules/core/include/visp3/core/vpColor.h b/modules/core/include/visp3/core/vpColor.h index 2f135449df..1bb97a68ab 100644 --- a/modules/core/include/visp3/core/vpColor.h +++ b/modules/core/include/visp3/core/vpColor.h @@ -38,7 +38,20 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpColor; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +// Forward declaration to ensure that the operators are in the global namespace +bool operator==(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2); +bool operator!=(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2); + +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -278,8 +291,8 @@ class VISP_EXPORT vpColor : public vpRGBa /*! Default destructor. */ inline virtual ~vpColor() { } - friend VISP_EXPORT bool operator==(const vpColor &c1, const vpColor &c2); - friend VISP_EXPORT bool operator!=(const vpColor &c1, const vpColor &c2); + friend VISP_EXPORT bool ::operator==(const vpColor &c1, const vpColor &c2); + friend VISP_EXPORT bool ::operator!=(const vpColor &c1, const vpColor &c2); /*! Set a color from its RGB values. @@ -387,7 +400,8 @@ vpColor const __declspec(selectany) vpColor::allColors[vpColor::nbColors] = { vp vpColor::gray, // 3 vpColor::darkGray, // 4 vpColor::black, // 0 - vpColor::white }; // 17 + vpColor::white +}; // 17 #endif #if defined(ENABLE_VISP_NAMESPACE) diff --git a/modules/core/include/visp3/core/vpColorDepthConversion.h b/modules/core/include/visp3/core/vpColorDepthConversion.h index 7a5c591528..a46f4bc3e9 100644 --- a/modules/core/include/visp3/core/vpColorDepthConversion.h +++ b/modules/core/include/visp3/core/vpColorDepthConversion.h @@ -40,7 +40,7 @@ #include "vpImage.h" #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif class VISP_EXPORT vpColorDepthConversion diff --git a/modules/core/include/visp3/core/vpColormap.h b/modules/core/include/visp3/core/vpColormap.h index 0d8d737628..e04f8a7c1f 100644 --- a/modules/core/include/visp3/core/vpColormap.h +++ b/modules/core/include/visp3/core/vpColormap.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpConvert.h b/modules/core/include/visp3/core/vpConvert.h index a6def4962c..c5df0299e9 100644 --- a/modules/core/include/visp3/core/vpConvert.h +++ b/modules/core/include/visp3/core/vpConvert.h @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpConvert \ingroup group_core_bridges @@ -98,6 +102,8 @@ class VISP_EXPORT vpConvert static cv::Point3d vpObjectPointToPoint3d(const vpPoint &point); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpCylinder.h b/modules/core/include/visp3/core/vpCylinder.h index aaf327d2fd..901b72b0e1 100644 --- a/modules/core/include/visp3/core/vpCylinder.h +++ b/modules/core/include/visp3/core/vpCylinder.h @@ -45,6 +45,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpCylinder * \ingroup group_core_geometry @@ -193,5 +197,7 @@ class VISP_EXPORT vpCylinder : public vpForwardProjection void setWorldCoordinates(const vpColVector &oP) vp_override; void setWorldCoordinates(double oA, double oB, double oC, double oX, double oY, double oZ, double R); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpDebug.h b/modules/core/include/visp3/core/vpDebug.h index 81f648a4a8..300a0c2561 100644 --- a/modules/core/include/visp3/core/vpDebug.h +++ b/modules/core/include/visp3/core/vpDebug.h @@ -62,7 +62,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpDisplay.h b/modules/core/include/visp3/core/vpDisplay.h index 0b4a1fc8b8..1c06ea03ad 100644 --- a/modules/core/include/visp3/core/vpDisplay.h +++ b/modules/core/include/visp3/core/vpDisplay.h @@ -55,7 +55,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpDisplayException.h b/modules/core/include/visp3/core/vpDisplayException.h index 8aa630df69..7ebbfb49b5 100644 --- a/modules/core/include/visp3/core/vpDisplayException.h +++ b/modules/core/include/visp3/core/vpDisplayException.h @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpEigenConversion.h b/modules/core/include/visp3/core/vpEigenConversion.h index 8c1d898e4a..165e3325f5 100644 --- a/modules/core/include/visp3/core/vpEigenConversion.h +++ b/modules/core/include/visp3/core/vpEigenConversion.h @@ -43,7 +43,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) #define VISP_EIGEN_CONVERSION_NAMESPACE vp #else -#define VISP_EIGEN_CONVERSION_NAMESPACE visp +#define VISP_EIGEN_CONVERSION_NAMESPACE VISP_NAMESPACE_NAME #endif namespace VISP_EIGEN_CONVERSION_NAMESPACE diff --git a/modules/core/include/visp3/core/vpEndian.h b/modules/core/include/visp3/core/vpEndian.h index 2ea849e449..ffc8ae563a 100644 --- a/modules/core/include/visp3/core/vpEndian.h +++ b/modules/core/include/visp3/core/vpEndian.h @@ -87,7 +87,7 @@ typedef unsigned short uint16_t; #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif namespace vpEndian diff --git a/modules/core/include/visp3/core/vpException.h b/modules/core/include/visp3/core/vpException.h index 96b40e17be..76b68875ae 100644 --- a/modules/core/include/visp3/core/vpException.h +++ b/modules/core/include/visp3/core/vpException.h @@ -46,7 +46,18 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpException; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +// Forward declaration to ensure that the operator is in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpException &art); +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -133,7 +144,7 @@ class VISP_EXPORT vpException : public std::exception /*! * Print the error structure. */ - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpException &art); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpException &art); protected: //! Contains the error code, see the errorCodeEnum table for details. diff --git a/modules/core/include/visp3/core/vpExponentialMap.h b/modules/core/include/visp3/core/vpExponentialMap.h index e5c3e71555..e805c03d24 100644 --- a/modules/core/include/visp3/core/vpExponentialMap.h +++ b/modules/core/include/visp3/core/vpExponentialMap.h @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpFeatureDisplay.h b/modules/core/include/visp3/core/vpFeatureDisplay.h index 2ec64cf9c0..9e0ad3687d 100644 --- a/modules/core/include/visp3/core/vpFeatureDisplay.h +++ b/modules/core/include/visp3/core/vpFeatureDisplay.h @@ -50,7 +50,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpFont.h b/modules/core/include/visp3/core/vpFont.h index de15cb3c81..12291d1da6 100644 --- a/modules/core/include/visp3/core/vpFont.h +++ b/modules/core/include/visp3/core/vpFont.h @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpForceTwistMatrix.h b/modules/core/include/visp3/core/vpForceTwistMatrix.h index f1635b7ca7..73b32725a5 100644 --- a/modules/core/include/visp3/core/vpForceTwistMatrix.h +++ b/modules/core/include/visp3/core/vpForceTwistMatrix.h @@ -38,7 +38,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif class vpMatrix; @@ -53,7 +53,7 @@ class vpMatrix; #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpForwardProjection.h b/modules/core/include/visp3/core/vpForwardProjection.h index 845ce10209..7447b2d520 100644 --- a/modules/core/include/visp3/core/vpForwardProjection.h +++ b/modules/core/include/visp3/core/vpForwardProjection.h @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpFrameGrabber.h b/modules/core/include/visp3/core/vpFrameGrabber.h index fbb84085c9..30e2231a26 100644 --- a/modules/core/include/visp3/core/vpFrameGrabber.h +++ b/modules/core/include/visp3/core/vpFrameGrabber.h @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpFrameGrabberException.h b/modules/core/include/visp3/core/vpFrameGrabberException.h index a8c29ea6b0..3f9c0175d5 100644 --- a/modules/core/include/visp3/core/vpFrameGrabberException.h +++ b/modules/core/include/visp3/core/vpFrameGrabberException.h @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpGEMM.h b/modules/core/include/visp3/core/vpGEMM.h index 982d4bb060..a26abf91e9 100644 --- a/modules/core/include/visp3/core/vpGEMM.h +++ b/modules/core/include/visp3/core/vpGEMM.h @@ -38,7 +38,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif const vpArray2D null(0, 0); diff --git a/modules/core/include/visp3/core/vpGaussRand.h b/modules/core/include/visp3/core/vpGaussRand.h index 79c5f1d356..ba1730f304 100644 --- a/modules/core/include/visp3/core/vpGaussRand.h +++ b/modules/core/include/visp3/core/vpGaussRand.h @@ -37,6 +37,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpGaussRand \ingroup group_core_random @@ -127,7 +131,7 @@ class VISP_EXPORT vpGaussRand /*! Default noise generator constructor. */ - vpGaussRand() : m_rng(), m_mean(0), m_sigma(0), m_AlreadyDone(false), m_x2(0) {} + vpGaussRand() : m_rng(), m_mean(0), m_sigma(0), m_AlreadyDone(false), m_x2(0) { } /*! Gaussian noise random generator constructor. @@ -138,8 +142,7 @@ class VISP_EXPORT vpGaussRand */ vpGaussRand(double sigma_val, double mean_val, long noise_seed = 0) : m_rng(noise_seed), m_mean(mean_val), m_sigma(sigma_val), m_AlreadyDone(false), m_x2(0) - { - } + { } /*! Set the standard deviation and mean for gaussian noise. @@ -165,5 +168,7 @@ class VISP_EXPORT vpGaussRand */ double operator()() { return m_sigma * gaussianDraw() + m_mean; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpGaussianFilter.h b/modules/core/include/visp3/core/vpGaussianFilter.h index 2209a48441..77b3c43cc5 100644 --- a/modules/core/include/visp3/core/vpGaussianFilter.h +++ b/modules/core/include/visp3/core/vpGaussianFilter.h @@ -45,7 +45,7 @@ #if defined(VISP_HAVE_SIMDLIB) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpHinkley.h b/modules/core/include/visp3/core/vpHinkley.h index 046e6fa8ae..5c07f0fea1 100644 --- a/modules/core/include/visp3/core/vpHinkley.h +++ b/modules/core/include/visp3/core/vpHinkley.h @@ -31,13 +31,14 @@ * Hinkley's cumulative sum test implementation. */ -#ifndef vpHinkley_H -#define vpHinkley_H - /*! \file vpHinkley.h \brief class for Hinkley's cumulative test computation. */ + +#ifndef vpHinkley_H +#define vpHinkley_H + #include #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) diff --git a/modules/core/include/visp3/core/vpHistogram.h b/modules/core/include/visp3/core/vpHistogram.h index 8c2d98a5d1..7c7599dcac 100644 --- a/modules/core/include/visp3/core/vpHistogram.h +++ b/modules/core/include/visp3/core/vpHistogram.h @@ -56,7 +56,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpHistogramPeak.h b/modules/core/include/visp3/core/vpHistogramPeak.h index 593cae001f..9985322224 100644 --- a/modules/core/include/visp3/core/vpHistogramPeak.h +++ b/modules/core/include/visp3/core/vpHistogramPeak.h @@ -45,7 +45,18 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpHistogramPeak; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramPeak &p); + +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -137,7 +148,7 @@ class VISP_EXPORT vpHistogramPeak //--------------------------------- // Printing //--------------------------------- - friend VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramPeak &p); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &s, const vpHistogramPeak &p); protected: unsigned char level; //! Gray level ot the peak. diff --git a/modules/core/include/visp3/core/vpHistogramValey.h b/modules/core/include/visp3/core/vpHistogramValey.h index 1ce432ef55..c04bc4128c 100644 --- a/modules/core/include/visp3/core/vpHistogramValey.h +++ b/modules/core/include/visp3/core/vpHistogramValey.h @@ -44,7 +44,18 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpHistogramValey; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramValey &v); + +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -135,7 +146,7 @@ class VISP_EXPORT vpHistogramValey : vpHistogramPeak //--------------------------------- // Printing //--------------------------------- - friend VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramValey &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &s, const vpHistogramValey &v); }; /* diff --git a/modules/core/include/visp3/core/vpHomogeneousMatrix.h b/modules/core/include/visp3/core/vpHomogeneousMatrix.h index 10dcfbe7f7..942f6afc11 100644 --- a/modules/core/include/visp3/core/vpHomogeneousMatrix.h +++ b/modules/core/include/visp3/core/vpHomogeneousMatrix.h @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -69,18 +69,18 @@ class vpPoint; #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { +#endif class vpHomogeneousMatrix; +#if defined(ENABLE_VISP_NAMESPACE) } #endif #ifdef VISP_HAVE_NLOHMANN_JSON #include -#if defined(ENABLE_VISP_NAMESPACE) -void to_json(nlohmann::json &j, const visp::vpHomogeneousMatrix &T); -void from_json(const nlohmann::json &j, visp::vpHomogeneousMatrix &T); -#endif +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T); +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T); #endif /*! @@ -436,23 +436,12 @@ vpHomogeneousMatrix: public vpArray2D }; #ifdef VISP_HAVE_NLOHMANN_JSON -inline void to_json(nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -const visp::vpHomogeneousMatrix &T -#else -const vpHomogeneousMatrix &T -#endif -) +inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T) { T.convert_to_json(j); } -inline void from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -visp::vpHomogeneousMatrix &T -#else -vpHomogeneousMatrix &T -#endif -) + +inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T) { T.parse_json(j); } diff --git a/modules/core/include/visp3/core/vpImage.h b/modules/core/include/visp3/core/vpImage.h index 7b971486fc..3055ce4a7f 100644 --- a/modules/core/include/visp3/core/vpImage.h +++ b/modules/core/include/visp3/core/vpImage.h @@ -67,11 +67,29 @@ typedef unsigned short uint16_t; #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif class vpDisplay; +// Ref: http://en.cppreference.com/w/cpp/language/friend#Template_friends +template class vpImage; // forward declare to make function declaration possible +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif +// declarations +template std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); + +std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); +std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); +std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); +std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); + +template void swap(VISP_NAMESPACE_ADDRESSING vpImage &first, VISP_NAMESPACE_ADDRESSING vpImage &second); +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpImage @@ -121,20 +139,6 @@ value = I[i][j]; // Here we will get the pixel value at position (101, 80) \endcode */ - -// Ref: http://en.cppreference.com/w/cpp/language/friend#Template_friends -template class vpImage; // forward declare to make function declaration possible - -// declarations -template std::ostream &operator<<(std::ostream &, const vpImage &); - -std::ostream &operator<<(std::ostream &, const vpImage &); -std::ostream &operator<<(std::ostream &, const vpImage &); -std::ostream &operator<<(std::ostream &, const vpImage &); -std::ostream &operator<<(std::ostream &, const vpImage &); - -template void swap(vpImage &first, vpImage &second); - template class vpImage { friend class vpImageConvert; @@ -326,11 +330,11 @@ template class vpImage vpImage &operator=(const Type &v); bool operator==(const vpImage &I) const; bool operator!=(const vpImage &I) const; - friend std::ostream &operator<< <>(std::ostream &s, const vpImage &I); - friend std::ostream &operator<<(std::ostream &s, const vpImage &I); - friend std::ostream &operator<<(std::ostream &s, const vpImage &I); - friend std::ostream &operator<<(std::ostream &s, const vpImage &I); - friend std::ostream &operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &::operator<< <>(std::ostream &s, const vpImage &I); + friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); // Perform a look-up table transformation void performLut(const Type(&lut)[256], unsigned int nbThreads = 1); @@ -347,7 +351,7 @@ template class vpImage void sub(const vpImage &A, const vpImage &B, vpImage &C) const; void subsample(unsigned int v_scale, unsigned int h_scale, vpImage &sampled) const; - friend void swap<>(vpImage &first, vpImage &second); + friend void ::swap<>(vpImage &first, vpImage &second); //@} @@ -358,8 +362,11 @@ template class vpImage Type **row; ///! points the row pointer array bool hasOwnership; ///! true if this instance owns the bitmap, false otherwise (e.g. copyData=false) }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif -template std::ostream &operator<<(std::ostream &s, const vpImage &I) +template std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -384,7 +391,7 @@ template std::ostream &operator<<(std::ostream &s, const vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -412,7 +419,7 @@ inline std::ostream &operator<<(std::ostream &s, const vpImage &I return s; } -inline std::ostream &operator<<(std::ostream &s, const vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -440,7 +447,7 @@ inline std::ostream &operator<<(std::ostream &s, const vpImage &I) return s; } -inline std::ostream &operator<<(std::ostream &s, const vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -469,7 +476,7 @@ inline std::ostream &operator<<(std::ostream &s, const vpImage &I) return s; } -inline std::ostream &operator<<(std::ostream &s, const vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -566,7 +573,7 @@ struct vpImageLutRGBa_Param_t unsigned int m_start_index; unsigned int m_end_index; - vpRGBa m_lut[256]; + VISP_NAMESPACE_ADDRESSING vpRGBa m_lut[256]; unsigned char *m_bitmap; vpImageLutRGBa_Param_t() : m_start_index(0), m_end_index(0), m_lut(), m_bitmap(nullptr) { } @@ -627,6 +634,10 @@ void performLutRGBaThread(vpImageLutRGBa_Param_t *imageLut_param) } // namespace #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \relates vpImage */ @@ -2553,8 +2564,10 @@ template <> inline void vpImage::performLut(const vpRGBa(&lut)[256], uns #endif } } - -template void swap(vpImage &first, vpImage &second) +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif +template void swap(VISP_NAMESPACE_ADDRESSING vpImage &first, VISP_NAMESPACE_ADDRESSING vpImage &second) { using std::swap; swap(first.bitmap, second.bitmap); @@ -2564,7 +2577,4 @@ template void swap(vpImage &first, vpImage &second) swap(first.height, second.height); swap(first.row, second.row); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif #endif diff --git a/modules/core/include/visp3/core/vpImageCircle.h b/modules/core/include/visp3/core/vpImageCircle.h index c3f651bd7c..18491cf11b 100644 --- a/modules/core/include/visp3/core/vpImageCircle.h +++ b/modules/core/include/visp3/core/vpImageCircle.h @@ -50,7 +50,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /** diff --git a/modules/core/include/visp3/core/vpImageConvert.h b/modules/core/include/visp3/core/vpImageConvert.h index 92159df084..e3e831ee51 100644 --- a/modules/core/include/visp3/core/vpImageConvert.h +++ b/modules/core/include/visp3/core/vpImageConvert.h @@ -76,7 +76,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpImageDraw.h b/modules/core/include/visp3/core/vpImageDraw.h index 84af344082..352806b058 100644 --- a/modules/core/include/visp3/core/vpImageDraw.h +++ b/modules/core/include/visp3/core/vpImageDraw.h @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpImageException.h b/modules/core/include/visp3/core/vpImageException.h index 45ee9ab972..92b421475e 100644 --- a/modules/core/include/visp3/core/vpImageException.h +++ b/modules/core/include/visp3/core/vpImageException.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpImageFilter.h b/modules/core/include/visp3/core/vpImageFilter.h index 265e930d36..9636675260 100644 --- a/modules/core/include/visp3/core/vpImageFilter.h +++ b/modules/core/include/visp3/core/vpImageFilter.h @@ -60,7 +60,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpImageMorphology.h b/modules/core/include/visp3/core/vpImageMorphology.h index d7e57ed5de..f851e1e40f 100644 --- a/modules/core/include/visp3/core/vpImageMorphology.h +++ b/modules/core/include/visp3/core/vpImageMorphology.h @@ -51,7 +51,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpImagePoint.h b/modules/core/include/visp3/core/vpImagePoint.h index e87dba4a9e..2c4acdf8eb 100644 --- a/modules/core/include/visp3/core/vpImagePoint.h +++ b/modules/core/include/visp3/core/vpImagePoint.h @@ -48,11 +48,8 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -#define VISP_VPIMAGEPOINT_NAMESPACE visp:: -namespace visp +namespace VISP_NAMESPACE_NAME { -#else -#define VISP_VPIMAGEPOINT_NAMESPACE #endif class vpImagePoint; class vpRect; @@ -61,23 +58,23 @@ class vpRect; #endif // Forward declaration to have the operators in the global namespace when using ViSP namespace -bool operator==(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); -bool operator!=(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+=(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, int offset); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, unsigned int offset); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator+(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double offset); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip2); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, int offset); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, unsigned int offset); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator-(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double offset); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator*(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double scale); -VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint operator/(const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip1, double scale); -std::ostream &operator<<(std::ostream &os, const VISP_VPIMAGEPOINT_NAMESPACE vpImagePoint &ip); +bool operator==(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); +bool operator!=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator+=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator*(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale); +VISP_NAMESPACE_ADDRESSING vpImagePoint operator/(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale); +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip); #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -393,17 +390,17 @@ class VISP_EXPORT vpImagePoint friend VISP_EXPORT bool ::operator==(const vpImagePoint &ip1, const vpImagePoint &ip2); friend VISP_EXPORT bool ::operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint ::operator+=(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, int offset); - friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, unsigned int offset); - friend VISP_EXPORT vpImagePoint ::operator+(const vpImagePoint &ip1, double offset); - friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, int offset); - friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, unsigned int offset); - friend VISP_EXPORT vpImagePoint ::operator-(const vpImagePoint &ip1, double offset); - friend VISP_EXPORT vpImagePoint ::operator*(const vpImagePoint &ip1, double scale); - friend VISP_EXPORT vpImagePoint ::operator/(const vpImagePoint &ip1, double scale); + friend VISP_EXPORT vpImagePoint(::operator+=)(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, int offset); + friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, unsigned int offset); + friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, double offset); + friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, int offset); + friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, unsigned int offset); + friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, double offset); + friend VISP_EXPORT vpImagePoint(::operator*)(const vpImagePoint &ip1, double scale); + friend VISP_EXPORT vpImagePoint(::operator/)(const vpImagePoint &ip1, double scale); friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpImagePoint &ip); private: diff --git a/modules/core/include/visp3/core/vpImageTools.h b/modules/core/include/visp3/core/vpImageTools.h index 0308b49396..f706de4a4f 100644 --- a/modules/core/include/visp3/core/vpImageTools.h +++ b/modules/core/include/visp3/core/vpImageTools.h @@ -64,7 +64,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpIoException.h b/modules/core/include/visp3/core/vpIoException.h index 3c4a9e2ce7..3c3ab32ba3 100644 --- a/modules/core/include/visp3/core/vpIoException.h +++ b/modules/core/include/visp3/core/vpIoException.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpIoTools.h b/modules/core/include/visp3/core/vpIoTools.h index dc12e89c6f..d5bc19a294 100644 --- a/modules/core/include/visp3/core/vpIoTools.h +++ b/modules/core/include/visp3/core/vpIoTools.h @@ -56,7 +56,7 @@ #include #if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98 -namespace visp +namespace VISP_NAMESPACE_NAME { // https://github.com/BinomialLLC/basis_universal/blob/ad9386a4a1cf2a248f7bbd45f543a7448db15267/encoder/basisu_miniz.h#L665 static inline unsigned long vp_mz_crc32(unsigned long crc, const unsigned char *ptr, size_t buf_len) @@ -385,7 +385,7 @@ template std::vector create_npy_header(const std::vector std::vector create_npy_header(const std::vector #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpKalmanFilter.h b/modules/core/include/visp3/core/vpKalmanFilter.h index b9461884ec..3cf3e02c4d 100644 --- a/modules/core/include/visp3/core/vpKalmanFilter.h +++ b/modules/core/include/visp3/core/vpKalmanFilter.h @@ -31,6 +31,11 @@ * Kalman filtering. */ +/*! + \file vpKalmanFilter.h + \brief Generic kalman filtering implementation +*/ + #ifndef vpKalmanFilter_h #define vpKalmanFilter_h @@ -39,11 +44,10 @@ #include -/*! - \file vpKalmanFilter.h - \brief Generic kalman filtering implementation -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpKalmanFilter \ingroup group_core_kalman @@ -125,7 +129,7 @@ class VISP_EXPORT vpKalmanFilter explicit vpKalmanFilter(unsigned int n_signal); vpKalmanFilter(unsigned int size_state, unsigned int size_measure, unsigned int n_signal); /*! Destructor that does noting. */ - virtual ~vpKalmanFilter(){}; + virtual ~vpKalmanFilter() { }; /*! Set the number of signal to filter. */ @@ -211,5 +215,7 @@ class VISP_EXPORT vpKalmanFilter //! Identity matrix \f$ \bf I\f$. vpMatrix I; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpLinProg.h b/modules/core/include/visp3/core/vpLinProg.h index 7edbb3c2d3..d08e97157a 100644 --- a/modules/core/include/visp3/core/vpLinProg.h +++ b/modules/core/include/visp3/core/vpLinProg.h @@ -31,6 +31,11 @@ * Linear Programming with simplex */ +/*! + \file vpLinProg.h + \brief Implementation of Linear Program with simplex algorithm. +*/ + #ifndef vpLinProgh #define vpLinProgh @@ -41,11 +46,10 @@ #include #include -/*! - \file vpLinProg.h - \brief Implementation of Linear Program with simplex algorithm. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpLinProg \ingroup group_core_optim @@ -222,4 +226,7 @@ class VISP_EXPORT vpLinProg } //@} }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpLine.h b/modules/core/include/visp3/core/vpLine.h index f446976e24..43014d2169 100644 --- a/modules/core/include/visp3/core/vpLine.h +++ b/modules/core/include/visp3/core/vpLine.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpLinearKalmanFilterInstantiation.h b/modules/core/include/visp3/core/vpLinearKalmanFilterInstantiation.h index d6d7b207ac..d14d1d61e0 100644 --- a/modules/core/include/visp3/core/vpLinearKalmanFilterInstantiation.h +++ b/modules/core/include/visp3/core/vpLinearKalmanFilterInstantiation.h @@ -31,6 +31,11 @@ * Kalman filtering. */ +/*! + \file vpLinearKalmanFilterInstantiation.h + \brief Implementation of some specific linear Kalman filters. +*/ + #ifndef vpLinearKalmanFilterInstantiation_h #define vpLinearKalmanFilterInstantiation_h @@ -38,11 +43,10 @@ #include -/*! - \file vpLinearKalmanFilterInstantiation.h - \brief Implementation of some specific linear Kalman filters. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpLinearKalmanFilterInstantiation \ingroup group_core_kalman @@ -156,5 +160,7 @@ void vpLinearKalmanFilterInstantiation::setStateModel(vpStateModel mdl) break; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpList.h b/modules/core/include/visp3/core/vpList.h index f9a8525030..0f17f0a02d 100644 --- a/modules/core/include/visp3/core/vpList.h +++ b/modules/core/include/visp3/core/vpList.h @@ -48,7 +48,7 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpMath.h b/modules/core/include/visp3/core/vpMath.h index 017a5d8582..536ced7ce7 100644 --- a/modules/core/include/visp3/core/vpMath.h +++ b/modules/core/include/visp3/core/vpMath.h @@ -93,7 +93,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpMatrix.h b/modules/core/include/visp3/core/vpMatrix.h index aecc94bada..a469965781 100644 --- a/modules/core/include/visp3/core/vpMatrix.h +++ b/modules/core/include/visp3/core/vpMatrix.h @@ -42,7 +42,7 @@ #define _vpMatrix_H_ #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -69,7 +69,7 @@ class vpForceTwistMatrix; #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpMatrixException.h b/modules/core/include/visp3/core/vpMatrixException.h index a92505545e..19b4cc6540 100644 --- a/modules/core/include/visp3/core/vpMatrixException.h +++ b/modules/core/include/visp3/core/vpMatrixException.h @@ -41,7 +41,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpMeterPixelConversion.h b/modules/core/include/visp3/core/vpMeterPixelConversion.h index 5666e0a62d..f7f9164fe0 100644 --- a/modules/core/include/visp3/core/vpMeterPixelConversion.h +++ b/modules/core/include/visp3/core/vpMeterPixelConversion.h @@ -51,7 +51,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpMoment.h b/modules/core/include/visp3/core/vpMoment.h index 60ccc96ed4..0cffa55a1a 100644 --- a/modules/core/include/visp3/core/vpMoment.h +++ b/modules/core/include/visp3/core/vpMoment.h @@ -45,9 +45,24 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMoment; class vpMomentDatabase; class vpMomentObject; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMoment &m); +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMoment * @@ -152,6 +167,9 @@ class VISP_EXPORT vpMoment virtual void printDependencies(std::ostream &os) const; void update(vpMomentObject &object); //@} - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMoment &m); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMoment &m); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentAlpha.h b/modules/core/include/visp3/core/vpMomentAlpha.h index 1e0a991482..b45e071d53 100644 --- a/modules/core/include/visp3/core/vpMomentAlpha.h +++ b/modules/core/include/visp3/core/vpMomentAlpha.h @@ -39,8 +39,25 @@ #ifndef _vpMomentAlpha_h_ #define _vpMomentAlpha_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMomentAlpha; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAlpha &v); + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMomentAlpha * @@ -246,8 +263,10 @@ class VISP_EXPORT vpMomentAlpha : public vpMoment return false; } - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAlpha &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentAlpha &v); void printDependencies(std::ostream &os) const; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentArea.h b/modules/core/include/visp3/core/vpMomentArea.h index ccef048ad6..4a0db73af8 100644 --- a/modules/core/include/visp3/core/vpMomentArea.h +++ b/modules/core/include/visp3/core/vpMomentArea.h @@ -33,11 +33,27 @@ #ifndef _vpMomentArea_h_ #define _vpMomentArea_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMomentArea; class vpMomentObject; class vpMomentCentered; // Required for discrete case of vpMomentObject +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentArea &m); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMomentArea * @@ -65,7 +81,9 @@ class VISP_EXPORT vpMomentArea : public vpMoment const std::string name() const { return "vpMomentArea"; } void printDependencies(std::ostream &os) const; //@} - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentArea &m); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentArea &m); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentAreaNormalized.h b/modules/core/include/visp3/core/vpMomentAreaNormalized.h index 212ad34ffe..b394d9977e 100644 --- a/modules/core/include/visp3/core/vpMomentAreaNormalized.h +++ b/modules/core/include/visp3/core/vpMomentAreaNormalized.h @@ -37,11 +37,27 @@ #ifndef _vpMomentAreaNormalized_h_ #define _vpMomentAreaNormalized_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMomentAreaNormalized; class vpMomentObject; class vpMomentCentered; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAreaNormalized &v); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMomentAreaNormalized * @@ -178,8 +194,10 @@ class VISP_EXPORT vpMomentAreaNormalized : public vpMoment * Moment name. */ const std::string name() const { return "vpMomentAreaNormalized"; } - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAreaNormalized &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentAreaNormalized &v); void printDependencies(std::ostream &os) const; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentBasic.h b/modules/core/include/visp3/core/vpMomentBasic.h index e0bc51abb2..a06bc5259d 100644 --- a/modules/core/include/visp3/core/vpMomentBasic.h +++ b/modules/core/include/visp3/core/vpMomentBasic.h @@ -39,8 +39,25 @@ #ifndef _vpMomentBasic_h_ #define _vpMomentBasic_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMomentBasic; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentBasic &v); + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMomentBasic @@ -78,7 +95,10 @@ class VISP_EXPORT vpMomentBasic : public vpMoment Moment name. */ const std::string name() const { return "vpMomentBasic"; } - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentBasic &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentBasic &v); void printDependencies(std::ostream &os) const; }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentCInvariant.h b/modules/core/include/visp3/core/vpMomentCInvariant.h index 58290fd9e4..a10ee46652 100644 --- a/modules/core/include/visp3/core/vpMomentCInvariant.h +++ b/modules/core/include/visp3/core/vpMomentCInvariant.h @@ -39,12 +39,28 @@ #ifndef _vpMomentCInvariant_h_ #define _vpMomentCInvariant_h_ +#include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentCentered; class vpMomentBasic; +class vpMomentCInvariant; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCInvariant &v); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMomentCInvariant @@ -276,6 +292,9 @@ class VISP_EXPORT vpMomentCInvariant : public vpMoment */ inline const std::vector &getMomentVector() const { return values; } - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCInvariant &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentCInvariant &v); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentCentered.h b/modules/core/include/visp3/core/vpMomentCentered.h index 0f6afae38c..cf448e1d73 100644 --- a/modules/core/include/visp3/core/vpMomentCentered.h +++ b/modules/core/include/visp3/core/vpMomentCentered.h @@ -31,18 +31,34 @@ * Centered moment descriptor */ -#ifndef _vpMomentCentered_h_ -#define _vpMomentCentered_h_ - -#include /*! \file vpMomentCentered.h \brief Centered moment descriptor (also referred as \f$\mu_{ij}\f$). - */ +#ifndef _vpMomentCentered_h_ +#define _vpMomentCentered_h_ + +#include +#include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMomentCentered; class vpMomentObject; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCentered &v); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMomentCentered @@ -85,7 +101,7 @@ class VISP_EXPORT vpMomentCentered : public vpMoment */ inline const std::string name() const { return "vpMomentCentered"; } - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCentered &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentCentered &v); void printWithIndices(std::ostream &os) const; void printDependencies(std::ostream &os) const; @@ -127,5 +143,7 @@ mu12 = mc.get(1,2); // the same \endcode */ inline const std::vector &vpMomentCentered::get() const { return vpMoment::get(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentCommon.h b/modules/core/include/visp3/core/vpMomentCommon.h index a6b112ebb3..d2963f970a 100644 --- a/modules/core/include/visp3/core/vpMomentCommon.h +++ b/modules/core/include/visp3/core/vpMomentCommon.h @@ -49,6 +49,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentObject; /*! @@ -137,4 +141,7 @@ class VISP_EXPORT vpMomentCommon : public vpMomentDatabase void updateAll(vpMomentObject &object) vp_override; }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // VPCOMMONMOMENTS_H diff --git a/modules/core/include/visp3/core/vpMomentDatabase.h b/modules/core/include/visp3/core/vpMomentDatabase.h index 0cd4d7cee1..036832509d 100644 --- a/modules/core/include/visp3/core/vpMomentDatabase.h +++ b/modules/core/include/visp3/core/vpMomentDatabase.h @@ -44,9 +44,24 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMoment; +class vpMomentDatabase; class vpMomentObject; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentDatabase &v); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMomentDatabase * @@ -156,7 +171,9 @@ class VISP_EXPORT vpMomentDatabase //@} friend class vpMoment; - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentDatabase &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentDatabase &v); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentGravityCenter.h b/modules/core/include/visp3/core/vpMomentGravityCenter.h index 83e61ecfb2..25b5bf46ce 100644 --- a/modules/core/include/visp3/core/vpMomentGravityCenter.h +++ b/modules/core/include/visp3/core/vpMomentGravityCenter.h @@ -38,10 +38,26 @@ #ifndef _vpMomentGravityCenter_h_ #define _vpMomentGravityCenter_h_ +#include #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMomentGravityCenter; class vpMomentObject; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenter &v); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMomentGravityCenter * @@ -130,7 +146,9 @@ class VISP_EXPORT vpMomentGravityCenter : public vpMoment const std::string name() const { return "vpMomentGravityCenter"; } void printDependencies(std::ostream &os) const; //@} - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenter &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentGravityCenter &v); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h b/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h index 6523a74a17..a3884222b8 100644 --- a/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h +++ b/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h @@ -41,8 +41,24 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMomentGravityCenterNormalized; class vpMomentObject; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenterNormalized &v); + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMomentGravityCenterNormalized * @@ -65,7 +81,10 @@ class VISP_EXPORT vpMomentGravityCenterNormalized : public vpMomentGravityCenter //! Moment name. const std::string name() const { return "vpMomentGravityCenterNormalized"; } void printDependencies(std::ostream &os) const; - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenterNormalized &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentGravityCenterNormalized &v); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMomentObject.h b/modules/core/include/visp3/core/vpMomentObject.h index fb8e1af6ff..3e2ca99935 100644 --- a/modules/core/include/visp3/core/vpMomentObject.h +++ b/modules/core/include/visp3/core/vpMomentObject.h @@ -39,13 +39,29 @@ #include #include +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpCameraParameters; +class vpMomentObject; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentObject &v); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMomentObject @@ -280,7 +296,7 @@ class VISP_EXPORT vpMomentObject void init(unsigned int orderinp); void init(const vpMomentObject &objin); - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentObject &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentObject &v); /*! Outputs raw moments in indexed form like m[1,1] = value of moment m11 \param momobj : A vpMomentObject @@ -310,5 +326,8 @@ class VISP_EXPORT vpMomentObject void cacheValues(std::vector &cache, double x, double y, double IntensityNormalized); double calc_mom_polygon(unsigned int p, unsigned int q, const std::vector &points); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMouseButton.h b/modules/core/include/visp3/core/vpMouseButton.h index 7eb197937b..3bf9b1e0b4 100644 --- a/modules/core/include/visp3/core/vpMouseButton.h +++ b/modules/core/include/visp3/core/vpMouseButton.h @@ -37,7 +37,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpMunkres.h b/modules/core/include/visp3/core/vpMunkres.h index 221dd0a97e..b039015426 100644 --- a/modules/core/include/visp3/core/vpMunkres.h +++ b/modules/core/include/visp3/core/vpMunkres.h @@ -47,7 +47,7 @@ #include "vpMath.h" #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpMutex.h b/modules/core/include/visp3/core/vpMutex.h index 9c05b9d067..950f4f5547 100644 --- a/modules/core/include/visp3/core/vpMutex.h +++ b/modules/core/include/visp3/core/vpMutex.h @@ -48,6 +48,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMutex @@ -184,6 +188,8 @@ class vp_deprecated vpMutex HANDLE m_mutex; #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpNetwork.h b/modules/core/include/visp3/core/vpNetwork.h index 45da39ad9f..9ece98dfb3 100644 --- a/modules/core/include/visp3/core/vpNetwork.h +++ b/modules/core/include/visp3/core/vpNetwork.h @@ -65,6 +65,10 @@ #include // To detect OSX or IOS using TARGET_OS_IPHONE or TARGET_OS_IOS macro #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpNetwork @@ -501,6 +505,8 @@ template int vpNetwork::sendTo(T *object, const unsigned int &dest, flags, (sockaddr *)&receptor_list[dest].receptorAddress, receptor_list[dest].receptorAddressSize); #endif } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpPixelMeterConversion.h b/modules/core/include/visp3/core/vpPixelMeterConversion.h index 4af6db7267..aec68bca19 100644 --- a/modules/core/include/visp3/core/vpPixelMeterConversion.h +++ b/modules/core/include/visp3/core/vpPixelMeterConversion.h @@ -51,7 +51,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpPlane.h b/modules/core/include/visp3/core/vpPlane.h index 0f1abb167c..bf16976453 100644 --- a/modules/core/include/visp3/core/vpPlane.h +++ b/modules/core/include/visp3/core/vpPlane.h @@ -34,12 +34,25 @@ #ifndef _vpPlane_h_ #define _vpPlane_h_ +#include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpPlane; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPlane &p); + #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -149,7 +162,7 @@ class VISP_EXPORT vpPlane vpColVector getNormal() const; void getNormal(vpColVector &n) const; - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpPlane &p); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpPlane &p); // Operation with Plane void projectionPointOnPlan(const vpPoint &P, vpPoint &Pproj) const; diff --git a/modules/core/include/visp3/core/vpPoint.h b/modules/core/include/visp3/core/vpPoint.h index 2453ee3734..80af46e0f8 100644 --- a/modules/core/include/visp3/core/vpPoint.h +++ b/modules/core/include/visp3/core/vpPoint.h @@ -44,11 +44,22 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif class vpHomogeneousMatrix; +class vpPoint; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPoint &vpp); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpPoint \ingroup group_core_geometry @@ -122,7 +133,7 @@ class VISP_EXPORT vpPoint : public vpForwardProjection vpColVector getWorldCoordinates(void); void getWorldCoordinates(std::vector &oP); - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpPoint &vpp); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpPoint &vpp); //! Projection onto the image plane of a point. Input: the 3D coordinates in //! the camera frame _cP, output : the 2D coordinates _p. diff --git a/modules/core/include/visp3/core/vpPolygon.h b/modules/core/include/visp3/core/vpPolygon.h index d9b055d9a3..c3872822e7 100644 --- a/modules/core/include/visp3/core/vpPolygon.h +++ b/modules/core/include/visp3/core/vpPolygon.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpPolygon3D.h b/modules/core/include/visp3/core/vpPolygon3D.h index cb3e5b3bb2..ba4ab90748 100644 --- a/modules/core/include/visp3/core/vpPolygon3D.h +++ b/modules/core/include/visp3/core/vpPolygon3D.h @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpPolygon3D \ingroup group_core_geometry @@ -54,7 +58,8 @@ class VISP_EXPORT vpPolygon3D { public: - typedef enum { + typedef enum + { NO_CLIPPING = 0, NEAR_CLIPPING = 1, FAR_CLIPPING = 2, @@ -213,31 +218,37 @@ class VISP_EXPORT vpPolygon3D static void getMinMaxRoi(const std::vector &roi, int &i_min, int &i_max, int &j_min, int &j_max); static bool roiInsideImage(const vpImage &I, const std::vector &corners); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #ifdef VISP_HAVE_NLOHMANN_JSON #include #include -NLOHMANN_JSON_SERIALIZE_ENUM( vpPolygon3D::vpPolygon3DClippingType, { - {vpPolygon3D::NO_CLIPPING, "none"}, - {vpPolygon3D::NEAR_CLIPPING, "near"}, - {vpPolygon3D::FAR_CLIPPING, "far"}, - {vpPolygon3D::LEFT_CLIPPING, "left"}, - {vpPolygon3D::RIGHT_CLIPPING, "right"}, - {vpPolygon3D::UP_CLIPPING, "up"}, - {vpPolygon3D::DOWN_CLIPPING, "down"}, - {vpPolygon3D::FOV_CLIPPING, "fov"}, - {vpPolygon3D::ALL_CLIPPING, "all"} +NLOHMANN_JSON_SERIALIZE_ENUM(VISP_NAMESPACE_ADDRESSING vpPolygon3D::vpPolygon3DClippingType, { + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::NO_CLIPPING, "none"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::NEAR_CLIPPING, "near"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::FAR_CLIPPING, "far"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::LEFT_CLIPPING, "left"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::RIGHT_CLIPPING, "right"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::UP_CLIPPING, "up"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::DOWN_CLIPPING, "down"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::FOV_CLIPPING, "fov"}, + {VISP_NAMESPACE_ADDRESSING vpPolygon3D::ALL_CLIPPING, "all"} }); -inline nlohmann::json clippingFlagsToJSON(const int flags) { +inline nlohmann::json clippingFlagsToJSON(const int flags) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif constexpr std::array specificFlags = { vpPolygon3D::ALL_CLIPPING, vpPolygon3D::FOV_CLIPPING, vpPolygon3D::NO_CLIPPING }; - for(const auto f: specificFlags) { - if(flags == f) { + for (const auto f: specificFlags) { + if (flags == f) { return nlohmann::json::array({ f }); } } @@ -252,5 +263,4 @@ inline nlohmann::json clippingFlagsToJSON(const int flags) { } #endif - #endif diff --git a/modules/core/include/visp3/core/vpPoseVector.h b/modules/core/include/visp3/core/vpPoseVector.h index fc601b3987..a5ef1b9f5d 100644 --- a/modules/core/include/visp3/core/vpPoseVector.h +++ b/modules/core/include/visp3/core/vpPoseVector.h @@ -49,33 +49,30 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME { +#endif +class vpRotationMatrix; +class vpHomogeneousMatrix; class vpPoseVector; +class vpTranslationVector; +class vpThetaUVector; +class vpRowVector; +#ifdef ENABLE_VISP_NAMESPACE } #endif #ifdef VISP_HAVE_NLOHMANN_JSON #include -#if defined(ENABLE_VISP_NAMESPACE) -void to_json(nlohmann::json &j, const visp::vpPoseVector &pose); -void from_json(const nlohmann::json &j, visp::vpPoseVector &pose); -#endif +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); #endif -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME { #endif -class vpRotationMatrix; -class vpHomogeneousMatrix; -class vpTranslationVector; -class vpThetaUVector; -class vpRowVector; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif /*! \class vpPoseVector @@ -203,11 +200,7 @@ class vpRowVector; {"cols":1,"data":[0.1,0.2,0.3,3.141592653589793,1.5707963267948966,0.7853981633974483],"rows":6,"type":"vpPoseVector"} \endcode */ -class VISP_EXPORT -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif -vpPoseVector: public vpArray2D +class VISP_EXPORT vpPoseVector : public vpArray2D { public: // constructor @@ -221,6 +214,8 @@ vpPoseVector: public vpArray2D // constructor convert a translation and a rotation matrix into a pose vpPoseVector(const vpTranslationVector &tv, const vpRotationMatrix &R); + virtual ~vpPoseVector() { } + #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS vp_deprecated vpPoseVector buildFrom(double tx, double ty, double tz, double tux, double tuy, double tuz); // convert an homogeneous matrix in a pose @@ -345,26 +340,18 @@ vpPoseVector: public vpArray2D //@} #endif }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #ifdef VISP_HAVE_NLOHMANN_JSON #include -inline void to_json(nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -const visp::vpPoseVector &r -#else -const vpPoseVector &r -#endif -) +inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpPoseVector &r) { r.convert_to_json(j); } -inline void from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -visp::vpPoseVector &r -#else -vpPoseVector &r -#endif -) + +inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpPoseVector &r) { r.parse_json(j); } diff --git a/modules/core/include/visp3/core/vpQuadProg.h b/modules/core/include/visp3/core/vpQuadProg.h index 052dcbd1d0..e60dbfce9b 100644 --- a/modules/core/include/visp3/core/vpQuadProg.h +++ b/modules/core/include/visp3/core/vpQuadProg.h @@ -31,6 +31,11 @@ * Quadratic Programming */ +/*! + * \file vpQuadProg.h + * \brief Implementation of Quadratic Program with Active Sets. + */ + #ifndef _vpQuadProg_h_ #define _vpQuadProg_h_ @@ -41,11 +46,10 @@ #include #include -/*! - * \file vpQuadProg.h - * \brief Implementation of Quadratic Program with Active Sets. - */ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpQuadProg * \ingroup group_core_optim @@ -159,4 +163,7 @@ class VISP_EXPORT vpQuadProg } #endif }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpQuaternionVector.h b/modules/core/include/visp3/core/vpQuaternionVector.h index 5a891f8d62..5d37572c46 100644 --- a/modules/core/include/visp3/core/vpQuaternionVector.h +++ b/modules/core/include/visp3/core/vpQuaternionVector.h @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpRGBa.h b/modules/core/include/visp3/core/vpRGBa.h index 1703078d64..89daeb2160 100644 --- a/modules/core/include/visp3/core/vpRGBa.h +++ b/modules/core/include/visp3/core/vpRGBa.h @@ -44,11 +44,8 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -#define VISP_VPRGBA_NAMESPACE visp:: -namespace visp +namespace VISP_NAMESPACE_NAME { -#else -#define VISP_VPRGBA_NAMESPACE #endif class vpRGBa; #if defined(ENABLE_VISP_NAMESPACE) @@ -56,11 +53,11 @@ class vpRGBa; #endif // Forward declaration to have the operators in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_VPRGBA_NAMESPACE vpRGBa &rgba); -VISP_VPRGBA_NAMESPACE vpRGBa operator*(const double &x, const VISP_VPRGBA_NAMESPACE vpRGBa &rgb); +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgba); +VISP_NAMESPACE_ADDRESSING vpRGBa operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgb); #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -160,7 +157,7 @@ class VISP_EXPORT vpRGBa unsigned char B; //!< Blue component. unsigned char A; //!< Additionnal component. - friend VISP_EXPORT vpRGBa ::operator*(const double &x, const vpRGBa &rgb); + friend VISP_EXPORT vpRGBa(::operator*)(const double &x, const vpRGBa &rgb); }; #if defined(ENABLE_VISP_NAMESPACE) } diff --git a/modules/core/include/visp3/core/vpRGBf.h b/modules/core/include/visp3/core/vpRGBf.h index 4550516063..06ab1fbcfe 100644 --- a/modules/core/include/visp3/core/vpRGBf.h +++ b/modules/core/include/visp3/core/vpRGBf.h @@ -44,22 +44,20 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -#define VISP_VPRGBF_NAMESPACE visp:: -namespace visp +namespace VISP_NAMESPACE_NAME { -#else -#define VISP_VPRGBF_NAMESPACE #endif class vpRGBf; #if defined(ENABLE_VISP_NAMESPACE) } #endif -std::ostream &operator<<(std::ostream &os, const VISP_VPRGBF_NAMESPACE vpRGBf &rgb); -VISP_VPRGBF_NAMESPACE vpRGBf operator*(double x, const VISP_VPRGBF_NAMESPACE vpRGBf &rgb); +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb); +VISP_NAMESPACE_ADDRESSING vpRGBf operator*(double x, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb); #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -138,14 +136,14 @@ class VISP_EXPORT vpRGBf bool operator<(const vpRGBf &v) const; bool operator>(const vpRGBf &v) const; - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBf &rgb); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpRGBf &rgb); public: float R; //!< Red component. float G; //!< Green component. float B; //!< Blue component. - friend VISP_EXPORT vpRGBf operator*(double x, const vpRGBf &rgb); + friend VISP_EXPORT vpRGBf(::operator*)(double x, const vpRGBf &rgb); }; #if defined(ENABLE_VISP_NAMESPACE) } diff --git a/modules/core/include/visp3/core/vpRansac.h b/modules/core/include/visp3/core/vpRansac.h index adfa6aaa20..8c3af2ea2c 100644 --- a/modules/core/include/visp3/core/vpRansac.h +++ b/modules/core/include/visp3/core/vpRansac.h @@ -46,7 +46,7 @@ #include // random number generation #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpRect.h b/modules/core/include/visp3/core/vpRect.h index ba1242e2c0..ef1f95ac7e 100644 --- a/modules/core/include/visp3/core/vpRect.h +++ b/modules/core/include/visp3/core/vpRect.h @@ -41,8 +41,21 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpRect; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +bool inRectangle(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip, const VISP_NAMESPACE_ADDRESSING vpRect &rect); +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRect &r); + #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -270,8 +283,8 @@ class VISP_EXPORT vpRect return a &= r; } - friend VISP_EXPORT bool inRectangle(const vpImagePoint &ip, const vpRect &rect); - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRect &r); + friend VISP_EXPORT bool ::inRectangle(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip, const vpRect &rect); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpRect &r); void set(double left, double top, double width, double height); void set(const vpImagePoint &topLeft, double width, double height); diff --git a/modules/core/include/visp3/core/vpRectOriented.h b/modules/core/include/visp3/core/vpRectOriented.h index b1fe5d323e..ee8fab1fba 100644 --- a/modules/core/include/visp3/core/vpRectOriented.h +++ b/modules/core/include/visp3/core/vpRectOriented.h @@ -39,7 +39,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpRequest.h b/modules/core/include/visp3/core/vpRequest.h index 20939485e7..6327594024 100644 --- a/modules/core/include/visp3/core/vpRequest.h +++ b/modules/core/include/visp3/core/vpRequest.h @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRequest @@ -225,5 +229,7 @@ template void vpRequest::addParameterObject(T *params, const int &s delete[] tempS; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpRobust.h b/modules/core/include/visp3/core/vpRobust.h index fa3282aef5..ee98ee55c9 100644 --- a/modules/core/include/visp3/core/vpRobust.h +++ b/modules/core/include/visp3/core/vpRobust.h @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpRotationMatrix.h b/modules/core/include/visp3/core/vpRotationMatrix.h index c7c4ca60b9..796b77587b 100644 --- a/modules/core/include/visp3/core/vpRotationMatrix.h +++ b/modules/core/include/visp3/core/vpRotationMatrix.h @@ -51,7 +51,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpRotationVector.h b/modules/core/include/visp3/core/vpRotationVector.h index b05d2e3e6d..2adc11acec 100644 --- a/modules/core/include/visp3/core/vpRotationVector.h +++ b/modules/core/include/visp3/core/vpRotationVector.h @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpRowVector.h b/modules/core/include/visp3/core/vpRowVector.h index 9b9ac3060f..880794827b 100644 --- a/modules/core/include/visp3/core/vpRowVector.h +++ b/modules/core/include/visp3/core/vpRowVector.h @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpRxyzVector.h b/modules/core/include/visp3/core/vpRxyzVector.h index 7e0598c82f..2ff0862b18 100644 --- a/modules/core/include/visp3/core/vpRxyzVector.h +++ b/modules/core/include/visp3/core/vpRxyzVector.h @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpRzyxVector.h b/modules/core/include/visp3/core/vpRzyxVector.h index 977a236cff..8521298350 100644 --- a/modules/core/include/visp3/core/vpRzyxVector.h +++ b/modules/core/include/visp3/core/vpRzyxVector.h @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpRzyzVector.h b/modules/core/include/visp3/core/vpRzyzVector.h index c5cf2b9b4a..2940a60cff 100644 --- a/modules/core/include/visp3/core/vpRzyzVector.h +++ b/modules/core/include/visp3/core/vpRzyzVector.h @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpScale.h b/modules/core/include/visp3/core/vpScale.h index 98da42ad49..aa02376d8b 100644 --- a/modules/core/include/visp3/core/vpScale.h +++ b/modules/core/include/visp3/core/vpScale.h @@ -51,6 +51,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpScale \ingroup group_core_robust @@ -85,5 +89,7 @@ class VISP_EXPORT vpScale double KernelDensity_EPANECHNIKOV(vpColVector &X); double KernelDensityGradient_EPANECHNIKOV(double X, unsigned int n); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpSerial.h b/modules/core/include/visp3/core/vpSerial.h index 1707e9c619..d3012b2b06 100644 --- a/modules/core/include/visp3/core/vpSerial.h +++ b/modules/core/include/visp3/core/vpSerial.h @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpSerial \ingroup group_core_com_serial @@ -68,7 +72,8 @@ class VISP_EXPORT vpSerial /*! * Defines the possible byte sizes for the serial port. */ - typedef enum { + typedef enum + { fivebits = 5, //!< Data is encoded with 5 bits sixbits = 6, //!< Data is encoded with 6 bits sevenbits = 7, //!< Data is encoded with 7 bits @@ -78,7 +83,8 @@ class VISP_EXPORT vpSerial /*! * Defines the possible parity types for the serial port. */ - typedef enum { + typedef enum + { parity_none = 0, //!< No parity check parity_odd = 1, //!< Check for odd parity parity_even = 2 //!< Check for even parity @@ -87,7 +93,8 @@ class VISP_EXPORT vpSerial /*! * Defines the possible stopbit types for the serial port. */ - typedef enum { + typedef enum + { stopbits_one = 1, //!< 1 stop bit is used stopbits_two = 2, //!< 2 stop bits are used } stopbits_t; @@ -95,7 +102,8 @@ class VISP_EXPORT vpSerial /*! * Defines the possible flowcontrol types for the serial port. */ - typedef enum { + typedef enum + { flowcontrol_none = 0, //!< No flow control flowcontrol_software, //!< Software flow control flowcontrol_hardware //!< Hardware flow control @@ -173,6 +181,8 @@ class VISP_EXPORT vpSerial stopbits_t m_stopbits; flowcontrol_t m_flowcontrol; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpServer.h b/modules/core/include/visp3/core/vpServer.h index 2ab89b9ded..01c0343240 100644 --- a/modules/core/include/visp3/core/vpServer.h +++ b/modules/core/include/visp3/core/vpServer.h @@ -42,6 +42,10 @@ // inet_ntop() not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpServer @@ -216,6 +220,8 @@ class VISP_EXPORT vpServer : public vpNetwork */ void setMaxNumberOfClients(const unsigned int &l) { max_clients = l; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpSphere.h b/modules/core/include/visp3/core/vpSphere.h index bee076c35b..a6d2eaed2e 100644 --- a/modules/core/include/visp3/core/vpSphere.h +++ b/modules/core/include/visp3/core/vpSphere.h @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpStatisticalTestAbstract.h b/modules/core/include/visp3/core/vpStatisticalTestAbstract.h index cd7e0454e9..393f78a6d9 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestAbstract.h +++ b/modules/core/include/visp3/core/vpStatisticalTestAbstract.h @@ -44,6 +44,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \ingroup group_core_math_tools * \brief Base class for methods detecting the drift of the mean of a process. @@ -262,5 +266,7 @@ class VISP_EXPORT vpStatisticalTestAbstract */ vpMeanDriftType testUpwardMeanDrift(const float &signal); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpStatisticalTestEWMA.h b/modules/core/include/visp3/core/vpStatisticalTestEWMA.h index 63893668c9..d4fdb0c14c 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestEWMA.h +++ b/modules/core/include/visp3/core/vpStatisticalTestEWMA.h @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \ingroup group_core_math_tools * \brief Class that permits to perform Exponentially Weighted Moving Average mean drft tests. @@ -179,4 +183,7 @@ class VISP_EXPORT vpStatisticalTestEWMA : public vpStatisticalTestAbstract */ void setAlpha(const float &alpha); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpStatisticalTestHinkley.h b/modules/core/include/visp3/core/vpStatisticalTestHinkley.h index 9a8dcc2724..1161ff7df3 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestHinkley.h +++ b/modules/core/include/visp3/core/vpStatisticalTestHinkley.h @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \ingroup group_core_math_tools * \brief This class implements the Hinkley's cumulative sum test. @@ -329,5 +333,7 @@ class VISP_EXPORT vpStatisticalTestHinkley : public vpStatisticalTestAbstract */ void setAlpha(const float &alpha); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h b/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h index 8a39d7d8f0..7ecf8c21a3 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h +++ b/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \ingroup group_core_math_tools * \brief Class that permits to perform a mean adjusted Cumulative Sum test. @@ -271,4 +275,7 @@ class VISP_EXPORT vpStatisticalTestMeanAdjustedCUSUM : public vpStatisticalTestA m_limitUp = limitUp; } }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpStatisticalTestShewhart.h b/modules/core/include/visp3/core/vpStatisticalTestShewhart.h index 9954831496..d02eed3861 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestShewhart.h +++ b/modules/core/include/visp3/core/vpStatisticalTestShewhart.h @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \ingroup group_core_math_tools * \brief Class that permits a Shewhart's test. @@ -238,5 +242,7 @@ class VISP_EXPORT vpStatisticalTestShewhart : public vpStatisticalTestSigma */ void init(const bool &activateWECOrules, const bool activatedRules[COUNT_WECO - 1], const float &mean, const float &stdev); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpStatisticalTestSigma.h b/modules/core/include/visp3/core/vpStatisticalTestSigma.h index 210da6eba0..ba19275ca1 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestSigma.h +++ b/modules/core/include/visp3/core/vpStatisticalTestSigma.h @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \ingroup group_core_math_tools * \brief Class that permits a simple test comparing the current value to the @@ -169,5 +173,7 @@ class VISP_EXPORT vpStatisticalTestSigma : public vpStatisticalTestAbstract */ void init(const float &h, const float &mean, const float &stdev); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpSubColVector.h b/modules/core/include/visp3/core/vpSubColVector.h index b78710511a..deea0afef5 100644 --- a/modules/core/include/visp3/core/vpSubColVector.h +++ b/modules/core/include/visp3/core/vpSubColVector.h @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpSubMatrix.h b/modules/core/include/visp3/core/vpSubMatrix.h index 12237b21d5..32a5ebbade 100644 --- a/modules/core/include/visp3/core/vpSubMatrix.h +++ b/modules/core/include/visp3/core/vpSubMatrix.h @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpSubRowVector.h b/modules/core/include/visp3/core/vpSubRowVector.h index ba6be0fe83..2134a514e0 100644 --- a/modules/core/include/visp3/core/vpSubRowVector.h +++ b/modules/core/include/visp3/core/vpSubRowVector.h @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpThetaUVector.h b/modules/core/include/visp3/core/vpThetaUVector.h index 5990620aa7..a5f2af1ae7 100644 --- a/modules/core/include/visp3/core/vpThetaUVector.h +++ b/modules/core/include/visp3/core/vpThetaUVector.h @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpThread.h b/modules/core/include/visp3/core/vpThread.h index be654680a1..5c346f7aba 100644 --- a/modules/core/include/visp3/core/vpThread.h +++ b/modules/core/include/visp3/core/vpThread.h @@ -48,6 +48,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpThread @@ -179,6 +183,8 @@ class vp_deprecated vpThread bool m_isCreated; //!< Indicates if the thread is created bool m_isJoinable; //!< Indicates if the thread is joinable }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpTime.h b/modules/core/include/visp3/core/vpTime.h index 3e348cccf5..5613d23a34 100644 --- a/modules/core/include/visp3/core/vpTime.h +++ b/modules/core/include/visp3/core/vpTime.h @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpTracker.h b/modules/core/include/visp3/core/vpTracker.h index baaeeba60b..e8d33178da 100644 --- a/modules/core/include/visp3/core/vpTracker.h +++ b/modules/core/include/visp3/core/vpTracker.h @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpTrackingException.h b/modules/core/include/visp3/core/vpTrackingException.h index 761169a5b3..fc7a8713d2 100644 --- a/modules/core/include/visp3/core/vpTrackingException.h +++ b/modules/core/include/visp3/core/vpTrackingException.h @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/include/visp3/core/vpTranslationVector.h b/modules/core/include/visp3/core/vpTranslationVector.h index 4481c10c2f..c2d43aace2 100644 --- a/modules/core/include/visp3/core/vpTranslationVector.h +++ b/modules/core/include/visp3/core/vpTranslationVector.h @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif class vpMatrix; diff --git a/modules/core/include/visp3/core/vpTriangle.h b/modules/core/include/visp3/core/vpTriangle.h index de27604290..e9914cae90 100644 --- a/modules/core/include/visp3/core/vpTriangle.h +++ b/modules/core/include/visp3/core/vpTriangle.h @@ -34,6 +34,14 @@ #ifndef vpTriangle_h #define vpTriangle_h +#include +#include +#include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTriangle \ingroup group_core_geometry @@ -45,11 +53,6 @@ vpImagePoint class documentation for more details about the frame.) are \f$ (0,0) \f$, \f$ (1,0) \f$ and \f$ (0,1) \f$. */ - -#include -#include -#include - class VISP_EXPORT vpTriangle { private: @@ -107,5 +110,7 @@ class VISP_EXPORT vpTriangle private: void init(const vpImagePoint &iP1, const vpImagePoint &iP2, const vpImagePoint &iP3); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpUDPClient.h b/modules/core/include/visp3/core/vpUDPClient.h index 75d36acd44..3a2f33ac5a 100644 --- a/modules/core/include/visp3/core/vpUDPClient.h +++ b/modules/core/include/visp3/core/vpUDPClient.h @@ -51,6 +51,10 @@ #define VP_MAX_UDP_PAYLOAD 508 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpUDPClient * @@ -194,6 +198,8 @@ class VISP_EXPORT vpUDPClient void close(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpUDPServer.h b/modules/core/include/visp3/core/vpUDPServer.h index 351f20a2f7..c765787a2c 100644 --- a/modules/core/include/visp3/core/vpUDPServer.h +++ b/modules/core/include/visp3/core/vpUDPServer.h @@ -51,6 +51,10 @@ #define VP_MAX_UDP_PAYLOAD 508 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpUDPServer @@ -217,6 +221,8 @@ class VISP_EXPORT vpUDPServer void init(const std::string &hostname, int port); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h b/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h index 24e51c8259..8ee6e86486 100644 --- a/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h +++ b/modules/core/include/visp3/core/vpUKSigmaDrawerAbstract.h @@ -41,6 +41,10 @@ #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpUKSigmaDrawerAbstract \ingroup group_core_kalman @@ -79,5 +83,8 @@ class VISP_EXPORT vpUKSigmaDrawerAbstract protected: unsigned int m_n; /*!< The size of the state of the UKF.*/ }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpUKSigmaDrawerMerwe.h b/modules/core/include/visp3/core/vpUKSigmaDrawerMerwe.h index cd0039da9d..54612dd5e7 100644 --- a/modules/core/include/visp3/core/vpUKSigmaDrawerMerwe.h +++ b/modules/core/include/visp3/core/vpUKSigmaDrawerMerwe.h @@ -42,6 +42,10 @@ #include #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpUKSigmaDrawerMerwe \ingroup group_core_kalman @@ -146,5 +150,8 @@ class VISP_EXPORT vpUKSigmaDrawerMerwe : public vpUKSigmaDrawerAbstract vpAddSubFunction m_resFunc; /*!< Residual function expressed in the state space.*/ vpAddSubFunction m_addFunc; /*!< Addition function expressed in the state space.*/ }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpUniRand.h b/modules/core/include/visp3/core/vpUniRand.h index bec507bf08..c26eb4fb65 100644 --- a/modules/core/include/visp3/core/vpUniRand.h +++ b/modules/core/include/visp3/core/vpUniRand.h @@ -84,7 +84,7 @@ typedef unsigned __int32 uint32_t; #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpUnscentedKalman.h b/modules/core/include/visp3/core/vpUnscentedKalman.h index 60c3eba162..d5509f85e6 100644 --- a/modules/core/include/visp3/core/vpUnscentedKalman.h +++ b/modules/core/include/visp3/core/vpUnscentedKalman.h @@ -44,6 +44,10 @@ #include // std::function #include // std::shared_ptr +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpUnscentedKalman \ingroup group_core_kalman @@ -426,6 +430,8 @@ class VISP_EXPORT vpUnscentedKalman static vpUnscentedTransformResult unscentedTransform(const std::vector &sigmaPoints, const std::vector &wm, const std::vector &wc, const vpMatrix &cov, const vpAddSubFunction &resFunc, const vpMeanFunction &meanFunc); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpVelocityTwistMatrix.h b/modules/core/include/visp3/core/vpVelocityTwistMatrix.h index 2a97a8525b..bcda476a67 100644 --- a/modules/core/include/visp3/core/vpVelocityTwistMatrix.h +++ b/modules/core/include/visp3/core/vpVelocityTwistMatrix.h @@ -41,7 +41,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif class vpColVector; diff --git a/modules/core/include/visp3/core/vpXmlParser.h b/modules/core/include/visp3/core/vpXmlParser.h index e069a59c9e..375360d339 100644 --- a/modules/core/include/visp3/core/vpXmlParser.h +++ b/modules/core/include/visp3/core/vpXmlParser.h @@ -31,14 +31,14 @@ * Tools to automatize the creation of xml parser based on the libXML2 */ -#ifndef vpXmlParser_HH -#define vpXmlParser_HH - /*! \file vpXmlParser.h \brief Tools to simplify the creation of xml parser based on the libXML2 */ +#ifndef vpXmlParser_HH +#define vpXmlParser_HH + #include #ifdef VISP_HAVE_XML2 @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpXmlParser @@ -309,7 +313,9 @@ class VISP_EXPORT vpXmlParser static void cleanup() { xmlCleanupParser(); } //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif /* VISP_HAVE_XML2 */ #endif diff --git a/modules/core/include/visp3/core/vpXmlParserCamera.h b/modules/core/include/visp3/core/vpXmlParserCamera.h index aa42d82b42..7a1bb91e89 100644 --- a/modules/core/include/visp3/core/vpXmlParserCamera.h +++ b/modules/core/include/visp3/core/vpXmlParserCamera.h @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h b/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h index eb440b024f..84a22aa3c1 100644 --- a/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h +++ b/modules/core/include/visp3/core/vpXmlParserHomogeneousMatrix.h @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/include/visp3/core/vpXmlParserRectOriented.h b/modules/core/include/visp3/core/vpXmlParserRectOriented.h index 329dc63fe7..ab52a10e40 100644 --- a/modules/core/include/visp3/core/vpXmlParserRectOriented.h +++ b/modules/core/include/visp3/core/vpXmlParserRectOriented.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/camera/vpCameraParameters.cpp b/modules/core/src/camera/vpCameraParameters.cpp index 465b6dddd1..af8f12ef4f 100644 --- a/modules/core/src/camera/vpCameraParameters.cpp +++ b/modules/core/src/camera/vpCameraParameters.cpp @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -643,14 +643,25 @@ void vpCameraParameters::printParameters() std::cout.flags(original_flags); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! * Print on the output stream \e os the camera parameters. * * \param os : Output stream. * \param cam : Camera parameters. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const +#if defined(ENABLE_VISP_NAMESPACE) +visp:: +#endif +vpCameraParameters &cam) { +#if defined(ENABLE_VISP_NAMESPACE) + using namespace VISP_NAMESPACE_NAME; +#endif switch (cam.get_projModel()) { case vpCameraParameters::perspectiveProjWithoutDistortion: { os << "Camera parameters for perspective projection without distortion:" << std::endl; @@ -688,7 +699,3 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters } return os; } - -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/camera/vpColorDepthConversion.cpp b/modules/core/src/camera/vpColorDepthConversion.cpp index b84a4360a9..ca85cb2d87 100644 --- a/modules/core/src/camera/vpColorDepthConversion.cpp +++ b/modules/core/src/camera/vpColorDepthConversion.cpp @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif namespace diff --git a/modules/core/src/camera/vpMeterPixelConversion.cpp b/modules/core/src/camera/vpMeterPixelConversion.cpp index 840e02b198..778f4e62c5 100644 --- a/modules/core/src/camera/vpMeterPixelConversion.cpp +++ b/modules/core/src/camera/vpMeterPixelConversion.cpp @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/camera/vpPixelMeterConversion.cpp b/modules/core/src/camera/vpPixelMeterConversion.cpp index 0c4fcf9184..fea29574bf 100644 --- a/modules/core/src/camera/vpPixelMeterConversion.cpp +++ b/modules/core/src/camera/vpPixelMeterConversion.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/camera/vpXmlParserCamera.cpp b/modules/core/src/camera/vpXmlParserCamera.cpp index 2465884265..ad9b020ea5 100644 --- a/modules/core/src/camera/vpXmlParserCamera.cpp +++ b/modules/core/src/camera/vpXmlParserCamera.cpp @@ -82,7 +82,7 @@ #define LABEL_XML_ADDITIONAL_INFO "additional_information" #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/src/display/vpColor.cpp b/modules/core/src/display/vpColor.cpp index cfeff37f8b..7aa3b5ddc6 100644 --- a/modules/core/src/display/vpColor.cpp +++ b/modules/core/src/display/vpColor.cpp @@ -36,7 +36,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif // FS: Sould be improved to avoid the #if preprocessor line. Not a good idea @@ -124,6 +124,10 @@ vpColor const vpColor::allColors[vpColor::nbColors] = { vpColor::blue, // vpColor colors[6] = { vpColor::blue, vpColor::green, vpColor::red, vpColor::cyan, vpColor::orange, vpColor::purple }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! Compare two colors. @@ -131,7 +135,7 @@ vpColor colors[6] = { vpColor::blue, vpColor::green, vpColor::red, vpColor::cyan \param c1,c2 : Color to compare. */ -VISP_EXPORT bool operator==(const vpColor &c1, const vpColor &c2) +VISP_EXPORT bool operator==(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2) { return ((c1.R == c2.R) && (c1.G == c2.G) && (c1.B == c2.B)); } @@ -144,10 +148,7 @@ VISP_EXPORT bool operator==(const vpColor &c1, const vpColor &c2) \param c1,c2 : Color to compare. */ -VISP_EXPORT bool operator!=(const vpColor &c1, const vpColor &c2) +VISP_EXPORT bool operator!=(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2) { return ((c1.R != c2.R) || (c1.G != c2.G) || (c1.B == c2.B)); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/display/vpDisplay.cpp b/modules/core/src/display/vpDisplay.cpp index c727dade04..eb25b62c45 100644 --- a/modules/core/src/display/vpDisplay.cpp +++ b/modules/core/src/display/vpDisplay.cpp @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/display/vpDisplay_impl.h b/modules/core/src/display/vpDisplay_impl.h index 05f4331e34..b500efa7da 100644 --- a/modules/core/src/display/vpDisplay_impl.h +++ b/modules/core/src/display/vpDisplay_impl.h @@ -38,7 +38,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif template void vp_display_close(vpImage &I) diff --git a/modules/core/src/display/vpDisplay_rgba.cpp b/modules/core/src/display/vpDisplay_rgba.cpp index 0e363fd2dd..c5199f66d1 100644 --- a/modules/core/src/display/vpDisplay_rgba.cpp +++ b/modules/core/src/display/vpDisplay_rgba.cpp @@ -42,7 +42,7 @@ // files that implement other types (unsigned char, vpRGB, vpRGBa) //************************************************************************ #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/display/vpDisplay_uchar.cpp b/modules/core/src/display/vpDisplay_uchar.cpp index 74a10f8e63..5b4563b262 100644 --- a/modules/core/src/display/vpDisplay_uchar.cpp +++ b/modules/core/src/display/vpDisplay_uchar.cpp @@ -42,7 +42,7 @@ // files that implement other types (unsigned char, vpRGB, vpRGBa) //************************************************************************ #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/display/vpFeatureDisplay.cpp b/modules/core/src/display/vpFeatureDisplay.cpp index 2f083a14ea..40f7360de9 100644 --- a/modules/core/src/display/vpFeatureDisplay.cpp +++ b/modules/core/src/display/vpFeatureDisplay.cpp @@ -50,7 +50,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/framegrabber/vpFrameGrabber.cpp b/modules/core/src/framegrabber/vpFrameGrabber.cpp index 5740f5dd7b..25e98a3e48 100644 --- a/modules/core/src/framegrabber/vpFrameGrabber.cpp +++ b/modules/core/src/framegrabber/vpFrameGrabber.cpp @@ -35,7 +35,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif unsigned int vpFrameGrabber::getHeight() const diff --git a/modules/core/src/image/private/vpBayerConversion.h b/modules/core/src/image/private/vpBayerConversion.h index 3cce883e44..505b3799e6 100644 --- a/modules/core/src/image/private/vpBayerConversion.h +++ b/modules/core/src/image/private/vpBayerConversion.h @@ -75,7 +75,7 @@ template T demosaicCrossBilinear(const T *bayer, unsigned int width // Malvar template T demosaicPhiMalvar(const T *bayer, unsigned int width, unsigned int i, unsigned int j) { - return vpMath::saturate( + return VISP_NAMESPACE_ADDRESSING vpMath::saturate( (-bayer[(i - 2) * width + j] - bayer[(i - 1) * width + j - 1] + 4 * bayer[(i - 1) * width + j] - bayer[(i - 1) * width + j + 1] + 0.5f * bayer[i * width + j - 2] + 5 * bayer[i * width + j] + 0.5f * bayer[i * width + j + 2] - bayer[(i + 1) * width + j - 1] + 4 * bayer[(i + 1) * width + j] - @@ -85,17 +85,17 @@ template T demosaicPhiMalvar(const T *bayer, unsigned int width, un template T demosaicThetaMalvar(const T *bayer, unsigned int width, unsigned int i, unsigned int j) { - return vpMath::saturate((0.5f * bayer[(i - 2) * width + j] - bayer[(i - 1) * width + j - 1] - - bayer[(i - 1) * width + j + 1] - bayer[i * width + j - 2] + 4 * bayer[i * width + j - 1] + - 5 * bayer[i * width + j] + 4 * bayer[i * width + j + 1] - bayer[i * width + j + 2] - - bayer[(i + 1) * width + j - 1] - bayer[(i + 1) * width + j + 1] + - 0.5f * bayer[(i + 2) * width + j]) * + return VISP_NAMESPACE_ADDRESSING vpMath::saturate((0.5f * bayer[(i - 2) * width + j] - bayer[(i - 1) * width + j - 1] - + bayer[(i - 1) * width + j + 1] - bayer[i * width + j - 2] + 4 * bayer[i * width + j - 1] + + 5 * bayer[i * width + j] + 4 * bayer[i * width + j + 1] - bayer[i * width + j + 2] - + bayer[(i + 1) * width + j - 1] - bayer[(i + 1) * width + j + 1] + + 0.5f * bayer[(i + 2) * width + j]) * 0.125f); } template T demosaicCheckerMalvar(const T *bayer, unsigned int width, unsigned int i, unsigned int j) { - return vpMath::saturate( + return VISP_NAMESPACE_ADDRESSING vpMath::saturate( (-1.5f * bayer[(i - 2) * width + j] + 2 * bayer[(i - 1) * width + j - 1] + 2 * bayer[(i - 1) * width + j + 1] - 1.5f * bayer[i * width + j - 2] + 6 * bayer[i * width + j] - 1.5f * bayer[i * width + j + 2] + 2 * bayer[(i + 1) * width + j - 1] + 2 * bayer[(i + 1) * width + j + 1] - 1.5f * bayer[(i + 2) * width + j]) * @@ -104,9 +104,9 @@ template T demosaicCheckerMalvar(const T *bayer, unsigned int width template T demosaicCrossMalvar(const T *bayer, unsigned int width, unsigned int i, unsigned int j) { - return vpMath::saturate((-bayer[(i - 2) * width + j] + 2 * bayer[(i - 1) * width + j] - bayer[i * width + j - 2] + - 2 * bayer[i * width + j - 1] + 4 * bayer[i * width + j] + 2 * bayer[i * width + j + 1] - - bayer[i * width + j + 2] + 2 * bayer[(i + 1) * width + j] - bayer[(i + 2) * width + j]) * + return VISP_NAMESPACE_ADDRESSING vpMath::saturate((-bayer[(i - 2) * width + j] + 2 * bayer[(i - 1) * width + j] - bayer[i * width + j - 2] + + 2 * bayer[i * width + j - 1] + 4 * bayer[i * width + j] + 2 * bayer[i * width + j + 1] - + bayer[i * width + j + 2] + 2 * bayer[(i + 1) * width + j] - bayer[(i + 2) * width + j]) * 0.125f); } diff --git a/modules/core/src/image/private/vpImageConvert_impl.h b/modules/core/src/image/private/vpImageConvert_impl.h index 177e8061f3..05de1aa317 100644 --- a/modules/core/src/image/private/vpImageConvert_impl.h +++ b/modules/core/src/image/private/vpImageConvert_impl.h @@ -51,7 +51,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/image/vpCannyEdgeDetection.cpp b/modules/core/src/image/vpCannyEdgeDetection.cpp index 78a5ab0783..0548a55d51 100644 --- a/modules/core/src/image/vpCannyEdgeDetection.cpp +++ b/modules/core/src/image/vpCannyEdgeDetection.cpp @@ -57,23 +57,14 @@ static void scaleFilter( #endif #ifdef VISP_HAVE_NLOHMANN_JSON -void ::from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpCannyEdgeDetection &detector) +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector) { - std::string filteringAndGradientName = #if defined(ENABLE_VISP_NAMESPACE) - visp:: + using namespace VISP_NAMESPACE_NAME; #endif - vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); + std::string filteringAndGradientName = vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); filteringAndGradientName = j.value("filteringAndGradientType", filteringAndGradientName); - detector.m_filteringAndGradientType = -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpImageFilter::vpCannyFiltAndGradTypeFromStr(filteringAndGradientName); + detector.m_filteringAndGradientType = vpImageFilter::vpCannyFiltAndGradTypeFromStr(filteringAndGradientName); detector.m_gaussianKernelSize = j.value("gaussianSize", detector.m_gaussianKernelSize); detector.m_gaussianStdev = j.value("gaussianStdev", detector.m_gaussianStdev); detector.m_lowerThreshold = j.value("lowerThreshold", detector.m_lowerThreshold); @@ -83,17 +74,9 @@ void ::from_json(const nlohmann::json &j, detector.m_upperThresholdRatio = j.value("upperThresholdRatio", detector.m_upperThresholdRatio); } -void ::to_json(nlohmann::json &j, const -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif -vpCannyEdgeDetection &detector) +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector) { - std::string filteringAndGradientName = -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); + std::string filteringAndGradientName = VISP_NAMESPACE_ADDRESSING vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); j = nlohmann::json { {"filteringAndGradientType", filteringAndGradientName}, {"gaussianSize", detector.m_gaussianKernelSize}, @@ -108,7 +91,7 @@ vpCannyEdgeDetection &detector) #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif // // Initialization methods diff --git a/modules/core/src/image/vpColormap.cpp b/modules/core/src/image/vpColormap.cpp index 1cb501b5a6..6cee3b61c9 100644 --- a/modules/core/src/image/vpColormap.cpp +++ b/modules/core/src/image/vpColormap.cpp @@ -1008,7 +1008,7 @@ unsigned char m_winterSrgbBytes[256][3] = { }; #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/image/vpFont.cpp b/modules/core/src/image/vpFont.cpp index 6b9b3e99c8..439d6a2f95 100644 --- a/modules/core/src/image/vpFont.cpp +++ b/modules/core/src/image/vpFont.cpp @@ -68,7 +68,7 @@ #include "private/stb_truetype.h" #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/src/image/vpGaussianFilter.cpp b/modules/core/src/image/vpGaussianFilter.cpp index 9bc6f356e8..625411496a 100644 --- a/modules/core/src/image/vpGaussianFilter.cpp +++ b/modules/core/src/image/vpGaussianFilter.cpp @@ -39,7 +39,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/src/image/vpImageCircle.cpp b/modules/core/src/image/vpImageCircle.cpp index ce35034320..9bbadd1b4d 100644 --- a/modules/core/src/image/vpImageCircle.cpp +++ b/modules/core/src/image/vpImageCircle.cpp @@ -35,7 +35,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif vpImageCircle::vpImageCircle() diff --git a/modules/core/src/image/vpImageConvert.cpp b/modules/core/src/image/vpImageConvert.cpp index d6abbd7306..455c44b922 100644 --- a/modules/core/src/image/vpImageConvert.cpp +++ b/modules/core/src/image/vpImageConvert.cpp @@ -57,7 +57,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif bool vpImageConvert::YCbCrLUTcomputed = false; diff --git a/modules/core/src/image/vpImageConvert_hsv.cpp b/modules/core/src/image/vpImageConvert_hsv.cpp index 647093e36f..7ce121869c 100644 --- a/modules/core/src/image/vpImageConvert_hsv.cpp +++ b/modules/core/src/image/vpImageConvert_hsv.cpp @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/image/vpImageConvert_pcl.cpp b/modules/core/src/image/vpImageConvert_pcl.cpp index d588f81dbd..a53274b158 100644 --- a/modules/core/src/image/vpImageConvert_pcl.cpp +++ b/modules/core/src/image/vpImageConvert_pcl.cpp @@ -49,7 +49,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/image/vpImageConvert_yuv.cpp b/modules/core/src/image/vpImageConvert_yuv.cpp index c0a1f11dfb..afc002a8f6 100644 --- a/modules/core/src/image/vpImageConvert_yuv.cpp +++ b/modules/core/src/image/vpImageConvert_yuv.cpp @@ -55,7 +55,7 @@ void vpSAT(int &c) }; #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/image/vpImageDraw.cpp b/modules/core/src/image/vpImageDraw.cpp index fe146e9444..15171f14ed 100644 --- a/modules/core/src/image/vpImageDraw.cpp +++ b/modules/core/src/image/vpImageDraw.cpp @@ -63,6 +63,9 @@ namespace { +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif template void DrawLine(vpImage &canvas, int x1, int y1, int x2, int y2, const Type &color, unsigned int width = 1) { @@ -235,7 +238,7 @@ void DrawRectangle(vpImage &canvas, const vpRect &rect, const Type &color, } // namespace #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/image/vpImageFilter.cpp b/modules/core/src/image/vpImageFilter.cpp index a4070fc528..edc0138892 100644 --- a/modules/core/src/image/vpImageFilter.cpp +++ b/modules/core/src/image/vpImageFilter.cpp @@ -37,7 +37,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /** diff --git a/modules/core/src/image/vpImagePoint.cpp b/modules/core/src/image/vpImagePoint.cpp index 5f9c724ba7..76d1573c39 100644 --- a/modules/core/src/image/vpImagePoint.cpp +++ b/modules/core/src/image/vpImagePoint.cpp @@ -39,7 +39,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -123,14 +123,58 @@ vpImagePoint &vpImagePoint::operator/=(double scale) return *this; } +/** + * Computes and returns the bounding box. + * @param ipVec : Vector of input image points. + * @return Bounding box of the points. + */ +vpRect vpImagePoint::getBBox(const std::vector &ipVec) +{ + vpRect rec(ipVec); + + return rec; +} + +/*! + Compute the distance \f$ |iP1 - iP2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2} \f$ + + \param iP1 : First point + \param iP2 : Second point + + \return the distance between the two points. +*/ +double vpImagePoint::distance(const vpImagePoint &iP1, const vpImagePoint &iP2) +{ + return sqrt(vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j())); +} + +/*! + Compute the distance \f$ |iP1 - iP2| = (i_1-i_2)^2+(j_1-j_2)^2 \f$ + + \param iP1 : First point + \param iP2 : Second point + + \return the distance between the two points. +*/ +double vpImagePoint::sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP2) +{ + return vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j()); +} +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! \relates vpImagePoint Returns true if ip1 and ip2 are equal; otherwire returns false. */ -VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2) +VISP_EXPORT bool operator==(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) { - // --comment: return ip1 dot get_i() eq ip2 dot get_i() and ip1 dot get_j() eq ip2 dot get_j() +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif +// --comment: return ip1 dot get_i() eq ip2 dot get_i() and ip1 dot get_j() eq ip2 dot get_j() double i1 = ip1.get_i(); double j1 = ip1.get_j(); @@ -146,9 +190,12 @@ VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2) Returns true if ip1 and ip2 are different; otherwire returns true. */ -VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2) +VISP_EXPORT bool operator!=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) { - // --comment: return ip1 dot get_i() diff ip2 dot get_i() or ip1 dot get_j() diff ip2 dot get_j() +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif +// --comment: return ip1 dot get_i() diff ip2 dot get_i() or ip1 dot get_j() diff ip2 dot get_j() double i1 = ip1.get_i(); double j1 = ip1.get_j(); double i2 = ip2.get_i(); @@ -163,9 +210,9 @@ VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2) Returns a vpImagePoint wich is the sum of \f$ ip1 \f$ and \f$ ip2 \f$. */ -VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, const vpImagePoint &ip2) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) { - return (vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); } /*! @@ -173,9 +220,9 @@ VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, const vpImagePoint & Returns a vpImagePoint wich is the sum of \f$ ip1 \f$ and \f$ ip2 \f$. */ -VISP_EXPORT vpImagePoint operator+=(const vpImagePoint &ip1, const vpImagePoint &ip2) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) { - return (vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); } /*! @@ -197,9 +244,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, int offset) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset) { - return (vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); } /*! @@ -221,9 +268,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, unsigned int offset) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset) { - return (vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); } /*! @@ -245,9 +292,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, double offset) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset) { - return (vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); } /*! @@ -256,9 +303,9 @@ VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, double offset) Returns a vpImagePoint wich is the difference between \f$ ip1 \f$ and \f$ ip2 \f$. */ -VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, const vpImagePoint &ip2) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) { - return (vpImagePoint(ip1.get_i() - ip2.get_i(), ip1.get_j() - ip2.get_j())); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - ip2.get_i(), ip1.get_j() - ip2.get_j())); } /*! @@ -280,9 +327,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, int offset) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset) { - return (vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); } /*! @@ -304,9 +351,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, unsigned int offset) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset) { - return (vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); } /*! @@ -328,9 +375,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, double offset) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset) { - return (vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); } /*! @@ -352,9 +399,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator*(const vpImagePoint &ip1, double scale) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator*(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale) { - return (vpImagePoint(ip1.get_i() * scale, ip1.get_j() * scale)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() * scale, ip1.get_j() * scale)); } /*! @@ -376,9 +423,9 @@ int main() } \endcode */ -VISP_EXPORT vpImagePoint operator/(const vpImagePoint &ip1, double scale) +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator/(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale) { - return (vpImagePoint(ip1.get_i() / scale, ip1.get_j() / scale)); + return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() / scale, ip1.get_j() / scale)); } /*! @@ -412,49 +459,8 @@ int main() Image point with coordinates: 10, 11.1 \endverbatim */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpImagePoint &ip) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip) { os << ip.get_i() << ", " << ip.get_j(); return os; } - -/** - * Computes and returns the bounding box. - * @param ipVec : Vector of input image points. - * @return Bounding box of the points. - */ -vpRect vpImagePoint::getBBox(const std::vector &ipVec) -{ - vpRect rec(ipVec); - - return rec; -} - -/*! - Compute the distance \f$ |iP1 - iP2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2} \f$ - - \param iP1 : First point - \param iP2 : Second point - - \return the distance between the two points. -*/ -double vpImagePoint::distance(const vpImagePoint &iP1, const vpImagePoint &iP2) -{ - return sqrt(vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j())); -} - -/*! - Compute the distance \f$ |iP1 - iP2| = (i_1-i_2)^2+(j_1-j_2)^2 \f$ - - \param iP1 : First point - \param iP2 : Second point - - \return the distance between the two points. -*/ -double vpImagePoint::sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP2) -{ - return vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j()); -} -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/image/vpImageTools.cpp b/modules/core/src/image/vpImageTools.cpp index e2867bfa7c..1eb1853f67 100644 --- a/modules/core/src/image/vpImageTools.cpp +++ b/modules/core/src/image/vpImageTools.cpp @@ -43,7 +43,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/image/vpRGBa.cpp b/modules/core/src/image/vpRGBa.cpp index a46d1f5231..5b4850e746 100644 --- a/modules/core/src/image/vpRGBa.cpp +++ b/modules/core/src/image/vpRGBa.cpp @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -232,8 +232,11 @@ bool vpRGBa::operator>(const vpRGBa &v) const return (gray1 > gray2); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif -vpRGBa operator*(const double &x, const vpRGBa &rgb) { return rgb * x; } +VISP_NAMESPACE_ADDRESSING vpRGBa operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgb) { return rgb * x; } /*! @@ -257,11 +260,8 @@ int main() } \endcode */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgba) { os << "(" << static_cast(rgba.R) << "," << static_cast(rgba.G) << "," << static_cast(rgba.B) << "," << static_cast(rgba.A) << ")"; return os; } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/image/vpRGBf.cpp b/modules/core/src/image/vpRGBf.cpp index ab4c977760..748168277e 100644 --- a/modules/core/src/image/vpRGBf.cpp +++ b/modules/core/src/image/vpRGBf.cpp @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -237,8 +237,11 @@ bool vpRGBf::operator>(const vpRGBf &v) const return (gray1 > gray2); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif -vpRGBf operator*(double x, const vpRGBf &rgb) { return rgb * x; } +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpRGBf operator*(double x, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb) { return rgb * x; } /*! \relates vpRGBf @@ -261,11 +264,8 @@ int main() } \endcode */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBf &rgb) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb) { os << "(" << rgb.R << "," << rgb.G << "," << rgb.B << ")"; return os; } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/math/kalman/vpKalmanFilter.cpp b/modules/core/src/math/kalman/vpKalmanFilter.cpp index 9112f4038e..50cc917035 100644 --- a/modules/core/src/math/kalman/vpKalmanFilter.cpp +++ b/modules/core/src/math/kalman/vpKalmanFilter.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize the Kalman filter. @@ -87,9 +91,8 @@ void vpKalmanFilter::init(unsigned int size_state_vector, unsigned int size_meas */ vpKalmanFilter::vpKalmanFilter() : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(), - dt(-1), Ppre(), Pest(), W(), I() -{ -} + dt(-1), Ppre(), Pest(), W(), I() +{ } /*! Construct a default Kalman filter by setting the number of signal to filter. @@ -100,9 +103,8 @@ vpKalmanFilter::vpKalmanFilter() */ vpKalmanFilter::vpKalmanFilter(unsigned int n_signal) : iter(0), size_state(0), size_measure(0), nsignal(n_signal), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(), - dt(-1), Ppre(), Pest(), W(), I() -{ -} + dt(-1), Ppre(), Pest(), W(), I() +{ } /*! Construct a Kalman filter. @@ -119,7 +121,7 @@ vpKalmanFilter::vpKalmanFilter(unsigned int n_signal) */ vpKalmanFilter::vpKalmanFilter(unsigned int size_state_vector, unsigned int size_measure_vector, unsigned int n_signal) : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(), - dt(-1), Ppre(), Pest(), W(), I() + dt(-1), Ppre(), Pest(), W(), I() { init(size_state_vector, size_measure_vector, n_signal); } @@ -285,81 +287,80 @@ vpKalmanFilter::initFilterCteAcceleration(double dt, vpColVector &Z0, vpColVector &Z1, vpColVector &Z2, - vpColVector &sigma_noise, - vpColVector &sigma_state ) + vpColVector &sigma_noise, + vpColVector &sigma_state) { - this->dt = dt ; + this->dt = dt; - double dt2 = dt*dt ; - double dt3 = dt2*dt ; - double dt4 = dt3*dt ; - double dt5 = dt4*dt ; + double dt2 = dt*dt; + double dt3 = dt2*dt; + double dt4 = dt3*dt; + double dt5 = dt4*dt; //init_done = true ; - Pest =0 ; + Pest = 0; // initialise les matrices decrivant les modeles - for (int i=0; i < size_measure ; i++ ) - { + for (int i = 0; i < size_measure; i++) { // modele sur l'etat // | 1 dt dt2/2 | // F = | 0 1 dt | // | 0 0 1 | - F[3*i][3*i] = 1 ; - F[3*i][3*i+1] = dt ; - F[3*i][3*i+2] = dt*dt/2 ; - F[3*i+1][3*i+1] = 1 ; - F[3*i+1][3*i+2] = dt ; - F[3*i+2][3*i+2] = 1 ; + F[3*i][3*i] = 1; + F[3*i][3*i+1] = dt; + F[3*i][3*i+2] = dt*dt/2; + F[3*i+1][3*i+1] = 1; + F[3*i+1][3*i+2] = dt; + F[3*i+2][3*i+2] = 1; // modele sur la mesure - H[i][3*i] = 1 ; - H[i][3*i+1] = 0 ; - H[i][3*i+2] = 0 ; + H[i][3*i] = 1; + H[i][3*i+1] = 0; + H[i][3*i+2] = 0; - double sR = sigma_noise[i] ; - double sQ = sigma_state[i] ; + double sR = sigma_noise[i]; + double sQ = sigma_state[i]; // bruit de mesure - R[i][i] = (sR) ; + R[i][i] = (sR); // bruit d'etat 6.2.3.9 - Q[3*i ][3*i ] = sQ * dt5/20; - Q[3*i ][3*i+1] = sQ * dt4/8; - Q[3*i ][3*i+2] = sQ * dt3/6 ; + Q[3*i][3*i] = sQ * dt5/20; + Q[3*i][3*i+1] = sQ * dt4/8; + Q[3*i][3*i+2] = sQ * dt3/6; - Q[3*i+1][3*i ] = sQ * dt4/8 ; - Q[3*i+1][3*i+1] = sQ * dt3/3 ; - Q[3*i+1][3*i+2] = sQ * dt2/2 ; + Q[3*i+1][3*i] = sQ * dt4/8; + Q[3*i+1][3*i+1] = sQ * dt3/3; + Q[3*i+1][3*i+2] = sQ * dt2/2; - Q[3*i+2][3*i ] = sQ * dt3/6 ; - Q[3*i+2][3*i+1] = sQ * dt2/2.0 ; - Q[3*i+2][3*i+2] = sQ * dt ; + Q[3*i+2][3*i] = sQ * dt3/6; + Q[3*i+2][3*i+1] = sQ * dt2/2.0; + Q[3*i+2][3*i+2] = sQ * dt; // Initialisation pour la matrice de covariance sur l'etat - Pest[3*i ][3*i ] = sR ; - Pest[3*i ][3*i+1] = 1.5/dt*sR ; - Pest[3*i ][3*i+2] = sR/(dt2) ; + Pest[3*i][3*i] = sR; + Pest[3*i][3*i+1] = 1.5/dt*sR; + Pest[3*i][3*i+2] = sR/(dt2); - Pest[3*i+1][3*i ] = 1.5/dt*sR ; - Pest[3*i+1][3*i+1] = dt3/3*sQ + 13/(2*dt2)*sR ; - Pest[3*i+1][3*i+2] = 9*dt2*sQ/40.0 +6/dt3*sR ; + Pest[3*i+1][3*i] = 1.5/dt*sR; + Pest[3*i+1][3*i+1] = dt3/3*sQ + 13/(2*dt2)*sR; + Pest[3*i+1][3*i+2] = 9*dt2*sQ/40.0 +6/dt3*sR; - Pest[3*i+2][3*i ] = sR/(dt2) ; - Pest[3*i+2][3*i+1] = 9*dt2*sQ/40.0 +6/dt3*sR ; - Pest[3*i+2][3*i+2] = 23*dt/30.0*sQ+6.0/dt4*sR ; + Pest[3*i+2][3*i] = sR/(dt2); + Pest[3*i+2][3*i+1] = 9*dt2*sQ/40.0 +6/dt3*sR; + Pest[3*i+2][3*i+2] = 23*dt/30.0*sQ+6.0/dt4*sR; // Initialisation pour l'etat - Xest[3*i] = Z2[i] ; - Xest[3*i+1] = ( 1.5 *Z2[i] - Z1[i] -0.5*Z0[i] ) /( 2*dt ) ; - Xest[3*i+2] = ( Z2[i] - 2*Z1[i] + Z0[i] ) /( dt*dt ) ; + Xest[3*i] = Z2[i]; + Xest[3*i+1] = (1.5 *Z2[i] - Z1[i] -0.5*Z0[i]) /(2*dt); + Xest[3*i+2] = (Z2[i] - 2*Z1[i] + Z0[i]) /(dt*dt); } } @@ -369,82 +370,84 @@ vpKalmanFilter::initFilterSinger(double dt, double a, vpColVector &Z0, vpColVector &Z1, - vpColVector &sigma_noise, - vpColVector &sigma_state ) + vpColVector &sigma_noise, + vpColVector &sigma_state) { - this->dt = dt ; + this->dt = dt; - double dt2 = dt*dt ; - double dt3 = dt2*dt ; + double dt2 = dt*dt; + double dt3 = dt2*dt; - double a2 = a*a ; - double a3 = a2*a ; - double a4 = a3*a ; + double a2 = a*a; + double a3 = a2*a; + double a4 = a3*a; //init_done = true ; - Pest =0 ; + Pest = 0; // initialise les matrices decrivant les modeles - for (int i=0; i < size_measure ; i++ ) - { + for (int i = 0; i < size_measure; i++) { // modele sur l'etat // | 1 dt dt2/2 | // F = | 0 1 dt | // | 0 0 1 | - F[3*i][3*i] = 1 ; - F[3*i][3*i+1] = dt ; - F[3*i][3*i+2] = 1/a2*(1+a*dt+exp(-a*dt)) ; - F[3*i+1][3*i+1] = 1 ; - F[3*i+1][3*i+2] = 1/a*(1-exp(-a*dt)) ; - F[3*i+2][3*i+2] = exp(-a*dt) ; + F[3*i][3*i] = 1; + F[3*i][3*i+1] = dt; + F[3*i][3*i+2] = 1/a2*(1+a*dt+exp(-a*dt)); + F[3*i+1][3*i+1] = 1; + F[3*i+1][3*i+2] = 1/a*(1-exp(-a*dt)); + F[3*i+2][3*i+2] = exp(-a*dt); // modele sur la mesure - H[i][3*i] = 1 ; - H[i][3*i+1] = 0 ; - H[i][3*i+2] = 0 ; + H[i][3*i] = 1; + H[i][3*i+1] = 0; + H[i][3*i+2] = 0; - double sR = sigma_noise[i] ; - double sQ = sigma_state[i] ; + double sR = sigma_noise[i]; + double sQ = sigma_state[i]; - R[i][i] = (sR) ; // bruit de mesure 1.5mm + R[i][i] = (sR); // bruit de mesure 1.5mm - Q[3*i ][3*i ] = sQ/a4*(1-exp(-2*a*dt)+2*a*dt+2*a3/3*dt3-2*a2*dt2-4*a*dt*exp(-a*dt) ) ; - Q[3*i ][3*i+1] = sQ/a3*(1+exp(-2*a*dt)-2*exp(-a*dt)+2*a*dt*exp(-a*dt)-2*a*dt+a2*dt2 ) ; - Q[3*i ][3*i+2] = sQ/a2*(1-exp(-2*a*dt)-2*a*dt*exp(-a*dt) ) ; + Q[3*i][3*i] = sQ/a4*(1-exp(-2*a*dt)+2*a*dt+2*a3/3*dt3-2*a2*dt2-4*a*dt*exp(-a*dt)); + Q[3*i][3*i+1] = sQ/a3*(1+exp(-2*a*dt)-2*exp(-a*dt)+2*a*dt*exp(-a*dt)-2*a*dt+a2*dt2); + Q[3*i][3*i+2] = sQ/a2*(1-exp(-2*a*dt)-2*a*dt*exp(-a*dt)); - Q[3*i+1][3*i ] = Q[3*i ][3*i+1] ; - Q[3*i+1][3*i+1] = sQ/a2*(4*exp(-a*dt)-3-exp(-2*a*dt)+2*a*dt ) ; - Q[3*i+1][3*i+2] = sQ/a*(exp(-2*a*dt)+1- 2*exp(-a*dt)) ; + Q[3*i+1][3*i] = Q[3*i][3*i+1]; + Q[3*i+1][3*i+1] = sQ/a2*(4*exp(-a*dt)-3-exp(-2*a*dt)+2*a*dt); + Q[3*i+1][3*i+2] = sQ/a*(exp(-2*a*dt)+1- 2*exp(-a*dt)); - Q[3*i+2][3*i ] = Q[3*i ][3*i+2] ; - Q[3*i+2][3*i+1] = Q[3*i+1][3*i+2] ; - Q[3*i+2][3*i+2] = sQ*(1-exp(-2*a*dt) ) ; + Q[3*i+2][3*i] = Q[3*i][3*i+2]; + Q[3*i+2][3*i+1] = Q[3*i+1][3*i+2]; + Q[3*i+2][3*i+2] = sQ*(1-exp(-2*a*dt)); // Initialisation pour la matrice de covariance sur l'etat - Pest[3*i ][3*i ] = sR ; - Pest[3*i ][3*i+1] = 1/dt*sR ; - Pest[3*i ][3*i+2] = 0 ; + Pest[3*i][3*i] = sR; + Pest[3*i][3*i+1] = 1/dt*sR; + Pest[3*i][3*i+2] = 0; - Pest[3*i+1][3*i ] = 1/dt*sR ; + Pest[3*i+1][3*i] = 1/dt*sR; Pest[3*i+1][3*i+1] = 2*sR/dt2 + sQ/(a4*dt2)*(2-a2*dt2+2*a3*dt3/3.0 -2*exp(-a*dt)-2*a*dt*exp(-a*dt)); - Pest[3*i+1][3*i+2] = sQ/(a2*dt)*(exp(-a*dt)+a*dt-1) ; + Pest[3*i+1][3*i+2] = sQ/(a2*dt)*(exp(-a*dt)+a*dt-1); - Pest[3*i+2][3*i ] = 0 ; - Pest[3*i+2][3*i+1] = Pest[3*i+1][3*i+2] ; - Pest[3*i+2][3*i+2] = 0 ; + Pest[3*i+2][3*i] = 0; + Pest[3*i+2][3*i+1] = Pest[3*i+1][3*i+2]; + Pest[3*i+2][3*i+2] = 0; // Initialisation pour l'etat - Xest[3*i] = Z1[i] ; - Xest[3*i+1] = ( Z1[i] - Z0[i] ) /(dt ) ; - Xest[3*i+2] = 0 ; + Xest[3*i] = Z1[i]; + Xest[3*i+1] = (Z1[i] - Z0[i]) /(dt); + Xest[3*i+2] = 0; } } #endif +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp b/modules/core/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp index ad4179240d..669f7836d6 100644 --- a/modules/core/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp +++ b/modules/core/src/math/kalman/vpLinearKalmanFilterInstantiation.cpp @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize the Kalman filter material depending on the selected @@ -810,7 +814,8 @@ void vpLinearKalmanFilterInstantiation::filter(vpColVector &z) iter++; return; - } else if (iter == 1) { + } + else if (iter == 1) { if (model == stateConstVel_MeasurePos) { for (unsigned int i = 0; i < size_measure * nsignal; i++) { double z_prev = Xest[size_state * i]; // Previous mesured position @@ -827,3 +832,6 @@ void vpLinearKalmanFilterInstantiation::filter(vpColVector &z) filtering(z); prediction(); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/kalman/vpUKSigmaDrawerMerwe.cpp b/modules/core/src/math/kalman/vpUKSigmaDrawerMerwe.cpp index 56d64fb2dd..4ddf238aea 100644 --- a/modules/core/src/math/kalman/vpUKSigmaDrawerMerwe.cpp +++ b/modules/core/src/math/kalman/vpUKSigmaDrawerMerwe.cpp @@ -41,6 +41,10 @@ #include #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpUKSigmaDrawerMerwe::vpUKSigmaDrawerMerwe(const int &n, const double &alpha, const double &beta, const double &kappa, const vpAddSubFunction &resFunc, const vpAddSubFunction &addFunc) : vpUKSigmaDrawerAbstract(n) @@ -84,6 +88,9 @@ vpUKSigmaDrawerMerwe::vpSigmaPointsWeights vpUKSigmaDrawerMerwe::computeWeights( } return weights; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else void vpUKSigmaDrawerMerwe_dummy() { diff --git a/modules/core/src/math/kalman/vpUnscentedKalman.cpp b/modules/core/src/math/kalman/vpUnscentedKalman.cpp index c873e3b2b7..50f8b3aa96 100644 --- a/modules/core/src/math/kalman/vpUnscentedKalman.cpp +++ b/modules/core/src/math/kalman/vpUnscentedKalman.cpp @@ -39,6 +39,10 @@ #include #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpUnscentedKalman::vpUnscentedKalman(const vpMatrix &Q, const vpMatrix &R, std::shared_ptr &drawer, const vpProcessFunction &f, const vpMeasurementFunction &h) : m_Q(Q) , m_R(R) @@ -145,6 +149,9 @@ vpUnscentedKalman::vpUnscentedTransformResult vpUnscentedKalman::unscentedTransf } return result; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else void vpUnscentedKalman_dummy() { diff --git a/modules/core/src/math/matrix/vpColVector.cpp b/modules/core/src/math/matrix/vpColVector.cpp index 0c72b2cd9a..f5e8363229 100644 --- a/modules/core/src/math/matrix/vpColVector.cpp +++ b/modules/core/src/math/matrix/vpColVector.cpp @@ -58,7 +58,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif vpColVector vpColVector::operator+(const vpColVector &v) const diff --git a/modules/core/src/math/matrix/vpMatrix.cpp b/modules/core/src/math/matrix/vpMatrix.cpp index 1ec2ee4f16..056d2f6773 100644 --- a/modules/core/src/math/matrix/vpMatrix.cpp +++ b/modules/core/src/math/matrix/vpMatrix.cpp @@ -63,7 +63,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifdef VISP_HAVE_LAPACK diff --git a/modules/core/src/math/matrix/vpMatrix_cholesky.cpp b/modules/core/src/math/matrix/vpMatrix_cholesky.cpp index a68d19f570..330bef9959 100644 --- a/modules/core/src/math/matrix/vpMatrix_cholesky.cpp +++ b/modules/core/src/math/matrix/vpMatrix_cholesky.cpp @@ -72,7 +72,7 @@ extern "C" int dpotri_(char *uplo, integer *n, double *a, integer *lda, integer #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/matrix/vpMatrix_covariance.cpp b/modules/core/src/math/matrix/vpMatrix_covariance.cpp index 9e3b044aef..47d3b0f812 100644 --- a/modules/core/src/math/matrix/vpMatrix_covariance.cpp +++ b/modules/core/src/math/matrix/vpMatrix_covariance.cpp @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/matrix/vpMatrix_lu.cpp b/modules/core/src/math/matrix/vpMatrix_lu.cpp index 7c42b094ae..efc6629250 100644 --- a/modules/core/src/math/matrix/vpMatrix_lu.cpp +++ b/modules/core/src/math/matrix/vpMatrix_lu.cpp @@ -75,7 +75,7 @@ extern "C" void dgetri_(integer *n, double *a, integer *lda, integer *ipiv, doub #include // numeric_limits #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*-------------------------------------------------------------------- diff --git a/modules/core/src/math/matrix/vpMatrix_mul.cpp b/modules/core/src/math/matrix/vpMatrix_mul.cpp index e0aecb1430..3715bf900d 100644 --- a/modules/core/src/math/matrix/vpMatrix_mul.cpp +++ b/modules/core/src/math/matrix/vpMatrix_mul.cpp @@ -45,7 +45,7 @@ // that's why we prefer use naive code when VISP_HAVE_GSL is defined. #if defined(VISP_HAVE_LAPACK) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifdef VISP_HAVE_MKL diff --git a/modules/core/src/math/matrix/vpMatrix_qr.cpp b/modules/core/src/math/matrix/vpMatrix_qr.cpp index f80a2e6b72..2121bb2368 100644 --- a/modules/core/src/math/matrix/vpMatrix_qr.cpp +++ b/modules/core/src/math/matrix/vpMatrix_qr.cpp @@ -53,7 +53,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifdef VISP_HAVE_LAPACK diff --git a/modules/core/src/math/matrix/vpMatrix_svd.cpp b/modules/core/src/math/matrix/vpMatrix_svd.cpp index 7f5f5ec57a..082474bb0c 100644 --- a/modules/core/src/math/matrix/vpMatrix_svd.cpp +++ b/modules/core/src/math/matrix/vpMatrix_svd.cpp @@ -75,7 +75,7 @@ extern "C" int dgesdd_(char *jobz, integer *m, integer *n, double *a, integer *l #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*--------------------------------------------------------------------- diff --git a/modules/core/src/math/matrix/vpRowVector.cpp b/modules/core/src/math/matrix/vpRowVector.cpp index fb488de875..6b5c2fd6cd 100644 --- a/modules/core/src/math/matrix/vpRowVector.cpp +++ b/modules/core/src/math/matrix/vpRowVector.cpp @@ -52,7 +52,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif //! Copy operator. Allow operation such as A = v diff --git a/modules/core/src/math/matrix/vpSubColVector.cpp b/modules/core/src/math/matrix/vpSubColVector.cpp index b458ab47f0..a0a09f76ae 100644 --- a/modules/core/src/math/matrix/vpSubColVector.cpp +++ b/modules/core/src/math/matrix/vpSubColVector.cpp @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif //! Default constructor that creates an empty vector. diff --git a/modules/core/src/math/matrix/vpSubMatrix.cpp b/modules/core/src/math/matrix/vpSubMatrix.cpp index 2760aefcb4..c7fa6f8234 100644 --- a/modules/core/src/math/matrix/vpSubMatrix.cpp +++ b/modules/core/src/math/matrix/vpSubMatrix.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif vpSubMatrix::vpSubMatrix() : pRowNum(0), pColNum(0), parent(nullptr) { } diff --git a/modules/core/src/math/matrix/vpSubRowVector.cpp b/modules/core/src/math/matrix/vpSubRowVector.cpp index 6fb6181788..ddf2ccb03d 100644 --- a/modules/core/src/math/matrix/vpSubRowVector.cpp +++ b/modules/core/src/math/matrix/vpSubRowVector.cpp @@ -37,7 +37,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif //! Default constructor that creates an empty vector. diff --git a/modules/core/src/math/misc/vpHinkley.cpp b/modules/core/src/math/misc/vpHinkley.cpp index fc534c3e7e..7394e4d6a0 100644 --- a/modules/core/src/math/misc/vpHinkley.cpp +++ b/modules/core/src/math/misc/vpHinkley.cpp @@ -53,6 +53,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* VP_DEBUG_MODE fixed by configure: 1: 2: @@ -432,6 +436,9 @@ void vpHinkley::print(vpHinkley::vpHinkleyJumpType jump) break; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpHinkley.cpp.o) has no symbols void dummy_vpRHinkley() { }; diff --git a/modules/core/src/math/misc/vpMath.cpp b/modules/core/src/math/misc/vpMath.cpp index b025958c7a..d6e4bda7b9 100644 --- a/modules/core/src/math/misc/vpMath.cpp +++ b/modules/core/src/math/misc/vpMath.cpp @@ -55,7 +55,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #if !(defined(VISP_HAVE_FUNC_ISNAN) || defined(VISP_HAVE_FUNC_STD_ISNAN)) || \ diff --git a/modules/core/src/math/misc/vpStatisticalTestAbstract.cpp b/modules/core/src/math/misc/vpStatisticalTestAbstract.cpp index 3f1cb6e76a..d065c9b5c2 100644 --- a/modules/core/src/math/misc/vpStatisticalTestAbstract.cpp +++ b/modules/core/src/math/misc/vpStatisticalTestAbstract.cpp @@ -38,6 +38,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif std::string vpStatisticalTestAbstract::vpMeanDriftTypeToString(const vpStatisticalTestAbstract::vpMeanDriftType &type) { std::string name; @@ -244,3 +248,6 @@ vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestAbstract::testUpward return MEAN_DRIFT_NONE; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/misc/vpStatisticalTestEWMA.cpp b/modules/core/src/math/misc/vpStatisticalTestEWMA.cpp index 6e1d925f82..111727bfff 100644 --- a/modules/core/src/math/misc/vpStatisticalTestEWMA.cpp +++ b/modules/core/src/math/misc/vpStatisticalTestEWMA.cpp @@ -39,6 +39,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpStatisticalTestEWMA::computeDeltaAndLimits() { float delta = 3.f * m_stdev * std::sqrt(m_alpha / (2.f - m_alpha)); @@ -126,3 +130,6 @@ void vpStatisticalTestEWMA::setAlpha(const float &alpha) { init(alpha); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/misc/vpStatisticalTestHinkley.cpp b/modules/core/src/math/misc/vpStatisticalTestHinkley.cpp index ab07c8e1dd..ab6cd7a97b 100644 --- a/modules/core/src/math/misc/vpStatisticalTestHinkley.cpp +++ b/modules/core/src/math/misc/vpStatisticalTestHinkley.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpStatisticalTestHinkley::vpStatisticalTestHinkley() : vpStatisticalTestAbstract() , m_dmin2(0.1f) @@ -248,3 +252,6 @@ void vpStatisticalTestHinkley::updateTestSignals(const float &signal) ++m_count; computeMean(signal); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/misc/vpStatisticalTestMeanAdjustedCUSUM.cpp b/modules/core/src/math/misc/vpStatisticalTestMeanAdjustedCUSUM.cpp index c5fbb5fbdb..3af8ebaff5 100644 --- a/modules/core/src/math/misc/vpStatisticalTestMeanAdjustedCUSUM.cpp +++ b/modules/core/src/math/misc/vpStatisticalTestMeanAdjustedCUSUM.cpp @@ -39,6 +39,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpStatisticalTestMeanAdjustedCUSUM::computeDeltaAndLimits() { setDelta(m_k * m_stdev); @@ -153,3 +157,6 @@ void vpStatisticalTestMeanAdjustedCUSUM::init(const float &delta, const float &l m_sumForMean = 0.f; m_areStatisticsComputed = true; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp b/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp index 811d6a9d8e..61a1857357 100644 --- a/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp +++ b/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp @@ -43,6 +43,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const int vpStatisticalTestShewhart::NB_DATA_SIGNAL; const bool vpStatisticalTestShewhart::CONST_ALL_WECO_ACTIVATED[vpStatisticalTestShewhart::COUNT_WECO - 1] = { true, true, true, true }; @@ -306,3 +310,6 @@ void vpStatisticalTestShewhart::init(const bool &activateWECOrules, const bool a computeLimits(); m_areStatisticsComputed = true; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/misc/vpStatisticalTestSigma.cpp b/modules/core/src/math/misc/vpStatisticalTestSigma.cpp index 6180460386..9b705734f7 100644 --- a/modules/core/src/math/misc/vpStatisticalTestSigma.cpp +++ b/modules/core/src/math/misc/vpStatisticalTestSigma.cpp @@ -39,6 +39,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpStatisticalTestSigma::computeLimits() { float delta = m_h * m_stdev; @@ -112,3 +116,6 @@ void vpStatisticalTestSigma::init(const float &h, const float &mean, const float computeLimits(); m_areStatisticsComputed = true; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/random-generator/vpGaussRand.cpp b/modules/core/src/math/random-generator/vpGaussRand.cpp index 0682f07217..4ebc869d27 100644 --- a/modules/core/src/math/random-generator/vpGaussRand.cpp +++ b/modules/core/src/math/random-generator/vpGaussRand.cpp @@ -36,6 +36,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Generate a normal random variable using the Box-Muller generator. @@ -64,3 +68,6 @@ double vpGaussRand::gaussianDraw() return v1 * fac; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/random-generator/vpUniRand.cpp b/modules/core/src/math/random-generator/vpUniRand.cpp index 31d2dfcbb7..3ede0b2ce7 100644 --- a/modules/core/src/math/random-generator/vpUniRand.cpp +++ b/modules/core/src/math/random-generator/vpUniRand.cpp @@ -70,7 +70,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif vpUniRand::vpUniRand() diff --git a/modules/core/src/math/robust/vpRobust.cpp b/modules/core/src/math/robust/vpRobust.cpp index b178661c48..95b0fa110a 100644 --- a/modules/core/src/math/robust/vpRobust.cpp +++ b/modules/core/src/math/robust/vpRobust.cpp @@ -54,7 +54,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/robust/vpScale.cpp b/modules/core/src/math/robust/vpScale.cpp index 4af25912f2..8e1e647772 100644 --- a/modules/core/src/math/robust/vpScale.cpp +++ b/modules/core/src/math/robust/vpScale.cpp @@ -47,6 +47,10 @@ #define DEBUG_LEVEL2 0 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif //! Constructor vpScale::vpScale() : bandwidth(0.02), dimension(1) { @@ -71,7 +75,7 @@ vpScale::vpScale(double kernel_bandwidth, unsigned int dim) : bandwidth(kernel_b } //! Destructor -vpScale::~vpScale() {} +vpScale::~vpScale() { } // Calculate the modes of the density for the distribution // and their associated errors @@ -181,7 +185,8 @@ double vpScale::KernelDensityGradient(vpColVector &error, unsigned int position) inside_kernel = 1; sum_delta += error[j] - error[position]; j++; - } else { + } + else { inside_kernel = 0; } } @@ -196,7 +201,8 @@ double vpScale::KernelDensityGradient(vpColVector &error, unsigned int position) inside_kernel = 1; sum_delta += error[j] - error[position]; j--; - } else { + } + else { inside_kernel = 0; } } @@ -259,3 +265,6 @@ double vpScale::KernelDensityGradient_EPANECHNIKOV(double sumX, unsigned int n) // (double)dimension)*c*vpMath::sqr(bandwidth)); return sumX * (dimension + 2) / (n * bandwidth * c * vpMath::sqr(bandwidth)); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/spline/vpBSpline.cpp b/modules/core/src/math/spline/vpBSpline.cpp index 4f4b16cfb1..e2f7b774c6 100644 --- a/modules/core/src/math/spline/vpBSpline.cpp +++ b/modules/core/src/math/spline/vpBSpline.cpp @@ -36,6 +36,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. @@ -517,3 +521,6 @@ vpImagePoint *vpBSpline::computeCurveDers(double u, unsigned int der) const return derivate; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/math/transformation/vpExponentialMap.cpp b/modules/core/src/math/transformation/vpExponentialMap.cpp index f1472dde02..e6077f3859 100644 --- a/modules/core/src/math/transformation/vpExponentialMap.cpp +++ b/modules/core/src/math/transformation/vpExponentialMap.cpp @@ -39,7 +39,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/transformation/vpForceTwistMatrix.cpp b/modules/core/src/math/transformation/vpForceTwistMatrix.cpp index b97e0e8c77..a7a1f3751e 100644 --- a/modules/core/src/math/transformation/vpForceTwistMatrix.cpp +++ b/modules/core/src/math/transformation/vpForceTwistMatrix.cpp @@ -50,7 +50,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp b/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp index 8db2b1ab77..562f5ef791 100644 --- a/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp +++ b/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -1384,7 +1384,7 @@ void vpHomogeneousMatrix::convert_to_json(nlohmann::json &j) const void vpHomogeneousMatrix::parse_json(const nlohmann::json &j) { #if defined(ENABLE_VISP_NAMESPACE) - using namespace visp; + using namespace VISP_NAMESPACE_NAME; #endif vpArray2D *asArray = (vpArray2D*) this; if (j.is_object() && j.contains("type")) { // Specific conversions diff --git a/modules/core/src/math/transformation/vpPoseVector.cpp b/modules/core/src/math/transformation/vpPoseVector.cpp index f2461ec9d2..ae9d337a00 100644 --- a/modules/core/src/math/transformation/vpPoseVector.cpp +++ b/modules/core/src/math/transformation/vpPoseVector.cpp @@ -50,7 +50,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -616,7 +616,7 @@ void vpPoseVector::convert_to_json(nlohmann::json &j) const void vpPoseVector::parse_json(const nlohmann::json &j) { #if defined(ENABLE_VISP_NAMESPACE) - using namespace visp; + using namespace VISP_NAMESPACE_NAME; #endif vpArray2D *asArray = (vpArray2D*) this; if (j.is_object() && j.contains("type")) { // Specific conversions diff --git a/modules/core/src/math/transformation/vpQuaternionVector.cpp b/modules/core/src/math/transformation/vpQuaternionVector.cpp index 2cd55c12a4..326cd78e4a 100644 --- a/modules/core/src/math/transformation/vpQuaternionVector.cpp +++ b/modules/core/src/math/transformation/vpQuaternionVector.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif // minimum value of sine diff --git a/modules/core/src/math/transformation/vpRotationMatrix.cpp b/modules/core/src/math/transformation/vpRotationMatrix.cpp index 209d6a7e7b..f75cca57be 100644 --- a/modules/core/src/math/transformation/vpRotationMatrix.cpp +++ b/modules/core/src/math/transformation/vpRotationMatrix.cpp @@ -53,7 +53,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/transformation/vpRotationVector.cpp b/modules/core/src/math/transformation/vpRotationVector.cpp index e26688380d..66c56f4d8f 100644 --- a/modules/core/src/math/transformation/vpRotationVector.cpp +++ b/modules/core/src/math/transformation/vpRotationVector.cpp @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/transformation/vpRxyzVector.cpp b/modules/core/src/math/transformation/vpRxyzVector.cpp index bc4a936f20..c4312d8a79 100644 --- a/modules/core/src/math/transformation/vpRxyzVector.cpp +++ b/modules/core/src/math/transformation/vpRxyzVector.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! Default constructor that initialize all the 3 angles to zero. */ diff --git a/modules/core/src/math/transformation/vpRzyxVector.cpp b/modules/core/src/math/transformation/vpRzyxVector.cpp index b12de39431..18b5c8f3a9 100644 --- a/modules/core/src/math/transformation/vpRzyxVector.cpp +++ b/modules/core/src/math/transformation/vpRzyxVector.cpp @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! Default constructor that initialize all the 3 angles to zero. */ diff --git a/modules/core/src/math/transformation/vpRzyzVector.cpp b/modules/core/src/math/transformation/vpRzyzVector.cpp index 339533d40a..1dd7a18aac 100644 --- a/modules/core/src/math/transformation/vpRzyzVector.cpp +++ b/modules/core/src/math/transformation/vpRzyzVector.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! Default constructor that initialize all the 3 angles to zero. */ diff --git a/modules/core/src/math/transformation/vpThetaUVector.cpp b/modules/core/src/math/transformation/vpThetaUVector.cpp index b4cc60c079..b54297f3cf 100644 --- a/modules/core/src/math/transformation/vpThetaUVector.cpp +++ b/modules/core/src/math/transformation/vpThetaUVector.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif const double vpThetaUVector::minimum = 0.0001; diff --git a/modules/core/src/math/transformation/vpTranslationVector.cpp b/modules/core/src/math/transformation/vpTranslationVector.cpp index 3082c0148d..dc7327c1af 100644 --- a/modules/core/src/math/transformation/vpTranslationVector.cpp +++ b/modules/core/src/math/transformation/vpTranslationVector.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/transformation/vpVelocityTwistMatrix.cpp b/modules/core/src/math/transformation/vpVelocityTwistMatrix.cpp index 066efd633f..817ea6b4b7 100644 --- a/modules/core/src/math/transformation/vpVelocityTwistMatrix.cpp +++ b/modules/core/src/math/transformation/vpVelocityTwistMatrix.cpp @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp b/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp index 42ea6c2d0b..665472eece 100644 --- a/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp +++ b/modules/core/src/math/transformation/vpXmlParserHomogeneousMatrix.cpp @@ -63,7 +63,7 @@ #define LABEL_XML_TUZ "theta_uz" #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/src/munkres/vpMunkres.cpp b/modules/core/src/munkres/vpMunkres.cpp index 7af19d50f1..74e408fd97 100644 --- a/modules/core/src/munkres/vpMunkres.cpp +++ b/modules/core/src/munkres/vpMunkres.cpp @@ -43,7 +43,7 @@ #if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/tools/convert/vpConvert.cpp b/modules/core/src/tools/convert/vpConvert.cpp index 6ba42f78c6..74c036a18a 100644 --- a/modules/core/src/tools/convert/vpConvert.cpp +++ b/modules/core/src/tools/convert/vpConvert.cpp @@ -44,6 +44,10 @@ #include #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_FEATURES2D) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Unary function used to transform a cv::KeyPoint to a vpImagePoint. \param keypoint : KeyPoint to convert. @@ -461,6 +465,9 @@ void vpConvert::convertToOpenCV(const std::vector &from, std::vector #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif namespace vpCPUFeatures diff --git a/modules/core/src/tools/endian/vpEndian.cpp b/modules/core/src/tools/endian/vpEndian.cpp index 5166911f22..7a397b7a42 100644 --- a/modules/core/src/tools/endian/vpEndian.cpp +++ b/modules/core/src/tools/endian/vpEndian.cpp @@ -41,7 +41,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif namespace vpEndian diff --git a/modules/core/src/tools/exceptions/vpException.cpp b/modules/core/src/tools/exceptions/vpException.cpp index 2c2ee7df09..6ef46fc632 100644 --- a/modules/core/src/tools/exceptions/vpException.cpp +++ b/modules/core/src/tools/exceptions/vpException.cpp @@ -40,7 +40,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif vpException::vpException(int id) : code(id), message() { } @@ -72,13 +72,13 @@ const std::string &vpException::getStringMessage() const { return this->message; int vpException::getCode() const { return this->code; } const char *vpException::what() const throw() { return (this->message).c_str(); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpException &error) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpException &error) { os << "Error [" << error.code << "]:\t" << error.message << std::endl; return os; } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/tools/file/vpIoTools.cpp b/modules/core/src/tools/file/vpIoTools.cpp index cfdbb9c5e1..028e8fe80d 100644 --- a/modules/core/src/tools/file/vpIoTools.cpp +++ b/modules/core/src/tools/file/vpIoTools.cpp @@ -126,13 +126,13 @@ using namespace buminiz; #include -char visp::cnpy::BigEndianTest() +char VISP_NAMESPACE_ADDRESSING cnpy::BigEndianTest() { int x = 1; return (((reinterpret_cast(&x))[0]) ? '<' : '>'); } -char visp::cnpy::map_type(const std::type_info &t) +char VISP_NAMESPACE_ADDRESSING cnpy::map_type(const std::type_info &t) { if (t == typeid(float)) { return 'f'; } if (t == typeid(double)) { return 'f'; } @@ -159,7 +159,7 @@ char visp::cnpy::map_type(const std::type_info &t) else { return '?'; } } -void visp::cnpy::parse_npy_header(unsigned char *buffer, size_t &word_size, std::vector &shape, bool &fortran_order) +void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(unsigned char *buffer, size_t &word_size, std::vector &shape, bool &fortran_order) { uint16_t header_len = *reinterpret_cast(buffer+8); std::string header(reinterpret_cast(buffer+9), header_len); @@ -194,7 +194,7 @@ void visp::cnpy::parse_npy_header(unsigned char *buffer, size_t &word_size, std: word_size = atoi(str_ws.substr(0, loc2).c_str()); } -void visp::cnpy::parse_npy_header(FILE *fp, size_t &word_size, std::vector &shape, bool &fortran_order) +void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(FILE *fp, size_t &word_size, std::vector &shape, bool &fortran_order) { char buffer[256]; size_t res = fread(buffer, sizeof(char), 11, fp); @@ -250,7 +250,7 @@ void visp::cnpy::parse_npy_header(FILE *fp, size_t &word_size, std::vector footer(22); fseek(fp, -22, SEEK_END); @@ -274,14 +274,14 @@ void visp::cnpy::parse_zip_footer(FILE *fp, uint16_t &nrecs, size_t &global_head UNUSED(comment_len); assert(comment_len == 0); } -visp::cnpy::NpyArray load_the_npy_file(FILE *fp) +VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npy_file(FILE *fp) { std::vector shape; size_t word_size; bool fortran_order; - visp::cnpy::parse_npy_header(fp, word_size, shape, fortran_order); + VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(fp, word_size, shape, fortran_order); - visp::cnpy::NpyArray arr(shape, word_size, fortran_order); + VISP_NAMESPACE_ADDRESSING cnpy::NpyArray arr(shape, word_size, fortran_order); size_t nread = fread(arr.data(), 1, arr.num_bytes(), fp); if (nread != arr.num_bytes()) { throw std::runtime_error("load_the_npy_file: failed fread"); @@ -289,7 +289,7 @@ visp::cnpy::NpyArray load_the_npy_file(FILE *fp) return arr; } -visp::cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t uncompr_bytes) +VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t uncompr_bytes) { std::vector buffer_compr(compr_bytes); std::vector buffer_uncompr(uncompr_bytes); @@ -321,9 +321,9 @@ visp::cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t std::vector shape; size_t word_size; bool fortran_order; - visp::cnpy::parse_npy_header(&buffer_uncompr[0], word_size, shape, fortran_order); + VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(&buffer_uncompr[0], word_size, shape, fortran_order); - visp::cnpy::NpyArray array(shape, word_size, fortran_order); + VISP_NAMESPACE_ADDRESSING cnpy::NpyArray array(shape, word_size, fortran_order); size_t offset = uncompr_bytes - array.num_bytes(); memcpy(array.data(), &buffer_uncompr[0]+offset, array.num_bytes()); @@ -339,7 +339,7 @@ visp::cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t \warning This function has only been tested on little endian platform. \note Original library: cnpy with MIT license. */ -visp::cnpy::npz_t visp::cnpy::npz_load(std::string fname) +VISP_NAMESPACE_ADDRESSING cnpy::npz_t VISP_NAMESPACE_ADDRESSING cnpy::npz_load(std::string fname) { FILE *fp = fopen(fname.c_str(), "rb"); @@ -347,7 +347,7 @@ visp::cnpy::npz_t visp::cnpy::npz_load(std::string fname) throw std::runtime_error("npz_load: Error! Unable to open file "+fname+"!"); } - visp::cnpy::npz_t arrays; + VISP_NAMESPACE_ADDRESSING cnpy::npz_t arrays; bool quit = false; while (!quit) { std::vector local_header(30); @@ -404,7 +404,7 @@ visp::cnpy::npz_t visp::cnpy::npz_load(std::string fname) \warning This function has only been tested on little endian platform. \note Original library: cnpy with MIT license. */ -visp::cnpy::NpyArray visp::cnpy::npz_load(std::string fname, std::string varname) +VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npz_load(std::string fname, std::string varname) { FILE *fp = fopen(fname.c_str(), "rb"); @@ -469,7 +469,7 @@ visp::cnpy::NpyArray visp::cnpy::npz_load(std::string fname, std::string varname \warning This function has only been tested on little endian platform. \note Original library: cnpy with MIT license. */ -visp::cnpy::NpyArray visp::cnpy::npy_load(std::string fname) +VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npy_load(std::string fname) { FILE *fp = fopen(fname.c_str(), "rb"); @@ -487,7 +487,7 @@ visp::cnpy::NpyArray visp::cnpy::npy_load(std::string fname) #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif std::string vpIoTools::baseName = ""; @@ -546,7 +546,7 @@ std::string &rtrim(std::string &s) } // namespace #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -2132,16 +2132,16 @@ std::string vpIoTools::toLowerCase(const std::string &input) out += std::tolower(*it); } return out; - } +} - /** - * @brief Return a upper-case version of the string \b input . - * Numbers and special characters stay the same - * - * @param input The input string for which we want to ensure that all the characters are in upper case. - * @return std::string A upper-case version of the string \b input, where - * numbers and special characters stay the same - */ +/** + * @brief Return a upper-case version of the string \b input . + * Numbers and special characters stay the same + * + * @param input The input string for which we want to ensure that all the characters are in upper case. + * @return std::string A upper-case version of the string \b input, where + * numbers and special characters stay the same + */ std::string vpIoTools::toUpperCase(const std::string &input) { std::string out; @@ -2153,16 +2153,16 @@ std::string vpIoTools::toUpperCase(const std::string &input) out += std::toupper(*it); } return out; - } +} - /*! - Returns the absolute path using realpath() on Unix systems or - GetFullPathName() on Windows systems. \return According to realpath() - manual, returns an absolute pathname that names the same file, whose - resolution does not involve '.', '..', or symbolic links for Unix systems. - According to GetFullPathName() documentation, retrieves the full path of the - specified file for Windows systems. - */ +/*! + Returns the absolute path using realpath() on Unix systems or + GetFullPathName() on Windows systems. \return According to realpath() + manual, returns an absolute pathname that names the same file, whose + resolution does not involve '.', '..', or symbolic links for Unix systems. + According to GetFullPathName() documentation, retrieves the full path of the + specified file for Windows systems. + */ std::string vpIoTools::getAbsolutePathname(const std::string &pathname) { diff --git a/modules/core/src/tools/geometry/vpPlane.cpp b/modules/core/src/tools/geometry/vpPlane.cpp index 8837153155..3a76de02f9 100644 --- a/modules/core/src/tools/geometry/vpPlane.cpp +++ b/modules/core/src/tools/geometry/vpPlane.cpp @@ -44,7 +44,7 @@ #include // numeric_limits #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -383,16 +383,17 @@ void vpPlane::changeFrame(const vpHomogeneousMatrix &cMo) D = Do - ((cMo[0][3] * A) + (cMo[1][3] * B) + (cMo[2][3] * C)); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! Print the plane parameters as a stream like "(A,B,C,D) " where A,B,C and D correspond to the parameters of the plane. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpPlane &p) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPlane &p) { return (os << "(" << p.getA() << "," << p.getB() << "," << p.getC() << "," << p.getD() << ") "); }; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/tools/geometry/vpPolygon.cpp b/modules/core/src/tools/geometry/vpPolygon.cpp index 969b6e4cbc..deec53e328 100644 --- a/modules/core/src/tools/geometry/vpPolygon.cpp +++ b/modules/core/src/tools/geometry/vpPolygon.cpp @@ -44,22 +44,22 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp -{ -#endif // Local helper #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) #include + /*! * Compute convex hull corners. * * \param[in] ips : List of 2D points. */ -template std::vector convexHull(const IpContainer &ips) +template std::vector convexHull(const IpContainer &ips) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif if (ips.size() == 0) { throw vpException(vpException::badValue, "Convex Hull can not be computed as the input does not contain any image point."); @@ -109,6 +109,10 @@ template std::vector convexHull(const IpCon #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor that creates an empty polygon. */ diff --git a/modules/core/src/tools/geometry/vpPolygon3D.cpp b/modules/core/src/tools/geometry/vpPolygon3D.cpp index bf8f6b1e8f..9c59184d10 100644 --- a/modules/core/src/tools/geometry/vpPolygon3D.cpp +++ b/modules/core/src/tools/geometry/vpPolygon3D.cpp @@ -36,29 +36,33 @@ * *****************************************************************************/ -#include - -#include /*! \file vpPolygon3D.cpp \brief Implements a polygon of the model used by the model-based tracker. */ +#include + +#include + #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. */ vpPolygon3D::vpPolygon3D() : nbpt(0), nbCornersInsidePrev(0), p(nullptr), polyClipped(), clippingFlag(vpPolygon3D::NO_CLIPPING), - distNearClip(0.001), distFarClip(100.) -{ -} + distNearClip(0.001), distFarClip(100.) +{ } vpPolygon3D::vpPolygon3D(const vpPolygon3D &mbtp) : nbpt(mbtp.nbpt), nbCornersInsidePrev(mbtp.nbCornersInsidePrev), p(nullptr), polyClipped(mbtp.polyClipped), - clippingFlag(mbtp.clippingFlag), distNearClip(mbtp.distNearClip), distFarClip(mbtp.distFarClip) + clippingFlag(mbtp.clippingFlag), distNearClip(mbtp.distNearClip), distFarClip(mbtp.distFarClip) { if (p) delete[] p; @@ -201,23 +205,23 @@ void vpPolygon3D::computePolygonClipped(const vpCameraParameters &cam) break; case 4: problem = - !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, - p2ClippedInfo, fovNormals[0], vpPolygon3D::LEFT_CLIPPING)); + !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, + p2ClippedInfo, fovNormals[0], vpPolygon3D::LEFT_CLIPPING)); break; case 8: problem = - !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, - p2ClippedInfo, fovNormals[1], vpPolygon3D::RIGHT_CLIPPING)); + !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, + p2ClippedInfo, fovNormals[1], vpPolygon3D::RIGHT_CLIPPING)); break; case 16: problem = - !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, - p2ClippedInfo, fovNormals[2], vpPolygon3D::UP_CLIPPING)); + !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, + p2ClippedInfo, fovNormals[2], vpPolygon3D::UP_CLIPPING)); break; case 32: problem = - !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, - p2ClippedInfo, fovNormals[3], vpPolygon3D::DOWN_CLIPPING)); + !(vpPolygon3D::getClippedPointsFovGeneric(p1Clipped, p2Clipped, p1Clipped, p2Clipped, p1ClippedInfo, + p2ClippedInfo, fovNormals[3], vpPolygon3D::DOWN_CLIPPING)); break; } @@ -306,7 +310,8 @@ bool vpPolygon3D::getClippedPointsFovGeneric(const vpPoint &p1, const vpPoint &p if (beta1 < M_PI / 2.0) { p1ClippedInfo = p1ClippedInfo | flag; p1Clipped = pClipped; - } else { + } + else { p2ClippedInfo = p2ClippedInfo | flag; p2Clipped = pClipped; } @@ -361,7 +366,8 @@ bool vpPolygon3D::getClippedPointsDistance(const vpPoint &p1, const vpPoint &p2, p1ClippedInfo = p1ClippedInfo | vpPolygon3D::FAR_CLIPPING; else p1ClippedInfo = p1ClippedInfo | vpPolygon3D::NEAR_CLIPPING; - } else { + } + else { p2Clipped = pClippedNear; if (flag == vpPolygon3D::FAR_CLIPPING) p2ClippedInfo = p2ClippedInfo | vpPolygon3D::FAR_CLIPPING; @@ -645,3 +651,6 @@ bool vpPolygon3D::roiInsideImage(const vpImage &I, const std::vec return true; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tools/geometry/vpRect.cpp b/modules/core/src/tools/geometry/vpRect.cpp index 6bbe4c053e..c5ffec712c 100644 --- a/modules/core/src/tools/geometry/vpRect.cpp +++ b/modules/core/src/tools/geometry/vpRect.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -255,6 +255,9 @@ bool vpRect::operator!=(const vpRect &r) const */ return !(*this == r); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /*! Check if an image point belongs to a rectangle. @@ -264,17 +267,14 @@ bool vpRect::operator!=(const vpRect &r) const \return Returns true if the point belongs to the rectangle. */ -VISP_EXPORT bool inRectangle(const vpImagePoint &ip, const vpRect &rect) +VISP_EXPORT bool inRectangle(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip, const VISP_NAMESPACE_ADDRESSING vpRect &rect) { return ((ip.get_i() <= rect.getBottom()) && (ip.get_i() >= rect.getTop()) && (ip.get_j() <= rect.getRight()) && (ip.get_j() >= rect.getLeft())); } -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRect &r) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRect &r) { os << r.getLeft() << ", " << r.getTop() << ", " << r.getWidth() << ", " << r.getHeight(); return os; } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif diff --git a/modules/core/src/tools/geometry/vpRectOriented.cpp b/modules/core/src/tools/geometry/vpRectOriented.cpp index fff4d2ca29..efddfc12a2 100644 --- a/modules/core/src/tools/geometry/vpRectOriented.cpp +++ b/modules/core/src/tools/geometry/vpRectOriented.cpp @@ -37,7 +37,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /// Default constructor. diff --git a/modules/core/src/tools/geometry/vpTriangle.cpp b/modules/core/src/tools/geometry/vpTriangle.cpp index ff820314c0..ea0560e0bd 100644 --- a/modules/core/src/tools/geometry/vpTriangle.cpp +++ b/modules/core/src/tools/geometry/vpTriangle.cpp @@ -36,6 +36,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. @@ -189,3 +193,6 @@ bool vpTriangle::inTriangle(const vpImagePoint &iP, double threshold) return (p_ds_uv0 + p_ds_uv1 < 1. + threshold && p_ds_uv0 > -threshold && p_ds_uv1 > -threshold); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp b/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp index ce0445330e..c07faeb9ac 100644 --- a/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp +++ b/modules/core/src/tools/geometry/vpXmlParserRectOriented.cpp @@ -51,7 +51,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/src/tools/histogram/vpHistogram.cpp b/modules/core/src/tools/histogram/vpHistogram.cpp index 4c793a6b95..02e9e42086 100644 --- a/modules/core/src/tools/histogram/vpHistogram.cpp +++ b/modules/core/src/tools/histogram/vpHistogram.cpp @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #if defined(VISP_HAVE_THREADS) diff --git a/modules/core/src/tools/histogram/vpHistogramPeak.cpp b/modules/core/src/tools/histogram/vpHistogramPeak.cpp index ce74255e0a..cb8416900e 100644 --- a/modules/core/src/tools/histogram/vpHistogramPeak.cpp +++ b/modules/core/src/tools/histogram/vpHistogramPeak.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -88,21 +88,21 @@ vpHistogramPeak &vpHistogramPeak::operator=(const vpHistogramPeak &p) */ bool vpHistogramPeak::operator==(const vpHistogramPeak &p) const { return ((level == p.level) && (value == p.value)); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /*! \relates vpHistogramPeak \brief std::cout a peak */ -VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramPeak &p) +VISP_EXPORT std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramPeak &p) { s << static_cast(p.getLevel()) << " " << p.getValue(); return s; } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/core/src/tools/histogram/vpHistogramValey.cpp b/modules/core/src/tools/histogram/vpHistogramValey.cpp index e980cd4b94..25d8458ef2 100644 --- a/modules/core/src/tools/histogram/vpHistogramValey.cpp +++ b/modules/core/src/tools/histogram/vpHistogramValey.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -77,20 +77,22 @@ bool vpHistogramValey::operator==(const vpHistogramValey &v) const return ((level == v.level) && (value == v.value)); } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! \relates vpHistogramValey \brief std::cout a valey */ -VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramValey &v) +VISP_EXPORT std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramValey &v) { s << static_cast(v.getLevel()) << " " << v.getValue(); return s; } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif + /* * Local variables: * c-basic-offset: 2 diff --git a/modules/core/src/tools/network/vpClient.cpp b/modules/core/src/tools/network/vpClient.cpp index 19d0994c8e..10c8331f1d 100644 --- a/modules/core/src/tools/network/vpClient.cpp +++ b/modules/core/src/tools/network/vpClient.cpp @@ -40,7 +40,10 @@ // inet_ntop() not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpClient::vpClient() : vpNetwork(), m_numberOfAttempts(0) { } /*! @@ -94,18 +97,18 @@ bool vpClient::connectToHostname(const std::string &hostname, const unsigned int serv.receptorIP = inet_ntoa(*(in_addr *)server->h_addr); return connectServer(serv); - } +} - /*! - Connect to the server represented by the given ip, and at a given port. +/*! + Connect to the server represented by the given ip, and at a given port. - \sa vpClient::connectToHostname() + \sa vpClient::connectToHostname() - \param ip : IP of the server. - \param port_serv : Port used for the connection. + \param ip : IP of the server. + \param port_serv : Port used for the connection. - \return True if the connection has been etablished, false otherwise. - */ + \return True if the connection has been etablished, false otherwise. +*/ bool vpClient::connectToIP(const std::string &ip, const unsigned int &port_serv) { vpNetwork::vpReceptor serv; @@ -127,13 +130,13 @@ bool vpClient::connectToIP(const std::string &ip, const unsigned int &port_serv) serv.receptorAddress.sin_port = htons((unsigned short)port_serv); return connectServer(serv); - } +} - /*! - Deconnect from the server at a specific index. +/*! + Deconnect from the server at a specific index. - \param index : Index of the server. - */ + \param index : Index of the server. +*/ void vpClient::deconnect(const unsigned int &index) { if (index < receptor_list.size()) { @@ -214,7 +217,9 @@ bool vpClient::connectServer(vpNetwork::vpReceptor &serv) std::cout << "Connected!" << std::endl; return true; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpClient.cpp.o) has no symbols void dummy_vpClient() { }; diff --git a/modules/core/src/tools/network/vpNetwork.cpp b/modules/core/src/tools/network/vpNetwork.cpp index 158c5942e3..9e7f80f983 100644 --- a/modules/core/src/tools/network/vpNetwork.cpp +++ b/modules/core/src/tools/network/vpNetwork.cpp @@ -40,7 +40,10 @@ // inet_ntop() not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpNetwork::vpNetwork() : emitter(), receptor_list(), readFileDescriptor(), socketMax(0), request_list(), max_size_message(999999), separator("[*@*]"), beginning("[*start*]"), end("[*end*]"), param_sep("[*|*]"), currentMessageReceived(), tv(), @@ -794,7 +797,9 @@ int vpNetwork::privReceiveRequestOnceFrom(const unsigned int &receptorEmitting) return numbytes; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpNetwork.cpp.o) has no symbols void dummy_vpNetwork() { }; diff --git a/modules/core/src/tools/network/vpRequest.cpp b/modules/core/src/tools/network/vpRequest.cpp index bc3fd7b313..c6f6647d78 100644 --- a/modules/core/src/tools/network/vpRequest.cpp +++ b/modules/core/src/tools/network/vpRequest.cpp @@ -38,6 +38,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpRequest::vpRequest() : request_id(""), listOfParams() { } vpRequest::~vpRequest() { } @@ -78,3 +82,6 @@ void vpRequest::addParameter(const std::vector &listOfparams) this->listOfParams.push_back(listOfparams[i]); } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tools/network/vpServer.cpp b/modules/core/src/tools/network/vpServer.cpp index 80d68105ca..7ec67ba44b 100644 --- a/modules/core/src/tools/network/vpServer.cpp +++ b/modules/core/src/tools/network/vpServer.cpp @@ -44,6 +44,10 @@ #include // To detect OSX or IOS using TARGET_OS_IPHONE or TARGET_OS_IOS macro #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Construct a server on the machine launching it. */ @@ -174,7 +178,8 @@ bool vpServer::start() int set_option = 1; if (0 == setsockopt(emitter.socketFileDescriptorEmitter, SOL_SOCKET, SO_NOSIGPIPE, &set_option, sizeof(set_option))) { - } else { + } + else { std::cout << "Failed to set socket signal option" << std::endl; } } @@ -232,9 +237,11 @@ bool vpServer::checkForConnections() if (value == -1) { // vpERROR_TRACE( "vpServer::run(), select()" ); return false; - } else if (value == 0) { + } + else if (value == 0) { return false; - } else { + } + else { if (FD_ISSET((unsigned int)emitter.socketFileDescriptorEmitter, &readFileDescriptor)) { vpNetwork::vpReceptor client; client.receptorAddressSize = sizeof(client.receptorAddress); @@ -243,8 +250,8 @@ bool vpServer::checkForConnections() emitter.socketFileDescriptorEmitter, (struct sockaddr *)&client.receptorAddress, &client.receptorAddressSize); #else // Win32 client.socketFileDescriptorReceptor = - accept((unsigned int)emitter.socketFileDescriptorEmitter, (struct sockaddr *)&client.receptorAddress, - &client.receptorAddressSize); + accept((unsigned int)emitter.socketFileDescriptorEmitter, (struct sockaddr *)&client.receptorAddress, + &client.receptorAddressSize); #endif #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX @@ -259,7 +266,8 @@ bool vpServer::checkForConnections() receptor_list.push_back(client); return true; - } else { + } + else { for (unsigned int i = 0; i < receptor_list.size(); i++) { if (FD_ISSET((unsigned int)receptor_list[i].socketFileDescriptorReceptor, &readFileDescriptor)) { char deco; @@ -286,8 +294,10 @@ bool vpServer::checkForConnections() Print the connected clients. */ void vpServer::print() { vpNetwork::print("Client"); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpServer.cpp.o) has no symbols -void dummy_vpServer(){}; +void dummy_vpServer() { }; #endif diff --git a/modules/core/src/tools/network/vpUDPClient.cpp b/modules/core/src/tools/network/vpUDPClient.cpp index eba00e84f4..804099e118 100644 --- a/modules/core/src/tools/network/vpUDPClient.cpp +++ b/modules/core/src/tools/network/vpUDPClient.cpp @@ -58,6 +58,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. @@ -66,11 +70,10 @@ vpUDPClient::vpUDPClient() : m_is_init(false), m_serverAddress(), m_serverLength(0), m_socketFileDescriptor() #if defined(_WIN32) - , - m_wsa() + , + m_wsa() #endif -{ -} +{ } /*! Create a (IPv4) UDP client. @@ -81,8 +84,8 @@ vpUDPClient::vpUDPClient() vpUDPClient::vpUDPClient(const std::string &hostname, int port) : m_is_init(false), m_serverAddress(), m_serverLength(0), m_socketFileDescriptor() #if defined(_WIN32) - , - m_wsa() + , + m_wsa() #endif { init(hostname, port); @@ -345,8 +348,10 @@ int vpUDPClient::send(const void *msg, size_t len) return sendto(m_socketFileDescriptor, (char *)msg, (int)len, 0, (struct sockaddr *)&m_serverAddress, m_serverLength); #endif } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpUDPClient.cpp.o) has no symbols -void dummy_vpUDPClient(){}; +void dummy_vpUDPClient() { }; #endif diff --git a/modules/core/src/tools/network/vpUDPServer.cpp b/modules/core/src/tools/network/vpUDPServer.cpp index 42725f7db3..d17898005d 100644 --- a/modules/core/src/tools/network/vpUDPServer.cpp +++ b/modules/core/src/tools/network/vpUDPServer.cpp @@ -65,6 +65,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Create a (IPv4) UDP server. @@ -74,8 +78,8 @@ vpUDPServer::vpUDPServer(int port) : m_clientAddress(), m_clientLength(0), m_serverAddress(), m_socketFileDescriptor(0) #if defined(_WIN32) - , - m_wsa() + , + m_wsa() #endif { init("", port); @@ -90,8 +94,8 @@ vpUDPServer::vpUDPServer(int port) vpUDPServer::vpUDPServer(const std::string &hostname, int port) : m_clientAddress(), m_clientLength(0), m_serverAddress(), m_socketFileDescriptor(0) #if defined(_WIN32) - , - m_wsa() + , + m_wsa() #endif { init(hostname, port); @@ -145,7 +149,8 @@ void vpUDPServer::init(const std::string &hostname, int port) m_serverAddress.sin_family = AF_INET; m_serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); m_serverAddress.sin_port = htons((unsigned short)port); - } else { + } + else { std::stringstream ss; ss << port; struct addrinfo hints; @@ -234,7 +239,7 @@ int vpUDPServer::receive(std::string &msg, std::string &hostInfo, int timeoutMs) (struct sockaddr *)&m_clientAddress, (socklen_t *)&m_clientLength)); #else int length = - recvfrom(m_socketFileDescriptor, m_buf, sizeof(m_buf), 0, (struct sockaddr *)&m_clientAddress, &m_clientLength); + recvfrom(m_socketFileDescriptor, m_buf, sizeof(m_buf), 0, (struct sockaddr *)&m_clientAddress, &m_clientLength); #endif if (length <= 0) { return length < 0 ? -1 : 0; @@ -251,7 +256,8 @@ int vpUDPServer::receive(std::string &msg, std::string &hostInfo, int timeoutMs) std::string hostName = "", hostIp = "", hostPort = ""; if (dwRetval != 0) { std::cerr << "getnameinfo failed with error: " << WSAGetLastError() << std::endl; - } else { + } + else { hostName = hostname; hostPort = servInfo; } @@ -260,7 +266,8 @@ int vpUDPServer::receive(std::string &msg, std::string &hostInfo, int timeoutMs) const char *ptr = inet_ntop(AF_INET, (void *)&m_clientAddress.sin_addr, result, sizeof(result)); if (ptr == nullptr) { std::cerr << "inet_ntop failed with error: " << WSAGetLastError() << std::endl; - } else { + } + else { hostIp = result; } @@ -330,8 +337,10 @@ int vpUDPServer::send(const std::string &msg, const std::string &hostname, int p m_clientLength); #endif } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpUDPServer.cpp.o) has no symbols -void dummy_vpUDPServer(){}; +void dummy_vpUDPServer() { }; #endif diff --git a/modules/core/src/tools/optimization/vpLinProg.cpp b/modules/core/src/tools/optimization/vpLinProg.cpp index fea24cea8f..b9e9484fe0 100644 --- a/modules/core/src/tools/optimization/vpLinProg.cpp +++ b/modules/core/src/tools/optimization/vpLinProg.cpp @@ -38,6 +38,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Reduces the search space induced by an equality constraint. @@ -727,5 +731,7 @@ bool vpLinProg::simplex(const vpColVector &c, vpMatrix A, vpColVector b, vpColVe std::swap(B[k], N[j]); } } - +#endif +#ifdef ENABLE_VISP_NAMESPACE +} #endif diff --git a/modules/core/src/tools/optimization/vpQuadProg.cpp b/modules/core/src/tools/optimization/vpQuadProg.cpp index fdac7be8f2..a81a1695db 100644 --- a/modules/core/src/tools/optimization/vpQuadProg.cpp +++ b/modules/core/src/tools/optimization/vpQuadProg.cpp @@ -41,7 +41,10 @@ #include #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Changes a canonical quadratic cost \f$\min \frac{1}{2}\mathbf{x}^T\mathbf{H}\mathbf{x} + \mathbf{c}^T\mathbf{x}\f$ to the formulation used by this class \f$ \min ||\mathbf{Q}\mathbf{x} - \mathbf{r}||^2\f$. @@ -678,7 +681,9 @@ vpColVector vpQuadProg::solveSVDorQR(const vpMatrix &A, const vpColVector &b) return A.solveBySVD(b); return A.solveByQR(b); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else void dummy_vpQuadProg() { }; #endif diff --git a/modules/core/src/tools/serial/vpSerial.cpp b/modules/core/src/tools/serial/vpSerial.cpp index a36e5e16f1..6341038842 100644 --- a/modules/core/src/tools/serial/vpSerial.cpp +++ b/modules/core/src/tools/serial/vpSerial.cpp @@ -59,6 +59,10 @@ #endif #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Creates a serial port object that opens the port if the parameter is not empty. \code @@ -97,7 +101,7 @@ int main() vpSerial::vpSerial(const std::string &port, unsigned long baudrate, bytesize_t bytesize, parity_t parity, stopbits_t stopbits, flowcontrol_t flowcontrol) : m_port(port), m_fd(-1), m_is_open(false), m_xonxoff(false), m_rtscts(false), m_baudrate(baudrate), m_parity(parity), - m_bytesize(bytesize), m_stopbits(stopbits), m_flowcontrol(flowcontrol) + m_bytesize(bytesize), m_stopbits(stopbits), m_flowcontrol(flowcontrol) { if (m_port.empty() == false) open(); @@ -168,7 +172,8 @@ int vpSerial::available() int count = 0; if (-1 == ioctl(m_fd, TIOCINQ, &count)) { throw(vpException(vpException::fatalError, "Cannot check is serial port data available")); - } else { + } + else { return count; } } @@ -185,7 +190,8 @@ void vpSerial::close() ret = ::close(m_fd); if (ret == 0) { m_fd = -1; - } else { + } + else { throw(vpException(vpException::fatalError, "Cannot close serial port")); } } @@ -262,7 +268,7 @@ bool vpSerial::read(char *c, long timeout_s) } fd_set readfds; /* list of fds for select to listen to */ - struct timeval timeout = {timeout_s, 0}; // seconde, micro-sec + struct timeval timeout = { timeout_s, 0 }; // seconde, micro-sec FD_ZERO(&readfds); FD_SET(static_cast(m_fd), &readfds); @@ -271,10 +277,12 @@ bool vpSerial::read(char *c, long timeout_s) if (ret < 0) { throw(vpException(vpException::fatalError, "Serial i/o exception")); - } else if (ret == 0) { - // Timeout occurred + } + else if (ret == 0) { + // Timeout occurred return false; - } else { + } + else { ssize_t n = ::read(m_fd, c, 1); // read one character at a time if (n != 1) return false; @@ -337,10 +345,10 @@ void vpSerial::configure() // set up raw mode / no echo / binary options.c_cflag |= (tcflag_t)(CLOCAL | CREAD); - options.c_lflag &= (tcflag_t) ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | IEXTEN); //|ECHOPRT + options.c_lflag &= (tcflag_t)~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | IEXTEN); //|ECHOPRT - options.c_oflag &= (tcflag_t) ~(OPOST); - options.c_iflag &= (tcflag_t) ~(INLCR | IGNCR | ICRNL | IGNBRK); + options.c_oflag &= (tcflag_t)~(OPOST); + options.c_iflag &= (tcflag_t)~(INLCR | IGNCR | ICRNL | IGNBRK); #ifdef IUCLC options.c_iflag &= (tcflag_t)~IUCLC; @@ -541,7 +549,7 @@ void vpSerial::configure() switch (m_stopbits) { case stopbits_one: - options.c_cflag &= (tcflag_t) ~(CSTOPB); + options.c_cflag &= (tcflag_t)~(CSTOPB); break; case stopbits_two: options.c_cflag |= (CSTOPB); @@ -549,13 +557,13 @@ void vpSerial::configure() } // setup parity - options.c_iflag &= (tcflag_t) ~(INPCK | ISTRIP); + options.c_iflag &= (tcflag_t)~(INPCK | ISTRIP); switch (m_parity) { case parity_none: - options.c_cflag &= (tcflag_t) ~(PARENB | PARODD); + options.c_cflag &= (tcflag_t)~(PARENB | PARODD); break; case parity_even: - options.c_cflag &= (tcflag_t) ~(PARODD); + options.c_cflag &= (tcflag_t)~(PARODD); options.c_cflag |= (PARENB); break; case parity_odd: @@ -584,9 +592,9 @@ void vpSerial::configure() options.c_iflag |= (IXON | IXOFF); else #ifdef IXANY - options.c_iflag &= (tcflag_t) ~(IXON | IXOFF | IXANY); + options.c_iflag &= (tcflag_t)~(IXON | IXOFF | IXANY); #else - options.c_iflag &= (tcflag_t) ~(IXON | IXOFF); + options.c_iflag &= (tcflag_t)~(IXON | IXOFF); #endif // rtscts @@ -610,8 +618,10 @@ void vpSerial::configure() // activate settings ::tcsetattr(m_fd, TCSANOW, &options); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpAROgre.cpp.o) has no symbols -void dummy_vpSerial(){}; +void dummy_vpSerial() { }; #endif diff --git a/modules/core/src/tools/time/vpTime.cpp b/modules/core/src/tools/time/vpTime.cpp index be8c492df6..d66dafb815 100644 --- a/modules/core/src/tools/time/vpTime.cpp +++ b/modules/core/src/tools/time/vpTime.cpp @@ -62,7 +62,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/src/tools/xml/vpXmlParser.cpp b/modules/core/src/tools/xml/vpXmlParser.cpp index 56480aee98..38fb55a3ba 100644 --- a/modules/core/src/tools/xml/vpXmlParser.cpp +++ b/modules/core/src/tools/xml/vpXmlParser.cpp @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. @@ -481,7 +485,9 @@ void vpXmlParser::save(const std::string &filename, bool append) xmlSaveFormatFile(filename.c_str(), doc, 1); xmlFreeDoc(doc); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpXmlParser.cpp.o) has no symbols void dummy_vpXmlParser() { }; diff --git a/modules/core/src/tracking/forward-projection/vpCircle.cpp b/modules/core/src/tracking/forward-projection/vpCircle.cpp index e3b3c6805f..b01dace0a2 100644 --- a/modules/core/src/tracking/forward-projection/vpCircle.cpp +++ b/modules/core/src/tracking/forward-projection/vpCircle.cpp @@ -38,7 +38,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif void vpCircle::init() diff --git a/modules/core/src/tracking/forward-projection/vpCylinder.cpp b/modules/core/src/tracking/forward-projection/vpCylinder.cpp index 65b83613f7..1d336ffa95 100644 --- a/modules/core/src/tracking/forward-projection/vpCylinder.cpp +++ b/modules/core/src/tracking/forward-projection/vpCylinder.cpp @@ -36,6 +36,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpCylinder::init() { oP.resize(7); @@ -420,3 +424,6 @@ void vpCylinder::display(const vpImage &I, const vpCameraParameters &cam { vpFeatureDisplay::displayCylinder(p[0], p[1], p[2], p[3], cam, I, color, thickness); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp b/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp index cd9792d3c4..0c306d1b2a 100644 --- a/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp +++ b/modules/core/src/tracking/forward-projection/vpForwardProjection.cpp @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/tracking/forward-projection/vpLine.cpp b/modules/core/src/tracking/forward-projection/vpLine.cpp index b94db57cc5..08b546be8a 100644 --- a/modules/core/src/tracking/forward-projection/vpLine.cpp +++ b/modules/core/src/tracking/forward-projection/vpLine.cpp @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/tracking/forward-projection/vpPoint.cpp b/modules/core/src/tracking/forward-projection/vpPoint.cpp index a630200556..f07a3054c7 100644 --- a/modules/core/src/tracking/forward-projection/vpPoint.cpp +++ b/modules/core/src/tracking/forward-projection/vpPoint.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif void vpPoint::init() @@ -414,8 +414,6 @@ void vpPoint::display(const vpImage &I, const vpHomogeneousMatrix &cMo, vpFeatureDisplay::displayPoint(v_p[0], v_p[1], cam, I, color, thickness); } -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpPoint & /* vpp */) { return (os << "vpPoint"); } - /*! * Display the projection of a 3D point in image \e I. * @@ -513,3 +511,5 @@ void vpPoint::set_w(double w) { p[2] = w; } #if defined(ENABLE_VISP_NAMESPACE) } #endif + +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPoint & /* vpp */) { return (os << "vpPoint"); } diff --git a/modules/core/src/tracking/forward-projection/vpSphere.cpp b/modules/core/src/tracking/forward-projection/vpSphere.cpp index 93185d70b9..9209ed99a7 100644 --- a/modules/core/src/tracking/forward-projection/vpSphere.cpp +++ b/modules/core/src/tracking/forward-projection/vpSphere.cpp @@ -37,7 +37,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/core/src/tracking/moments/vpMoment.cpp b/modules/core/src/tracking/moments/vpMoment.cpp index 121ab5dc81..1da05131eb 100644 --- a/modules/core/src/tracking/moments/vpMoment.cpp +++ b/modules/core/src/tracking/moments/vpMoment.cpp @@ -40,6 +40,24 @@ #include #include #include + +/*! + * Prints the moment contents to a stream + * \param os : a std::stream. + * \param m : a moment instance. + */ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMoment &m) +{ + for (std::vector::const_iterator i = m.values.begin(); i != m.values.end(); ++i) + os << *i << ","; + + return os; +} + +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor */ @@ -107,19 +125,6 @@ void vpMoment::linkTo(vpMomentDatabase &data_base) */ void vpMoment::update(vpMomentObject &moment_object) { this->object = &moment_object; } -/*! - * Prints the moment contents to a stream - * \param os : a std::stream. - * \param m : a moment instance. - */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMoment &m) -{ - for (std::vector::const_iterator i = m.values.begin(); i != m.values.end(); ++i) - os << *i << ","; - - return os; -} - /*! * Prints values of all dependent moments required to calculate a specific * vpMoment. Not made pure to maintain compatibility Recommended : Types @@ -132,3 +137,6 @@ void vpMoment::printDependencies(std::ostream &os) const "the derived classes!" << std::endl; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentAlpha.cpp b/modules/core/src/tracking/moments/vpMomentAlpha.cpp index 19ace725f7..3cf523ca56 100644 --- a/modules/core/src/tracking/moments/vpMomentAlpha.cpp +++ b/modules/core/src/tracking/moments/vpMomentAlpha.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Empty constructor. Initializes alpha moment as a reference alpha with a value in \f$[-\pi/2 ; \pi/2]\f$. A default-constructed alpha moment may be @@ -67,7 +71,7 @@ vpMomentAlpha::vpMomentAlpha() */ vpMomentAlpha::vpMomentAlpha(const std::vector &mu3_ref, double alpha_ref, double threshold) : vpMoment(), m_isRef(false), m_symmetric(true), m_mu3Ref(mu3_ref), m_alphaRef(alpha_ref), - m_symmetricThreshold(threshold) + m_symmetricThreshold(threshold) { for (std::vector::const_iterator it = mu3_ref.begin(); it != mu3_ref.end(); ++it) { if (std::fabs(*it) > m_symmetricThreshold) { @@ -89,7 +93,7 @@ void vpMomentAlpha::compute() bool found_moment_centered; const vpMomentCentered &momentCentered = - (static_cast(getMoments().get("vpMomentCentered", found_moment_centered))); + (static_cast(getMoments().get("vpMomentCentered", found_moment_centered))); if (!found_moment_centered) throw vpException(vpException::notInitialized, "vpMomentCentered not found"); @@ -100,7 +104,8 @@ void vpMomentAlpha::compute() if (m_isRef) { m_alphaRef = alpha; - } else { + } + else { if (!m_symmetric) { double r11 = cos(alpha - m_alphaRef); double r12 = sin(alpha - m_alphaRef); @@ -145,7 +150,8 @@ void vpMomentAlpha::compute() if (signChange) { if (alpha < 0) { alpha += M_PI; - } else { + } + else { alpha -= M_PI; } } @@ -154,16 +160,6 @@ void vpMomentAlpha::compute() values[0] = alpha; } -/*! - Prints the value of the major-axis orientation in degrees and rad - */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAlpha &c) -{ - os << (__FILE__) << std::endl; - os << "Alpha = " << c.values[0] << "rad = " << vpMath::deg(c.values[0]) << "deg " << std::endl; - return os; -} - /*! Prints the dependencies of alpha, namely centered moments mu11, mu20 ad mu02 */ @@ -172,7 +168,7 @@ void vpMomentAlpha::printDependencies(std::ostream &os) const os << (__FILE__) << std::endl; bool found_moment_centered; const vpMomentCentered &momentCentered = - (static_cast(getMoments().get("vpMomentCentered", found_moment_centered))); + (static_cast(getMoments().get("vpMomentCentered", found_moment_centered))); if (!found_moment_centered) throw vpException(vpException::notInitialized, "vpMomentCentered not found"); @@ -180,3 +176,20 @@ void vpMomentAlpha::printDependencies(std::ostream &os) const os << "mu20 = " << momentCentered.get(2, 0) << "\t"; os << "mu02 = " << momentCentered.get(0, 2) << std::endl; } + +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +/*! + Prints the value of the major-axis orientation in degrees and rad + */ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAlpha &c) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + os << (__FILE__) << std::endl; + os << "Alpha = " << c.values[0] << "rad = " << vpMath::deg(c.values[0]) << "deg " << std::endl; + return os; +} diff --git a/modules/core/src/tracking/moments/vpMomentArea.cpp b/modules/core/src/tracking/moments/vpMomentArea.cpp index 4a916f0b8e..da0f65df79 100644 --- a/modules/core/src/tracking/moments/vpMomentArea.cpp +++ b/modules/core/src/tracking/moments/vpMomentArea.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Has the area \f$ a = m_{00} = \mu_{00} \f$ for dense objects, \f$ \mu_{20}+\mu_{02} \f$ for a discrete set of points. @@ -58,11 +62,12 @@ void vpMomentArea::compute() * linked to it */ const vpMomentCentered &momentCentered = - static_cast(getMoments().get("vpMomentCentered", found_moment_centered)); + static_cast(getMoments().get("vpMomentCentered", found_moment_centered)); if (!found_moment_centered) throw vpException(vpException::notInitialized, "vpMomentCentered not found"); values[0] = momentCentered.get(2, 0) + momentCentered.get(0, 2); - } else { + } + else { values[0] = getObject().get(0, 0); } } @@ -72,16 +77,6 @@ void vpMomentArea::compute() */ vpMomentArea::vpMomentArea() : vpMoment() { values.resize(1); } -/*! - Outputs the moment's values to a stream. -*/ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentArea &m) -{ - os << (__FILE__) << std::endl; - os << "a(m00) = " << m.values[0] << std::endl; - return os; -} - /*! If the vpMomentObject type is 1. DISCRETE(set of discrete points), uses mu20+mu02 @@ -93,14 +88,28 @@ void vpMomentArea::printDependencies(std::ostream &os) const bool found_moment_centered; const vpMomentCentered &momentCentered = - static_cast(getMoments().get("vpMomentCentered", found_moment_centered)); + static_cast(getMoments().get("vpMomentCentered", found_moment_centered)); if (!found_moment_centered) throw vpException(vpException::notInitialized, "vpMomentCentered not found"); if (getObject().getType() == vpMomentObject::DISCRETE) { os << "mu20 = " << momentCentered.get(2, 0) << "\t"; os << "mu02 = " << momentCentered.get(0, 2) << std::endl; - } else { + } + else { os << "mu00 = " << momentCentered.get(0, 0) << std::endl; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +/*! + Outputs the moment's values to a stream. +*/ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentArea &m) +{ + os << (__FILE__) << std::endl; + os << "a(m00) = " << m.values[0] << std::endl; + return os; +} diff --git a/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp b/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp index e81999de34..841f65b0d9 100644 --- a/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp +++ b/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp @@ -41,6 +41,11 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! Computes the normalized area \f$ a_n=Z^* \sqrt{\frac{a^*}{a}} \f$. Depends on vpMomentCentered. @@ -82,16 +87,6 @@ vpMomentAreaNormalized::vpMomentAreaNormalized(double a_star, double Z_star) values.resize(1); } -/*! - Outputs the moment's values to a stream. -*/ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAreaNormalized &m) -{ - os << (__FILE__) << std::endl; - os << "An = " << m.values[0] << std::endl; - return os; -} - /*! Prints dependencies namely, 1. Depth at desired pose Z* @@ -119,3 +114,17 @@ void vpMomentAreaNormalized::printDependencies(std::ostream &os) const a = getObject().get(0, 0); os << "a = " << a << std::endl; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + + +/*! + Outputs the moment's values to a stream. +*/ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAreaNormalized &m) +{ + os << (__FILE__) << std::endl; + os << "An = " << m.values[0] << std::endl; + return os; +} diff --git a/modules/core/src/tracking/moments/vpMomentBasic.cpp b/modules/core/src/tracking/moments/vpMomentBasic.cpp index 336c731871..8dbbd6269b 100644 --- a/modules/core/src/tracking/moments/vpMomentBasic.cpp +++ b/modules/core/src/tracking/moments/vpMomentBasic.cpp @@ -38,10 +38,15 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. */ -vpMomentBasic::vpMomentBasic() : vpMoment() {} +vpMomentBasic::vpMomentBasic() : vpMoment() { } /*! Retrieve all moments of all orders computed. vpMomentBasic::get()[j*order+i] @@ -64,28 +69,34 @@ double vpMomentBasic::get(unsigned int i, unsigned int j) const { return getObje /*! Dummy function. Everything is already done in object. */ -void vpMomentBasic::compute() {} +void vpMomentBasic::compute() { } /*! - Outputs the moment's values to a stream. - Same output as in vpMomentObject. +No dependencies on other vpMoments, since basic moments are computed in +vpMomentObject Just prints the basic moments in vpMomentObject with indices */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentBasic &m) +void vpMomentBasic::printDependencies(std::ostream &os) const { os << (__FILE__) << std::endl; - vpMomentObject::printWithIndices(m.getObject(), os); - return os; + os << "No dependencies on other vpMoments, since basic moments are " + "computed in vpMomentObject" + << std::endl; + vpMomentObject::printWithIndices(getObject(), os); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /*! -No dependencies on other vpMoments, since basic moments are computed in -vpMomentObject Just prints the basic moments in vpMomentObject with indices + Outputs the moment's values to a stream. + Same output as in vpMomentObject. */ -void vpMomentBasic::printDependencies(std::ostream &os) const +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentBasic &m) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif os << (__FILE__) << std::endl; - os << "No dependencies on other vpMoments, since basic moments are " - "computed in vpMomentObject" - << std::endl; - vpMomentObject::printWithIndices(getObject(), os); + vpMomentObject::printWithIndices(m.getObject(), os); + return os; } diff --git a/modules/core/src/tracking/moments/vpMomentCInvariant.cpp b/modules/core/src/tracking/moments/vpMomentCInvariant.cpp index 782c199e3b..b8f663590d 100644 --- a/modules/core/src/tracking/moments/vpMomentCInvariant.cpp +++ b/modules/core/src/tracking/moments/vpMomentCInvariant.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. (option to use a different calculation mode for sx and sy) @@ -122,15 +126,15 @@ void vpMomentCInvariant::computeI(const vpMomentCentered &momentCentered, std::v I_val[4] = (mu30 + mu12) * (mu30 + mu12) + (mu21 + mu03) * (mu21 + mu03); I_val[5] = -mu30_2 * mu03_2 + (-4 * mu12_3 + 6 * mu21 * mu12 * mu03) * mu30 - 4 * mu21_3 * mu03 + 3 * mu21_2 * mu12_2; I_val[6] = 3 * mu12_4 + 2 * mu30 * mu12_3 + (3 * mu30_2 - 6 * mu03 * mu21) * mu12_2 - - 6 * mu30 * mu21 * (mu21 + mu03) * mu12 + 2 * mu30_2 * mu03_2 + 2 * mu21_3 * mu03 + 3 * mu21_2 * mu03_2 + - 3 * mu21_4; + 6 * mu30 * mu21 * (mu21 + mu03) * mu12 + 2 * mu30_2 * mu03_2 + 2 * mu21_3 * mu03 + 3 * mu21_2 * mu03_2 + + 3 * mu21_4; I_val[7] = (3 * mu21 + 2 * mu03) * mu12_3 + 3 * mu30 * (mu03 + 2 * mu21) * mu12_2 - - 3 * mu21 * (mu30 + mu03 + mu21) * (-mu30 + mu03 + mu21) * mu12 + - mu30 * (-mu30_2 * mu03 - 2 * mu21_3 - 3 * mu03 * mu21_2 + mu03_3); - // I_val[8]=3*mu21_4-3*mu21_3*mu03+(3*mu03_2+kappa-6*mu12_2)*mu21_2-mu03*(-15*mu12_2+kappa)*mu21-(-3*mu12_2*mu30+(2*kappa-3*mu03_2)*mu12+kappa*mu30)*mu12; + 3 * mu21 * (mu30 + mu03 + mu21) * (-mu30 + mu03 + mu21) * mu12 + + mu30 * (-mu30_2 * mu03 - 2 * mu21_3 - 3 * mu03 * mu21_2 + mu03_3); +// I_val[8]=3*mu21_4-3*mu21_3*mu03+(3*mu03_2+kappa-6*mu12_2)*mu21_2-mu03*(-15*mu12_2+kappa)*mu21-(-3*mu12_2*mu30+(2*kappa-3*mu03_2)*mu12+kappa*mu30)*mu12; I_val[8] = 3 * mu03 * mu21_3 - 2 * mu03_2 * mu21_2 + mu21_2 * mu30_2 + 3 * mu12_2 * mu03 * mu21 - - mu03 * mu21 * mu30_2 - mu03_3 * mu21 + 3 * mu12_3 * mu30 - 2 * mu12_2 * mu30_2 + mu12_2 * mu03_2 - - mu12 * mu30_3 - mu12 * mu30 * mu03_2 + 3 * mu12 * mu30 * mu21_2 - 6 * mu12 * mu30 * mu03 * mu21; + mu03 * mu21 * mu30_2 - mu03_3 * mu21 + 3 * mu12_3 * mu30 - 2 * mu12_2 * mu30_2 + mu12_2 * mu03_2 - + mu12 * mu30_3 - mu12 * mu30 * mu03_2 + 3 * mu12 * mu30 * mu21_2 - 6 * mu12 * mu30 * mu03 * mu21; I_val[9] = omicron * omicron; I_val[10] = mu40 * mu04 - 4 * mu31 * mu13 + 3 * mu22_2; @@ -169,7 +173,7 @@ void vpMomentCInvariant::computeI(const vpMomentCentered &momentCentered, std::v double p02 = momentCentered.get(0, 2) / II[3]; double d = - sqrt(std::fabs(a)) / (II[3] * sqrt(std::fabs(II[3]))); // d is the normalization factor for 3rd order moments + sqrt(std::fabs(a)) / (II[3] * sqrt(std::fabs(II[3]))); // d is the normalization factor for 3rd order moments double p30 = momentCentered.get(3, 0) * d; double p21 = momentCentered.get(2, 1) * d; double p12 = momentCentered.get(1, 2) * d; @@ -199,7 +203,7 @@ void vpMomentCInvariant::compute() "Specify at least order 5."); bool found_moment_centered; const vpMomentCentered &momentCentered = - (static_cast(getMoments().get("vpMomentCentered", found_moment_centered))); + (static_cast(getMoments().get("vpMomentCentered", found_moment_centered))); if (!found_moment_centered) throw vpException(vpException::notInitialized, "vpMomentCentered not found"); @@ -281,11 +285,14 @@ void vpMomentCInvariant::printInvariants(std::ostream &os) const } os << std::endl; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /*! Outputs the moment's values to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCInvariant &c) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCInvariant &c) { for (unsigned int i = 0; i < c.values.size(); i++) { os << c.values[i] << "," << std::endl; diff --git a/modules/core/src/tracking/moments/vpMomentCentered.cpp b/modules/core/src/tracking/moments/vpMomentCentered.cpp index 5ea7600b3a..eb9da481b7 100644 --- a/modules/core/src/tracking/moments/vpMomentCentered.cpp +++ b/modules/core/src/tracking/moments/vpMomentCentered.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! To set the values of centred moments. Required when normalizing the moment values. @@ -68,7 +72,7 @@ void vpMomentCentered::compute() values.resize((getObject().getOrder() + 1) * (getObject().getOrder() + 1)); const vpMomentGravityCenter &momentGravity = - static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); + static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); if (!found_moment_gravity) throw vpException(vpException::notInitialized, "vpMomentGravityCenter not found"); @@ -92,7 +96,7 @@ void vpMomentCentered::compute() /*! Default constructor. */ -vpMomentCentered::vpMomentCentered() : vpMoment() {} +vpMomentCentered::vpMomentCentered() : vpMoment() { } /*! Gets the desired moment using indexes. @@ -112,42 +116,6 @@ double vpMomentCentered::get(unsigned int i, unsigned int j) const return values[j * (order + 1) + i]; } -/*! - Outputs the centered moment's values \f$\mu_{ij}\f$ to a stream presented as -a matrix. The first line corresponds to \f$\mu_{0[0:order]}\f$, the second one -to \f$\mu_{1[0:order]}\f$ Values in table corresponding to a higher order are -marked with an "x" and not computed. - - For example, if the maximal order is 3, the following values are provided: - - \code -u00 u10 u20 u30 -u01 u11 u21 x -u02 u12 x x -u30 x x x - \endcode - - This output will be followed by an output with indexes as produced by -printWithIndices() function -*/ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCentered &m) -{ - for (unsigned int i = 0; i < m.values.size(); i++) { - if (i % (m.getObject().getOrder() + 1) == 0) - os << std::endl; - - if ((i % (m.getObject().getOrder() + 1) + i / (m.getObject().getOrder() + 1)) < m.getObject().getOrder() + 1) - os << m.values[i]; - else - os << "x"; - - os << "\t"; - } - os << std::endl; - m.printWithIndices(os); - return os; -} - /*! Print in a readable form which looks better than output from << operator */ @@ -183,9 +151,48 @@ void vpMomentCentered::printDependencies(std::ostream &os) const */ bool found_moment_gravity; const vpMomentGravityCenter &momentGravity = - static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); + static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); if (!found_moment_gravity) throw vpException(vpException::notInitialized, "vpMomentGravityCenter not found"); os << "Xg = " << momentGravity.getXg() << "\t" - << "Yg = " << momentGravity.getYg() << std::endl; + << "Yg = " << momentGravity.getYg() << std::endl; +} +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +/*! + Outputs the centered moment's values \f$\mu_{ij}\f$ to a stream presented as +a matrix. The first line corresponds to \f$\mu_{0[0:order]}\f$, the second one +to \f$\mu_{1[0:order]}\f$ Values in table corresponding to a higher order are +marked with an "x" and not computed. + + For example, if the maximal order is 3, the following values are provided: + + \code +u00 u10 u20 u30 +u01 u11 u21 x +u02 u12 x x +u30 x x x + \endcode + + This output will be followed by an output with indexes as produced by +printWithIndices() function +*/ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCentered &m) +{ + for (unsigned int i = 0; i < m.values.size(); i++) { + if (i % (m.getObject().getOrder() + 1) == 0) + os << std::endl; + + if ((i % (m.getObject().getOrder() + 1) + i / (m.getObject().getOrder() + 1)) < m.getObject().getOrder() + 1) + os << m.values[i]; + else + os << "x"; + + os << "\t"; + } + os << std::endl; + m.printWithIndices(os); + return os; } diff --git a/modules/core/src/tracking/moments/vpMomentCommon.cpp b/modules/core/src/tracking/moments/vpMomentCommon.cpp index e890a0fb77..fd92af8e29 100644 --- a/modules/core/src/tracking/moments/vpMomentCommon.cpp +++ b/modules/core/src/tracking/moments/vpMomentCommon.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. Initializes the common database with the following moments: basic, gravity,centered,centered+normalized,normalized @@ -227,3 +231,6 @@ vpMomentCommon::~vpMomentCommon() if (momentCInvariant) delete momentCInvariant; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentDatabase.cpp b/modules/core/src/tracking/moments/vpMomentDatabase.cpp index aab0306600..12642ec3c3 100644 --- a/modules/core/src/tracking/moments/vpMomentDatabase.cpp +++ b/modules/core/src/tracking/moments/vpMomentDatabase.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Adds a moment to the database. * \param moment : Moment to add. @@ -86,12 +90,18 @@ void vpMomentDatabase::updateAll(vpMomentObject &object) (*itr).second->update(object); } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /*! * Outputs all the moments values in the database to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentDatabase &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentDatabase &m) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::map::const_iterator itr; os << "{"; diff --git a/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp b/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp index ee6307fcdc..1a79e04218 100644 --- a/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp +++ b/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp @@ -38,6 +38,11 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Computes the two gravity center coordinates commonly called \f$x_g\f$ and \f$y_g\f$. @@ -59,16 +64,6 @@ vpMomentGravityCenter::vpMomentGravityCenter() : vpMoment() { values.resize(2); */ const std::vector &vpMomentGravityCenter::get() const { return values; } -/*! - Outputs the moment's values to a stream. -*/ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenter &m) -{ - os << (__FILE__) << std::endl; - os << "(Xg,Yg) = (" << m.values[0] << ", " << m.values[1] << ")" << std::endl; - return os; -} - /*! Prints its dependencies Basic moments m10, m01 and m00 from vpMomentObject @@ -80,3 +75,16 @@ void vpMomentGravityCenter::printDependencies(std::ostream &os) const os << "m00 = " << getObject().get(0, 1) << "\t"; os << "m00 = " << getObject().get(0, 0) << std::endl; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +/*! + Outputs the moment's values to a stream. +*/ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenter &m) +{ + os << (__FILE__) << std::endl; + os << "(Xg,Yg) = (" << m.values[0] << ", " << m.values[1] << ")" << std::endl; + return os; +} diff --git a/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp b/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp index c9efb735d7..8476cc5bf7 100644 --- a/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp +++ b/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Computes normalized gravity center moment. Depends on vpMomentAreaNormalized and on vpMomentGravityCenter. @@ -54,7 +58,7 @@ void vpMomentGravityCenterNormalized::compute() const vpMomentAreaNormalized &momentSurfaceNormalized = static_cast( getMoments().get("vpMomentAreaNormalized", found_moment_surface_normalized)); const vpMomentGravityCenter &momentGravity = - static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); + static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); if (!found_moment_surface_normalized) throw vpException(vpException::notInitialized, "vpMomentAreaNormalized not found"); @@ -71,17 +75,7 @@ void vpMomentGravityCenterNormalized::compute() /*! Default constructor. */ -vpMomentGravityCenterNormalized::vpMomentGravityCenterNormalized() : vpMomentGravityCenter() {} - -/*! - Outputs the moment's values to a stream. -*/ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenterNormalized &m) -{ - os << (__FILE__) << std::endl; - os << "(Xn,Yn) = (" << m.values[0] << ", " << m.values[1] << ")" << std::endl; - return os; -} +vpMomentGravityCenterNormalized::vpMomentGravityCenterNormalized() : vpMomentGravityCenter() { } /*! Prints the dependent moments, @@ -97,13 +91,26 @@ void vpMomentGravityCenterNormalized::printDependencies(std::ostream &os) const const vpMomentAreaNormalized &momentSurfaceNormalized = static_cast( getMoments().get("vpMomentAreaNormalized", found_moment_surface_normalized)); const vpMomentGravityCenter &momentGravity = - static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); + static_cast(getMoments().get("vpMomentGravityCenter", found_moment_gravity)); if (!found_moment_surface_normalized) throw vpException(vpException::notInitialized, "vpMomentAreaNormalized not found"); if (!found_moment_gravity) throw vpException(vpException::notInitialized, "vpMomentGravityCenter not found"); os << "Xg = " << momentGravity.get()[0] << "\t" - << "Yg = " << momentGravity.get()[1] << std::endl; + << "Yg = " << momentGravity.get()[1] << std::endl; os << "An = " << momentSurfaceNormalized.get()[0] << std::endl; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +/*! + Outputs the moment's values to a stream. +*/ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenterNormalized &m) +{ + os << (__FILE__) << std::endl; + os << "(Xn,Yn) = (" << m.values[0] << ", " << m.values[1] << ")" << std::endl; + return os; +} diff --git a/modules/core/src/tracking/moments/vpMomentObject.cpp b/modules/core/src/tracking/moments/vpMomentObject.cpp index d206132df8..f092d76f55 100644 --- a/modules/core/src/tracking/moments/vpMomentObject.cpp +++ b/modules/core/src/tracking/moments/vpMomentObject.cpp @@ -51,6 +51,10 @@ #endif #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Computes moments from a vector of points describing a polygon (\cite Steger96). The points must be stored in a clockwise order. Used internally. @@ -236,7 +240,8 @@ void vpMomentObject::fromVector(std::vector &points) for (unsigned int j = 0; j < order * order; j++) { values[j] = calc_mom_polygon(j % order, j / order, points); } - } else { + } + else { std::vector cache(order * order, 0.); values.assign(order * order, 0); for (unsigned int i = 0; i < points.size(); i++) { @@ -415,8 +420,9 @@ void vpMomentObject::fromImage(const vpImage &image, const vpCame } } } - } else { - /////////// BLACK BACKGROUND /////////// + } + else { + /////////// BLACK BACKGROUND /////////// for (unsigned int j = 0; j < image.getRows(); j++) { for (unsigned int i = 0; i < image.getCols(); i++) { x = 0; @@ -559,39 +565,6 @@ void vpMomentObject::set(unsigned int i, unsigned int j, const double &value_ij) values[j * order + i] = value_ij; } -/*! - Outputs the basic moment's values \f$m_{ij}\f$ to a stream presented as a - matrix. The first line corresponds to \f$m_{0[0:order]}\f$, the second one - to \f$m_{1[0:order]}\f$ Values in table corresponding to a higher order are - marked with an "x" and not computed. - - For example, if the maximal order is 3, the following values are provided: - - \code - m00 m10 m20 m30 - m01 m11 m21 x - m02 m12 x x - m03 x x x - \endcode -*/ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentObject &m) -{ - for (unsigned int i = 0; i < m.values.size(); i++) { - - if (i % (m.order) == 0) - os << std::endl; - - if ((i % (m.order) + i / (m.order)) < m.order) - os << m.values[i]; - else - os << "x"; - - os << "\t"; - } - - return os; -} - /*! Outputs the raw moment values \f$m_{ij}\f$ in indexed form. The moment values are same as provided by the operator << which outputs x @@ -662,3 +635,41 @@ vpMomentObject::~vpMomentObject() { // deliberate empty } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +/*! + Outputs the basic moment's values \f$m_{ij}\f$ to a stream presented as a + matrix. The first line corresponds to \f$m_{0[0:order]}\f$, the second one + to \f$m_{1[0:order]}\f$ Values in table corresponding to a higher order are + marked with an "x" and not computed. + + For example, if the maximal order is 3, the following values are provided: + + \code + m00 m10 m20 m30 + m01 m11 m21 x + m02 m12 x x + m03 x x x + \endcode +*/ +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentObject &m) +{ + for (unsigned int i = 0; i < m.values.size(); ++i) { + + if (i % (m.order) == 0) + os << std::endl; + + if ((i % (m.order) + i / (m.order)) < m.order) { + os << m.values[i]; + } + else { + os << "x"; + } + + os << "\t"; + } + + return os; +} diff --git a/modules/core/src/tracking/vpTracker.cpp b/modules/core/src/tracking/vpTracker.cpp index 9562d74b8c..70bc574837 100644 --- a/modules/core/src/tracking/vpTracker.cpp +++ b/modules/core/src/tracking/vpTracker.cpp @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif From 9edcb333ef08742945acf353655a721cd99df182 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Wed, 22 May 2024 16:43:33 +0200 Subject: [PATCH 06/64] [TEST] In visp_core, use 'using namespace VISP_NAMESPACE_NAME;' in the tests --- .../camera/testCameraParametersConversion.cpp | 50 ++-- modules/core/test/camera/testJsonCamera.cpp | 4 + .../core/test/camera/testXmlParserCamera.cpp | 3 + .../core/test/image-with-dataset/common.hpp | 3 + .../perfColorConversion.cpp | 3 + .../image-with-dataset/perfGaussianFilter.cpp | 3 + .../image-with-dataset/perfImageAddSub.cpp | 11 +- .../perfImageMorphology.cpp | 5 +- .../image-with-dataset/perfImageResize.cpp | 3 + .../test/image-with-dataset/perfImageWarp.cpp | 11 +- .../testColorConversion.cpp | 4 + .../image-with-dataset/testConversion.cpp | 4 + .../core/test/image-with-dataset/testCrop.cpp | 22 +- .../image-with-dataset/testCropAdvanced.cpp | 20 +- .../image-with-dataset/testGaussianFilter.cpp | 4 + .../image-with-dataset/testImageAddSub.cpp | 4 + .../testImageComparison.cpp | 25 +- .../image-with-dataset/testImageFilter.cpp | 4 + .../testImageNormalizedCorrelation.cpp | 19 +- .../testImageTemplateMatching.cpp | 268 +++++++++--------- .../test/image-with-dataset/testImageWarp.cpp | 4 + .../test/image-with-dataset/testIoEXR.cpp | 4 + .../test/image-with-dataset/testIoPFM.cpp | 24 +- .../test/image-with-dataset/testIoPGM.cpp | 28 +- .../test/image-with-dataset/testIoPPM.cpp | 34 ++- .../image-with-dataset/testPerformanceLUT.cpp | 4 + .../test/image-with-dataset/testReadImage.cpp | 16 +- .../image-with-dataset/testUndistortImage.cpp | 4 + modules/core/test/image/common.hpp | 3 + modules/core/test/image/testImageBinarise.cpp | 9 +- .../core/test/image/testImageDifference.cpp | 8 +- modules/core/test/image/testImageDraw.cpp | 3 + modules/core/test/image/testImageGetValue.cpp | 4 + .../core/test/image/testImageMeanAndStdev.cpp | 3 + .../core/test/image/testImageMorphology.cpp | 3 + .../core/test/image/testImageOwnership.cpp | 3 + modules/core/test/image/testImagePoint.cpp | 15 +- modules/core/test/image/testImagePrint.cpp | 3 + modules/core/test/image/testImageResize.cpp | 31 +- .../test/math/perfColVectorOperations.cpp | 4 + .../test/math/perfMatrixMultiplication.cpp | 60 ++-- .../core/test/math/perfMatrixTranspose.cpp | 19 +- modules/core/test/math/testArray2D.cpp | 4 + modules/core/test/math/testColVector.cpp | 4 + .../core/test/math/testEigenConversion.cpp | 16 +- .../core/test/math/testHomogeneousMatrix.cpp | 4 + .../test/math/testJsonArrayConversion.cpp | 4 + .../core/test/math/testKalmanAcceleration.cpp | 7 +- modules/core/test/math/testKalmanVelocity.cpp | 9 +- modules/core/test/math/testLineFitting.cpp | 6 +- modules/core/test/math/testMath.cpp | 3 + modules/core/test/math/testMathUtils.cpp | 8 +- modules/core/test/math/testMatrix.cpp | 4 + modules/core/test/math/testMatrixCholesky.cpp | 3 + .../test/math/testMatrixConditionNumber.cpp | 19 +- .../core/test/math/testMatrixConvolution.cpp | 35 ++- .../core/test/math/testMatrixDeterminant.cpp | 28 +- .../core/test/math/testMatrixException.cpp | 9 +- .../test/math/testMatrixInitialization.cpp | 4 + modules/core/test/math/testMatrixInverse.cpp | 52 ++-- .../test/math/testMatrixPseudoInverse.cpp | 4 + modules/core/test/math/testMomentAlpha.cpp | 11 +- modules/core/test/math/testPoseVector.cpp | 22 +- modules/core/test/math/testQuaternion.cpp | 4 + modules/core/test/math/testRand.cpp | 11 +- modules/core/test/math/testRobust.cpp | 13 +- modules/core/test/math/testRotation.cpp | 4 + modules/core/test/math/testRowVector.cpp | 4 + modules/core/test/math/testSPC.cpp | 4 + modules/core/test/math/testSvd.cpp | 8 +- .../core/test/math/testTranslationVector.cpp | 4 + modules/core/test/math/testTwistMatrix.cpp | 6 +- .../math/testXmlParserHomogeneousMatrix.cpp | 3 + modules/core/test/munkres/testMunkres.cpp | 6 +- modules/core/test/network/testClient.cpp | 8 +- modules/core/test/network/testServer.cpp | 8 +- modules/core/test/network/testUDPClient.cpp | 22 +- modules/core/test/network/testUDPServer.cpp | 25 +- .../core/test/tools/convert/testConvert.cpp | 4 + .../tools/cpu-features/testCPUFeatures.cpp | 9 +- modules/core/test/tools/endian/testEndian.cpp | 6 +- .../test/tools/geometry/testImageCircle.cpp | 3 + .../core/test/tools/geometry/testPolygon.cpp | 6 + .../core/test/tools/geometry/testPolygon2.cpp | 4 + modules/core/test/tools/geometry/testRect.cpp | 3 + .../geometry/testXmlParserRectOriented.cpp | 3 + .../histogram-with-dataset/testHistogram.cpp | 4 + .../tools/io-with-dataset/testIoTools.cpp | 211 ++++++++------ .../test/tools/io/testBuildInformation.cpp | 3 + modules/core/test/tools/io/testNPZ.cpp | 4 + .../core/test/tools/serial/testSerialRead.cpp | 8 +- .../test/tools/serial/testSerialWrite.cpp | 6 +- modules/core/test/tools/time/testTime.cpp | 6 +- modules/core/test/tools/xml/testXmlParser.cpp | 4 + 94 files changed, 937 insertions(+), 489 deletions(-) diff --git a/modules/core/test/camera/testCameraParametersConversion.cpp b/modules/core/test/camera/testCameraParametersConversion.cpp index 7c8f691715..ce807c3b93 100644 --- a/modules/core/test/camera/testCameraParametersConversion.cpp +++ b/modules/core/test/camera/testCameraParametersConversion.cpp @@ -51,6 +51,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { { std::cout << "* Test operator=()" << std::endl; @@ -103,8 +106,8 @@ int main() vpMeterPixelConversion::convertPoint(cam, x1, y1, u2, v2); if (!vpMath::equal(u1, u2) || !vpMath::equal(v1, v2)) { std::cerr << "Error in point conversion without distortion:\n" - << "u1 = " << u1 << ", u2 = " << u2 << std::endl - << "v1 = " << v1 << ", v2 = " << v2 << std::endl; + << "u1 = " << u1 << ", u2 = " << u2 << std::endl + << "v1 = " << v1 << ", v2 = " << v2 << std::endl; return EXIT_FAILURE; } @@ -113,8 +116,8 @@ int main() vpMeterPixelConversion::convertPoint(camDist, x1, y1, u2, v2); if (!vpMath::equal(u1, u2) || !vpMath::equal(v1, v2)) { std::cerr << "Error in point conversion without distortion:\n" - << "u1 = " << u1 << ", u2 = " << u2 << std::endl - << "v1 = " << v1 << ", v2 = " << v2 << std::endl; + << "u1 = " << u1 << ", u2 = " << u2 << std::endl + << "v1 = " << v1 << ", v2 = " << v2 << std::endl; return EXIT_FAILURE; } @@ -129,7 +132,7 @@ int main() vpPixelMeterConversion::convertPoint(cameraMatrix, distCoeffs, u1, v1, x2, y2); if (!vpMath::equal(x1, x2, 1e-6) || !vpMath::equal(y1, y2, 1e-6)) { std::cerr << "Error in point pixel meter conversion: visp result (" << x1 << ", " << y1 << ") " - << "differ from OpenCV result (" << x2 << ", " << y2 << ")" << std::endl; + << "differ from OpenCV result (" << x2 << ", " << y2 << ")" << std::endl; return EXIT_FAILURE; } @@ -138,7 +141,7 @@ int main() vpPixelMeterConversion::convertPoint(cameraMatrix, distCoeffs, ip, x2, y2); if (!vpMath::equal(x1, x2, 1e-6) || !vpMath::equal(y1, y2, 1e-6)) { std::cerr << "Error in point pixel meter conversion: visp result (" << x1 << ", " << y1 << ") " - << "differ from OpenCV result (" << x2 << ", " << y2 << ")" << std::endl; + << "differ from OpenCV result (" << x2 << ", " << y2 << ")" << std::endl; return EXIT_FAILURE; } @@ -147,7 +150,7 @@ int main() vpMeterPixelConversion::convertPoint(cameraMatrix, distCoeffs, x1, y1, u2, v2); if (!vpMath::equal(u1, u2, 1e-6) || !vpMath::equal(v1, v2, 1e-6)) { std::cerr << "Error in point meter pixel conversion: visp result (" << u1 << ", " << v1 << ") " - << "differ from OpenCV result (" << u2 << ", " << v2 << ")" << std::endl; + << "differ from OpenCV result (" << u2 << ", " << v2 << ")" << std::endl; return EXIT_FAILURE; } @@ -156,7 +159,7 @@ int main() vpMeterPixelConversion::convertPoint(cameraMatrix, distCoeffs, x1, y1, iP2); if (vpImagePoint::distance(iP1, iP2) > 1e-6) { std::cerr << "Error in point meter pixel conversion: visp result (" << u1 << ", " << v1 << ") " - << "differ from OpenCV result (" << u2 << ", " << v2 << ")" << std::endl; + << "differ from OpenCV result (" << u2 << ", " << v2 << ")" << std::endl; return EXIT_FAILURE; } } @@ -172,7 +175,7 @@ int main() vpPixelMeterConversion::convertPoint(cameraMatrix, distCoeffs, u1, v1, x2, y2); if (!vpMath::equal(x1, x2, 1e-6) || !vpMath::equal(y1, y2, 1e-6)) { std::cerr << "Error in point conversion: visp result (" << x1 << ", " << y1 << ") " - << "differ from OpenCV result (" << x2 << ", " << y2 << ")" << std::endl; + << "differ from OpenCV result (" << x2 << ", " << y2 << ")" << std::endl; return EXIT_FAILURE; } @@ -182,7 +185,7 @@ int main() vpMeterPixelConversion::convertPoint(cameraMatrix, distCoeffs, x1, y1, u2, v2); if (!vpMath::equal(u1, u2, 1e-6) || !vpMath::equal(v1, v2, 1e-6)) { std::cerr << "Error in point meter pixel conversion: visp result (" << u1 << ", " << v1 << ") " - << "differ from OpenCV result (" << u2 << ", " << v2 << ")" << std::endl; + << "differ from OpenCV result (" << u2 << ", " << v2 << ")" << std::endl; return EXIT_FAILURE; } } @@ -197,7 +200,7 @@ int main() vpPixelMeterConversion::convertLine(cameraMatrix, rho_p, theta_p, rho_m2, theta_m2); if (!vpMath::equal(rho_m1, rho_m2, 1e-6) || !vpMath::equal(theta_m1, theta_m2, 1e-6)) { std::cerr << "Error in line pixel meter conversion: visp result (" << rho_m1 << ", " << theta_m1 << ") " - << "differ from OpenCV result (" << rho_m2 << ", " << theta_m1 << ")" << std::endl; + << "differ from OpenCV result (" << rho_m2 << ", " << theta_m1 << ")" << std::endl; return EXIT_FAILURE; } @@ -207,7 +210,7 @@ int main() vpMeterPixelConversion::convertLine(cameraMatrix, rho_m1, theta_m1, rho_p2, theta_p2); if (!vpMath::equal(rho_p1, rho_p2, 1e-6) || !vpMath::equal(theta_p1, theta_p2, 1e-6)) { std::cerr << "Error in line meter pixel conversion: visp result (" << rho_p1 << ", " << theta_p1 << ") " - << "differ from OpenCV result (" << rho_p2 << ", " << theta_p1 << ")" << std::endl; + << "differ from OpenCV result (" << rho_p2 << ", " << theta_p1 << ")" << std::endl; return EXIT_FAILURE; } } @@ -234,8 +237,8 @@ int main() for (unsigned int j = 0; j < m1.getCols(); j++) { if (!vpMath::equal(m1[i][j], m1[i][j], 1e-6)) { std::cerr << "Error in moments pixel meter conversion: visp result for [" << i << "][" << j << "] (" - << m1[i][j] << ") " - << "differ from OpenCV result (" << m2[i][j] << ")" << std::endl; + << m1[i][j] << ") " + << "differ from OpenCV result (" << m2[i][j] << ")" << std::endl; return EXIT_FAILURE; } } @@ -244,7 +247,7 @@ int main() { std::cout << "* Compare ViSP and OpenCV ellipse from circle meter pixel conversion without distortion" - << std::endl; + << std::endl; cv::Mat cameraMatrix = (cv::Mat_(3, 3) << px, 0, u0, 0, py, v0, 0, 0, 1); vpCircle circle; circle.setWorldCoordinates(0, 0, 1, 0, 0, 0, 0.1); // plane:(Z=0),X0=0,Y0=0,Z=0,R=0.1 @@ -260,18 +263,18 @@ int main() if (!vpMath::equal(n20_p1, n20_p2, 1e-6) || !vpMath::equal(n11_p1, n11_p2, 1e-6) || !vpMath::equal(n02_p1, n02_p2, 1e-6)) { std::cerr << "Error in ellipse from circle meter pixel conversion: visp result (" << n20_p1 << ", " << n11_p1 - << ", " << n02_p1 << ") " - << "differ from OpenCV result (" << n20_p2 << ", " << n11_p2 << ", " << n02_p2 << ")" << std::endl; + << ", " << n02_p1 << ") " + << "differ from OpenCV result (" << n20_p2 << ", " << n11_p2 << ", " << n02_p2 << ")" << std::endl; return EXIT_FAILURE; } if (vpImagePoint::distance(center_p1, center_p2) > 1e-6) { std::cerr << "Error in ellipse from circle meter pixel conversion: visp result (" << center_p1 << ") " - << "differ from OpenCV result (" << center_p2 << ")" << std::endl; + << "differ from OpenCV result (" << center_p2 << ")" << std::endl; return EXIT_FAILURE; } std::cout << "* Compare ViSP and OpenCV ellipse from sphere meter pixel conversion without distortion" - << std::endl; + << std::endl; vpSphere sphere; sphere.setWorldCoordinates(0, 0, 0, 0.1); // X0=0,Y0=0,Z0=0,R=0.1 circle.changeFrame(cMo); @@ -282,13 +285,13 @@ int main() if (!vpMath::equal(n20_p1, n20_p2, 1e-6) || !vpMath::equal(n11_p1, n11_p2, 1e-6) || !vpMath::equal(n02_p1, n02_p2, 1e-6)) { std::cerr << "Error in ellipse from sphere meter pixel conversion: visp result (" << n20_p1 << ", " << n11_p1 - << ", " << n02_p1 << ") " - << "differ from OpenCV result (" << n20_p2 << ", " << n11_p2 << ", " << n02_p2 << ")" << std::endl; + << ", " << n02_p1 << ") " + << "differ from OpenCV result (" << n20_p2 << ", " << n11_p2 << ", " << n02_p2 << ")" << std::endl; return EXIT_FAILURE; } if (vpImagePoint::distance(center_p1, center_p2) > 1e-6) { std::cerr << "Error in ellipse from sphere meter pixel conversion: visp result (" << center_p1 << ") " - << "differ from OpenCV result (" << center_p2 << ")" << std::endl; + << "differ from OpenCV result (" << center_p2 << ")" << std::endl; return EXIT_FAILURE; } } @@ -296,7 +299,8 @@ int main() std::cout << "Test successful" << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/camera/testJsonCamera.cpp b/modules/core/test/camera/testJsonCamera.cpp index 2d406d2674..2eea57cf25 100644 --- a/modules/core/test/camera/testJsonCamera.cpp +++ b/modules/core/test/camera/testJsonCamera.cpp @@ -49,6 +49,10 @@ using json = nlohmann::json; //! json namespace shortcut #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + #include namespace { diff --git a/modules/core/test/camera/testXmlParserCamera.cpp b/modules/core/test/camera/testXmlParserCamera.cpp index bf26a31369..37c531b673 100644 --- a/modules/core/test/camera/testXmlParserCamera.cpp +++ b/modules/core/test/camera/testXmlParserCamera.cpp @@ -44,6 +44,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if defined(VISP_HAVE_PUGIXML) #if defined(_WIN32) diff --git a/modules/core/test/image-with-dataset/common.hpp b/modules/core/test/image-with-dataset/common.hpp index a10efa2d21..9a059f8d4d 100644 --- a/modules/core/test/image-with-dataset/common.hpp +++ b/modules/core/test/image-with-dataset/common.hpp @@ -46,6 +46,9 @@ namespace common_tools { +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif static const int g_nearest_neighbor = 0; static const int g_bilinear = 1; diff --git a/modules/core/test/image-with-dataset/perfColorConversion.cpp b/modules/core/test/image-with-dataset/perfColorConversion.cpp index e6df803d23..3dd6446ca3 100644 --- a/modules/core/test/image-with-dataset/perfColorConversion.cpp +++ b/modules/core/test/image-with-dataset/perfColorConversion.cpp @@ -50,6 +50,9 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif static std::string ipath = vpIoTools::getViSPImagesDataPath(); static std::string imagePathColor = vpIoTools::createFilePath(ipath, "Klimt/Klimt.ppm"); static std::string imagePathGray = vpIoTools::createFilePath(ipath, "Klimt/Klimt.pgm"); diff --git a/modules/core/test/image-with-dataset/perfGaussianFilter.cpp b/modules/core/test/image-with-dataset/perfGaussianFilter.cpp index e557cf30ce..39cd7f6603 100644 --- a/modules/core/test/image-with-dataset/perfGaussianFilter.cpp +++ b/modules/core/test/image-with-dataset/perfGaussianFilter.cpp @@ -50,6 +50,9 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif static const std::string ipath = vpIoTools::getViSPImagesDataPath(); static std::string imagePath = vpIoTools::createFilePath(ipath, "faces/1280px-Solvay_conference_1927.png"); diff --git a/modules/core/test/image-with-dataset/perfImageAddSub.cpp b/modules/core/test/image-with-dataset/perfImageAddSub.cpp index 94456af16c..79372cf975 100644 --- a/modules/core/test/image-with-dataset/perfImageAddSub.cpp +++ b/modules/core/test/image-with-dataset/perfImageAddSub.cpp @@ -50,6 +50,9 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif TEST_CASE("Benchmark vpImageTools::imageAdd()", "[benchmark]") { const std::string filepath = vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "Klimt/Klimt.pgm"); @@ -146,11 +149,11 @@ int main(int argc, char *argv[]) // Build a new parser on top of Catch's using namespace Catch::clara; auto cli = session.cli() // Get Catch's composite command line parser - | Opt(runBenchmark) // bind variable to a new option, with a hint string - ["--benchmark"] // the option names it will respond to - ("run benchmark?"); // description string for the help output + | Opt(runBenchmark) // bind variable to a new option, with a hint string + ["--benchmark"] // the option names it will respond to + ("run benchmark?"); // description string for the help output - // Now pass the new composite back to Catch so it uses that +// Now pass the new composite back to Catch so it uses that session.cli(cli); // Let Catch (using Clara) parse the command line diff --git a/modules/core/test/image-with-dataset/perfImageMorphology.cpp b/modules/core/test/image-with-dataset/perfImageMorphology.cpp index 2635e46150..a592bc36a7 100644 --- a/modules/core/test/image-with-dataset/perfImageMorphology.cpp +++ b/modules/core/test/image-with-dataset/perfImageMorphology.cpp @@ -46,6 +46,9 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif static std::string ipath = vpIoTools::getViSPImagesDataPath(); TEST_CASE("Benchmark binary image morphology", "[benchmark]") @@ -238,7 +241,7 @@ TEST_CASE("Benchmark gray image morphology", "[benchmark]") } #endif -int main(int argc, char *argv []) +int main(int argc, char *argv[]) { Catch::Session session; // There must be exactly one instance diff --git a/modules/core/test/image-with-dataset/perfImageResize.cpp b/modules/core/test/image-with-dataset/perfImageResize.cpp index 98fb426a42..529a1cca71 100644 --- a/modules/core/test/image-with-dataset/perfImageResize.cpp +++ b/modules/core/test/image-with-dataset/perfImageResize.cpp @@ -51,6 +51,9 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif static const std::string ipath = vpIoTools::getViSPImagesDataPath(); static std::string imagePathColor = vpIoTools::createFilePath(ipath, "Klimt/Klimt.ppm"); static std::string imagePathGray = vpIoTools::createFilePath(ipath, "Klimt/Klimt.pgm"); diff --git a/modules/core/test/image-with-dataset/perfImageWarp.cpp b/modules/core/test/image-with-dataset/perfImageWarp.cpp index f5ed50cf31..0d747d07c2 100644 --- a/modules/core/test/image-with-dataset/perfImageWarp.cpp +++ b/modules/core/test/image-with-dataset/perfImageWarp.cpp @@ -44,6 +44,9 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif namespace { static std::string ipath = vpIoTools::getViSPImagesDataPath(); @@ -341,11 +344,11 @@ int main(int argc, char *argv[]) // Build a new parser on top of Catch's using namespace Catch::clara; auto cli = session.cli() // Get Catch's composite command line parser - | Opt(runBenchmark) // bind variable to a new option, with a hint string - ["--benchmark"] // the option names it will respond to - ("run benchmark?"); // description string for the help output + | Opt(runBenchmark) // bind variable to a new option, with a hint string + ["--benchmark"] // the option names it will respond to + ("run benchmark?"); // description string for the help output - // Now pass the new composite back to Catch so it uses that +// Now pass the new composite back to Catch so it uses that session.cli(cli); // Let Catch (using Clara) parse the command line diff --git a/modules/core/test/image-with-dataset/testColorConversion.cpp b/modules/core/test/image-with-dataset/testColorConversion.cpp index 3ee2ded944..136adae9ce 100644 --- a/modules/core/test/image-with-dataset/testColorConversion.cpp +++ b/modules/core/test/image-with-dataset/testColorConversion.cpp @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + static const double maxMeanPixelError = 1.5; // conversion to gray produce an error = 1.0 static const unsigned int width = 223, height = 151; diff --git a/modules/core/test/image-with-dataset/testConversion.cpp b/modules/core/test/image-with-dataset/testConversion.cpp index 053c6fab95..128dcf556d 100644 --- a/modules/core/test/image-with-dataset/testConversion.cpp +++ b/modules/core/test/image-with-dataset/testConversion.cpp @@ -50,6 +50,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! \example testConversion.cpp diff --git a/modules/core/test/image-with-dataset/testCrop.cpp b/modules/core/test/image-with-dataset/testCrop.cpp index ef420ee246..f974926635 100644 --- a/modules/core/test/image-with-dataset/testCrop.cpp +++ b/modules/core/test/image-with-dataset/testCrop.cpp @@ -43,6 +43,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! \example testCrop.cpp @@ -78,7 +82,7 @@ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n\ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -204,7 +208,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -219,8 +224,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -229,9 +234,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -261,7 +266,8 @@ int main(int argc, const char **argv) std::cout << "Write cropped image: " << filename << std::endl; vpImageIo::write(C, filename); return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image-with-dataset/testCropAdvanced.cpp b/modules/core/test/image-with-dataset/testCropAdvanced.cpp index 06c662b6f4..ae1593d47f 100644 --- a/modules/core/test/image-with-dataset/testCropAdvanced.cpp +++ b/modules/core/test/image-with-dataset/testCropAdvanced.cpp @@ -38,6 +38,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! \example testCropAdvanced.cpp @@ -195,7 +199,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -210,8 +215,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -220,9 +225,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -401,7 +406,8 @@ int main(int argc, const char **argv) std::cout << "Test succeed" << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image-with-dataset/testGaussianFilter.cpp b/modules/core/test/image-with-dataset/testGaussianFilter.cpp index 7c2c1a66a7..0b014ac38b 100644 --- a/modules/core/test/image-with-dataset/testGaussianFilter.cpp +++ b/modules/core/test/image-with-dataset/testGaussianFilter.cpp @@ -35,6 +35,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! \example testGaussianFilter.cpp diff --git a/modules/core/test/image-with-dataset/testImageAddSub.cpp b/modules/core/test/image-with-dataset/testImageAddSub.cpp index b4bb3224f2..7aacf3a18e 100644 --- a/modules/core/test/image-with-dataset/testImageAddSub.cpp +++ b/modules/core/test/image-with-dataset/testImageAddSub.cpp @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + TEST_CASE("Test vpImageTools::imageAdd()", "[image_add]") { const std::string filepath = vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "Klimt/Klimt.pgm"); diff --git a/modules/core/test/image-with-dataset/testImageComparison.cpp b/modules/core/test/image-with-dataset/testImageComparison.cpp index 19821c0726..35510f384d 100644 --- a/modules/core/test/image-with-dataset/testImageComparison.cpp +++ b/modules/core/test/image-with-dataset/testImageComparison.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // List of allowed command line options #define GETOPTARGS "cdi:h" @@ -68,7 +72,7 @@ SYNOPSIS\n\ %s [-i ]\n\ [-h]\n \ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -170,8 +174,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -180,9 +184,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; exit(EXIT_FAILURE); } @@ -217,7 +221,8 @@ int main(int argc, const char **argv) // Modify I_Klimt1 if (I_Klimt1[I_Klimt1.getHeight() / 2][I_Klimt1.getWidth() / 2] < 255) { I_Klimt1[I_Klimt1.getHeight() / 2][I_Klimt1.getWidth() / 2]++; - } else { + } + else { I_Klimt1[I_Klimt1.getHeight() / 2][I_Klimt1.getWidth() / 2]--; } @@ -262,7 +267,8 @@ int main(int argc, const char **argv) // Modify I_color_Klimt2 if (I_color_Klimt2[I_color_Klimt2.getHeight() / 2][I_color_Klimt2.getWidth() / 2].R < 255) { I_color_Klimt2[I_color_Klimt2.getHeight() / 2][I_color_Klimt2.getWidth() / 2].R++; - } else { + } + else { I_color_Klimt2[I_color_Klimt2.getHeight() / 2][I_color_Klimt2.getWidth() / 2].R--; } @@ -280,7 +286,8 @@ int main(int argc, const char **argv) throw vpException(vpException::fatalError, ss.str()); } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "\nCatch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image-with-dataset/testImageFilter.cpp b/modules/core/test/image-with-dataset/testImageFilter.cpp index d05719987c..07e5978d85 100644 --- a/modules/core/test/image-with-dataset/testImageFilter.cpp +++ b/modules/core/test/image-with-dataset/testImageFilter.cpp @@ -49,6 +49,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:p:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { /* diff --git a/modules/core/test/image-with-dataset/testImageNormalizedCorrelation.cpp b/modules/core/test/image-with-dataset/testImageNormalizedCorrelation.cpp index 6819c9bde6..b54c03c308 100644 --- a/modules/core/test/image-with-dataset/testImageNormalizedCorrelation.cpp +++ b/modules/core/test/image-with-dataset/testImageNormalizedCorrelation.cpp @@ -50,6 +50,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void usage(const char *name, const char *badparam, std::string ipath) @@ -174,8 +178,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -184,9 +188,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; exit(EXIT_FAILURE); } @@ -218,7 +222,7 @@ int main(int argc, const char **argv) for (unsigned int j = 0; j < I_score.getWidth(); j++) { if (!vpMath::equal(I_score[i][j], I_score_gold[i][j], 1e-9)) { std::cerr << "Issue with normalizedCorrelation, gold: " << std::setprecision(17) << I_score_gold[i][j] - << " ; compute: " << I_score[i][j] << std::endl; + << " ; compute: " << I_score[i][j] << std::endl; return EXIT_FAILURE; } } @@ -240,7 +244,8 @@ int main(int argc, const char **argv) return EXIT_FAILURE; } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "\nCatch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image-with-dataset/testImageTemplateMatching.cpp b/modules/core/test/image-with-dataset/testImageTemplateMatching.cpp index e3f589c703..16bdc269de 100644 --- a/modules/core/test/image-with-dataset/testImageTemplateMatching.cpp +++ b/modules/core/test/image-with-dataset/testImageTemplateMatching.cpp @@ -50,6 +50,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:th" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void usage(const char *name, const char *badparam, std::string ipath) @@ -182,13 +186,13 @@ int main(int argc, const char **argv) for (int j = 0; j < w; j++) { if (!vpMath::equal(II[i][j], sum.at(i, j), std::numeric_limits::epsilon())) { std::cerr << "Error vpImageTools::integralImage(II), reference: " << std::setprecision(17) - << sum.at(i, j) << " ; compute: " << II[i][j] << std::endl; + << sum.at(i, j) << " ; compute: " << II[i][j] << std::endl; return EXIT_FAILURE; } if (!vpMath::equal(IIsq[i][j], sqsum.at(i, j), std::numeric_limits::epsilon())) { std::cerr << "Error vpImageTools::integralImage(IIsq), reference: " << std::setprecision(17) - << sqsum.at(i, j) << " ; compute: " << IIsq[i][j] << std::endl; + << sqsum.at(i, j) << " ; compute: " << IIsq[i][j] << std::endl; return EXIT_FAILURE; } } @@ -196,178 +200,180 @@ int main(int argc, const char **argv) } #endif - try { - std::string env_ipath; - std::string opt_ipath; - std::string ipath; - std::string filename; - bool click = false; - bool doTemplateMatching = false; +try { + std::string env_ipath; + std::string opt_ipath; + std::string ipath; + std::string filename; + bool click = false; + bool doTemplateMatching = false; #if VISP_HAVE_DATASET_VERSION >= 0x030600 - std::string ext("png"); + std::string ext("png"); #else - std::string ext("pgm"); + std::string ext("pgm"); #endif // Get the visp-images-data package path or VISP_INPUT_IMAGE_PATH // environment variable value - env_ipath = vpIoTools::getViSPImagesDataPath(); + env_ipath = vpIoTools::getViSPImagesDataPath(); - // Set the default input path - if (!env_ipath.empty()) { - ipath = env_ipath; - } + // Set the default input path + if (!env_ipath.empty()) { + ipath = env_ipath; + } - // Read the command line options - if (!getOptions(argc, argv, opt_ipath, click, doTemplateMatching)) { - exit(EXIT_FAILURE); - } + // Read the command line options + if (!getOptions(argc, argv, opt_ipath, click, doTemplateMatching)) { + exit(EXIT_FAILURE); + } - // Get the option values - if (!opt_ipath.empty()) { - ipath = opt_ipath; - } + // Get the option values + if (!opt_ipath.empty()) { + ipath = opt_ipath; + } - // Compare ipath and env_ipath. If they differ, we take into account - // the input path coming from the command line option - if (!opt_ipath.empty() && !env_ipath.empty()) { - if (ipath != env_ipath) { - std::cout << std::endl << "WARNING: " << std::endl; - std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; - } + // Compare ipath and env_ipath. If they differ, we take into account + // the input path coming from the command line option + if (!opt_ipath.empty() && !env_ipath.empty()) { + if (ipath != env_ipath) { + std::cout << std::endl << "WARNING: " << std::endl; + std::cout << " Since -i " + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } + } - // Test if an input path is set - if (opt_ipath.empty() && env_ipath.empty()) { - usage(argv[0], nullptr, ipath); - std::cerr << std::endl << "ERROR:" << std::endl; - std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; - exit(EXIT_FAILURE); - } + // Test if an input path is set + if (opt_ipath.empty() && env_ipath.empty()) { + usage(argv[0], nullptr, ipath); + std::cerr << std::endl << "ERROR:" << std::endl; + std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; + exit(EXIT_FAILURE); + } - // - // Here starts really the test - // + // + // Here starts really the test + // - // Load cube sequence - filename = vpIoTools::createFilePath(ipath, "mbt/cube/image%04d." + ext); + // Load cube sequence + filename = vpIoTools::createFilePath(ipath, "mbt/cube/image%04d." + ext); - vpVideoReader reader; - reader.setFileName(filename); - vpImage I, I_template; - reader.open(I); - vpRect template_roi(vpImagePoint(201, 310), vpImagePoint(201 + 152 - 1, 310 + 138 - 1)); - vpImageTools::crop(I, template_roi, I_template); + vpVideoReader reader; + reader.setFileName(filename); + vpImage I, I_template; + reader.open(I); + vpRect template_roi(vpImagePoint(201, 310), vpImagePoint(201 + 152 - 1, 310 + 138 - 1)); + vpImageTools::crop(I, template_roi, I_template); - if (doTemplateMatching) { + if (doTemplateMatching) { #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) #if defined(VISP_HAVE_X11) - vpDisplayX d; + vpDisplayX d; #elif defined(VISP_HAVE_GDI) - vpDisplayGDI d; + vpDisplayGDI d; #elif defined(HAVE_OPENCV_HIGHGUI) - vpDisplayOpenCV d; + vpDisplayOpenCV d; #endif - d.init(I, 0, 0, "Image"); + d.init(I, 0, 0, "Image"); - vpImage I_score; - std::vector benchmark_vec; - bool quit = false; - while (!reader.end() && !quit) { - reader.acquire(I); + vpImage I_score; + std::vector benchmark_vec; + bool quit = false; + while (!reader.end() && !quit) { + reader.acquire(I); - vpDisplay::display(I); + vpDisplay::display(I); - std::stringstream ss; - ss << "Frame: " << reader.getFrameIndex(); - vpDisplay::displayText(I, 20, 20, ss.str(), vpColor::red); + std::stringstream ss; + ss << "Frame: " << reader.getFrameIndex(); + vpDisplay::displayText(I, 20, 20, ss.str(), vpColor::red); - // Basic template matching - double t_proc = vpTime::measureTimeMs(); - const unsigned int step_u = 5, step_v = 5; - vpImageTools::templateMatching(I, I_template, I_score, step_u, step_v); + // Basic template matching + double t_proc = vpTime::measureTimeMs(); + const unsigned int step_u = 5, step_v = 5; + vpImageTools::templateMatching(I, I_template, I_score, step_u, step_v); - vpImagePoint max_loc; - double max_correlation = -1.0; - I_score.getMinMaxLoc(nullptr, &max_loc, nullptr, &max_correlation); - t_proc = vpTime::measureTimeMs() - t_proc; - benchmark_vec.push_back(t_proc); + vpImagePoint max_loc; + double max_correlation = -1.0; + I_score.getMinMaxLoc(nullptr, &max_loc, nullptr, &max_correlation); + t_proc = vpTime::measureTimeMs() - t_proc; + benchmark_vec.push_back(t_proc); - ss.str(""); - ss << "Template matching: " << t_proc << " ms"; - vpDisplay::displayText(I, 40, 20, ss.str(), vpColor::red); + ss.str(""); + ss << "Template matching: " << t_proc << " ms"; + vpDisplay::displayText(I, 40, 20, ss.str(), vpColor::red); - ss.str(""); - ss << "Max correlation: " << max_correlation; - vpDisplay::displayText(I, 60, 20, ss.str(), vpColor::red); + ss.str(""); + ss << "Max correlation: " << max_correlation; + vpDisplay::displayText(I, 60, 20, ss.str(), vpColor::red); - vpDisplay::displayRectangle(I, max_loc, I_template.getWidth(), I_template.getHeight(), vpColor::red, false, 1); + vpDisplay::displayRectangle(I, max_loc, I_template.getWidth(), I_template.getHeight(), vpColor::red, false, 1); - vpDisplay::flush(I); + vpDisplay::flush(I); - vpMouseButton::vpMouseButtonType button; - if (vpDisplay::getClick(I, button, click)) { - switch (button) { - case vpMouseButton::button1: - quit = !click; - break; + vpMouseButton::vpMouseButtonType button; + if (vpDisplay::getClick(I, button, click)) { + switch (button) { + case vpMouseButton::button1: + quit = !click; + break; - case vpMouseButton::button3: - click = !click; - break; + case vpMouseButton::button3: + click = !click; + break; - default: - break; - } + default: + break; } } + } - if (!benchmark_vec.empty()) { - std::cout << "Processing time, Mean: " << vpMath::getMean(benchmark_vec) - << " ms ; Median: " << vpMath::getMedian(benchmark_vec) - << " ms ; Std: " << vpMath::getStdev(benchmark_vec) << " ms" << std::endl; - } + if (!benchmark_vec.empty()) { + std::cout << "Processing time, Mean: " << vpMath::getMean(benchmark_vec) + << " ms ; Median: " << vpMath::getMedian(benchmark_vec) + << " ms ; Std: " << vpMath::getStdev(benchmark_vec) << " ms" << std::endl; + } #endif - } else { - // ctest case - // Basic template matching - const unsigned int step_u = 5, step_v = 5; - vpImage I_score, I_score_gold; - - double t = vpTime::measureTimeMs(); - vpImageTools::templateMatching(I, I_template, I_score, step_u, step_v, true); - t = vpTime::measureTimeMs() - t; - - double t_gold = vpTime::measureTimeMs(); - vpImageTools::templateMatching(I, I_template, I_score_gold, step_u, step_v, false); - t_gold = vpTime::measureTimeMs() - t_gold; - - std::cout << "Template matching: " << t << " ms" << std::endl; - std::cout << "Template matching (gold): " << t_gold << " ms" << std::endl; - - for (unsigned int i = 0; i < I_score.getHeight(); i++) { - for (unsigned int j = 0; j < I_score.getWidth(); j++) { - if (!vpMath::equal(I_score[i][j], I_score_gold[i][j], 1e-9)) { - std::cerr << "Issue with template matching, gold: " << std::setprecision(17) << I_score_gold[i][j] - << " ; compute: " << I_score[i][j] << std::endl; - return EXIT_FAILURE; - } + } + else { + // ctest case + // Basic template matching + const unsigned int step_u = 5, step_v = 5; + vpImage I_score, I_score_gold; + + double t = vpTime::measureTimeMs(); + vpImageTools::templateMatching(I, I_template, I_score, step_u, step_v, true); + t = vpTime::measureTimeMs() - t; + + double t_gold = vpTime::measureTimeMs(); + vpImageTools::templateMatching(I, I_template, I_score_gold, step_u, step_v, false); + t_gold = vpTime::measureTimeMs() - t_gold; + + std::cout << "Template matching: " << t << " ms" << std::endl; + std::cout << "Template matching (gold): " << t_gold << " ms" << std::endl; + + for (unsigned int i = 0; i < I_score.getHeight(); i++) { + for (unsigned int j = 0; j < I_score.getWidth(); j++) { + if (!vpMath::equal(I_score[i][j], I_score_gold[i][j], 1e-9)) { + std::cerr << "Issue with template matching, gold: " << std::setprecision(17) << I_score_gold[i][j] + << " ; compute: " << I_score[i][j] << std::endl; + return EXIT_FAILURE; } } } - - } catch (const vpException &e) { - std::cerr << "\nCatch an exception: " << e << std::endl; - return EXIT_FAILURE; } - return EXIT_SUCCESS; +} +catch (const vpException &e) { + std::cerr << "\nCatch an exception: " << e << std::endl; + return EXIT_FAILURE; +} + +return EXIT_SUCCESS; } diff --git a/modules/core/test/image-with-dataset/testImageWarp.cpp b/modules/core/test/image-with-dataset/testImageWarp.cpp index 3bebc67edb..136a922014 100644 --- a/modules/core/test/image-with-dataset/testImageWarp.cpp +++ b/modules/core/test/image-with-dataset/testImageWarp.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { static const double g_threshold_value = 0.5; diff --git a/modules/core/test/image-with-dataset/testIoEXR.cpp b/modules/core/test/image-with-dataset/testIoEXR.cpp index 88d0001736..8474ca7597 100644 --- a/modules/core/test/image-with-dataset/testIoEXR.cpp +++ b/modules/core/test/image-with-dataset/testIoEXR.cpp @@ -53,6 +53,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { #ifdef VISP_LITTLE_ENDIAN diff --git a/modules/core/test/image-with-dataset/testIoPFM.cpp b/modules/core/test/image-with-dataset/testIoPFM.cpp index 4d724ff6d3..5dfb0d9e52 100644 --- a/modules/core/test/image-with-dataset/testIoPFM.cpp +++ b/modules/core/test/image-with-dataset/testIoPFM.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void checkColorImages(const vpImage &I1, const vpImage &I2) @@ -80,7 +84,7 @@ TEST_CASE("HDR PFM image read", "[hdr_pfm_image_io]") SECTION("Color") { const std::string imgPath = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_LSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_LSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPath)); vpImage I; @@ -90,7 +94,7 @@ TEST_CASE("HDR PFM image read", "[hdr_pfm_image_io]") SECTION("Gray") { const std::string imgPath = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_LSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_LSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPath)); vpImage I; @@ -104,7 +108,7 @@ TEST_CASE("HDR PFM image read", "[hdr_pfm_image_io]") SECTION("Color") { const std::string imgPath = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_MSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_MSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPath)); vpImage I; @@ -114,7 +118,7 @@ TEST_CASE("HDR PFM image read", "[hdr_pfm_image_io]") SECTION("Gray") { const std::string imgPath = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_MSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_MSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPath)); vpImage I; @@ -128,9 +132,9 @@ TEST_CASE("HDR PFM image read", "[hdr_pfm_image_io]") SECTION("Color") { const std::string imgPathLSB = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_LSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_LSB.pfm"); const std::string imgPathMSB = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_MSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_MSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPathLSB)); REQUIRE(vpIoTools::checkFilename(imgPathMSB)); @@ -150,9 +154,9 @@ TEST_CASE("HDR PFM image read", "[hdr_pfm_image_io]") SECTION("Gray") { const std::string imgPathLSB = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_LSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_LSB.pfm"); const std::string imgPathMSB = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_MSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_MSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPathLSB)); REQUIRE(vpIoTools::checkFilename(imgPathMSB)); @@ -182,7 +186,7 @@ TEST_CASE("HDR PFM image write", "[hdr_pfm_image_io]") SECTION("Color") { const std::string imgPath = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_LSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_color_LSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPath)); vpImage I; @@ -201,7 +205,7 @@ TEST_CASE("HDR PFM image write", "[hdr_pfm_image_io]") SECTION("Gray") { const std::string imgPath = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_LSB.pfm"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "memorial/memorial_gray_LSB.pfm"); REQUIRE(vpIoTools::checkFilename(imgPath)); vpImage I; diff --git a/modules/core/test/image-with-dataset/testIoPGM.cpp b/modules/core/test/image-with-dataset/testIoPGM.cpp index 2c5d507367..b5ffe32f66 100644 --- a/modules/core/test/image-with-dataset/testIoPGM.cpp +++ b/modules/core/test/image-with-dataset/testIoPGM.cpp @@ -51,6 +51,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:o:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /* Print the program options. @@ -72,7 +76,7 @@ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n\ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -198,7 +202,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -213,8 +218,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -223,9 +228,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -251,7 +256,8 @@ int main(int argc, const char **argv) filename = vpIoTools::createFilePath(ipath, "image-that-does-not-exist.pgm"); std::cout << "Read image: " << filename << std::endl; vpImageIo::read(I, filename); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception due to a non existing file: " << e << std::endl; } @@ -260,11 +266,13 @@ int main(int argc, const char **argv) filename = vpIoTools::createFilePath(opath, "directory-that-does-not-exist/Klimt.pgm"); std::cout << "Write image: " << filename << std::endl; vpImageIo::write(I, filename); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception due to a non existing file: " << e << std::endl; } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image-with-dataset/testIoPPM.cpp b/modules/core/test/image-with-dataset/testIoPPM.cpp index 5319ce63ac..783de2289f 100644 --- a/modules/core/test/image-with-dataset/testIoPPM.cpp +++ b/modules/core/test/image-with-dataset/testIoPPM.cpp @@ -52,6 +52,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:o:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /* Print the program options. @@ -73,7 +77,7 @@ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n\ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -200,7 +204,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -215,8 +220,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -225,9 +230,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -254,7 +259,8 @@ int main(int argc, const char **argv) filename = vpIoTools::createFilePath(ipath, "image-that-does-not-exist.ppm"); std::cout << "Read image: " << filename << std::endl; vpImageIo::read(I, filename); - } catch (vpImageException &e) { + } + catch (vpImageException &e) { vpERROR_TRACE("at main level"); std::cout << e << std::endl; } @@ -264,7 +270,8 @@ int main(int argc, const char **argv) filename = vpIoTools::createFilePath(opath, "directory-that-does-not-exist/Klimt.ppm"); std::cout << "Write image: " << filename << std::endl; vpImageIo::write(I, filename); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception due to a non existing file: " << e << std::endl; } @@ -287,7 +294,8 @@ int main(int argc, const char **argv) filename = vpIoTools::createFilePath(ipath, "image-that-does-not-exist.ppm"); std::cout << "Read image: " << filename << std::endl; vpImageIo::read(Irgba, filename); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception due to a non existing file: " << e << std::endl; } @@ -296,11 +304,13 @@ int main(int argc, const char **argv) filename = vpIoTools::createFilePath(opath, "directory-that-does-not-exist/Klimt.ppm"); std::cout << "Write image: " << filename << std::endl; vpImageIo::write(Irgba, filename); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception due to a non existing file: " << e << std::endl; } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image-with-dataset/testPerformanceLUT.cpp b/modules/core/test/image-with-dataset/testPerformanceLUT.cpp index 9d8f95db45..8cbdf167ed 100644 --- a/modules/core/test/image-with-dataset/testPerformanceLUT.cpp +++ b/modules/core/test/image-with-dataset/testPerformanceLUT.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! * \example testPerformanceLUT.cpp * diff --git a/modules/core/test/image-with-dataset/testReadImage.cpp b/modules/core/test/image-with-dataset/testReadImage.cpp index 7d63c4faa4..05e2a23c14 100644 --- a/modules/core/test/image-with-dataset/testReadImage.cpp +++ b/modules/core/test/image-with-dataset/testReadImage.cpp @@ -48,6 +48,10 @@ */ +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // List of allowed command line options #define GETOPTARGS "cdi:p:h" @@ -72,7 +76,7 @@ SYNOPSIS\n\ %s [-i ] [-p ]\n\ [-h]\n\ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -179,8 +183,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -220,12 +224,14 @@ int main(int argc, const char **argv) filename = vpIoTools::createFilePath(ipath, "Klimt/Klimt.png"); vpImageIo::read(Irgb, filename); printf("Read png ok\n"); - } else { + } + else { filename = opt_ppath; vpImageIo::read(I, filename); printf("Image \"%s\" read successfully\n", filename.c_str()); } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image-with-dataset/testUndistortImage.cpp b/modules/core/test/image-with-dataset/testUndistortImage.cpp index 3f871a0983..0eb164b3b1 100644 --- a/modules/core/test/image-with-dataset/testUndistortImage.cpp +++ b/modules/core/test/image-with-dataset/testUndistortImage.cpp @@ -53,6 +53,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:o:t:s:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /* Print the program options. diff --git a/modules/core/test/image/common.hpp b/modules/core/test/image/common.hpp index 5d1f424fe6..4ae826cf2e 100644 --- a/modules/core/test/image/common.hpp +++ b/modules/core/test/image/common.hpp @@ -46,6 +46,9 @@ namespace common_tools { +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif static const int g_nearest_neighbor = 0; static const int g_bilinear = 1; diff --git a/modules/core/test/image/testImageBinarise.cpp b/modules/core/test/image/testImageBinarise.cpp index e828aff8d9..3dbcdba534 100644 --- a/modules/core/test/image/testImageBinarise.cpp +++ b/modules/core/test/image/testImageBinarise.cpp @@ -46,6 +46,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::cout << "Test vpImageTools::binarise() with different data types." << std::endl; unsigned int width = 5, height = 4; @@ -82,8 +85,8 @@ int main() for (unsigned int i = 0; i < I_rgba.getHeight(); i++) { for (unsigned int j = 0; j < I_rgba.getWidth(); j++) { std::cout << static_cast(I_rgba[i][j].R) << " ; " << static_cast(I_rgba[i][j].G) << " ; " - << static_cast(I_rgba[i][j].B) << " ; " << static_cast(I_rgba[i][j].A) - << std::endl; + << static_cast(I_rgba[i][j].B) << " ; " << static_cast(I_rgba[i][j].A) + << std::endl; } std::cout << std::endl; } @@ -113,7 +116,7 @@ int main() for (unsigned int i = 0; i < I_rgba.getHeight(); i++) { for (unsigned int j = 0; j < I_rgba.getWidth(); j++) { std::cout << static_cast(I_rgba[i][j].R) << " ; " << static_cast(I_rgba[i][j].G) << " ; " - << static_cast(I_rgba[i][j].B) << " ; " << static_cast(I_rgba[i][j].A) << std::endl; + << static_cast(I_rgba[i][j].B) << " ; " << static_cast(I_rgba[i][j].A) << std::endl; } std::cout << std::endl; } diff --git a/modules/core/test/image/testImageDifference.cpp b/modules/core/test/image/testImageDifference.cpp index e3b773f7bc..71450593e4 100644 --- a/modules/core/test/image/testImageDifference.cpp +++ b/modules/core/test/image/testImageDifference.cpp @@ -44,6 +44,10 @@ \brief Test vpImageTools::imageDifference() */ +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void regularImageDifference(const vpImage &I1, const vpImage &I2, @@ -94,7 +98,7 @@ int main() unsigned int width = 501, height = 447; vpImage I1(height, width), I2(height, width), Idiff_regular(height, width), Idiff_sse(height, width); vpImage I1_color(height, width), I2_color(height, width), Idiff_regular_color(height, width), - Idiff_sse_color(height, width); + Idiff_sse_color(height, width); for (unsigned int i = 0; i < I1.getRows(); i++) { for (unsigned int j = 0; j < I1.getCols(); j++) { I1[i][j] = static_cast(i * I1.getCols() + j); @@ -212,7 +216,7 @@ int main() } } - { + { std::cout << "Test vpRGBf" << std::endl; vpRGBf rgbf_1(10.f, 20.f, 30.f); vpRGBf rgbf_2(10.f, 20.f, 30.f); diff --git a/modules/core/test/image/testImageDraw.cpp b/modules/core/test/image/testImageDraw.cpp index 08026571bf..25aee19d53 100644 --- a/modules/core/test/image/testImageDraw.cpp +++ b/modules/core/test/image/testImageDraw.cpp @@ -45,6 +45,9 @@ int main(int argc, char *argv[]) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif bool save = false; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--save") { diff --git a/modules/core/test/image/testImageGetValue.cpp b/modules/core/test/image/testImageGetValue.cpp index 577d24e59a..fe20646340 100644 --- a/modules/core/test/image/testImageGetValue.cpp +++ b/modules/core/test/image/testImageGetValue.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { template PixelType checkPixelAccess(unsigned int height, unsigned int width, double v, double u) diff --git a/modules/core/test/image/testImageMeanAndStdev.cpp b/modules/core/test/image/testImageMeanAndStdev.cpp index 71b0904c3b..c5280e7b81 100644 --- a/modules/core/test/image/testImageMeanAndStdev.cpp +++ b/modules/core/test/image/testImageMeanAndStdev.cpp @@ -56,6 +56,9 @@ void printHelp(const std::string &progName) int main(const int argc, const char *argv[]) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif bool opt_verbose = false; for (int i = 1; i < argc; ++i) { std::string argName(argv[i]); diff --git a/modules/core/test/image/testImageMorphology.cpp b/modules/core/test/image/testImageMorphology.cpp index 8e051b8330..2125ffbfaa 100644 --- a/modules/core/test/image/testImageMorphology.cpp +++ b/modules/core/test/image/testImageMorphology.cpp @@ -48,6 +48,9 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif TEST_CASE("Binary image morphology", "[image_morphology]") { unsigned char image_data[8 * 16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/modules/core/test/image/testImageOwnership.cpp b/modules/core/test/image/testImageOwnership.cpp index 9c3a1770b4..72af85a704 100644 --- a/modules/core/test/image/testImageOwnership.cpp +++ b/modules/core/test/image/testImageOwnership.cpp @@ -43,6 +43,9 @@ int main(int /* argc */, const char ** /* argv */) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { { unsigned char bitmap[4]; diff --git a/modules/core/test/image/testImagePoint.cpp b/modules/core/test/image/testImagePoint.cpp index 9a03c4a236..c226befd43 100644 --- a/modules/core/test/image/testImagePoint.cpp +++ b/modules/core/test/image/testImagePoint.cpp @@ -48,6 +48,9 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif TEST_CASE("Test comparison operator", "[operator]") { vpImagePoint ip1, ip2, ip3; @@ -152,7 +155,8 @@ int main() if (ip1 == ip2) { std::cout << "ip1 == ip2" << std::endl; - } else { + } + else { std::cout << "ip1 != ip2 (bad result)" << std::endl; return EXIT_FAILURE; } @@ -160,20 +164,23 @@ int main() if (ip1 != ip2) { std::cout << "ip1 != ip2 (bad result)" << std::endl; return EXIT_FAILURE; - } else { + } + else { std::cout << "ip1 == ip2" << std::endl; } if (ip1 == ip3) { std::cout << "ip1 == ip3 (bad result)" << std::endl; return EXIT_FAILURE; - } else { + } + else { std::cout << "ip1 != ip3" << std::endl; } if (ip1 != ip3) { std::cout << "ip1 != ip3" << std::endl; - } else { + } + else { std::cout << "ip1 == ip3 (bad result)" << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/image/testImagePrint.cpp b/modules/core/test/image/testImagePrint.cpp index 91dbcbbfc7..9144ae019a 100644 --- a/modules/core/test/image/testImagePrint.cpp +++ b/modules/core/test/image/testImagePrint.cpp @@ -43,6 +43,9 @@ */ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif unsigned int size = 16; vpImage I_int(size, size); vpImage I_uchar(size, size); diff --git a/modules/core/test/image/testImageResize.cpp b/modules/core/test/image/testImageResize.cpp index 1d5bc6961d..6e77322767 100644 --- a/modules/core/test/image/testImageResize.cpp +++ b/modules/core/test/image/testImageResize.cpp @@ -52,6 +52,9 @@ static unsigned int g_input_height = 5; static unsigned int g_output_width = 4; static unsigned int g_output_height = 3; +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif TEST_CASE("Nearest neighbor interpolation", "[image_resize]") { SECTION("unsigned char") @@ -136,20 +139,20 @@ int main(int argc, char *argv[]) // Build a new parser on top of Catch's using namespace Catch::clara; auto cli = session.cli() // Get Catch's composite command line parser - | Opt(g_input_width, "g_input_width") // bind variable to a new option, with a hint string - ["--iw"] // the option names it will respond to - ("Input image width.") // description string for the help output - | Opt(g_input_height, "g_input_height") // bind variable to a new option, with a hint string - ["--ih"] // the option names it will respond to - ("Input image height.") | - Opt(g_output_width, "g_output_width") // bind variable to a new option, with a hint string - ["--ow"] // the option names it will respond to - ("Output image width.") | - Opt(g_output_height, "g_output_height") // bind variable to a new option, with a hint string - ["--oh"] // the option names it will respond to - ("Output image height."); - - // Now pass the new composite back to Catch so it uses that + | Opt(g_input_width, "g_input_width") // bind variable to a new option, with a hint string + ["--iw"] // the option names it will respond to + ("Input image width.") // description string for the help output + | Opt(g_input_height, "g_input_height") // bind variable to a new option, with a hint string + ["--ih"] // the option names it will respond to + ("Input image height.") | + Opt(g_output_width, "g_output_width") // bind variable to a new option, with a hint string + ["--ow"] // the option names it will respond to + ("Output image width.") | + Opt(g_output_height, "g_output_height") // bind variable to a new option, with a hint string + ["--oh"] // the option names it will respond to + ("Output image height."); + +// Now pass the new composite back to Catch so it uses that session.cli(cli); // Let Catch (using Clara) parse the command line diff --git a/modules/core/test/math/perfColVectorOperations.cpp b/modules/core/test/math/perfColVectorOperations.cpp index c67a0790ec..344f739c0e 100644 --- a/modules/core/test/math/perfColVectorOperations.cpp +++ b/modules/core/test/math/perfColVectorOperations.cpp @@ -42,6 +42,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { static bool g_runBenchmark = false; diff --git a/modules/core/test/math/perfMatrixMultiplication.cpp b/modules/core/test/math/perfMatrixMultiplication.cpp index 0f12b36ec9..0e200134c6 100644 --- a/modules/core/test/math/perfMatrixMultiplication.cpp +++ b/modules/core/test/math/perfMatrixMultiplication.cpp @@ -50,6 +50,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { @@ -214,8 +218,8 @@ bool equalMatrix(const vpMatrix &A, const vpMatrix &B, double tol = 1e-9) TEST_CASE("Benchmark matrix-matrix multiplication", "[benchmark]") { if (runBenchmark || runBenchmarkAll) { - std::vector > sizes = {{3, 3}, {6, 6}, {8, 8}, {10, 10}, {20, 20}, {6, 200}, - {200, 6}, {207, 119}, {83, 201}, {600, 400}, {400, 600}}; + std::vector > sizes = { {3, 3}, {6, 6}, {8, 8}, {10, 10}, {20, 20}, {6, 200}, + {200, 6}, {207, 119}, {83, 201}, {600, 400}, {400, 600} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -273,7 +277,7 @@ TEST_CASE("Benchmark matrix-matrix multiplication", "[benchmark]") oss.str(""); oss << "(" << eigenA.rows() << "x" << eigenA.cols() << ")x(" << eigenB.rows() << "x" << eigenB.cols() - << ") - Eigen"; + << ") - Eigen"; BENCHMARK(oss.str().c_str()) { Eigen::MatrixXd eigenC = eigenA * eigenB; @@ -298,7 +302,7 @@ TEST_CASE("Benchmark matrix-matrix multiplication", "[benchmark]") TEST_CASE("Benchmark matrix-rotation matrix multiplication", "[benchmark]") { if (runBenchmark || runBenchmarkAll) { - std::vector > sizes = {{3, 3}}; + std::vector > sizes = { {3, 3} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -365,7 +369,7 @@ TEST_CASE("Benchmark matrix-rotation matrix multiplication", "[benchmark]") oss.str(""); oss << "(" << eigenA.rows() << "x" << eigenA.cols() << ")x(" << eigenB.rows() << "x" << eigenB.cols() - << ") - Eigen"; + << ") - Eigen"; BENCHMARK(oss.str().c_str()) { Eigen::MatrixXd eigenC = eigenA * eigenB; @@ -391,7 +395,7 @@ TEST_CASE("Benchmark matrix-rotation matrix multiplication", "[benchmark]") TEST_CASE("Benchmark matrix-homogeneous matrix multiplication", "[benchmark]") { if (runBenchmark || runBenchmarkAll) { - std::vector > sizes = {{4, 4}}; + std::vector > sizes = { {4, 4} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -459,7 +463,7 @@ TEST_CASE("Benchmark matrix-homogeneous matrix multiplication", "[benchmark]") oss.str(""); oss << "(" << eigenA.rows() << "x" << eigenA.cols() << ")x(" << eigenB.rows() << "x" << eigenB.cols() - << ") - Eigen"; + << ") - Eigen"; BENCHMARK(oss.str().c_str()) { Eigen::MatrixXd eigenC = eigenA * eigenB; @@ -487,8 +491,8 @@ TEST_CASE("Benchmark matrix-homogeneous matrix multiplication", "[benchmark]") TEST_CASE("Benchmark matrix-vector multiplication", "[benchmark]") { if (runBenchmark || runBenchmarkAll) { - std::vector > sizes = {{3, 3}, {6, 6}, {8, 8}, {10, 10}, {20, 20}, {6, 200}, - {200, 6}, {207, 119}, {83, 201}, {600, 400}, {400, 600}}; + std::vector > sizes = { {3, 3}, {6, 6}, {8, 8}, {10, 10}, {20, 20}, {6, 200}, + {200, 6}, {207, 119}, {83, 201}, {600, 400}, {400, 600} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -550,7 +554,7 @@ TEST_CASE("Benchmark matrix-vector multiplication", "[benchmark]") oss.str(""); oss << "(" << eigenA.rows() << "x" << eigenA.cols() << ")x(" << eigenB.rows() << "x" << eigenB.cols() - << ") - Eigen"; + << ") - Eigen"; BENCHMARK(oss.str().c_str()) { Eigen::MatrixXd eigenC = eigenA * eigenB; @@ -575,8 +579,8 @@ TEST_CASE("Benchmark matrix-vector multiplication", "[benchmark]") TEST_CASE("Benchmark AtA", "[benchmark]") { if (runBenchmark || runBenchmarkAll) { - std::vector > sizes = {{3, 3}, {6, 6}, {8, 8}, {10, 10}, {20, 20}, {6, 200}, - {200, 6}, {207, 119}, {83, 201}, {600, 400}, {400, 600}}; + std::vector > sizes = { {3, 3}, {6, 6}, {8, 8}, {10, 10}, {20, 20}, {6, 200}, + {200, 6}, {207, 119}, {83, 201}, {600, 400}, {400, 600} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -654,7 +658,7 @@ TEST_CASE("Benchmark AAt", "[benchmark]") if (runBenchmark || runBenchmarkAll) { std::vector > sizes = { {3, 3}, {6, 6}, {8, 8}, {10, 10}, - {20, 20}, {6, 200}, {200, 6}}; //, {207, 119}, {83, 201}, {600, 400}, {400, 600} }; + {20, 20}, {6, 200}, {200, 6} }; //, {207, 119}, {83, 201}, {600, 400}, {400, 600} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -730,7 +734,7 @@ TEST_CASE("Benchmark AAt", "[benchmark]") TEST_CASE("Benchmark matrix-velocity twist multiplication", "[benchmark]") { if (runBenchmark || runBenchmarkAll) { - std::vector > sizes = {{6, 6}, {20, 6}, {207, 6}, {600, 6}, {1201, 6}}; + std::vector > sizes = { {6, 6}, {20, 6}, {207, 6}, {600, 6}, {1201, 6} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -820,7 +824,7 @@ TEST_CASE("Benchmark matrix-velocity twist multiplication", "[benchmark]") TEST_CASE("Benchmark matrix-force twist multiplication", "[benchmark]") { if (runBenchmark || runBenchmarkAll) { - std::vector > sizes = {{6, 6}, {20, 6}, {207, 6}, {600, 6}, {1201, 6}}; + std::vector > sizes = { {6, 6}, {20, 6}, {207, 6}, {600, 6}, {1201, 6} }; for (auto sz : sizes) { vpMatrix A = generateRandomMatrix(sz.first, sz.second); @@ -921,18 +925,18 @@ int main(int argc, char *argv[]) // Build a new parser on top of Catch's using namespace Catch::clara; auto cli = session.cli() // Get Catch's composite command line parser - | Opt(runBenchmark) // bind variable to a new option, with a hint string - ["--benchmark"] // the option names it will respond to - ("run benchmark comparing naive code with ViSP implementation") // description string for the help output - | Opt(runBenchmarkAll) // bind variable to a new option, with a hint string - ["--benchmark-all"] // the option names it will respond to - ("run benchmark comparing naive code with ViSP, OpenCV, Eigen implementation") // description string for - // the help output - | Opt(lapackMinSize, "min size") // bind variable to a new option, with a hint string - ["--lapack-min-size"] // the option names it will respond to - ("matrix/vector min size to enable blas/lapack usage"); // description string for the help output - - // Now pass the new composite back to Catch so it uses that + | Opt(runBenchmark) // bind variable to a new option, with a hint string + ["--benchmark"] // the option names it will respond to + ("run benchmark comparing naive code with ViSP implementation") // description string for the help output + | Opt(runBenchmarkAll) // bind variable to a new option, with a hint string + ["--benchmark-all"] // the option names it will respond to + ("run benchmark comparing naive code with ViSP, OpenCV, Eigen implementation") // description string for + // the help output + | Opt(lapackMinSize, "min size") // bind variable to a new option, with a hint string + ["--lapack-min-size"] // the option names it will respond to + ("matrix/vector min size to enable blas/lapack usage"); // description string for the help output + +// Now pass the new composite back to Catch so it uses that session.cli(cli); // Let Catch (using Clara) parse the command line @@ -940,7 +944,7 @@ int main(int argc, char *argv[]) vpMatrix::setLapackMatrixMinSize(lapackMinSize); std::cout << "Used matrix/vector min size to enable Blas/Lapack optimization: " << vpMatrix::getLapackMatrixMinSize() - << std::endl; + << std::endl; int numFailed = session.run(); diff --git a/modules/core/test/math/perfMatrixTranspose.cpp b/modules/core/test/math/perfMatrixTranspose.cpp index 373a295e17..d2a50d5e30 100644 --- a/modules/core/test/math/perfMatrixTranspose.cpp +++ b/modules/core/test/math/perfMatrixTranspose.cpp @@ -50,6 +50,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { @@ -176,7 +180,7 @@ TEST_CASE("Benchmark vpMatrix transpose", "[benchmark]") const std::vector > sizes = { {701, 1503}, {1791, 837}, {1201, 1201}, {1024, 1024}, {2000, 2000}, {10, 6}, {25, 6}, {100, 6}, {200, 6}, {500, 6}, {1000, 6}, {1500, 6}, {2000, 6}, {6, 10}, {6, 25}, {6, 100}, {6, 200}, {6, 500}, - {6, 1000}, {6, 1500}, {6, 2000}, {640, 1000}, {800, 640}, {640, 500}, {500, 640}, {640, 837}}; + {6, 1000}, {6, 1500}, {6, 2000}, {640, 1000}, {800, 640}, {640, 500}, {500, 640}, {640, 837} }; for (auto sz : sizes) { vpMatrix M = generateMatrix(sz.first, sz.second); @@ -270,7 +274,8 @@ TEST_CASE("Benchmark vpMatrix transpose", "[benchmark]") }; #endif } - } else { + } + else { vpMatrix M = generateMatrix(11, 17); vpMatrix Mt_true = generateMatrixTranspose(11, 17); @@ -286,12 +291,12 @@ int main(int argc, char *argv[]) // Build a new parser on top of Catch's using namespace Catch::clara; auto cli = session.cli() // Get Catch's composite command line parser - | Opt(g_runBenchmark) // bind variable to a new option, with a hint string - ["--benchmark"] // the option names it will respond to - ("run benchmark?") // description string for the help output - | Opt(g_tileSize, "tileSize")["--tileSize"]("Tile size?"); + | Opt(g_runBenchmark) // bind variable to a new option, with a hint string + ["--benchmark"] // the option names it will respond to + ("run benchmark?") // description string for the help output + | Opt(g_tileSize, "tileSize")["--tileSize"]("Tile size?"); - // Now pass the new composite back to Catch so it uses that +// Now pass the new composite back to Catch so it uses that session.cli(cli); // Let Catch (using Clara) parse the command line diff --git a/modules/core/test/math/testArray2D.cpp b/modules/core/test/math/testArray2D.cpp index 50dcb0cc9c..9194e0f2ff 100644 --- a/modules/core/test/math/testArray2D.cpp +++ b/modules/core/test/math/testArray2D.cpp @@ -51,6 +51,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + template bool test(const std::string &s, const vpArray2D &A, const std::vector &bench) { static unsigned int cpt = 0; diff --git a/modules/core/test/math/testColVector.cpp b/modules/core/test/math/testColVector.cpp index b6eac7a01b..94f2654557 100644 --- a/modules/core/test/math/testColVector.cpp +++ b/modules/core/test/math/testColVector.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { bool test(const std::string &s, const vpColVector &v, const std::vector &bench) diff --git a/modules/core/test/math/testEigenConversion.cpp b/modules/core/test/math/testEigenConversion.cpp index 47ad406e20..3400c627a1 100644 --- a/modules/core/test/math/testEigenConversion.cpp +++ b/modules/core/test/math/testEigenConversion.cpp @@ -46,6 +46,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { template std::ostream &operator<<(std::ostream &os, const Eigen::Quaternion &q) @@ -56,8 +60,8 @@ template std::ostream &operator<<(std::ostream &os, const Eigen: template std::ostream &operator<<(std::ostream &os, const Eigen::AngleAxis &aa) { return os << "angle: " << aa.angle() << " ; axis: " << aa.axis()(0) << " ; " << aa.axis()(1) << " ; " << aa.axis()(2) - << " ; thetau: " << aa.angle() * aa.axis()(0) << " ; " << aa.angle() * aa.axis()(1) << " ; " - << aa.angle() * aa.axis()(2); + << " ; thetau: " << aa.angle() * aa.axis()(0) << " ; " << aa.angle() * aa.axis()(1) << " ; " + << aa.angle() * aa.axis()(2); } } // namespace @@ -121,7 +125,7 @@ TEST_CASE("Eigen::MatrixXd <--> vpMatrix conversion", "[eigen_conversion]") vp::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; -} + } TEST_CASE("Eigen::MatrixX4d <--> vpMatrix conversion", "[eigen_conversion]") { @@ -150,7 +154,7 @@ TEST_CASE("Eigen::MatrixX4d <--> vpMatrix conversion", "[eigen_conversion]") vp::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; -} + } TEST_CASE("Eigen::Matrix <--> vpMatrix conversion", "[eigen_conversion]") { @@ -179,7 +183,7 @@ TEST_CASE("Eigen::Matrix <--> vpMatrix conve vp::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; -} + } TEST_CASE("Eigen::Matrix <--> vpMatrix conversion", "[eigen_conversion]") { @@ -208,7 +212,7 @@ TEST_CASE("Eigen::Matrix <--> vpMatrix conve vp::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; -} + } TEST_CASE("vpHomogeneousMatrix <--> Eigen::Matrix4d conversion", "[eigen_conversion]") { diff --git a/modules/core/test/math/testHomogeneousMatrix.cpp b/modules/core/test/math/testHomogeneousMatrix.cpp index 9f7df93d43..9a3c7549a0 100644 --- a/modules/core/test/math/testHomogeneousMatrix.cpp +++ b/modules/core/test/math/testHomogeneousMatrix.cpp @@ -44,6 +44,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool test_matrix_equal(const vpHomogeneousMatrix &M1, const vpHomogeneousMatrix &M2, double epsilon = 1e-10) { for (unsigned int i = 0; i < 4; i++) { diff --git a/modules/core/test/math/testJsonArrayConversion.cpp b/modules/core/test/math/testJsonArrayConversion.cpp index 152836a9b0..a2a88dd73d 100644 --- a/modules/core/test/math/testJsonArrayConversion.cpp +++ b/modules/core/test/math/testJsonArrayConversion.cpp @@ -53,6 +53,10 @@ using json = nlohmann::json; //! json namespace shortcut #define CATCH_CONFIG_RUNNER #include "catch.hpp" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { using StringMatcherBase = Catch::Matchers::StdString::StringMatcherBase; diff --git a/modules/core/test/math/testKalmanAcceleration.cpp b/modules/core/test/math/testKalmanAcceleration.cpp index f7105fb6fb..32b2ce93da 100644 --- a/modules/core/test/math/testKalmanAcceleration.cpp +++ b/modules/core/test/math/testKalmanAcceleration.cpp @@ -46,6 +46,10 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + try { unsigned int nsignal = 1; // Number of signal to filter unsigned int niter = 100; @@ -105,7 +109,8 @@ int main() flog.close(); return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/math/testKalmanVelocity.cpp b/modules/core/test/math/testKalmanVelocity.cpp index a3d84250c5..cef84f56ac 100644 --- a/modules/core/test/math/testKalmanVelocity.cpp +++ b/modules/core/test/math/testKalmanVelocity.cpp @@ -44,13 +44,17 @@ #include #include -typedef enum { +typedef enum +{ Position, // Considered measures are the successive positions of the target Velocity // Considered measures are the successive velocities of the target } vpMeasureType; int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { unsigned int nsignal = 2; // Number of signal to filter unsigned int niter = 200; @@ -127,7 +131,8 @@ int main() flog.close(); return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/math/testLineFitting.cpp b/modules/core/test/math/testLineFitting.cpp index e8d5617ab1..b5e33fd947 100644 --- a/modules/core/test/math/testLineFitting.cpp +++ b/modules/core/test/math/testLineFitting.cpp @@ -48,6 +48,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void convertLineEquation(double A, double B, double C, double &a, double &b) @@ -121,7 +125,7 @@ TEST_CASE("Line fitting - Gaussian noise", "[line_fitting]") double y = a * x + b; imPts.push_back(vpImagePoint(y + gauss(), x + gauss())); std::cout << "x: " << x << " ; y: " << y << " ; imPts: (" << imPts.back().get_u() << ", " << imPts.back().get_v() - << ")" << std::endl; + << ")" << std::endl; } double A = 0, B = 0, C = 0; diff --git a/modules/core/test/math/testMath.cpp b/modules/core/test/math/testMath.cpp index 75e10d2215..7b45907617 100644 --- a/modules/core/test/math/testMath.cpp +++ b/modules/core/test/math/testMath.cpp @@ -66,6 +66,9 @@ static const unsigned long __nan[2] = { 0xffffffff, 0x7fffffff }; int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // Test isNaN if (vpMath::isNaN(0.0)) { std::cerr << "Fail: IsNaN(0.0)=" << vpMath::isNaN(0.0) << " / should be false" << std::endl; diff --git a/modules/core/test/math/testMathUtils.cpp b/modules/core/test/math/testMathUtils.cpp index 0073d8a6f2..3a55d02afe 100644 --- a/modules/core/test/math/testMathUtils.cpp +++ b/modules/core/test/math/testMathUtils.cpp @@ -55,6 +55,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + TEST_CASE("Lon-Lat generator", "[math_lonlat]") { const int lonStart = 0, lonEnd = 360, nlon = 20; @@ -132,11 +136,11 @@ TEST_CASE("Lon-Lat generator", "[math_lonlat]") if (file.is_open()) { (ecef_M_enu * enu_M_cv).save(file); } - } -#endif } +#endif } } +} TEST_CASE("Equidistributed sphere point", "[math_equi_sphere_pts]") { diff --git a/modules/core/test/math/testMatrix.cpp b/modules/core/test/math/testMatrix.cpp index b894a63a42..b4200852fe 100644 --- a/modules/core/test/math/testMatrix.cpp +++ b/modules/core/test/math/testMatrix.cpp @@ -51,6 +51,10 @@ #include // for std::back_inserter +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { bool test_memory(unsigned int nrows, unsigned int ncols, const vpMatrix &M, const std::string &matrix_name, bool pointer_is_null) diff --git a/modules/core/test/math/testMatrixCholesky.cpp b/modules/core/test/math/testMatrixCholesky.cpp index 8f4572d0fa..24db7d6dba 100644 --- a/modules/core/test/math/testMatrixCholesky.cpp +++ b/modules/core/test/math/testMatrixCholesky.cpp @@ -48,6 +48,9 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif bool equal(const vpMatrix &A, const vpMatrix &B) { diff --git a/modules/core/test/math/testMatrixConditionNumber.cpp b/modules/core/test/math/testMatrixConditionNumber.cpp index 956ac8b3d6..54363c578a 100644 --- a/modules/core/test/math/testMatrixConditionNumber.cpp +++ b/modules/core/test/math/testMatrixConditionNumber.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int test_condition_number(const std::string &test_name, const vpMatrix &M) { double precision = 1e-6; @@ -97,7 +101,8 @@ int main() if (test_condition_number("* Test square matrix M", M)) { std::cout << " - Condition number computation fails" << std::endl; return EXIT_FAILURE; - } else { + } + else { std::cout << " + Condition number computation succeed" << std::endl; } @@ -112,7 +117,8 @@ int main() if (test_condition_number("* Test rect matrix M", M)) { std::cout << " - Condition number computation fails" << std::endl; return EXIT_FAILURE; - } else { + } + else { std::cout << " + Condition number computation succeed" << std::endl; } @@ -121,7 +127,8 @@ int main() if (test_condition_number("* Test rect matrix M", M)) { std::cout << " - Condition number computation fails" << std::endl; return EXIT_FAILURE; - } else { + } + else { std::cout << " + Condition number computation succeed" << std::endl; } @@ -142,7 +149,8 @@ int main() if (test_condition_number("* Test rect matrix M", M)) { std::cout << " - Condition number computation fails" << std::endl; return EXIT_FAILURE; - } else { + } + else { std::cout << " + Condition number computation succeed" << std::endl; } @@ -151,7 +159,8 @@ int main() if (test_condition_number("* Test rect matrix M", M)) { std::cout << " - Condition number computation fails" << std::endl; return EXIT_FAILURE; - } else { + } + else { std::cout << " + Condition number computation succeed" << std::endl; } std::cout << "Test succeed" << std::endl; diff --git a/modules/core/test/math/testMatrixConvolution.cpp b/modules/core/test/math/testMatrixConvolution.cpp index bb92a8bc30..02f59cd9f8 100644 --- a/modules/core/test/math/testMatrixConvolution.cpp +++ b/modules/core/test/math/testMatrixConvolution.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { bool compareMatrix(const vpMatrix &m, const double *const array) @@ -86,8 +90,8 @@ int main() { vpMatrix res = vpMatrix::conv2(A, B, "full"); - double ground_truth[5 * 5] = {16, 50, 9, 22, 39, 69, 66, 59, 96, 50, 29, 88, 89, - 82, 52, 40, 72, 95, 106, 27, 16, 64, 88, 34, 2}; + double ground_truth[5 * 5] = { 16, 50, 9, 22, 39, 69, 66, 59, 96, 50, 29, 88, 89, + 82, 52, 40, 72, 95, 106, 27, 16, 64, 88, 34, 2 }; std::cout << "A:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, full):\n" << res << std::endl; @@ -97,7 +101,7 @@ int main() } { vpMatrix res = vpMatrix::conv2(A, B, "same"); - double ground_truth[4 * 4] = {66, 59, 96, 50, 88, 89, 82, 52, 72, 95, 106, 27, 64, 88, 34, 2}; + double ground_truth[4 * 4] = { 66, 59, 96, 50, 88, 89, 82, 52, 72, 95, 106, 27, 64, 88, 34, 2 }; std::cout << "\nA:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, same):\n" << res << std::endl; @@ -107,7 +111,7 @@ int main() } { vpMatrix res = vpMatrix::conv2(A, B, "valid"); - double ground_truth[3 * 3] = {66, 59, 96, 88, 89, 82, 72, 95, 106}; + double ground_truth[3 * 3] = { 66, 59, 96, 88, 89, 82, 72, 95, 106 }; std::cout << "\nA:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, valid):\n" << res << std::endl; @@ -130,8 +134,8 @@ int main() { vpMatrix res = vpMatrix::conv2(A, B, "full"); - double ground_truth[5 * 7] = {0, 0, 1, 2, 3, 4, 5, 0, 8, 14, 20, 26, 32, 26, 12, 36, 50, 64, - 78, 92, 58, 24, 64, 86, 108, 130, 152, 90, 36, 84, 97, 110, 123, 136, 77}; + double ground_truth[5 * 7] = { 0, 0, 1, 2, 3, 4, 5, 0, 8, 14, 20, 26, 32, 26, 12, 36, 50, 64, + 78, 92, 58, 24, 64, 86, 108, 130, 152, 90, 36, 84, 97, 110, 123, 136, 77 }; std::cout << "A:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, full):\n" << res << std::endl; @@ -141,7 +145,7 @@ int main() } { vpMatrix res = vpMatrix::conv2(A, B, "same"); - double ground_truth[2 * 6] = {36, 50, 64, 78, 92, 58, 64, 86, 108, 130, 152, 90}; + double ground_truth[2 * 6] = { 36, 50, 64, 78, 92, 58, 64, 86, 108, 130, 152, 90 }; std::cout << "\nA:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, same):\n" << res << std::endl; @@ -161,8 +165,8 @@ int main() { vpMatrix res = vpMatrix::conv2(B, A, "full"); - double ground_truth[5 * 7] = {0, 0, 1, 2, 3, 4, 5, 0, 8, 14, 20, 26, 32, 26, 12, 36, 50, 64, - 78, 92, 58, 24, 64, 86, 108, 130, 152, 90, 36, 84, 97, 110, 123, 136, 77}; + double ground_truth[5 * 7] = { 0, 0, 1, 2, 3, 4, 5, 0, 8, 14, 20, 26, 32, 26, 12, 36, 50, 64, + 78, 92, 58, 24, 64, 86, 108, 130, 152, 90, 36, 84, 97, 110, 123, 136, 77 }; std::cout << "A:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(B, A, full):\n" << res << std::endl; @@ -172,7 +176,7 @@ int main() } { vpMatrix res = vpMatrix::conv2(B, A, "same"); - double ground_truth[4 * 2] = {20, 26, 64, 78, 108, 130, 110, 123}; + double ground_truth[4 * 2] = { 20, 26, 64, 78, 108, 130, 110, 123 }; std::cout << "\nA:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(B, A, same):\n" << res << std::endl; @@ -223,9 +227,9 @@ int main() { vpMatrix res = vpMatrix::conv2(A, B, "full"); - double ground_truth[6 * 6] = {128, 32, 122, 119, 31, 78, 88, 179, 252, 208, 154, 139, + double ground_truth[6 * 6] = { 128, 32, 122, 119, 31, 78, 88, 179, 252, 208, 154, 139, 151, 275, 291, 378, 281, 154, 79, 271, 423, 366, 285, 106, - 48, 171, 248, 292, 230, 31, 16, 92, 194, 167, 39, 2}; + 48, 171, 248, 292, 230, 31, 16, 92, 194, 167, 39, 2 }; std::cout << "A:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, full):\n" << res << std::endl; @@ -235,7 +239,7 @@ int main() } { vpMatrix res = vpMatrix::conv2(A, B, "same"); - double ground_truth[4 * 4] = {179, 252, 208, 154, 275, 291, 378, 281, 271, 423, 366, 285, 171, 248, 292, 230}; + double ground_truth[4 * 4] = { 179, 252, 208, 154, 275, 291, 378, 281, 271, 423, 366, 285, 171, 248, 292, 230 }; std::cout << "\nA:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, same):\n" << res << std::endl; @@ -245,7 +249,7 @@ int main() } { vpMatrix res = vpMatrix::conv2(A, B, "valid"); - double ground_truth[2 * 2] = {291, 378, 423, 366}; + double ground_truth[2 * 2] = { 291, 378, 423, 366 }; std::cout << "\nA:\n" << A << "\nB:\n" << B << "\nvpMatrix::conv2(A, B, valid):\n" << res << std::endl; @@ -254,7 +258,8 @@ int main() } } } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/math/testMatrixDeterminant.cpp b/modules/core/test/math/testMatrixDeterminant.cpp index 77ed348f5e..0b6a0d4d2d 100644 --- a/modules/core/test/math/testMatrixDeterminant.cpp +++ b/modules/core/test/math/testMatrixDeterminant.cpp @@ -45,6 +45,10 @@ // List of allowed command line options #define GETOPTARGS "cdn:i:pf:R:C:vh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! Print the program options. @@ -290,22 +294,22 @@ int main(int argc, const char *argv[]) if (use_plot_file) { of.open(plotfile.c_str()); of << "iter" - << "\t"; + << "\t"; of << "\"Determinant default\"" - << "\t"; + << "\t"; #if defined(VISP_HAVE_LAPACK) of << "\"Determinant Lapack\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_EIGEN3) of << "\"Determinant Eigen3\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_OPENCV) of << "\"Determinant OpenCV\"" - << "\t"; + << "\t"; #endif of << std::endl; } @@ -350,7 +354,7 @@ int main(int argc, const char *argv[]) for (unsigned int i = 0; i < bench.size(); i++) { if (std::fabs(result_lapack[i] - result_opencv[i]) > 1e-6) { std::cout << "Determinant differ between Lapack and OpenCV: " << result_lapack[i] << " " << result_opencv[i] - << std::endl; + << std::endl; ret = EXIT_FAILURE; } } @@ -360,7 +364,7 @@ int main(int argc, const char *argv[]) for (unsigned int i = 0; i < bench.size(); i++) { if (std::fabs(result_eigen3[i] - result_opencv[i]) > 1e-6) { std::cout << "Determinant differ between Eigen3 and OpenCV: " << result_eigen3[i] << " " << result_opencv[i] - << std::endl; + << std::endl; ret = EXIT_FAILURE; } } @@ -370,7 +374,7 @@ int main(int argc, const char *argv[]) for (unsigned int i = 0; i < bench.size(); i++) { if (std::fabs(result_eigen3[i] - result_lapack[i]) > 1e-6) { std::cout << "Determinant differ between Eigen3 and Lapack: " << result_eigen3[i] << " " << result_lapack[i] - << std::endl; + << std::endl; ret = EXIT_FAILURE; } } @@ -383,7 +387,8 @@ int main(int argc, const char *argv[]) if (ret == EXIT_SUCCESS) { std::cout << "Test succeed" << std::endl; - } else { + } + else { std::cout << "Test failed" << std::endl; } @@ -394,8 +399,9 @@ int main(int argc, const char *argv[]) std::cout << "Test does nothing since you dont't have Lapack, Eigen3 or OpenCV 3rd party" << std::endl; return EXIT_SUCCESS; #endif - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } -} + } diff --git a/modules/core/test/math/testMatrixException.cpp b/modules/core/test/math/testMatrixException.cpp index afb00f30b8..5da0509f34 100644 --- a/modules/core/test/math/testMatrixException.cpp +++ b/modules/core/test/math/testMatrixException.cpp @@ -45,6 +45,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpMatrix M; vpMatrix M1(2, 3); vpMatrix M3(2, 2); @@ -53,7 +56,8 @@ int main() try { M = M1 * M3; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } @@ -61,7 +65,8 @@ int main() try { M = M1 + M3; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } diff --git a/modules/core/test/math/testMatrixInitialization.cpp b/modules/core/test/math/testMatrixInitialization.cpp index a4f0f4dd53..11127a34a0 100644 --- a/modules/core/test/math/testMatrixInitialization.cpp +++ b/modules/core/test/math/testMatrixInitialization.cpp @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool equal(const vpArray2D &a1, const vpArray2D &a2, double epsilon) { if (a1.size() != a2.size()) { diff --git a/modules/core/test/math/testMatrixInverse.cpp b/modules/core/test/math/testMatrixInverse.cpp index 745fc88c98..509ddd1bc3 100644 --- a/modules/core/test/math/testMatrixInverse.cpp +++ b/modules/core/test/math/testMatrixInverse.cpp @@ -53,6 +53,10 @@ // List of allowed command line options #define GETOPTARGS "cdn:i:pf:R:C:vh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! Print the program options. @@ -248,7 +252,7 @@ void create_bench_symmetric_positive_matrix(unsigned int nb_matrices, unsigned i { if (verbose) std::cout << "Create a bench of " << nb_matrices << " " << n << " by " << n << " symmetric positive matrices" - << std::endl; + << std::endl; bench.clear(); for (unsigned int i = 0; i < nb_matrices; i++) { vpMatrix M; @@ -260,8 +264,8 @@ void create_bench_symmetric_positive_matrix(unsigned int nb_matrices, unsigned i if (verbose) { std::cout << " Generated random symmetric positive matrix A=" << std::endl << M << std::endl; std::cout << " Generated random symmetric positive matrix not " - "invertibleL: det=" - << det << ". Retrying..." << std::endl; + "invertibleL: det=" + << det << ". Retrying..." << std::endl; } } #else @@ -286,8 +290,8 @@ void create_bench_random_triangular_matrix(unsigned int nb_matrices, unsigned in if (verbose) { std::cout << " Generated random symmetric positive matrix A=" << std::endl << M << std::endl; std::cout << " Generated random symmetric positive matrix not " - "invertibleL: det=" - << det << ". Retrying..." << std::endl; + "invertibleL: det=" + << det << ". Retrying..." << std::endl; } } #else @@ -304,7 +308,7 @@ int test_inverse(const std::vector &bench, const std::vector vpMatrix I = bench[i] * result[i]; if (std::fabs(I.frobeniusNorm() - sqrt(static_cast(bench[0].AtA().getRows()))) > epsilon) { std::cout << "Bad inverse[" << i << "]: " << I.frobeniusNorm() << " " << sqrt((double)bench[0].AtA().getRows()) - << std::endl; + << std::endl; return EXIT_FAILURE; } } @@ -337,7 +341,7 @@ int test_inverse_lu_eigen3(bool verbose, const std::vector &bench, dou // Compute inverse if (verbose) std::cout << " Inverting " << bench[0].AtA().getRows() << "x" << bench[0].AtA().getCols() - << " matrix using LU decomposition (Eigen3)." << std::endl; + << " matrix using LU decomposition (Eigen3)." << std::endl; std::vector result(bench.size()); double t = vpTime::measureTimeMs(); for (unsigned int i = 0; i < bench.size(); i++) { @@ -358,7 +362,7 @@ int test_inverse_lu_lapack(bool verbose, const std::vector &bench, dou // Compute inverse if (verbose) std::cout << " Inverting " << bench[0].AtA().getRows() << "x" << bench[0].AtA().getCols() - << " matrix using LU decomposition (Lapack)." << std::endl; + << " matrix using LU decomposition (Lapack)." << std::endl; std::vector result(bench.size()); double t = vpTime::measureTimeMs(); for (unsigned int i = 0; i < bench.size(); i++) { @@ -377,7 +381,7 @@ int test_inverse_cholesky_lapack(bool verbose, const std::vector &benc // Compute inverse if (verbose) std::cout << " Inverting " << bench[0].AtA().getRows() << "x" << bench[0].AtA().getCols() - << " matrix using cholesky decomposition (Lapack)." << std::endl; + << " matrix using cholesky decomposition (Lapack)." << std::endl; std::vector result(bench.size()); double t = vpTime::measureTimeMs(); for (unsigned int i = 0; i < bench.size(); i++) { @@ -396,7 +400,7 @@ int test_inverse_qr_lapack(bool verbose, const std::vector &bench, dou // Compute inverse if (verbose) std::cout << " Inverting " << bench[0].AtA().getRows() << "x" << bench[0].AtA().getCols() - << " matrix using QR decomposition (Lapack)" << std::endl; + << " matrix using QR decomposition (Lapack)" << std::endl; std::vector result(bench.size()); double t = vpTime::measureTimeMs(); for (unsigned int i = 0; i < bench.size(); i++) { @@ -417,7 +421,7 @@ int test_inverse_lu_opencv(bool verbose, const std::vector &bench, dou // Compute inverse if (verbose) std::cout << " Inverting " << bench[0].AtA().getRows() << "x" << bench[0].AtA().getCols() - << " matrix using LU decomposition (OpenCV)" << std::endl; + << " matrix using LU decomposition (OpenCV)" << std::endl; std::vector result(bench.size()); double t = vpTime::measureTimeMs(); for (unsigned int i = 0; i < bench.size(); i++) { @@ -436,7 +440,7 @@ int test_inverse_cholesky_opencv(bool verbose, const std::vector &benc // Compute inverse if (verbose) std::cout << " Inverting " << bench[0].AtA().getRows() << "x" << bench[0].AtA().getCols() - << " matrix using Cholesky decomposition (OpenCV)" << std::endl; + << " matrix using Cholesky decomposition (OpenCV)" << std::endl; std::vector result(bench.size()); double t = vpTime::measureTimeMs(); for (unsigned int i = 0; i < bench.size(); i++) { @@ -458,7 +462,7 @@ int test_pseudo_inverse(bool verbose, const std::vector &bench, double // Compute inverse if (verbose) std::cout << " Pseudo inverting " << bench[0].AtA().getRows() << "x" << bench[0].AtA().getCols() << " matrix" - << std::endl; + << std::endl; std::vector result(bench.size()); double t = vpTime::measureTimeMs(); for (unsigned int i = 0; i < bench.size(); i++) { @@ -519,39 +523,39 @@ int main(int argc, const char *argv[]) if (use_plot_file) { of.open(plotfile.c_str()); of << "iter" - << "\t"; + << "\t"; #if defined(VISP_HAVE_LAPACK) of << "\"LU Lapack\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_EIGEN3) of << "\"LU Eigen3\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_OPENCV) of << "\"LU OpenCV\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_LAPACK) of << "\"Cholesky Lapack\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_OPENCV) of << "\"Cholesky OpenCV\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_LAPACK) of << "\"QR Lapack\"" - << "\t"; + << "\t"; #endif #if defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV) of << "\"Pseudo inverse (Lapack, Eigen3 or OpenCV)\"" - << "\t"; + << "\t"; #endif of << std::endl; } @@ -643,12 +647,14 @@ int main(int argc, const char *argv[]) if (ret == EXIT_SUCCESS) { std::cout << "Test succeed" << std::endl; - } else { + } + else { std::cout << "Test failed" << std::endl; } return ret; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/math/testMatrixPseudoInverse.cpp b/modules/core/test/math/testMatrixPseudoInverse.cpp index 914af147e7..ec5f195b56 100644 --- a/modules/core/test/math/testMatrixPseudoInverse.cpp +++ b/modules/core/test/math/testMatrixPseudoInverse.cpp @@ -51,6 +51,10 @@ // List of allowed command line options #define GETOPTARGS "cdn:i:pf:R:C:vh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! Print the program options. diff --git a/modules/core/test/math/testMomentAlpha.cpp b/modules/core/test/math/testMomentAlpha.cpp index a4fe42ef1e..5123e070ae 100644 --- a/modules/core/test/math/testMomentAlpha.cpp +++ b/modules/core/test/math/testMomentAlpha.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int test_moment_alpha(const std::string &name, bool symmetry, const std::vector &vec_angle, double tolerance_deg, double symmetry_threshold = 1e-6) { @@ -155,8 +159,9 @@ int test_moment_alpha(const std::string &name, bool symmetry, const std::vector< std::cout << "Error: result is not in the tolerance: " << tolerance_deg << std::endl; return EXIT_FAILURE; } - } else { - // Tranform input angle from [0; 360] to [0; 180] range + } + else { + // Tranform input angle from [0; 360] to [0; 180] range double angle_des1 = vec_angle[i]; double angle_des2 = vec_angle[i] - 180; @@ -164,7 +169,7 @@ int test_moment_alpha(const std::string &name, bool symmetry, const std::vector< double alpha = vpMath::deg(malpha.get()); std::cout << "alpha expected " << angle_des1 << " or " << angle_des2 << " computed " << alpha << " deg" - << std::endl; + << std::endl; if (!vpMath::equal(angle_des1, alpha, tolerance_deg) && !vpMath::equal(angle_des2, alpha, tolerance_deg)) { // 0.5 deg of tolerance diff --git a/modules/core/test/math/testPoseVector.cpp b/modules/core/test/math/testPoseVector.cpp index bfe0126b0e..68602ebd22 100644 --- a/modules/core/test/math/testPoseVector.cpp +++ b/modules/core/test/math/testPoseVector.cpp @@ -49,6 +49,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void checkSize(const vpPoseVector &pose, const std::vector &ref) @@ -112,7 +116,7 @@ TEST_CASE("vpPoseVector constructor", "[vpColVector]") TEST_CASE("vpPoseVector copy constructor", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpPoseVector pose1(ref[0], ref[1], ref[2], ref[3], ref[4], ref[5]); vpPoseVector pose2(pose1); @@ -123,7 +127,7 @@ TEST_CASE("vpPoseVector copy constructor", "[vpColVector]") TEST_CASE("vpPoseVector object assignment", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpPoseVector pose1(ref[0], ref[1], ref[2], ref[3], ref[4], ref[5]); vpPoseVector pose2 = pose1; @@ -134,7 +138,7 @@ TEST_CASE("vpPoseVector object assignment", "[vpColVector]") TEST_CASE("vpPoseVector set", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpPoseVector pose1(ref[0], ref[1], ref[2], ref[3], ref[4], ref[5]); vpPoseVector pose2; @@ -146,7 +150,7 @@ TEST_CASE("vpPoseVector set", "[vpColVector]") TEST_CASE("vpPoseVector constructor t, tu", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpTranslationVector t(ref[0], ref[1], ref[2]); vpThetaUVector tu(ref[3], ref[4], ref[5]); @@ -158,7 +162,7 @@ TEST_CASE("vpPoseVector constructor t, tu", "[vpColVector]") TEST_CASE("vpPoseVector build t, tu", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpTranslationVector t(ref[0], ref[1], ref[2]); vpThetaUVector tu(ref[3], ref[4], ref[5]); @@ -171,7 +175,7 @@ TEST_CASE("vpPoseVector build t, tu", "[vpColVector]") TEST_CASE("vpPoseVector constructor vpHomogeneousMatrix", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpTranslationVector t(ref[0], ref[1], ref[2]); vpThetaUVector tu(ref[3], ref[4], ref[5]); vpHomogeneousMatrix M(t, tu); @@ -184,7 +188,7 @@ TEST_CASE("vpPoseVector constructor vpHomogeneousMatrix", "[vpColVector]") TEST_CASE("vpPoseVector build vpHomogeneousMatrix", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpTranslationVector t(ref[0], ref[1], ref[2]); vpThetaUVector tu(ref[3], ref[4], ref[5]); vpHomogeneousMatrix M(t, tu); @@ -198,7 +202,7 @@ TEST_CASE("vpPoseVector build vpHomogeneousMatrix", "[vpColVector]") TEST_CASE("vpPoseVector constructor t, R", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpTranslationVector t(ref[0], ref[1], ref[2]); vpThetaUVector tu(ref[3], ref[4], ref[5]); vpRotationMatrix R(tu); @@ -211,7 +215,7 @@ TEST_CASE("vpPoseVector constructor t, R", "[vpColVector]") TEST_CASE("vpPoseVector build t, R", "[vpColVector]") { - std::vector ref = {0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)}; + std::vector ref = { 0.1, 0.2, 0.3, vpMath::rad(10), vpMath::rad(20), vpMath::rad(30) }; vpTranslationVector t(ref[0], ref[1], ref[2]); vpThetaUVector tu(ref[3], ref[4], ref[5]); vpRotationMatrix R(tu); diff --git a/modules/core/test/math/testQuaternion.cpp b/modules/core/test/math/testQuaternion.cpp index 0993377aae..347fc32c92 100644 --- a/modules/core/test/math/testQuaternion.cpp +++ b/modules/core/test/math/testQuaternion.cpp @@ -46,6 +46,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + TEST_CASE("Quaternion interpolation", "[quaternion]") { const double angle0 = vpMath::rad(-37.14); diff --git a/modules/core/test/math/testRand.cpp b/modules/core/test/math/testRand.cpp index 3b9427b945..9943689b7e 100644 --- a/modules/core/test/math/testRand.cpp +++ b/modules/core/test/math/testRand.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { class vpUniRandOld @@ -106,11 +110,10 @@ class vpUniRandOld //! Default constructor. explicit vpUniRandOld(const long seed = 0) : a(16807), m(2147483647), q(127773), r(2836), normalizer(2147484721.0), x((seed) ? seed : 739806647) - { - } + { } //! Default destructor. - virtual ~vpUniRandOld(){}; + virtual ~vpUniRandOld() { }; //! Operator that allows to get a random value. double operator()() { return draw1(); } @@ -249,7 +252,7 @@ TEST_CASE("Check uniform draw", "[visp_rand]") double pi_error = pi - M_PI; std::cout << "Old ViSP vpUniRand implementation calculated pi: " << pi << " in " << chrono.getDurationMs() << " ms" - << std::endl; + << std::endl; std::cout << "pi error: " << pi_error << std::endl; CHECK(pi == Approx(M_PI).margin(0.005)); diff --git a/modules/core/test/math/testRobust.cpp b/modules/core/test/math/testRobust.cpp index 86697b5640..e043f8e442 100644 --- a/modules/core/test/math/testRobust.cpp +++ b/modules/core/test/math/testRobust.cpp @@ -50,6 +50,10 @@ // List of allowed command line options #define GETOPTARGS "cdho:" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, std::string ofilename); bool getOptions(int argc, const char **argv, std::string &ofilename); @@ -162,7 +166,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(ofilename); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ofilename); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << ofilename << std::endl; @@ -196,14 +201,16 @@ int main(int argc, const char **argv) while (x < 10) { if (fabs(x / sig) <= (4.6851)) { w = vpMath::sqr(1 - vpMath::sqr(x / (sig * 4.6851))); - } else { + } + else { w = 0; } f << x << " " << w << std::endl; x += 0.01; } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/math/testRotation.cpp b/modules/core/test/math/testRotation.cpp index db2202956e..58665da2ce 100644 --- a/modules/core/test/math/testRotation.cpp +++ b/modules/core/test/math/testRotation.cpp @@ -47,6 +47,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { vpThetaUVector generateThetaU(vpUniRand &rng) diff --git a/modules/core/test/math/testRowVector.cpp b/modules/core/test/math/testRowVector.cpp index 20731459c6..55fa99fa92 100644 --- a/modules/core/test/math/testRowVector.cpp +++ b/modules/core/test/math/testRowVector.cpp @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool test(const std::string &s, const vpRowVector &v, const std::vector &bench) { static unsigned int cpt = 0; diff --git a/modules/core/test/math/testSPC.cpp b/modules/core/test/math/testSPC.cpp index 7d8e3140f8..9ac1f22f10 100644 --- a/modules/core/test/math/testSPC.cpp +++ b/modules/core/test/math/testSPC.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool initializeShewhartTest(const float &mean, const float &stdev, const bool &verbose, const std::string &testName, vpStatisticalTestShewhart &tester) { const bool activateWECOrules = true; diff --git a/modules/core/test/math/testSvd.cpp b/modules/core/test/math/testSvd.cpp index 69dc066c56..1806a12691 100644 --- a/modules/core/test/math/testSvd.cpp +++ b/modules/core/test/math/testSvd.cpp @@ -50,6 +50,10 @@ // List of allowed command line options #define GETOPTARGS "cdn:i:pf:R:C:vh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! Print the program options. @@ -541,9 +545,9 @@ int main(int argc, const char *argv[]) std::cout << "Test does nothing since you dont't have Lapack, Eigen3 or OpenCV 3rd party" << std::endl; return EXIT_SUCCESS; #endif - } + } catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } -} + } diff --git a/modules/core/test/math/testTranslationVector.cpp b/modules/core/test/math/testTranslationVector.cpp index 1a6d1b436a..560aad3b63 100644 --- a/modules/core/test/math/testTranslationVector.cpp +++ b/modules/core/test/math/testTranslationVector.cpp @@ -45,6 +45,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool test(const std::string &s, const vpArray2D &A, const std::vector &bench) { static unsigned int cpt = 0; diff --git a/modules/core/test/math/testTwistMatrix.cpp b/modules/core/test/math/testTwistMatrix.cpp index 1437fe5ff8..105ccd356a 100644 --- a/modules/core/test/math/testTwistMatrix.cpp +++ b/modules/core/test/math/testTwistMatrix.cpp @@ -55,6 +55,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { vpTRACE("--------------------------"); vpTRACE("--- TEST vpVelocityTwistMatrix ---"); @@ -102,7 +105,8 @@ int main() vpTRACE("cv = cVe * ev:"); cv.print(std::cout, 6); return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/math/testXmlParserHomogeneousMatrix.cpp b/modules/core/test/math/testXmlParserHomogeneousMatrix.cpp index ffc21d3a3d..d273d997b9 100644 --- a/modules/core/test/math/testXmlParserHomogeneousMatrix.cpp +++ b/modules/core/test/math/testXmlParserHomogeneousMatrix.cpp @@ -44,6 +44,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if defined(VISP_HAVE_PUGIXML) #if defined(_WIN32) std::string tmp_dir = "C:/temp/"; diff --git a/modules/core/test/munkres/testMunkres.cpp b/modules/core/test/munkres/testMunkres.cpp index 9256e48a21..af5e2ac723 100644 --- a/modules/core/test/munkres/testMunkres.cpp +++ b/modules/core/test/munkres/testMunkres.cpp @@ -63,6 +63,10 @@ ostream &operator<<(ostream &os, const pair &val) #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + TEST_CASE("Check Munkres-based assignment", "[visp_munkres]") { auto testMunkres = [](const std::vector > &cost_matrix, @@ -231,7 +235,7 @@ int main() if (not testHorMat()) { return EXIT_FAILURE; - } +} return EXIT_SUCCESS; } diff --git a/modules/core/test/network/testClient.cpp b/modules/core/test/network/testClient.cpp index 099ed19642..67cb120c23 100644 --- a/modules/core/test/network/testClient.cpp +++ b/modules/core/test/network/testClient.cpp @@ -47,6 +47,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // inet_ntop() used in vpClient is not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP try { @@ -71,7 +74,8 @@ int main() std::cout << "Received : " << val << std::endl; } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } @@ -79,4 +83,4 @@ int main() std::cout << "This test doesn't work on win XP where inet_ntop() is not available" << std::endl; return EXIT_SUCCESS; #endif -} + } diff --git a/modules/core/test/network/testServer.cpp b/modules/core/test/network/testServer.cpp index 1d03c142fb..e165e3f601 100644 --- a/modules/core/test/network/testServer.cpp +++ b/modules/core/test/network/testServer.cpp @@ -47,6 +47,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #ifdef VISP_HAVE_FUNC_INET_NTOP try { int port = 35000; @@ -73,7 +76,8 @@ int main() } } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } @@ -81,4 +85,4 @@ int main() std::cout << "This test doesn't work on win XP where inet_ntop() is not available" << std::endl; return EXIT_SUCCESS; #endif -} + } diff --git a/modules/core/test/network/testUDPClient.cpp b/modules/core/test/network/testUDPClient.cpp index de36ca400b..ca0b9ba582 100644 --- a/modules/core/test/network/testUDPClient.cpp +++ b/modules/core/test/network/testUDPClient.cpp @@ -46,17 +46,21 @@ namespace { -struct vpDataType_t { +struct vpDataType_t +{ double double_val; int int_val; - vpDataType_t() : double_val(0.0), int_val(0) {} - vpDataType_t(double dbl, int i) : double_val(dbl), int_val(i) {} + vpDataType_t() : double_val(0.0), int_val(0) { } + vpDataType_t(double dbl, int i) : double_val(dbl), int_val(i) { } }; } // namespace int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // inet_ntop() used in vpUDPClient is not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP try { @@ -65,9 +69,10 @@ int main(int argc, char **argv) for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { servername = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip
(default: 127.0.0.1)] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -89,7 +94,7 @@ int main(int argc, char **argv) data_type.int_val = *reinterpret_cast(msg.c_str() + sizeof(data_type.double_val)); std::cout << "Receive from the server double_val: " << data_type.double_val << " ; int_val: " << data_type.int_val - << std::endl; + << std::endl; } // Send user message @@ -104,7 +109,8 @@ int main(int argc, char **argv) } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -114,4 +120,4 @@ int main(int argc, char **argv) (void)argv; return EXIT_SUCCESS; #endif -} + } diff --git a/modules/core/test/network/testUDPServer.cpp b/modules/core/test/network/testUDPServer.cpp index c5afecf488..21d1e56d36 100644 --- a/modules/core/test/network/testUDPServer.cpp +++ b/modules/core/test/network/testUDPServer.cpp @@ -49,17 +49,21 @@ namespace { -struct vpDataType_t { +struct vpDataType_t +{ double double_val; int int_val; - vpDataType_t() : double_val(0.0), int_val(0) {} - vpDataType_t(double dbl, int i) : double_val(dbl), int_val(i) {} + vpDataType_t() : double_val(0.0), int_val(0) { } + vpDataType_t(double dbl, int i) : double_val(dbl), int_val(i) { } }; } // namespace int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // inet_ntop() used in vpUDPClient is not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP try { @@ -74,9 +78,9 @@ int main() memcpy(&data_type.double_val, msg.c_str(), sizeof(data_type.double_val)); memcpy(&data_type.int_val, msg.c_str() + sizeof(data_type.double_val), sizeof(data_type.int_val)); std::cout << "Server received double_val: " << data_type.double_val << " ; int_val: " << data_type.int_val - << " from: " << hostInfo << std::endl; + << " from: " << hostInfo << std::endl; - // Get address and port +// Get address and port std::istringstream iss(hostInfo); std::vector tokens; std::copy(std::istream_iterator(iss), std::istream_iterator(), @@ -104,15 +108,18 @@ int main() std::copy(std::istream_iterator(iss), std::istream_iterator(), std::back_inserter(tokens)); server.send("Echo: " + msg, tokens[1], atoi(tokens[2].c_str())); - } else if (res == 0) { + } + else if (res == 0) { std::cout << "Receive timeout" << std::endl; - } else { + } + else { std::cerr << "Error server.receive()!" << std::endl; } } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -120,4 +127,4 @@ int main() std::cout << "This test doesn't work on win XP where inet_ntop() is not available" << std::endl; return EXIT_SUCCESS; #endif -} + } diff --git a/modules/core/test/tools/convert/testConvert.cpp b/modules/core/test/tools/convert/testConvert.cpp index f3573925ab..eea81ef634 100644 --- a/modules/core/test/tools/convert/testConvert.cpp +++ b/modules/core/test/tools/convert/testConvert.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool areSame(double a, double b) { return fabs(a - b) < std::numeric_limits::epsilon(); } void testConvertFromImagePointToPoint2f() diff --git a/modules/core/test/tools/cpu-features/testCPUFeatures.cpp b/modules/core/test/tools/cpu-features/testCPUFeatures.cpp index ea52c13617..94e973e1b0 100644 --- a/modules/core/test/tools/cpu-features/testCPUFeatures.cpp +++ b/modules/core/test/tools/cpu-features/testCPUFeatures.cpp @@ -64,13 +64,16 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpCPUFeatures::printCPUInfo(); std::cout << "checkSSE2: " << vpCPUFeatures::checkSSE2() << " ; VISP_HAVE_SSE2: " << VALUE(VISP_HAVE_SSE2) - << std::endl; + << std::endl; std::cout << "checkSSE3: " << vpCPUFeatures::checkSSE3() << " ; VISP_HAVE_SSE3: " << VALUE(VISP_HAVE_SSE3) - << std::endl; + << std::endl; std::cout << "checkSSSE3: " << vpCPUFeatures::checkSSSE3() << " ; VISP_HAVE_SSSE3: " << VALUE(VISP_HAVE_SSSE3) - << std::endl; + << std::endl; return EXIT_SUCCESS; } diff --git a/modules/core/test/tools/endian/testEndian.cpp b/modules/core/test/tools/endian/testEndian.cpp index 32b1c18053..100e9c15e6 100644 --- a/modules/core/test/tools/endian/testEndian.cpp +++ b/modules/core/test/tools/endian/testEndian.cpp @@ -41,9 +41,13 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + TEST_CASE("Test reinterpret_cast_uchar_to_uint16_LE", "[vpEndian_test]") { - unsigned char bitmap[] = {100, 110, 120, 130}; + unsigned char bitmap[] = { 100, 110, 120, 130 }; uint16_t val01 = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap); uint16_t val12 = vpEndian::reinterpret_cast_uchar_to_uint16_LE(bitmap + 2); diff --git a/modules/core/test/tools/geometry/testImageCircle.cpp b/modules/core/test/tools/geometry/testImageCircle.cpp index 757172fc86..394a79a1fe 100644 --- a/modules/core/test/tools/geometry/testImageCircle.cpp +++ b/modules/core/test/tools/geometry/testImageCircle.cpp @@ -45,6 +45,9 @@ bool equal(const float &actualVal, const float &theoreticalVal) int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif const float OFFSET = 5.f; const float WIDTH = 640.f; const float HEIGHT = 480.f; diff --git a/modules/core/test/tools/geometry/testPolygon.cpp b/modules/core/test/tools/geometry/testPolygon.cpp index 268106d49e..000cece60b 100644 --- a/modules/core/test/tools/geometry/testPolygon.cpp +++ b/modules/core/test/tools/geometry/testPolygon.cpp @@ -103,6 +103,9 @@ OPTIONS: \n\ */ bool getOptions(int argc, const char **argv, bool &opt_display, bool &opt_click, int &method) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif const char *optarg_; int c; while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { @@ -148,6 +151,9 @@ bool getOptions(int argc, const char **argv, bool &opt_display, bool &opt_click, int main(int argc, const char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { bool opt_display = true; bool opt_click = true; diff --git a/modules/core/test/tools/geometry/testPolygon2.cpp b/modules/core/test/tools/geometry/testPolygon2.cpp index d21c68bde1..97577f8e7f 100644 --- a/modules/core/test/tools/geometry/testPolygon2.cpp +++ b/modules/core/test/tools/geometry/testPolygon2.cpp @@ -50,6 +50,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + #ifdef VISP_HAVE_OPENCV TEST_CASE("Check OpenCV-bsed convex hull") { diff --git a/modules/core/test/tools/geometry/testRect.cpp b/modules/core/test/tools/geometry/testRect.cpp index 2f8dde3291..1c782f3832 100644 --- a/modules/core/test/tools/geometry/testRect.cpp +++ b/modules/core/test/tools/geometry/testRect.cpp @@ -39,6 +39,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpRect c(10.1, 15.05, 19.63, 7.84); vpRect a(c.getLeft() - 12.456, c.getTop() - 7.75, c.getWidth() + 12.456, c.getHeight() + 7.75); vpRect b(c.getLeft(), c.getTop(), c.getWidth() + 8.81, c.getHeight() + 14.57); diff --git a/modules/core/test/tools/geometry/testXmlParserRectOriented.cpp b/modules/core/test/tools/geometry/testXmlParserRectOriented.cpp index 17b5c4b7e5..e25f8bc8e1 100644 --- a/modules/core/test/tools/geometry/testXmlParserRectOriented.cpp +++ b/modules/core/test/tools/geometry/testXmlParserRectOriented.cpp @@ -44,6 +44,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if defined(VISP_HAVE_PUGIXML) #if defined(_WIN32) std::string tmp_dir = "C:/temp/"; diff --git a/modules/core/test/tools/histogram-with-dataset/testHistogram.cpp b/modules/core/test/tools/histogram-with-dataset/testHistogram.cpp index 1c818c46ea..c04bbb799f 100644 --- a/modules/core/test/tools/histogram-with-dataset/testHistogram.cpp +++ b/modules/core/test/tools/histogram-with-dataset/testHistogram.cpp @@ -54,6 +54,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:t:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /* Print the program options. diff --git a/modules/core/test/tools/io-with-dataset/testIoTools.cpp b/modules/core/test/tools/io-with-dataset/testIoTools.cpp index c31c4e36f3..bc46bf9874 100644 --- a/modules/core/test/tools/io-with-dataset/testIoTools.cpp +++ b/modules/core/test/tools/io-with-dataset/testIoTools.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { template void checkReadBinaryValue(std::ifstream &file, const T checkValue) @@ -84,7 +88,8 @@ int main(int argc, const char **argv) const char c = vpIoTools::separator; if (c == '\\') { std::cout << "The directory separator character is '" << c << "' (Windows platform)." << std::endl; - } else { + } + else { std::cout << "The directory separator character is '" << c << "' (Unix like platform)." << std::endl; } @@ -104,13 +109,13 @@ int main(int argc, const char **argv) std::string windowsPathnameStyle = "\\usr\\bin\\java"; std::cout << "Parent of " << windowsPathnameStyle << " is " << vpIoTools::getParent(windowsPathnameStyle) - << std::endl; + << std::endl; std::cout << "Name of " << windowsPathnameStyle << " is " << vpIoTools::getName(windowsPathnameStyle) << std::endl; std::string parent = "/usr/toto/", child = "\\blabla\\java"; std::cout << "parent=" << vpIoTools::path(parent) << " ; child=" << vpIoTools::path(child) << std::endl; std::cout << "Create file path from parent=" << parent << " and child=" << child << " is " - << vpIoTools::createFilePath(parent, child) << std::endl; + << vpIoTools::createFilePath(parent, child) << std::endl; std::string expandPath = "~/Documents/fictional directory/fictional file"; std::cout << "Path for " << expandPath << " is " << vpIoTools::path(expandPath) << std::endl; @@ -120,13 +125,13 @@ int main(int argc, const char **argv) std::cout << "Get parent with a filename=" << vpIoTools::getParent("my_file.txt") << std::endl; expandPath = "~/Documents/fictional dir/fictional file.txt"; std::cout << "Get name with a unix expand pathname " << expandPath << "=" << vpIoTools::getName(expandPath) - << std::endl; + << std::endl; std::cout << "Get parent with a unix expand pathname " << expandPath << "=" << vpIoTools::getParent(expandPath) - << std::endl; + << std::endl; pathname = "c:/dir"; std::cout << "pathname=" << vpIoTools::splitDrive(pathname).first << " ; " << vpIoTools::splitDrive(pathname).second - << std::endl; + << std::endl; std::cout << "isAbsolutePath of " << pathname << "=" << vpIoTools::isAbsolutePathname(pathname) << std::endl; @@ -147,118 +152,134 @@ int main(int argc, const char **argv) #if defined(_WIN32) if (strcmp(vpIoTools::splitDrive("c:\\foo\\bar").first.c_str(), "c:") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("c:\\foo\\bar").first << " should be=c:" << std::endl; } if (strcmp(vpIoTools::splitDrive("c:\\foo\\bar").second.c_str(), "\\foo\\bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("c:\\foo\\bar").second << " should be=\\foo\\bar" << std::endl; } if (strcmp(vpIoTools::splitDrive("c:/foo/bar").first.c_str(), "c:") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("c:/foo/bar").first << " should be=c:" << std::endl; } if (strcmp(vpIoTools::splitDrive("c:/foo/bar").second.c_str(), "/foo/bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("c:/foo/bar").second << " should be=/foo/bar" << std::endl; } if (strcmp(vpIoTools::splitDrive("\\\\conky\\mountpoint\\foo\\bar").first.c_str(), "\\\\conky\\mountpoint") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("\\\\conky\\mountpoint\\foo\\bar").first - << " should be=\\\\conky\\mountpoint" << std::endl; + << " should be=\\\\conky\\mountpoint" << std::endl; } if (strcmp(vpIoTools::splitDrive("\\\\conky\\mountpoint\\foo\\bar").second.c_str(), "\\foo\\bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("\\\\conky\\mountpoint\\foo\\bar").second << " should be=\\foo\\bar" - << std::endl; + << std::endl; } if (strcmp(vpIoTools::splitDrive("//conky/mountpoint/foo/bar").first.c_str(), "//conky/mountpoint") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("//conky/mountpoint/foo/bar").first << " should be=//conky/mountpoint" - << std::endl; + << std::endl; } if (strcmp(vpIoTools::splitDrive("//conky/mountpoint/foo/bar").second.c_str(), "/foo/bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("//conky/mountpoint/foo/bar").second << " should be=/foo/bar" - << std::endl; + << std::endl; } if (strcmp(vpIoTools::splitDrive("\\\\\\conky\\mountpoint\\foo\\bar").first.c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("\\\\\\conky\\mountpoint\\foo\\bar").first - << " should be=" << std::endl; + << " should be=" << std::endl; } if (strcmp(vpIoTools::splitDrive("\\\\\\conky\\mountpoint\\foo\\bar").second.c_str(), "\\\\\\conky\\mountpoint\\foo\\bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("\\\\\\conky\\mountpoint\\foo\\bar").second - << " should be=\\\\\\conky\\mountpoint\\foo\\bar" << std::endl; + << " should be=\\\\\\conky\\mountpoint\\foo\\bar" << std::endl; } if (strcmp(vpIoTools::splitDrive("///conky/mountpoint/foo/bar").first.c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("///conky/mountpoint/foo/bar").first << " should be=" << std::endl; } if (strcmp(vpIoTools::splitDrive("///conky/mountpoint/foo/bar").second.c_str(), "///conky/mountpoint/foo/bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("///conky/mountpoint/foo/bar").second - << " should be=///conky/mountpoint/foo/bar" << std::endl; + << " should be=///conky/mountpoint/foo/bar" << std::endl; } if (strcmp(vpIoTools::splitDrive("\\\\conky\\\\mountpoint\\foo\\bar").first.c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("\\\\conky\\\\mountpoint\\foo\\bar").first - << " should be=" << std::endl; + << " should be=" << std::endl; } if (strcmp(vpIoTools::splitDrive("\\\\conky\\\\mountpoint\\foo\\bar").second.c_str(), "\\\\conky\\\\mountpoint\\foo\\bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("\\\\conky\\\\mountpoint\\foo\\bar").second - << " should be=\\\\conky\\\\mountpoint\\foo\\bar" << std::endl; + << " should be=\\\\conky\\\\mountpoint\\foo\\bar" << std::endl; } if (strcmp(vpIoTools::splitDrive("//conky//mountpoint/foo/bar").first.c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("//conky//mountpoint/foo/bar").first << " should be=" << std::endl; } if (strcmp(vpIoTools::splitDrive("//conky//mountpoint/foo/bar").second.c_str(), "//conky//mountpoint/foo/bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::splitDrive("//conky//mountpoint/foo/bar").second - << " should be=//conky//mountpoint/foo/bar" << std::endl; + << " should be=//conky//mountpoint/foo/bar" << std::endl; } std::cout << "Test vpIoTools::splitDrive (Win32) - passed: " << nbOk << "/" << (nbOk + nbFail) << std::endl; @@ -266,7 +287,7 @@ int main(int argc, const char **argv) if (nbFail) { std::cerr << "Failed test: vpIoTools::splitDrive (Win32)" << std::endl; return EXIT_FAILURE; - } +} #endif // Test vpIoTools::getFileExtension @@ -276,76 +297,86 @@ int main(int argc, const char **argv) if (strcmp(vpIoTools::getFileExtension("foo.ext").c_str(), ".ext") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("foo.ext") << " should be=.ext" << std::endl; } if (strcmp(vpIoTools::getFileExtension("/foo/foo.ext").c_str(), ".ext") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("/foo/foo.ext") << " should be=.ext" << std::endl; } if (strcmp(vpIoTools::getFileExtension(".ext").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension(".ext") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("\\foo.ext\\foo").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("\\foo.ext\\foo") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("foo.ext\\").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("foo.ext\\") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("foo.bar.ext").c_str(), ".ext") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("foo.bar.ext") << " should be=.ext" << std::endl; } if (strcmp(vpIoTools::getFileExtension("xx/foo.bar.ext").c_str(), ".ext") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("xx/foo.bar.ext") << " should be=.ext" << std::endl; } if (strcmp(vpIoTools::getFileExtension("xx\\foo.bar.ext").c_str(), ".ext") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("xx\\foo.bar.ext") << " should be=.ext" << std::endl; } if (strcmp(vpIoTools::getFileExtension("c:a/b\\c.d").c_str(), ".d") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("c:a/b\\c.d") << " should be=.d" << std::endl; } std::cout << "Test vpIoTools::getFileExtension (WIN32 platform) - passed: " << nbOk << "/" << (nbOk + nbFail) - << std::endl; + << std::endl; if (nbFail) { std::cerr << "Failed test: vpIoTools::getFileExtension (WIN32 platform)" << std::endl; @@ -357,90 +388,102 @@ int main(int argc, const char **argv) if (strcmp(vpIoTools::getFileExtension("foo.bar").c_str(), ".bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("foo.bar") << " should be=.bar" << std::endl; } if (strcmp(vpIoTools::getFileExtension("foo.boo.bar").c_str(), ".bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("foo.boo.bar") << " should be=.bar" << std::endl; } if (strcmp(vpIoTools::getFileExtension("foo.boo.biff.bar").c_str(), ".bar") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("foo.boo.biff.bar") << " should be=.bar" << std::endl; } if (strcmp(vpIoTools::getFileExtension(".csh.rc").c_str(), ".rc") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension(".csh.rc") << " should be=.rc" << std::endl; } if (strcmp(vpIoTools::getFileExtension("nodots").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("nodots") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension(".cshrc").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension(".cshrc") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("...manydots").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("...manydots") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("...manydots.ext").c_str(), ".ext") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("...manydots.ext") << " should be=.ext" << std::endl; } if (strcmp(vpIoTools::getFileExtension(".").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension(".") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("..").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("..") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("........").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("........") << " should be=" << std::endl; } if (strcmp(vpIoTools::getFileExtension("").c_str(), "") == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" << vpIoTools::getFileExtension("") << " should be=" << std::endl; } std::cout << "Test vpIoTools::getFileExtension (Unix-like platform) - passed: " << nbOk << "/" << (nbOk + nbFail) - << std::endl; + << std::endl; #endif // Test makeDirectory() @@ -511,7 +554,8 @@ int main(int argc, const char **argv) std::cerr << "Error: cannot remove directory: " << tmp_dir << "/test_directory1" << std::endl; return EXIT_FAILURE; } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -548,7 +592,8 @@ int main(int argc, const char **argv) return EXIT_FAILURE; } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -596,7 +641,8 @@ int main(int argc, const char **argv) return EXIT_FAILURE; } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -639,7 +685,7 @@ int main(int argc, const char **argv) nbFail = res ? nbFail + 1 : nbFail; std::cout << "Test vpIoTools::isSamePathname (WIN32 platform) - passed: " << nbOk << "/" << (nbOk + nbFail) - << std::endl; + << std::endl; if (nbFail) { std::cerr << "Failed test: vpIoTools::isSamePathname (WIN32 platform)" << std::endl; return EXIT_FAILURE; @@ -692,16 +738,16 @@ int main(int argc, const char **argv) nbFail = res ? nbFail : nbFail + 1; std::cout << "Test vpIoTools::isSamePathname (Unix platform) - passed: " << nbOk << "/" << (nbOk + nbFail) - << std::endl; + << std::endl; - // Delete test directory +// Delete test directory if (!vpIoTools::remove("/tmp/" + username + "/test")) { std::cerr << "Cannot remove directory: " - << "/tmp/" << username << "/test" << std::endl; + << "/tmp/" << username << "/test" << std::endl; } if (!vpIoTools::remove("/tmp/" + username + "/dummy dir")) { std::cerr << "Cannot remove directory: " - << "/tmp/" << username << "/dummy dir" << std::endl; + << "/tmp/" << username << "/dummy dir" << std::endl; } if (nbFail) { @@ -727,8 +773,8 @@ int main(int argc, const char **argv) // Test checkFilename() vpIoTools::makeDirectory("/tmp/" + username + "/directory (1) with ' quote and spaces"); path1 = "/tmp/" + username + - "/directory (1) with ' quote and spaces/file with ' quote (1) and " - "spaces.txt"; + "/directory (1) with ' quote and spaces/file with ' quote (1) and " + "spaces.txt"; dummy_file.open(path1.c_str()); if (!dummy_file.is_open()) { return EXIT_SUCCESS; @@ -744,13 +790,13 @@ int main(int argc, const char **argv) // Delete test directory if (!vpIoTools::remove("/tmp/" + username + "/directory (1) with ' quote and spaces")) { std::cerr << "Cannot remove directory: " - << "/tmp/" << username << "/directory (1) with ' quote and spaces" << std::endl; + << "/tmp/" << username << "/directory (1) with ' quote and spaces" << std::endl; } // Test endianness { std::string filename_endianness = - vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "endianness/test_endianness_little_endian.bin"); + vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "endianness/test_endianness_little_endian.bin"); std::ifstream file_endianness(filename_endianness.c_str(), std::ios::in | std::ios::binary); if (file_endianness.is_open()) { checkReadBinaryValue(file_endianness, std::numeric_limits::min()); @@ -772,7 +818,8 @@ int main(int argc, const char **argv) checkReadBinaryValue(file_endianness, std::numeric_limits::max()); std::cout << "Test endianness is ok." << std::endl; - } else { + } + else { std::cout << "Cannot open file: " << filename_endianness << std::endl; } } @@ -784,52 +831,56 @@ int main(int argc, const char **argv) std::string testString = std::string("Yolo-V3"); std::string expectedLower = std::string("yolo-v3"); std::string expectedUpper = std::string("YOLO-V3"); - #if defined(_WIN32) +#if defined(_WIN32) if (strcmp(vpIoTools::toLowerCase(testString).c_str(), expectedLower.c_str()) == 0) { nbOk++; - } else { + } + else { nbFail++; std::cout << "Fail=" < #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { std::string createTmpDir() diff --git a/modules/core/test/tools/serial/testSerialRead.cpp b/modules/core/test/tools/serial/testSerialRead.cpp index 1253e5a1b6..48c4bf434a 100644 --- a/modules/core/test/tools/serial/testSerialRead.cpp +++ b/modules/core/test/tools/serial/testSerialRead.cpp @@ -46,6 +46,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if !defined(_WIN32) std::string port; @@ -55,7 +58,8 @@ int main(int argc, char **argv) port = std::string(argv[i + 1]); else if (std::string(argv[i]) == "--baud") { baud = (unsigned long)atol(argv[i + 1]); - } else if (std::string(argv[i]) == "--help") { + } + else if (std::string(argv[i]) == "--help") { std::cout << "\nUsage: " << argv[0] << " [--port ] [--baud ] [--help]\n" << std::endl; return EXIT_SUCCESS; } @@ -84,4 +88,4 @@ int main(int argc, char **argv) std::cout << "Serial test is only working on unix-like OS." << std::endl; #endif return EXIT_SUCCESS; -} + } diff --git a/modules/core/test/tools/serial/testSerialWrite.cpp b/modules/core/test/tools/serial/testSerialWrite.cpp index 6698fc8649..9b12439afc 100644 --- a/modules/core/test/tools/serial/testSerialWrite.cpp +++ b/modules/core/test/tools/serial/testSerialWrite.cpp @@ -44,6 +44,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if !defined(_WIN32) std::string port; @@ -53,7 +56,8 @@ int main(int argc, char **argv) port = std::string(argv[i + 1]); else if (std::string(argv[i]) == "--baud") { baud = (unsigned long)atol(argv[i + 1]); - } else if (std::string(argv[i]) == "--help") { + } + else if (std::string(argv[i]) == "--help") { std::cout << "\nUsage: " << argv[0] << " [--port ] [--baud ] [--help]\n" << std::endl; return EXIT_SUCCESS; } diff --git a/modules/core/test/tools/time/testTime.cpp b/modules/core/test/tools/time/testTime.cpp index cdf8d9f4ae..c58fef4fb5 100644 --- a/modules/core/test/tools/time/testTime.cpp +++ b/modules/core/test/tools/time/testTime.cpp @@ -58,6 +58,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if !defined(WINRT) try { double v = 0; @@ -123,7 +126,8 @@ int main() std::cout << "t8-t6: ; chrono: " << chrono.getDurationMs() << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/core/test/tools/xml/testXmlParser.cpp b/modules/core/test/tools/xml/testXmlParser.cpp index 5c667d327d..23fbfb868e 100644 --- a/modules/core/test/tools/xml/testXmlParser.cpp +++ b/modules/core/test/tools/xml/testXmlParser.cpp @@ -62,6 +62,10 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! * \class vpExampleDataParser * \brief Class example used to show how to implement a xml parser based on the From 024272d84afbd85762c9eb83db32b97cd3bd5d28 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Wed, 22 May 2024 17:09:54 +0200 Subject: [PATCH 07/64] [WIP] Worked on the detection module. There might be a problem with the nested classes in vpDetectorDNNOpenCV.h --- .../visp3/detection/vpDetectorAprilTag.h | 17 +- .../include/visp3/detection/vpDetectorBase.h | 2 +- .../visp3/detection/vpDetectorDNNOpenCV.h | 365 +++--------------- .../detection/vpDetectorDataMatrixCode.h | 8 +- .../include/visp3/detection/vpDetectorFace.h | 8 +- .../visp3/detection/vpDetectorQRCode.h | 8 +- .../src/barcode/vpDetectorDataMatrixCode.cpp | 16 +- .../src/barcode/vpDetectorQRCode.cpp | 9 +- .../detection/src/dnn/vpDetectorDNNOpenCV.cpp | 315 +++++++++++++++ modules/detection/src/face/vpDetectorFace.cpp | 8 +- .../detection/src/tag/vpDetectorAprilTag.cpp | 16 +- modules/detection/src/vpDetectorBase.cpp | 2 +- .../perfApriltagDetection.cpp | 12 +- .../apriltag-with-dataset/testAprilTag.cpp | 4 + 14 files changed, 460 insertions(+), 330 deletions(-) diff --git a/modules/detection/include/visp3/detection/vpDetectorAprilTag.h b/modules/detection/include/visp3/detection/vpDetectorAprilTag.h index 8cb4ee8bd1..0c26ca46d2 100644 --- a/modules/detection/include/visp3/detection/vpDetectorAprilTag.h +++ b/modules/detection/include/visp3/detection/vpDetectorAprilTag.h @@ -46,11 +46,22 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME { #endif +class vpDetectorAprilTag; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +void swap(VISP_NAMESPACE_ADDRESSING vpDetectorAprilTag &o1, VISP_NAMESPACE_ADDRESSING vpDetectorAprilTag &o2); +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpDetectorAprilTag * \ingroup group_detection_tag @@ -305,7 +316,7 @@ class VISP_EXPORT vpDetectorAprilTag : public vpDetectorBase m_displayTagThickness = thickness; } - friend void swap(vpDetectorAprilTag &o1, vpDetectorAprilTag &o2); + friend void ::swap(vpDetectorAprilTag &o1, vpDetectorAprilTag &o2); void setZAlignedWithCameraAxis(bool zAlignedWithCameraFrame); diff --git a/modules/detection/include/visp3/detection/vpDetectorBase.h b/modules/detection/include/visp3/detection/vpDetectorBase.h index 19d663fae2..e1fa9bd49e 100644 --- a/modules/detection/include/visp3/detection/vpDetectorBase.h +++ b/modules/detection/include/visp3/detection/vpDetectorBase.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h index fa20745bef..6029d01357 100644 --- a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h +++ b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h @@ -52,10 +52,30 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpDetectorDNNOpenCV; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network); + #ifdef VISP_HAVE_NLOHMANN_JSON #include +// Forward declaration to have the methods in the global namespace +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network); +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network); #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpDetectorDNNOpenCV * \ingroup group_detection_dnn @@ -175,295 +195,7 @@ class VISP_EXPORT vpDetectorDNNOpenCV * \struct NetConfig * \brief Structure containing some information required for the configuration of a \b vpDetectorDNNOpenCV object. */ - typedef class NetConfig - { - private: - float m_confThreshold; /*!< Threshold to filter detections by confidence.*/ - float m_nmsThreshold; /*!< Threshold for Non-Maximum Suppression.*/ - std::vector m_classNames;/*!< Vector containing the names of the different classes the DNN can detect.*/ - cv::Size m_inputSize; /*!< Size of the images the DNN can manipulate. The input images will be resized to match these dimensions.*/ - double m_filterSizeRatio; /*!< Size ratio used by the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods. - If <= 0., the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods are not used.*/ - cv::Scalar m_mean; /*!< Values for mean subtraction.*/ - double m_scaleFactor; /*!< Scale factor to normalize pixel values.*/ - bool m_swapRB; /* 0"); - } - - config.m_nmsThreshold = j.value("nmsThreshold", config.m_nmsThreshold); - if (config.m_nmsThreshold <= 0) { - throw vpException(vpException::badValue, "Confidence threshold should be > 0"); - } - - config.m_filterSizeRatio = j.value("filterSizeRatio", config.m_filterSizeRatio); - - config.m_classNames = j.value("classNames", config.m_classNames); - - std::pair resolution = j.value("resolution", std::pair(config.m_inputSize.width, config.m_inputSize.height)); - config.m_inputSize.width = resolution.first; - config.m_inputSize.height = resolution.second; - - std::vector v_mean = j.value("mean", std::vector({ config.m_mean[0], config.m_mean[1], config.m_mean[2] })); - if (v_mean.size() != 3) { - throw(vpException(vpException::dimensionError, "Mean should have size = 3")); - } - config.m_mean = cv::Scalar(v_mean[0], v_mean[1], v_mean[2]); - - config.m_scaleFactor = j.value("scale", config.m_scaleFactor); - config.m_swapRB = j.value("swapRB", config.m_swapRB); - config.m_parsingMethodType = dnnResultsParsingTypeFromString(j.value("parsingType", dnnResultsParsingTypeToString(config.m_parsingMethodType))); - config.m_modelFilename = j.value("modelFile", config.m_modelFilename); - config.m_modelConfigFilename = j.value("configurationFile", config.m_modelConfigFilename); - config.m_framework = j.value("framework", config.m_framework); - } - - /** - * \brief Parse a vpDetectorDNNOpenCV::NetConfig into JSON format. - * - * \param j A JSON parser object. - * \param config The vpDetectorDNNOpenCV::NetConfig that must be parsed into JSON format. - */ - friend inline void to_json(nlohmann::json &j, const NetConfig &config) - { - std::pair resolution = { config.m_inputSize.width, config.m_inputSize.height }; - std::vector v_mean = { config.m_mean[0], config.m_mean[1], config.m_mean[2] }; - j = nlohmann::json { - {"confidenceThreshold", config.m_confThreshold } , - {"nmsThreshold" , config.m_nmsThreshold } , - {"filterSizeRatio" , config.m_filterSizeRatio} , - {"classNames" , config.m_classNames } , - {"resolution" , resolution } , - {"mean" , v_mean } , - {"scale" , config.m_scaleFactor } , - {"swapRB" , config.m_swapRB } , - {"parsingType" , dnnResultsParsingTypeToString(config.m_parsingMethodType) }, - {"modelFile" , config.m_modelFilename } , - {"configurationFile" , config.m_modelConfigFilename } , - {"framework" , config.m_framework } - }; - } -#endif - - public: - /** - * \brief Parse the file containing the list of classes the DNN can detect. - * These classes can be written either as a YAML array (i.e. ["classname_0", ... ,"classname_last"]) - * or with one classname by row (without quotes). - * - * For example, in the case of a yaml file called `my-classes.yaml`, one content could be: - \verbatim - $ cat my-classes.yaml - [ "person", "bicycle", "car"] - \endverbatim - * - * And in the case of a text file called `my-classes.txt`, similar content could be: - \verbatim - $ cat my-classes.txt - person - bicycle - car - \endverbatim - * - * \param filename The path towards the file containing the list of classes the DNN can detect. - * \return std::vector The list of classes the DNN can detect. - */ - inline static std::vector parseClassNamesFile(const std::string &filename) - { - std::vector classNames; - std::ifstream ifs(filename); - std::string line; - while (getline(ifs, line)) { - if (line.find("[") == std::string::npos) { - classNames.push_back(line); - } - else { - std::string lineWithoutBracket; - if (line.find("[") != std::string::npos) { - lineWithoutBracket = line.substr(line.find("[") + 1, line.size() - 2); // Remove opening and closing brackets - } - - while (!lineWithoutBracket.empty()) { - std::string className; - auto start_pos = lineWithoutBracket.find("\""); - auto end_pos = lineWithoutBracket.find("\"", start_pos + 1); - className = lineWithoutBracket.substr(start_pos + 1, end_pos - (start_pos + 1)); - if (!className.empty()) { - classNames.push_back(className); - lineWithoutBracket = lineWithoutBracket.substr(end_pos + 1); - } - } - } - } - return classNames; - } - - /** - * \brief Default constructor of the structure \b vpDetectorDNNOpenCV::NetConfig , required for JSON serialization/deserialization. - */ - inline NetConfig() - : m_confThreshold(0.5f) - , m_nmsThreshold(0.4f) - , m_classNames() - , m_inputSize(300, 300) - , m_filterSizeRatio(0.) - , m_mean(127.5, 127.5, 127.5) - , m_scaleFactor(2.0 / 255.0) - , m_swapRB(true) - , m_parsingMethodType(vpDetectorDNNOpenCV::USER_SPECIFIED) - , m_modelFilename() - , m_modelConfigFilename() - , m_framework() - { - - } - - inline NetConfig(const NetConfig &config) - : m_confThreshold(config.m_confThreshold) - , m_nmsThreshold(config.m_nmsThreshold) - , m_classNames(config.m_classNames) - , m_inputSize(config.m_inputSize.width, config.m_inputSize.height) - , m_filterSizeRatio(config.m_filterSizeRatio) - , m_mean(cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2])) - , m_scaleFactor(config.m_scaleFactor) - , m_swapRB(config.m_swapRB) - , m_parsingMethodType(config.m_parsingMethodType) - , m_modelFilename(config.m_modelFilename) - , m_modelConfigFilename(config.m_modelConfigFilename) - , m_framework(config.m_framework) - { - - } - - /** - * \brief Construct a new Net Config object - * - * \param confThresh The confidence threshold to keep a detection. - * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. - * \param classNames A vector containing the list of classes the DNN can detect. - * \param dnnInputSize The size of the input that the DNN is expecting. - * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput - * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). - * \param mean The mean value we must deduce to each color channel of the image. - * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. - * \param swapRB If true, will swap the red and blue channel of the input image. - * \param parsingType The type of parsing method to use to interpret the DNN raw results. - * \param modelFilename The path towards the DNN weights. - * \param configFilename The path towards the additional DNN configuration file potentially needed. - * \param framework The type of framework used to store the weights of the DNN. - */ - inline NetConfig(float confThresh, const float &nmsThresh, const std::vector &classNames, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. - , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true - , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") - : m_confThreshold(confThresh) - , m_nmsThreshold(nmsThresh) - , m_classNames(classNames) - , m_inputSize(dnnInputSize) - , m_filterSizeRatio(filterSizeRatio) - , m_mean(mean) - , m_scaleFactor(scaleFactor) - , m_swapRB(swapRB) - , m_parsingMethodType(parsingType) - , m_modelFilename(modelFilename) - , m_modelConfigFilename(configFilename) - , m_framework(framework) - { } - - /** - * \brief Construct a new Net Config object - * - * \param confThresh The confidence threshold to keep a detection. - * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. - * \param classNamesFile The path towards the file containing the classes names, written as a YAML string array or one class name by line. - * \param dnnInputSize The size of the input that the DNN is expecting. - * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput - * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). - * \param mean The mean value we must deduce to each color channel of the image. - * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. - * \param swapRB If true, will swap the red and blue channel of the input image. - * \param parsingType The type of parsing method to use to interpret the DNN raw results. - * \param modelFilename The path towards the DNN weights. - * \param configFilename The path towards the additional DNN configuration file potentially needed. - * \param framework The type of framework used to store the weights of the DNN. - */ - inline NetConfig(const float &confThresh, const float &nmsThresh, const std::string &classNamesFile, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. - , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true - , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") - : m_confThreshold(confThresh) - , m_nmsThreshold(nmsThresh) - , m_inputSize(dnnInputSize) - , m_filterSizeRatio(filterSizeRatio) - , m_mean(mean) - , m_scaleFactor(scaleFactor) - , m_swapRB(swapRB) - , m_parsingMethodType(parsingType) - , m_modelFilename(modelFilename) - , m_modelConfigFilename(configFilename) - , m_framework(framework) - { - m_classNames = parseClassNamesFile(classNamesFile); - } - - inline std::string toString() const - { - std::string text; - text += "Model : " + m_modelFilename + "\n"; - text += "Type : " + vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(m_parsingMethodType) + "\n"; - text += "Config (optional): " + (m_modelConfigFilename.empty() ? "\"None\"" : m_modelConfigFilename) + "\n"; - text += "Framework (optional): " + (m_framework.empty() ? "\"None\"" : m_framework) + "\n"; - text += "Width x Height : " + std::to_string(m_inputSize.width) + " x " + std::to_string(m_inputSize.height) + "\n"; - text += "Mean RGB : " + std::to_string(m_mean[0]) + " " + std::to_string(m_mean[1]) + " " + std::to_string(m_mean[2]) + "\n"; - text += "Scale : " + std::to_string(m_scaleFactor) + "\n"; - text += "Swap RB? : " + (m_swapRB ? std::string("true") : std::string("false")) + "\n"; - text += "Confidence threshold : " + std::to_string(m_confThreshold) + "\n"; - text += "NMS threshold : " + std::to_string(m_nmsThreshold) + "\n"; - text += "Filter threshold : " + - (m_filterSizeRatio > std::numeric_limits::epsilon() ? std::to_string(m_filterSizeRatio) - : "disabled") + "\n"; - return text; - } - - friend inline std::ostream &operator<<(std::ostream &os, const NetConfig &config) - { - os << config.toString(); - return os; - } - - NetConfig &operator=(const NetConfig &config) - { - m_confThreshold = config.m_confThreshold; - m_nmsThreshold = config.m_nmsThreshold; - m_classNames = config.m_classNames; - m_inputSize = cv::Size(config.m_inputSize.width, config.m_inputSize.height); - m_filterSizeRatio = config.m_filterSizeRatio; - m_mean = cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2]); - m_scaleFactor = config.m_scaleFactor; - m_swapRB = config.m_swapRB; - m_parsingMethodType = config.m_parsingMethodType; - m_modelFilename = config.m_modelFilename; - m_modelConfigFilename = config.m_modelConfigFilename; - m_framework = config.m_framework; - return *this; - } - - friend vpDetectorDNNOpenCV; - } NetConfig; + class NetConfig; static std::string getAvailableDnnResultsParsingTypes(); static std::string dnnResultsParsingTypeToString(const DNNResultsParsingType &type); @@ -514,10 +246,7 @@ class VISP_EXPORT vpDetectorDNNOpenCV * \param j The JSON object, resulting from the parsing of a JSON file. * \param network The network, that will be initialized from the JSON data. */ - friend inline void from_json(const nlohmann::json &j, vpDetectorDNNOpenCV &network) - { - network.m_netConfig = j.value("networkSettings", network.m_netConfig); - } + friend inline void ::from_json(const nlohmann::json &j, vpDetectorDNNOpenCV &network); /** * \brief Parse the network configuration into JSON format. @@ -525,19 +254,10 @@ class VISP_EXPORT vpDetectorDNNOpenCV * \param j The JSON parser. * \param network The network we want to parse the configuration. */ - friend inline void to_json(nlohmann::json &j, const vpDetectorDNNOpenCV &network) - { - j = nlohmann::json { - {"networkSettings", network.m_netConfig} - }; - } + friend inline void ::to_json(nlohmann::json &j, const vpDetectorDNNOpenCV &network); #endif - friend inline std::ostream &operator<<(std::ostream &os, const vpDetectorDNNOpenCV &network) - { - os << network.m_netConfig; - return os; - } + friend inline std::ostream &::operator<<(std::ostream &os, const vpDetectorDNNOpenCV &network); protected: #if (VISP_HAVE_OPENCV_VERSION == 0x030403) @@ -615,5 +335,42 @@ vpDetectorDNNOpenCV::DetectedFeatures2D::display(const vpImage< Type > &img, con ss << "(" << std::setprecision(4) << m_score * 100. << "%)"; vpDisplay::displayText(img, m_bbox.getTopRight(), ss.str(), color); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +inline std::ostream &::operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) +{ + os << network.m_netConfig; + return os; +} + +#ifdef VISP_HAVE_NLOHMANN_JSON + /** + * \brief Read the network configuration from JSON. All values are optional and if an argument is not present, + * the default value defined in the constructor is kept + * + * \param j The JSON object, resulting from the parsing of a JSON file. + * \param network The network, that will be initialized from the JSON data. + */ +inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) +{ + network.m_netConfig = j.value("networkSettings", network.m_netConfig); +} + +/** + * \brief Parse the network configuration into JSON format. + * + * \param j The JSON parser. + * \param network The network we want to parse the configuration. + */ +inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) +{ + j = nlohmann::json { + {"networkSettings", network.m_netConfig} + }; +} +#endif + #endif #endif diff --git a/modules/detection/include/visp3/detection/vpDetectorDataMatrixCode.h b/modules/detection/include/visp3/detection/vpDetectorDataMatrixCode.h index 89b814aaa3..7208b5d97f 100644 --- a/modules/detection/include/visp3/detection/vpDetectorDataMatrixCode.h +++ b/modules/detection/include/visp3/detection/vpDetectorDataMatrixCode.h @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpDetectorDataMatrixCode * \ingroup group_detection_barcode @@ -112,6 +116,8 @@ class VISP_EXPORT vpDetectorDataMatrixCode : public vpDetectorBase vpDetectorDataMatrixCode(); bool detect(const vpImage &I) vp_override; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/detection/include/visp3/detection/vpDetectorFace.h b/modules/detection/include/visp3/detection/vpDetectorFace.h index 392e67ff73..24342d3c6c 100644 --- a/modules/detection/include/visp3/detection/vpDetectorFace.h +++ b/modules/detection/include/visp3/detection/vpDetectorFace.h @@ -46,6 +46,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpDetectorFace * \ingroup group_detection_face @@ -96,6 +100,8 @@ class VISP_EXPORT vpDetectorFace : public vpDetectorBase bool detect(const cv::Mat &frame_gray); void setCascadeClassifierFile(const std::string &filename); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/detection/include/visp3/detection/vpDetectorQRCode.h b/modules/detection/include/visp3/detection/vpDetectorQRCode.h index 654283a1d8..1527ead1d0 100644 --- a/modules/detection/include/visp3/detection/vpDetectorQRCode.h +++ b/modules/detection/include/visp3/detection/vpDetectorQRCode.h @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpDetectorQRCode * \ingroup group_detection_barcode @@ -115,6 +119,8 @@ class VISP_EXPORT vpDetectorQRCode : public vpDetectorBase vpDetectorQRCode(); bool detect(const vpImage &I) vp_override; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/detection/src/barcode/vpDetectorDataMatrixCode.cpp b/modules/detection/src/barcode/vpDetectorDataMatrixCode.cpp index c71573fe15..7cfca2610f 100644 --- a/modules/detection/src/barcode/vpDetectorDataMatrixCode.cpp +++ b/modules/detection/src/barcode/vpDetectorDataMatrixCode.cpp @@ -43,6 +43,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor that does nothing except setting detection timeout to 50ms. This value could be changed using setTimeout(). @@ -109,11 +113,13 @@ bool vpDetectorDataMatrixCode::detect(const vpImage &I) m_message.push_back((const char *)msg->output); m_nb_objects++; - } else { + } + else { end = true; } dmtxMessageDestroy(&msg); - } else { + } + else { end = true; } dmtxRegionDestroy(®); @@ -127,9 +133,11 @@ bool vpDetectorDataMatrixCode::detect(const vpImage &I) } return detected; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: // libvisp_core.a(vpDetectorDataMatrixCode.cpp.o) has no symbols -void dummy_vpDetectorDataMatrixCode(){}; +void dummy_vpDetectorDataMatrixCode() { }; #endif diff --git a/modules/detection/src/barcode/vpDetectorQRCode.cpp b/modules/detection/src/barcode/vpDetectorQRCode.cpp index 81c904b6fd..8e3ed7fd37 100644 --- a/modules/detection/src/barcode/vpDetectorQRCode.cpp +++ b/modules/detection/src/barcode/vpDetectorQRCode.cpp @@ -39,6 +39,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. */ @@ -88,8 +92,11 @@ bool vpDetectorQRCode::detect(const vpImage &I) return detected; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpDetectorQRCode.cpp.o) has // no symbols -void dummy_vpDetectorQRCode(){}; +void dummy_vpDetectorQRCode() { }; #endif diff --git a/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp b/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp index f9ad489009..d7ee9865d1 100644 --- a/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp +++ b/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp @@ -43,6 +43,318 @@ #include #include + +// Forward declaration to have the methods in the global namespace +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config); +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config); +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config); + +class VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig +{ +private: + float m_confThreshold; /*!< Threshold to filter detections by confidence.*/ + float m_nmsThreshold; /*!< Threshold for Non-Maximum Suppression.*/ + std::vector m_classNames;/*!< Vector containing the names of the different classes the DNN can detect.*/ + cv::Size m_inputSize; /*!< Size of the images the DNN can manipulate. The input images will be resized to match these dimensions.*/ + double m_filterSizeRatio; /*!< Size ratio used by the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods. + If <= 0., the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods are not used.*/ + cv::Scalar m_mean; /*!< Values for mean subtraction.*/ + double m_scaleFactor; /*!< Scale factor to normalize pixel values.*/ + bool m_swapRB; /* The list of classes the DNN can detect. + */ + inline static std::vector parseClassNamesFile(const std::string &filename) + { + std::vector classNames; + std::ifstream ifs(filename); + std::string line; + while (getline(ifs, line)) { + if (line.find("[") == std::string::npos) { + classNames.push_back(line); + } + else { + std::string lineWithoutBracket; + if (line.find("[") != std::string::npos) { + lineWithoutBracket = line.substr(line.find("[") + 1, line.size() - 2); // Remove opening and closing brackets + } + + while (!lineWithoutBracket.empty()) { + std::string className; + auto start_pos = lineWithoutBracket.find("\""); + auto end_pos = lineWithoutBracket.find("\"", start_pos + 1); + className = lineWithoutBracket.substr(start_pos + 1, end_pos - (start_pos + 1)); + if (!className.empty()) { + classNames.push_back(className); + lineWithoutBracket = lineWithoutBracket.substr(end_pos + 1); + } + } + } + } + return classNames; + } + + /** + * \brief Default constructor of the structure \b vpDetectorDNNOpenCV::NetConfig , required for JSON serialization/deserialization. + */ + inline NetConfig() + : m_confThreshold(0.5f) + , m_nmsThreshold(0.4f) + , m_classNames() + , m_inputSize(300, 300) + , m_filterSizeRatio(0.) + , m_mean(127.5, 127.5, 127.5) + , m_scaleFactor(2.0 / 255.0) + , m_swapRB(true) + , m_parsingMethodType(vpDetectorDNNOpenCV::USER_SPECIFIED) + , m_modelFilename() + , m_modelConfigFilename() + , m_framework() + { + + } + + inline NetConfig(const NetConfig &config) + : m_confThreshold(config.m_confThreshold) + , m_nmsThreshold(config.m_nmsThreshold) + , m_classNames(config.m_classNames) + , m_inputSize(config.m_inputSize.width, config.m_inputSize.height) + , m_filterSizeRatio(config.m_filterSizeRatio) + , m_mean(cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2])) + , m_scaleFactor(config.m_scaleFactor) + , m_swapRB(config.m_swapRB) + , m_parsingMethodType(config.m_parsingMethodType) + , m_modelFilename(config.m_modelFilename) + , m_modelConfigFilename(config.m_modelConfigFilename) + , m_framework(config.m_framework) + { + + } + + /** + * \brief Construct a new Net Config object + * + * \param confThresh The confidence threshold to keep a detection. + * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. + * \param classNames A vector containing the list of classes the DNN can detect. + * \param dnnInputSize The size of the input that the DNN is expecting. + * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput + * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). + * \param mean The mean value we must deduce to each color channel of the image. + * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. + * \param swapRB If true, will swap the red and blue channel of the input image. + * \param parsingType The type of parsing method to use to interpret the DNN raw results. + * \param modelFilename The path towards the DNN weights. + * \param configFilename The path towards the additional DNN configuration file potentially needed. + * \param framework The type of framework used to store the weights of the DNN. + */ + inline NetConfig(float confThresh, const float &nmsThresh, const std::vector &classNames, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. + , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true + , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") + : m_confThreshold(confThresh) + , m_nmsThreshold(nmsThresh) + , m_classNames(classNames) + , m_inputSize(dnnInputSize) + , m_filterSizeRatio(filterSizeRatio) + , m_mean(mean) + , m_scaleFactor(scaleFactor) + , m_swapRB(swapRB) + , m_parsingMethodType(parsingType) + , m_modelFilename(modelFilename) + , m_modelConfigFilename(configFilename) + , m_framework(framework) + { } + + /** + * \brief Construct a new Net Config object + * + * \param confThresh The confidence threshold to keep a detection. + * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. + * \param classNamesFile The path towards the file containing the classes names, written as a YAML string array or one class name by line. + * \param dnnInputSize The size of the input that the DNN is expecting. + * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput + * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). + * \param mean The mean value we must deduce to each color channel of the image. + * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. + * \param swapRB If true, will swap the red and blue channel of the input image. + * \param parsingType The type of parsing method to use to interpret the DNN raw results. + * \param modelFilename The path towards the DNN weights. + * \param configFilename The path towards the additional DNN configuration file potentially needed. + * \param framework The type of framework used to store the weights of the DNN. + */ + inline NetConfig(const float &confThresh, const float &nmsThresh, const std::string &classNamesFile, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. + , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true + , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") + : m_confThreshold(confThresh) + , m_nmsThreshold(nmsThresh) + , m_inputSize(dnnInputSize) + , m_filterSizeRatio(filterSizeRatio) + , m_mean(mean) + , m_scaleFactor(scaleFactor) + , m_swapRB(swapRB) + , m_parsingMethodType(parsingType) + , m_modelFilename(modelFilename) + , m_modelConfigFilename(configFilename) + , m_framework(framework) + { + m_classNames = parseClassNamesFile(classNamesFile); + } + + inline std::string toString() const + { + std::string text; + text += "Model : " + m_modelFilename + "\n"; + text += "Type : " + vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(m_parsingMethodType) + "\n"; + text += "Config (optional): " + (m_modelConfigFilename.empty() ? "\"None\"" : m_modelConfigFilename) + "\n"; + text += "Framework (optional): " + (m_framework.empty() ? "\"None\"" : m_framework) + "\n"; + text += "Width x Height : " + std::to_string(m_inputSize.width) + " x " + std::to_string(m_inputSize.height) + "\n"; + text += "Mean RGB : " + std::to_string(m_mean[0]) + " " + std::to_string(m_mean[1]) + " " + std::to_string(m_mean[2]) + "\n"; + text += "Scale : " + std::to_string(m_scaleFactor) + "\n"; + text += "Swap RB? : " + (m_swapRB ? std::string("true") : std::string("false")) + "\n"; + text += "Confidence threshold : " + std::to_string(m_confThreshold) + "\n"; + text += "NMS threshold : " + std::to_string(m_nmsThreshold) + "\n"; + text += "Filter threshold : " + + (m_filterSizeRatio > std::numeric_limits::epsilon() ? std::to_string(m_filterSizeRatio) + : "disabled") + "\n"; + return text; + } + + friend std::ostream &::operator<<(std::ostream &os, const NetConfig &config); + + NetConfig &operator=(const NetConfig &config) + { + m_confThreshold = config.m_confThreshold; + m_nmsThreshold = config.m_nmsThreshold; + m_classNames = config.m_classNames; + m_inputSize = cv::Size(config.m_inputSize.width, config.m_inputSize.height); + m_filterSizeRatio = config.m_filterSizeRatio; + m_mean = cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2]); + m_scaleFactor = config.m_scaleFactor; + m_swapRB = config.m_swapRB; + m_parsingMethodType = config.m_parsingMethodType; + m_modelFilename = config.m_modelFilename; + m_modelConfigFilename = config.m_modelConfigFilename; + m_framework = config.m_framework; + return *this; + } + + friend vpDetectorDNNOpenCV; +}; + +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + config.m_confThreshold = j.value("confidenceThreshold", config.m_confThreshold); + if (config.m_confThreshold <= 0) { + throw vpException(vpException::badValue, "Confidence threshold should be > 0"); + } + + config.m_nmsThreshold = j.value("nmsThreshold", config.m_nmsThreshold); + if (config.m_nmsThreshold <= 0) { + throw vpException(vpException::badValue, "Confidence threshold should be > 0"); + } + + config.m_filterSizeRatio = j.value("filterSizeRatio", config.m_filterSizeRatio); + + config.m_classNames = j.value("classNames", config.m_classNames); + + std::pair resolution = j.value("resolution", std::pair(config.m_inputSize.width, config.m_inputSize.height)); + config.m_inputSize.width = resolution.first; + config.m_inputSize.height = resolution.second; + + std::vector v_mean = j.value("mean", std::vector({ config.m_mean[0], config.m_mean[1], config.m_mean[2] })); + if (v_mean.size() != 3) { + throw(vpException(vpException::dimensionError, "Mean should have size = 3")); + } + config.m_mean = cv::Scalar(v_mean[0], v_mean[1], v_mean[2]); + + config.m_scaleFactor = j.value("scale", config.m_scaleFactor); + config.m_swapRB = j.value("swapRB", config.m_swapRB); + config.m_parsingMethodType = VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::dnnResultsParsingTypeFromString(j.value("parsingType", dnnResultsParsingTypeToString(config.m_parsingMethodType))); + config.m_modelFilename = j.value("modelFile", config.m_modelFilename); + config.m_modelConfigFilename = j.value("configurationFile", config.m_modelConfigFilename); + config.m_framework = j.value("framework", config.m_framework); +} + +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + std::pair resolution = { config.m_inputSize.width, config.m_inputSize.height }; + std::vector v_mean = { config.m_mean[0], config.m_mean[1], config.m_mean[2] }; + j = nlohmann::json { + {"confidenceThreshold", config.m_confThreshold } , + {"nmsThreshold" , config.m_nmsThreshold } , + {"filterSizeRatio" , config.m_filterSizeRatio} , + {"classNames" , config.m_classNames } , + {"resolution" , resolution } , + {"mean" , v_mean } , + {"scale" , config.m_scaleFactor } , + {"swapRB" , config.m_swapRB } , + {"parsingType" , VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(config.m_parsingMethodType) }, + {"modelFile" , config.m_modelFilename } , + {"configurationFile" , config.m_modelConfigFilename } , + {"framework" , config.m_framework } + }; +} + +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) +{ + os << config.toString(); + return os; +} + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \brief Get the list of the parsing methods / types of DNNs supported by the \b vpDetectorDNNOpenCV class. * @@ -1181,6 +1493,9 @@ void vpDetectorDNNOpenCV::setParsingMethod(const DNNResultsParsingType &typePars #endif } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpDetectorDNNOpenCV.cpp.o) has no symbols void dummy_vpDetectorDNN() { }; diff --git a/modules/detection/src/face/vpDetectorFace.cpp b/modules/detection/src/face/vpDetectorFace.cpp index be790f1cb7..1479bc97a8 100644 --- a/modules/detection/src/face/vpDetectorFace.cpp +++ b/modules/detection/src/face/vpDetectorFace.cpp @@ -43,6 +43,10 @@ bool vpSortLargestFace(cv::Rect rect1, cv::Rect rect2) { return (rect1.area() > rect2.area()); } +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. */ @@ -139,7 +143,9 @@ bool vpDetectorFace::detect(const cv::Mat &frame_gray) return detected; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpDetectorFace.cpp.o) has no symbols void dummy_vpDetectorFace() { }; diff --git a/modules/detection/src/tag/vpDetectorAprilTag.cpp b/modules/detection/src/tag/vpDetectorAprilTag.cpp index f06310baf5..19c2ab40ec 100644 --- a/modules/detection/src/tag/vpDetectorAprilTag.cpp +++ b/modules/detection/src/tag/vpDetectorAprilTag.cpp @@ -61,7 +61,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -1191,13 +1191,6 @@ void vpDetectorAprilTag::setAprilTagRefineEdges(bool refineEdges) { m_impl->setR void vpDetectorAprilTag::setAprilTagRefinePose(bool refinePose) { m_impl->setRefinePose(refinePose); } #endif -void swap(vpDetectorAprilTag &o1, vpDetectorAprilTag &o2) -{ - using std::swap; - - swap(o1.m_impl, o2.m_impl); -} - /*! * Modify the resulting tag pose returned by getPose() in order to get * a pose where z-axis is aligned when the camera plane is parallel to the tag. @@ -1212,6 +1205,13 @@ void vpDetectorAprilTag::setZAlignedWithCameraAxis(bool zAlignedWithCameraFrame) } #endif +void swap(VISP_NAMESPACE_ADDRESSING vpDetectorAprilTag &o1, VISP_NAMESPACE_ADDRESSING vpDetectorAprilTag &o2) +{ + using std::swap; + + swap(o1.m_impl, o2.m_impl); +} + #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpDetectorAprilTag.cpp.o) has // no symbols diff --git a/modules/detection/src/vpDetectorBase.cpp b/modules/detection/src/vpDetectorBase.cpp index a070e8380a..079cb9cfaf 100644 --- a/modules/detection/src/vpDetectorBase.cpp +++ b/modules/detection/src/vpDetectorBase.cpp @@ -36,7 +36,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/detection/test/apriltag-with-dataset/perfApriltagDetection.cpp b/modules/detection/test/apriltag-with-dataset/perfApriltagDetection.cpp index 9bc86f8244..63c0903edd 100644 --- a/modules/detection/test/apriltag-with-dataset/perfApriltagDetection.cpp +++ b/modules/detection/test/apriltag-with-dataset/perfApriltagDetection.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + TEST_CASE("Benchmark Apriltag detection 1920x1080", "[benchmark]") { const double tagSize = 0.25; @@ -502,11 +506,11 @@ int main(int argc, char *argv[]) // Build a new parser on top of Catch's using namespace Catch::clara; auto cli = session.cli() // Get Catch's composite command line parser - | Opt(runBenchmark) // bind variable to a new option, with a hint string - ["--benchmark"] // the option names it will respond to - ("run benchmark?"); // description string for the help output + | Opt(runBenchmark) // bind variable to a new option, with a hint string + ["--benchmark"] // the option names it will respond to + ("run benchmark?"); // description string for the help output - // Now pass the new composite back to Catch so it uses that +// Now pass the new composite back to Catch so it uses that session.cli(cli); // Let Catch (using Clara) parse the command line diff --git a/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp b/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp index 286d54e63e..64ad274b6d 100644 --- a/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp +++ b/modules/detection/test/apriltag-with-dataset/testAprilTag.cpp @@ -52,6 +52,10 @@ #include #include #include + +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif namespace { struct TagGroundTruth From 10fc3d530420184b90f425d63f3dbd5fb6a3e337 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 08:30:56 +0200 Subject: [PATCH 08/64] [WIP] visp_module io compiles --- modules/io/include/visp3/io/vpDiskGrabber.h | 2 +- modules/io/include/visp3/io/vpImageIo.h | 2 +- modules/io/include/visp3/io/vpImageQueue.h | 8 +++++++- .../io/include/visp3/io/vpImageStorageWorker.h | 8 +++++++- .../io/include/visp3/io/vpJsonArgumentParser.h | 2 +- modules/io/include/visp3/io/vpKeyboard.h | 8 +++++++- modules/io/include/visp3/io/vpParallelPort.h | 8 +++++++- .../include/visp3/io/vpParallelPortException.h | 8 +++++++- modules/io/include/visp3/io/vpParseArgv.h | 2 +- modules/io/include/visp3/io/vpVideoReader.h | 10 +++++----- modules/io/include/visp3/io/vpVideoWriter.h | 10 +++++----- .../io/src/image/private/vpImageIoBackend.h | 2 +- .../io/src/image/private/vpImageIoLibjpeg.cpp | 2 +- .../io/src/image/private/vpImageIoLibpng.cpp | 2 +- .../io/src/image/private/vpImageIoOpenCV.cpp | 2 +- .../io/src/image/private/vpImageIoPortable.cpp | 2 +- modules/io/src/image/private/vpImageIoSimd.cpp | 2 +- modules/io/src/image/private/vpImageIoStb.cpp | 2 +- .../io/src/image/private/vpImageIoTinyEXR.cpp | 2 +- modules/io/src/image/vpImageIo.cpp | 2 +- .../io/src/parallel-port/vpParallelPort.cpp | 18 +++++++++++++----- modules/io/src/tools/vpJsonArgumentParser.cpp | 2 +- modules/io/src/tools/vpKeyboard.cpp | 17 ++++++++++++----- modules/io/src/tools/vpParseArgv.cpp | 2 +- modules/io/src/video/vpDiskGrabber.cpp | 2 +- modules/io/src/video/vpVideoReader.cpp | 2 +- modules/io/src/video/vpVideoWriter.cpp | 10 +++++----- .../image-with-dataset/perfImageLoadSave.cpp | 4 ++++ .../image-with-dataset/testImageLoadSave.cpp | 4 ++++ modules/io/test/video/testVideo.cpp | 10 ++++++++-- 30 files changed, 108 insertions(+), 49 deletions(-) diff --git a/modules/io/include/visp3/io/vpDiskGrabber.h b/modules/io/include/visp3/io/vpDiskGrabber.h index df2d16677f..920a5160d3 100644 --- a/modules/io/include/visp3/io/vpDiskGrabber.h +++ b/modules/io/include/visp3/io/vpDiskGrabber.h @@ -46,7 +46,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/include/visp3/io/vpImageIo.h b/modules/io/include/visp3/io/vpImageIo.h index 4e7c72f9b0..4a6221af36 100644 --- a/modules/io/include/visp3/io/vpImageIo.h +++ b/modules/io/include/visp3/io/vpImageIo.h @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/include/visp3/io/vpImageQueue.h b/modules/io/include/visp3/io/vpImageQueue.h index e7869d1036..5bace32345 100644 --- a/modules/io/include/visp3/io/vpImageQueue.h +++ b/modules/io/include/visp3/io/vpImageQueue.h @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpImageQueue @@ -282,6 +286,8 @@ template class vpImageQueue bool m_directory_to_create; bool m_recording_trigger; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/io/include/visp3/io/vpImageStorageWorker.h b/modules/io/include/visp3/io/vpImageStorageWorker.h index 1eb0e79b2b..d27d635fa1 100644 --- a/modules/io/include/visp3/io/vpImageStorageWorker.h +++ b/modules/io/include/visp3/io/vpImageStorageWorker.h @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpImageStorageWorker @@ -132,6 +136,8 @@ template class vpImageStorageWorker std::ofstream m_ofs_data; bool m_data_file_created; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/io/include/visp3/io/vpJsonArgumentParser.h b/modules/io/include/visp3/io/vpJsonArgumentParser.h index f15f8e9f07..0f26307b32 100644 --- a/modules/io/include/visp3/io/vpJsonArgumentParser.h +++ b/modules/io/include/visp3/io/vpJsonArgumentParser.h @@ -69,7 +69,7 @@ nlohmann::json convertCommandLineArgument(const std::string &arg) } #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/include/visp3/io/vpKeyboard.h b/modules/io/include/visp3/io/vpKeyboard.h index 6026faeebd..e303844d9e 100644 --- a/modules/io/include/visp3/io/vpKeyboard.h +++ b/modules/io/include/visp3/io/vpKeyboard.h @@ -49,6 +49,10 @@ #include #endif // defined UNIX +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpKeyboard @@ -97,5 +101,7 @@ class VISP_EXPORT vpKeyboard struct termios initial_settings, new_settings; #endif // defined UNIX }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/io/include/visp3/io/vpParallelPort.h b/modules/io/include/visp3/io/vpParallelPort.h index 043aed23ab..6c1e2719a1 100644 --- a/modules/io/include/visp3/io/vpParallelPort.h +++ b/modules/io/include/visp3/io/vpParallelPort.h @@ -52,6 +52,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpParallelPort @@ -92,7 +96,9 @@ class VISP_EXPORT vpParallelPort int fd; // parallel port descriptor std::string device; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/io/include/visp3/io/vpParallelPortException.h b/modules/io/include/visp3/io/vpParallelPortException.h index f7ff7fd38e..242e5307fe 100644 --- a/modules/io/include/visp3/io/vpParallelPortException.h +++ b/modules/io/include/visp3/io/vpParallelPortException.h @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpParallelPortException * @@ -88,5 +92,7 @@ class VISP_EXPORT vpParallelPortException : public vpException */ explicit vpParallelPortException(int id) : vpException(id) { } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/io/include/visp3/io/vpParseArgv.h b/modules/io/include/visp3/io/vpParseArgv.h index 20fb09ded3..2873da2538 100644 --- a/modules/io/include/visp3/io/vpParseArgv.h +++ b/modules/io/include/visp3/io/vpParseArgv.h @@ -30,7 +30,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/include/visp3/io/vpVideoReader.h b/modules/io/include/visp3/io/vpVideoReader.h index 6a832019d8..451075b135 100644 --- a/modules/io/include/visp3/io/vpVideoReader.h +++ b/modules/io/include/visp3/io/vpVideoReader.h @@ -43,16 +43,16 @@ #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp -{ -#endif - #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_VIDEOIO) && defined(HAVE_OPENCV_HIGHGUI) #include #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! * \class vpVideoReader * diff --git a/modules/io/include/visp3/io/vpVideoWriter.h b/modules/io/include/visp3/io/vpVideoWriter.h index 594400d516..ea20fc9491 100644 --- a/modules/io/include/visp3/io/vpVideoWriter.h +++ b/modules/io/include/visp3/io/vpVideoWriter.h @@ -43,16 +43,16 @@ #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp -{ -#endif - #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_VIDEOIO) && defined(HAVE_OPENCV_HIGHGUI) #include #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! \class vpVideoWriter diff --git a/modules/io/src/image/private/vpImageIoBackend.h b/modules/io/src/image/private/vpImageIoBackend.h index bd40585b8c..4fe0b707f2 100644 --- a/modules/io/src/image/private/vpImageIoBackend.h +++ b/modules/io/src/image/private/vpImageIoBackend.h @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/image/private/vpImageIoLibjpeg.cpp b/modules/io/src/image/private/vpImageIoLibjpeg.cpp index 029cc06804..afaf778ccf 100644 --- a/modules/io/src/image/private/vpImageIoLibjpeg.cpp +++ b/modules/io/src/image/private/vpImageIoLibjpeg.cpp @@ -51,7 +51,7 @@ #if defined(VISP_HAVE_JPEG) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/io/src/image/private/vpImageIoLibpng.cpp b/modules/io/src/image/private/vpImageIoLibpng.cpp index 03f54ae5d5..5b5b110f40 100644 --- a/modules/io/src/image/private/vpImageIoLibpng.cpp +++ b/modules/io/src/image/private/vpImageIoLibpng.cpp @@ -50,7 +50,7 @@ #if defined(VISP_HAVE_PNG) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/io/src/image/private/vpImageIoOpenCV.cpp b/modules/io/src/image/private/vpImageIoOpenCV.cpp index 45e92ea69f..bbdc5384eb 100644 --- a/modules/io/src/image/private/vpImageIoOpenCV.cpp +++ b/modules/io/src/image/private/vpImageIoOpenCV.cpp @@ -60,7 +60,7 @@ && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC)) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/io/src/image/private/vpImageIoPortable.cpp b/modules/io/src/image/private/vpImageIoPortable.cpp index 9d5fddb7d6..26326453c2 100644 --- a/modules/io/src/image/private/vpImageIoPortable.cpp +++ b/modules/io/src/image/private/vpImageIoPortable.cpp @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/image/private/vpImageIoSimd.cpp b/modules/io/src/image/private/vpImageIoSimd.cpp index a6d22e74ae..e780c05c34 100644 --- a/modules/io/src/image/private/vpImageIoSimd.cpp +++ b/modules/io/src/image/private/vpImageIoSimd.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/image/private/vpImageIoStb.cpp b/modules/io/src/image/private/vpImageIoStb.cpp index 5d91698446..7fe8e2e430 100644 --- a/modules/io/src/image/private/vpImageIoStb.cpp +++ b/modules/io/src/image/private/vpImageIoStb.cpp @@ -58,7 +58,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/image/private/vpImageIoTinyEXR.cpp b/modules/io/src/image/private/vpImageIoTinyEXR.cpp index f03d204cdb..c8fd53938a 100644 --- a/modules/io/src/image/private/vpImageIoTinyEXR.cpp +++ b/modules/io/src/image/private/vpImageIoTinyEXR.cpp @@ -52,7 +52,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/image/vpImageIo.cpp b/modules/io/src/image/vpImageIo.cpp index 7d26b2b1af..de95afb60f 100644 --- a/modules/io/src/image/vpImageIo.cpp +++ b/modules/io/src/image/vpImageIo.cpp @@ -42,7 +42,7 @@ #include "private/vpImageIoBackend.h" #if defined(ENABLE_VISP_NAMESPACE) -using namespace visp; +using namespace VISP_NAMESPACE_NAME; #endif vpImageIo::vpImageFormatType vpImageIo::getFormat(const std::string &filename) diff --git a/modules/io/src/parallel-port/vpParallelPort.cpp b/modules/io/src/parallel-port/vpParallelPort.cpp index 26d39c4533..bc4ebbd28a 100644 --- a/modules/io/src/parallel-port/vpParallelPort.cpp +++ b/modules/io/src/parallel-port/vpParallelPort.cpp @@ -31,6 +31,11 @@ * Parallel port management. */ +/*! + \file vpParallelPort.cpp + \brief Parallel port management under unix. +*/ + #include #ifdef VISP_HAVE_PARPORT @@ -43,11 +48,12 @@ #include -/*! - \file vpParallelPort.cpp - \brief Parallel port management under unix. -*/ + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif static unsigned char vpParallelPortData; /*! @@ -157,7 +163,9 @@ void vpParallelPort::close() throw(vpParallelPortException(vpParallelPortException::closing, "Can't close the parallel port")); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpParallelPort.cpp.o) has no symbols void dummy_vpParallelPort() { }; diff --git a/modules/io/src/tools/vpJsonArgumentParser.cpp b/modules/io/src/tools/vpJsonArgumentParser.cpp index bcf1029e82..edd16659e7 100644 --- a/modules/io/src/tools/vpJsonArgumentParser.cpp +++ b/modules/io/src/tools/vpJsonArgumentParser.cpp @@ -35,7 +35,7 @@ #if defined(VISP_HAVE_NLOHMANN_JSON) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/tools/vpKeyboard.cpp b/modules/io/src/tools/vpKeyboard.cpp index 76c202b0c8..fba823b393 100644 --- a/modules/io/src/tools/vpKeyboard.cpp +++ b/modules/io/src/tools/vpKeyboard.cpp @@ -31,6 +31,11 @@ * Keyboard management. */ +/*! + \file vpKeyboard.cpp + \brief Keyboard management under unix. +*/ + #include #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) @@ -41,10 +46,10 @@ #include #include -/*! - \file vpKeyboard.cpp - \brief Keyboard management under unix. -*/ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Activates the raw mode to read keys in an non blocking way. @@ -161,5 +166,7 @@ void vpKeyboard::setRawMode(bool active) tcsetattr(STDIN_FILENO, TCSANOW, &initial_settings); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // defined UNIX diff --git a/modules/io/src/tools/vpParseArgv.cpp b/modules/io/src/tools/vpParseArgv.cpp index e0b454ce86..4f0a909aaa 100644 --- a/modules/io/src/tools/vpParseArgv.cpp +++ b/modules/io/src/tools/vpParseArgv.cpp @@ -33,7 +33,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/video/vpDiskGrabber.cpp b/modules/io/src/video/vpDiskGrabber.cpp index 7f4a01bfb6..e99e52be09 100644 --- a/modules/io/src/video/vpDiskGrabber.cpp +++ b/modules/io/src/video/vpDiskGrabber.cpp @@ -34,7 +34,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/video/vpVideoReader.cpp b/modules/io/src/video/vpVideoReader.cpp index e157bf1aef..9ab6bf9de9 100644 --- a/modules/io/src/video/vpVideoReader.cpp +++ b/modules/io/src/video/vpVideoReader.cpp @@ -46,7 +46,7 @@ #include // numeric_limits #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/io/src/video/vpVideoWriter.cpp b/modules/io/src/video/vpVideoWriter.cpp index e05358dc7b..4988568ebb 100644 --- a/modules/io/src/video/vpVideoWriter.cpp +++ b/modules/io/src/video/vpVideoWriter.cpp @@ -40,15 +40,15 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp -{ -#endif - #if defined(HAVE_OPENCV_IMGPROC) #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! Basic constructor. */ diff --git a/modules/io/test/image-with-dataset/perfImageLoadSave.cpp b/modules/io/test/image-with-dataset/perfImageLoadSave.cpp index 815525b09f..3a039d903f 100644 --- a/modules/io/test/image-with-dataset/perfImageLoadSave.cpp +++ b/modules/io/test/image-with-dataset/perfImageLoadSave.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + static std::string ipath = vpIoTools::getViSPImagesDataPath(); static std::vector paths { ipath + "/Solvay/Solvay_conference_1927_Version2_640x440", diff --git a/modules/io/test/image-with-dataset/testImageLoadSave.cpp b/modules/io/test/image-with-dataset/testImageLoadSave.cpp index 3d3ae6d855..72b8190888 100644 --- a/modules/io/test/image-with-dataset/testImageLoadSave.cpp +++ b/modules/io/test/image-with-dataset/testImageLoadSave.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + static const std::string ipath = vpIoTools::getViSPImagesDataPath(); static const std::string path = ipath + "/Solvay/Solvay_conference_1927_Version2_640x440"; diff --git a/modules/io/test/video/testVideo.cpp b/modules/io/test/video/testVideo.cpp index 4d105fd960..734bc4e96f 100644 --- a/modules/io/test/video/testVideo.cpp +++ b/modules/io/test/video/testVideo.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + static long first_frame = 100; static int frame_step = 2; static unsigned int nframes = 3; @@ -72,7 +76,8 @@ bool test_createSequence(vpImage &I, const std::string &videoname, unsigne std::cout << "Frame saved in: " << writer.getFrameName() << std::endl; } return true; - } catch (...) { + } + catch (...) { return false; } } @@ -177,7 +182,8 @@ int main(int argc, char *argv[]) try { // Create the dirname vpIoTools::makeDirectory(tmp); - } catch (...) { + } + catch (...) { std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << tmp << std::endl; } From d2ca3ae7cb2e396f76f9161ddd44e41db395444e Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 08:32:22 +0200 Subject: [PATCH 09/64] [WIP] Moved to_json from_json and operator<< of vpDetectorDNNOpenCV in the cpp file due to the forward declaration of NetConfig --- .../visp3/detection/vpDetectorDNNOpenCV.h | 34 ------------------- .../detection/src/dnn/vpDetectorDNNOpenCV.cpp | 33 ++++++++++++++++++ 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h index 6029d01357..f3762da05e 100644 --- a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h +++ b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h @@ -338,39 +338,5 @@ vpDetectorDNNOpenCV::DetectedFeatures2D::display(const vpImage< Type > &img, con #ifdef ENABLE_VISP_NAMESPACE } #endif - -inline std::ostream &::operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) -{ - os << network.m_netConfig; - return os; -} - -#ifdef VISP_HAVE_NLOHMANN_JSON - /** - * \brief Read the network configuration from JSON. All values are optional and if an argument is not present, - * the default value defined in the constructor is kept - * - * \param j The JSON object, resulting from the parsing of a JSON file. - * \param network The network, that will be initialized from the JSON data. - */ -inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) -{ - network.m_netConfig = j.value("networkSettings", network.m_netConfig); -} - -/** - * \brief Parse the network configuration into JSON format. - * - * \param j The JSON parser. - * \param network The network we want to parse the configuration. - */ -inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) -{ - j = nlohmann::json { - {"networkSettings", network.m_netConfig} - }; -} -#endif - #endif #endif diff --git a/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp b/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp index d7ee9865d1..28cac5a001 100644 --- a/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp +++ b/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp @@ -285,6 +285,7 @@ class VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig friend vpDetectorDNNOpenCV; }; +#ifdef VISP_HAVE_NLOHMANN_JSON void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) { #ifdef ENABLE_VISP_NAMESPACE @@ -345,12 +346,44 @@ void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpe }; } +/** + * \brief Read the network configuration from JSON. All values are optional and if an argument is not present, + * the default value defined in the constructor is kept + * + * \param j The JSON object, resulting from the parsing of a JSON file. + * \param network The network, that will be initialized from the JSON data. + */ +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) +{ + network.m_netConfig = j.value("networkSettings", network.m_netConfig); +} + +/** + * \brief Parse the network configuration into JSON format. + * + * \param j The JSON parser. + * \param network The network we want to parse the configuration. + */ +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) +{ + j = nlohmann::json { + {"networkSettings", network.m_netConfig} + }; +} +#endif + std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) { os << config.toString(); return os; } +inline std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) +{ + os << network.m_netConfig; + return os; +} + #ifdef ENABLE_VISP_NAMESPACE namespace VISP_NAMESPACE_NAME { From d312bcf68dcc53244e6d51d435218486488cf93f Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 08:43:15 +0200 Subject: [PATCH 10/64] [WIP] visp_gui compiles --- .../visp3/gui/vpColorBlindFriendlyPalette.h | 17 ++++-- modules/gui/include/visp3/gui/vpD3DRenderer.h | 2 +- modules/gui/include/visp3/gui/vpDisplayD3D.h | 2 +- .../gui/include/visp3/gui/vpDisplayFactory.h | 8 ++- modules/gui/include/visp3/gui/vpDisplayGDI.h | 2 +- modules/gui/include/visp3/gui/vpDisplayGTK.h | 2 +- .../gui/include/visp3/gui/vpDisplayOpenCV.h | 2 +- modules/gui/include/visp3/gui/vpDisplayPCL.h | 8 ++- .../gui/include/visp3/gui/vpDisplayWin32.h | 2 +- modules/gui/include/visp3/gui/vpDisplayX.h | 2 +- modules/gui/include/visp3/gui/vpGDIRenderer.h | 2 +- modules/gui/include/visp3/gui/vpPclViewer.h | 7 +++ modules/gui/include/visp3/gui/vpPlot.h | 2 +- modules/gui/include/visp3/gui/vpPlotCurve.h | 2 +- modules/gui/include/visp3/gui/vpPlotGraph.h | 2 +- .../include/visp3/gui/vpProjectionDisplay.h | 2 +- modules/gui/include/visp3/gui/vpWin32API.h | 2 +- .../gui/include/visp3/gui/vpWin32Renderer.h | 2 +- modules/gui/include/visp3/gui/vpWin32Window.h | 2 +- modules/gui/src/display/vpDisplayGTK.cpp | 2 +- modules/gui/src/display/vpDisplayOpenCV.cpp | 10 ++-- modules/gui/src/display/vpDisplayX.cpp | 2 +- .../gui/src/display/windows/vpD3DRenderer.cpp | 2 +- .../gui/src/display/windows/vpDisplayD3D.cpp | 2 +- .../gui/src/display/windows/vpDisplayGDI.cpp | 2 +- .../src/display/windows/vpDisplayWin32.cpp | 2 +- .../gui/src/display/windows/vpGDIRenderer.cpp | 2 +- .../gui/src/display/windows/vpWin32API.cpp | 2 +- .../gui/src/display/windows/vpWin32Window.cpp | 2 +- .../vpProjectionDisplay.cpp | 2 +- modules/gui/src/plot/vpPlot.cpp | 2 +- modules/gui/src/plot/vpPlotCurve.cpp | 2 +- modules/gui/src/plot/vpPlotGraph.cpp | 2 +- .../vpColorBlindFriendlyPalette.cpp | 13 ++++- modules/gui/src/pointcloud/vpDisplayPCL.cpp | 8 ++- modules/gui/src/pointcloud/vpPclViewer.cpp | 8 ++- .../test/display-with-dataset/testClick.cpp | 37 +++++++----- .../testDisplayScaled.cpp | 33 +++++++---- .../display-with-dataset/testMouseEvent.cpp | 57 ++++++++++++------- .../display-with-dataset/testVideoDevice.cpp | 37 +++++++----- .../test/display/testDisplayPolygonLines.cpp | 4 ++ modules/gui/test/display/testDisplayRoi.cpp | 8 ++- modules/gui/test/display/testDisplays.cpp | 10 +++- .../gui/test/display/testVideoDeviceDual.cpp | 27 ++++++--- 44 files changed, 230 insertions(+), 118 deletions(-) diff --git a/modules/gui/include/visp3/gui/vpColorBlindFriendlyPalette.h b/modules/gui/include/visp3/gui/vpColorBlindFriendlyPalette.h index 55b8e091b5..973904ad08 100644 --- a/modules/gui/include/visp3/gui/vpColorBlindFriendlyPalette.h +++ b/modules/gui/include/visp3/gui/vpColorBlindFriendlyPalette.h @@ -37,14 +37,20 @@ #ifndef _vpColorBlindFliendlyPalette_h_ #define _vpColorBlindFliendlyPalette_h_ -#include -#include +#include + +#include +#include #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98) /** * \brief Class that furnishes a set of colors that color blind people * should be able to distinguish one from another. */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpColorBlindFriendlyPalette { public: @@ -172,6 +178,9 @@ class VISP_EXPORT vpColorBlindFriendlyPalette Palette m_colorID; /*!< The ID of the color in the \b vpColorBlindFriendlyPalette::Palette.*/ }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /** * \brief Permit to display in a \b std::ostream the name of the \b color. @@ -180,7 +189,7 @@ class VISP_EXPORT vpColorBlindFriendlyPalette * \param color The color we are interested in displaying the name. * \return std::ostream& The stream, in which the name of the \b color has been written. */ -std::ostream &operator<<(std::ostream &os, const vpColorBlindFriendlyPalette &color); +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpColorBlindFriendlyPalette &color); /** * \brief Permits to initialize a \b vpColorBlindFriendlyPalette by reading its name in @@ -190,7 +199,7 @@ std::ostream &operator<<(std::ostream &os, const vpColorBlindFriendlyPalette &co * \param color The color we want to initialized. * \return std::istream& The \b is input, from which we have read the name of \b color. */ -std::istream &operator>>(std::istream &is, vpColorBlindFriendlyPalette &color); +std::istream &operator>>(std::istream &is, VISP_NAMESPACE_ADDRESSING vpColorBlindFriendlyPalette &color); #endif #endif // _vpColorBlindFliendlyPalette_h_ diff --git a/modules/gui/include/visp3/gui/vpD3DRenderer.h b/modules/gui/include/visp3/gui/vpD3DRenderer.h index 38e4d17bb6..0b33734852 100644 --- a/modules/gui/include/visp3/gui/vpD3DRenderer.h +++ b/modules/gui/include/visp3/gui/vpD3DRenderer.h @@ -50,7 +50,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayD3D.h b/modules/gui/include/visp3/gui/vpDisplayD3D.h index 6b9318da08..74ead416dd 100644 --- a/modules/gui/include/visp3/gui/vpDisplayD3D.h +++ b/modules/gui/include/visp3/gui/vpDisplayD3D.h @@ -41,7 +41,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayFactory.h b/modules/gui/include/visp3/gui/vpDisplayFactory.h index 5413adc70e..401564bafb 100644 --- a/modules/gui/include/visp3/gui/vpDisplayFactory.h +++ b/modules/gui/include/visp3/gui/vpDisplayFactory.h @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \ingroup group_gui_display */ @@ -140,5 +144,7 @@ vpDisplay *displayFactory(vpImage &I, vpDisplay::vpScaleType scale_type) #endif } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayGDI.h b/modules/gui/include/visp3/gui/vpDisplayGDI.h index a250f4a3dd..0cf052c084 100644 --- a/modules/gui/include/visp3/gui/vpDisplayGDI.h +++ b/modules/gui/include/visp3/gui/vpDisplayGDI.h @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayGTK.h b/modules/gui/include/visp3/gui/vpDisplayGTK.h index a32b26b578..c7fc0b85ae 100644 --- a/modules/gui/include/visp3/gui/vpDisplayGTK.h +++ b/modules/gui/include/visp3/gui/vpDisplayGTK.h @@ -41,7 +41,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayOpenCV.h b/modules/gui/include/visp3/gui/vpDisplayOpenCV.h index c3a5e76d96..748f776239 100644 --- a/modules/gui/include/visp3/gui/vpDisplayOpenCV.h +++ b/modules/gui/include/visp3/gui/vpDisplayOpenCV.h @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayPCL.h b/modules/gui/include/visp3/gui/vpDisplayPCL.h index 0d97c9aa51..b4603e9b1f 100644 --- a/modules/gui/include/visp3/gui/vpDisplayPCL.h +++ b/modules/gui/include/visp3/gui/vpDisplayPCL.h @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpDisplayPCL \ingroup group_gui_plotter @@ -80,7 +84,9 @@ class VISP_EXPORT vpDisplayPCL std::string m_window_name; pcl::visualization::PCLVisualizer::Ptr m_viewer; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayWin32.h b/modules/gui/include/visp3/gui/vpDisplayWin32.h index d2cc1a2d3c..00819cbbb8 100644 --- a/modules/gui/include/visp3/gui/vpDisplayWin32.h +++ b/modules/gui/include/visp3/gui/vpDisplayWin32.h @@ -53,7 +53,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpDisplayX.h b/modules/gui/include/visp3/gui/vpDisplayX.h index 4482aae482..024353a817 100644 --- a/modules/gui/include/visp3/gui/vpDisplayX.h +++ b/modules/gui/include/visp3/gui/vpDisplayX.h @@ -41,7 +41,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpGDIRenderer.h b/modules/gui/include/visp3/gui/vpGDIRenderer.h index 54d19d4703..4d2ab83ed9 100644 --- a/modules/gui/include/visp3/gui/vpGDIRenderer.h +++ b/modules/gui/include/visp3/gui/vpGDIRenderer.h @@ -59,7 +59,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpPclViewer.h b/modules/gui/include/visp3/gui/vpPclViewer.h index 37d51ec5d9..c4583fffb0 100644 --- a/modules/gui/include/visp3/gui/vpPclViewer.h +++ b/modules/gui/include/visp3/gui/vpPclViewer.h @@ -48,6 +48,10 @@ // PCL #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpPclViewer \ingroup group_gui_plotter @@ -256,5 +260,8 @@ class VISP_EXPORT vpPclViewer bool m_hasToSavePCDs; /*!< If true, the point clouds will be saved at each iteration of the drawing thread.*/ std::string m_outFolder; /*!< If non empty, the path to the folders where the point clouds will be saved.*/ }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #if defined(VISP_HAVE_PCL) #endif // _vpPclVisualizer_h_ diff --git a/modules/gui/include/visp3/gui/vpPlot.h b/modules/gui/include/visp3/gui/vpPlot.h index 088025d02e..9b23acdd86 100644 --- a/modules/gui/include/visp3/gui/vpPlot.h +++ b/modules/gui/include/visp3/gui/vpPlot.h @@ -46,7 +46,7 @@ #if defined(VISP_HAVE_DISPLAY) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpPlotCurve.h b/modules/gui/include/visp3/gui/vpPlotCurve.h index f811c3cd7a..2a65611f55 100644 --- a/modules/gui/include/visp3/gui/vpPlotCurve.h +++ b/modules/gui/include/visp3/gui/vpPlotCurve.h @@ -52,7 +52,7 @@ #if defined(VISP_HAVE_DISPLAY) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpPlotGraph.h b/modules/gui/include/visp3/gui/vpPlotGraph.h index b87f052d8d..3587bfe2a2 100644 --- a/modules/gui/include/visp3/gui/vpPlotGraph.h +++ b/modules/gui/include/visp3/gui/vpPlotGraph.h @@ -55,7 +55,7 @@ #if defined(VISP_HAVE_DISPLAY) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpProjectionDisplay.h b/modules/gui/include/visp3/gui/vpProjectionDisplay.h index 4fcd663d80..b0d17429cc 100644 --- a/modules/gui/include/visp3/gui/vpProjectionDisplay.h +++ b/modules/gui/include/visp3/gui/vpProjectionDisplay.h @@ -58,7 +58,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpWin32API.h b/modules/gui/include/visp3/gui/vpWin32API.h index 8d8c36a2b4..7291223abe 100644 --- a/modules/gui/include/visp3/gui/vpWin32API.h +++ b/modules/gui/include/visp3/gui/vpWin32API.h @@ -50,7 +50,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpWin32Renderer.h b/modules/gui/include/visp3/gui/vpWin32Renderer.h index 90231c57ae..6178f23a19 100644 --- a/modules/gui/include/visp3/gui/vpWin32Renderer.h +++ b/modules/gui/include/visp3/gui/vpWin32Renderer.h @@ -55,7 +55,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/include/visp3/gui/vpWin32Window.h b/modules/gui/include/visp3/gui/vpWin32Window.h index 2b7c35863a..15fa83614c 100644 --- a/modules/gui/include/visp3/gui/vpWin32Window.h +++ b/modules/gui/include/visp3/gui/vpWin32Window.h @@ -56,7 +56,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/vpDisplayGTK.cpp b/modules/gui/src/display/vpDisplayGTK.cpp index 19b4bda8f8..99a6be53a2 100644 --- a/modules/gui/src/display/vpDisplayGTK.cpp +++ b/modules/gui/src/display/vpDisplayGTK.cpp @@ -69,7 +69,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/vpDisplayOpenCV.cpp b/modules/gui/src/display/vpDisplayOpenCV.cpp index 69b66b627f..d401dc3d1f 100644 --- a/modules/gui/src/display/vpDisplayOpenCV.cpp +++ b/modules/gui/src/display/vpDisplayOpenCV.cpp @@ -65,11 +65,6 @@ #include #endif -#if defined(ENABLE_VISP_NAMESPACE) -namespace visp -{ -#endif - #ifndef CV_RGB #define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0) #endif @@ -80,6 +75,11 @@ namespace visp #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif + std::vector vpDisplayOpenCV::m_listTitles = std::vector(); unsigned int vpDisplayOpenCV::m_nbWindows = 0; diff --git a/modules/gui/src/display/vpDisplayX.cpp b/modules/gui/src/display/vpDisplayX.cpp index 7390c30073..f67868c1f7 100644 --- a/modules/gui/src/display/vpDisplayX.cpp +++ b/modules/gui/src/display/vpDisplayX.cpp @@ -67,7 +67,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/windows/vpD3DRenderer.cpp b/modules/gui/src/display/windows/vpD3DRenderer.cpp index 5f72aeb4a6..0e0b74cc82 100644 --- a/modules/gui/src/display/windows/vpD3DRenderer.cpp +++ b/modules/gui/src/display/windows/vpD3DRenderer.cpp @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/windows/vpDisplayD3D.cpp b/modules/gui/src/display/windows/vpDisplayD3D.cpp index 60914444c0..a1d18aa314 100644 --- a/modules/gui/src/display/windows/vpDisplayD3D.cpp +++ b/modules/gui/src/display/windows/vpDisplayD3D.cpp @@ -48,7 +48,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! diff --git a/modules/gui/src/display/windows/vpDisplayGDI.cpp b/modules/gui/src/display/windows/vpDisplayGDI.cpp index 048ebe993a..90ef843c94 100644 --- a/modules/gui/src/display/windows/vpDisplayGDI.cpp +++ b/modules/gui/src/display/windows/vpDisplayGDI.cpp @@ -47,7 +47,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/windows/vpDisplayWin32.cpp b/modules/gui/src/display/windows/vpDisplayWin32.cpp index 6c73236e57..e1f2982194 100644 --- a/modules/gui/src/display/windows/vpDisplayWin32.cpp +++ b/modules/gui/src/display/windows/vpDisplayWin32.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/windows/vpGDIRenderer.cpp b/modules/gui/src/display/windows/vpGDIRenderer.cpp index b82667120c..28d4c19145 100644 --- a/modules/gui/src/display/windows/vpGDIRenderer.cpp +++ b/modules/gui/src/display/windows/vpGDIRenderer.cpp @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/windows/vpWin32API.cpp b/modules/gui/src/display/windows/vpWin32API.cpp index 27d5d66637..d390bebcff 100644 --- a/modules/gui/src/display/windows/vpWin32API.cpp +++ b/modules/gui/src/display/windows/vpWin32API.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/display/windows/vpWin32Window.cpp b/modules/gui/src/display/windows/vpWin32Window.cpp index 9102b6327a..d493cff834 100644 --- a/modules/gui/src/display/windows/vpWin32Window.cpp +++ b/modules/gui/src/display/windows/vpWin32Window.cpp @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/forward-projection/vpProjectionDisplay.cpp b/modules/gui/src/forward-projection/vpProjectionDisplay.cpp index e912f04d14..b8caf68835 100644 --- a/modules/gui/src/forward-projection/vpProjectionDisplay.cpp +++ b/modules/gui/src/forward-projection/vpProjectionDisplay.cpp @@ -58,7 +58,7 @@ //#include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/plot/vpPlot.cpp b/modules/gui/src/plot/vpPlot.cpp index f4ff388c93..1b1c38170c 100644 --- a/modules/gui/src/plot/vpPlot.cpp +++ b/modules/gui/src/plot/vpPlot.cpp @@ -50,7 +50,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/plot/vpPlotCurve.cpp b/modules/gui/src/plot/vpPlotCurve.cpp index 98402c0ebb..b4f22b5909 100644 --- a/modules/gui/src/plot/vpPlotCurve.cpp +++ b/modules/gui/src/plot/vpPlotCurve.cpp @@ -46,7 +46,7 @@ #if defined(VISP_HAVE_DISPLAY) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/plot/vpPlotGraph.cpp b/modules/gui/src/plot/vpPlotGraph.cpp index b543224bbc..e4e1423894 100644 --- a/modules/gui/src/plot/vpPlotGraph.cpp +++ b/modules/gui/src/plot/vpPlotGraph.cpp @@ -55,7 +55,7 @@ #if defined(VISP_HAVE_DISPLAY) #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/gui/src/pointcloud/vpColorBlindFriendlyPalette.cpp b/modules/gui/src/pointcloud/vpColorBlindFriendlyPalette.cpp index a28a934eba..06055bcfa0 100644 --- a/modules/gui/src/pointcloud/vpColorBlindFriendlyPalette.cpp +++ b/modules/gui/src/pointcloud/vpColorBlindFriendlyPalette.cpp @@ -37,6 +37,10 @@ #if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif std::vector vpColorBlindFriendlyPalette::s_paletteNames = { "black" , @@ -193,20 +197,23 @@ std::string vpColorBlindFriendlyPalette::to_string(const vpColorBlindFriendlyPal return nameColor; } -std::ostream &operator<<(std::ostream &os, const vpColorBlindFriendlyPalette &color) +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpColorBlindFriendlyPalette &color) { os << color.to_string(); return os; } -std::istream &operator>>(std::istream &is, vpColorBlindFriendlyPalette &color) +std::istream &operator>>(std::istream &is, VISP_NAMESPACE_ADDRESSING vpColorBlindFriendlyPalette &color) { std::string nameColor; is >> nameColor; color.set_fromString(nameColor); return is; } - #else void dummy_vpColorBlindFriendlyPalette() { } #endif diff --git a/modules/gui/src/pointcloud/vpDisplayPCL.cpp b/modules/gui/src/pointcloud/vpDisplayPCL.cpp index 64a2e5bbbc..eb5af2801b 100644 --- a/modules/gui/src/pointcloud/vpDisplayPCL.cpp +++ b/modules/gui/src/pointcloud/vpDisplayPCL.cpp @@ -37,6 +37,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor. * By default, viewer size is set to 640 x 480. @@ -226,7 +230,9 @@ void vpDisplayPCL::setVerbose(bool verbose) { m_verbose = verbose; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_gui.a(vpDisplayPCL.cpp.o) has no symbols void dummy_vpDisplayPCL() { }; diff --git a/modules/gui/src/pointcloud/vpPclViewer.cpp b/modules/gui/src/pointcloud/vpPclViewer.cpp index 89794b04f8..0807684a43 100644 --- a/modules/gui/src/pointcloud/vpPclViewer.cpp +++ b/modules/gui/src/pointcloud/vpPclViewer.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const std::vector gcolor = { vpColorBlindFriendlyPalette::Palette::Green, vpColorBlindFriendlyPalette::Palette::Vermillon,vpColorBlindFriendlyPalette::Palette::Blue, vpColorBlindFriendlyPalette::Palette::Black, vpColorBlindFriendlyPalette::Palette::Orange, vpColorBlindFriendlyPalette::Palette::Purple, vpColorBlindFriendlyPalette::Palette::Yellow }; @@ -485,7 +489,9 @@ void vpPclViewer::threadUpdateSurfaceOriginalColor(const pclPointCloudPointXYZRG m_vpmutex[id]->unlock(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpD3DRenderer.cpp.o) has no symbols void dummy_vpPCLPointCLoudVisualization() { }; diff --git a/modules/gui/test/display-with-dataset/testClick.cpp b/modules/gui/test/display-with-dataset/testClick.cpp index 4417c1cd1f..48c0ce5d0e 100644 --- a/modules/gui/test/display-with-dataset/testClick.cpp +++ b/modules/gui/test/display-with-dataset/testClick.cpp @@ -64,6 +64,10 @@ // List of allowed command line options #define GETOPTARGS "i:hlt:dc" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, std::string ipath, vpDisplayType &dtype); @@ -89,7 +93,7 @@ SYNOPSIS\n\ %s [-i ] \n\ [-t ] [-l] [-c] [-d] [-h]\n\ ", - name); +name); std::string display; switch (dtype) { @@ -185,13 +189,17 @@ bool getOptions(int argc, const char **argv, std::string &ipath, vpDisplayType & // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; - } else if (sDisplayType.compare("GTK") == 0) { + } + else if (sDisplayType.compare("GTK") == 0) { dtype = vpGTK; - } else if (sDisplayType.compare("GDI") == 0) { + } + else if (sDisplayType.compare("GDI") == 0) { dtype = vpGDI; - } else if (sDisplayType.compare("D3D") == 0) { + } + else if (sDisplayType.compare("D3D") == 0) { dtype = vpD3D; - } else if (sDisplayType.compare("CV") == 0) { + } + else if (sDisplayType.compare("CV") == 0) { dtype = vpCV; } @@ -292,9 +300,9 @@ int main(int argc, const char **argv) std::cout << " No display is available\n"; } return EXIT_FAILURE; - } + } - // Get the option values + // Get the option values if (!opt_ipath.empty()) ipath = opt_ipath; @@ -304,8 +312,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -314,9 +322,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_dtype); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -440,11 +448,12 @@ int main(int argc, const char **argv) } } delete display; - } catch (...) { +} + catch (...) { vpERROR_TRACE("Error while displaying the image"); return EXIT_FAILURE; } -} + } #else int main() { vpERROR_TRACE("You do not have display functionalities..."); } diff --git a/modules/gui/test/display-with-dataset/testDisplayScaled.cpp b/modules/gui/test/display-with-dataset/testDisplayScaled.cpp index 2c7457371a..95cdc6a706 100644 --- a/modules/gui/test/display-with-dataset/testDisplayScaled.cpp +++ b/modules/gui/test/display-with-dataset/testDisplayScaled.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + template bool test(const std::string &display, vpImage &I, unsigned int scale, bool click) { bool success = true; @@ -66,19 +70,23 @@ template bool test(const std::string &display, vpImage &I, #ifdef VISP_HAVE_GDI d = new vpDisplayGDI; #endif - } else if (display == "GTK") { + } + else if (display == "GTK") { #ifdef VISP_HAVE_GTK d = new vpDisplayGTK; #endif - } else if (display == "X") { + } + else if (display == "X") { #ifdef VISP_HAVE_X11 d = new vpDisplayX; #endif - } else if (display == "OpenCV") { + } + else if (display == "OpenCV") { #ifdef HAVE_OPENCV_HIGHGUI d = new vpDisplayOpenCV; #endif - } else if (display == "D3D9") { + } + else if (display == "D3D9") { #ifdef VISP_HAVE_D3D9 d = new vpDisplayD3D; #endif @@ -145,10 +153,12 @@ template bool test(const std::string &display, vpImage &I, #endif vpImageIo::write(Idiff, ss.str()); - } else { + } + else { std::cout << " ++ Test width scale= " << scale << " type= " << itype << ": succeed" << std::endl; } - } else { + } + else { itype = "rgba"; vpImage Iinsert = I; vpImage Isampled; // vpRGBa necessary @@ -197,7 +207,8 @@ template bool test(const std::string &display, vpImage &I, vpImageIo::write(Idiff, ss.str()); - } else { + } + else { std::cout << " ++ Test width scale= " << scale << " type= " << itype << ": succeed" << std::endl; } } @@ -277,10 +288,10 @@ int main(int argc, const char *argv[]) std::cout << "\nUsage: " << argv[0] << " [-i ] [-c] [-d] [--help]\n" << std::endl; std::cout << "\nOptions: " << std::endl; std::cout << " -i : set image input path.\n" - << " From this path read \"Klimt/Klimt.pgm\" image.\n" - << " Setting the VISP_INPUT_IMAGE_PATH environment\n" - << " variable produces the same behaviour than using\n" - << " this option." << std::endl; + << " From this path read \"Klimt/Klimt.pgm\" image.\n" + << " Setting the VISP_INPUT_IMAGE_PATH environment\n" + << " variable produces the same behaviour than using\n" + << " this option." << std::endl; std::cout << " -c : disable mouse click" << std::endl; std::cout << " -d : disable display" << std::endl; std::cout << " -h, --help : print this help\n" << std::endl; diff --git a/modules/gui/test/display-with-dataset/testMouseEvent.cpp b/modules/gui/test/display-with-dataset/testMouseEvent.cpp index 863ab1c87d..dec8c89a33 100644 --- a/modules/gui/test/display-with-dataset/testMouseEvent.cpp +++ b/modules/gui/test/display-with-dataset/testMouseEvent.cpp @@ -77,7 +77,13 @@ // List of allowed command line options #define GETOPTARGS "cdi:Lp:ht:f:l:s:w" -typedef enum { + +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +typedef enum +{ vpX11, vpGTK, vpGDI, @@ -238,11 +244,14 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &pp // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; - } else if (sDisplayType.compare("GTK") == 0) { + } + else if (sDisplayType.compare("GTK") == 0) { dtype = vpGTK; - } else if (sDisplayType.compare("GDI") == 0) { + } + else if (sDisplayType.compare("GDI") == 0) { dtype = vpGDI; - } else if (sDisplayType.compare("D3D") == 0) { + } + else if (sDisplayType.compare("D3D") == 0) { dtype = vpD3D; } @@ -363,7 +372,7 @@ int main(int argc, const char **argv) std::cout << " No display is available\n"; } return EXIT_FAILURE; - } +} if (!opt_display) opt_click_blocking = false; // turn off the waiting @@ -378,8 +387,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -388,11 +397,11 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_ppath, opt_first, opt_last, opt_step, opt_dtype); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << " Use -p option if you want to " << std::endl - << " use personal images." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << " Use -p option if you want to " << std::endl + << " use personal images." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -414,7 +423,8 @@ int main(int argc, const char **argv) s.setf(std::ios::right, std::ios::adjustfield); s << "image." << std::setw(4) << std::setfill('0') << iter << "." << ext; filename = vpIoTools::createFilePath(dirname, s.str()); - } else { + } + else { snprintf(cfilename, FILENAME_MAX, opt_ppath.c_str(), iter); filename = cfilename; @@ -422,12 +432,13 @@ int main(int argc, const char **argv) // Read image named "filename" and put the bitmap in I try { vpImageIo::read(I, filename); - } catch (...) { + } + catch (...) { std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot read " << filename << std::endl; std::cerr << " Check your -i " << ipath << " option, " << std::endl - << " or your -p " << opt_ppath << " option " << std::endl - << " or VISP_INPUT_IMAGE_PATH environment variable" << std::endl; + << " or your -p " << opt_ppath << " option " << std::endl + << " or VISP_INPUT_IMAGE_PATH environment variable" << std::endl; return EXIT_FAILURE; } // Create a display for the image @@ -490,7 +501,8 @@ int main(int argc, const char **argv) // display variable. vpDisplay::display(I); vpDisplay::flush(I); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error while displaying the image"); delete display; return EXIT_FAILURE; @@ -507,7 +519,8 @@ int main(int argc, const char **argv) s.str(""); s << "image." << std::setw(4) << std::setfill('0') << iter << "." << ext; filename = vpIoTools::createFilePath(dirname, s.str()); - } else { + } + else { snprintf(cfilename, FILENAME_MAX, opt_ppath.c_str(), iter); filename = cfilename; } @@ -548,11 +561,13 @@ int main(int argc, const char **argv) } } vpTime::wait(tms, 1000); - } else { - // Synchronise the loop to 40 ms + } + else { + // Synchronise the loop to 40 ms vpTime::wait(tms, 40); } - } catch (...) { + } + catch (...) { delete display; return EXIT_FAILURE; } diff --git a/modules/gui/test/display-with-dataset/testVideoDevice.cpp b/modules/gui/test/display-with-dataset/testVideoDevice.cpp index e5ed80be5c..45429ff34b 100644 --- a/modules/gui/test/display-with-dataset/testVideoDevice.cpp +++ b/modules/gui/test/display-with-dataset/testVideoDevice.cpp @@ -66,6 +66,10 @@ // List of allowed command line options #define GETOPTARGS "i:hlt:dc" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, std::string ipath, vpDisplayType &dtype); @@ -91,7 +95,7 @@ SYNOPSIS\n\ %s [-i ] \n\ [-t ] [-l] [-c] [-d] [-h]\n\ ", - name); +name); std::string display; switch (dtype) { @@ -183,13 +187,17 @@ bool getOptions(int argc, const char **argv, std::string &ipath, vpDisplayType & // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; - } else if (sDisplayType.compare("GTK") == 0) { + } + else if (sDisplayType.compare("GTK") == 0) { dtype = vpGTK; - } else if (sDisplayType.compare("GDI") == 0) { + } + else if (sDisplayType.compare("GDI") == 0) { dtype = vpGDI; - } else if (sDisplayType.compare("D3D") == 0) { + } + else if (sDisplayType.compare("D3D") == 0) { dtype = vpD3D; - } else if (sDisplayType.compare("CV") == 0) { + } + else if (sDisplayType.compare("CV") == 0) { dtype = vpCV; } @@ -290,9 +298,9 @@ int main(int argc, const char **argv) std::cout << " No display is available\n"; } return EXIT_FAILURE; - } + } - // Get the option values + // Get the option values if (!opt_ipath.empty()) ipath = opt_ipath; @@ -302,8 +310,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -312,9 +320,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_dtype); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -469,11 +477,12 @@ int main(int argc, const char **argv) vpDisplay::getClick(Irgba); } delete display; - } catch (...) { +} + catch (...) { vpERROR_TRACE("Error while displaying the image"); return EXIT_FAILURE; } -} + } #else int main() { vpERROR_TRACE("You do not have display functionalities..."); } diff --git a/modules/gui/test/display/testDisplayPolygonLines.cpp b/modules/gui/test/display/testDisplayPolygonLines.cpp index 6b1d96c849..d19cc90001 100644 --- a/modules/gui/test/display/testDisplayPolygonLines.cpp +++ b/modules/gui/test/display/testDisplayPolygonLines.cpp @@ -55,6 +55,10 @@ // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); diff --git a/modules/gui/test/display/testDisplayRoi.cpp b/modules/gui/test/display/testDisplayRoi.cpp index 78d780cf7a..052fe857ea 100644 --- a/modules/gui/test/display/testDisplayRoi.cpp +++ b/modules/gui/test/display/testDisplayRoi.cpp @@ -54,6 +54,10 @@ // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); @@ -203,10 +207,10 @@ int main(int argc, const char **argv) std::cout << "A click in the image to exit..." << std::endl; vpDisplay::getClick(C); } - } + } #else (void)argc; (void)argv; #endif return EXIT_SUCCESS; -} + } diff --git a/modules/gui/test/display/testDisplays.cpp b/modules/gui/test/display/testDisplays.cpp index b277a39edf..75b81698ac 100644 --- a/modules/gui/test/display/testDisplays.cpp +++ b/modules/gui/test/display/testDisplays.cpp @@ -66,6 +66,10 @@ // List of allowed command line options #define GETOPTARGS "hldc" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! Print the program options. @@ -415,16 +419,16 @@ int main(int argc, const char **argv) std::cout << " No display is available\n"; } return EXIT_FAILURE; - } + } - // Create a color image for each display. + // Create a color image for each display. runTest(opt_display, opt_click_allowed); // Create a grayscale image for each display. runTest(opt_display, opt_click_allowed); return EXIT_SUCCESS; - } +} catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return EXIT_FAILURE; diff --git a/modules/gui/test/display/testVideoDeviceDual.cpp b/modules/gui/test/display/testVideoDeviceDual.cpp index ea2a4e710d..5fa5dd5a6c 100644 --- a/modules/gui/test/display/testVideoDeviceDual.cpp +++ b/modules/gui/test/display/testVideoDeviceDual.cpp @@ -57,6 +57,10 @@ // List of allowed command line options #define GETOPTARGS "hlt:dc" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, vpDisplayType &dtype); @@ -79,7 +83,7 @@ Test to open video devices or display.\n\ SYNOPSIS\n\ %s [-t ] [-l] [-c] [-d] [-h]\n\ ", - name); +name); std::string display; switch (dtype) { @@ -158,13 +162,17 @@ bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, b // Parse the display type option if (sDisplayType.compare("X11") == 0) { dtype = vpX11; - } else if (sDisplayType.compare("GTK") == 0) { + } + else if (sDisplayType.compare("GTK") == 0) { dtype = vpGTK; - } else if (sDisplayType.compare("GDI") == 0) { + } + else if (sDisplayType.compare("GDI") == 0) { dtype = vpGDI; - } else if (sDisplayType.compare("D3D") == 0) { + } + else if (sDisplayType.compare("D3D") == 0) { dtype = vpD3D; - } else if (sDisplayType.compare("CV") == 0) { + } + else if (sDisplayType.compare("CV") == 0) { dtype = vpCV; } @@ -253,9 +261,9 @@ int main(int argc, const char **argv) std::cout << " No display is available\n"; } return EXIT_FAILURE; - } + } - // Create 2 images + // Create 2 images vpImage I1(240, 320), I2(240, 320); I1 = 128; I2 = 255; @@ -344,11 +352,12 @@ int main(int argc, const char **argv) delete d1; delete d2; return EXIT_SUCCESS; - } catch (const vpException &e) { +} + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } -} + } #else int main() { vpERROR_TRACE("You do not have display functionalities..."); } From d05362aaa7c8b90697307b9e650a97fa6bc32c81 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 13:41:57 +0200 Subject: [PATCH 11/64] [WIP] visp_visual_features visp_me visp_tt visp_tt_mi visp_vision compile --- modules/tracker/me/include/visp3/me/vpMe.h | 47 +++++---- .../tracker/me/include/visp3/me/vpMeEllipse.h | 2 +- .../tracker/me/include/visp3/me/vpMeLine.h | 8 +- .../tracker/me/include/visp3/me/vpMeNurbs.h | 8 +- .../tracker/me/include/visp3/me/vpMeSite.h | 16 +++- .../tracker/me/include/visp3/me/vpMeTracker.h | 2 +- modules/tracker/me/include/visp3/me/vpNurbs.h | 8 +- modules/tracker/me/src/moving-edges/vpMe.cpp | 2 +- .../me/src/moving-edges/vpMeEllipse.cpp | 2 +- .../tracker/me/src/moving-edges/vpMeLine.cpp | 7 ++ .../tracker/me/src/moving-edges/vpMeNurbs.cpp | 7 ++ .../tracker/me/src/moving-edges/vpMeSite.cpp | 12 +-- .../me/src/moving-edges/vpMeTracker.cpp | 2 +- .../tracker/me/src/moving-edges/vpNurbs.cpp | 8 ++ modules/tracker/me/test/testJsonMe.cpp | 4 + modules/tracker/me/test/testNurbs.cpp | 17 +++- .../tt/include/visp3/tt/vpTemplateTracker.h | 31 +++--- .../visp3/tt/vpTemplateTrackerBSpline.h | 8 +- .../visp3/tt/vpTemplateTrackerHeader.h | 34 ++++--- .../include/visp3/tt/vpTemplateTrackerSSD.h | 9 +- .../visp3/tt/vpTemplateTrackerSSDESM.h | 8 ++ .../vpTemplateTrackerSSDForwardAdditional.h | 10 +- ...vpTemplateTrackerSSDForwardCompositional.h | 8 ++ ...vpTemplateTrackerSSDInverseCompositional.h | 8 ++ .../visp3/tt/vpTemplateTrackerTriangle.h | 14 ++- .../include/visp3/tt/vpTemplateTrackerWarp.h | 13 ++- .../visp3/tt/vpTemplateTrackerWarpAffine.h | 12 ++- .../tt/vpTemplateTrackerWarpHomography.h | 10 +- .../tt/vpTemplateTrackerWarpHomographySL3.h | 8 ++ .../visp3/tt/vpTemplateTrackerWarpRT.h | 12 ++- .../visp3/tt/vpTemplateTrackerWarpSRT.h | 12 ++- .../tt/vpTemplateTrackerWarpTranslation.h | 12 ++- .../include/visp3/tt/vpTemplateTrackerZNCC.h | 8 ++ .../vpTemplateTrackerZNCCForwardAdditional.h | 8 ++ ...pTemplateTrackerZNCCInverseCompositional.h | 8 ++ .../include/visp3/tt/vpTemplateTrackerZone.h | 8 ++ .../tt/src/ssd/vpTemplateTrackerSSD.cpp | 7 ++ .../tt/src/ssd/vpTemplateTrackerSSDESM.cpp | 10 +- .../vpTemplateTrackerSSDForwardAdditional.cpp | 13 ++- ...TemplateTrackerSSDForwardCompositional.cpp | 13 ++- ...TemplateTrackerSSDInverseCompositional.cpp | 7 ++ .../tt/src/tools/vpTemplateTrackerBSpline.cpp | 13 ++- .../src/tools/vpTemplateTrackerTriangle.cpp | 25 +++-- .../tt/src/tools/vpTemplateTrackerZone.cpp | 21 +++- modules/tracker/tt/src/vpTemplateTracker.cpp | 71 +++++++++----- .../tt/src/warp/vpTemplateTrackerWarp.cpp | 16 +++- .../src/warp/vpTemplateTrackerWarpAffine.cpp | 9 +- .../warp/vpTemplateTrackerWarpHomography.cpp | 17 +++- .../vpTemplateTrackerWarpHomographySL3.cpp | 7 ++ .../tt/src/warp/vpTemplateTrackerWarpRT.cpp | 7 ++ .../tt/src/warp/vpTemplateTrackerWarpSRT.cpp | 7 ++ .../warp/vpTemplateTrackerWarpTranslation.cpp | 7 ++ .../tt/src/zncc/vpTemplateTrackerZNCC.cpp | 7 ++ ...vpTemplateTrackerZNCCForwardAdditional.cpp | 10 +- ...emplateTrackerZNCCInverseCompositional.cpp | 18 +++- .../include/visp3/tt_mi/vpTemplateTrackerMI.h | 8 +- .../visp3/tt_mi/vpTemplateTrackerMIBSpline.h | 9 +- .../visp3/tt_mi/vpTemplateTrackerMIESM.h | 9 +- .../vpTemplateTrackerMIForwardAdditional.h | 11 ++- .../vpTemplateTrackerMIForwardCompositional.h | 8 +- .../vpTemplateTrackerMIInverseCompositional.h | 12 ++- .../tt_mi/src/mi/vpTemplateTrackerMI.cpp | 7 ++ .../tt_mi/src/mi/vpTemplateTrackerMIESM.cpp | 18 +++- .../vpTemplateTrackerMIForwardAdditional.cpp | 19 +++- ...pTemplateTrackerMIForwardCompositional.cpp | 16 +++- ...pTemplateTrackerMIInverseCompositional.cpp | 51 ++++++---- .../src/tools/vpTemplateTrackerMIBSpline.cpp | 48 ++++++---- .../include/visp3/vision/vpBasicKeyPoint.h | 8 +- .../include/visp3/vision/vpCalibration.h | 8 +- .../visp3/vision/vpCalibrationException.h | 8 +- .../visp3/vision/vpHandEyeCalibration.h | 8 +- .../include/visp3/vision/vpHomography.h | 2 +- .../vision/include/visp3/vision/vpKeyPoint.h | 8 +- .../include/visp3/vision/vpPlaneEstimation.h | 9 +- modules/vision/include/visp3/vision/vpPose.h | 2 +- .../include/visp3/vision/vpPoseException.h | 2 +- .../include/visp3/vision/vpPoseFeatures.h | 9 ++ .../visp3/vision/vpXmlConfigParserKeyPoint.h | 7 ++ .../vision/src/calibration/vpCalibration.cpp | 8 ++ .../src/calibration/vpCalibrationTools.cpp | 8 +- .../src/calibration/vpHandEyeCalibration.cpp | 9 ++ .../homography-estimation/vpHomography.cpp | 2 +- .../homography-estimation/vpHomographyDLT.cpp | 2 +- .../vpHomographyExtract.cpp | 2 +- .../vpHomographyMalis.cpp | 2 +- .../vpHomographyRansac.cpp | 2 +- .../homography-estimation/vpHomographyVVS.cpp | 2 +- modules/vision/src/key-point/vpKeyPoint.cpp | 9 ++ .../key-point/vpXmlConfigParserKeyPoint.cpp | 8 +- .../plane-estimation/vpPlaneEstimation.cpp | 8 +- .../private/vpLevenbergMarquartd.cpp | 2 +- .../private/vpLevenbergMarquartd.h | 2 +- modules/vision/src/pose-estimation/vpPose.cpp | 2 +- .../src/pose-estimation/vpPoseDementhon.cpp | 2 +- .../src/pose-estimation/vpPoseFeatures.cpp | 10 ++ .../src/pose-estimation/vpPoseLagrange.cpp | 2 +- .../vision/src/pose-estimation/vpPoseLowe.cpp | 2 +- .../vision/src/pose-estimation/vpPoseRGBD.cpp | 2 +- .../src/pose-estimation/vpPoseRansac.cpp | 2 +- .../vpPoseVirtualVisualServoing.cpp | 2 +- .../test/homography/testDisplacement.cpp | 7 +- .../keypoint-with-dataset/testKeyPoint-2.cpp | 4 + .../keypoint-with-dataset/testKeyPoint-3.cpp | 19 ++-- .../keypoint-with-dataset/testKeyPoint-4.cpp | 4 + .../keypoint-with-dataset/testKeyPoint-5.cpp | 8 +- .../keypoint-with-dataset/testKeyPoint-6.cpp | 51 ++++++---- .../keypoint-with-dataset/testKeyPoint-7.cpp | 4 + .../keypoint-with-dataset/testKeyPoint.cpp | 19 ++-- .../testXmlConfigParserKeyPoint.cpp | 4 + .../pose-with-dataset/testPoseRansac2.cpp | 96 ++++++++++--------- modules/vision/test/pose/testFindMatch.cpp | 7 +- modules/vision/test/pose/testPose.cpp | 4 + modules/vision/test/pose/testPoseFeatures.cpp | 4 + modules/vision/test/pose/testPoseRansac.cpp | 8 +- .../visp3/visual_features/vpBasicFeature.h | 15 ++- .../visp3/visual_features/vpFeatureBuilder.h | 15 ++- .../visp3/visual_features/vpFeatureDepth.h | 14 ++- .../visp3/visual_features/vpFeatureEllipse.h | 14 ++- .../visual_features/vpFeatureException.h | 14 ++- .../visp3/visual_features/vpFeatureLine.h | 14 ++- .../visual_features/vpFeatureLuminance.h | 22 +++-- .../visp3/visual_features/vpFeatureMoment.h | 21 +++- .../visual_features/vpFeatureMomentAlpha.h | 8 ++ .../visual_features/vpFeatureMomentArea.h | 8 ++ .../vpFeatureMomentAreaNormalized.h | 8 ++ .../visual_features/vpFeatureMomentBasic.h | 7 ++ .../vpFeatureMomentCInvariant.h | 41 +++++++- .../visual_features/vpFeatureMomentCentered.h | 23 ++++- .../visual_features/vpFeatureMomentCommon.h | 9 +- .../visual_features/vpFeatureMomentDatabase.h | 8 +- .../vpFeatureMomentGravityCenter.h | 9 +- .../vpFeatureMomentGravityCenterNormalized.h | 8 ++ .../visp3/visual_features/vpFeaturePoint.h | 14 ++- .../visp3/visual_features/vpFeaturePoint3D.h | 13 ++- .../visual_features/vpFeaturePointPolar.h | 14 ++- .../visp3/visual_features/vpFeatureSegment.h | 14 ++- .../visp3/visual_features/vpFeatureThetaU.h | 14 ++- .../visual_features/vpFeatureTranslation.h | 14 ++- .../visual_features/vpFeatureVanishingPoint.h | 14 ++- .../visp3/visual_features/vpGenericFeature.h | 15 ++- .../vpFeatureBuilderEllipse.cpp | 7 ++ .../feature-builder/vpFeatureBuilderLine.cpp | 24 +++-- .../feature-builder/vpFeatureBuilderPoint.cpp | 22 ++++- .../vpFeatureBuilderPoint3D.cpp | 11 ++- .../vpFeatureBuilderPointPolar.cpp | 23 +++-- .../vpFeatureBuilderSegment.cpp | 7 ++ .../vpFeatureBuilderVanishingPoint.cpp | 27 ++++-- .../src/visual-feature/vpBasicFeature.cpp | 25 +++-- .../src/visual-feature/vpFeatureDepth.cpp | 16 ++-- .../src/visual-feature/vpFeatureEllipse.cpp | 8 ++ .../src/visual-feature/vpFeatureLine.cpp | 7 ++ .../src/visual-feature/vpFeatureLuminance.cpp | 20 ++-- .../src/visual-feature/vpFeatureMoment.cpp | 38 +++++--- .../visual-feature/vpFeatureMomentAlpha.cpp | 7 ++ .../visual-feature/vpFeatureMomentArea.cpp | 14 ++- .../vpFeatureMomentAreaNormalized.cpp | 16 +++- .../visual-feature/vpFeatureMomentBasic.cpp | 8 ++ .../vpFeatureMomentCInvariant.cpp | 17 +++- .../vpFeatureMomentCentered.cpp | 12 ++- .../visual-feature/vpFeatureMomentCommon.cpp | 7 ++ .../vpFeatureMomentDatabase.cpp | 7 ++ .../vpFeatureMomentGravityCenter.cpp | 16 +++- ...vpFeatureMomentGravityCenterNormalized.cpp | 16 +++- .../src/visual-feature/vpFeaturePoint.cpp | 7 ++ .../src/visual-feature/vpFeaturePoint3D.cpp | 7 ++ .../visual-feature/vpFeaturePointPolar.cpp | 7 ++ .../src/visual-feature/vpFeatureSegment.cpp | 16 +++- .../src/visual-feature/vpFeatureThetaU.cpp | 16 +++- .../visual-feature/vpFeatureTranslation.cpp | 16 +++- .../vpFeatureVanishingPoint.cpp | 7 ++ .../src/visual-feature/vpGenericFeature.cpp | 8 +- .../test/feature/testPoint.cpp | 12 ++- 172 files changed, 1645 insertions(+), 470 deletions(-) diff --git a/modules/tracker/me/include/visp3/me/vpMe.h b/modules/tracker/me/include/visp3/me/vpMe.h index 070fba3fe5..005602034f 100644 --- a/modules/tracker/me/include/visp3/me/vpMe.h +++ b/modules/tracker/me/include/visp3/me/vpMe.h @@ -39,12 +39,29 @@ #ifndef _vpMe_h_ #define _vpMe_h_ +#include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMe; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +#ifdef VISP_HAVE_NLOHMANN_JSON +#include +// Forward declaration to have the methods in the global namespace +void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpMe &me); +void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpMe &me); +#endif + #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif /*! @@ -530,7 +547,7 @@ class VISP_EXPORT vpMe * @param j : Resulting json object. * @param me : The object to convert. */ - friend void to_json(nlohmann::json &j, const vpMe &me); + friend void ::to_json(nlohmann::json &j, const vpMe &me); /** * @brief Retrieve a vpMe object from a JSON representation @@ -579,18 +596,21 @@ class VISP_EXPORT vpMe * @param j JSON representation to convert * @param me converted object */ - friend void from_json(const nlohmann::json &j, vpMe &me); + friend void ::from_json(const nlohmann::json &j, vpMe &me); #endif }; -#ifdef VISP_HAVE_NLOHMANN_JSON -#include -NLOHMANN_JSON_SERIALIZE_ENUM(vpMe::vpLikelihoodThresholdType, { - {vpMe::vpLikelihoodThresholdType::OLD_THRESHOLD, "old"}, - {vpMe::vpLikelihoodThresholdType::NORMALIZED_THRESHOLD, "normalized"} +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + +#ifdef VISP_HAVE_NLOHMANN_JSON +NLOHMANN_JSON_SERIALIZE_ENUM(VISP_NAMESPACE_ADDRESSING vpMe::vpLikelihoodThresholdType, { + {VISP_NAMESPACE_ADDRESSING vpMe::vpLikelihoodThresholdType::OLD_THRESHOLD, "old"}, + {VISP_NAMESPACE_ADDRESSING vpMe::vpLikelihoodThresholdType::NORMALIZED_THRESHOLD, "normalized"} }); -inline void to_json(nlohmann::json &j, const vpMe &me) +inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpMe &me) { j = { {"thresholdType", me.getLikelihoodThresholdType()}, @@ -610,7 +630,7 @@ inline void to_json(nlohmann::json &j, const vpMe &me) }; } -inline void from_json(const nlohmann::json &j, vpMe &me) +inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpMe &me) { if (j.contains("thresholdType")) { me.setLikelihoodThresholdType(j.value("thresholdType", me.getLikelihoodThresholdType())); @@ -624,7 +644,7 @@ inline void from_json(const nlohmann::json &j, vpMe &me) assert((mus.size() == 2)); me.setMu1(mus[0]); me.setMu2(mus[1]); -} + } me.setMinSampleStep(j.value("minSampleStep", me.getMinSampleStep())); me.setSampleStep(j.value("sampleStep", me.getSampleStep())); me.setRange(j.value("range", me.getRange())); @@ -648,9 +668,4 @@ inline void from_json(const nlohmann::json &j, vpMe &me) #endif - -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - #endif diff --git a/modules/tracker/me/include/visp3/me/vpMeEllipse.h b/modules/tracker/me/include/visp3/me/vpMeEllipse.h index 0eadccaf06..8128668917 100644 --- a/modules/tracker/me/include/visp3/me/vpMeEllipse.h +++ b/modules/tracker/me/include/visp3/me/vpMeEllipse.h @@ -54,7 +54,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/tracker/me/include/visp3/me/vpMeLine.h b/modules/tracker/me/include/visp3/me/vpMeLine.h index c3a833ffe8..011526e006 100644 --- a/modules/tracker/me/include/visp3/me/vpMeLine.h +++ b/modules/tracker/me/include/visp3/me/vpMeLine.h @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMeLine * @@ -458,5 +462,7 @@ class VISP_EXPORT vpMeLine : public vpMeTracker const vpColor &color = vpColor::green, unsigned int thickness = 1); #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/me/include/visp3/me/vpMeNurbs.h b/modules/tracker/me/include/visp3/me/vpMeNurbs.h index de056e67f1..0af38d34d1 100644 --- a/modules/tracker/me/include/visp3/me/vpMeNurbs.h +++ b/modules/tracker/me/include/visp3/me/vpMeNurbs.h @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMeNurbs * @@ -337,5 +341,7 @@ class VISP_EXPORT vpMeNurbs : public vpMeTracker */ static void display(const vpImage &I, vpNurbs &n, const vpColor &color = vpColor::green, unsigned int thickness = 1); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/me/include/visp3/me/vpMeSite.h b/modules/tracker/me/include/visp3/me/vpMeSite.h index 3d0f9871f0..9de3ea2eda 100644 --- a/modules/tracker/me/include/visp3/me/vpMeSite.h +++ b/modules/tracker/me/include/visp3/me/vpMeSite.h @@ -44,8 +44,20 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpMeSite; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpMeSite &vpMeS); + #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -321,7 +333,7 @@ class VISP_EXPORT vpMeSite /*! * ostream operator. */ - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, vpMeSite &vpMeS); // Static functions /*! diff --git a/modules/tracker/me/include/visp3/me/vpMeTracker.h b/modules/tracker/me/include/visp3/me/vpMeTracker.h index f4e150440b..22d7848d8b 100644 --- a/modules/tracker/me/include/visp3/me/vpMeTracker.h +++ b/modules/tracker/me/include/visp3/me/vpMeTracker.h @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/tracker/me/include/visp3/me/vpNurbs.h b/modules/tracker/me/include/visp3/me/vpNurbs.h index ee9fad05f7..462269ec80 100644 --- a/modules/tracker/me/include/visp3/me/vpNurbs.h +++ b/modules/tracker/me/include/visp3/me/vpNurbs.h @@ -49,6 +49,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpNurbs * \ingroup module_me @@ -523,5 +527,7 @@ class VISP_EXPORT vpNurbs : public vpBSpline */ void globalCurveApprox(unsigned int n); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/me/src/moving-edges/vpMe.cpp b/modules/tracker/me/src/moving-edges/vpMe.cpp index 93d7278a03..f0704797ba 100644 --- a/modules/tracker/me/src/moving-edges/vpMe.cpp +++ b/modules/tracker/me/src/moving-edges/vpMe.cpp @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp b/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp index 11f4c0c94f..271f6dc60e 100644 --- a/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp @@ -41,7 +41,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/tracker/me/src/moving-edges/vpMeLine.cpp b/modules/tracker/me/src/moving-edges/vpMeLine.cpp index 39e01e785f..d7782b6c22 100644 --- a/modules/tracker/me/src/moving-edges/vpMeLine.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeLine.cpp @@ -51,6 +51,10 @@ #define INCR_MIN 1 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void computeDelta(double &delta, int i1, int j1, int i2, int j2); static void normalizeAngle(double &delta) @@ -1204,3 +1208,6 @@ void vpMeLine::displayLine(const vpImage &I, const vpMeSite &PExt1, cons ip1.set_j(PExt2.m_jfloat); vpDisplay::displayCross(I, ip1, 10, vpColor::green, thickness); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp b/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp index 5b1f17bf5f..aaba941e44 100644 --- a/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp @@ -56,6 +56,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif double computeDelta(double deltai, double deltaj); void findAngle(const vpImage &I, const vpImagePoint &iP, vpMe *me, double &angle, double &convlt); vpImagePoint findFirstBorder(const vpImage &Isub, const vpImagePoint &iP); @@ -1094,3 +1098,6 @@ void vpMeNurbs::display(const vpImage &I, vpNurbs &n, const vpColor &col u += 0.01; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/me/src/moving-edges/vpMeSite.cpp b/modules/tracker/me/src/moving-edges/vpMeSite.cpp index 56e12aec1c..068dfb18df 100644 --- a/modules/tracker/me/src/moving-edges/vpMeSite.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeSite.cpp @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -382,11 +382,6 @@ void vpMeSite::track(const vpImage &I, const vpMe *me, const bool int vpMeSite::operator!=(const vpMeSite &m) { return ((m.m_i != m_i) || (m.m_j != m_j)); } -VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS) -{ - return (os << "Alpha: " << vpMeS.m_alpha << " Convolution: " << vpMeS.m_convlt << " Weight: " << vpMeS.m_weight << " Threshold: " << vpMeS.m_contrastThreshold); -} - void vpMeSite::display(const vpImage &I) { vpMeSite::display(I, m_ifloat, m_jfloat, m_state); } void vpMeSite::display(const vpImage &I) { vpMeSite::display(I, m_ifloat, m_jfloat, m_state); } @@ -453,3 +448,8 @@ void vpMeSite::display(const vpImage &I, const double &i, const double & #if defined(ENABLE_VISP_NAMESPACE) } #endif + +VISP_EXPORT std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpMeSite &vpMeS) +{ + return (os << "Alpha: " << vpMeS.m_alpha << " Convolution: " << vpMeS.m_convlt << " Weight: " << vpMeS.m_weight << " Threshold: " << vpMeS.m_contrastThreshold); +} diff --git a/modules/tracker/me/src/moving-edges/vpMeTracker.cpp b/modules/tracker/me/src/moving-edges/vpMeTracker.cpp index 6ff223c362..86dde306ab 100644 --- a/modules/tracker/me/src/moving-edges/vpMeTracker.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeTracker.cpp @@ -45,7 +45,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/tracker/me/src/moving-edges/vpNurbs.cpp b/modules/tracker/me/src/moving-edges/vpNurbs.cpp index 3eac4dff37..8f74128dcf 100644 --- a/modules/tracker/me/src/moving-edges/vpNurbs.cpp +++ b/modules/tracker/me/src/moving-edges/vpNurbs.cpp @@ -35,6 +35,11 @@ #include // numeric_limits #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* Compute the distance d = |Pw1-Pw2| */ @@ -745,3 +750,6 @@ void vpNurbs::globalCurveApprox(unsigned int n) { globalCurveApprox(crossingPoints, p, n, knots, controlPoints, weights); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/me/test/testJsonMe.cpp b/modules/tracker/me/test/testJsonMe.cpp index 18edc7d6ea..a6d3c6b54f 100644 --- a/modules/tracker/me/test/testJsonMe.cpp +++ b/modules/tracker/me/test/testJsonMe.cpp @@ -51,6 +51,10 @@ using json = nlohmann::json; //! json namespace shortcut #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + template void checkProperties(const T &t1, const T &t2, C fn, const std::string &message) { THEN(message) { REQUIRE((t1.*fn)() == (t2.*fn)()); } diff --git a/modules/tracker/me/test/testNurbs.cpp b/modules/tracker/me/test/testNurbs.cpp index 49e853206a..6fcbb26581 100644 --- a/modules/tracker/me/test/testNurbs.cpp +++ b/modules/tracker/me/test/testNurbs.cpp @@ -59,6 +59,10 @@ // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); @@ -292,7 +296,8 @@ int main(int argc, const char **argv) display[1].init(I2, 100, 100, "Points interpolation"); vpDisplay::display(I2); vpDisplay::flush(I2); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error while displaying the image"); return EXIT_FAILURE; } @@ -321,7 +326,8 @@ int main(int argc, const char **argv) display[2].init(I3, 100, 100, "Points approximation"); vpDisplay::display(I3); vpDisplay::flush(I3); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error while displaying the image"); return EXIT_FAILURE; } @@ -354,7 +360,8 @@ int main(int argc, const char **argv) } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } @@ -370,8 +377,8 @@ int main() int main() { std::cout << "This example requires a video device. " << std::endl - << "You should install X11, GTK, OpenCV, GDI or Direct3D" << std::endl - << "to be able to execute this example." << std::endl; + << "You should install X11, GTK, OpenCV, GDI or Direct3D" << std::endl + << "to be able to execute this example." << std::endl; return EXIT_SUCCESS; } #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTracker.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTracker.h index 68e1bb1902..2d974024d9 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTracker.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTracker.h @@ -46,11 +46,16 @@ #include +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTracker \ingroup group_tt_tracker @@ -146,17 +151,16 @@ class VISP_EXPORT vpTemplateTracker //! Default constructor. vpTemplateTracker() : nbLvlPyr(0), l0Pyr(0), pyrInitialised(false), ptTemplate(nullptr), ptTemplatePyr(nullptr), ptTemplateInit(false), - templateSize(0), templateSizePyr(nullptr), ptTemplateSelect(nullptr), ptTemplateSelectPyr(nullptr), - ptTemplateSelectInit(false), templateSelectSize(0), ptTemplateSupp(nullptr), ptTemplateSuppPyr(nullptr), - ptTemplateCompo(nullptr), ptTemplateCompoPyr(nullptr), zoneTracked(nullptr), zoneTrackedPyr(nullptr), pyr_IDes(nullptr), H(), - Hdesire(), HdesirePyr(nullptr), HLM(), HLMdesire(), HLMdesirePyr(nullptr), HLMdesireInverse(), - HLMdesireInversePyr(nullptr), G(), gain(0), thresholdGradient(0), costFunctionVerification(false), blur(false), - useBrent(false), nbIterBrent(0), taillef(0), fgG(nullptr), fgdG(nullptr), ratioPixelIn(0), mod_i(0), mod_j(0), - nbParam(), lambdaDep(0), iterationMax(0), iterationGlobale(0), diverge(false), nbIteration(0), - useCompositionnal(false), useInverse(false), Warp(nullptr), p(), dp(), X1(), X2(), dW(), BI(), dIx(), dIy(), - zoneRef_() - { - } + templateSize(0), templateSizePyr(nullptr), ptTemplateSelect(nullptr), ptTemplateSelectPyr(nullptr), + ptTemplateSelectInit(false), templateSelectSize(0), ptTemplateSupp(nullptr), ptTemplateSuppPyr(nullptr), + ptTemplateCompo(nullptr), ptTemplateCompoPyr(nullptr), zoneTracked(nullptr), zoneTrackedPyr(nullptr), pyr_IDes(nullptr), H(), + Hdesire(), HdesirePyr(nullptr), HLM(), HLMdesire(), HLMdesirePyr(nullptr), HLMdesireInverse(), + HLMdesireInversePyr(nullptr), G(), gain(0), thresholdGradient(0), costFunctionVerification(false), blur(false), + useBrent(false), nbIterBrent(0), taillef(0), fgG(nullptr), fgdG(nullptr), ratioPixelIn(0), mod_i(0), mod_j(0), + nbParam(), lambdaDep(0), iterationMax(0), iterationGlobale(0), diverge(false), nbIteration(0), + useCompositionnal(false), useInverse(false), Warp(nullptr), p(), dp(), X1(), X2(), dW(), BI(), dIx(), dIy(), + zoneRef_() + { } explicit vpTemplateTracker(vpTemplateTrackerWarp *_warp); virtual ~vpTemplateTracker(); @@ -232,7 +236,7 @@ class VISP_EXPORT vpTemplateTracker l0Pyr = level_to_stop; if (l0Pyr >= nlevels) { std::cout << "Warning: level_to_stop: " << level_to_stop << " higher than level_to_start: " << nlevels - 1 - << " (nlevels-1)" << std::endl; + << " (nlevels-1)" << std::endl; std::cout << "Level to stop put to: " << nlevels - 1 << std::endl; l0Pyr = nlevels - 1; } @@ -297,4 +301,7 @@ class VISP_EXPORT vpTemplateTracker virtual void trackNoPyr(const vpImage &I) = 0; virtual void trackPyr(const vpImage &I); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerBSpline.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerBSpline.h index 3e5ff70055..69fcb1e91c 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerBSpline.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerBSpline.h @@ -49,7 +49,10 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpTemplateTrackerBSpline { public: @@ -57,5 +60,8 @@ class VISP_EXPORT vpTemplateTrackerBSpline static double getSubPixBspline4(const vpImage &I, double r, double t); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerHeader.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerHeader.h index 23ca9507b0..f53e93227a 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerHeader.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerHeader.h @@ -45,49 +45,59 @@ #define vpTemplateTrackerHeader_hh #include +#include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \struct vpTemplateTrackerZPoint \ingroup group_tt_tools */ -struct vpTemplateTrackerZPoint { +struct vpTemplateTrackerZPoint +{ int x, y; - vpTemplateTrackerZPoint() : x(0), y(0) {} + vpTemplateTrackerZPoint() : x(0), y(0) { } }; /*! \struct vpTemplateTrackerDPoint \ingroup group_tt_tools */ -struct vpTemplateTrackerDPoint { +struct vpTemplateTrackerDPoint +{ double x, y; - vpTemplateTrackerDPoint() : x(0), y(0) {} + vpTemplateTrackerDPoint() : x(0), y(0) { } }; /*! \struct vpTemplateTrackerPoint \ingroup group_tt_tools */ -struct vpTemplateTrackerPoint { +struct vpTemplateTrackerPoint +{ int x, y; double dx, dy; double val; double *dW; double *HiG; - vpTemplateTrackerPoint() : x(0), y(0), dx(0), dy(0), val(0), dW(nullptr), HiG(nullptr) {} + vpTemplateTrackerPoint() : x(0), y(0), dx(0), dy(0), val(0), dW(nullptr), HiG(nullptr) { } }; /*! \struct vpTemplateTrackerPointCompo \ingroup group_tt_tools */ -struct vpTemplateTrackerPointCompo { +struct vpTemplateTrackerPointCompo +{ double *dW; - vpTemplateTrackerPointCompo() : dW(nullptr) {} + vpTemplateTrackerPointCompo() : dW(nullptr) { } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS -struct vpTemplateTrackerPointSuppMIInv { +struct vpTemplateTrackerPointSuppMIInv +{ double et; int ct; double *BtInit; @@ -97,9 +107,11 @@ struct vpTemplateTrackerPointSuppMIInv { double *d2Wx; double *d2Wy; vpTemplateTrackerPointSuppMIInv() : et(0), ct(0), BtInit(nullptr), Bt(nullptr), dBt(nullptr), d2W(nullptr), d2Wx(nullptr), d2Wy(nullptr) - { - } + { } }; #endif // DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSD.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSD.h index 5fb26ad185..98a60ff003 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSD.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSD.h @@ -46,6 +46,7 @@ #include +#include #include #include #include @@ -55,6 +56,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerSSD \ingroup group_tt_tracker @@ -77,5 +82,7 @@ class VISP_EXPORT vpTemplateTrackerSSD : public vpTemplateTracker double getSSD(const vpImage &I, const vpColVector &tp); void setGain(double g) { gain = g; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDESM.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDESM.h index f0f722fe6f..c418ef2b02 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDESM.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDESM.h @@ -44,8 +44,13 @@ #ifndef vpTemplateTrackerSSDESM_hh #define vpTemplateTrackerSSDESM_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerSSDESM \ingroup group_tt_tracker @@ -69,4 +74,7 @@ class VISP_EXPORT vpTemplateTrackerSSDESM : public vpTemplateTrackerSSD public: explicit vpTemplateTrackerSSDESM(vpTemplateTrackerWarp *warp); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardAdditional.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardAdditional.h index 3eedfae3e0..dafaac10bd 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardAdditional.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardAdditional.h @@ -44,8 +44,13 @@ #ifndef vpTemplateTrackerSSDForwardAdditional_hh #define vpTemplateTrackerSSDForwardAdditional_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \ingroup group_tt_tracker The algorithm implemented in this class is described in \cite Baker04a and @@ -65,7 +70,7 @@ class VISP_EXPORT vpTemplateTrackerSSDForwardAdditional : public vpTemplateTrack vpMatrix KQuasiNewton; protected: - void initHessienDesired(const vpImage & /*I*/) {} + void initHessienDesired(const vpImage & /*I*/) { } void trackNoPyr(const vpImage &I); public: @@ -73,4 +78,7 @@ class VISP_EXPORT vpTemplateTrackerSSDForwardAdditional : public vpTemplateTrack void setMinimizationMethod(vpMinimizationTypeSSDForwardAdditional method) { minimizationMethod = method; } }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardCompositional.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardCompositional.h index 562788881c..3ef4e4144b 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardCompositional.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDForwardCompositional.h @@ -44,8 +44,13 @@ #ifndef vpTemplateTrackerSSDForwardCompositional_hh #define vpTemplateTrackerSSDForwardCompositional_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \ingroup group_tt_tracker The algorithm implemented in this class is described in \cite Baker04a and @@ -64,4 +69,7 @@ class VISP_EXPORT vpTemplateTrackerSSDForwardCompositional : public vpTemplateTr public: explicit vpTemplateTrackerSSDForwardCompositional(vpTemplateTrackerWarp *warp); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDInverseCompositional.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDInverseCompositional.h index 3c0dad8f42..96ce5051b4 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDInverseCompositional.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerSSDInverseCompositional.h @@ -45,8 +45,13 @@ #include +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \ingroup group_tt_tracker The algorithm implemented in this class is described in \cite Baker04a and @@ -72,4 +77,7 @@ class VISP_EXPORT vpTemplateTrackerSSDInverseCompositional : public vpTemplateTr * this feature is disabled. */ void setUseTemplateSelect(bool b) { useTemplateSelect = b; } }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerTriangle.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerTriangle.h index e2a42be271..005afc5869 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerTriangle.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerTriangle.h @@ -48,11 +48,16 @@ #include #include +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerTriangle \ingroup group_tt_tools @@ -137,10 +142,12 @@ class VISP_EXPORT vpTemplateTrackerTriangle if (i == 0) { x = C1.x; y = C1.y; - } else if (i == 1) { + } + else if (i == 1) { x = C2.x; y = C2.y; - } else /*if(i==2)*/ { + } + else /*if(i==2)*/ { x = C3.x; y = C3.y; } @@ -164,4 +171,7 @@ class VISP_EXPORT vpTemplateTrackerTriangle vpTemplateTrackerTriangle &operator=(const vpTemplateTrackerTriangle &T); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarp.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarp.h index 9481490b90..6f0012f482 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarp.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarp.h @@ -44,12 +44,17 @@ #ifndef vpTemplateTrackerWarp_hh #define vpTemplateTrackerWarp_hh +#include #include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerWarp \ingroup group_tt_warp @@ -64,11 +69,11 @@ class VISP_EXPORT vpTemplateTrackerWarp /*! * Default constructor. */ - vpTemplateTrackerWarp() : denom(1.), nbParam(0) {} + vpTemplateTrackerWarp() : denom(1.), nbParam(0) { } /*! * Destructor. */ - virtual ~vpTemplateTrackerWarp() {} + virtual ~vpTemplateTrackerWarp() { } #ifndef DOXYGEN_SHOULD_SKIP_THIS virtual void computeCoeff(const vpColVector &p) = 0; @@ -255,5 +260,7 @@ class VISP_EXPORT vpTemplateTrackerWarp void warpZone(const vpTemplateTrackerZone &in, const vpColVector &p, vpTemplateTrackerZone &out); //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpAffine.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpAffine.h index 2d30a78084..c56c18ac0f 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpAffine.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpAffine.h @@ -45,8 +45,13 @@ #ifndef vpTemplateTrackerWarpAffine_hh #define vpTemplateTrackerWarpAffine_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerWarpAffine \ingroup group_tt_warp @@ -70,8 +75,8 @@ class VISP_EXPORT vpTemplateTrackerWarpAffine : public vpTemplateTrackerWarp vpTemplateTrackerWarpAffine(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - void computeCoeff(const vpColVector &) {} - void computeDenom(vpColVector &, const vpColVector &) {} + void computeCoeff(const vpColVector &) { } + void computeDenom(vpColVector &, const vpColVector &) { } #endif void dWarp(const vpColVector &X, const vpColVector &, const vpColVector &, vpMatrix &dM); @@ -96,4 +101,7 @@ class VISP_EXPORT vpTemplateTrackerWarpAffine : public vpTemplateTrackerWarp void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p); void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomography.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomography.h index 93c6712f09..974953da77 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomography.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomography.h @@ -45,9 +45,14 @@ #ifndef vpTemplateTrackerWarpHomography_hh #define vpTemplateTrackerWarpHomography_hh +#include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerWarpHomography \ingroup group_tt_warp @@ -71,7 +76,7 @@ class VISP_EXPORT vpTemplateTrackerWarpHomography : public vpTemplateTrackerWarp vpTemplateTrackerWarpHomography(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - void computeCoeff(const vpColVector &) {} + void computeCoeff(const vpColVector &) { } #endif void computeDenom(vpColVector &X, const vpColVector &p); @@ -103,4 +108,7 @@ class VISP_EXPORT vpTemplateTrackerWarpHomography : public vpTemplateTrackerWarp void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p); void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomographySL3.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomographySL3.h index 9a531b5efb..3678da6398 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomographySL3.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpHomographySL3.h @@ -42,9 +42,14 @@ #include +#include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpTemplateTrackerWarpHomographySL3 * \ingroup group_tt_warp @@ -92,4 +97,7 @@ class VISP_EXPORT vpTemplateTrackerWarpHomographySL3 : public vpTemplateTrackerW void warpXInv(const vpColVector &, vpColVector &, const vpColVector &) { } #endif }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpRT.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpRT.h index b4e74b162a..548f9e73fd 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpRT.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpRT.h @@ -44,8 +44,13 @@ #ifndef vpTemplateTrackerWarpRT_hh #define vpTemplateTrackerWarpRT_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerWarpRT \ingroup group_tt_warp @@ -68,8 +73,8 @@ class VISP_EXPORT vpTemplateTrackerWarpRT : public vpTemplateTrackerWarp vpTemplateTrackerWarpRT(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - void computeCoeff(const vpColVector &) {} - void computeDenom(vpColVector &, const vpColVector &) {} + void computeCoeff(const vpColVector &) { } + void computeDenom(vpColVector &, const vpColVector &) { } #endif void dWarp(const vpColVector &X, const vpColVector &, const vpColVector &p, vpMatrix &dM); @@ -94,4 +99,7 @@ class VISP_EXPORT vpTemplateTrackerWarpRT : public vpTemplateTrackerWarp void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p); void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpSRT.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpSRT.h index 5bb8992260..7b07b789a8 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpSRT.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpSRT.h @@ -44,8 +44,13 @@ #ifndef vpTemplateTrackerWarpSRT_hh #define vpTemplateTrackerWarpSRT_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerWarpSRT \ingroup group_tt_warp @@ -69,8 +74,8 @@ class VISP_EXPORT vpTemplateTrackerWarpSRT : public vpTemplateTrackerWarp vpTemplateTrackerWarpSRT(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - void computeCoeff(const vpColVector &) {} - void computeDenom(vpColVector &, const vpColVector &) {} + void computeCoeff(const vpColVector &) { } + void computeDenom(vpColVector &, const vpColVector &) { } #endif void dWarp(const vpColVector &X, const vpColVector &, const vpColVector &p, vpMatrix &dM); @@ -95,4 +100,7 @@ class VISP_EXPORT vpTemplateTrackerWarpSRT : public vpTemplateTrackerWarp void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p); void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpTranslation.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpTranslation.h index b6c676bbe5..137bc4f447 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpTranslation.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerWarpTranslation.h @@ -44,8 +44,13 @@ #ifndef vpTemplateTrackerWarpTranslation_hh #define vpTemplateTrackerWarpTranslation_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerWarpTranslation \ingroup group_tt_warp @@ -69,8 +74,8 @@ class VISP_EXPORT vpTemplateTrackerWarpTranslation : public vpTemplateTrackerWar vpTemplateTrackerWarpTranslation(); #ifndef DOXYGEN_SHOULD_SKIP_THIS - void computeCoeff(const vpColVector &) {} - void computeDenom(vpColVector &, const vpColVector &) {} + void computeCoeff(const vpColVector &) { } + void computeDenom(vpColVector &, const vpColVector &) { } #endif void dWarp(const vpColVector &, const vpColVector &, const vpColVector &, vpMatrix &dM); @@ -95,4 +100,7 @@ class VISP_EXPORT vpTemplateTrackerWarpTranslation : public vpTemplateTrackerWar void warpX(const int &v1, const int &u1, double &v2, double &u2, const vpColVector &p); void warpXInv(const vpColVector &X1, vpColVector &X2, const vpColVector &p); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCC.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCC.h index 639407dbd5..2435d9f7af 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCC.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCC.h @@ -46,6 +46,7 @@ #include +#include #include #include #include @@ -57,6 +58,10 @@ #define APPROX_NCC +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerZNCC \ingroup group_tt_tracker @@ -82,4 +87,7 @@ class VISP_EXPORT vpTemplateTrackerZNCC : public vpTemplateTracker void setGain(double _gain) { gain = _gain; } }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCForwardAdditional.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCForwardAdditional.h index 5e5d73cf57..e01d0d26ca 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCForwardAdditional.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCForwardAdditional.h @@ -44,8 +44,13 @@ #ifndef vpTemplateTrackerZNCCForwardAdditional_hh #define vpTemplateTrackerZNCCForwardAdditional_hh +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerZNCCForwardAdditional \ingroup group_tt_tracker @@ -62,4 +67,7 @@ class VISP_EXPORT vpTemplateTrackerZNCCForwardAdditional : public vpTemplateTrac public: explicit vpTemplateTrackerZNCCForwardAdditional(vpTemplateTrackerWarp *warp); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCInverseCompositional.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCInverseCompositional.h index faae1cf606..2605b6bd37 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCInverseCompositional.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZNCCInverseCompositional.h @@ -46,8 +46,13 @@ #include +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerZNCCInverseCompositional \ingroup group_tt_tracker @@ -68,4 +73,7 @@ class VISP_EXPORT vpTemplateTrackerZNCCInverseCompositional : public vpTemplateT public: explicit vpTemplateTrackerZNCCInverseCompositional(vpTemplateTrackerWarp *warp); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZone.h b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZone.h index cca9d9fb8b..cceb9b37c6 100644 --- a/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZone.h +++ b/modules/tracker/tt/include/visp3/tt/vpTemplateTrackerZone.h @@ -41,6 +41,7 @@ #include +#include #include #include #include @@ -48,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerZone \ingroup group_tt_tools @@ -119,4 +124,7 @@ class VISP_EXPORT vpTemplateTrackerZone vpTemplateTrackerZone &operator=(const vpTemplateTrackerZone &z); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt/src/ssd/vpTemplateTrackerSSD.cpp b/modules/tracker/tt/src/ssd/vpTemplateTrackerSSD.cpp index 3c258df4ad..da3b47b584 100644 --- a/modules/tracker/tt/src/ssd/vpTemplateTrackerSSD.cpp +++ b/modules/tracker/tt/src/ssd/vpTemplateTrackerSSD.cpp @@ -39,6 +39,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerSSD::vpTemplateTrackerSSD(vpTemplateTrackerWarp *warp) : vpTemplateTracker(warp), DI(), temp() { dW.resize(2, nbParam); @@ -120,3 +124,6 @@ double vpTemplateTrackerSSD::getSSD(const vpImage &I, const vpCol return 10e10; return erreur / Nbpoint; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDESM.cpp b/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDESM.cpp index f54de5075b..2422975bd0 100644 --- a/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDESM.cpp +++ b/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDESM.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerSSDESM::vpTemplateTrackerSSDESM(vpTemplateTrackerWarp *warp) : vpTemplateTrackerSSD(warp), compoInitialised(false), HDir(), HInv(), HLMDir(), HLMInv(), GDir(), GInv() { @@ -169,7 +173,8 @@ void vpTemplateTrackerSSDESM::trackNoPyr(const vpImage &I) try { dp = (HLMDir).inverseByLU() * (GDir); - } catch (const vpException &e) { + } + catch (const vpException &e) { delete[] tempt; throw(e); } @@ -199,3 +204,6 @@ void vpTemplateTrackerSSDESM::trackNoPyr(const vpImage &I) nbIteration = iteration; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDForwardAdditional.cpp b/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDForwardAdditional.cpp index aa87773162..44f9a89035 100644 --- a/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDForwardAdditional.cpp +++ b/modules/tracker/tt/src/ssd/vpTemplateTrackerSSDForwardAdditional.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerSSDForwardAdditional::vpTemplateTrackerSSDForwardAdditional(vpTemplateTrackerWarp *warp) : vpTemplateTrackerSSD(warp), minimizationMethod(USE_NEWTON), p_prec(), G_prec(), KQuasiNewton() { @@ -124,7 +128,8 @@ void vpTemplateTrackerSSDForwardAdditional::trackNoPyr(const vpImage #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerSSDForwardCompositional::vpTemplateTrackerSSDForwardCompositional(vpTemplateTrackerWarp *warp) : vpTemplateTrackerSSD(warp), compoInitialised(false) -{ -} +{ } void vpTemplateTrackerSSDForwardCompositional::initCompo(const vpImage & /*I*/) { @@ -141,7 +144,8 @@ void vpTemplateTrackerSSDForwardCompositional::trackNoPyr(const vpImage #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerSSDInverseCompositional::vpTemplateTrackerSSDInverseCompositional(vpTemplateTrackerWarp *warp) : vpTemplateTrackerSSD(warp), compoInitialised(false), HInv(), HCompInverse(), useTemplateSelect(false) { @@ -167,3 +171,6 @@ void vpTemplateTrackerSSDInverseCompositional::trackNoPyr(const vpImage std::fabs(evolRMS_init) * evolRMS_eps)); nbIteration = iteration; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/tools/vpTemplateTrackerBSpline.cpp b/modules/tracker/tt/src/tools/vpTemplateTrackerBSpline.cpp index eb5cbd505f..b5cb76e6cd 100644 --- a/modules/tracker/tt/src/tools/vpTemplateTrackerBSpline.cpp +++ b/modules/tracker/tt/src/tools/vpTemplateTrackerBSpline.cpp @@ -38,6 +38,10 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS double vpTemplateTrackerBSpline::getSubPixBspline4(const vpImage &I, double r, double t) @@ -67,11 +71,16 @@ double vpTemplateTrackerBSpline::Bspline4(double diff) double aDiff = vpMath::abs(diff); if (aDiff < 1.) { return (aDiff * aDiff * (aDiff / 2. - 1) + 4. / 6.); - } else if (aDiff < 2.) { + } + else if (aDiff < 2.) { double a = 2. - aDiff; return (a * a * a / 6.); - } else + } + else return 0; } #endif +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/tools/vpTemplateTrackerTriangle.cpp b/modules/tracker/tt/src/tools/vpTemplateTrackerTriangle.cpp index af34542cf5..0522c7061a 100644 --- a/modules/tracker/tt/src/tools/vpTemplateTrackerTriangle.cpp +++ b/modules/tracker/tt/src/tools/vpTemplateTrackerTriangle.cpp @@ -38,21 +38,24 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. */ vpTemplateTrackerTriangle::vpTemplateTrackerTriangle() : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), uvinv00(0.), uvinv01(0.), - uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) -{ -} + uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) +{ } /*! Copy constructor. */ vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(const vpTemplateTrackerTriangle &T) : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), uvinv00(0.), uvinv01(0.), - uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) + uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) { *this = T; } @@ -104,7 +107,7 @@ vpTemplateTrackerTriangle &vpTemplateTrackerTriangle::operator=(const vpTemplate vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(const vpColVector &c1, const vpColVector &c2, const vpColVector &c3) : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), uvinv00(0.), uvinv01(0.), - uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) + uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) { init(c1[0], c1[1], c2[0], c2[1], c3[0], c3[1]); } @@ -125,7 +128,7 @@ vpTemplateTrackerTriangle vpTemplateTrackerTriangle::getPyramidDown() const */ vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(int x1, int y1, int x2, int y2, int x3, int y3) : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), uvinv00(0.), uvinv01(0.), - uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) + uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) { init(x1, y1, x2, y2, x3, y3); } @@ -139,7 +142,7 @@ vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(int x1, int y1, int x2, int vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(const vpImagePoint &c1, const vpImagePoint &c2, const vpImagePoint &c3) : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), uvinv00(0.), uvinv01(0.), - uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) + uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) { init(c1.get_u(), c1.get_v(), c2.get_u(), c2.get_v(), c3.get_u(), c3.get_v()); } @@ -151,7 +154,7 @@ vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(const vpImagePoint &c1, con */ vpTemplateTrackerTriangle::vpTemplateTrackerTriangle(double x1, double y1, double x2, double y2, double x3, double y3) : minx_temp(0), miny_temp(0), C1(), C2(), C3(), l_t(0), h_t(0), not_good(false), uvinv00(0.), uvinv01(0.), - uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) + uvinv10(0.), uvinv11(0.), marge_triangle(0.00001), area(0) { init(x1, y1, x2, y2, x3, y3); } @@ -236,7 +239,8 @@ void vpTemplateTrackerTriangle::init(double x1, double y1, double x2, double y2, try { uvinv = uv.inverseByLU(); not_good = false; - } catch (...) { + } + catch (...) { not_good = true; std::cout << "Triangle vide" << std::endl; } @@ -423,3 +427,6 @@ double vpTemplateTrackerTriangle::getMaxx() const { return minx_temp + l_t + 1; that are in the triangle. \sa getMaxx() */ double vpTemplateTrackerTriangle::getMaxy() const { return miny_temp + h_t + 1; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/tools/vpTemplateTrackerZone.cpp b/modules/tracker/tt/src/tools/vpTemplateTrackerZone.cpp index f5dd658ead..c8a133ca81 100644 --- a/modules/tracker/tt/src/tools/vpTemplateTrackerZone.cpp +++ b/modules/tracker/tt/src/tools/vpTemplateTrackerZone.cpp @@ -43,10 +43,14 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. */ -vpTemplateTrackerZone::vpTemplateTrackerZone() : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1) {} +vpTemplateTrackerZone::vpTemplateTrackerZone() : Zone(), min_x(-1), min_y(-1), max_x(-1), max_y(-1) { } /*! Copy constructor. @@ -123,7 +127,8 @@ void vpTemplateTrackerZone::initClick(const vpImage &I, bool dela if (delaunay) { // Draw a line between the 2 last points vpDisplay::displayLine(I, p, vip[vip.size() - 2], vpColor::blue, 3); - } else { + } + else { if (vip.size() % 3 == 2) // draw line between point 2-1 vpDisplay::displayLine(I, p, vip[vip.size() - 2], vpColor::blue, 3); @@ -166,7 +171,8 @@ void vpTemplateTrackerZone::initFromPoints(const vpImage &I, cons if (delaunay) { if (vip.size() == 3) { initFromPoints(I, vip, false); - } else if (vip.size() == 4) { + } + else if (vip.size() == 4) { std::vector vip_delaunay; vip_delaunay.push_back(vip[0]); vip_delaunay.push_back(vip[1]); @@ -175,7 +181,8 @@ void vpTemplateTrackerZone::initFromPoints(const vpImage &I, cons vip_delaunay.push_back(vip[3]); vip_delaunay.push_back(vip[0]); initFromPoints(I, vip_delaunay, false); - } else { + } + else { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) // Init Delaunay cv::Subdiv2D subdiv(cv::Rect(0, 0, (int)I.getWidth(), (int)I.getHeight())); @@ -213,7 +220,8 @@ void vpTemplateTrackerZone::initFromPoints(const vpImage &I, cons throw vpException(vpException::functionNotImplementedError, "Delaunay triangulation is not available!"); #endif } - } else { + } + else { Zone.clear(); for (unsigned int i = 0; i < vip.size(); i += 3) { vpTemplateTrackerTriangle triangle(vip[i], vip[i + 1], vip[i + 2]); @@ -577,3 +585,6 @@ double vpTemplateTrackerZone::getArea() const } return area; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/vpTemplateTracker.cpp b/modules/tracker/tt/src/vpTemplateTracker.cpp index 7dd4e4c17c..58c5be4c0e 100644 --- a/modules/tracker/tt/src/vpTemplateTracker.cpp +++ b/modules/tracker/tt/src/vpTemplateTracker.cpp @@ -40,16 +40,20 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTracker::vpTemplateTracker(vpTemplateTrackerWarp *_warp) : nbLvlPyr(1), l0Pyr(0), pyrInitialised(false), evolRMS(0), x_pos(), y_pos(), evolRMS_eps(1e-4), ptTemplate(nullptr), - ptTemplatePyr(nullptr), ptTemplateInit(false), templateSize(0), templateSizePyr(nullptr), ptTemplateSelect(nullptr), - ptTemplateSelectPyr(nullptr), ptTemplateSelectInit(false), templateSelectSize(0), ptTemplateSupp(nullptr), - ptTemplateSuppPyr(nullptr), ptTemplateCompo(nullptr), ptTemplateCompoPyr(nullptr), zoneTracked(nullptr), zoneTrackedPyr(nullptr), - pyr_IDes(nullptr), H(), Hdesire(), HdesirePyr(), HLM(), HLMdesire(), HLMdesirePyr(), HLMdesireInverse(), - HLMdesireInversePyr(), G(), gain(1.), thresholdGradient(40), costFunctionVerification(false), blur(true), - useBrent(false), nbIterBrent(3), taillef(7), fgG(nullptr), fgdG(nullptr), ratioPixelIn(0), mod_i(1), mod_j(1), nbParam(0), - lambdaDep(0.001), iterationMax(30), iterationGlobale(0), diverge(false), nbIteration(0), useCompositionnal(true), - useInverse(false), Warp(_warp), p(0), dp(), X1(), X2(), dW(), BI(), dIx(), dIy(), zoneRef_() + ptTemplatePyr(nullptr), ptTemplateInit(false), templateSize(0), templateSizePyr(nullptr), ptTemplateSelect(nullptr), + ptTemplateSelectPyr(nullptr), ptTemplateSelectInit(false), templateSelectSize(0), ptTemplateSupp(nullptr), + ptTemplateSuppPyr(nullptr), ptTemplateCompo(nullptr), ptTemplateCompoPyr(nullptr), zoneTracked(nullptr), zoneTrackedPyr(nullptr), + pyr_IDes(nullptr), H(), Hdesire(), HdesirePyr(), HLM(), HLMdesire(), HLMdesirePyr(), HLMdesireInverse(), + HLMdesireInversePyr(), G(), gain(1.), thresholdGradient(40), costFunctionVerification(false), blur(true), + useBrent(false), nbIterBrent(3), taillef(7), fgG(nullptr), fgdG(nullptr), ratioPixelIn(0), mod_i(1), mod_j(1), nbParam(0), + lambdaDep(0.001), iterationMax(30), iterationGlobale(0), diverge(false), nbIteration(0), useCompositionnal(true), + useInverse(false), Warp(_warp), p(0), dp(), X1(), X2(), dW(), BI(), dIx(), dIy(), zoneRef_() { nbParam = Warp->getNbParam(); p.resize(nbParam); @@ -125,7 +129,8 @@ void vpTemplateTracker::initTracking(const vpImage &I, vpTemplate if (pt.dx * pt.dx + pt.dy * pt.dy > thresholdGradient) { ptTemplateSelect[cpt_point] = true; templateSelectSize++; - } else { + } + else { ptTemplateSelect[cpt_point] = false; } pt.val = vpTemplateTrackerBSpline::getSubPixBspline4(GaussI, i, j); @@ -241,7 +246,8 @@ void vpTemplateTracker::resetTracker() delete[] pyr_IDes; pyr_IDes = nullptr; } - } else { + } + else { if (ptTemplateInit) { for (unsigned int point = 0; point < templateSize; point++) { delete[] ptTemplate[point].dW; @@ -382,7 +388,8 @@ void vpTemplateTracker::computeOptimalBrentGain(const vpImage &I, else dpt = direction; Warp->pRondp(tp, dpt, p1); - } else { + } + else { p1 = tp + direction; } @@ -394,7 +401,8 @@ void vpTemplateTracker::computeOptimalBrentGain(const vpImage &I, else dpt = adpt; Warp->pRondp(tp, dpt, p2); - } else { + } + else { p2 = tp + alpha * direction; } vpColVector p3(nbParam); @@ -431,7 +439,8 @@ void vpTemplateTracker::computeOptimalBrentGain(const vpImage &I, // If convexe if (parabol[0] > 0) { talpha[3] = -0.5 * parabol[1] / parabol[0]; - } else { // If concave + } + else { // If concave int tindic_x_min = 0; int tindic_x_max = 0; for (int i = 1; i < 3; i++) { @@ -443,7 +452,8 @@ void vpTemplateTracker::computeOptimalBrentGain(const vpImage &I, if (Cost[tindic_x_max] < Cost[tindic_x_min]) { talpha[3] = talpha[tindic_x_max] + 1.; - } else { + } + else { talpha[3] = talpha[tindic_x_min] - 1.; } } @@ -469,7 +479,8 @@ void vpTemplateTracker::computeOptimalBrentGain(const vpImage &I, else dpt = adpt; Warp->pRondp(tp, dpt, p3); - } else { + } + else { p3 = tp + talpha[3] * direction; } @@ -483,7 +494,8 @@ void vpTemplateTracker::computeOptimalBrentGain(const vpImage &I, *ptp[indice_f_max] = *ptp[3]; Cost[indice_f_max] = Cost[3]; talpha[indice_f_max] = talpha[3]; - } else + } + else break; } @@ -586,7 +598,8 @@ void vpTemplateTracker::initClick(const vpImage &I, bool delaunay initPyramidal(nbLvlPyr, l0Pyr); initTrackingPyr(I, zoneRef_); initHessienDesiredPyr(I); - } else { + } + else { initTracking(I, zoneRef_); initHessienDesired(I); } @@ -612,7 +625,8 @@ void vpTemplateTracker::initFromPoints(const vpImage &I, const st initPyramidal(nbLvlPyr, l0Pyr); initTrackingPyr(I, zoneRef_); initHessienDesiredPyr(I); - } else { + } + else { initTracking(I, zoneRef_); initHessienDesired(I); } @@ -632,7 +646,8 @@ void vpTemplateTracker::initFromZone(const vpImage &I, const vpTe initPyramidal(nbLvlPyr, l0Pyr); initTrackingPyr(I, zoneRef_); initHessienDesiredPyr(I); - } else { + } + else { initTracking(I, zoneRef_); initHessienDesired(I); } @@ -650,7 +665,8 @@ void vpTemplateTracker::initHessienDesiredPyr(const vpImage &I) HdesirePyr[0] = Hdesire; HLMdesirePyr[0] = HLMdesire; HLMdesireInversePyr[0] = HLMdesireInverse; - } catch (const vpException &e) { + } + catch (const vpException &e) { ptTemplateSuppPyr[0] = ptTemplateSupp; ptTemplateCompoPyr[0] = ptTemplateCompo; HdesirePyr[0] = Hdesire; @@ -675,7 +691,8 @@ void vpTemplateTracker::initHessienDesiredPyr(const vpImage &I) HdesirePyr[i] = Hdesire; HLMdesirePyr[i] = HLMdesire; HLMdesireInversePyr[i] = HLMdesireInverse; - } catch (const vpException &e) { + } + catch (const vpException &e) { ptTemplateSuppPyr[i] = ptTemplateSupp; ptTemplateCompoPyr[i] = ptTemplateCompo; HdesirePyr[i] = Hdesire; @@ -733,11 +750,13 @@ void vpTemplateTracker::trackPyr(const vpImage &I) zoneTracked = &zoneTrackedPyr[i - 1]; } } - } else { + } + else { trackRobust(I); } delete[] pyr_I; - } catch (const vpException &e) { + } + catch (const vpException &e) { delete[] pyr_I; throw(vpTrackingException(vpTrackingException::badValue, e.getMessage())); } @@ -757,7 +776,8 @@ void vpTemplateTracker::trackRobust(const vpImage &I) if (pre_fcost < post_fcost) { p = p_pre_estimation; } - } else { + } + else { trackNoPyr(I); } } @@ -823,3 +843,6 @@ void vpTemplateTracker::initPosEvalRMS(const vpColVector ¶m) } } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/warp/vpTemplateTrackerWarp.cpp b/modules/tracker/tt/src/warp/vpTemplateTrackerWarp.cpp index e6788ec31f..905541fddb 100644 --- a/modules/tracker/tt/src/warp/vpTemplateTrackerWarp.cpp +++ b/modules/tracker/tt/src/warp/vpTemplateTrackerWarp.cpp @@ -38,13 +38,17 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpTemplateTrackerWarp::warpTriangle(const vpTemplateTrackerTriangle &in, const vpColVector &p, vpTemplateTrackerTriangle &out) { if (p.size() < 2) { vpCTRACE << "Bad template tracker warp parameters dimension. Should " - "never occur. " - << std::endl; + "never occur. " + << std::endl; throw(vpException(vpException::dimensionError, "Bad template tracker warp parameters dimension")); } vpColVector S1(2), S2(2), S3(2); @@ -149,8 +153,9 @@ void vpTemplateTrackerWarp::findWarp(const double *ut0, const double *vt0, const vpMatrix::computeHLM(H, lambda, HLM); try { p += (vpColVector)(HLM.inverseByLU() * G, 0u); - } catch (const vpException &e) { - // std::cout<<"Cannot inverse the matrix by LU " << std::endl; + } + catch (const vpException &e) { + // std::cout<<"Cannot inverse the matrix by LU " << std::endl; throw(e); } cpt++; @@ -158,3 +163,6 @@ void vpTemplateTrackerWarp::findWarp(const double *ut0, const double *vt0, const // std::cout<<"erreur apres transformation="< +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Construct a model with 6 affine parameters initialized to zero. */ @@ -221,7 +225,7 @@ void vpTemplateTrackerWarpAffine::getParamInverse(const vpColVector &p, vpColVec double det = r_00 * r_11 - r_01 * r_10; if (std::fabs(det) < std::numeric_limits::epsilon()) { throw(vpException(vpException::fatalError, "In vpTemplateTrackerWarpAffine::getParamInverse() " - "cannot inverse 2-by-2 matrix. Matrix determinant is 0.")); + "cannot inverse 2-by-2 matrix. Matrix determinant is 0.")); } double ri_11 = r_00 / det; @@ -263,3 +267,6 @@ void vpTemplateTrackerWarpAffine::pRondp(const vpColVector &p1, const vpColVecto p12[4] = r1_00 * u2 + r1_01 * v2 + u1; p12[5] = r1_10 * u2 + r1_11 * v2 + v1; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomography.cpp b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomography.cpp index 1fe19dced2..e446421837 100644 --- a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomography.cpp +++ b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomography.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Construct an homography model with 8 parameters initialized to zero. */ @@ -151,7 +155,8 @@ void vpTemplateTrackerWarpHomography::computeDenom(vpColVector &X, const vpColVe if (std::fabs(value) > std::numeric_limits::epsilon()) { denom = (1. / value); - } else { + } + else { throw(vpTrackingException(vpTrackingException::fatalError, "Division by zero in vpTemplateTrackerWarpHomography::computeDenom()")); } @@ -259,10 +264,11 @@ void vpTemplateTrackerWarpHomography::warpXInv(const vpColVector &X1, vpColVecto if (std::fabs(value) > std::numeric_limits::epsilon()) { X2[0] = ((1 + p[0]) * X1[0] + p[3] * X1[1] + p[6]) / value; X2[1] = (p[1] * X1[0] + (1 + p[4]) * X1[1] + p[7]) / value; - } else { + } + else { throw(vpTrackingException(vpTrackingException::fatalError, "Division by zero in " - "vpTemplateTrackerWarpHomography::" - "warpXInv()")); + "vpTemplateTrackerWarpHomography::" + "warpXInv()")); } } @@ -400,3 +406,6 @@ void vpTemplateTrackerWarpHomography::pRondp(const vpColVector &p1, const vpColV p12[2] = (h1_20 * h2_00 + h1_21 * h2_10 + h2_20) / h12_22; p12[5] = (h1_20 * h2_01 + h1_21 * h2_11 + h2_21) / h12_22; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomographySL3.cpp b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomographySL3.cpp index 666ee5827b..84b7044c5d 100644 --- a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomographySL3.cpp +++ b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpHomographySL3.cpp @@ -38,6 +38,10 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif // findWarp special a SL3 car methode additionnelle ne marche pas (la derivee // n est calculable qu en p=0) // => resout le probleme de maniere compositionnelle @@ -526,3 +530,6 @@ void vpTemplateTrackerWarpHomographySL3::pRondp(const vpColVector &p1, const vpC // vrai que si commutatif ... p12 = p1 + p2; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpRT.cpp b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpRT.cpp index ab731939b8..eac47617d9 100644 --- a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpRT.cpp +++ b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpRT.cpp @@ -38,6 +38,10 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Construct a model with 3 parameters for rotation and translation initialized to zero. */ @@ -242,3 +246,6 @@ void vpTemplateTrackerWarpRT::pRondp(const vpColVector &p1, const vpColVector &p p12[1] = c1 * u2 - s1 * v2 + u1; p12[2] = s1 * u2 + c1 * v2 + v1; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpSRT.cpp b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpSRT.cpp index 9969666e30..ee79a9ed61 100644 --- a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpSRT.cpp +++ b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpSRT.cpp @@ -38,6 +38,10 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Construct a model with 4 parameters for scale, rotation and translation initialized to zero. */ @@ -261,3 +265,6 @@ void vpTemplateTrackerWarpSRT::pRondp(const vpColVector &p1, const vpColVector & p12[2] = scale1 * (c1 * u2 - s1 * v2) + u1; p12[3] = scale1 * (s1 * u2 + c1 * v2) + v1; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpTranslation.cpp b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpTranslation.cpp index 6ae4e03eeb..7463f1b30e 100644 --- a/modules/tracker/tt/src/warp/vpTemplateTrackerWarpTranslation.cpp +++ b/modules/tracker/tt/src/warp/vpTemplateTrackerWarpTranslation.cpp @@ -38,6 +38,10 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Construct a model with 2 parameters for translation initialized to zero. */ @@ -194,3 +198,6 @@ void vpTemplateTrackerWarpTranslation::pRondp(const vpColVector &p1, const vpCol p12[0] = p1[0] + p2[0]; p12[1] = p1[1] + p2[1]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCC.cpp b/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCC.cpp index 97e311baf6..c03f605f88 100644 --- a/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCC.cpp +++ b/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCC.cpp @@ -38,6 +38,10 @@ *****************************************************************************/ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerZNCC::vpTemplateTrackerZNCC(vpTemplateTrackerWarp *warp) : vpTemplateTracker(warp), DI(), temp() { dW.resize(2, nbParam); @@ -119,3 +123,6 @@ double vpTemplateTrackerZNCC::getCost(const vpImage &I, const vpC } return -nom / sqrt(var1 * var2); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp b/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp index b5c5961db6..5f0cbea215 100644 --- a/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp +++ b/modules/tracker/tt/src/zncc/vpTemplateTrackerZNCCForwardAdditional.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerZNCCForwardAdditional::vpTemplateTrackerZNCCForwardAdditional(vpTemplateTrackerWarp *warp) : vpTemplateTrackerZNCC(warp) { @@ -252,7 +256,8 @@ void vpTemplateTrackerZNCCForwardAdditional::trackNoPyr(const vpImage #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerZNCCInverseCompositional::vpTemplateTrackerZNCCInverseCompositional(vpTemplateTrackerWarp *warp) : vpTemplateTrackerZNCC(warp), compoInitialised(false), moydIrefdp() { @@ -194,7 +198,7 @@ void vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(const vpImage sIcd2Iref[it][jt] += prodIc * (dW[0][it] * (dW[0][jt] * d_Ixx + dW[1][jt] * d_Ixy) + dW[1][it] * (dW[0][jt] * d_Ixy + dW[1][jt] * d_Iyy) - moyd2Iref[it][jt]); sdIrefdIref[it][jt] += - (ptTemplate[point].dW[it] - moydIrefdp[it]) * (ptTemplate[point].dW[jt] - moydIrefdp[jt]); + (ptTemplate[point].dW[it] - moydIrefdp[it]) * (ptTemplate[point].dW[jt] - moydIrefdp[jt]); } } @@ -323,7 +327,8 @@ void vpTemplateTrackerZNCCInverseCompositional::trackNoPyr(const vpImage::epsilon()) { diverge = true; - } else { + } + else { double NCC = sIcIref / denom; vpColVector dcovarIref(nbParam); dcovarIref = sIrefdIref / covarIref; @@ -331,7 +336,8 @@ void vpTemplateTrackerZNCCInverseCompositional::trackNoPyr(const vpImage #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpTemplateTrackerMI * \ingroup group_tt_mi_tracker @@ -165,5 +169,7 @@ class VISP_EXPORT vpTemplateTrackerMI : public vpTemplateTracker void setLambda(double _l) { lambda = _l; } void setNc(int newNc); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIBSpline.h b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIBSpline.h index 82201e4e0a..12be780682 100644 --- a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIBSpline.h +++ b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIBSpline.h @@ -54,7 +54,10 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpTemplateTrackerMIBSpline { public: @@ -118,6 +121,8 @@ class VISP_EXPORT vpTemplateTrackerMIBSpline unsigned int &NbParam, int &bspline, vpTemplateTrackerMI::vpHessienApproximationType &approx, bool use_hessien_des); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif 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 4f92ef50a0..deb09efcaa 100644 --- a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIESM.h +++ b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIESM.h @@ -39,6 +39,7 @@ #ifndef vpTemplateTrackerMIESM_hh #define vpTemplateTrackerMIESM_hh +#include #include #include #include @@ -46,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerMIESM \ingroup group_tt_mi_tracker @@ -104,5 +109,7 @@ class VISP_EXPORT vpTemplateTrackerMIESM : public vpTemplateTrackerMI void setMinimizationMethod(vpMinimizationTypeMIESM method) { minimizationMethod = method; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardAdditional.h b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardAdditional.h index 161c5d210b..71c767cb32 100644 --- a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardAdditional.h +++ b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardAdditional.h @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerMIForwardAdditional \ingroup group_tt_mi_tracker @@ -75,10 +79,11 @@ class VISP_EXPORT vpTemplateTrackerMIForwardAdditional : public vpTemplateTracke //! Default constructor. vpTemplateTrackerMIForwardAdditional() : vpTemplateTrackerMI(), minimizationMethod(USE_NEWTON), p_prec(), G_prec(), KQuasiNewton() - { - } + { } explicit vpTemplateTrackerMIForwardAdditional(vpTemplateTrackerWarp *_warp); void setMinimizationMethod(vpMinimizationTypeMIForwardAdditional method) { minimizationMethod = method; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardCompositional.h b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardCompositional.h index ecb71dff50..7e19853b5f 100644 --- a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardCompositional.h +++ b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIForwardCompositional.h @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerMIForwardCompositional \ingroup group_tt_mi_tracker @@ -67,5 +71,7 @@ class VISP_EXPORT vpTemplateTrackerMIForwardCompositional : public vpTemplateTra public: explicit vpTemplateTrackerMIForwardCompositional(vpTemplateTrackerWarp *_warp); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIInverseCompositional.h b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIInverseCompositional.h index 876ed586d8..9357051651 100644 --- a/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIInverseCompositional.h +++ b/modules/tracker/tt_mi/include/visp3/tt_mi/vpTemplateTrackerMIInverseCompositional.h @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpTemplateTrackerMIInverseCompositional \ingroup group_tt_mi_tracker @@ -84,9 +88,8 @@ class VISP_EXPORT vpTemplateTrackerMIInverseCompositional : public vpTemplateTra //! Default constructor. vpTemplateTrackerMIInverseCompositional() : vpTemplateTrackerMI(), minimizationMethod(USE_LMA), CompoInitialised(false), useTemplateSelect(false), p_prec(), - G_prec(), KQuasiNewton() - { - } + G_prec(), KQuasiNewton() + { } explicit vpTemplateTrackerMIInverseCompositional(vpTemplateTrackerWarp *_warp); /*! Use only the strong gradient pixels to compute the Jabobian. By default @@ -94,4 +97,7 @@ class VISP_EXPORT vpTemplateTrackerMIInverseCompositional : public vpTemplateTra void setUseTemplateSelect(bool b) { useTemplateSelect = b; } void setMinimizationMethod(vpMinimizationTypeMIInverseCompositional method) { minimizationMethod = method; } }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMI.cpp b/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMI.cpp index 634b7a300f..7c8d5659f1 100644 --- a/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMI.cpp +++ b/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMI.cpp @@ -40,6 +40,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpTemplateTrackerMI::setBspline(const vpBsplineType &newbs) { bspline = (int)newbs; @@ -758,3 +762,6 @@ double vpTemplateTrackerMI::getMI256(const vpImage &I, const vpCo } return MI; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIESM.cpp b/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIESM.cpp index 2238f304a0..09d01d29bf 100644 --- a/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIESM.cpp +++ b/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIESM.cpp @@ -43,9 +43,13 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerMIESM::vpTemplateTrackerMIESM(vpTemplateTrackerWarp *_warp) : vpTemplateTrackerMI(_warp), minimizationMethod(USE_NEWTON), CompoInitialised(false), HDirect(), HInverse(), - HdesireDirect(), HdesireInverse(), GDirect(), GInverse() + HdesireDirect(), HdesireInverse(), GDirect(), GInverse() { useCompositionnal = false; useInverse = false; @@ -293,7 +297,8 @@ void vpTemplateTrackerMIESM::trackNoPyr(const vpImage &I) diverge = true; MI = 0; throw(vpTrackingException(vpTrackingException::notEnoughPointError, "No points in the template")); - } else { + } + else { computeProba(Nbpoint); computeMI(MI); if (hessianComputation != vpTemplateTrackerMI::USE_HESSIEN_DESIRE) { @@ -377,7 +382,8 @@ void vpTemplateTrackerMIESM::trackNoPyr(const vpImage &I) case vpTemplateTrackerMI::USE_HESSIEN_BEST_COND: if (HLM.cond() > HLMdesire.cond()) { dp = gain * HLMdesireInverse * G; - } else { + } + else { dp = gain * 0.3 * HLM.inverseByLU() * G; } break; @@ -386,7 +392,8 @@ void vpTemplateTrackerMIESM::trackNoPyr(const vpImage &I) break; } } - } catch (const vpException &e) { + } + catch (const vpException &e) { throw(e); } @@ -411,3 +418,6 @@ void vpTemplateTrackerMIESM::trackNoPyr(const vpImage &I) nbIteration = iteration; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIForwardAdditional.cpp b/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIForwardAdditional.cpp index 91ab3f8db9..3bed29421d 100644 --- a/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIForwardAdditional.cpp +++ b/modules/tracker/tt_mi/src/mi/vpTemplateTrackerMIForwardAdditional.cpp @@ -43,6 +43,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerMIForwardAdditional::vpTemplateTrackerMIForwardAdditional(vpTemplateTrackerWarp *_warp) : vpTemplateTrackerMI(_warp), minimizationMethod(USE_NEWTON), p_prec(), G_prec(), KQuasiNewton() { @@ -122,7 +126,8 @@ void vpTemplateTrackerMIForwardAdditional::initHessienDesired(const vpImage MI) { p = p_test_LMA; lambda = (lambda / 10. < 1e-6) ? lambda / 10. : 1e-6; - } else { + } + else { lambda = (lambda * 10. < 1e6) ? 1e6 : lambda * 10.; } } break; @@ -325,3 +333,6 @@ void vpTemplateTrackerMIForwardAdditional::trackNoPyr(const vpImage +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerMIForwardCompositional::vpTemplateTrackerMIForwardCompositional(vpTemplateTrackerWarp *_warp) : vpTemplateTrackerMI(_warp), CompoInitialised(false) -{ -} +{ } void vpTemplateTrackerMIForwardCompositional::initCompo() { @@ -228,7 +231,8 @@ void vpTemplateTrackerMIForwardCompositional::trackNoPyr(const vpImage +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpTemplateTrackerMIInverseCompositional::vpTemplateTrackerMIInverseCompositional(vpTemplateTrackerWarp *_warp) : vpTemplateTrackerMI(_warp), minimizationMethod(USE_LMA), CompoInitialised(false), useTemplateSelect(false), - p_prec(), G_prec(), KQuasiNewton() + p_prec(), G_prec(), KQuasiNewton() { useInverse = true; } @@ -65,7 +69,8 @@ void vpTemplateTrackerMIInverseCompositional::initTemplateRefBspline(unsigned in ptBspFct = &vpTemplateTrackerMIBSpline::Bspline3; ptdBspFct = &vpTemplateTrackerMIBSpline::dBspline3; ptd2BspFct = &vpTemplateTrackerMIBSpline::d2Bspline3; - } else { + } + else { ptBspFct = &vpTemplateTrackerBSpline::Bspline4; ptdBspFct = &vpTemplateTrackerMIBSpline::dBspline4; ptd2BspFct = &vpTemplateTrackerMIBSpline::d2Bspline4; @@ -77,10 +82,10 @@ void vpTemplateTrackerMIInverseCompositional::initTemplateRefBspline(unsigned in for (unsigned int ip = 0; ip < nbParam; ++ip) { ptTemplateSupp[ptIndex].BtInit[index++] = - (*ptdBspFct)(static_cast(-it) + et) * ptTemplate[ptIndex].dW[ip] * (-1.0); + (*ptdBspFct)(static_cast(-it) + et) * ptTemplate[ptIndex].dW[ip] * (-1.0); for (unsigned int ip2 = 0; ip2 < nbParam; ++ip2) { ptTemplateSupp[ptIndex].BtInit[index++] = - (*ptd2BspFct)(static_cast(-it) + et) * ptTemplate[ptIndex].dW[ip] * ptTemplate[ptIndex].dW[ip2]; + (*ptd2BspFct)(static_cast(-it) + et) * ptTemplate[ptIndex].dW[ip] * ptTemplate[ptIndex].dW[ip2]; } } } @@ -166,14 +171,17 @@ void vpTemplateTrackerMIInverseCompositional::initHessienDesired(const vpImage(Ncb); @@ -323,7 +335,8 @@ void vpTemplateTrackerMIInverseCompositional::trackNoPyr(const vpImage MI) { dp = dp_test_LMA; lambda = (lambda / 10. < 1e-6) ? lambda / 10. : 1e-6; - } else { + } + else { dp = 0; lambda = (lambda * 10. < 1e6) ? 1e6 : lambda * 10.; } @@ -405,7 +419,8 @@ void vpTemplateTrackerMIInverseCompositional::trackNoPyr(const vpImagegetNbParam(), Warp->getNbParam()); covarianceMatrix = -1; MI_postEstimation = -1; @@ -429,3 +445,6 @@ void vpTemplateTrackerMIInverseCompositional::trackNoPyr(const vpImage #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpTemplateTrackerMIBSpline::PutPVBsplineD(double *Prt, int cr, double er, int ct, double et, int Nc, double val, const int °re) { @@ -72,7 +75,8 @@ void vpTemplateTrackerMIBSpline::PutPVBsplineD3(double *Prt, int cr, double er, *pt++ += Bspline3_diff_r_ * Bspline3(it - et) * val; } } - } else { + } + else { for (int ir = -1; ir <= 1; ir++) { double Bspline3_diff_r_ = Bspline3(ir - er); for (int it = -1; it <= 1; it++) { @@ -100,7 +104,8 @@ void vpTemplateTrackerMIBSpline::PutPVBsplineD4(double *Prt, int cr, double er, *pt++ += Br * (*ptBti++) * val; } } - } else { + } + else { for (int ir = -1; ir <= 2; ir++) { double Br = Bspline4i(ir - er, ir); ptBti = &Bti[0]; @@ -164,14 +169,18 @@ double vpTemplateTrackerMIBSpline::dBspline4(double diff) if ((diff > -2.) && (diff <= -1.)) { double diff_2_ = diff + 2.; return (diff_2_ * diff_2_ * 0.5); - } else if ((diff > -1.) && (diff <= 0.)) { + } + else if ((diff > -1.) && (diff <= 0.)) { return -1.5 * diff * diff - 2. * diff; - } else if ((diff > 0.) && (diff <= 1.)) { + } + else if ((diff > 0.) && (diff <= 1.)) { return 1.5 * diff * diff - 2. * diff; - } else if ((diff > 1.) && (diff <= 2.)) { + } + else if ((diff > 1.) && (diff <= 2.)) { double diff_2_ = diff - 2.; return (-0.5 * diff_2_ * diff_2_); - } else { + } + else { return 0; } } @@ -407,7 +416,7 @@ void vpTemplateTrackerMIBSpline::PutTotPVBspline4(double *Prt, double *dPrt, dou double Bti[4]; double dBti[4]; double d2Bti[4]; - + for (size_t i = 0; i < 4; ++i) { Bti[i] = 0.; dBti[i] = 0.; @@ -609,8 +618,8 @@ void vpTemplateTrackerMIBSpline::PutTotPVBspline3NoSecond(double *Prt, double *d void vpTemplateTrackerMIBSpline::PutTotPVBspline4NoSecond(double *Prt, int &cr, double &er, int &ct, double &et, int &Nc, double *val, unsigned int &NbParam) { - double Bti[4] = {0, 0, 0, 0}; - double dBti[4] = {0, 0, 0, 0}; + double Bti[4] = { 0, 0, 0, 0 }; + double dBti[4] = { 0, 0, 0, 0 }; for (char it = -1; it <= 2; it++) { Bti[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et); @@ -638,8 +647,8 @@ void vpTemplateTrackerMIBSpline::PutTotPVBspline4NoSecond(double *Prt, int &cr, void vpTemplateTrackerMIBSpline::PutTotPVBspline4NoSecond(double *Prt, double *dPrt, int &cr, double &er, int &ct, double &et, int &Ncb, double *val, unsigned int &NbParam) { - double Bti[4] = {0, 0, 0, 0}; - double dBti[4] = {0, 0, 0, 0}; + double Bti[4] = { 0, 0, 0, 0 }; + double dBti[4] = { 0, 0, 0, 0 }; for (char it = -1; it <= 2; it++) { Bti[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et); @@ -692,7 +701,7 @@ void vpTemplateTrackerMIBSpline::PutTotPVBspline3PrtTout(double *PrtTout, int &c et = et - 1; } - double Bti[3] = {0, 0, 0}; + double Bti[3] = { 0, 0, 0 }; for (char it = -1; it <= 1; it++) { Bti[it + 1] = Bspline3(-it + et); @@ -713,7 +722,7 @@ void vpTemplateTrackerMIBSpline::PutTotPVBspline3PrtTout(double *PrtTout, int &c void vpTemplateTrackerMIBSpline::PutTotPVBspline4PrtTout(double *PrtTout, int &cr, double &er, int &ct, double &et, int &Nc, unsigned int &NbParam) { - double Bti[4] = {0, 0, 0, 0}; + double Bti[4] = { 0, 0, 0, 0 }; for (char it = -1; it <= 2; it++) { Bti[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et); @@ -757,7 +766,7 @@ void vpTemplateTrackerMIBSpline::PutTotPVBspline3Prt(double *Prt, int &cr, doubl et = et - 1; } - double Bti[3] = {0, 0, 0}; + double Bti[3] = { 0, 0, 0 }; for (char it = -1; it <= 1; it++) { Bti[it + 1] = Bspline3(-it + et); @@ -778,7 +787,7 @@ void vpTemplateTrackerMIBSpline::PutTotPVBspline3Prt(double *Prt, int &cr, doubl void vpTemplateTrackerMIBSpline::PutTotPVBspline4Prt(double *Prt, int &cr, double &er, int &ct, double &et, int &Ncb) { - double Bti[4] = {0, 0, 0, 0}; + double Bti[4] = { 0, 0, 0, 0 }; for (char it = -1; it <= 2; it++) { Bti[it + 1] = vpTemplateTrackerBSpline::Bspline4(-it + et); @@ -805,12 +814,15 @@ void vpTemplateTrackerMIBSpline::computeProbabilities(double *Prt, int &cr, doub PutTotPVBspline3NoSecond(Prt, cr, er, ct, et, Nc, dW, NbParam); else PutTotPVBspline4NoSecond(Prt, cr, er, ct, et, Nc, dW, NbParam); - } else { + } + else { if (bspline == 3) PutTotPVBspline3(Prt, cr, er, ct, et, Nc, dW, NbParam); else PutTotPVBspline4(Prt, cr, er, ct, et, Nc, dW, NbParam); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vision/include/visp3/vision/vpBasicKeyPoint.h b/modules/vision/include/visp3/vision/vpBasicKeyPoint.h index 612cd02db8..b0c8c8bc34 100644 --- a/modules/vision/include/visp3/vision/vpBasicKeyPoint.h +++ b/modules/vision/include/visp3/vision/vpBasicKeyPoint.h @@ -46,6 +46,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpBasicKeyPoint * \ingroup group_vision_keypoints @@ -279,5 +283,7 @@ class VISP_EXPORT vpBasicKeyPoint private: virtual void init() = 0; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vision/include/visp3/vision/vpCalibration.h b/modules/vision/include/visp3/vision/vpCalibration.h index fe032b46d3..3da256de8a 100644 --- a/modules/vision/include/visp3/vision/vpCalibration.h +++ b/modules/vision/include/visp3/vision/vpCalibration.h @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpCalibration * @@ -339,5 +343,7 @@ class VISP_EXPORT vpCalibration static unsigned int m_nbIterMax; static double m_gain; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vision/include/visp3/vision/vpCalibrationException.h b/modules/vision/include/visp3/vision/vpCalibrationException.h index ab1af21145..051f92d63a 100644 --- a/modules/vision/include/visp3/vision/vpCalibrationException.h +++ b/modules/vision/include/visp3/vision/vpCalibrationException.h @@ -40,6 +40,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpCalibrationException * \brief Error that can be emitted by the vpCalibration class. @@ -90,5 +94,7 @@ class VISP_EXPORT vpCalibrationException : public vpException */ explicit vpCalibrationException(int id) : vpException(id) { } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vision/include/visp3/vision/vpHandEyeCalibration.h b/modules/vision/include/visp3/vision/vpHandEyeCalibration.h index 7fadeff41f..b6f165c957 100644 --- a/modules/vision/include/visp3/vision/vpHandEyeCalibration.h +++ b/modules/vision/include/visp3/vision/vpHandEyeCalibration.h @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpHandEyeCalibration * @@ -94,5 +98,7 @@ class VISP_EXPORT vpHandEyeCalibration static int calibrationVVS(const std::vector &cMo, const std::vector &rMe, vpHomogeneousMatrix &eMc); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vision/include/visp3/vision/vpHomography.h b/modules/vision/include/visp3/vision/vpHomography.h index 2e5e363bab..94421991fc 100644 --- a/modules/vision/include/visp3/vision/vpHomography.h +++ b/modules/vision/include/visp3/vision/vpHomography.h @@ -52,7 +52,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/include/visp3/vision/vpKeyPoint.h b/modules/vision/include/visp3/vision/vpKeyPoint.h index 26ffadf8c4..05c3711e6c 100644 --- a/modules/vision/include/visp3/vision/vpKeyPoint.h +++ b/modules/vision/include/visp3/vision/vpKeyPoint.h @@ -73,6 +73,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpKeyPoint * \ingroup group_vision_keypoints group_detection_keypoint group_detection_mbt_object @@ -2252,6 +2256,8 @@ class VISP_EXPORT vpKeyPoint : public vpBasicKeyPoint #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/vision/include/visp3/vision/vpPlaneEstimation.h b/modules/vision/include/visp3/vision/vpPlaneEstimation.h index 8816bb3ce5..c2d2e84a81 100644 --- a/modules/vision/include/visp3/vision/vpPlaneEstimation.h +++ b/modules/vision/include/visp3/vision/vpPlaneEstimation.h @@ -52,6 +52,11 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! * \class vpPlaneEstimation * \ingroup group_vision_plane @@ -83,5 +88,7 @@ class VISP_EXPORT vpPlaneEstimation //! Maximal subsampling factor applied to the point cloud to estimate a plane static constexpr auto MaxSubSampFactorToEstimatePlane { 20u }; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vision/include/visp3/vision/vpPose.h b/modules/vision/include/visp3/vision/vpPose.h index 67d6dce801..98a3715088 100644 --- a/modules/vision/include/visp3/vision/vpPose.h +++ b/modules/vision/include/visp3/vision/vpPose.h @@ -63,7 +63,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/include/visp3/vision/vpPoseException.h b/modules/vision/include/visp3/vision/vpPoseException.h index de51ec66ad..3ba183d6e9 100644 --- a/modules/vision/include/visp3/vision/vpPoseException.h +++ b/modules/vision/include/visp3/vision/vpPoseException.h @@ -40,7 +40,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/include/visp3/vision/vpPoseFeatures.h b/modules/vision/include/visp3/vision/vpPoseFeatures.h index 7428e422c5..83bad94e97 100644 --- a/modules/vision/include/visp3/vision/vpPoseFeatures.h +++ b/modules/vision/include/visp3/vision/vpPoseFeatures.h @@ -62,6 +62,11 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS //################################################# //## Call a function with a tuple as parameters @@ -806,6 +811,10 @@ void vpPoseFeatures::addSpecificFeature(ObjType *obj, RetType(ObjType:: *fct_ptr if (m_featureSpecific_list.size() > m_maxSize) m_maxSize = static_cast(m_featureSpecific_list.size()); } + +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/vision/include/visp3/vision/vpXmlConfigParserKeyPoint.h b/modules/vision/include/visp3/vision/vpXmlConfigParserKeyPoint.h index eaf7e67cfb..2c3f99a13f 100644 --- a/modules/vision/include/visp3/vision/vpXmlConfigParserKeyPoint.h +++ b/modules/vision/include/visp3/vision/vpXmlConfigParserKeyPoint.h @@ -47,6 +47,10 @@ #if defined(VISP_HAVE_PUGIXML) #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpXmlConfigParserKeyPoint * \ingroup group_vision_keypoints @@ -198,5 +202,8 @@ class VISP_EXPORT vpXmlConfigParserKeyPoint //! Pointer to implementation Impl *m_impl; }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/vision/src/calibration/vpCalibration.cpp b/modules/vision/src/calibration/vpCalibration.cpp index 0f2c53ec32..e3b8785699 100644 --- a/modules/vision/src/calibration/vpCalibration.cpp +++ b/modules/vision/src/calibration/vpCalibration.cpp @@ -41,6 +41,11 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + double vpCalibration::m_threshold = 1e-10f; unsigned int vpCalibration::m_nbIterMax = 4000; double vpCalibration::m_gain = 0.25; @@ -630,3 +635,6 @@ void vpCalibration::setAspectRatio(double aspect_ratio) m_aspect_ratio = aspect_ratio; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/vision/src/calibration/vpCalibrationTools.cpp b/modules/vision/src/calibration/vpCalibrationTools.cpp index a4965614a3..7daab41fba 100644 --- a/modules/vision/src/calibration/vpCalibrationTools.cpp +++ b/modules/vision/src/calibration/vpCalibrationTools.cpp @@ -45,6 +45,10 @@ #undef MAX /* FC unused anywhere */ #undef MIN /* FC unused anywhere */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpCalibration::calibLagrange(vpCameraParameters &cam_est, vpHomogeneousMatrix &cMo_est) { @@ -1222,6 +1226,8 @@ void vpCalibration::calibVVSWithDistortionMulti(unsigned int nbPose, vpCalibrati table_cal[i] = v_table_cal[i]; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #undef DEBUG_LEVEL1 #undef DEBUG_LEVEL2 diff --git a/modules/vision/src/calibration/vpHandEyeCalibration.cpp b/modules/vision/src/calibration/vpHandEyeCalibration.cpp index 90d41e3f2b..e14147fde0 100644 --- a/modules/vision/src/calibration/vpHandEyeCalibration.cpp +++ b/modules/vision/src/calibration/vpHandEyeCalibration.cpp @@ -39,6 +39,11 @@ #define DEBUG_LEVEL1 0 #define DEBUG_LEVEL2 0 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! \brief Compute the distances of the data to the mean obtained. @@ -1023,6 +1028,10 @@ int vpHandEyeCalibration::calibrate(const std::vector &cMo, return err; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + #undef HE_I #undef HE_TSAI_OROT #undef HE_TSAI_ORNT diff --git a/modules/vision/src/homography-estimation/vpHomography.cpp b/modules/vision/src/homography-estimation/vpHomography.cpp index 48c344c589..ec0269b337 100644 --- a/modules/vision/src/homography-estimation/vpHomography.cpp +++ b/modules/vision/src/homography-estimation/vpHomography.cpp @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/homography-estimation/vpHomographyDLT.cpp b/modules/vision/src/homography-estimation/vpHomographyDLT.cpp index 66d3f8d8f3..9d7ada66a7 100644 --- a/modules/vision/src/homography-estimation/vpHomographyDLT.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyDLT.cpp @@ -46,7 +46,7 @@ #include // numeric_limits #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/homography-estimation/vpHomographyExtract.cpp b/modules/vision/src/homography-estimation/vpHomographyExtract.cpp index b238259ec1..fcb4c6a66f 100644 --- a/modules/vision/src/homography-estimation/vpHomographyExtract.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyExtract.cpp @@ -36,7 +36,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/homography-estimation/vpHomographyMalis.cpp b/modules/vision/src/homography-estimation/vpHomographyMalis.cpp index f587e34d96..7546244828 100644 --- a/modules/vision/src/homography-estimation/vpHomographyMalis.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyMalis.cpp @@ -50,7 +50,7 @@ #include // numeric_limits #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/homography-estimation/vpHomographyRansac.cpp b/modules/vision/src/homography-estimation/vpHomographyRansac.cpp index ad2e2c6f3b..f248f57c89 100644 --- a/modules/vision/src/homography-estimation/vpHomographyRansac.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyRansac.cpp @@ -40,7 +40,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/homography-estimation/vpHomographyVVS.cpp b/modules/vision/src/homography-estimation/vpHomographyVVS.cpp index 20d3b0c1cc..031093762e 100644 --- a/modules/vision/src/homography-estimation/vpHomographyVVS.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyVVS.cpp @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/key-point/vpKeyPoint.cpp b/modules/vision/src/key-point/vpKeyPoint.cpp index b0e6d5bf20..1e1f59ee14 100644 --- a/modules/vision/src/key-point/vpKeyPoint.cpp +++ b/modules/vision/src/key-point/vpKeyPoint.cpp @@ -43,6 +43,11 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + namespace { // Specific Type transformation functions @@ -4216,6 +4221,10 @@ void vpKeyPoint::PyramidAdaptedFeatureDetector::detectImpl(const cv::Mat &image, #endif #endif +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_vision.a(vpKeyPoint.cpp.o) has no symbols void dummy_vpKeyPoint() { }; diff --git a/modules/vision/src/key-point/vpXmlConfigParserKeyPoint.cpp b/modules/vision/src/key-point/vpXmlConfigParserKeyPoint.cpp index d6f3da952c..81d83ca964 100644 --- a/modules/vision/src/key-point/vpXmlConfigParserKeyPoint.cpp +++ b/modules/vision/src/key-point/vpXmlConfigParserKeyPoint.cpp @@ -48,6 +48,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpXmlConfigParserKeyPoint::Impl { @@ -546,7 +550,9 @@ bool vpXmlConfigParserKeyPoint::getUseRansacVVSPoseEstimation() const { return m_impl->getUseRansacVVSPoseEstimation(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpXmlConfigParserKeyPoint.cpp.o) has no symbols void dummy_vpXmlConfigParserKeyPoint() { }; diff --git a/modules/vision/src/plane-estimation/vpPlaneEstimation.cpp b/modules/vision/src/plane-estimation/vpPlaneEstimation.cpp index 1c9c13e78c..4493cab65a 100644 --- a/modules/vision/src/plane-estimation/vpPlaneEstimation.cpp +++ b/modules/vision/src/plane-estimation/vpPlaneEstimation.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif // Local helpers namespace { @@ -298,5 +302,7 @@ vpPlaneEstimation::estimatePlane(const vpImage &I_depth_raw, double de return estimatePlaneEquationSVD(pt_cloud); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp index 4de8e57cbc..509bbda8e4 100644 --- a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp +++ b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.cpp @@ -40,7 +40,7 @@ #include "vpLevenbergMarquartd.h" #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h index 5ab0e298d0..e0804dd575 100644 --- a/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h +++ b/modules/vision/src/pose-estimation/private/vpLevenbergMarquartd.h @@ -44,7 +44,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/pose-estimation/vpPose.cpp b/modules/vision/src/pose-estimation/vpPose.cpp index 787d09752e..12d42c7103 100644 --- a/modules/vision/src/pose-estimation/vpPose.cpp +++ b/modules/vision/src/pose-estimation/vpPose.cpp @@ -50,7 +50,7 @@ #include // numeric_limits #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/pose-estimation/vpPoseDementhon.cpp b/modules/vision/src/pose-estimation/vpPoseDementhon.cpp index 2fcc251d59..4b15b89fe0 100644 --- a/modules/vision/src/pose-estimation/vpPoseDementhon.cpp +++ b/modules/vision/src/pose-estimation/vpPoseDementhon.cpp @@ -35,7 +35,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/pose-estimation/vpPoseFeatures.cpp b/modules/vision/src/pose-estimation/vpPoseFeatures.cpp index 113fd30b2c..05bcbe7a55 100644 --- a/modules/vision/src/pose-estimation/vpPoseFeatures.cpp +++ b/modules/vision/src/pose-estimation/vpPoseFeatures.cpp @@ -34,6 +34,11 @@ #if defined(VISP_HAVE_MODULE_VISUAL_FEATURES) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + vpPoseFeatures::vpPoseFeatures() : m_maxSize(0), m_totalSize(0), m_vvsIterMax(200), m_lambda(1.0), m_verbose(false), m_computeCovariance(false), m_covarianceMatrix(), m_featurePoint_Point_list(), m_featurePoint3D_Point_list(), m_featureVanishingPoint_Point_list(), @@ -462,6 +467,11 @@ void vpPoseFeatures::computePoseRobustVVS(vpHomogeneousMatrix &cMo) throw; } } + +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_vision.a(vpPoseFeatures.cpp.o) has no symbols void dummy_vpPoseFeatures() { }; diff --git a/modules/vision/src/pose-estimation/vpPoseLagrange.cpp b/modules/vision/src/pose-estimation/vpPoseLagrange.cpp index 98a4542fda..644f72f16f 100644 --- a/modules/vision/src/pose-estimation/vpPoseLagrange.cpp +++ b/modules/vision/src/pose-estimation/vpPoseLagrange.cpp @@ -34,7 +34,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/pose-estimation/vpPoseLowe.cpp b/modules/vision/src/pose-estimation/vpPoseLowe.cpp index 79d9a55e2d..e449a40a13 100644 --- a/modules/vision/src/pose-estimation/vpPoseLowe.cpp +++ b/modules/vision/src/pose-estimation/vpPoseLowe.cpp @@ -42,7 +42,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/pose-estimation/vpPoseRGBD.cpp b/modules/vision/src/pose-estimation/vpPoseRGBD.cpp index c9af47f58f..c573182b47 100644 --- a/modules/vision/src/pose-estimation/vpPoseRGBD.cpp +++ b/modules/vision/src/pose-estimation/vpPoseRGBD.cpp @@ -38,7 +38,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/src/pose-estimation/vpPoseRansac.cpp b/modules/vision/src/pose-estimation/vpPoseRansac.cpp index a0f6c5ea7e..2fa4832c16 100644 --- a/modules/vision/src/pose-estimation/vpPoseRansac.cpp +++ b/modules/vision/src/pose-estimation/vpPoseRansac.cpp @@ -54,7 +54,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif #define EPS 1e-6 diff --git a/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp b/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp index 7727de8106..204b5e70a2 100644 --- a/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp +++ b/modules/vision/src/pose-estimation/vpPoseVirtualVisualServoing.cpp @@ -43,7 +43,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif diff --git a/modules/vision/test/homography/testDisplacement.cpp b/modules/vision/test/homography/testDisplacement.cpp index 0c57e3962f..f0284e9511 100644 --- a/modules/vision/test/homography/testDisplacement.cpp +++ b/modules/vision/test/homography/testDisplacement.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool test(const std::string &s, const vpHomography &H, const std::vector &bench) { static unsigned int cpt = 0; @@ -182,7 +186,8 @@ int main() } std::cout << "All tests succeed" << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/vision/test/keypoint-with-dataset/testKeyPoint-2.cpp b/modules/vision/test/keypoint-with-dataset/testKeyPoint-2.cpp index edcbab6cd3..025a6a2dec 100644 --- a/modules/vision/test/keypoint-with-dataset/testKeyPoint-2.cpp +++ b/modules/vision/test/keypoint-with-dataset/testKeyPoint-2.cpp @@ -52,6 +52,10 @@ // List of allowed command line options #define GETOPTARGS "cdph" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); diff --git a/modules/vision/test/keypoint-with-dataset/testKeyPoint-3.cpp b/modules/vision/test/keypoint-with-dataset/testKeyPoint-3.cpp index 1040f85c2f..37552fe411 100644 --- a/modules/vision/test/keypoint-with-dataset/testKeyPoint-3.cpp +++ b/modules/vision/test/keypoint-with-dataset/testKeyPoint-3.cpp @@ -53,6 +53,10 @@ // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); @@ -244,12 +248,14 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis if (button == vpMouseButton::button3) { opt_click = false; } - } else { - // Use right click to enable/disable step by step tracking + } + else { + // Use right click to enable/disable step by step tracking if (vpDisplay::getClick(Imatch, button, false)) { if (button == vpMouseButton::button3) { opt_click = true; - } else if (button == vpMouseButton::button1) { + } + else if (button == vpMouseButton::button1) { break; } } @@ -282,8 +288,8 @@ int main(int argc, const char **argv) if (env_ipath.empty()) { std::cerr << "Please set the VISP_INPUT_IMAGE_PATH environment " - "variable value." - << std::endl; + "variable value." + << std::endl; return EXIT_FAILURE; } @@ -301,7 +307,8 @@ int main(int argc, const char **argv) run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch); } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/vision/test/keypoint-with-dataset/testKeyPoint-4.cpp b/modules/vision/test/keypoint-with-dataset/testKeyPoint-4.cpp index 2dfd21d68f..e310246933 100644 --- a/modules/vision/test/keypoint-with-dataset/testKeyPoint-4.cpp +++ b/modules/vision/test/keypoint-with-dataset/testKeyPoint-4.cpp @@ -54,6 +54,10 @@ // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); diff --git a/modules/vision/test/keypoint-with-dataset/testKeyPoint-5.cpp b/modules/vision/test/keypoint-with-dataset/testKeyPoint-5.cpp index 203f764ac9..cc874ebfd4 100644 --- a/modules/vision/test/keypoint-with-dataset/testKeyPoint-5.cpp +++ b/modules/vision/test/keypoint-with-dataset/testKeyPoint-5.cpp @@ -48,13 +48,13 @@ #include #include - - - - // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); diff --git a/modules/vision/test/keypoint-with-dataset/testKeyPoint-6.cpp b/modules/vision/test/keypoint-with-dataset/testKeyPoint-6.cpp index d8fd45b188..0e5d86ace9 100644 --- a/modules/vision/test/keypoint-with-dataset/testKeyPoint-6.cpp +++ b/modules/vision/test/keypoint-with-dataset/testKeyPoint-6.cpp @@ -50,6 +50,10 @@ // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); @@ -265,7 +269,8 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis ss << "No keypoints detected with " << detectorName << " and image:" << filename << "." << std::endl; throw(vpException(vpException::fatalError, ss.str())); } - } else if (*itd == "AKAZE") { + } + else if (*itd == "AKAZE") { detectorName = "AKAZE"; keyPoints.setDetector(detectorName); keyPoints.detect(I, kpts); @@ -275,13 +280,14 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis ss << "No keypoints detected with " << detectorName << " and image:" << filename << "." << std::endl; throw(vpException(vpException::fatalError, ss.str())); } - } else if (*itd == "BoostDesc") { + } + else if (*itd == "BoostDesc") { #if (VISP_HAVE_OPENCV_VERSION >= 0x030200) && defined(VISP_HAVE_OPENCV_XFEATURES2D) cv::Ptr boostDesc = keyPoints.getExtractor("BoostDesc"); // Init BIN BOOST descriptor for FAST keypoints boostDesc = cv::xfeatures2d::BoostDesc::create(cv::xfeatures2d::BoostDesc::BINBOOST_256, true, 5.0f); #endif - } + } double t = vpTime::measureTimeMs(); cv::Mat descriptor; @@ -289,8 +295,8 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis t = vpTime::measureTimeMs() - t; std::cout << "Descriptor: " << descriptor.rows << "x" << descriptor.cols - << " (rows x cols) ; type=" << getOpenCVType(descriptor.type()) << " for " << *itd << " method in " << t - << " ms." << std::endl; + << " (rows x cols) ; type=" << getOpenCVType(descriptor.type()) << " for " << *itd << " method in " << t + << " ms." << std::endl; if (descriptor.empty()) { std::stringstream ss; ss << "No descriptor extracted with " << *itd << " and image:" << filename << "." << std::endl; @@ -313,7 +319,7 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis vpDisplay::getClick(I); } } - } + } std::cout << "\n\n"; @@ -332,7 +338,8 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis ss << "No keypoints detected with " << detectorName << " and image:" << filename << "." << std::endl; throw(vpException(vpException::fatalError, ss.str())); } - } else if (mapOfDescriptorNames[(vpKeyPoint::vpFeatureDescriptorType)i] == "AKAZE") { + } + else if (mapOfDescriptorNames[(vpKeyPoint::vpFeatureDescriptorType)i] == "AKAZE") { detectorName = "AKAZE"; keyPoints.setDetector(detectorName); keyPoints.detect(I, kpts); @@ -342,7 +349,8 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis ss << "No keypoints detected with " << detectorName << " and image:" << filename << "." << std::endl; throw(vpException(vpException::fatalError, ss.str())); } - } else if (mapOfDescriptorNames[(vpKeyPoint::vpFeatureDescriptorType)i] == "BoostDesc") { + } + else if (mapOfDescriptorNames[(vpKeyPoint::vpFeatureDescriptorType)i] == "BoostDesc") { #if (VISP_HAVE_OPENCV_VERSION >= 0x030200) && defined(VISP_HAVE_OPENCV_XFEATURES2D) detectorName = "FAST"; keyPoints.setDetector(detectorName); @@ -358,7 +366,7 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis // Init BIN BOOST descriptor for FAST keypoints boostDesc = cv::xfeatures2d::BoostDesc::create(cv::xfeatures2d::BoostDesc::BINBOOST_256, true, 5.0f); #endif - } + } double t = vpTime::measureTimeMs(); cv::Mat descriptor; @@ -366,13 +374,13 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis t = vpTime::measureTimeMs() - t; std::cout << "Descriptor: " << descriptor.rows << "x" << descriptor.cols - << " (rows x cols) ; type=" << getOpenCVType(descriptor.type()) << " for " - << mapOfDescriptorNames[(vpKeyPoint::vpFeatureDescriptorType)i] << " method in " << t << " ms." - << std::endl; + << " (rows x cols) ; type=" << getOpenCVType(descriptor.type()) << " for " + << mapOfDescriptorNames[(vpKeyPoint::vpFeatureDescriptorType)i] << " method in " << t << " ms." + << std::endl; if (descriptor.empty()) { std::stringstream ss; ss << "No descriptor extracted with " << mapOfDescriptorNames[(vpKeyPoint::vpFeatureDescriptorType)i] - << " and image:" << filename << "." << std::endl; + << " and image:" << filename << "." << std::endl; throw(vpException(vpException::fatalError, ss.str())); } @@ -392,14 +400,14 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis vpDisplay::getClick(I); } } + } } -} -/*! - \example testKeyPoint-6.cpp + /*! + \example testKeyPoint-6.cpp - \brief Test descriptor extraction. -*/ + \brief Test descriptor extraction. + */ int main(int argc, const char **argv) { try { @@ -418,8 +426,8 @@ int main(int argc, const char **argv) if (env_ipath.empty()) { std::cerr << "Please set the VISP_INPUT_IMAGE_PATH environment " - "variable value." - << std::endl; + "variable value." + << std::endl; return EXIT_FAILURE; } @@ -437,7 +445,8 @@ int main(int argc, const char **argv) run_test(env_ipath, opt_click_allowed, opt_display, Iinput, I); } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/vision/test/keypoint-with-dataset/testKeyPoint-7.cpp b/modules/vision/test/keypoint-with-dataset/testKeyPoint-7.cpp index b66df93f4d..b526fe8090 100644 --- a/modules/vision/test/keypoint-with-dataset/testKeyPoint-7.cpp +++ b/modules/vision/test/keypoint-with-dataset/testKeyPoint-7.cpp @@ -48,6 +48,10 @@ // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! Print the program options. diff --git a/modules/vision/test/keypoint-with-dataset/testKeyPoint.cpp b/modules/vision/test/keypoint-with-dataset/testKeyPoint.cpp index 7240c1e375..2c833c7347 100644 --- a/modules/vision/test/keypoint-with-dataset/testKeyPoint.cpp +++ b/modules/vision/test/keypoint-with-dataset/testKeyPoint.cpp @@ -51,6 +51,10 @@ // List of allowed command line options #define GETOPTARGS "cdh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam); bool getOptions(int argc, const char **argv, bool &click_allowed, bool &display); @@ -205,12 +209,14 @@ void run_test(const std::string &env_ipath, bool opt_click_allowed, bool opt_dis if (button == vpMouseButton::button3) { opt_click = false; } - } else { - // Use right click to enable/disable step by step tracking + } + else { + // Use right click to enable/disable step by step tracking if (vpDisplay::getClick(Imatch, button, false)) { if (button == vpMouseButton::button3) { opt_click = true; - } else if (button == vpMouseButton::button1) { + } + else if (button == vpMouseButton::button1) { break; } } @@ -242,8 +248,8 @@ int main(int argc, const char **argv) if (env_ipath.empty()) { std::cerr << "Please set the VISP_INPUT_IMAGE_PATH environment " - "variable value." - << std::endl; + "variable value." + << std::endl; return EXIT_FAILURE; } @@ -261,7 +267,8 @@ int main(int argc, const char **argv) run_test(env_ipath, opt_click_allowed, opt_display, Iref, Icur, Imatch); } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/vision/test/keypoint-with-dataset/testXmlConfigParserKeyPoint.cpp b/modules/vision/test/keypoint-with-dataset/testXmlConfigParserKeyPoint.cpp index 549f5a4c7a..04bd9ca326 100644 --- a/modules/vision/test/keypoint-with-dataset/testXmlConfigParserKeyPoint.cpp +++ b/modules/vision/test/keypoint-with-dataset/testXmlConfigParserKeyPoint.cpp @@ -42,6 +42,10 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + #if defined(VISP_HAVE_PUGIXML) std::string visp_images_dir = vpIoTools::getViSPImagesDataPath(); if (vpIoTools::checkDirectory(visp_images_dir + "/xml")) { diff --git a/modules/vision/test/pose-with-dataset/testPoseRansac2.cpp b/modules/vision/test/pose-with-dataset/testPoseRansac2.cpp index 19a6cb3ac0..a332b544ed 100644 --- a/modules/vision/test/pose-with-dataset/testPoseRansac2.cpp +++ b/modules/vision/test/pose-with-dataset/testPoseRansac2.cpp @@ -47,16 +47,20 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { #if (VISP_HAVE_DATASET_VERSION >= 0x030300) bool samePoints(const vpPoint &pt1, const vpPoint &pt2) { return vpMath::equal(pt1.get_oX(), pt2.get_oX(), std::numeric_limits::epsilon()) && - vpMath::equal(pt1.get_oY(), pt2.get_oY(), std::numeric_limits::epsilon()) && - vpMath::equal(pt1.get_oZ(), pt2.get_oZ(), std::numeric_limits::epsilon()) && - vpMath::equal(pt1.get_x(), pt2.get_x(), std::numeric_limits::epsilon()) && - vpMath::equal(pt1.get_y(), pt2.get_y(), std::numeric_limits::epsilon()); + vpMath::equal(pt1.get_oY(), pt2.get_oY(), std::numeric_limits::epsilon()) && + vpMath::equal(pt1.get_oZ(), pt2.get_oZ(), std::numeric_limits::epsilon()) && + vpMath::equal(pt1.get_x(), pt2.get_x(), std::numeric_limits::epsilon()) && + vpMath::equal(pt1.get_y(), pt2.get_y(), std::numeric_limits::epsilon()); } int checkInlierIndex(const std::vector &vectorOfFoundInlierIndex, @@ -81,16 +85,16 @@ bool checkInlierPoints(const std::vector &vectorOfFoundInlierPoints, for (size_t i = 0; i < vectorOfFoundInlierPoints.size(); i++) { if (!samePoints(vectorOfFoundInlierPoints[i], bunnyModelPoints_noisy[vectorOfFoundInlierIndex[i]])) { std::cerr << "Problem with the inlier index and the corresponding " - "inlier point!" - << std::endl; + "inlier point!" + << std::endl; std::cerr << "Returned inliers: oX=" << std::setprecision(std::numeric_limits::max_digits10) - << vectorOfFoundInlierPoints[i].get_oX() << ", oY=" << vectorOfFoundInlierPoints[i].get_oY() - << ", oZ=" << vectorOfFoundInlierPoints[i].get_oZ() << " ; x=" << vectorOfFoundInlierPoints[i].get_x() - << ", y=" << vectorOfFoundInlierPoints[i].get_y() << std::endl; + << vectorOfFoundInlierPoints[i].get_oX() << ", oY=" << vectorOfFoundInlierPoints[i].get_oY() + << ", oZ=" << vectorOfFoundInlierPoints[i].get_oZ() << " ; x=" << vectorOfFoundInlierPoints[i].get_x() + << ", y=" << vectorOfFoundInlierPoints[i].get_y() << std::endl; const vpPoint &pt = bunnyModelPoints_noisy[vectorOfFoundInlierIndex[i]]; std::cerr << "Object points: oX=" << std::setprecision(std::numeric_limits::max_digits10) << pt.get_oX() - << ", oY=" << pt.get_oY() << ", oZ=" << pt.get_oZ() << " ; x=" << pt.get_x() << ", y=" << pt.get_y() - << std::endl; + << ", oY=" << pt.get_oY() << ", oZ=" << pt.get_oZ() << " ; x=" << pt.get_x() << ", y=" << pt.get_y() + << std::endl; return false; } } @@ -256,8 +260,8 @@ bool testRansac(const std::vector &bunnyModelPoints_original, // Print the number of points in the final data vector std::cout << "\nNumber of model points in the noisy data vector: " << bunnyModelPoints_noisy.size() << " points." - << std::endl - << std::endl; + << std::endl + << std::endl; unsigned int nbInlierToReachConsensus = (unsigned int)(60.0 * (double)(bunnyModelPoints_noisy.size()) / 100.0); double threshold = 0.001; @@ -299,7 +303,7 @@ bool testRansac(const std::vector &bunnyModelPoints_original, chrono_RANSAC.stop(); std::cout << "\ncMo estimated with RANSAC (" << ransac_iterations << " iterations) on noisy data:\n" - << cMo_estimated_RANSAC_2 << std::endl; + << cMo_estimated_RANSAC_2 << std::endl; std::cout << "Computation time: " << chrono_RANSAC.getDurationMs() << " ms" << std::endl; double r_RANSAC_estimated_2 = ground_truth_pose.computeResidual(cMo_estimated_RANSAC_2); @@ -318,8 +322,8 @@ bool testRansac(const std::vector &bunnyModelPoints_original, chrono_RANSAC_parallel.stop(); std::cout << "\ncMo estimated with parallel RANSAC (1000 iterations) on " - "noisy data:\n" - << cMo_estimated_RANSAC_parallel << std::endl; + "noisy data:\n" + << cMo_estimated_RANSAC_parallel << std::endl; std::cout << "Computation time: " << chrono_RANSAC_parallel.getDurationMs() << " ms" << std::endl; double r_RANSAC_estimated_parallel = ground_truth_pose.computeResidual(cMo_estimated_RANSAC_parallel); @@ -332,28 +336,28 @@ bool testRansac(const std::vector &bunnyModelPoints_original, chrono_RANSAC_parallel2.stop(); std::cout << "\ncMo estimated with parallel RANSAC (" << ransac_iterations << " iterations) on noisy data:\n" - << cMo_estimated_RANSAC_parallel2 << std::endl; + << cMo_estimated_RANSAC_parallel2 << std::endl; std::cout << "Computation time: " << chrono_RANSAC_parallel2.getDurationMs() << " ms" << std::endl; double r_RANSAC_estimated_parallel2 = ground_truth_pose.computeResidual(cMo_estimated_RANSAC_parallel2); std::cout << "Corresponding residual (" << ransac_iterations << " iterations): " << r_RANSAC_estimated_parallel2 - << std::endl; + << std::endl; - // Check inlier index +// Check inlier index std::vector vectorOfFoundInlierIndex = pose_ransac.getRansacInlierIndex(); int nbInlierIndexOk = checkInlierIndex(vectorOfFoundInlierIndex, vectorOfOutlierFlags); int nbTrueInlierIndex = (int)std::count(vectorOfOutlierFlags.begin(), vectorOfOutlierFlags.end(), false); std::cout << "\nThere are " << nbInlierIndexOk << " true inliers found, " << vectorOfFoundInlierIndex.size() - << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; + << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; - // Check inlier points returned +// Check inlier points returned std::vector vectorOfFoundInlierPoints = pose_ransac.getRansacInliers(); if (vectorOfFoundInlierPoints.size() != vectorOfFoundInlierIndex.size()) { std::cerr << "The number of inlier index is different from the number of " - "inlier points!" - << std::endl; + "inlier points!" + << std::endl; return false; } if (!checkInlierPoints(vectorOfFoundInlierPoints, vectorOfFoundInlierIndex, bunnyModelPoints_noisy)) { @@ -367,14 +371,14 @@ bool testRansac(const std::vector &bunnyModelPoints_original, nbInlierIndexOk = checkInlierIndex(vectorOfFoundInlierIndex_2, vectorOfOutlierFlags); std::cout << "There are " << nbInlierIndexOk << " true inliers found, " << vectorOfFoundInlierIndex_2.size() - << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; + << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; - // Check inlier points returned +// Check inlier points returned std::vector vectorOfFoundInlierPoints_2 = pose_ransac2.getRansacInliers(); if (vectorOfFoundInlierPoints_2.size() != vectorOfFoundInlierIndex_2.size()) { std::cerr << "The number of inlier index is different from the number of " - "inlier points!" - << std::endl; + "inlier points!" + << std::endl; return false; } if (!checkInlierPoints(vectorOfFoundInlierPoints_2, vectorOfFoundInlierIndex_2, bunnyModelPoints_noisy)) { @@ -388,14 +392,14 @@ bool testRansac(const std::vector &bunnyModelPoints_original, nbInlierIndexOk = checkInlierIndex(vectorOfFoundInlierIndex_parallel, vectorOfOutlierFlags); std::cout << "There are " << nbInlierIndexOk << " true inliers found, " << vectorOfFoundInlierIndex_parallel.size() - << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; + << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; - // Check inlier points returned +// Check inlier points returned std::vector vectorOfFoundInlierPoints_parallel = pose_ransac_parallel.getRansacInliers(); if (vectorOfFoundInlierPoints_parallel.size() != vectorOfFoundInlierIndex_parallel.size()) { std::cerr << "The number of inlier index is different from the number " - "of inlier points!" - << std::endl; + "of inlier points!" + << std::endl; return false; } if (!checkInlierPoints(vectorOfFoundInlierPoints_parallel, vectorOfFoundInlierIndex_parallel, @@ -410,14 +414,14 @@ bool testRansac(const std::vector &bunnyModelPoints_original, nbInlierIndexOk = checkInlierIndex(vectorOfFoundInlierIndex_parallel2, vectorOfOutlierFlags); std::cout << "There are " << nbInlierIndexOk << " true inliers found, " << vectorOfFoundInlierIndex_parallel2.size() - << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; + << " inliers returned and " << nbTrueInlierIndex << " true inliers." << std::endl; - // Check inlier points returned +// Check inlier points returned std::vector vectorOfFoundInlierPoints_parallel2 = pose_ransac_parallel2.getRansacInliers(); if (vectorOfFoundInlierPoints_parallel2.size() != vectorOfFoundInlierIndex_parallel2.size()) { std::cerr << "The number of inlier index is different from the number " - "of inlier points!" - << std::endl; + "of inlier points!" + << std::endl; return false; } if (!checkInlierPoints(vectorOfFoundInlierPoints_parallel2, vectorOfFoundInlierIndex_parallel2, @@ -430,11 +434,12 @@ bool testRansac(const std::vector &bunnyModelPoints_original, std::cerr << "r_RANSAC_estimated=" << r_RANSAC_estimated << std::endl; std::cerr << "threshold=" << threshold << std::endl; return false; - } else { + } + else { if (r_RANSAC_estimated_parallel > threshold) { std::cerr << "The pose estimated with the parallel RANSAC method is " - "badly estimated!" - << std::endl; + "badly estimated!" + << std::endl; std::cerr << "r_RANSAC_estimated_parallel=" << r_RANSAC_estimated_parallel << std::endl; std::cerr << "threshold=" << threshold << std::endl; return false; @@ -449,14 +454,14 @@ bool testRansac(const std::vector &bunnyModelPoints_original, TEST_CASE("Print RANSAC number of iterations", "[ransac_pose]") { - const int sample_sizes[] = {2, 3, 4, 5, 6, 7, 8}; - const double epsilon[] = {0.05, 0.1, 0.2, 0.25, 0.3, 0.4, 0.5}; + const int sample_sizes[] = { 2, 3, 4, 5, 6, 7, 8 }; + const double epsilon[] = { 0.05, 0.1, 0.2, 0.25, 0.3, 0.4, 0.5 }; // Format output const std::string spacing = " "; std::cout << spacing << " outliers percentage\n" - << "nb pts\\"; + << "nb pts\\"; for (int cpt2 = 0; cpt2 < 7; cpt2++) { std::cout << std::setfill(' ') << std::setw(5) << epsilon[cpt2] << " "; } @@ -483,9 +488,9 @@ TEST_CASE("Print RANSAC number of iterations", "[ransac_pose]") #if (VISP_HAVE_DATASET_VERSION >= 0x030300) TEST_CASE("RANSAC pose estimation tests", "[ransac_pose]") { - const std::vector model_sizes = {10, 20, 50, 100, 200, 500, 1000, 0, 0}; - const std::vector duplicates = {false, false, false, false, false, false, false, false, true}; - const std::vector degenerates = {false, false, false, false, false, false, true, true, true}; + const std::vector model_sizes = { 10, 20, 50, 100, 200, 500, 1000, 0, 0 }; + const std::vector duplicates = { false, false, false, false, false, false, false, false, true }; + const std::vector degenerates = { false, false, false, false, false, false, true, true, true }; std::string visp_input_images = vpIoTools::getViSPImagesDataPath(); std::string model_filename = vpIoTools::createFilePath(visp_input_images, "3dmodel/bunny/bunny.xyz"); @@ -499,7 +504,8 @@ TEST_CASE("RANSAC pose estimation tests", "[ransac_pose]") std::cout << "\n\n===============================================================================" << std::endl; if (model_sizes[i] == 0) { std::cout << "Test on " << bunnyModelPoints_noisy_original.size() << " model points." << std::endl; - } else { + } + else { std::cout << "Test on " << model_sizes[i] << " model points." << std::endl; } std::cout << "Test duplicate: " << duplicates[i] << " ; Test degenerate: " << degenerates[i] << std::endl; diff --git a/modules/vision/test/pose/testFindMatch.cpp b/modules/vision/test/pose/testFindMatch.cpp index 60bd02e72f..7431f3dca0 100644 --- a/modules/vision/test/pose/testFindMatch.cpp +++ b/modules/vision/test/pose/testFindMatch.cpp @@ -52,6 +52,10 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)) try { std::cout << "Find Matches using Ransac" << std::endl; @@ -106,7 +110,8 @@ int main() std::cout << "Matching is " << (test_fail ? "badly" : "well") << " performed" << std::endl; return (test_fail ? EXIT_FAILURE : EXIT_SUCCESS); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/vision/test/pose/testPose.cpp b/modules/vision/test/pose/testPose.cpp index c09a94c99b..0d9f034acb 100644 --- a/modules/vision/test/pose/testPose.cpp +++ b/modules/vision/test/pose/testPose.cpp @@ -59,6 +59,10 @@ */ +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void print_pose(const vpHomogeneousMatrix &cMo, const std::string &legend); int compare_pose(const vpPose &pose, const vpHomogeneousMatrix &cMo_ref, const vpHomogeneousMatrix &cMo_est, const vpCameraParameters &cam, const std::string &legend, const double &translation3DThresh, const double &rotationRadian3DThresh, const double &pose2DThresh, const double &posePixThresh); diff --git a/modules/vision/test/pose/testPoseFeatures.cpp b/modules/vision/test/pose/testPoseFeatures.cpp index 811697078c..dbd1e59b2b 100644 --- a/modules/vision/test/pose/testPoseFeatures.cpp +++ b/modules/vision/test/pose/testPoseFeatures.cpp @@ -50,6 +50,10 @@ */ +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + #if defined(VISP_HAVE_MODULE_VISUAL_FEATURES) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) #ifndef DOXYGEN_SHOULD_SKIP_THIS class vp_createPointClass diff --git a/modules/vision/test/pose/testPoseRansac.cpp b/modules/vision/test/pose/testPoseRansac.cpp index 9dd4cc8330..fd01d591a2 100644 --- a/modules/vision/test/pose/testPoseRansac.cpp +++ b/modules/vision/test/pose/testPoseRansac.cpp @@ -52,6 +52,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)) try { std::cout << "Pose computation with matched points" << std::endl; @@ -117,7 +120,8 @@ int main() std::cout << "Pose is " << (test_fail ? "badly" : "well") << " estimated" << std::endl; return (test_fail ? EXIT_FAILURE : EXIT_SUCCESS); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } @@ -125,4 +129,4 @@ int main() std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl; return EXIT_SUCCESS; #endif -} + } diff --git a/modules/visual_features/include/visp3/visual_features/vpBasicFeature.h b/modules/visual_features/include/visp3/visual_features/vpBasicFeature.h index 4be273154e..a6da9d931f 100644 --- a/modules/visual_features/include/visp3/visual_features/vpBasicFeature.h +++ b/modules/visual_features/include/visp3/visual_features/vpBasicFeature.h @@ -36,14 +36,15 @@ * *****************************************************************************/ -#ifndef vpBasicFeature_H -#define vpBasicFeature_H - /*! \file vpBasicFeature.h \brief class that defines what is a visual feature */ +#ifndef vpBasicFeature_H +#define vpBasicFeature_H + +#include #include #include @@ -68,6 +69,10 @@ // #define FEATURE_LINE7 0x40 // #define FEATURE_LINE8 0x80 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpBasicFeature * \ingroup group_visual_features @@ -145,5 +150,7 @@ class VISP_EXPORT vpBasicFeature protected: vpBasicFeatureDeallocatorType deallocate; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureBuilder.h b/modules/visual_features/include/visp3/visual_features/vpFeatureBuilder.h index 4469fe64af..1ff7fdb9f1 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureBuilder.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureBuilder.h @@ -33,13 +33,15 @@ * *****************************************************************************/ -#ifndef vpFeatureBuilder_H -#define vpFeatureBuilder_H - /*! \file vpFeatureBuilder.h \brief class that defines conversion between tracker and visual feature */ + +#ifndef vpFeatureBuilder_H +#define vpFeatureBuilder_H + + #include // tracker @@ -79,6 +81,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpFeatureBuilder @@ -152,4 +158,7 @@ class VISP_EXPORT vpFeatureBuilder const vpImagePoint &line1_ip2, const vpImagePoint &line2_ip1, const vpImagePoint &line2_ip2, unsigned int select); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureDepth.h b/modules/visual_features/include/visp3/visual_features/vpFeatureDepth.h index f93422418d..651e43e53c 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureDepth.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureDepth.h @@ -31,14 +31,14 @@ * 2D point visual feature. */ -#ifndef vpFeatureDepth_H -#define vpFeatureDepth_H - /*! * \file vpFeatureDepth.h * \brief Class that defines 3D point visual feature */ +#ifndef vpFeatureDepth_H +#define vpFeatureDepth_H + #include #include #include @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureDepth * \ingroup group_visual_features @@ -207,5 +211,7 @@ class VISP_EXPORT vpFeatureDepth : public vpBasicFeature void set_xyZLogZoverZstar(double x, double y, double Z, double logZZs); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureEllipse.h b/modules/visual_features/include/visp3/visual_features/vpFeatureEllipse.h index bfe879edc0..6e633f25f2 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureEllipse.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureEllipse.h @@ -31,14 +31,14 @@ * 2D ellipse visual feature. */ -#ifndef vpFeatureEllipse_H -#define vpFeatureEllipse_H - /*! * \file vpFeatureEllipse.h * \brief Class that defines 2D ellipse visual feature */ +#ifndef vpFeatureEllipse_H +#define vpFeatureEllipse_H + #include #include #include @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureEllipse * \ingroup group_visual_features @@ -173,5 +177,7 @@ class VISP_EXPORT vpFeatureEllipse : public vpBasicFeature //@} #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureException.h b/modules/visual_features/include/visp3/visual_features/vpFeatureException.h index cd76aa0eca..fb71001d14 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureException.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureException.h @@ -31,19 +31,23 @@ * Exception that can be emitted by the vpFeature class and its derivatives. */ -#ifndef _vpFeatureException_h_ -#define _vpFeatureException_h_ - /*! * \file vpFeatureException.h * \brief error that can be emitted by the vpFeature class and its derivatives */ +#ifndef _vpFeatureException_h_ +#define _vpFeatureException_h_ + #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureException * \ingroup group_visual_features @@ -92,5 +96,7 @@ class VISP_EXPORT vpFeatureException : public vpException */ explicit vpFeatureException(int id) : vpException(id) { } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureLine.h b/modules/visual_features/include/visp3/visual_features/vpFeatureLine.h index 76ffe94cb9..962208db54 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureLine.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureLine.h @@ -31,14 +31,14 @@ * 2D line visual feature. */ -#ifndef _vpFeatureLine_h_ -#define _vpFeatureLine_h_ - /*! * \file vpFeatureLine.h * \brief Class that defines 2D line visual feature */ +#ifndef _vpFeatureLine_h_ +#define _vpFeatureLine_h_ + #include #include #include @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureLine * \ingroup group_visual_features @@ -236,5 +240,7 @@ class VISP_EXPORT vpFeatureLine : public vpBasicFeature static unsigned int selectRho(); static unsigned int selectTheta(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureLuminance.h b/modules/visual_features/include/visp3/visual_features/vpFeatureLuminance.h index 2806a8e3ea..a8c0fe6bad 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureLuminance.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureLuminance.h @@ -31,6 +31,13 @@ * Luminance based feature. */ +/*! + * \file vpFeatureLuminance.h + * \brief Class that defines the image luminance visual feature + * + * For more details see \cite Collewet08c. + */ + #ifndef vpFeatureLuminance_h #define vpFeatureLuminance_h @@ -39,15 +46,12 @@ #include #include -/*! - * \file vpFeatureLuminance.h - * \brief Class that defines the image luminance visual feature - * - * For more details see \cite Collewet08c. - */ - #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpLuminance * \brief Class that defines the luminance and gradient of a point. @@ -129,5 +133,7 @@ class VISP_EXPORT vpFeatureLuminance : public vpBasicFeature public: vpCameraParameters cam; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h index b387404617..34c56a32b2 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h @@ -47,11 +47,26 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentObject; class vpMomentDatabase; class vpFeatureMomentDatabase; +class vpFeatureMoment; class vpMoment; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMoment &featM); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureMoment * @@ -237,7 +252,7 @@ class VISP_EXPORT vpFeatureMoment : public vpBasicFeature void update(double A, double B, double C); //@} - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpFeatureMoment &featM); }; /*! @@ -277,5 +292,7 @@ class VISP_EXPORT vpMomentGenericFeature : public vpFeatureMoment */ virtual const std::string name() const { return std::string(); } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAlpha.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAlpha.h index ed7de38ddc..fc0fed66cb 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAlpha.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAlpha.h @@ -40,9 +40,14 @@ #ifndef _vpFeatureMomentAlpha_h_ #define _vpFeatureMomentAlpha_h_ +#include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentDatabase; /*! * \class vpFeatureMomentAlpha @@ -133,4 +138,7 @@ class VISP_EXPORT vpFeatureMomentAlpha : public vpFeatureMoment vpColVector error(const vpBasicFeature &s_star, unsigned int select = FEATURE_ALL) vp_override; }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentArea.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentArea.h index 7281bbf156..f280368373 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentArea.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentArea.h @@ -39,8 +39,13 @@ #ifndef _vpFeatureMomentArea_h_ #define _vpFeatureMomentArea_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentDatabase; /*! @@ -87,4 +92,7 @@ class VISP_EXPORT vpFeatureMomentArea : public vpFeatureMoment return "vpFeatureMomentArea"; } }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAreaNormalized.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAreaNormalized.h index 1e7401a609..6cf21eb0db 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAreaNormalized.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentAreaNormalized.h @@ -39,8 +39,13 @@ #ifndef _vpFeatureMomentAreaNormalized_h_ #define _vpFeatureMomentAreaNormalized_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_MOMENTS_COMBINE_MATRICES class vpMomentDatabase; @@ -216,4 +221,7 @@ class VISP_EXPORT vpFeatureMomentAreaNormalized : public vpFeatureMoment } }; #endif +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentBasic.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentBasic.h index 9c8c2dff92..a72ea1acde 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentBasic.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentBasic.h @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentDatabase; /*! * \class vpFeatureMomentBasic @@ -110,4 +114,7 @@ class VISP_EXPORT vpFeatureMomentBasic : public vpFeatureMoment return "vpFeatureMomentBasic"; } }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h index 96a9c299d5..cd4e803e1a 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h @@ -38,9 +38,26 @@ #ifndef _vpFeatureMomentCInvariant_h_ #define _vpFeatureMomentCInvariant_h_ +#include #include #ifdef VISP_MOMENTS_COMBINE_MATRICES +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpFeatureMomentCInvariant; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCInvariant &featcinv); + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureMomentCInvariant * @@ -179,10 +196,27 @@ class VISP_EXPORT vpFeatureMomentCInvariant : public vpFeatureMoment */ static unsigned int selectPy() { return 1 << 13; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpFeatureMomentCInvariant; class vpMomentDatabase; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCInvariant &featcinv); + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureMomentCInvariant * @@ -327,7 +361,10 @@ class VISP_EXPORT vpFeatureMomentCInvariant : public vpFeatureMoment */ void printLsofInvariants(std::ostream &os) const; - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCInvariant &featcinv); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpFeatureMomentCInvariant &featcinv); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h index dd035e8005..7298805e38 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h @@ -38,10 +38,27 @@ #ifndef _vpFeatureMomentCentered_h_ #define _vpFeatureMomentCentered_h_ +#include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentDatabase; +class vpFeatureMomentCentered; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCentered &v); + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureMomentCentered * @@ -114,7 +131,9 @@ class VISP_EXPORT vpFeatureMomentCentered : public vpFeatureMoment return "vpFeatureMomentCentered"; } - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCentered &v); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpFeatureMomentCentered &v); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCommon.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCommon.h index 39a26f163f..d03e822f6f 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCommon.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCommon.h @@ -40,6 +40,7 @@ #ifndef _vpFeatureMomentCommon_h_ #define _vpFeatureMomentCommon_h_ +#include #include #include #include @@ -51,6 +52,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpMomentDatabase; class vpServo; /*! @@ -266,5 +271,7 @@ class VISP_EXPORT vpFeatureMomentCommon : public vpFeatureMomentDatabase */ vpFeatureMomentGravityCenter &getFeatureGravityCenter() { return featureGravity; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentDatabase.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentDatabase.h index d6530fac82..d42d538971 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentDatabase.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentDatabase.h @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpFeatureMoment; class vpMomentObject; /*! @@ -180,5 +184,7 @@ class VISP_EXPORT vpFeatureMomentDatabase // vpFeatureMomentDatabase& m); friend class vpFeatureMoment; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenter.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenter.h index 71351a164a..5f165f7823 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenter.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenter.h @@ -39,8 +39,13 @@ #ifndef _vpFeatureMomentGravityCenter_h_ #define _vpFeatureMomentGravityCenter_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_MOMENTS_COMBINE_MATRICES class vpMomentDatabase; /*! @@ -255,6 +260,8 @@ class VISP_EXPORT vpFeatureMomentGravityCenter : public vpFeatureMoment */ static unsigned int selectYg() { return 1 << 1; } }; - +#endif +#ifdef ENABLE_VISP_NAMESPACE +} #endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h index a2cef02fd9..a974638156 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentGravityCenterNormalized.h @@ -39,8 +39,13 @@ #ifndef _vpFeatureMomentGravityCenterNormalized_h_ #define _vpFeatureMomentGravityCenterNormalized_h_ +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_MOMENTS_COMBINE_MATRICES class vpMomentDatabase; /*! @@ -279,4 +284,7 @@ class VISP_EXPORT vpFeatureMomentGravityCenterNormalized : public vpFeatureMomen static unsigned int selectYn() { return 1 << 1; } }; #endif +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeaturePoint.h b/modules/visual_features/include/visp3/visual_features/vpFeaturePoint.h index 9f10acb371..cc95315971 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeaturePoint.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeaturePoint.h @@ -31,14 +31,14 @@ * 2D point visual feature. */ -#ifndef vpFeaturePoint_H -#define vpFeaturePoint_H - /*! * \file vpFeaturePoint.h * \brief Class that defines 2D point visual feature */ +#ifndef vpFeaturePoint_H +#define vpFeaturePoint_H + #include #include #include @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeaturePoint * \ingroup group_visual_features @@ -227,5 +231,7 @@ class VISP_EXPORT vpFeaturePoint : public vpBasicFeature Y = 2 // y coordinates } vpFeaturePointType; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeaturePoint3D.h b/modules/visual_features/include/visp3/visual_features/vpFeaturePoint3D.h index 2422eb41ba..c2df501792 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeaturePoint3D.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeaturePoint3D.h @@ -31,14 +31,14 @@ * 3D point visual feature. */ -#ifndef vpFeaturePoint3d_H -#define vpFeaturePoint3d_H - /*! * \file vpFeaturePoint3D.h * \brief class that defines the 3D point visual feature. */ +#ifndef vpFeaturePoint3d_H +#define vpFeaturePoint3d_H + #include #include #include @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeaturePoint3D * \ingroup group_visual_features @@ -260,5 +264,8 @@ class VISP_EXPORT vpFeaturePoint3D : public vpBasicFeature static unsigned int selectY(); static unsigned int selectZ(); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeaturePointPolar.h b/modules/visual_features/include/visp3/visual_features/vpFeaturePointPolar.h index e34faaae83..3d7ec03a26 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeaturePointPolar.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeaturePointPolar.h @@ -31,14 +31,14 @@ * 2D point with polar coordinates visual feature. */ -#ifndef vpFeaturePointPolar_H -#define vpFeaturePointPolar_H - /*! * \file vpFeaturePointPolar.h * \brief Class that defines a 2D point visual feature with polar coordinates. */ +#ifndef vpFeaturePointPolar_H +#define vpFeaturePointPolar_H + #include #include #include @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeaturePointPolar * \ingroup group_visual_features @@ -309,5 +313,7 @@ class VISP_EXPORT vpFeaturePointPolar : public vpBasicFeature static unsigned int selectTheta(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureSegment.h b/modules/visual_features/include/visp3/visual_features/vpFeatureSegment.h index 284596a155..aa9f6b26ca 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureSegment.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureSegment.h @@ -31,14 +31,14 @@ * Segment visual feature. */ -#ifndef vpFeatureSegment_H -#define vpFeatureSegment_H - /*! * \file vpFeatureSegment.h * \brief class that defines the Segment visual feature */ +#ifndef vpFeatureSegment_H +#define vpFeatureSegment_H + #include #include #include @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureSegment * \ingroup group_visual_features @@ -291,5 +295,7 @@ class VISP_EXPORT vpFeatureSegment : public vpBasicFeature double sin_a_; bool normalized_; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureThetaU.h b/modules/visual_features/include/visp3/visual_features/vpFeatureThetaU.h index 05ba663316..6ce183a05e 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureThetaU.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureThetaU.h @@ -33,14 +33,14 @@ * *****************************************************************************/ -#ifndef vpFeatureThetaU_H -#define vpFeatureThetaU_H - /*! \file vpFeatureThetaU.h \brief class that defines the ThetaU visual feature */ +#ifndef vpFeatureThetaU_H +#define vpFeatureThetaU_H + #include #include #include @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureThetaU * \ingroup group_visual_features @@ -306,5 +310,7 @@ class VISP_EXPORT vpFeatureThetaU : public vpBasicFeature private: vpFeatureThetaURotationRepresentationType rotation; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureTranslation.h b/modules/visual_features/include/visp3/visual_features/vpFeatureTranslation.h index 7a0f9d2143..d3591bd5ed 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureTranslation.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureTranslation.h @@ -31,14 +31,14 @@ * 3D translation visual feature. */ -#ifndef vpFeatureTranslation_H -#define vpFeatureTranslation_H - /*! \file vpFeatureTranslation.h \brief class that defines the translation visual feature. */ +#ifndef vpFeatureTranslation_H +#define vpFeatureTranslation_H + #include #include #include @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureTranslation * \ingroup group_visual_features @@ -347,5 +351,7 @@ class VISP_EXPORT vpFeatureTranslation : public vpBasicFeature vpHomogeneousMatrix f2Mf1; vpFeatureTranslationRepresentationType translation; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureVanishingPoint.h b/modules/visual_features/include/visp3/visual_features/vpFeatureVanishingPoint.h index 5463eb0945..37ed2ae3bd 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureVanishingPoint.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureVanishingPoint.h @@ -31,14 +31,14 @@ * 2D vanishing point visual feature (Z coordinate in 3D space is infinity) */ -#ifndef vpFeatureVanishingPoint_H -#define vpFeatureVanishingPoint_H - /*! * \file vpFeatureVanishingPoint.h \brief Class that defines 2D vanishing * point visual feature (Z coordinate in 3D space is infinity) */ +#ifndef vpFeatureVanishingPoint_H +#define vpFeatureVanishingPoint_H + #include #include #include @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpFeatureVanishingPoint * \ingroup group_visual_features @@ -112,5 +116,7 @@ class VISP_EXPORT vpFeatureVanishingPoint : public vpBasicFeature protected: unsigned int m_select; // Memory to know which features are used for display; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h b/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h index b21adc2191..9cf4bae616 100644 --- a/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h +++ b/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h @@ -31,21 +31,26 @@ * Generic feature (used to create new feature not implemented in ViSP). */ -#ifndef vpGenericFeature_hh -#define vpGenericFeature_hh - /*! * \file vpGenericFeature.h * \brief class that defines what is a generic feature (used to create new * feature not implemented in ViSP2 */ +#ifndef vpGenericFeature_hh +#define vpGenericFeature_hh + +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpGenericFeature * \ingroup group_visual_features @@ -212,5 +217,7 @@ class VISP_EXPORT vpGenericFeature : public vpBasicFeature vpColVector err; vpGenericFeatureErrorType errorStatus; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/src/feature-builder/vpFeatureBuilderEllipse.cpp b/modules/visual_features/src/feature-builder/vpFeatureBuilderEllipse.cpp index 6c0bebbab9..b9857f1ab7 100644 --- a/modules/visual_features/src/feature-builder/vpFeatureBuilderEllipse.cpp +++ b/modules/visual_features/src/feature-builder/vpFeatureBuilderEllipse.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize an ellipse feature thanks to a vpCircle. The vpFeatureEllipse is initialized thanks to the parameters of the circle @@ -196,3 +200,6 @@ void vpFeatureBuilder::create(vpFeatureEllipse &s, const vpCameraParameters &cam } #endif //#ifdef VISP_HAVE_MODULE_ME +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/feature-builder/vpFeatureBuilderLine.cpp b/modules/visual_features/src/feature-builder/vpFeatureBuilderLine.cpp index 4b2cc411f4..0acc1496a0 100644 --- a/modules/visual_features/src/feature-builder/vpFeatureBuilderLine.cpp +++ b/modules/visual_features/src/feature-builder/vpFeatureBuilderLine.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize a line feature thanks to a vpLine. A vpFeatureLine contains the parameters \f$(\rho,\theta)\f$ which are @@ -66,7 +70,8 @@ void vpFeatureBuilder::create(vpFeatureLine &s, const vpLine &t) B = t.cP[1]; C = t.cP[2]; D = t.cP[3]; - } else { + } + else { A = t.cP[4]; B = t.cP[5]; C = t.cP[6]; @@ -75,7 +80,8 @@ void vpFeatureBuilder::create(vpFeatureLine &s, const vpLine &t) s.setABCD(A, B, C, D); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -110,7 +116,7 @@ void vpFeatureBuilder::create(vpFeatureLine &s, const vpCylinder &t, int line) double R = t.getR(); double D = - vpMath::sqr(x0) + vpMath::sqr(y0) + vpMath::sqr(z0) - vpMath::sqr(R) - vpMath::sqr(a * x0 + b * y0 + c * z0); + vpMath::sqr(x0) + vpMath::sqr(y0) + vpMath::sqr(z0) - vpMath::sqr(R) - vpMath::sqr(a * x0 + b * y0 + c * z0); double alpha1 = (1 - a * a) * x0 - a * b * y0 - a * c * z0; double beta1 = -a * b * x0 + (1 - b * b) * y0 - b * c * z0; @@ -131,11 +137,13 @@ void vpFeatureBuilder::create(vpFeatureLine &s, const vpCylinder &t, int line) s.setRhoTheta(t.getRho1(), t.getTheta1()); - } else { + } + else { s.setRhoTheta(t.getRho2(), t.getTheta2()); } - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -223,9 +231,13 @@ void vpFeatureBuilder::create(vpFeatureLine &s, const vpCameraParameters &cam, c } s.build(rho, theta); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } } #endif //#ifdef VISP_HAVE_MODULE_ME +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint.cpp b/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint.cpp index 56f4866cf1..1d561efe36 100644 --- a/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint.cpp +++ b/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_HAVE_MODULE_BLOB /*! Create a vpFeaturePoint thanks to a vpDot and the parameters of the camera. @@ -99,7 +103,8 @@ void vpFeatureBuilder::create(vpFeaturePoint &s, const vpCameraParameters &cam, s.set_x(x); s.set_y(y); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -159,7 +164,8 @@ void vpFeatureBuilder::create(vpFeaturePoint &s, const vpCameraParameters &cam, s.set_x(x); s.set_y(y); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -217,7 +223,8 @@ void vpFeatureBuilder::create(vpFeaturePoint &s, const vpCameraParameters &cam, s.set_x(x); s.set_y(y); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -259,7 +266,8 @@ void vpFeatureBuilder::create(vpFeaturePoint &s, const vpPoint &p) throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null")); } - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -311,8 +319,12 @@ void vpFeatureBuilder::create(vpFeaturePoint &s, const vpCameraParameters &goodC s.set_x(x); s.set_y(y); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint3D.cpp b/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint3D.cpp index 26572f006e..22b9e89c2d 100644 --- a/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint3D.cpp +++ b/modules/visual_features/src/feature-builder/vpFeatureBuilderPoint3D.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize a 3D point feature using the coordinates of the point @@ -64,12 +68,15 @@ void vpFeatureBuilder::create(vpFeaturePoint3D &s, const vpPoint &t) s.set_Y(t.cP[1] / t.cP[3]); s.set_Z(t.cP[2] / t.cP[3]); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/visual_features/src/feature-builder/vpFeatureBuilderPointPolar.cpp b/modules/visual_features/src/feature-builder/vpFeatureBuilderPointPolar.cpp index 8aaa92d95d..d2c668a357 100644 --- a/modules/visual_features/src/feature-builder/vpFeatureBuilderPointPolar.cpp +++ b/modules/visual_features/src/feature-builder/vpFeatureBuilderPointPolar.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_HAVE_MODULE_BLOB /*! @@ -111,7 +115,8 @@ void vpFeatureBuilder::create(vpFeaturePointPolar &s, const vpCameraParameters & s.set_rho(rho); s.set_theta(theta); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -183,7 +188,8 @@ void vpFeatureBuilder::create(vpFeaturePointPolar &s, const vpCameraParameters & s.set_rho(rho); s.set_theta(theta); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -251,7 +257,8 @@ void vpFeatureBuilder::create(vpFeaturePointPolar &s, const vpCameraParameters & s.set_rho(rho); s.set_theta(theta); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -304,7 +311,8 @@ void vpFeatureBuilder::create(vpFeaturePointPolar &s, const vpPoint &p) throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null")); } - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } @@ -361,12 +369,15 @@ void vpFeatureBuilder::create(vpFeaturePointPolar &s, const vpCameraParameters & s.set_rho(rho); s.set_theta(theta); - } catch (...) { + } + catch (...) { vpERROR_TRACE("Error caught"); throw; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/visual_features/src/feature-builder/vpFeatureBuilderSegment.cpp b/modules/visual_features/src/feature-builder/vpFeatureBuilderSegment.cpp index 22a1938feb..b09b71a7db 100644 --- a/modules/visual_features/src/feature-builder/vpFeatureBuilderSegment.cpp +++ b/modules/visual_features/src/feature-builder/vpFeatureBuilderSegment.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_HAVE_MODULE_BLOB /*! @@ -162,3 +166,6 @@ void vpFeatureBuilder::create(vpFeatureSegment &s, vpPoint &P1, vpPoint &P2) s.build(x1, y1, Z1, x2, y2, Z2); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/feature-builder/vpFeatureBuilderVanishingPoint.cpp b/modules/visual_features/src/feature-builder/vpFeatureBuilderVanishingPoint.cpp index 1cd2d9a4ea..6d1df7472a 100644 --- a/modules/visual_features/src/feature-builder/vpFeatureBuilderVanishingPoint.cpp +++ b/modules/visual_features/src/feature-builder/vpFeatureBuilderVanishingPoint.cpp @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize a vpFeatureVanishingPoint thanks to a vpPoint. The vpFeatureVanishingPoint is initialized thanks to the parameters of the @@ -66,8 +70,9 @@ void vpFeatureBuilder::create(vpFeatureVanishingPoint &s, const vpPoint &p, unsi if ((vpFeatureVanishingPoint::selectX() & select) || (vpFeatureVanishingPoint::selectY() & select)) { s.set_x(p.get_x()); s.set_y(p.get_y()); - } else if ((vpFeatureVanishingPoint::selectOneOverRho() & select) || - (vpFeatureVanishingPoint::selectAlpha() & select)) { + } + else if ((vpFeatureVanishingPoint::selectOneOverRho() & select) || + (vpFeatureVanishingPoint::selectAlpha() & select)) { double x = p.get_x(); double y = p.get_y(); @@ -113,8 +118,8 @@ void vpFeatureBuilder::create(vpFeatureVanishingPoint &s, const vpFeatureLine &L if (fabs(theta_r - theta_l) < min || fabs(fabs(theta_r - theta_l) - M_PI) < min || fabs(fabs(theta_r - theta_l) - 2 * M_PI) < min) { vpCERROR << "There is no vanishing point : the lines are parallel in the " - "image plane" - << std::endl; + "image plane" + << std::endl; throw(vpFeatureException(vpFeatureException::badInitializationError, "There is no vanishing point : the lines are " "parallel in the image plane")); @@ -125,8 +130,9 @@ void vpFeatureBuilder::create(vpFeatureVanishingPoint &s, const vpFeatureLine &L s.set_x(x); s.set_y(y); - } else if ((vpFeatureVanishingPoint::selectOneOverRho() & select) || - (vpFeatureVanishingPoint::selectAlpha() & select)) { + } + else if ((vpFeatureVanishingPoint::selectOneOverRho() & select) || + (vpFeatureVanishingPoint::selectAlpha() & select)) { double rho_1 = L1.getRho(); double theta_1 = L1.getTheta(); double rho_2 = L2.getRho(); @@ -225,7 +231,8 @@ void vpFeatureBuilder::create(vpFeatureVanishingPoint &s, const vpCameraParamete s.set_x(x); s.set_y(y); - } else if ((vpFeatureVanishingPoint::selectOneOverRho() & select)) { + } + else if ((vpFeatureVanishingPoint::selectOneOverRho() & select)) { double theta_diff = theta_1 - theta_2; double denom = sqrt(rho_1 * rho_1 + rho_2 * rho_2 - 2 * rho_1 * rho_2 * cos(theta_diff)); double one_over_rho = sin(theta_diff) / denom; @@ -236,7 +243,8 @@ void vpFeatureBuilder::create(vpFeatureVanishingPoint &s, const vpCameraParamete s.setOneOverRho(one_over_rho); s.setAlpha(alpha); - } else if ((vpFeatureVanishingPoint::selectAtanOneOverRho() & select)) { + } + else if ((vpFeatureVanishingPoint::selectAtanOneOverRho() & select)) { double theta_diff = theta_1 - theta_2; double denom = sqrt(rho_1 * rho_1 + rho_2 * rho_2 - 2 * rho_1 * rho_2 * cos(theta_diff)); double alpha = atan2(rho_1 * cos(theta_2) - rho_2 * cos(theta_1), rho_2 * sin(theta_1) - rho_1 * sin(theta_2)); @@ -252,3 +260,6 @@ void vpFeatureBuilder::create(vpFeatureVanishingPoint &s, const vpCameraParamete s.setAlpha(alpha); } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpBasicFeature.cpp b/modules/visual_features/src/visual-feature/vpBasicFeature.cpp index 1f219c43b9..afc36894d4 100644 --- a/modules/visual_features/src/visual-feature/vpBasicFeature.cpp +++ b/modules/visual_features/src/visual-feature/vpBasicFeature.cpp @@ -36,8 +36,17 @@ * *****************************************************************************/ +/*! + \file vpBasicFeature.cpp + \brief Class that defines what is a visual feature. +*/ + #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const unsigned int vpBasicFeature::FEATURE_LINE[32] = { (unsigned int)(1 << 0), (unsigned int)(1 << 1), (unsigned int)(1 << 2), (unsigned int)(1 << 3), (unsigned int)(1 << 4), (unsigned int)(1 << 5), (unsigned int)(1 << 6), (unsigned int)(1 << 7), @@ -46,16 +55,13 @@ const unsigned int vpBasicFeature::FEATURE_LINE[32] = { (unsigned int)(1 << 16), (unsigned int)(1 << 17), (unsigned int)(1 << 18), (unsigned int)(1 << 19), (unsigned int)(1 << 20), (unsigned int)(1 << 21), (unsigned int)(1 << 22), (unsigned int)(1 << 23), (unsigned int)(1 << 24), (unsigned int)(1 << 25), (unsigned int)(1 << 26), (unsigned int)(1 << 27), - (unsigned int)(1 << 28), (unsigned int)(1 << 29), (unsigned int)(1 << 30), (unsigned int)(1 << 31)}; + (unsigned int)(1 << 28), (unsigned int)(1 << 29), (unsigned int)(1 << 30), (unsigned int)(1 << 31) }; + -/*! - \file vpBasicFeature.cpp - \brief Class that defines what is a visual feature. -*/ /*! Default constructor. */ -vpBasicFeature::vpBasicFeature() : s(), dim_s(0), flags(nullptr), nbParameters(0), deallocate(vpBasicFeature::user) {} +vpBasicFeature::vpBasicFeature() : s(), dim_s(0), flags(nullptr), nbParameters(0), deallocate(vpBasicFeature::user) { } /*! Destructor that free allocated memory. @@ -157,7 +163,8 @@ vpColVector vpBasicFeature::error(const vpBasicFeature &s_star, unsigned int sel // std::cout << "dim_s <= 31"< /* - - - attributes and members directly related to the vpBasicFeature needs other functionalities ar useful but not mandatory - - - - - */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize the memory space requested for 3D depth visual feature. */ @@ -463,7 +459,9 @@ void vpFeatureDepth::display(const vpCameraParameters & /* cam */, const vpImage // to produce a failure } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/visual_features/src/visual-feature/vpFeatureEllipse.cpp b/modules/visual_features/src/visual-feature/vpFeatureEllipse.cpp index 5919bd3672..b714e49a02 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureEllipse.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureEllipse.cpp @@ -60,6 +60,11 @@ other functionalities ar useful but not mandatory */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + void vpFeatureEllipse::init() { // feature dimension @@ -481,3 +486,6 @@ vp_deprecated unsigned int vpFeatureEllipse::selectMu11() { return FEATURE_LINE[ */ vp_deprecated unsigned int vpFeatureEllipse::selectMu02() { return FEATURE_LINE[4]; } #endif +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureLine.cpp b/modules/visual_features/src/visual-feature/vpFeatureLine.cpp index b273a1d7c0..97470961a8 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureLine.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureLine.cpp @@ -67,6 +67,10 @@ attributes and members directly related to the vpBasicFeature needs other functionalities ar useful but not mandatory */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize the memory space requested for 2D line visual feature. */ @@ -600,3 +604,6 @@ unsigned int vpFeatureLine::selectRho() { return FEATURE_LINE[0]; } \endcode */ unsigned int vpFeatureLine::selectTheta() { return FEATURE_LINE[1]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureLuminance.cpp b/modules/visual_features/src/visual-feature/vpFeatureLuminance.cpp index 41d04e195a..bf5a1592df 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureLuminance.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureLuminance.cpp @@ -33,6 +33,13 @@ * *****************************************************************************/ +/*! + \file vpFeatureLuminance.cpp + \brief Class that defines the image luminance visual feature + + For more details see \cite Collewet08c. +*/ + #include #include #include @@ -43,12 +50,10 @@ #include -/*! - \file vpFeatureLuminance.cpp - \brief Class that defines the image luminance visual feature - - For more details see \cite Collewet08c. -*/ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize the memory space requested for vpFeatureLuminance visual feature. @@ -367,6 +372,9 @@ vpFeatureLuminance *vpFeatureLuminance::duplicate() const return feature; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp b/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp index bf8222a83b..f6c11a5725 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpBasicFeature; /*! @@ -247,20 +251,6 @@ void vpFeatureMoment::linkTo(vpFeatureMomentDatabase &featureMoments) void vpFeatureMoment::compute_interaction() { } -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM) -{ - /* - * - A static_cast is forced here since interaction() defined in vpBasicFeature() - * is not const. But introducing const in vpBasicFeature() can break a lot of - * client code. - * - 6 corresponds to 6 velocities in standard interaction matrix - */ - vpMatrix Lcomplete(static_cast(featM.getDimension()), 6); - Lcomplete = const_cast(featM).interaction(vpBasicFeature::FEATURE_ALL); - Lcomplete.matlabPrint(os); - return os; -} - /*! * Interface function to display the moments and other interaction matrices * on which a particular vpFeatureMoment is dependent upon @@ -275,3 +265,23 @@ void vpFeatureMoment::printDependencies(std::ostream &os) const "to be implemented in the derived classes!" << std::endl; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMoment &featM) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + /* + * - A static_cast is forced here since interaction() defined in vpBasicFeature() + * is not const. But introducing const in vpBasicFeature() can break a lot of + * client code. + * - 6 corresponds to 6 velocities in standard interaction matrix + */ + vpMatrix Lcomplete(static_cast(featM.getDimension()), 6); + Lcomplete = const_cast(featM).interaction(vpBasicFeature::FEATURE_ALL); + Lcomplete.matlabPrint(os); + return os; +} diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentAlpha.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentAlpha.cpp index 22a418b852..6c691139cd 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentAlpha.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentAlpha.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_MOMENTS_COMBINE_MATRICES /*! @@ -166,3 +170,6 @@ vpColVector vpFeatureMomentAlpha::error(const vpBasicFeature &s_star, const unsi return e; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentArea.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentArea.cpp index ed31e18f21..1e62395296 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentArea.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentArea.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Computes interaction matrix for the normalized surface moment. Called internally. The moment primitives must be computed before calling this. This @@ -74,11 +78,12 @@ void vpFeatureMomentArea::compute_interaction() if (!found_centered) throw vpException(vpException::notInitialized, "vpFeatureMomentCentered not found"); interaction_matrices[0] = momentCentered.interaction(2, 0) + momentCentered.interaction(0, 2); - } else { - // Get Xg and Yg + } + else { + // Get Xg and Yg bool found_xgyg; const vpMomentGravityCenter &momentGravity = - static_cast(moments.get("vpMomentGravityCenter", found_xgyg)); + static_cast(moments.get("vpMomentGravityCenter", found_xgyg)); if (!found_xgyg) throw vpException(vpException::notInitialized, "vpMomentGravityCenter not found"); @@ -102,3 +107,6 @@ void vpFeatureMomentArea::compute_interaction() interaction_matrices[0][0][5] = 0.; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentAreaNormalized.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentAreaNormalized.cpp index 61c845c788..b7cc46e43a 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentAreaNormalized.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentAreaNormalized.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for the normalized surface moment. Called * internally. The moment primitives must be computed before calling this. This @@ -97,7 +101,9 @@ void vpFeatureMomentAreaNormalized::compute_interaction() (-momentSurfaceNormalized.getDesiredDepth() / (2 * a)) * sqrt(momentSurfaceNormalized.getDesiredArea() / a); interaction_matrices[0] = normalized_multiplier * La; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else #include @@ -110,6 +116,10 @@ void vpFeatureMomentAreaNormalized::compute_interaction() #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for the normalized surface moment. Called * internally. The moment primitives must be computed before calling this. This @@ -199,5 +209,7 @@ void vpFeatureMomentAreaNormalized::compute_interaction() interaction_matrices[0][0][WY] = Anwy; interaction_matrices[0][0][WZ] = 0.; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentBasic.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentBasic.cpp index ff1bd231e8..269ac7c906 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentBasic.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentBasic.cpp @@ -36,6 +36,11 @@ #include #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor. * \param data_base : Database of moment primitives. @@ -158,3 +163,6 @@ vpMatrix vpFeatureMomentBasic::interaction(unsigned int select_one, unsigned int "specify a higher order."); return interaction_matrices[select_two * order + select_one]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp index 97769c5d7a..c700446ba9 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for space-scale-rotation invariants. Called * internally. The moment primitives must be computed before calling this. This @@ -405,7 +409,9 @@ void vpFeatureMomentCInvariant::compute_interaction() interaction_matrices[13] = (I2 / (I3 * I3 * I3)) * La + (a / (I3 * I3 * I3)) * LI2 - (3 * a * I2 / (I3 * I3 * I3 * I3)) * LI3; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else #include #include @@ -420,6 +426,10 @@ void vpFeatureMomentCInvariant::compute_interaction() #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for space-scale-rotation invariants. Called * internally. The moment primitives must be computed before calling this. This @@ -684,12 +694,15 @@ void vpFeatureMomentCInvariant::printLsofInvariants(std::ostream &os) const os << std::endl; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /*! * \relates vpFeatureMomentCInvariant * Print all the interaction matrices of visual features */ -std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCInvariant &featcinv) +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCInvariant &featcinv) { // Print L for c1 .. c10 for (unsigned int i = 0; i < 10; ++i) { diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp index a6642f887f..dc77ef1446 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor. * \param moments_ : Database of moment primitives. @@ -315,13 +319,19 @@ void vpFeatureMomentCentered::compute_interaction() } #endif // #ifdef VISP_MOMENTS_COMBINE_MATRICES } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /*! * \relates vpFeatureMomentCentered * Print all the interaction matrices of visual features */ -std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCentered &mu) +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCentered &mu) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpTRACE(" << Ls - CENTRED MOMENTS >>"); unsigned int order_m_1 = (unsigned int)(mu.order - 1); for (unsigned int i = 0; i < order_m_1; i++) { diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentCommon.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentCommon.cpp index 3922385be5..9d9de560ac 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentCommon.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentCommon.cpp @@ -35,6 +35,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Constructor which initializes and links all common features in the database * \param moments : database for moment primitives @@ -75,3 +79,6 @@ void vpFeatureMomentCommon::updateAll(double A, double B, double C) featureAlpha.update(A, B, C); feature_moment_area.update(A, B, C); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentDatabase.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentDatabase.cpp index 58a8e2c6ec..162426c62b 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentDatabase.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentDatabase.cpp @@ -37,6 +37,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Add a moment and it's corresponding name to the database * \param featureMoment : database for moment features @@ -91,3 +95,6 @@ void vpFeatureMomentDatabase::updateAll(double A, double B, double C) } #endif } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenter.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenter.cpp index a0fa07da9c..b043115704 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenter.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenter.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for gravity center moment. Called internally. * The moment primitives must be computed before calling this. @@ -72,7 +76,9 @@ void vpFeatureMomentGravityCenter::compute_interaction() featureMomentBasic.interaction(0, 1) / momentObject.get(0, 0) - momentObject.get(0, 1) * pow(momentObject.get(0, 0), -0.2e1) * featureMomentBasic.interaction(0, 0); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else #include @@ -84,6 +90,10 @@ void vpFeatureMomentGravityCenter::compute_interaction() #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for gravity center moment. Called internally. * The moment primitives must be computed before calling this. @@ -155,5 +165,7 @@ void vpFeatureMomentGravityCenter::compute_interaction() interaction_matrices[1][0][WY] = Ygwy; interaction_matrices[1][0][WZ] = -Xg; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp index 55145e01b9..112a524365 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentGravityCenterNormalized.cpp @@ -46,7 +46,10 @@ #include #include #include - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for centered and normalized moment. Called * internally. The moment primitives must be computed before calling this. This @@ -91,7 +94,9 @@ void vpFeatureMomentGravityCenterNormalized::compute_interaction() interaction_matrices[1] = momentGravity.get()[1] * featureMomentAreaNormalized.interaction(1) + momentSurfaceNormalized.get()[0] * featureMomentGravity.interaction(2); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else #include @@ -104,6 +109,10 @@ void vpFeatureMomentGravityCenterNormalized::compute_interaction() #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Computes interaction matrix for centered and normalized moment. Called * internally. The moment primitives must be computed before calling this. This @@ -221,4 +230,7 @@ void vpFeatureMomentGravityCenterNormalized::compute_interaction() interaction_matrices[1][0][WY] = Ynwy; interaction_matrices[1][0][WZ] = -Xn; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/src/visual-feature/vpFeaturePoint.cpp b/modules/visual_features/src/visual-feature/vpFeaturePoint.cpp index 64e87436b5..afc86b5d35 100644 --- a/modules/visual_features/src/visual-feature/vpFeaturePoint.cpp +++ b/modules/visual_features/src/visual-feature/vpFeaturePoint.cpp @@ -60,6 +60,10 @@ other functionalities ar useful but not mandatory */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize the memory space requested for 2D point visual feature. */ @@ -547,3 +551,6 @@ unsigned int vpFeaturePoint::selectX() { return FEATURE_LINE[0]; } \endcode */ unsigned int vpFeaturePoint::selectY() { return FEATURE_LINE[1]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeaturePoint3D.cpp b/modules/visual_features/src/visual-feature/vpFeaturePoint3D.cpp index b1c6213824..36dd6ba506 100644 --- a/modules/visual_features/src/visual-feature/vpFeaturePoint3D.cpp +++ b/modules/visual_features/src/visual-feature/vpFeaturePoint3D.cpp @@ -50,6 +50,10 @@ */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialise the memory space requested for a 3D point visual @@ -679,3 +683,6 @@ unsigned int vpFeaturePoint3D::selectY() { return FEATURE_LINE[1]; } */ unsigned int vpFeaturePoint3D::selectZ() { return FEATURE_LINE[2]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeaturePointPolar.cpp b/modules/visual_features/src/visual-feature/vpFeaturePointPolar.cpp index cac998ffb4..a89fd5995b 100644 --- a/modules/visual_features/src/visual-feature/vpFeaturePointPolar.cpp +++ b/modules/visual_features/src/visual-feature/vpFeaturePointPolar.cpp @@ -60,6 +60,10 @@ */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialise the memory space requested for a 2D point visual @@ -626,3 +630,6 @@ unsigned int vpFeaturePointPolar::selectRho() { return FEATURE_LINE[0]; } \sa selectRho() */ unsigned int vpFeaturePointPolar::selectTheta() { return FEATURE_LINE[1]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureSegment.cpp b/modules/visual_features/src/visual-feature/vpFeatureSegment.cpp index 1c4f599145..2ec6d501b3 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureSegment.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureSegment.cpp @@ -31,6 +31,11 @@ * Segment visual feature. */ +/*! + * \file vpFeatureSegment.cpp + * \brief class that defines the vpFeatureSegment visual feature + */ + #include #include #include @@ -45,10 +50,10 @@ // Debug trace #include -/*! - * \file vpFeatureSegment.cpp - * \brief class that defines the vpFeatureSegment visual feature - */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Initialise the memory space requested for segment visual feature. @@ -695,3 +700,6 @@ unsigned int vpFeatureSegment::selectL() { return FEATURE_LINE[2]; } */ unsigned int vpFeatureSegment::selectAlpha() { return FEATURE_LINE[3]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureThetaU.cpp b/modules/visual_features/src/visual-feature/vpFeatureThetaU.cpp index d5a7ed9841..e5faeaa61d 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureThetaU.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureThetaU.cpp @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + \file vpFeatureThetaU.cpp + \brief class that defines the ThetaU visual feature +*/ + #include #include #include @@ -44,10 +49,6 @@ // Debug trace #include -/*! - \file vpFeatureThetaU.cpp - \brief class that defines the ThetaU visual feature -*/ /* attributes and members directly related to the vpBasicFeature needs @@ -55,6 +56,10 @@ other functionalities are useful but not mandatory */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialise the memory space requested for 3D \f$ \theta u \f$ visual @@ -836,3 +841,6 @@ unsigned int vpFeatureThetaU::selectTUy() { return FEATURE_LINE[1]; } \sa selectTUx(), selectTUy() */ unsigned int vpFeatureThetaU::selectTUz() { return FEATURE_LINE[2]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureTranslation.cpp b/modules/visual_features/src/visual-feature/vpFeatureTranslation.cpp index adf8c6679e..c8fa77dd13 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureTranslation.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureTranslation.cpp @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + \file vpFeatureTranslation.cpp + \brief class that defines 3D translation visual feature +*/ + #include #include @@ -45,10 +50,6 @@ // Debug trace #include -/*! - \file vpFeatureTranslation.cpp - \brief class that defines 3D translation visual feature -*/ /* attributes and members directly related to the vpBasicFeature needs @@ -56,6 +57,10 @@ other functionalities are useful but not mandatory */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialise the memory space requested for 3D translation visual @@ -785,3 +790,6 @@ unsigned int vpFeatureTranslation::selectTy() { return FEATURE_LINE[1]; } \sa selectTx(), selectTy() */ unsigned int vpFeatureTranslation::selectTz() { return FEATURE_LINE[2]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureVanishingPoint.cpp b/modules/visual_features/src/visual-feature/vpFeatureVanishingPoint.cpp index bc8a239c56..89aa4d105e 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureVanishingPoint.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureVanishingPoint.cpp @@ -55,6 +55,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Vanishing point visual feature initialization. */ @@ -457,3 +461,6 @@ unsigned int vpFeatureVanishingPoint::selectAtanOneOverRho() { return FEATURE_LI * Select \f$ s = \theta \f$ visual feature. */ unsigned int vpFeatureVanishingPoint::selectAlpha() { return FEATURE_LINE[4]; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpGenericFeature.cpp b/modules/visual_features/src/visual-feature/vpGenericFeature.cpp index f967ded7e3..84bd4dfb87 100644 --- a/modules/visual_features/src/visual-feature/vpGenericFeature.cpp +++ b/modules/visual_features/src/visual-feature/vpGenericFeature.cpp @@ -42,6 +42,10 @@ // Debug trace #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpGenericFeature::init() { s = 0; } /*! @@ -646,7 +650,9 @@ void vpGenericFeature::display(const vpCameraParameters & /* cam */, const vpIma // to produce a failure } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/visual_features/test/feature/testPoint.cpp b/modules/visual_features/test/feature/testPoint.cpp index 18dd3b4e46..2ce5a46ff3 100644 --- a/modules/visual_features/test/feature/testPoint.cpp +++ b/modules/visual_features/test/feature/testPoint.cpp @@ -51,6 +51,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { vpHomogeneousMatrix cMo; cMo[0][3] = 0.1; @@ -130,9 +133,11 @@ int main() vpTRACE("\t selectAll"); e = p.error(pd, vpFeaturePoint::selectAll()); std::cout << e << std::endl; - } catch (vpFeatureException &me) { + } + catch (vpFeatureException &me) { std::cout << me << std::endl; - } catch (const vpException &me) { + } + catch (const vpException &me) { std::cout << me << std::endl; } std::cout << "------------------------------------------------------" << std::endl; @@ -158,7 +163,8 @@ int main() dim = p.getDimension(vpFeaturePoint::selectAll()); std::cout << "Dimension = " << dim << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } From ce67c68c2fd7677a0d0e21a51a22b1a4da057be5 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 13:42:41 +0200 Subject: [PATCH 12/64] [WIP] visp_blob compile --- modules/tracker/blob/include/visp3/blob/vpDot.h | 16 ++++++++++++++-- .../tracker/blob/include/visp3/blob/vpDot2.h | 17 +++++++++++++++-- modules/tracker/blob/src/dots/vpDot.cpp | 12 ++++++------ modules/tracker/blob/src/dots/vpDot2.cpp | 12 ++++++------ 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/modules/tracker/blob/include/visp3/blob/vpDot.h b/modules/tracker/blob/include/visp3/blob/vpDot.h index bca93ec2f3..1b52904b82 100644 --- a/modules/tracker/blob/include/visp3/blob/vpDot.h +++ b/modules/tracker/blob/include/visp3/blob/vpDot.h @@ -58,8 +58,20 @@ #pragma comment(linker, "/STACK:256000000") // Increase max recursion depth #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpDot; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot &d); + #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -304,7 +316,7 @@ class VISP_EXPORT vpDot : public vpTracker vpDot &operator=(const vpDot &d); bool operator==(const vpDot &d) const; bool operator!=(const vpDot &d) const; - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot &d); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, vpDot &d); void print(std::ostream &os) { os << *this << std::endl; } diff --git a/modules/tracker/blob/include/visp3/blob/vpDot2.h b/modules/tracker/blob/include/visp3/blob/vpDot2.h index 914164da39..2a9f239990 100644 --- a/modules/tracker/blob/include/visp3/blob/vpDot2.h +++ b/modules/tracker/blob/include/visp3/blob/vpDot2.h @@ -42,6 +42,7 @@ #define vpDot2_hh #include +#include #include #include #include @@ -51,8 +52,20 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpDot2; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot2 &d); + #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -246,7 +259,7 @@ class VISP_EXPORT vpDot2 : public vpTracker unsigned int gray_lvl_max, unsigned int size = 0); vpDot2 &operator=(const vpDot2 &twinDot); - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot2 &d); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, vpDot2 &d); void print(std::ostream &os) { os << *this << std::endl; } void searchDotsInArea(const vpImage &I, int area_u, int area_v, unsigned int area_w, diff --git a/modules/tracker/blob/src/dots/vpDot.cpp b/modules/tracker/blob/src/dots/vpDot.cpp index 20124f9eb8..29ef78a697 100644 --- a/modules/tracker/blob/src/dots/vpDot.cpp +++ b/modules/tracker/blob/src/dots/vpDot.cpp @@ -49,7 +49,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -946,13 +946,13 @@ void vpDot::display(const vpImage &I, const vpImagePoint &cog, const std } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! Writes the dot center of gravity coordinates in the frame (i,j) (For more details about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, and returns a reference to the stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot &d) { return (os << "(" << d.getCog() << ")"); }; - -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif +VISP_EXPORT std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot &d) { return (os << "(" << d.getCog() << ")"); }; diff --git a/modules/tracker/blob/src/dots/vpDot2.cpp b/modules/tracker/blob/src/dots/vpDot2.cpp index 3275d469ba..e753135714 100644 --- a/modules/tracker/blob/src/dots/vpDot2.cpp +++ b/modules/tracker/blob/src/dots/vpDot2.cpp @@ -55,7 +55,7 @@ #include #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif @@ -2505,13 +2505,13 @@ void vpDot2::display(const vpImage &I, const vpImagePoint &cog, const st } } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! Writes the dot center of gravity coordinates in the frame (i,j) (For more details about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, and returns a reference to the stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot2 &d) { return (os << "(" << d.getCog() << ")"); } - -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif +VISP_EXPORT std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot2 &d) { return (os << "(" << d.getCog() << ")"); } From bb7d93c4d4018f50705081ea8d26ec1f1de686c3 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 13:45:46 +0200 Subject: [PATCH 13/64] [WIP] visp_klt compiles --- modules/tracker/klt/include/visp3/klt/vpKltOpencv.h | 8 +++++++- modules/tracker/klt/src/vpKltOpencv.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/tracker/klt/include/visp3/klt/vpKltOpencv.h b/modules/tracker/klt/include/visp3/klt/vpKltOpencv.h index 45e4dcc6a1..fd2327e734 100644 --- a/modules/tracker/klt/include/visp3/klt/vpKltOpencv.h +++ b/modules/tracker/klt/include/visp3/klt/vpKltOpencv.h @@ -52,6 +52,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpKltOpencv * @@ -400,6 +404,8 @@ class VISP_EXPORT vpKltOpencv long m_next_points_id; //!< Id for the newt keypoint bool m_initial_guess; //!< true when initial guess is provided }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/tracker/klt/src/vpKltOpencv.cpp b/modules/tracker/klt/src/vpKltOpencv.cpp index 6f74012751..a6e950f2b5 100644 --- a/modules/tracker/klt/src/vpKltOpencv.cpp +++ b/modules/tracker/klt/src/vpKltOpencv.cpp @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpKltOpencv::vpKltOpencv() : m_gray(), m_prevGray(), m_points_id(), m_maxCount(500), m_termcrit(), m_winSize(10), m_qualityLevel(0.01), m_minDistance(15), m_minEigThreshold(1e-4), m_harris_k(0.04), m_blockSize(3), m_useHarrisDetector(1), @@ -321,7 +325,9 @@ void vpKltOpencv::suppressFeature(const int &index) m_points[1].erase(m_points[1].begin() + index); m_points_id.erase(m_points_id.begin() + index); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid visp_klt library empty when OpenCV is not installed or used From c4079d86e49ba1543111c8557a743a0aabbc2e53 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 13:52:53 +0200 Subject: [PATCH 14/64] [WIP] visp_vs compiles --- modules/vs/include/visp3/vs/vpAdaptiveGain.h | 27 ++++++++++--- modules/vs/include/visp3/vs/vpServo.h | 15 +++++-- modules/vs/include/visp3/vs/vpServoData.h | 15 +++++-- modules/vs/include/visp3/vs/vpServoDisplay.h | 15 +++++-- .../vs/include/visp3/vs/vpServoException.h | 15 +++++-- modules/vs/src/vpAdaptiveGain.cpp | 10 ++++- modules/vs/src/vpServo.cpp | 40 +++++++++++-------- modules/vs/src/vpServoData.cpp | 7 ++++ modules/vs/src/vpServoDisplay.cpp | 7 ++++ .../vs/test/visual-feature/testFeature.cpp | 6 ++- .../test/visual-feature/testFeatureMoment.cpp | 4 ++ .../visual-feature/testFeatureSegment.cpp | 5 ++- 12 files changed, 126 insertions(+), 40 deletions(-) diff --git a/modules/vs/include/visp3/vs/vpAdaptiveGain.h b/modules/vs/include/visp3/vs/vpAdaptiveGain.h index 43020522b4..2425cd1aa6 100644 --- a/modules/vs/include/visp3/vs/vpAdaptiveGain.h +++ b/modules/vs/include/visp3/vs/vpAdaptiveGain.h @@ -31,19 +31,34 @@ * Adaptive gain. */ -#ifndef _vpAdaptiveGain_h_ -#define _vpAdaptiveGain_h_ - /*! * \file vpAdaptiveGain.h * \brief Adaptive gain */ +#ifndef _vpAdaptiveGain_h_ +#define _vpAdaptiveGain_h_ + #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +class vpAdaptiveGain; class vpColVector; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif +// Forward declaration to have the operator in the global namespace +std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpAdaptiveGain &lambda); + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpAdaptiveGain * @@ -301,7 +316,9 @@ class VISP_EXPORT vpAdaptiveGain * \param os : The stream where to print the adaptive gain parameters. * \param lambda : The adaptive gain containing the parameters to print. */ - friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpAdaptiveGain &lambda); + friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpAdaptiveGain &lambda); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vs/include/visp3/vs/vpServo.h b/modules/vs/include/visp3/vs/vpServo.h index 8a00e2495e..70186e0ca1 100644 --- a/modules/vs/include/visp3/vs/vpServo.h +++ b/modules/vs/include/visp3/vs/vpServo.h @@ -31,22 +31,27 @@ * Visual servoing control law. */ -#ifndef _vpServo_h_ -#define _vpServo_h_ - /*! * \file vpServo.h * \brief Class required to compute the visual servoing control law. */ +#ifndef _vpServo_h_ +#define _vpServo_h_ + #include +#include #include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpServo * @@ -1333,5 +1338,7 @@ class VISP_EXPORT vpServo double m_pseudo_inverse_threshold; //!< Threshold used in the pseudo inverse }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vs/include/visp3/vs/vpServoData.h b/modules/vs/include/visp3/vs/vpServoData.h index cea85db513..3fac68cfe1 100644 --- a/modules/vs/include/visp3/vs/vpServoData.h +++ b/modules/vs/include/visp3/vs/vpServoData.h @@ -31,19 +31,24 @@ * Save data during the task execution. */ -#ifndef _vpServoData_h_ -#define _vpServoData_h_ - /*! \file vpServoData.h \brief save data during the task execution */ +#ifndef _vpServoData_h_ +#define _vpServoData_h_ + +#include // Servo #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpServoData * \ingroup group_task @@ -115,5 +120,7 @@ class VISP_EXPORT vpServoData */ void close(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vs/include/visp3/vs/vpServoDisplay.h b/modules/vs/include/visp3/vs/vpServoDisplay.h index 0da40d004f..4f7b7d2e4c 100644 --- a/modules/vs/include/visp3/vs/vpServoDisplay.h +++ b/modules/vs/include/visp3/vs/vpServoDisplay.h @@ -31,20 +31,25 @@ * Interface with the image for feature display. */ -#ifndef vpServoDisplay_H -#define vpServoDisplay_H - /*! * \file vpServoDisplay.h * \brief interface with the image for feature display */ +#ifndef vpServoDisplay_H +#define vpServoDisplay_H + +#include #include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpServoDisplay * \ingroup group_task @@ -97,5 +102,7 @@ class VISP_EXPORT vpServoDisplay vpColor currentColor = vpColor::green, vpColor desiredColor = vpColor::red, unsigned int thickness = 1); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vs/include/visp3/vs/vpServoException.h b/modules/vs/include/visp3/vs/vpServoException.h index 2b2a65b954..1d4f13eb03 100644 --- a/modules/vs/include/visp3/vs/vpServoException.h +++ b/modules/vs/include/visp3/vs/vpServoException.h @@ -31,19 +31,24 @@ * Exception that can be emitted by the vpServo class and its derivatives. */ -#ifndef _vpServoException_h_ -#define _vpServoException_h_ - /*! * \file vpServoException.h * \brief error that can be emitted by the vpServo class and its derivatives */ +#ifndef _vpServoException_h_ +#define _vpServoException_h_ + +#include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpServoException * \brief Error that can be emitted by the vpServo class and its derivatives. @@ -90,5 +95,7 @@ class VISP_EXPORT vpServoException : public vpException */ explicit vpServoException(int id) : vpException(id) { } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/vs/src/vpAdaptiveGain.cpp b/modules/vs/src/vpAdaptiveGain.cpp index 72c373c572..f1d6e36e54 100644 --- a/modules/vs/src/vpAdaptiveGain.cpp +++ b/modules/vs/src/vpAdaptiveGain.cpp @@ -44,6 +44,10 @@ #include #include // numeric_limits +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const double vpAdaptiveGain::DEFAULT_LAMBDA_ZERO = 1.666; const double vpAdaptiveGain::DEFAULT_LAMBDA_INFINITY = 0.1666; const double vpAdaptiveGain::DEFAULT_LAMBDA_SLOPE = 1.666; @@ -138,7 +142,11 @@ double vpAdaptiveGain::operator()(void) const { return this->limitValue(); } double vpAdaptiveGain::operator()(const vpColVector &x) const { return this->value(x.infinityNorm()); } -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpAdaptiveGain &lambda) +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpAdaptiveGain &lambda) { os << "Zero= " << lambda.coeff_a + lambda.coeff_c << "\tInf= " << lambda.coeff_c << "\tSlope= " << lambda.coeff_a * lambda.coeff_b; diff --git a/modules/vs/src/vpServo.cpp b/modules/vs/src/vpServo.cpp index ddd180e656..595f196ceb 100644 --- a/modules/vs/src/vpServo.cpp +++ b/modules/vs/src/vpServo.cpp @@ -31,17 +31,22 @@ * Visual servoing control law. */ -#include - -#include -#include -#include /*! \file vpServo.cpp \brief Class required to compute the visual servoing control law */ +#include + +#include +#include +#include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpServo::vpServo() : L(), error(), J1(), J1p(), s(), sStar(), e1(), e(), q_dot(), v(), servoType(vpServo::NONE), rankJ1(0), featureList(), desiredFeatureList(), featureSelectionList(), lambda(), signInteractionMatrix(1), @@ -800,7 +805,7 @@ vpColVector vpServo::computeControlLaw() J1p.print(std::cout, 10, "J1p"); #endif e1 = WpW * J1p * error; - } + } e = -lambda(e1) * e1; I.eye(J1.getCols()); @@ -810,7 +815,7 @@ vpColVector vpServo::computeControlLaw() m_first_iteration = false; return e; -} + } vpColVector vpServo::computeControlLaw(double t) { @@ -909,10 +914,10 @@ vpColVector vpServo::computeControlLaw(double t) std::cout << "J1p" << std::endl << J1p; #endif e1 = WpW * J1p * error; - } + } - // memorize the initial e1 value if the function is called the first time - // or if the time given as parameter is equal to 0. + // memorize the initial e1 value if the function is called the first time + // or if the time given as parameter is equal to 0. if (m_first_iteration || std::fabs(t) < std::numeric_limits::epsilon()) { e1_initial = e1; } @@ -930,7 +935,7 @@ vpColVector vpServo::computeControlLaw(double t) m_first_iteration = false; return e; -} + } vpColVector vpServo::computeControlLaw(double t, const vpColVector &e_dot_init) { @@ -1029,10 +1034,10 @@ vpColVector vpServo::computeControlLaw(double t, const vpColVector &e_dot_init) std::cout << "J1p" << std::endl << J1p; #endif e1 = WpW * J1p * error; - } + } - // memorize the initial e1 value if the function is called the first time - // or if the time given as parameter is equal to 0. + // memorize the initial e1 value if the function is called the first time + // or if the time given as parameter is equal to 0. if (m_first_iteration || std::fabs(t) < std::numeric_limits::epsilon()) { e1_initial = e1; } @@ -1050,7 +1055,7 @@ vpColVector vpServo::computeControlLaw(double t, const vpColVector &e_dot_init) m_first_iteration = false; return e; -} + } void vpServo::computeProjectionOperators(const vpMatrix &J1_, const vpMatrix &I_, const vpMatrix &I_WpW_, const vpColVector &error_, vpMatrix &P_) const @@ -1104,8 +1109,8 @@ vpColVector vpServo::secondaryTask(const vpColVector &de2dt, const bool &useLarg #endif // std::cout << "I-WpW" << std::endl << I_WpW < #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpServoData::open(const std::string &directory) { try { @@ -108,3 +112,6 @@ void vpServoData::close() sStarFile.close(); } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/vs/src/vpServoDisplay.cpp b/modules/vs/src/vpServoDisplay.cpp index 137f8f6244..c8c2a0b4d1 100644 --- a/modules/vs/src/vpServoDisplay.cpp +++ b/modules/vs/src/vpServoDisplay.cpp @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpServoDisplay::display(const vpServo &s, const vpCameraParameters &cam, const vpImage &I, vpColor currentColor, vpColor desiredColor, unsigned int thickness) { @@ -86,3 +90,6 @@ void vpServoDisplay::display(const vpServo &s, const vpCameraParameters &cam, co } } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/vs/test/visual-feature/testFeature.cpp b/modules/vs/test/visual-feature/testFeature.cpp index 590ac33396..f355cdff11 100644 --- a/modules/vs/test/visual-feature/testFeature.cpp +++ b/modules/vs/test/visual-feature/testFeature.cpp @@ -57,6 +57,9 @@ */ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { for (int i = 0; i < 3; i++) { vpServo task; @@ -85,7 +88,8 @@ int main() std::cout << "End, call vpServo destructors..." << std::endl; } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/vs/test/visual-feature/testFeatureMoment.cpp b/modules/vs/test/visual-feature/testFeatureMoment.cpp index 8999e3fa25..2260abe132 100644 --- a/modules/vs/test/visual-feature/testFeatureMoment.cpp +++ b/modules/vs/test/visual-feature/testFeatureMoment.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // initialize scene in the interface void initScene(const vpHomogeneousMatrix &cMo, const vpHomogeneousMatrix &cdMo, vpMomentObject &src, vpMomentObject &dst); diff --git a/modules/vs/test/visual-feature/testFeatureSegment.cpp b/modules/vs/test/visual-feature/testFeatureSegment.cpp index b5b260547c..820a0db26f 100644 --- a/modules/vs/test/visual-feature/testFeatureSegment.cpp +++ b/modules/vs/test/visual-feature/testFeatureSegment.cpp @@ -67,6 +67,9 @@ */ int main(int argc, const char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) int opt_no_display = 0; @@ -75,7 +78,7 @@ int main(int argc, const char **argv) int opt_normalized = 1; // Parse the command line to set the variables - vpParseArgv::vpArgvInfo argTable [] = { + vpParseArgv::vpArgvInfo argTable[] = { #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) {"-d", vpParseArgv::ARGV_CONSTANT_INT, 0, (char *)&opt_no_display, "Disable display and graphics viewer."}, #endif From d3b2501cc4d930e8b50a716205655b23e02e11d2 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Thu, 23 May 2024 13:58:12 +0200 Subject: [PATCH 15/64] [WIP] visp_ar compiles --- modules/ar/include/visp3/ar/vpAR.h | 10 ++- modules/ar/include/visp3/ar/vpAROgre.h | 14 +++- modules/ar/include/visp3/ar/vpSimulator.h | 8 +- .../include/visp3/ar/vpSimulatorException.h | 15 +++- modules/ar/include/visp3/ar/vpViewer.h | 13 +++- modules/ar/src/coin-simulator/vpAR.cpp | 10 ++- modules/ar/src/coin-simulator/vpSimulator.cpp | 8 +- modules/ar/src/coin-simulator/vpViewer.cpp | 12 ++- modules/ar/src/ogre-simulator/vpAROgre.cpp | 73 +++++++++++-------- modules/ar/src/vpSimulatorException.cpp | 11 ++- 10 files changed, 122 insertions(+), 52 deletions(-) diff --git a/modules/ar/include/visp3/ar/vpAR.h b/modules/ar/include/visp3/ar/vpAR.h index aa60da66bf..4b2c9bbc9b 100644 --- a/modules/ar/include/visp3/ar/vpAR.h +++ b/modules/ar/include/visp3/ar/vpAR.h @@ -64,6 +64,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpAR @@ -143,13 +147,15 @@ class VISP_EXPORT vpAR : public vpSimulator bool background; public: - vpAR() : background(false){}; + vpAR() : background(false) { }; virtual ~vpAR(); void initInternalViewer(unsigned int width, unsigned int height, vpImageType type = grayImage); void setImage(vpImage &I); void setImage(vpImage &I); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/ar/include/visp3/ar/vpAROgre.h b/modules/ar/include/visp3/ar/vpAROgre.h index 038db61e0d..702ddb1803 100644 --- a/modules/ar/include/visp3/ar/vpAROgre.h +++ b/modules/ar/include/visp3/ar/vpAROgre.h @@ -70,6 +70,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpAROgre @@ -88,10 +92,10 @@ */ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, - public Ogre::WindowEventListener + public Ogre::WindowEventListener #ifdef VISP_HAVE_OIS , - public OIS::KeyListener + public OIS::KeyListener #endif { public: @@ -296,7 +300,7 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, * Build the 3D scene * Override this to show what you want */ - virtual void createScene(void){}; + virtual void createScene(void) { }; virtual void closeOIS(void); @@ -391,7 +395,9 @@ class VISP_EXPORT vpAROgre : public Ogre::FrameListener, std::list mOptionalResourceLocation; /** Optional resource location (used to load mesh and material) */ }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // VISP_HAVE_OGRE #endif diff --git a/modules/ar/include/visp3/ar/vpSimulator.h b/modules/ar/include/visp3/ar/vpSimulator.h index 512ad4e019..5cbfc4f737 100644 --- a/modules/ar/include/visp3/ar/vpSimulator.h +++ b/modules/ar/include/visp3/ar/vpSimulator.h @@ -82,6 +82,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpSimulator @@ -291,6 +295,8 @@ class VISP_EXPORT vpSimulator //! get the intrinsic parameters of the camera void getCameraParameters(vpCameraParameters &cam) { cam = internalCameraParameters; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/ar/include/visp3/ar/vpSimulatorException.h b/modules/ar/include/visp3/ar/vpSimulatorException.h index e5a75bffe8..a0a3e74c25 100644 --- a/modules/ar/include/visp3/ar/vpSimulatorException.h +++ b/modules/ar/include/visp3/ar/vpSimulatorException.h @@ -31,20 +31,25 @@ * Exceptions that can be emitted by the simulator classes. */ -#ifndef _vpSimulatorException_h_ -#define _vpSimulatorException_h_ - /*! * \file vpSimulatorException.h * \brief Error that can be emitted by the vpSimulator class and its derivatives */ +#ifndef _vpSimulatorException_h_ +#define _vpSimulatorException_h_ + +#include #include #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS #include /* Classe std::ostream. */ #include /* Classe string. */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpSimulatorException * \brief Error that can be emitted by the vpSimulator class and its derivatives. @@ -81,6 +86,8 @@ class VISP_EXPORT vpSimulatorException : public vpException */ explicit vpSimulatorException(int id); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/ar/include/visp3/ar/vpViewer.h b/modules/ar/include/visp3/ar/vpViewer.h index 35c8d45b02..5a003b2130 100644 --- a/modules/ar/include/visp3/ar/vpViewer.h +++ b/modules/ar/include/visp3/ar/vpViewer.h @@ -33,8 +33,6 @@ * *****************************************************************************/ -#ifndef vpViewer_HH -#define vpViewer_HH /*! \file vpViewer.h @@ -47,6 +45,9 @@ */ +#ifndef vpViewer_HH +#define vpViewer_HH + #include #ifdef VISP_HAVE_COIN3D_AND_GUI @@ -94,6 +95,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpViewer \ingroup group_ar_simulator @@ -153,7 +158,9 @@ class VISP_EXPORT vpViewer : public SoXtExaminerViewer static void exitMainLoop() { SoXt::exitMainLoop(); }; #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // VISP_HAVE_COIN3D_AND_GUI #endif diff --git a/modules/ar/src/coin-simulator/vpAR.cpp b/modules/ar/src/coin-simulator/vpAR.cpp index 42c8dc35fc..5436e852a4 100644 --- a/modules/ar/src/coin-simulator/vpAR.cpp +++ b/modules/ar/src/coin-simulator/vpAR.cpp @@ -64,6 +64,10 @@ #include /* Groupement de noeuds (sans separation)*/ #include /* Matiere (couleur) des objets. */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic Destructor that calls the kill() method of the vpSimulator class. @@ -148,8 +152,10 @@ void vpAR::setImage(vpImage &I) } } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpAR.cpp.o) has no symbols -void dummy_vpAR(){}; +void dummy_vpAR() { }; #endif diff --git a/modules/ar/src/coin-simulator/vpSimulator.cpp b/modules/ar/src/coin-simulator/vpSimulator.cpp index 8d154d9931..841e694613 100644 --- a/modules/ar/src/coin-simulator/vpSimulator.cpp +++ b/modules/ar/src/coin-simulator/vpSimulator.cpp @@ -71,6 +71,10 @@ #include /* Groupement de noeuds (sans separation)*/ #include /* Matiere (couleur) des objets. */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif // Positions of all of the vertices: // static float pyramidVertexes[5][3] = { {0.33f, 0.33f, 0.f}, @@ -1002,7 +1006,9 @@ void vpSimulator::getInternalImage(vpImage &I) vpImageConvert::RGBToGrey(bufferView, I.bitmap, internal_width, internal_height, true); get = 1; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpSimulator.cpp.o) has no symbols void dummy_vpSimulator() { }; diff --git a/modules/ar/src/coin-simulator/vpViewer.cpp b/modules/ar/src/coin-simulator/vpViewer.cpp index 084f4836bd..d67d4a69a1 100644 --- a/modules/ar/src/coin-simulator/vpViewer.cpp +++ b/modules/ar/src/coin-simulator/vpViewer.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #if defined(VISP_HAVE_SOWIN) vpViewer::vpViewer(HWND parent, vpSimulator *_simu, vpViewerType type) : SoWinExaminerViewer(parent, (char *)nullptr, false), viewerType(type), simu(_simu) @@ -67,7 +71,7 @@ vpViewer::vpViewer(Widget parent, vpSimulator *_simu, vpViewerType type) setAutoRedraw(false); } -vpViewer::~vpViewer() {} +vpViewer::~vpViewer() { } void vpViewer::actualRedraw(void) { @@ -231,8 +235,10 @@ SbBool vpViewer::processSoEvent(const SoEvent *const event) return SoXtExaminerViewer::processSoEvent(event); #endif } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpViewer.cpp.o) has no symbols -void dummy_vpViewer(){}; +void dummy_vpViewer() { }; #endif diff --git a/modules/ar/src/ogre-simulator/vpAROgre.cpp b/modules/ar/src/ogre-simulator/vpAROgre.cpp index aa4dcf39b5..724039f0e8 100644 --- a/modules/ar/src/ogre-simulator/vpAROgre.cpp +++ b/modules/ar/src/ogre-simulator/vpAROgre.cpp @@ -55,6 +55,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Constructor. @@ -73,16 +77,15 @@ vpAROgre::vpAROgre(const vpCameraParameters &cam, unsigned int width, unsigned int height, const char *resourcePath, const char *pluginsPath) : name("ViSP - Augmented Reality"), mRoot(0), mCamera(0), mSceneMgr(0), mWindow(0), mResourcePath(resourcePath), - mPluginsPath(pluginsPath), + mPluginsPath(pluginsPath), #ifdef VISP_HAVE_OIS - mInputManager(0), mKeyboard(0), + mInputManager(0), mKeyboard(0), #endif - keepOn(true), // When created no reason to stop displaying - mImageRGBA(), mImage(), mPixelBuffer(), mBackground(nullptr), mBackgroundHeight(0), mBackgroundWidth(0), - mWindowHeight(height), mWindowWidth(width), windowHidden(false), mNearClipping(0.001), mFarClipping(200), mcam(cam), - mshowConfigDialog(true), mOptionalResourceLocation() -{ -} + keepOn(true), // When created no reason to stop displaying + mImageRGBA(), mImage(), mPixelBuffer(), mBackground(nullptr), mBackgroundHeight(0), mBackgroundWidth(0), + mWindowHeight(height), mWindowWidth(width), windowHidden(false), mNearClipping(0.001), mFarClipping(200), mcam(cam), + mshowConfigDialog(true), mOptionalResourceLocation() +{ } /*! Initialisation of Ogre with a grey level background. @@ -235,11 +238,11 @@ void vpAROgre::init(bool if (!pluginsFileExists) { std::string errorMsg = std::string("Error: the requested plugins file \"") #if defined(NDEBUG) || !defined(_WIN32) - + std::string("plugins.cfg") + +std::string("plugins.cfg") #else - + std::string("plugins_d.cfg") + + std::string("plugins_d.cfg") #endif - + std::string("\" doesn't exist in ") + std::string(mPluginsPath); + + std::string("\" doesn't exist in ") + std::string(mPluginsPath); std::cout << errorMsg << std::endl; throw(vpException(vpException::ioError, errorMsg)); @@ -248,7 +251,8 @@ void vpAROgre::init(bool if (Ogre::Root::getSingletonPtr() == nullptr) { mRoot = new Ogre::Root(pluginFile, "ogre.cfg", "Ogre.log"); - } else { + } + else { mRoot = Ogre::Root::getSingletonPtr(); } @@ -276,7 +280,7 @@ void vpAROgre::init(bool } if (!resourcesFileExists) { std::string errorMsg = std::string("Error: the requested resource file \"resources.cfg\"") + - std::string("doesn't exist in ") + std::string(mResourcePath); + std::string("doesn't exist in ") + std::string(mResourcePath); std::cout << errorMsg << std::endl; @@ -315,7 +319,8 @@ void vpAROgre::init(bool if (!mRoot->showConfigDialog()) { canInit = false; } - } else { + } + else { if (!mRoot->restoreConfig()) { canInit = false; } @@ -353,15 +358,18 @@ void vpAROgre::init(bool if (ss.fail()) { std::cout << "Cannot read Ogre video mode" << std::endl; } - } else if (mWindowWidth == 0 && mWindowHeight == 0) { + } + else if (mWindowWidth == 0 && mWindowHeight == 0) { mWindowWidth = mBackgroundWidth; mWindowHeight = mBackgroundHeight; } - } else if (leftconf == "Full Screen") { + } + else if (leftconf == "Full Screen") { if (canInit && (rightconf == "Yes")) { fullscreen = true; } - } else { + } + else { misc[leftconf] = rightconf; } @@ -485,7 +493,8 @@ bool vpAROgre::stopTest(const Ogre::FrameEvent &evt) // Always keep this part if (keepOn) { return updateScene(evt); - } else { + } + else { return keepOn; } } @@ -625,7 +634,8 @@ void vpAROgre::display(const vpImage &I, const vpHomogeneousMatri if (renderOneFrame(I, cMw)) { mWindow->update(); keepOn = true; - } else + } + else keepOn = false; } @@ -640,7 +650,8 @@ void vpAROgre::display(const vpImage &I, const vpHomogeneousMatrix &cMw) if (renderOneFrame(I, cMw)) { mWindow->update(); keepOn = true; - } else + } + else keepOn = false; } @@ -801,7 +812,8 @@ void vpAROgre::createBackground(vpImage & /* I */) mBackgroundHeight, // height 0, // num of mip maps Ogre::PF_BYTE_L, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); - } else { + } + else { Ogre::TextureManager::getSingleton().createManual( "BackgroundTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mBackgroundWidth, // width @@ -870,8 +882,9 @@ void vpAROgre::createBackground(vpImage & /* I */) 0, // num of mip maps // Ogre::PF_BYTE_RGBA, Ogre::PF_BYTE_BGRA, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); - } else { // As that texture does not seem to work properly with direct3D we - // use a default texture + } + else { // As that texture does not seem to work properly with direct3D we + // use a default texture Ogre::TextureManager::getSingleton().createManual( "BackgroundTexture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mBackgroundWidth, // width @@ -1025,10 +1038,10 @@ void vpAROgre::updateCameraParameters(const vpHomogeneousMatrix &cMw) Ogre::Matrix4 ModelView // = Ogre::Matrix4( (Ogre::Real)-cMo[0][0], (Ogre::Real)-cMo[0][1], // (Ogre::Real)-cMo[0][2], (Ogre::Real)-cMo[0][3], - = Ogre::Matrix4((Ogre::Real)cMw[0][0], (Ogre::Real)cMw[0][1], (Ogre::Real)cMw[0][2], (Ogre::Real)cMw[0][3], - (Ogre::Real)-cMw[1][0], (Ogre::Real)-cMw[1][1], (Ogre::Real)-cMw[1][2], (Ogre::Real)-cMw[1][3], - (Ogre::Real)-cMw[2][0], (Ogre::Real)-cMw[2][1], (Ogre::Real)-cMw[2][2], (Ogre::Real)-cMw[2][3], - (Ogre::Real)0, (Ogre::Real)0, (Ogre::Real)0, (Ogre::Real)1); + = Ogre::Matrix4((Ogre::Real)cMw[0][0], (Ogre::Real)cMw[0][1], (Ogre::Real)cMw[0][2], (Ogre::Real)cMw[0][3], + (Ogre::Real)-cMw[1][0], (Ogre::Real)-cMw[1][1], (Ogre::Real)-cMw[1][2], (Ogre::Real)-cMw[1][3], + (Ogre::Real)-cMw[2][0], (Ogre::Real)-cMw[2][1], (Ogre::Real)-cMw[2][2], (Ogre::Real)-cMw[2][3], + (Ogre::Real)0, (Ogre::Real)0, (Ogre::Real)0, (Ogre::Real)1); mCamera->setCustomViewMatrix(true, ModelView); } @@ -1075,8 +1088,10 @@ void vpAROgre::getRenderingOutput(vpImage &I, const vpHomogeneousMatrix // Unlock the pixel buffer mPixelBuffer->unlock(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpAROgre.cpp.o) has no symbols -void dummy_vpAROgre(){}; +void dummy_vpAROgre() { }; #endif diff --git a/modules/ar/src/vpSimulatorException.cpp b/modules/ar/src/vpSimulatorException.cpp index 565a6cc6d0..c09344ec51 100644 --- a/modules/ar/src/vpSimulatorException.cpp +++ b/modules/ar/src/vpSimulatorException.cpp @@ -41,7 +41,10 @@ #include #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpSimulatorException::vpSimulatorException(int id, const char *format, ...) { this->code = id; @@ -54,9 +57,11 @@ vpSimulatorException::vpSimulatorException(int id, const char *format, ...) vpSimulatorException::vpSimulatorException(int id, const std::string &msg) : vpException(id, msg) { ; } vpSimulatorException::vpSimulatorException(int id) : vpException(id) { ; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_ar.a(vpSimulatorException.cpp.o) has no symbols -void dummy_vpSimulatorException(){}; +void dummy_vpSimulatorException() { }; #endif From b0563c2c2291005d894e01ad9eca24826ed9b61a Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 09:10:23 +0200 Subject: [PATCH 16/64] [CORE] Moved back the operators in the visp workspace (see https://stackoverflow.com/questions/171862/namespaces-and-operator-overloading-in-c) --- modules/core/include/visp3/core/vpArray2D.h | 141 ++++++++---------- .../include/visp3/core/vpCameraParameters.h | 5 +- modules/core/include/visp3/core/vpColVector.h | 10 +- modules/core/include/visp3/core/vpColor.h | 17 +-- modules/core/include/visp3/core/vpException.h | 13 +- .../core/include/visp3/core/vpHistogramPeak.h | 13 +- .../include/visp3/core/vpHistogramValey.h | 13 +- modules/core/include/visp3/core/vpImage.h | 44 +++--- .../core/include/visp3/core/vpImagePoint.h | 52 ++----- modules/core/include/visp3/core/vpMatrix.h | 9 +- modules/core/include/visp3/core/vpMoment.h | 13 +- .../core/include/visp3/core/vpMomentAlpha.h | 13 +- .../core/include/visp3/core/vpMomentArea.h | 13 +- .../visp3/core/vpMomentAreaNormalized.h | 13 +- .../core/include/visp3/core/vpMomentBasic.h | 13 +- .../include/visp3/core/vpMomentCInvariant.h | 13 +- .../include/visp3/core/vpMomentCentered.h | 13 +- .../include/visp3/core/vpMomentDatabase.h | 13 +- .../visp3/core/vpMomentGravityCenter.h | 12 +- .../core/vpMomentGravityCenterNormalized.h | 13 +- .../core/include/visp3/core/vpMomentObject.h | 13 +- modules/core/include/visp3/core/vpPlane.h | 13 +- modules/core/include/visp3/core/vpPoint.h | 13 +- modules/core/include/visp3/core/vpRGBa.h | 15 +- modules/core/include/visp3/core/vpRGBf.h | 16 +- modules/core/include/visp3/core/vpRect.h | 16 +- .../include/visp3/core/vpRotationMatrix.h | 9 +- .../include/visp3/core/vpRotationVector.h | 9 +- modules/core/include/visp3/core/vpRowVector.h | 3 +- .../core/src/camera/vpCameraParameters.cpp | 16 +- modules/core/src/display/vpColor.cpp | 12 +- modules/core/src/image/vpImagePoint.cpp | 138 ++++++++--------- modules/core/src/image/vpRGBa.cpp | 10 +- modules/core/src/image/vpRGBf.cpp | 10 +- modules/core/src/math/matrix/vpColVector.cpp | 14 +- modules/core/src/math/matrix/vpMatrix.cpp | 100 ++++++------- modules/core/src/math/matrix/vpRowVector.cpp | 20 +-- .../math/transformation/vpRotationMatrix.cpp | 38 ++--- .../math/transformation/vpRotationVector.cpp | 22 +-- .../core/src/tools/exceptions/vpException.cpp | 8 +- modules/core/src/tools/geometry/vpPlane.cpp | 9 +- modules/core/src/tools/geometry/vpRect.cpp | 10 +- .../src/tools/histogram/vpHistogramPeak.cpp | 8 +- .../src/tools/histogram/vpHistogramValey.cpp | 9 +- .../tracking/forward-projection/vpPoint.cpp | 4 +- .../core/src/tracking/moments/vpMoment.cpp | 10 +- .../src/tracking/moments/vpMomentAlpha.cpp | 10 +- .../src/tracking/moments/vpMomentArea.cpp | 9 +- .../moments/vpMomentAreaNormalized.cpp | 9 +- .../src/tracking/moments/vpMomentBasic.cpp | 11 +- .../tracking/moments/vpMomentCInvariant.cpp | 8 +- .../src/tracking/moments/vpMomentCentered.cpp | 8 +- .../src/tracking/moments/vpMomentDatabase.cpp | 8 +- .../moments/vpMomentGravityCenter.cpp | 8 +- .../vpMomentGravityCenterNormalized.cpp | 8 +- .../src/tracking/moments/vpMomentObject.cpp | 8 +- .../include/visp3/imgproc/vpContours.h | 2 +- .../imgproc/include/visp3/imgproc/vpImgproc.h | 2 +- modules/imgproc/src/vpCLAHE.cpp | 2 +- modules/imgproc/src/vpConnectedComponents.cpp | 2 +- modules/imgproc/src/vpContours.cpp | 2 +- modules/imgproc/src/vpFloodFill.cpp | 2 +- modules/imgproc/src/vpMorph.cpp | 2 +- modules/imgproc/src/vpRetinex.cpp | 2 +- modules/imgproc/src/vpThreshold.cpp | 2 +- .../test/with-dataset/testAutoThreshold.cpp | 38 +++-- .../with-dataset/testConnectedComponents.cpp | 39 +++-- .../test/with-dataset/testContours.cpp | 48 +++--- .../test/with-dataset/testFloodFill.cpp | 66 ++++---- .../imgproc/test/with-dataset/testImgproc.cpp | 16 +- .../tracker/blob/include/visp3/blob/vpDot.h | 14 +- .../tracker/blob/include/visp3/blob/vpDot2.h | 14 +- modules/tracker/blob/src/dots/vpDot.cpp | 10 +- modules/tracker/blob/src/dots/vpDot2.cpp | 8 +- .../tracker/me/include/visp3/me/vpMeSite.h | 14 +- .../tracker/me/src/moving-edges/vpMeSite.cpp | 10 +- .../visp3/visual_features/vpFeatureMoment.h | 13 +- .../vpFeatureMomentCInvariant.h | 24 +-- .../visual_features/vpFeatureMomentCentered.h | 13 +- .../src/visual-feature/vpFeatureMoment.cpp | 12 +- .../vpFeatureMomentCInvariant.cpp | 8 +- .../vpFeatureMomentCentered.cpp | 11 +- modules/vs/include/visp3/vs/vpAdaptiveGain.h | 13 +- modules/vs/src/vpAdaptiveGain.cpp | 10 +- 84 files changed, 563 insertions(+), 914 deletions(-) diff --git a/modules/core/include/visp3/core/vpArray2D.h b/modules/core/include/visp3/core/vpArray2D.h index bf91691201..203d5c7700 100644 --- a/modules/core/include/visp3/core/vpArray2D.h +++ b/modules/core/include/visp3/core/vpArray2D.h @@ -55,9 +55,6 @@ template class vpArray2D; } #endif -template -std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpArray2D &A); - #ifdef VISP_HAVE_NLOHMANN_JSON #include //template @@ -623,7 +620,30 @@ template class vpArray2D Writes the given array to the output stream and returns a reference to the output stream. */ - friend std::ostream &::operator<< <>(std::ostream &s, const vpArray2D &A); + friend std::ostream &operator<<(std::ostream &s, const vpArray2D &A) + { + if (A.data == nullptr || A.size() == 0) { + return s; + } + std::ios_base::fmtflags original_flags = s.flags(); + + s.precision(10); + for (unsigned int i = 0; i < A.getRows(); i++) { + for (unsigned int j = 0; j < A.getCols() - 1; j++) { + s << A[i][j] << " "; + } + // We don't add " " after the last row element + s << A[i][A.getCols() - 1]; + // We don't add a \n char on the end of the last array line + if (i < A.getRows() - 1) { + s << std::endl; + } + } + + s.flags(original_flags); // restore s to standard state + + return s; + } vpArray2D hadamard(const vpArray2D &m) const; @@ -910,48 +930,49 @@ template class vpArray2D file.close(); return true; } - /*! - Save an array in a YAML-formatted file. - - \param filename : absolute file name. - \param A : array to be saved in the file. - \param header : optional lines that will be saved at the beginning of the - file. Should be YAML-formatted and will adapt to the indentation if any. - \return Returns true if success. - - Here is an example of outputs. - \code - vpArray2D M(3,4); - vpArray2D::saveYAML("matrix.yml", M, "example: a YAML-formatted header"); - vpArray2D::saveYAML("matrixIndent.yml", M, "example:\n - a YAML-formatted \ - header\n - with inner indentation"); - \endcode - Content of matrix.yml: - \code - example: a YAML-formatted header - rows: 3 - cols: 4 - data: - - [0, 0, 0, 0] - - [0, 0, 0, 0] - - [0, 0, 0, 0] - \endcode - Content of matrixIndent.yml: - \code - example: - - a YAML-formatted header - - with inner indentation - rows: 3 - cols: 4 - data: + /*! + Save an array in a YAML-formatted file. + + \param filename : absolute file name. + \param A : array to be saved in the file. + \param header : optional lines that will be saved at the beginning of the + file. Should be YAML-formatted and will adapt to the indentation if any. + + \return Returns true if success. + + Here is an example of outputs. + \code + vpArray2D M(3,4); + vpArray2D::saveYAML("matrix.yml", M, "example: a YAML-formatted header"); + vpArray2D::saveYAML("matrixIndent.yml", M, "example:\n - a YAML-formatted \ + header\n - with inner indentation"); + \endcode + Content of matrix.yml: + \code + example: a YAML-formatted header + rows: 3 + cols: 4 + data: - [0, 0, 0, 0] - [0, 0, 0, 0] - [0, 0, 0, 0] - \endcode - - \sa loadYAML() - */ + \endcode + Content of matrixIndent.yml: + \code + example: + - a YAML-formatted header + - with inner indentation + rows: 3 + cols: 4 + data: + - [0, 0, 0, 0] + - [0, 0, 0, 0] + - [0, 0, 0, 0] + \endcode + + \sa loadYAML() + */ static bool saveYAML(const std::string &filename, const vpArray2D &A, const char *header = "") { std::fstream file; @@ -1079,42 +1100,6 @@ template class vpArray2D static void insert(const vpArray2D &A, const vpArray2D &B, vpArray2D &C, unsigned int r, unsigned int c); //@} }; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -template -std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpArray2D &A) -{ - if ((A.data == nullptr) || (A.size() == 0)) { - return s; - } - std::ios_base::fmtflags original_flags = s.flags(); - - s.precision(10); - unsigned int a_rows = A.getRows(); - unsigned int a_cols = A.getCols(); - for (unsigned int i = 0; i < a_rows; ++i) { - for (unsigned int j = 0; j < (a_cols - 1); ++j) { - s << A[i][j] << " "; - } - // We don't add " " after the last row element - s << A[i][a_cols - 1]; - // We don't add a \n char on the end of the last array line - if (i < (a_rows - 1)) { - s << std::endl; - } - } - - s.flags(original_flags); // restore s to standard state - - return s; -} - -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! Return the array min value. diff --git a/modules/core/include/visp3/core/vpCameraParameters.h b/modules/core/include/visp3/core/vpCameraParameters.h index dbcecd0eec..0dbb6969f2 100644 --- a/modules/core/include/visp3/core/vpCameraParameters.h +++ b/modules/core/include/visp3/core/vpCameraParameters.h @@ -59,9 +59,6 @@ class vpCameraParameters; } #endif -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam); - #ifdef VISP_HAVE_NLOHMANN_JSON #include // Forward declaration to have the to_json in the global namespace @@ -438,7 +435,7 @@ class VISP_EXPORT vpMatrix get_K_inverse() const; void printParameters(); - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpCameraParameters &cam); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam); private: static const double DEFAULT_U0_PARAMETER; diff --git a/modules/core/include/visp3/core/vpColVector.h b/modules/core/include/visp3/core/vpColVector.h index ad78bfb146..3581b915aa 100644 --- a/modules/core/include/visp3/core/vpColVector.h +++ b/modules/core/include/visp3/core/vpColVector.h @@ -1481,6 +1481,10 @@ vpColVector: public vpArray2D namespace VISP_NAMESPACE_NAME { #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + /*! * \relates vpColVector * Allows to multiply a scalar by a column vector. @@ -1488,10 +1492,8 @@ namespace VISP_NAMESPACE_NAME #ifndef DOXYGEN_SHOULD_SKIP_THIS VISP_EXPORT #endif -vpColVector operator*(const double &x, const vpColVector &v); -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif +VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpColVector &v); + #ifdef VISP_HAVE_NLOHMANN_JSON inline void to_json(nlohmann::json &j, diff --git a/modules/core/include/visp3/core/vpColor.h b/modules/core/include/visp3/core/vpColor.h index 1bb97a68ab..62ac5bed40 100644 --- a/modules/core/include/visp3/core/vpColor.h +++ b/modules/core/include/visp3/core/vpColor.h @@ -37,19 +37,6 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif -class vpColor; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -// Forward declaration to ensure that the operators are in the global namespace -bool operator==(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2); -bool operator!=(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2); - #if defined(ENABLE_VISP_NAMESPACE) namespace VISP_NAMESPACE_NAME { @@ -291,8 +278,8 @@ class VISP_EXPORT vpColor : public vpRGBa /*! Default destructor. */ inline virtual ~vpColor() { } - friend VISP_EXPORT bool ::operator==(const vpColor &c1, const vpColor &c2); - friend VISP_EXPORT bool ::operator!=(const vpColor &c1, const vpColor &c2); + friend VISP_EXPORT bool operator==(const vpColor &c1, const vpColor &c2); + friend VISP_EXPORT bool operator!=(const vpColor &c1, const vpColor &c2); /*! Set a color from its RGB values. diff --git a/modules/core/include/visp3/core/vpException.h b/modules/core/include/visp3/core/vpException.h index 76b68875ae..c210cc5588 100644 --- a/modules/core/include/visp3/core/vpException.h +++ b/modules/core/include/visp3/core/vpException.h @@ -45,17 +45,6 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif -class vpException; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -// Forward declaration to ensure that the operator is in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpException &art); #if defined(ENABLE_VISP_NAMESPACE) namespace VISP_NAMESPACE_NAME { @@ -144,7 +133,7 @@ class VISP_EXPORT vpException : public std::exception /*! * Print the error structure. */ - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpException &art); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpException &art); protected: //! Contains the error code, see the errorCodeEnum table for details. diff --git a/modules/core/include/visp3/core/vpHistogramPeak.h b/modules/core/include/visp3/core/vpHistogramPeak.h index 9985322224..3f9a438fcf 100644 --- a/modules/core/include/visp3/core/vpHistogramPeak.h +++ b/modules/core/include/visp3/core/vpHistogramPeak.h @@ -44,17 +44,6 @@ #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif -class vpHistogramPeak; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramPeak &p); - #if defined(ENABLE_VISP_NAMESPACE) namespace VISP_NAMESPACE_NAME { @@ -148,7 +137,7 @@ class VISP_EXPORT vpHistogramPeak //--------------------------------- // Printing //--------------------------------- - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &s, const vpHistogramPeak &p); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramPeak &p); protected: unsigned char level; //! Gray level ot the peak. diff --git a/modules/core/include/visp3/core/vpHistogramValey.h b/modules/core/include/visp3/core/vpHistogramValey.h index c04bc4128c..fbb12375a7 100644 --- a/modules/core/include/visp3/core/vpHistogramValey.h +++ b/modules/core/include/visp3/core/vpHistogramValey.h @@ -43,17 +43,6 @@ #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif -class vpHistogramValey; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramValey &v); - #if defined(ENABLE_VISP_NAMESPACE) namespace VISP_NAMESPACE_NAME { @@ -146,7 +135,7 @@ class VISP_EXPORT vpHistogramValey : vpHistogramPeak //--------------------------------- // Printing //--------------------------------- - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &s, const vpHistogramValey &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramValey &v); }; /* diff --git a/modules/core/include/visp3/core/vpImage.h b/modules/core/include/visp3/core/vpImage.h index 3055ce4a7f..80bd561b2c 100644 --- a/modules/core/include/visp3/core/vpImage.h +++ b/modules/core/include/visp3/core/vpImage.h @@ -73,16 +73,17 @@ namespace VISP_NAMESPACE_NAME class vpDisplay; // Ref: http://en.cppreference.com/w/cpp/language/friend#Template_friends template class vpImage; // forward declare to make function declaration possible + +// declarations +template std::ostream &operator<<(std::ostream &, const vpImage &); + +std::ostream &operator<<(std::ostream &, const vpImage &); +std::ostream &operator<<(std::ostream &, const vpImage &); +std::ostream &operator<<(std::ostream &, const vpImage &); +std::ostream &operator<<(std::ostream &, const vpImage &); #if defined(ENABLE_VISP_NAMESPACE) } #endif -// declarations -template std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); - -std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); -std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); -std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); -std::ostream &operator<<(std::ostream &, const VISP_NAMESPACE_ADDRESSING vpImage &); template void swap(VISP_NAMESPACE_ADDRESSING vpImage &first, VISP_NAMESPACE_ADDRESSING vpImage &second); @@ -330,13 +331,13 @@ template class vpImage vpImage &operator=(const Type &v); bool operator==(const vpImage &I) const; bool operator!=(const vpImage &I) const; - friend std::ostream &::operator<< <>(std::ostream &s, const vpImage &I); - friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); - friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); - friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); - friend std::ostream &::operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &operator<< <>(std::ostream &s, const vpImage &I); + friend std::ostream &operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &operator<<(std::ostream &s, const vpImage &I); + friend std::ostream &operator<<(std::ostream &s, const vpImage &I); - // Perform a look-up table transformation + // Perform a look-up table transformation void performLut(const Type(&lut)[256], unsigned int nbThreads = 1); // Returns a new image that's a quarter size of the current image @@ -362,11 +363,8 @@ template class vpImage Type **row; ///! points the row pointer array bool hasOwnership; ///! true if this instance owns the bitmap, false otherwise (e.g. copyData=false) }; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif -template std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) +template std::ostream &operator<<(std::ostream &s, const vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -391,7 +389,7 @@ template std::ostream &operator<<(std::ostream &s, const VISP_NAMES return s; } -inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -419,7 +417,7 @@ inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING return s; } -inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -447,7 +445,7 @@ inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING return s; } -inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -476,7 +474,7 @@ inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING return s; } -inline std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpImage &I) +inline std::ostream &operator<<(std::ostream &s, const vpImage &I) { if (I.bitmap == nullptr) { return s; @@ -634,10 +632,6 @@ void performLutRGBaThread(vpImageLutRGBa_Param_t *imageLut_param) } // namespace #endif -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \relates vpImage */ diff --git a/modules/core/include/visp3/core/vpImagePoint.h b/modules/core/include/visp3/core/vpImagePoint.h index 2c4acdf8eb..7b87e68b85 100644 --- a/modules/core/include/visp3/core/vpImagePoint.h +++ b/modules/core/include/visp3/core/vpImagePoint.h @@ -51,32 +51,8 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpImagePoint; class vpRect; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -// Forward declaration to have the operators in the global namespace when using ViSP namespace -bool operator==(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); -bool operator!=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator+=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator*(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale); -VISP_NAMESPACE_ADDRESSING vpImagePoint operator/(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale); -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip); -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpImagePoint \ingroup group_core_image @@ -388,20 +364,20 @@ class VISP_EXPORT vpImagePoint static vpRect getBBox(const std::vector &ipVec); static double sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP2); - friend VISP_EXPORT bool ::operator==(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT bool ::operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint(::operator+=)(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, int offset); - friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, unsigned int offset); - friend VISP_EXPORT vpImagePoint(::operator+)(const vpImagePoint &ip1, double offset); - friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, const vpImagePoint &ip2); - friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, int offset); - friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, unsigned int offset); - friend VISP_EXPORT vpImagePoint(::operator-)(const vpImagePoint &ip1, double offset); - friend VISP_EXPORT vpImagePoint(::operator*)(const vpImagePoint &ip1, double scale); - friend VISP_EXPORT vpImagePoint(::operator/)(const vpImagePoint &ip1, double scale); - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpImagePoint &ip); + friend VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint operator+=(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, int offset); + friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, unsigned int offset); + friend VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, double offset); + friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, const vpImagePoint &ip2); + friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, int offset); + friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, unsigned int offset); + friend VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, double offset); + friend VISP_EXPORT vpImagePoint operator*(const vpImagePoint &ip1, double scale); + friend VISP_EXPORT vpImagePoint operator/(const vpImagePoint &ip1, double scale); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpImagePoint &ip); private: double i, j; diff --git a/modules/core/include/visp3/core/vpMatrix.h b/modules/core/include/visp3/core/vpMatrix.h index a469965781..14e2719b07 100644 --- a/modules/core/include/visp3/core/vpMatrix.h +++ b/modules/core/include/visp3/core/vpMatrix.h @@ -1209,11 +1209,12 @@ const __declspec(selectany) unsigned int vpMatrix::m_lapack_min_size_default = 0 __declspec(selectany) unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lapack_min_size_default; #endif -#ifndef DOXYGEN_SHOULD_SKIP_THIS -VISP_EXPORT -#endif -vpMatrix operator*(const double &x, const vpMatrix &A); #if defined(ENABLE_VISP_NAMESPACE) } #endif + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +VISP_EXPORT +#endif +VISP_NAMESPACE_ADDRESSING vpMatrix operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpMatrix &A); #endif diff --git a/modules/core/include/visp3/core/vpMoment.h b/modules/core/include/visp3/core/vpMoment.h index 0cffa55a1a..6912504188 100644 --- a/modules/core/include/visp3/core/vpMoment.h +++ b/modules/core/include/visp3/core/vpMoment.h @@ -49,20 +49,9 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMoment; class vpMomentDatabase; class vpMomentObject; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMoment &m); -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMoment * @@ -167,7 +156,7 @@ class VISP_EXPORT vpMoment virtual void printDependencies(std::ostream &os) const; void update(vpMomentObject &object); //@} - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMoment &m); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMoment &m); }; #if defined(ENABLE_VISP_NAMESPACE) } diff --git a/modules/core/include/visp3/core/vpMomentAlpha.h b/modules/core/include/visp3/core/vpMomentAlpha.h index b45e071d53..f7455c452b 100644 --- a/modules/core/include/visp3/core/vpMomentAlpha.h +++ b/modules/core/include/visp3/core/vpMomentAlpha.h @@ -46,18 +46,7 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMomentAlpha; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAlpha &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMomentAlpha * @@ -263,7 +252,7 @@ class VISP_EXPORT vpMomentAlpha : public vpMoment return false; } - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentAlpha &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAlpha &v); void printDependencies(std::ostream &os) const; }; #ifdef ENABLE_VISP_NAMESPACE diff --git a/modules/core/include/visp3/core/vpMomentArea.h b/modules/core/include/visp3/core/vpMomentArea.h index 4a0db73af8..6cc10c437a 100644 --- a/modules/core/include/visp3/core/vpMomentArea.h +++ b/modules/core/include/visp3/core/vpMomentArea.h @@ -40,20 +40,9 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMomentArea; class vpMomentObject; class vpMomentCentered; // Required for discrete case of vpMomentObject -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentArea &m); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMomentArea * @@ -81,7 +70,7 @@ class VISP_EXPORT vpMomentArea : public vpMoment const std::string name() const { return "vpMomentArea"; } void printDependencies(std::ostream &os) const; //@} - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentArea &m); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentArea &m); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/core/include/visp3/core/vpMomentAreaNormalized.h b/modules/core/include/visp3/core/vpMomentAreaNormalized.h index b394d9977e..31c4d97b98 100644 --- a/modules/core/include/visp3/core/vpMomentAreaNormalized.h +++ b/modules/core/include/visp3/core/vpMomentAreaNormalized.h @@ -44,20 +44,9 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMomentAreaNormalized; class vpMomentObject; class vpMomentCentered; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAreaNormalized &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMomentAreaNormalized * @@ -194,7 +183,7 @@ class VISP_EXPORT vpMomentAreaNormalized : public vpMoment * Moment name. */ const std::string name() const { return "vpMomentAreaNormalized"; } - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentAreaNormalized &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAreaNormalized &v); void printDependencies(std::ostream &os) const; }; #ifdef ENABLE_VISP_NAMESPACE diff --git a/modules/core/include/visp3/core/vpMomentBasic.h b/modules/core/include/visp3/core/vpMomentBasic.h index a06bc5259d..c44f4b5790 100644 --- a/modules/core/include/visp3/core/vpMomentBasic.h +++ b/modules/core/include/visp3/core/vpMomentBasic.h @@ -46,18 +46,7 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMomentBasic; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentBasic &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpMomentBasic @@ -95,7 +84,7 @@ class VISP_EXPORT vpMomentBasic : public vpMoment Moment name. */ const std::string name() const { return "vpMomentBasic"; } - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentBasic &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentBasic &v); void printDependencies(std::ostream &os) const; }; #ifdef ENABLE_VISP_NAMESPACE diff --git a/modules/core/include/visp3/core/vpMomentCInvariant.h b/modules/core/include/visp3/core/vpMomentCInvariant.h index a10ee46652..5c490f4a05 100644 --- a/modules/core/include/visp3/core/vpMomentCInvariant.h +++ b/modules/core/include/visp3/core/vpMomentCInvariant.h @@ -49,18 +49,7 @@ namespace VISP_NAMESPACE_NAME #endif class vpMomentCentered; class vpMomentBasic; -class vpMomentCInvariant; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCInvariant &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpMomentCInvariant @@ -292,7 +281,7 @@ class VISP_EXPORT vpMomentCInvariant : public vpMoment */ inline const std::vector &getMomentVector() const { return values; } - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentCInvariant &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCInvariant &v); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/core/include/visp3/core/vpMomentCentered.h b/modules/core/include/visp3/core/vpMomentCentered.h index cf448e1d73..b471d3cd85 100644 --- a/modules/core/include/visp3/core/vpMomentCentered.h +++ b/modules/core/include/visp3/core/vpMomentCentered.h @@ -46,19 +46,8 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMomentCentered; class vpMomentObject; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCentered &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpMomentCentered @@ -101,7 +90,7 @@ class VISP_EXPORT vpMomentCentered : public vpMoment */ inline const std::string name() const { return "vpMomentCentered"; } - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentCentered &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCentered &v); void printWithIndices(std::ostream &os) const; void printDependencies(std::ostream &os) const; diff --git a/modules/core/include/visp3/core/vpMomentDatabase.h b/modules/core/include/visp3/core/vpMomentDatabase.h index 036832509d..43bdc97033 100644 --- a/modules/core/include/visp3/core/vpMomentDatabase.h +++ b/modules/core/include/visp3/core/vpMomentDatabase.h @@ -49,19 +49,8 @@ namespace VISP_NAMESPACE_NAME { #endif class vpMoment; -class vpMomentDatabase; class vpMomentObject; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentDatabase &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMomentDatabase * @@ -171,7 +160,7 @@ class VISP_EXPORT vpMomentDatabase //@} friend class vpMoment; - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentDatabase &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentDatabase &v); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/core/include/visp3/core/vpMomentGravityCenter.h b/modules/core/include/visp3/core/vpMomentGravityCenter.h index 25b5bf46ce..bd26b22a44 100644 --- a/modules/core/include/visp3/core/vpMomentGravityCenter.h +++ b/modules/core/include/visp3/core/vpMomentGravityCenter.h @@ -46,18 +46,8 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMomentGravityCenter; class vpMomentObject; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenter &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMomentGravityCenter * @@ -146,7 +136,7 @@ class VISP_EXPORT vpMomentGravityCenter : public vpMoment const std::string name() const { return "vpMomentGravityCenter"; } void printDependencies(std::ostream &os) const; //@} - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentGravityCenter &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenter &v); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h b/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h index a3884222b8..cf7d78e70d 100644 --- a/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h +++ b/modules/core/include/visp3/core/vpMomentGravityCenterNormalized.h @@ -46,19 +46,8 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMomentGravityCenterNormalized; class vpMomentObject; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenterNormalized &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMomentGravityCenterNormalized * @@ -81,7 +70,7 @@ class VISP_EXPORT vpMomentGravityCenterNormalized : public vpMomentGravityCenter //! Moment name. const std::string name() const { return "vpMomentGravityCenterNormalized"; } void printDependencies(std::ostream &os) const; - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentGravityCenterNormalized &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenterNormalized &v); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/core/include/visp3/core/vpMomentObject.h b/modules/core/include/visp3/core/vpMomentObject.h index 3e2ca99935..47dcdd680c 100644 --- a/modules/core/include/visp3/core/vpMomentObject.h +++ b/modules/core/include/visp3/core/vpMomentObject.h @@ -50,18 +50,7 @@ namespace VISP_NAMESPACE_NAME { #endif class vpCameraParameters; -class vpMomentObject; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentObject &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpMomentObject @@ -296,7 +285,7 @@ class VISP_EXPORT vpMomentObject void init(unsigned int orderinp); void init(const vpMomentObject &objin); - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpMomentObject &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentObject &v); /*! Outputs raw moments in indexed form like m[1,1] = value of moment m11 \param momobj : A vpMomentObject diff --git a/modules/core/include/visp3/core/vpPlane.h b/modules/core/include/visp3/core/vpPlane.h index bf16976453..180648969c 100644 --- a/modules/core/include/visp3/core/vpPlane.h +++ b/modules/core/include/visp3/core/vpPlane.h @@ -43,18 +43,7 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpPlane; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPlane &p); -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpPlane @@ -162,7 +151,7 @@ class VISP_EXPORT vpPlane vpColVector getNormal() const; void getNormal(vpColVector &n) const; - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpPlane &p); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpPlane &p); // Operation with Plane void projectionPointOnPlan(const vpPoint &P, vpPoint &Pproj) const; diff --git a/modules/core/include/visp3/core/vpPoint.h b/modules/core/include/visp3/core/vpPoint.h index 80af46e0f8..6065dafa78 100644 --- a/modules/core/include/visp3/core/vpPoint.h +++ b/modules/core/include/visp3/core/vpPoint.h @@ -48,18 +48,7 @@ namespace VISP_NAMESPACE_NAME { #endif class vpHomogeneousMatrix; -class vpPoint; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPoint &vpp); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpPoint \ingroup group_core_geometry @@ -133,7 +122,7 @@ class VISP_EXPORT vpPoint : public vpForwardProjection vpColVector getWorldCoordinates(void); void getWorldCoordinates(std::vector &oP); - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpPoint &vpp); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpPoint &vpp); //! Projection onto the image plane of a point. Input: the 3D coordinates in //! the camera frame _cP, output : the 2D coordinates _p. diff --git a/modules/core/include/visp3/core/vpRGBa.h b/modules/core/include/visp3/core/vpRGBa.h index 89daeb2160..5e690b798f 100644 --- a/modules/core/include/visp3/core/vpRGBa.h +++ b/modules/core/include/visp3/core/vpRGBa.h @@ -48,18 +48,7 @@ namespace VISP_NAMESPACE_NAME { #endif class vpRGBa; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -// Forward declaration to have the operators in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgba); -VISP_NAMESPACE_ADDRESSING vpRGBa operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgb); -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpRGBa @@ -149,7 +138,7 @@ class VISP_EXPORT vpRGBa bool operator<(const vpRGBa &v) const; bool operator>(const vpRGBa &v) const; - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpRGBa &rgba); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba); public: unsigned char R; //!< Red component. @@ -157,7 +146,7 @@ class VISP_EXPORT vpRGBa unsigned char B; //!< Blue component. unsigned char A; //!< Additionnal component. - friend VISP_EXPORT vpRGBa(::operator*)(const double &x, const vpRGBa &rgb); + friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb); }; #if defined(ENABLE_VISP_NAMESPACE) } diff --git a/modules/core/include/visp3/core/vpRGBf.h b/modules/core/include/visp3/core/vpRGBf.h index 06ab1fbcfe..6823f4fcc3 100644 --- a/modules/core/include/visp3/core/vpRGBf.h +++ b/modules/core/include/visp3/core/vpRGBf.h @@ -47,19 +47,7 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpRGBf; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb); -VISP_NAMESPACE_ADDRESSING vpRGBf operator*(double x, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb); -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpRGBf @@ -136,14 +124,14 @@ class VISP_EXPORT vpRGBf bool operator<(const vpRGBf &v) const; bool operator>(const vpRGBf &v) const; - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpRGBf &rgb); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBf &rgb); public: float R; //!< Red component. float G; //!< Green component. float B; //!< Blue component. - friend VISP_EXPORT vpRGBf(::operator*)(double x, const vpRGBf &rgb); + friend VISP_EXPORT vpRGBf operator*(double x, const vpRGBf &rgb); }; #if defined(ENABLE_VISP_NAMESPACE) } diff --git a/modules/core/include/visp3/core/vpRect.h b/modules/core/include/visp3/core/vpRect.h index ef1f95ac7e..3bb1e980a0 100644 --- a/modules/core/include/visp3/core/vpRect.h +++ b/modules/core/include/visp3/core/vpRect.h @@ -45,19 +45,7 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpRect; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -bool inRectangle(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip, const VISP_NAMESPACE_ADDRESSING vpRect &rect); -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRect &r); -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! \class vpRect \ingroup group_core_geometry @@ -283,8 +271,8 @@ class VISP_EXPORT vpRect return a &= r; } - friend VISP_EXPORT bool ::inRectangle(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip, const vpRect &rect); - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpRect &r); + friend VISP_EXPORT bool inRectangle(const vpImagePoint &ip, const vpRect &rect); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRect &r); void set(double left, double top, double width, double height); void set(const vpImagePoint &topLeft, double width, double height); diff --git a/modules/core/include/visp3/core/vpRotationMatrix.h b/modules/core/include/visp3/core/vpRotationMatrix.h index 796b77587b..5a8d80b2b6 100644 --- a/modules/core/include/visp3/core/vpRotationMatrix.h +++ b/modules/core/include/visp3/core/vpRotationMatrix.h @@ -231,11 +231,12 @@ class VISP_EXPORT vpRotationMatrix : public vpArray2D unsigned int m_index; }; -#ifndef DOXYGEN_SHOULD_SKIP_THIS -VISP_EXPORT -#endif -vpRotationMatrix operator*(const double &x, const vpRotationMatrix &R); #if defined(ENABLE_VISP_NAMESPACE) } #endif + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +VISP_EXPORT +#endif +VISP_NAMESPACE_ADDRESSING vpRotationMatrix operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRotationMatrix &R); #endif diff --git a/modules/core/include/visp3/core/vpRotationVector.h b/modules/core/include/visp3/core/vpRotationVector.h index 2adc11acec..aa6ba95a20 100644 --- a/modules/core/include/visp3/core/vpRotationVector.h +++ b/modules/core/include/visp3/core/vpRotationVector.h @@ -158,12 +158,13 @@ class VISP_EXPORT vpRotationVector : public vpArray2D unsigned int m_index; // index used for operator<< and operator, to fill a vector }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #ifndef DOXYGEN_SHOULD_SKIP_THIS VISP_EXPORT #endif -vpColVector operator*(const double &x, const vpRotationVector &v); +VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRotationVector &v); -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif #endif diff --git a/modules/core/include/visp3/core/vpRowVector.h b/modules/core/include/visp3/core/vpRowVector.h index 880794827b..7a1b106eb5 100644 --- a/modules/core/include/visp3/core/vpRowVector.h +++ b/modules/core/include/visp3/core/vpRowVector.h @@ -340,8 +340,9 @@ class VISP_EXPORT vpRowVector : public vpArray2D #endif }; -VISP_EXPORT vpRowVector operator*(const double &x, const vpRowVector &v); #if defined(ENABLE_VISP_NAMESPACE) } #endif + +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpRowVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRowVector &v); #endif diff --git a/modules/core/src/camera/vpCameraParameters.cpp b/modules/core/src/camera/vpCameraParameters.cpp index af8f12ef4f..372c086c39 100644 --- a/modules/core/src/camera/vpCameraParameters.cpp +++ b/modules/core/src/camera/vpCameraParameters.cpp @@ -643,25 +643,14 @@ void vpCameraParameters::printParameters() std::cout.flags(original_flags); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! * Print on the output stream \e os the camera parameters. * * \param os : Output stream. * \param cam : Camera parameters. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const -#if defined(ENABLE_VISP_NAMESPACE) -visp:: -#endif -vpCameraParameters &cam) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters &cam) { -#if defined(ENABLE_VISP_NAMESPACE) - using namespace VISP_NAMESPACE_NAME; -#endif switch (cam.get_projModel()) { case vpCameraParameters::perspectiveProjWithoutDistortion: { os << "Camera parameters for perspective projection without distortion:" << std::endl; @@ -699,3 +688,6 @@ vpCameraParameters &cam) } return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/display/vpColor.cpp b/modules/core/src/display/vpColor.cpp index 7aa3b5ddc6..b3f135f7f8 100644 --- a/modules/core/src/display/vpColor.cpp +++ b/modules/core/src/display/vpColor.cpp @@ -124,10 +124,6 @@ vpColor const vpColor::allColors[vpColor::nbColors] = { vpColor::blue, // vpColor colors[6] = { vpColor::blue, vpColor::green, vpColor::red, vpColor::cyan, vpColor::orange, vpColor::purple }; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! Compare two colors. @@ -135,7 +131,7 @@ vpColor colors[6] = { vpColor::blue, vpColor::green, vpColor::red, vpColor::cyan \param c1,c2 : Color to compare. */ -VISP_EXPORT bool operator==(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2) +VISP_EXPORT bool operator==(const vpColor &c1, const vpColor &c2) { return ((c1.R == c2.R) && (c1.G == c2.G) && (c1.B == c2.B)); } @@ -148,7 +144,11 @@ VISP_EXPORT bool operator==(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const V \param c1,c2 : Color to compare. */ -VISP_EXPORT bool operator!=(const VISP_NAMESPACE_ADDRESSING vpColor &c1, const VISP_NAMESPACE_ADDRESSING vpColor &c2) +VISP_EXPORT bool operator!=(const vpColor &c1, const vpColor &c2) { return ((c1.R != c2.R) || (c1.G != c2.G) || (c1.B == c2.B)); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpImagePoint.cpp b/modules/core/src/image/vpImagePoint.cpp index 76d1573c39..71d0f6304a 100644 --- a/modules/core/src/image/vpImagePoint.cpp +++ b/modules/core/src/image/vpImagePoint.cpp @@ -123,57 +123,13 @@ vpImagePoint &vpImagePoint::operator/=(double scale) return *this; } -/** - * Computes and returns the bounding box. - * @param ipVec : Vector of input image points. - * @return Bounding box of the points. - */ -vpRect vpImagePoint::getBBox(const std::vector &ipVec) -{ - vpRect rec(ipVec); - - return rec; -} - -/*! - Compute the distance \f$ |iP1 - iP2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2} \f$ - - \param iP1 : First point - \param iP2 : Second point - - \return the distance between the two points. -*/ -double vpImagePoint::distance(const vpImagePoint &iP1, const vpImagePoint &iP2) -{ - return sqrt(vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j())); -} - -/*! - Compute the distance \f$ |iP1 - iP2| = (i_1-i_2)^2+(j_1-j_2)^2 \f$ - - \param iP1 : First point - \param iP2 : Second point - - \return the distance between the two points. -*/ -double vpImagePoint::sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP2) -{ - return vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j()); -} -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! \relates vpImagePoint Returns true if ip1 and ip2 are equal; otherwire returns false. */ -VISP_EXPORT bool operator==(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) +VISP_EXPORT bool operator==(const vpImagePoint &ip1, const vpImagePoint &ip2) { -#ifdef ENABLE_VISP_NAMESPACE - using namespace VISP_NAMESPACE_NAME; -#endif // --comment: return ip1 dot get_i() eq ip2 dot get_i() and ip1 dot get_j() eq ip2 dot get_j() double i1 = ip1.get_i(); @@ -190,11 +146,8 @@ VISP_EXPORT bool operator==(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, c Returns true if ip1 and ip2 are different; otherwire returns true. */ -VISP_EXPORT bool operator!=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) +VISP_EXPORT bool operator!=(const vpImagePoint &ip1, const vpImagePoint &ip2) { -#ifdef ENABLE_VISP_NAMESPACE - using namespace VISP_NAMESPACE_NAME; -#endif // --comment: return ip1 dot get_i() diff ip2 dot get_i() or ip1 dot get_j() diff ip2 dot get_j() double i1 = ip1.get_i(); double j1 = ip1.get_j(); @@ -210,9 +163,9 @@ VISP_EXPORT bool operator!=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, c Returns a vpImagePoint wich is the sum of \f$ ip1 \f$ and \f$ ip2 \f$. */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) +VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, const vpImagePoint &ip2) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); + return (vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); } /*! @@ -220,9 +173,9 @@ VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPAC Returns a vpImagePoint wich is the sum of \f$ ip1 \f$ and \f$ ip2 \f$. */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+=(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) +VISP_EXPORT vpImagePoint operator+=(const vpImagePoint &ip1, const vpImagePoint &ip2) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); + return (vpImagePoint(ip1.get_i() + ip2.get_i(), ip1.get_j() + ip2.get_j())); } /*! @@ -244,9 +197,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset) +VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, int offset) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); + return (vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); } /*! @@ -268,9 +221,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset) +VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, unsigned int offset) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); + return (vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); } /*! @@ -292,9 +245,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset) +VISP_EXPORT vpImagePoint operator+(const vpImagePoint &ip1, double offset) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); + return (vpImagePoint(ip1.get_i() + offset, ip1.get_j() + offset)); } /*! @@ -303,9 +256,9 @@ VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator+(const VISP_NAMESPAC Returns a vpImagePoint wich is the difference between \f$ ip1 \f$ and \f$ ip2 \f$. */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip2) +VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, const vpImagePoint &ip2) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - ip2.get_i(), ip1.get_j() - ip2.get_j())); + return (vpImagePoint(ip1.get_i() - ip2.get_i(), ip1.get_j() - ip2.get_j())); } /*! @@ -327,9 +280,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, int offset) +VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, int offset) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); + return (vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); } /*! @@ -351,9 +304,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, unsigned int offset) +VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, unsigned int offset) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); + return (vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); } /*! @@ -375,9 +328,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator-(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double offset) +VISP_EXPORT vpImagePoint operator-(const vpImagePoint &ip1, double offset) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); + return (vpImagePoint(ip1.get_i() - offset, ip1.get_j() - offset)); } /*! @@ -399,9 +352,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator*(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale) +VISP_EXPORT vpImagePoint operator*(const vpImagePoint &ip1, double scale) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() * scale, ip1.get_j() * scale)); + return (vpImagePoint(ip1.get_i() * scale, ip1.get_j() * scale)); } /*! @@ -423,9 +376,9 @@ int main() } \endcode */ -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpImagePoint operator/(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip1, double scale) +VISP_EXPORT vpImagePoint operator/(const vpImagePoint &ip1, double scale) { - return (VISP_NAMESPACE_ADDRESSING vpImagePoint(ip1.get_i() / scale, ip1.get_j() / scale)); + return (vpImagePoint(ip1.get_i() / scale, ip1.get_j() / scale)); } /*! @@ -459,8 +412,49 @@ int main() Image point with coordinates: 10, 11.1 \endverbatim */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpImagePoint &ip) { os << ip.get_i() << ", " << ip.get_j(); return os; } + +/** + * Computes and returns the bounding box. + * @param ipVec : Vector of input image points. + * @return Bounding box of the points. + */ +vpRect vpImagePoint::getBBox(const std::vector &ipVec) +{ + vpRect rec(ipVec); + + return rec; +} + +/*! + Compute the distance \f$ |iP1 - iP2| = \sqrt{(i_1-i_2)^2+(j_1-j_2)^2} \f$ + + \param iP1 : First point + \param iP2 : Second point + + \return the distance between the two points. +*/ +double vpImagePoint::distance(const vpImagePoint &iP1, const vpImagePoint &iP2) +{ + return sqrt(vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j())); +} + +/*! + Compute the distance \f$ |iP1 - iP2| = (i_1-i_2)^2+(j_1-j_2)^2 \f$ + + \param iP1 : First point + \param iP2 : Second point + + \return the distance between the two points. +*/ +double vpImagePoint::sqrDistance(const vpImagePoint &iP1, const vpImagePoint &iP2) +{ + return vpMath::sqr(iP1.get_i() - iP2.get_i()) + vpMath::sqr(iP1.get_j() - iP2.get_j()); +} +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpRGBa.cpp b/modules/core/src/image/vpRGBa.cpp index 5b4850e746..9cd2a22943 100644 --- a/modules/core/src/image/vpRGBa.cpp +++ b/modules/core/src/image/vpRGBa.cpp @@ -232,11 +232,8 @@ bool vpRGBa::operator>(const vpRGBa &v) const return (gray1 > gray2); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif -VISP_NAMESPACE_ADDRESSING vpRGBa operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgb) { return rgb * x; } +VISP_NAMESPACE_ADDRESSING vpRGBa operator*(const double &x, const vpRGBa &rgb) { return rgb * x; } /*! @@ -260,8 +257,11 @@ int main() } \endcode */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBa &rgba) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBa &rgba) { os << "(" << static_cast(rgba.R) << "," << static_cast(rgba.G) << "," << static_cast(rgba.B) << "," << static_cast(rgba.A) << ")"; return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/image/vpRGBf.cpp b/modules/core/src/image/vpRGBf.cpp index 748168277e..78e14c8e63 100644 --- a/modules/core/src/image/vpRGBf.cpp +++ b/modules/core/src/image/vpRGBf.cpp @@ -237,11 +237,8 @@ bool vpRGBf::operator>(const vpRGBf &v) const return (gray1 > gray2); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif -VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpRGBf operator*(double x, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb) { return rgb * x; } +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpRGBf operator*(double x, const vpRGBf &rgb) { return rgb * x; } /*! \relates vpRGBf @@ -264,8 +261,11 @@ int main() } \endcode */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRGBf &rgb) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRGBf &rgb) { os << "(" << rgb.R << "," << rgb.G << "," << rgb.B << ")"; return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpColVector.cpp b/modules/core/src/math/matrix/vpColVector.cpp index f5e8363229..36dfcf6bfe 100644 --- a/modules/core/src/math/matrix/vpColVector.cpp +++ b/modules/core/src/math/matrix/vpColVector.cpp @@ -521,13 +521,6 @@ vpRowVector vpColVector::transpose() const { return t(); } void vpColVector::transpose(vpRowVector &v) const { v = t(); } -vpColVector operator*(const double &x, const vpColVector &v) -{ - vpColVector vout; - vout = v * x; - return vout; -} - double vpColVector::dotProd(const vpColVector &a, const vpColVector &b) { if (a.data == nullptr) { @@ -1019,3 +1012,10 @@ double vpColVector::euclideanNorm() const { return frobeniusNorm(); } #if defined(ENABLE_VISP_NAMESPACE) } #endif + +VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpColVector &v) +{ + VISP_NAMESPACE_ADDRESSING vpColVector vout; + vout = v * x; + return vout; +} diff --git a/modules/core/src/math/matrix/vpMatrix.cpp b/modules/core/src/math/matrix/vpMatrix.cpp index 056d2f6773..bcb406d2ea 100644 --- a/modules/core/src/math/matrix/vpMatrix.cpp +++ b/modules/core/src/math/matrix/vpMatrix.cpp @@ -1665,31 +1665,6 @@ double vpMatrix::sum() const // Matrix/real operations. //--------------------------------- -/*! - \relates vpMatrix - Allow to multiply a scalar by a matrix. -*/ -vpMatrix operator*(const double &x, const vpMatrix &B) -{ - if (std::fabs(x - 1.) < std::numeric_limits::epsilon()) { - return B; - } - - unsigned int Brow = B.getRows(); - unsigned int Bcol = B.getCols(); - - vpMatrix C; - C.resize(Brow, Bcol, false, false); - - for (unsigned int i = 0; i < Brow; ++i) { - for (unsigned int j = 0; j < Bcol; ++j) { - C[i][j] = B[i][j] * x; - } - } - - return C; -} - /*! Operator that allows to multiply all the elements of a matrix by a scalar. @@ -5025,35 +5000,35 @@ vpRowVector vpMatrix::getRow(unsigned int i) const { return getRow(i, 0, colNum) \param row_size : Size of the row vector to extract. \return The extracted row vector. - The following example shows how to use this function: - \code - #include - #include +The following example shows how to use this function: +\code +#include +#include - int main() - { - vpMatrix A(4,4); +int main() +{ + vpMatrix A(4, 4); - for(unsigned int i=0; i < A.getRows(); i++) - for(unsigned int j=0; j < A.getCols(); j++) - A[i][j] = i*A.getCols()+j; + for (unsigned int i = 0; i < A.getRows(); i++) + for (unsigned int j = 0; j < A.getCols(); j++) + A[i][j] = i*A.getCols()+j; - A.print(std::cout, 4); + A.print(std::cout, 4); - vpRowVector rv = A.getRow(1, 1, 3); - std::cout << "Row vector: \n" << rv << std::endl; - } - \endcode - It produces the following output : - \code - [4, 4] = - 0 1 2 3 - 4 5 6 7 - 8 9 10 11 - 12 13 14 15 - Row vector : - 5 6 7 - \endcode + vpRowVector rv = A.getRow(1, 1, 3); + std::cout << "Row vector: \n" << rv << std::endl; +} +\endcode +It produces the following output : +\code +[4, 4] = +0 1 2 3 +4 5 6 7 +8 9 10 11 +12 13 14 15 +Row vector : +5 6 7 +\endcode */ vpRowVector vpMatrix::getRow(unsigned int i, unsigned int j_begin, unsigned int row_size) const { @@ -6729,3 +6704,28 @@ void vpMatrix::setIdentity(const double &val) #if defined(ENABLE_VISP_NAMESPACE) } #endif + +/*! + \relates vpMatrix + Allow to multiply a scalar by a matrix. +*/ +VISP_NAMESPACE_ADDRESSING vpMatrix operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpMatrix &B) +{ + if (std::fabs(x - 1.) < std::numeric_limits::epsilon()) { + return B; + } + + unsigned int Brow = B.getRows(); + unsigned int Bcol = B.getCols(); + + VISP_NAMESPACE_ADDRESSING vpMatrix C; + C.resize(Brow, Bcol, false, false); + + for (unsigned int i = 0; i < Brow; ++i) { + for (unsigned int j = 0; j < Bcol; ++j) { + C[i][j] = B[i][j] * x; + } + } + + return C; +} diff --git a/modules/core/src/math/matrix/vpRowVector.cpp b/modules/core/src/math/matrix/vpRowVector.cpp index 6b5c2fd6cd..17b42ff7cb 100644 --- a/modules/core/src/math/matrix/vpRowVector.cpp +++ b/modules/core/src/math/matrix/vpRowVector.cpp @@ -1085,16 +1085,6 @@ int vpRowVector::print(std::ostream &s, unsigned int length, char const *intro) return static_cast(maxBefore + maxAfter); } -/*! - Allows to multiply a scalar by row vector. -*/ -vpRowVector operator*(const double &x, const vpRowVector &v) -{ - vpRowVector vout; - vout = v * x; - return vout; -} - /*! Return the sum of all the elements \f$v_{i}\f$ of the row vector v(n). @@ -1373,3 +1363,13 @@ std::ostream &vpRowVector::matlabPrint(std::ostream &os) const #if defined(ENABLE_VISP_NAMESPACE) } #endif + +/*! + Allows to multiply a scalar by row vector. +*/ +VISP_NAMESPACE_ADDRESSING vpRowVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRowVector &v) +{ + VISP_NAMESPACE_ADDRESSING vpRowVector vout; + vout = v * x; + return vout; +} diff --git a/modules/core/src/math/transformation/vpRotationMatrix.cpp b/modules/core/src/math/transformation/vpRotationMatrix.cpp index f75cca57be..888fd7f3bb 100644 --- a/modules/core/src/math/transformation/vpRotationMatrix.cpp +++ b/modules/core/src/math/transformation/vpRotationMatrix.cpp @@ -948,25 +948,6 @@ vpRotationMatrix &vpRotationMatrix::build(const vpQuaternionVector &q) return *this; } -/*! - Allow to multiply a scalar by a rotation matrix. -*/ -vpRotationMatrix operator*(const double &x, const vpRotationMatrix &R) -{ - vpRotationMatrix C; - - unsigned int Rrow = R.getRows(); - unsigned int Rcol = R.getCols(); - - for (unsigned int i = 0; i < Rrow; ++i) { - for (unsigned int j = 0; j < Rcol; ++j) { - C[i][j] = R[i][j] * x; - } - } - - return C; -} - /*! Return the \f$\theta {\bf u}\f$ vector that corresponds to the rotation matrix. @@ -1145,3 +1126,22 @@ void vpRotationMatrix::setIdentity() { eye(); } #if defined(ENABLE_VISP_NAMESPACE) } #endif + +/*! + Allow to multiply a scalar by a rotation matrix. +*/ +VISP_NAMESPACE_ADDRESSING vpRotationMatrix operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRotationMatrix &R) +{ + VISP_NAMESPACE_ADDRESSING vpRotationMatrix C; + + unsigned int Rrow = R.getRows(); + unsigned int Rcol = R.getCols(); + + for (unsigned int i = 0; i < Rrow; ++i) { + for (unsigned int j = 0; j < Rcol; ++j) { + C[i][j] = R[i][j] * x; + } + } + + return C; +} diff --git a/modules/core/src/math/transformation/vpRotationVector.cpp b/modules/core/src/math/transformation/vpRotationVector.cpp index 66c56f4d8f..9d8a171fb2 100644 --- a/modules/core/src/math/transformation/vpRotationVector.cpp +++ b/modules/core/src/math/transformation/vpRotationVector.cpp @@ -100,17 +100,6 @@ vpColVector vpRotationVector::operator*(double x) const return v; } -/*! - \relates vpRotationVector - Allows to multiply a scalar by rotaion vector. -*/ -vpColVector operator*(const double &x, const vpRotationVector &v) -{ - vpColVector vout; - vout = v * x; - return vout; -} - /*! Set vector first element value. \param val : Value of the vector first element [rad]. @@ -197,3 +186,14 @@ double vpRotationVector::sumSquare() const #if defined(ENABLE_VISP_NAMESPACE) } #endif + +/*! + \relates vpRotationVector + Allows to multiply a scalar by rotaion vector. +*/ +VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRotationVector &v) +{ + VISP_NAMESPACE_ADDRESSING vpColVector vout; + vout = v * x; + return vout; +} diff --git a/modules/core/src/tools/exceptions/vpException.cpp b/modules/core/src/tools/exceptions/vpException.cpp index 6ef46fc632..36316d891b 100644 --- a/modules/core/src/tools/exceptions/vpException.cpp +++ b/modules/core/src/tools/exceptions/vpException.cpp @@ -72,13 +72,13 @@ const std::string &vpException::getStringMessage() const { return this->message; int vpException::getCode() const { return this->code; } const char *vpException::what() const throw() { return (this->message).c_str(); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpException &error) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpException &error) { os << "Error [" << error.code << "]:\t" << error.message << std::endl; return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/geometry/vpPlane.cpp b/modules/core/src/tools/geometry/vpPlane.cpp index 3a76de02f9..3042c5e858 100644 --- a/modules/core/src/tools/geometry/vpPlane.cpp +++ b/modules/core/src/tools/geometry/vpPlane.cpp @@ -383,17 +383,16 @@ void vpPlane::changeFrame(const vpHomogeneousMatrix &cMo) D = Do - ((cMo[0][3] * A) + (cMo[1][3] * B) + (cMo[2][3] * C)); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! Print the plane parameters as a stream like "(A,B,C,D) " where A,B,C and D correspond to the parameters of the plane. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPlane &p) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpPlane &p) { return (os << "(" << p.getA() << "," << p.getB() << "," << p.getC() << "," << p.getD() << ") "); }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/geometry/vpRect.cpp b/modules/core/src/tools/geometry/vpRect.cpp index c5ffec712c..2b29817a0a 100644 --- a/modules/core/src/tools/geometry/vpRect.cpp +++ b/modules/core/src/tools/geometry/vpRect.cpp @@ -255,9 +255,6 @@ bool vpRect::operator!=(const vpRect &r) const */ return !(*this == r); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif /*! Check if an image point belongs to a rectangle. @@ -267,14 +264,17 @@ bool vpRect::operator!=(const vpRect &r) const \return Returns true if the point belongs to the rectangle. */ -VISP_EXPORT bool inRectangle(const VISP_NAMESPACE_ADDRESSING vpImagePoint &ip, const VISP_NAMESPACE_ADDRESSING vpRect &rect) +VISP_EXPORT bool inRectangle(const vpImagePoint &ip, const vpRect &rect) { return ((ip.get_i() <= rect.getBottom()) && (ip.get_i() >= rect.getTop()) && (ip.get_j() <= rect.getRight()) && (ip.get_j() >= rect.getLeft())); } -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpRect &r) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpRect &r) { os << r.getLeft() << ", " << r.getTop() << ", " << r.getWidth() << ", " << r.getHeight(); return os; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/tools/histogram/vpHistogramPeak.cpp b/modules/core/src/tools/histogram/vpHistogramPeak.cpp index cb8416900e..ff5ab33bc4 100644 --- a/modules/core/src/tools/histogram/vpHistogramPeak.cpp +++ b/modules/core/src/tools/histogram/vpHistogramPeak.cpp @@ -88,21 +88,21 @@ vpHistogramPeak &vpHistogramPeak::operator=(const vpHistogramPeak &p) */ bool vpHistogramPeak::operator==(const vpHistogramPeak &p) const { return ((level == p.level) && (value == p.value)); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif /*! \relates vpHistogramPeak \brief std::cout a peak */ -VISP_EXPORT std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramPeak &p) +VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramPeak &p) { s << static_cast(p.getLevel()) << " " << p.getValue(); return s; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/core/src/tools/histogram/vpHistogramValey.cpp b/modules/core/src/tools/histogram/vpHistogramValey.cpp index 25d8458ef2..9391e21ae4 100644 --- a/modules/core/src/tools/histogram/vpHistogramValey.cpp +++ b/modules/core/src/tools/histogram/vpHistogramValey.cpp @@ -77,15 +77,11 @@ bool vpHistogramValey::operator==(const vpHistogramValey &v) const return ((level == v.level) && (value == v.value)); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! \relates vpHistogramValey \brief std::cout a valey */ -VISP_EXPORT std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRESSING vpHistogramValey &v) +VISP_EXPORT std::ostream &operator<<(std::ostream &s, const vpHistogramValey &v) { s << static_cast(v.getLevel()) << " " << v.getValue(); @@ -93,6 +89,9 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &s, const VISP_NAMESPACE_ADDRE return s; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/core/src/tracking/forward-projection/vpPoint.cpp b/modules/core/src/tracking/forward-projection/vpPoint.cpp index f07a3054c7..c2a7e786c3 100644 --- a/modules/core/src/tracking/forward-projection/vpPoint.cpp +++ b/modules/core/src/tracking/forward-projection/vpPoint.cpp @@ -508,8 +508,8 @@ void vpPoint::set_x(double x) { p[0] = x; } void vpPoint::set_y(double y) { p[1] = y; } //! Set the point w coordinate in the image plane. void vpPoint::set_w(double w) { p[2] = w; } + +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpPoint & /* vpp */) { return (os << "vpPoint"); } #if defined(ENABLE_VISP_NAMESPACE) } #endif - -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpPoint & /* vpp */) { return (os << "vpPoint"); } diff --git a/modules/core/src/tracking/moments/vpMoment.cpp b/modules/core/src/tracking/moments/vpMoment.cpp index 1da05131eb..ac29937392 100644 --- a/modules/core/src/tracking/moments/vpMoment.cpp +++ b/modules/core/src/tracking/moments/vpMoment.cpp @@ -41,12 +41,16 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Prints the moment contents to a stream * \param os : a std::stream. * \param m : a moment instance. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMoment &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMoment &m) { for (std::vector::const_iterator i = m.values.begin(); i != m.values.end(); ++i) os << *i << ","; @@ -54,10 +58,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDR return os; } -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * Default constructor */ diff --git a/modules/core/src/tracking/moments/vpMomentAlpha.cpp b/modules/core/src/tracking/moments/vpMomentAlpha.cpp index 3cf523ca56..d01dd8ed74 100644 --- a/modules/core/src/tracking/moments/vpMomentAlpha.cpp +++ b/modules/core/src/tracking/moments/vpMomentAlpha.cpp @@ -177,14 +177,10 @@ void vpMomentAlpha::printDependencies(std::ostream &os) const os << "mu02 = " << momentCentered.get(0, 2) << std::endl; } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - /*! Prints the value of the major-axis orientation in degrees and rad */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAlpha &c) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAlpha &c) { #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; @@ -193,3 +189,7 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDR os << "Alpha = " << c.values[0] << "rad = " << vpMath::deg(c.values[0]) << "deg " << std::endl; return os; } + +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentArea.cpp b/modules/core/src/tracking/moments/vpMomentArea.cpp index da0f65df79..1f6adb83c8 100644 --- a/modules/core/src/tracking/moments/vpMomentArea.cpp +++ b/modules/core/src/tracking/moments/vpMomentArea.cpp @@ -100,16 +100,17 @@ void vpMomentArea::printDependencies(std::ostream &os) const os << "mu00 = " << momentCentered.get(0, 0) << std::endl; } } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! Outputs the moment's values to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentArea &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentArea &m) { os << (__FILE__) << std::endl; os << "a(m00) = " << m.values[0] << std::endl; return os; } + +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp b/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp index 841f65b0d9..511d8a8790 100644 --- a/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp +++ b/modules/core/src/tracking/moments/vpMomentAreaNormalized.cpp @@ -114,17 +114,16 @@ void vpMomentAreaNormalized::printDependencies(std::ostream &os) const a = getObject().get(0, 0); os << "a = " << a << std::endl; } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - /*! Outputs the moment's values to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentAreaNormalized &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentAreaNormalized &m) { os << (__FILE__) << std::endl; os << "An = " << m.values[0] << std::endl; return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentBasic.cpp b/modules/core/src/tracking/moments/vpMomentBasic.cpp index 8dbbd6269b..a0a9ccf6a3 100644 --- a/modules/core/src/tracking/moments/vpMomentBasic.cpp +++ b/modules/core/src/tracking/moments/vpMomentBasic.cpp @@ -83,20 +83,17 @@ void vpMomentBasic::printDependencies(std::ostream &os) const << std::endl; vpMomentObject::printWithIndices(getObject(), os); } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! Outputs the moment's values to a stream. Same output as in vpMomentObject. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentBasic &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentBasic &m) { -#ifdef ENABLE_VISP_NAMESPACE - using namespace VISP_NAMESPACE_NAME; -#endif os << (__FILE__) << std::endl; vpMomentObject::printWithIndices(m.getObject(), os); return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentCInvariant.cpp b/modules/core/src/tracking/moments/vpMomentCInvariant.cpp index b8f663590d..ea9891d3c7 100644 --- a/modules/core/src/tracking/moments/vpMomentCInvariant.cpp +++ b/modules/core/src/tracking/moments/vpMomentCInvariant.cpp @@ -285,17 +285,17 @@ void vpMomentCInvariant::printInvariants(std::ostream &os) const } os << std::endl; } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! Outputs the moment's values to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCInvariant &c) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCInvariant &c) { for (unsigned int i = 0; i < c.values.size(); i++) { os << c.values[i] << "," << std::endl; } return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentCentered.cpp b/modules/core/src/tracking/moments/vpMomentCentered.cpp index eb9da481b7..c28943e999 100644 --- a/modules/core/src/tracking/moments/vpMomentCentered.cpp +++ b/modules/core/src/tracking/moments/vpMomentCentered.cpp @@ -157,9 +157,6 @@ void vpMomentCentered::printDependencies(std::ostream &os) const os << "Xg = " << momentGravity.getXg() << "\t" << "Yg = " << momentGravity.getYg() << std::endl; } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! Outputs the centered moment's values \f$\mu_{ij}\f$ to a stream presented as @@ -179,7 +176,7 @@ u30 x x x This output will be followed by an output with indexes as produced by printWithIndices() function */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentCentered &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentCentered &m) { for (unsigned int i = 0; i < m.values.size(); i++) { if (i % (m.getObject().getOrder() + 1) == 0) @@ -196,3 +193,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDR m.printWithIndices(os); return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentDatabase.cpp b/modules/core/src/tracking/moments/vpMomentDatabase.cpp index 12642ec3c3..4c4ffca129 100644 --- a/modules/core/src/tracking/moments/vpMomentDatabase.cpp +++ b/modules/core/src/tracking/moments/vpMomentDatabase.cpp @@ -90,14 +90,11 @@ void vpMomentDatabase::updateAll(vpMomentObject &object) (*itr).second->update(object); } } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! * Outputs all the moments values in the database to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentDatabase &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentDatabase &m) { #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; @@ -112,3 +109,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDR return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp b/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp index 1a79e04218..6d7105f50e 100644 --- a/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp +++ b/modules/core/src/tracking/moments/vpMomentGravityCenter.cpp @@ -75,16 +75,16 @@ void vpMomentGravityCenter::printDependencies(std::ostream &os) const os << "m00 = " << getObject().get(0, 1) << "\t"; os << "m00 = " << getObject().get(0, 0) << std::endl; } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! Outputs the moment's values to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenter &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenter &m) { os << (__FILE__) << std::endl; os << "(Xg,Yg) = (" << m.values[0] << ", " << m.values[1] << ")" << std::endl; return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp b/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp index 8476cc5bf7..93bead2439 100644 --- a/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp +++ b/modules/core/src/tracking/moments/vpMomentGravityCenterNormalized.cpp @@ -101,16 +101,16 @@ void vpMomentGravityCenterNormalized::printDependencies(std::ostream &os) const << "Yg = " << momentGravity.get()[1] << std::endl; os << "An = " << momentSurfaceNormalized.get()[0] << std::endl; } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! Outputs the moment's values to a stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentGravityCenterNormalized &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentGravityCenterNormalized &m) { os << (__FILE__) << std::endl; os << "(Xn,Yn) = (" << m.values[0] << ", " << m.values[1] << ")" << std::endl; return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/core/src/tracking/moments/vpMomentObject.cpp b/modules/core/src/tracking/moments/vpMomentObject.cpp index f092d76f55..8c679bf217 100644 --- a/modules/core/src/tracking/moments/vpMomentObject.cpp +++ b/modules/core/src/tracking/moments/vpMomentObject.cpp @@ -635,9 +635,6 @@ vpMomentObject::~vpMomentObject() { // deliberate empty } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! Outputs the basic moment's values \f$m_{ij}\f$ to a stream presented as a @@ -654,7 +651,7 @@ vpMomentObject::~vpMomentObject() m03 x x x \endcode */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpMomentObject &m) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpMomentObject &m) { for (unsigned int i = 0; i < m.values.size(); ++i) { @@ -673,3 +670,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDR return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/imgproc/include/visp3/imgproc/vpContours.h b/modules/imgproc/include/visp3/imgproc/vpContours.h index 743ff1952b..7252feb2fd 100644 --- a/modules/imgproc/include/visp3/imgproc/vpContours.h +++ b/modules/imgproc/include/visp3/imgproc/vpContours.h @@ -77,7 +77,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/include/visp3/imgproc/vpImgproc.h b/modules/imgproc/include/visp3/imgproc/vpImgproc.h index a2c315ac5f..677d8a925f 100644 --- a/modules/imgproc/include/visp3/imgproc/vpImgproc.h +++ b/modules/imgproc/include/visp3/imgproc/vpImgproc.h @@ -48,7 +48,7 @@ #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS #define VISP_IMGPROC_NAMESPACE vp #else -#define VISP_IMGPROC_NAMESPACE visp +#define VISP_IMGPROC_NAMESPACE VISP_NAMESPACE_NAME #endif namespace VISP_IMGPROC_NAMESPACE diff --git a/modules/imgproc/src/vpCLAHE.cpp b/modules/imgproc/src/vpCLAHE.cpp index 38ff57d97a..88ed860bb0 100644 --- a/modules/imgproc/src/vpCLAHE.cpp +++ b/modules/imgproc/src/vpCLAHE.cpp @@ -82,7 +82,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/src/vpConnectedComponents.cpp b/modules/imgproc/src/vpConnectedComponents.cpp index aa0adb3f3b..00f98acff8 100644 --- a/modules/imgproc/src/vpConnectedComponents.cpp +++ b/modules/imgproc/src/vpConnectedComponents.cpp @@ -42,7 +42,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/src/vpContours.cpp b/modules/imgproc/src/vpContours.cpp index 0a195f0208..c67aa67516 100644 --- a/modules/imgproc/src/vpContours.cpp +++ b/modules/imgproc/src/vpContours.cpp @@ -73,7 +73,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/src/vpFloodFill.cpp b/modules/imgproc/src/vpFloodFill.cpp index 368b8e2a88..3bfca2b9ce 100644 --- a/modules/imgproc/src/vpFloodFill.cpp +++ b/modules/imgproc/src/vpFloodFill.cpp @@ -69,7 +69,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/src/vpMorph.cpp b/modules/imgproc/src/vpMorph.cpp index d252708a96..f6b652819f 100644 --- a/modules/imgproc/src/vpMorph.cpp +++ b/modules/imgproc/src/vpMorph.cpp @@ -42,7 +42,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/src/vpRetinex.cpp b/modules/imgproc/src/vpRetinex.cpp index c26661efdb..248d9260ed 100644 --- a/modules/imgproc/src/vpRetinex.cpp +++ b/modules/imgproc/src/vpRetinex.cpp @@ -91,7 +91,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/src/vpThreshold.cpp b/modules/imgproc/src/vpThreshold.cpp index 97351741b8..9b9d531adc 100644 --- a/modules/imgproc/src/vpThreshold.cpp +++ b/modules/imgproc/src/vpThreshold.cpp @@ -43,7 +43,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) namespace vp #else -namespace visp +namespace VISP_NAMESPACE_NAME #endif { diff --git a/modules/imgproc/test/with-dataset/testAutoThreshold.cpp b/modules/imgproc/test/with-dataset/testAutoThreshold.cpp index 2de7a84f55..79e9ae70f9 100644 --- a/modules/imgproc/test/with-dataset/testAutoThreshold.cpp +++ b/modules/imgproc/test/with-dataset/testAutoThreshold.cpp @@ -31,21 +31,25 @@ * Test automatic thresholding. */ -#include -#include -#include -#include -#include - /*! \example testAutoThreshold.cpp \brief Test automatic thresholding. */ +#include +#include +#include +#include +#include + // List of allowed command line options #define GETOPTARGS "cdi:o:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); @@ -61,9 +65,9 @@ bool getOptions(int argc, const char **argv, std::string &ipath, std::string &op void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user) { #if VISP_HAVE_DATASET_VERSION >= 0x030600 - std::string ext("png"); + std::string ext("png"); #else - std::string ext("pgm"); + std::string ext("pgm"); #endif fprintf(stdout, "\n\ Test automatic thresholding.\n\ @@ -72,7 +76,7 @@ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n \ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -203,7 +207,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -218,8 +223,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -228,9 +233,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; exit(EXIT_FAILURE); } @@ -311,7 +316,8 @@ int main(int argc, const char **argv) std::cout << "Write: " << filename << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/imgproc/test/with-dataset/testConnectedComponents.cpp b/modules/imgproc/test/with-dataset/testConnectedComponents.cpp index de888663c9..8b8b8fe2dd 100644 --- a/modules/imgproc/test/with-dataset/testConnectedComponents.cpp +++ b/modules/imgproc/test/with-dataset/testConnectedComponents.cpp @@ -30,6 +30,13 @@ * Description: * Test connected components. */ + +/*! + \example testConnectedComponents.cpp + + \brief Test connected components. +*/ + #include #include #include @@ -38,15 +45,13 @@ #include #include -/*! - \example testConnectedComponents.cpp - - \brief Test connected components. -*/ - // List of allowed command line options #define GETOPTARGS "cdi:o:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); bool checkLabels(const vpImage &label1, const vpImage &label2); @@ -69,7 +74,7 @@ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n \ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -156,8 +161,8 @@ bool checkLabels(const vpImage &label1, const vpImage &label2) for (unsigned int j = 0; j < label1.getWidth(); j++) { if ((label1[i][j] > 0 && label2[i][j] == 0) || (label1[i][j] == 0 && label2[i][j] > 0)) { std::cerr << "label1[i][j] > 0 && label2[i][j] == 0 || label1[i][j] " - "== 0 && label2[i][j] > 0" - << std::endl; + "== 0 && label2[i][j] > 0" + << std::endl; return false; } @@ -242,7 +247,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -257,8 +263,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -267,9 +273,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; exit(EXIT_FAILURE); } @@ -393,7 +399,8 @@ int main(int argc, const char **argv) #endif return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/imgproc/test/with-dataset/testContours.cpp b/modules/imgproc/test/with-dataset/testContours.cpp index b1c7a9b9a3..60f263c317 100644 --- a/modules/imgproc/test/with-dataset/testContours.cpp +++ b/modules/imgproc/test/with-dataset/testContours.cpp @@ -31,6 +31,12 @@ * Test contours extraction. */ +/*! + \example testContours.cpp + + \brief Test contours extraction. +*/ + #include #include @@ -39,15 +45,13 @@ #include #include -/*! - \example testContours.cpp - - \brief Test contours extraction. -*/ - // List of allowed command line options #define GETOPTARGS "cdi:o:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); @@ -69,7 +73,7 @@ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n \ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -172,7 +176,7 @@ void displayContourInfo(const vp::vpContour &contour, int level) std::cout << "\nContour:" << std::endl; std::cout << "\tlevel: " << level << std::endl; std::cout << "\tcontour type: " << (contour.m_contourType == vp::CONTOUR_OUTER ? "outer contour" : "hole contour") - << std::endl; + << std::endl; std::cout << "\tnb children: " << contour.m_children.size() << std::endl; for (std::vector::const_iterator it = contour.m_children.begin(); it != contour.m_children.end(); @@ -229,7 +233,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -244,8 +249,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -254,9 +259,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; exit(EXIT_FAILURE); } @@ -268,7 +273,7 @@ int main(int argc, const char **argv) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; vpImage I_test_data(image_data, 14, 10, true); std::cout << "Test with image data:" << std::endl; @@ -353,7 +358,7 @@ int main(int argc, const char **argv) vp::drawContours(I_draw_contours_external, contours); std::cout << "(I_tmp_external == I_draw_contours_external)? " << (I_tmp_external == I_draw_contours_external) - << std::endl; + << std::endl; filename = vpIoTools::createFilePath(opath, "Klimt_contours_extracted_external.pgm"); vpImageIo::write(I_draw_contours_external, filename); @@ -390,7 +395,7 @@ int main(int argc, const char **argv) } std::cout << "(I_draw_contours_opencv == I_drawContours)? " << (I_draw_contours_opencv == I_draw_contours) - << std::endl; + << std::endl; filename = vpIoTools::createFilePath(opath, "Klimt_contours_extracted_opencv.pgm"); vpImageIo::write(I_draw_contours_opencv, filename); @@ -409,9 +414,9 @@ int main(int argc, const char **argv) } std::cout << "(I_draw_contours_opencv == I_draw_contours_list)? " - << (I_draw_contours_opencv == I_draw_contours_list) << std::endl; + << (I_draw_contours_opencv == I_draw_contours_list) << std::endl; - // Test retrieve external +// Test retrieve external vpImageConvert::convert(I, matImg); contours_opencv.clear(); cv::findContours(matImg, contours_opencv, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_NONE); @@ -425,11 +430,12 @@ int main(int argc, const char **argv) } std::cout << "(I_draw_contours_opencv == I_draw_contours_external)? " - << (I_draw_contours_opencv == I_draw_contours_external) << std::endl; + << (I_draw_contours_opencv == I_draw_contours_external) << std::endl; #endif return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/imgproc/test/with-dataset/testFloodFill.cpp b/modules/imgproc/test/with-dataset/testFloodFill.cpp index dfe48dcd43..ba3a449f5f 100644 --- a/modules/imgproc/test/with-dataset/testFloodFill.cpp +++ b/modules/imgproc/test/with-dataset/testFloodFill.cpp @@ -31,6 +31,12 @@ * Test flood fill algorithm. */ +/*! + \example testFloodFill.cpp + + \brief Test flood fill algorithm. +*/ + #include #include @@ -39,15 +45,13 @@ #include #include -/*! - \example testFloodFill.cpp - - \brief Test flood fill algorithm. -*/ - // List of allowed command line options #define GETOPTARGS "cdi:o:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); @@ -69,7 +73,7 @@ SYNOPSIS\n\ %s [-i ] [-o ]\n\ [-h]\n \ ", - name); +name); fprintf(stdout, "\n\ OPTIONS: Default\n\ @@ -221,7 +225,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(opath); - } catch (...) { + } + catch (...) { usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << opath << std::endl; @@ -236,8 +241,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -246,9 +251,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath, opt_opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; exit(EXIT_FAILURE); } @@ -256,21 +261,21 @@ int main(int argc, const char **argv) // Here starts really the test // - unsigned char image_data[8 * 8] = {1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, + unsigned char image_data[8 * 8] = { 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, - 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0}; + 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0 }; vpImage I_test_flood_fill_4_connexity(image_data, 8, 8, true); vpImage I_test_flood_fill_8_connexity = I_test_flood_fill_4_connexity; printImage(I_test_flood_fill_4_connexity, "Test image data"); unsigned char image_data_check_4_connexity[8 * 8] = { 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, - 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0}; + 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0 }; vpImage I_check_4_connexity(image_data_check_4_connexity, 8, 8, true); unsigned char image_data_check_8_connexity[8 * 8] = { 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0}; + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0 }; vpImage I_check_8_connexity(image_data_check_8_connexity, 8, 8, true); // Test flood fill on test data 4-connexity @@ -281,9 +286,9 @@ int main(int argc, const char **argv) throw vpException(vpException::fatalError, "Problem with vp::floodFill() and 4-connexity!"); } std::cout << "\n(I_test_flood_fill_4_connexity == I_check_4_connexity)? " - << (I_test_flood_fill_4_connexity == I_check_4_connexity) << std::endl; + << (I_test_flood_fill_4_connexity == I_check_4_connexity) << std::endl; - // Test flood fill on test data 8-connexity +// Test flood fill on test data 8-connexity vp::floodFill(I_test_flood_fill_8_connexity, vpImagePoint(2, 2), 0, 1, vpImageMorphology::CONNEXITY_8); printImage(I_test_flood_fill_8_connexity, "I_test_flood_fill_8_connexity"); @@ -291,15 +296,15 @@ int main(int argc, const char **argv) throw vpException(vpException::fatalError, "Problem with vp::floodFill() and 8-connexity!"); } std::cout << "\n(I_test_flood_fill_8_connexity == I_check_8_connexity)? " - << (I_test_flood_fill_8_connexity == I_check_8_connexity) << std::endl; + << (I_test_flood_fill_8_connexity == I_check_8_connexity) << std::endl; - // Read Klimt.ppm +// Read Klimt.ppm filename = vpIoTools::createFilePath(ipath, "Klimt/Klimt.pgm"); vpImage I_klimt; vpImageIo::read(I_klimt, filename); std::cout << "\nRead image: " << filename << " (" << I_klimt.getWidth() << "x" << I_klimt.getHeight() << ")" - << std::endl - << std::endl; + << std::endl + << std::endl; vpImageTools::binarise(I_klimt, (unsigned char)127, (unsigned char)255, (unsigned char)0, (unsigned char)255, (unsigned char)255); @@ -355,11 +360,11 @@ int main(int argc, const char **argv) // Check std::cout << "\n(I_klimt_flood_fill_4_connexity == " - "I_klimt_flood_fill_4_connexity_check)? " - << (I_klimt_flood_fill_4_connexity == I_klimt_flood_fill_4_connexity_check) << std::endl; + "I_klimt_flood_fill_4_connexity_check)? " + << (I_klimt_flood_fill_4_connexity == I_klimt_flood_fill_4_connexity_check) << std::endl; std::cout << "(I_klimt_flood_fill_8_connexity == " - "I_klimt_flood_fill_8_connexity_check)? " - << (I_klimt_flood_fill_8_connexity == I_klimt_flood_fill_8_connexity_check) << std::endl; + "I_klimt_flood_fill_8_connexity_check)? " + << (I_klimt_flood_fill_8_connexity == I_klimt_flood_fill_8_connexity_check) << std::endl; if (I_klimt_flood_fill_4_connexity != I_klimt_flood_fill_4_connexity_check) { throw vpException(vpException::fatalError, "(I_klimt_flood_fill_4_connexity != " @@ -372,13 +377,14 @@ int main(int argc, const char **argv) std::cout << "\nTest flood fill is ok!" << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.what() << std::endl; return EXIT_FAILURE; } #else - (void) argc; - (void) argv; + (void)argc; + (void)argv; std::cout << "Install OpenCV imgproc module required by this test" << std::endl; return EXIT_SUCCESS; #endif diff --git a/modules/imgproc/test/with-dataset/testImgproc.cpp b/modules/imgproc/test/with-dataset/testImgproc.cpp index 3f2fb03636..9e94047d9c 100644 --- a/modules/imgproc/test/with-dataset/testImgproc.cpp +++ b/modules/imgproc/test/with-dataset/testImgproc.cpp @@ -31,6 +31,12 @@ * Test imgproc functions. */ +/*! + \example testImgproc.cpp + + \brief Test imgproc functions. +*/ + #include #include #include @@ -40,15 +46,13 @@ #include #include -/*! - \example testImgproc.cpp - - \brief Test imgproc functions. -*/ - // List of allowed command line options #define GETOPTARGS "cdi:o:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, std::string ipath, std::string opath, std::string user); bool getOptions(int argc, const char **argv, std::string &ipath, std::string &opath, std::string user); diff --git a/modules/tracker/blob/include/visp3/blob/vpDot.h b/modules/tracker/blob/include/visp3/blob/vpDot.h index 1b52904b82..aa45203df8 100644 --- a/modules/tracker/blob/include/visp3/blob/vpDot.h +++ b/modules/tracker/blob/include/visp3/blob/vpDot.h @@ -62,18 +62,6 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpDot; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot &d); - -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpDot @@ -316,7 +304,7 @@ class VISP_EXPORT vpDot : public vpTracker vpDot &operator=(const vpDot &d); bool operator==(const vpDot &d) const; bool operator!=(const vpDot &d) const; - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, vpDot &d); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot &d); void print(std::ostream &os) { os << *this << std::endl; } diff --git a/modules/tracker/blob/include/visp3/blob/vpDot2.h b/modules/tracker/blob/include/visp3/blob/vpDot2.h index 2a9f239990..063e096b9c 100644 --- a/modules/tracker/blob/include/visp3/blob/vpDot2.h +++ b/modules/tracker/blob/include/visp3/blob/vpDot2.h @@ -56,18 +56,6 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpDot2; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot2 &d); - -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpDot2 @@ -259,7 +247,7 @@ class VISP_EXPORT vpDot2 : public vpTracker unsigned int gray_lvl_max, unsigned int size = 0); vpDot2 &operator=(const vpDot2 &twinDot); - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, vpDot2 &d); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot2 &d); void print(std::ostream &os) { os << *this << std::endl; } void searchDotsInArea(const vpImage &I, int area_u, int area_v, unsigned int area_w, diff --git a/modules/tracker/blob/src/dots/vpDot.cpp b/modules/tracker/blob/src/dots/vpDot.cpp index 29ef78a697..babd671320 100644 --- a/modules/tracker/blob/src/dots/vpDot.cpp +++ b/modules/tracker/blob/src/dots/vpDot.cpp @@ -946,13 +946,13 @@ void vpDot::display(const vpImage &I, const vpImagePoint &cog, const std } } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! Writes the dot center of gravity coordinates in the frame (i,j) (For more details about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, and returns a reference to the stream. */ -VISP_EXPORT std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot &d) { return (os << "(" << d.getCog() << ")"); }; +VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDot &d) { return (os << "(" << d.getCog() << ")"); }; + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/blob/src/dots/vpDot2.cpp b/modules/tracker/blob/src/dots/vpDot2.cpp index e753135714..4eb82ef252 100644 --- a/modules/tracker/blob/src/dots/vpDot2.cpp +++ b/modules/tracker/blob/src/dots/vpDot2.cpp @@ -2505,13 +2505,13 @@ void vpDot2::display(const vpImage &I, const vpImagePoint &cog, const st } } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! Writes the dot center of gravity coordinates in the frame (i,j) (For more details about the orientation of the frame see the vpImagePoint documentation) to the stream \e os, and returns a reference to the stream. */ VISP_EXPORT std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpDot2 &d) { return (os << "(" << d.getCog() << ")"); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/me/include/visp3/me/vpMeSite.h b/modules/tracker/me/include/visp3/me/vpMeSite.h index 9de3ea2eda..a801b97876 100644 --- a/modules/tracker/me/include/visp3/me/vpMeSite.h +++ b/modules/tracker/me/include/visp3/me/vpMeSite.h @@ -48,18 +48,6 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpMeSite; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpMeSite &vpMeS); - -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpMeSite @@ -333,7 +321,7 @@ class VISP_EXPORT vpMeSite /*! * ostream operator. */ - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, vpMeSite &vpMeS); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS); // Static functions /*! diff --git a/modules/tracker/me/src/moving-edges/vpMeSite.cpp b/modules/tracker/me/src/moving-edges/vpMeSite.cpp index 068dfb18df..79b8cc2f5b 100644 --- a/modules/tracker/me/src/moving-edges/vpMeSite.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeSite.cpp @@ -445,11 +445,11 @@ void vpMeSite::display(const vpImage &I, const double &i, const double & } } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - -VISP_EXPORT std::ostream &operator<<(std::ostream &os, VISP_NAMESPACE_ADDRESSING vpMeSite &vpMeS) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpMeSite &vpMeS) { return (os << "Alpha: " << vpMeS.m_alpha << " Convolution: " << vpMeS.m_convlt << " Weight: " << vpMeS.m_weight << " Threshold: " << vpMeS.m_contrastThreshold); } + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h index 34c56a32b2..d148f40357 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMoment.h @@ -54,19 +54,8 @@ namespace VISP_NAMESPACE_NAME class vpMomentObject; class vpMomentDatabase; class vpFeatureMomentDatabase; -class vpFeatureMoment; class vpMoment; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMoment &featM); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpFeatureMoment * @@ -252,7 +241,7 @@ class VISP_EXPORT vpFeatureMoment : public vpBasicFeature void update(double A, double B, double C); //@} - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpFeatureMoment &featM); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM); }; /*! diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h index cd4e803e1a..2a2a0def55 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCInvariant.h @@ -46,18 +46,7 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpFeatureMomentCInvariant; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCInvariant &featcinv); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpFeatureMomentCInvariant * @@ -204,19 +193,8 @@ class VISP_EXPORT vpFeatureMomentCInvariant : public vpFeatureMoment namespace VISP_NAMESPACE_NAME { #endif -class vpFeatureMomentCInvariant; class vpMomentDatabase; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCInvariant &featcinv); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpFeatureMomentCInvariant * @@ -361,7 +339,7 @@ class VISP_EXPORT vpFeatureMomentCInvariant : public vpFeatureMoment */ void printLsofInvariants(std::ostream &os) const; - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpFeatureMomentCInvariant &featcinv); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCInvariant &featcinv); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h index 7298805e38..46db843ea7 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureMomentCentered.h @@ -47,18 +47,7 @@ namespace VISP_NAMESPACE_NAME { #endif class vpMomentDatabase; -class vpFeatureMomentCentered; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCentered &v); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpFeatureMomentCentered * @@ -131,7 +120,7 @@ class VISP_EXPORT vpFeatureMomentCentered : public vpFeatureMoment return "vpFeatureMomentCentered"; } - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpFeatureMomentCentered &v); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCentered &v); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp b/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp index f6c11a5725..fc0218988d 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMoment.cpp @@ -265,15 +265,9 @@ void vpFeatureMoment::printDependencies(std::ostream &os) const "to be implemented in the derived classes!" << std::endl; } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMoment &featM) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpFeatureMoment &featM) { -#ifdef ENABLE_VISP_NAMESPACE - using namespace VISP_NAMESPACE_NAME; -#endif /* * - A static_cast is forced here since interaction() defined in vpBasicFeature() * is not const. But introducing const in vpBasicFeature() can break a lot of @@ -285,3 +279,7 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDR Lcomplete.matlabPrint(os); return os; } + +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp index c700446ba9..a0b5e76103 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentCInvariant.cpp @@ -694,15 +694,12 @@ void vpFeatureMomentCInvariant::printLsofInvariants(std::ostream &os) const os << std::endl; } } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! * \relates vpFeatureMomentCInvariant * Print all the interaction matrices of visual features */ -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCInvariant &featcinv) +std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCInvariant &featcinv) { // Print L for c1 .. c10 for (unsigned int i = 0; i < 10; ++i) { @@ -728,4 +725,7 @@ std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFea return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp b/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp index dc77ef1446..23009a4341 100644 --- a/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp +++ b/modules/visual_features/src/visual-feature/vpFeatureMomentCentered.cpp @@ -319,19 +319,13 @@ void vpFeatureMomentCentered::compute_interaction() } #endif // #ifdef VISP_MOMENTS_COMBINE_MATRICES } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif /*! * \relates vpFeatureMomentCentered * Print all the interaction matrices of visual features */ -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFeatureMomentCentered &mu) +std::ostream &operator<<(std::ostream &os, const vpFeatureMomentCentered &mu) { -#ifdef ENABLE_VISP_NAMESPACE - using namespace VISP_NAMESPACE_NAME; -#endif vpTRACE(" << Ls - CENTRED MOMENTS >>"); unsigned int order_m_1 = (unsigned int)(mu.order - 1); for (unsigned int i = 0; i < order_m_1; i++) { @@ -342,3 +336,6 @@ std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpFea } return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/vs/include/visp3/vs/vpAdaptiveGain.h b/modules/vs/include/visp3/vs/vpAdaptiveGain.h index 2425cd1aa6..124eeaf604 100644 --- a/modules/vs/include/visp3/vs/vpAdaptiveGain.h +++ b/modules/vs/include/visp3/vs/vpAdaptiveGain.h @@ -46,19 +46,8 @@ namespace VISP_NAMESPACE_NAME { #endif -class vpAdaptiveGain; class vpColVector; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpAdaptiveGain &lambda); -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif /*! * \class vpAdaptiveGain * @@ -316,7 +305,7 @@ class VISP_EXPORT vpAdaptiveGain * \param os : The stream where to print the adaptive gain parameters. * \param lambda : The adaptive gain containing the parameters to print. */ - friend VISP_EXPORT std::ostream &::operator<<(std::ostream &os, const vpAdaptiveGain &lambda); + friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpAdaptiveGain &lambda); }; #ifdef ENABLE_VISP_NAMESPACE } diff --git a/modules/vs/src/vpAdaptiveGain.cpp b/modules/vs/src/vpAdaptiveGain.cpp index f1d6e36e54..4f8df7a29b 100644 --- a/modules/vs/src/vpAdaptiveGain.cpp +++ b/modules/vs/src/vpAdaptiveGain.cpp @@ -142,14 +142,14 @@ double vpAdaptiveGain::operator()(void) const { return this->limitValue(); } double vpAdaptiveGain::operator()(const vpColVector &x) const { return this->value(x.infinityNorm()); } -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -VISP_EXPORT std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpAdaptiveGain &lambda) +VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpAdaptiveGain &lambda) { os << "Zero= " << lambda.coeff_a + lambda.coeff_c << "\tInf= " << lambda.coeff_c << "\tSlope= " << lambda.coeff_a * lambda.coeff_b; return os; } + +#ifdef ENABLE_VISP_NAMESPACE +} +#endif From ea809524be91fff85d008cfcb10d4d3209f9774b Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 10:08:06 +0200 Subject: [PATCH 17/64] [FIX] Fixed compilation problem in vpDetectorDNN: from_json and to_json have to be in the same namespace as the type (see https://github.com/nlohmann/json?tab=readme-ov-file#basic-usage) --- .../visp3/detection/vpDetectorDNNOpenCV.h | 323 ++++++++++++++++- .../detection/src/dnn/vpDetectorDNNOpenCV.cpp | 340 ------------------ 2 files changed, 304 insertions(+), 359 deletions(-) diff --git a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h index f3762da05e..49e70eeb4d 100644 --- a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h +++ b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h @@ -53,23 +53,8 @@ #include -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif -class vpDetectorDNNOpenCV; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - -// Forward declaration to have the operator in the global namespace -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network); - #ifdef VISP_HAVE_NLOHMANN_JSON #include -// Forward declaration to have the methods in the global namespace -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network); -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network); #endif #ifdef ENABLE_VISP_NAMESPACE @@ -195,7 +180,295 @@ class VISP_EXPORT vpDetectorDNNOpenCV * \struct NetConfig * \brief Structure containing some information required for the configuration of a \b vpDetectorDNNOpenCV object. */ - class NetConfig; + typedef class NetConfig + { + private: + float m_confThreshold; /*!< Threshold to filter detections by confidence.*/ + float m_nmsThreshold; /*!< Threshold for Non-Maximum Suppression.*/ + std::vector m_classNames;/*!< Vector containing the names of the different classes the DNN can detect.*/ + cv::Size m_inputSize; /*!< Size of the images the DNN can manipulate. The input images will be resized to match these dimensions.*/ + double m_filterSizeRatio; /*!< Size ratio used by the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods. + If <= 0., the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods are not used.*/ + cv::Scalar m_mean; /*!< Values for mean subtraction.*/ + double m_scaleFactor; /*!< Scale factor to normalize pixel values.*/ + bool m_swapRB; /* 0"); + } + + config.m_nmsThreshold = j.value("nmsThreshold", config.m_nmsThreshold); + if (config.m_nmsThreshold <= 0) { + throw vpException(vpException::badValue, "Confidence threshold should be > 0"); + } + + config.m_filterSizeRatio = j.value("filterSizeRatio", config.m_filterSizeRatio); + + config.m_classNames = j.value("classNames", config.m_classNames); + + std::pair resolution = j.value("resolution", std::pair(config.m_inputSize.width, config.m_inputSize.height)); + config.m_inputSize.width = resolution.first; + config.m_inputSize.height = resolution.second; + + std::vector v_mean = j.value("mean", std::vector({ config.m_mean[0], config.m_mean[1], config.m_mean[2] })); + if (v_mean.size() != 3) { + throw(vpException(vpException::dimensionError, "Mean should have size = 3")); + } + config.m_mean = cv::Scalar(v_mean[0], v_mean[1], v_mean[2]); + + config.m_scaleFactor = j.value("scale", config.m_scaleFactor); + config.m_swapRB = j.value("swapRB", config.m_swapRB); + config.m_parsingMethodType = dnnResultsParsingTypeFromString(j.value("parsingType", dnnResultsParsingTypeToString(config.m_parsingMethodType))); + config.m_modelFilename = j.value("modelFile", config.m_modelFilename); + config.m_modelConfigFilename = j.value("configurationFile", config.m_modelConfigFilename); + config.m_framework = j.value("framework", config.m_framework); + } + + /** + * \brief Parse a vpDetectorDNNOpenCV::NetConfig into JSON format. + * + * \param j A JSON parser object. + * \param config The vpDetectorDNNOpenCV::NetConfig that must be parsed into JSON format. + */ + friend inline void to_json(nlohmann::json &j, const NetConfig &config) + { + std::pair resolution = { config.m_inputSize.width, config.m_inputSize.height }; + std::vector v_mean = { config.m_mean[0], config.m_mean[1], config.m_mean[2] }; + j = nlohmann::json { + {"confidenceThreshold", config.m_confThreshold } , + {"nmsThreshold" , config.m_nmsThreshold } , + {"filterSizeRatio" , config.m_filterSizeRatio} , + {"classNames" , config.m_classNames } , + {"resolution" , resolution } , + {"mean" , v_mean } , + {"scale" , config.m_scaleFactor } , + {"swapRB" , config.m_swapRB } , + {"parsingType" , dnnResultsParsingTypeToString(config.m_parsingMethodType) }, + {"modelFile" , config.m_modelFilename } , + {"configurationFile" , config.m_modelConfigFilename } , + {"framework" , config.m_framework } + }; + } +#endif + + public: + /** + * \brief Parse the file containing the list of classes the DNN can detect. + * These classes can be written either as a YAML array (i.e. ["classname_0", ... ,"classname_last"]) + * or with one classname by row (without quotes). + * + * For example, in the case of a yaml file called `my-classes.yaml`, one content could be: + \verbatim + $ cat my-classes.yaml + [ "person", "bicycle", "car"] + \endverbatim + * + * And in the case of a text file called `my-classes.txt`, similar content could be: + \verbatim + $ cat my-classes.txt + person + bicycle + car + \endverbatim + * + * \param filename The path towards the file containing the list of classes the DNN can detect. + * \return std::vector The list of classes the DNN can detect. + */ + inline static std::vector parseClassNamesFile(const std::string &filename) + { + std::vector classNames; + std::ifstream ifs(filename); + std::string line; + while (getline(ifs, line)) { + if (line.find("[") == std::string::npos) { + classNames.push_back(line); + } + else { + std::string lineWithoutBracket; + if (line.find("[") != std::string::npos) { + lineWithoutBracket = line.substr(line.find("[") + 1, line.size() - 2); // Remove opening and closing brackets + } + + while (!lineWithoutBracket.empty()) { + std::string className; + auto start_pos = lineWithoutBracket.find("\""); + auto end_pos = lineWithoutBracket.find("\"", start_pos + 1); + className = lineWithoutBracket.substr(start_pos + 1, end_pos - (start_pos + 1)); + if (!className.empty()) { + classNames.push_back(className); + lineWithoutBracket = lineWithoutBracket.substr(end_pos + 1); + } + } + } + } + return classNames; + } + + /** + * \brief Default constructor of the structure \b vpDetectorDNNOpenCV::NetConfig , required for JSON serialization/deserialization. + */ + inline NetConfig() + : m_confThreshold(0.5f) + , m_nmsThreshold(0.4f) + , m_classNames() + , m_inputSize(300, 300) + , m_filterSizeRatio(0.) + , m_mean(127.5, 127.5, 127.5) + , m_scaleFactor(2.0 / 255.0) + , m_swapRB(true) + , m_parsingMethodType(vpDetectorDNNOpenCV::USER_SPECIFIED) + , m_modelFilename() + , m_modelConfigFilename() + , m_framework() + { + + } + + inline NetConfig(const NetConfig &config) + : m_confThreshold(config.m_confThreshold) + , m_nmsThreshold(config.m_nmsThreshold) + , m_classNames(config.m_classNames) + , m_inputSize(config.m_inputSize.width, config.m_inputSize.height) + , m_filterSizeRatio(config.m_filterSizeRatio) + , m_mean(cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2])) + , m_scaleFactor(config.m_scaleFactor) + , m_swapRB(config.m_swapRB) + , m_parsingMethodType(config.m_parsingMethodType) + , m_modelFilename(config.m_modelFilename) + , m_modelConfigFilename(config.m_modelConfigFilename) + , m_framework(config.m_framework) + { + + } + + /** + * \brief Construct a new Net Config object + * + * \param confThresh The confidence threshold to keep a detection. + * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. + * \param classNames A vector containing the list of classes the DNN can detect. + * \param dnnInputSize The size of the input that the DNN is expecting. + * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput + * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). + * \param mean The mean value we must deduce to each color channel of the image. + * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. + * \param swapRB If true, will swap the red and blue channel of the input image. + * \param parsingType The type of parsing method to use to interpret the DNN raw results. + * \param modelFilename The path towards the DNN weights. + * \param configFilename The path towards the additional DNN configuration file potentially needed. + * \param framework The type of framework used to store the weights of the DNN. + */ + inline NetConfig(float confThresh, const float &nmsThresh, const std::vector &classNames, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. + , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true + , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") + : m_confThreshold(confThresh) + , m_nmsThreshold(nmsThresh) + , m_classNames(classNames) + , m_inputSize(dnnInputSize) + , m_filterSizeRatio(filterSizeRatio) + , m_mean(mean) + , m_scaleFactor(scaleFactor) + , m_swapRB(swapRB) + , m_parsingMethodType(parsingType) + , m_modelFilename(modelFilename) + , m_modelConfigFilename(configFilename) + , m_framework(framework) + { } + + /** + * \brief Construct a new Net Config object + * + * \param confThresh The confidence threshold to keep a detection. + * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. + * \param classNamesFile The path towards the file containing the classes names, written as a YAML string array or one class name by line. + * \param dnnInputSize The size of the input that the DNN is expecting. + * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput + * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). + * \param mean The mean value we must deduce to each color channel of the image. + * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. + * \param swapRB If true, will swap the red and blue channel of the input image. + * \param parsingType The type of parsing method to use to interpret the DNN raw results. + * \param modelFilename The path towards the DNN weights. + * \param configFilename The path towards the additional DNN configuration file potentially needed. + * \param framework The type of framework used to store the weights of the DNN. + */ + inline NetConfig(const float &confThresh, const float &nmsThresh, const std::string &classNamesFile, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. + , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true + , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") + : m_confThreshold(confThresh) + , m_nmsThreshold(nmsThresh) + , m_inputSize(dnnInputSize) + , m_filterSizeRatio(filterSizeRatio) + , m_mean(mean) + , m_scaleFactor(scaleFactor) + , m_swapRB(swapRB) + , m_parsingMethodType(parsingType) + , m_modelFilename(modelFilename) + , m_modelConfigFilename(configFilename) + , m_framework(framework) + { + m_classNames = parseClassNamesFile(classNamesFile); + } + + inline std::string toString() const + { + std::string text; + text += "Model : " + m_modelFilename + "\n"; + text += "Type : " + vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(m_parsingMethodType) + "\n"; + text += "Config (optional): " + (m_modelConfigFilename.empty() ? "\"None\"" : m_modelConfigFilename) + "\n"; + text += "Framework (optional): " + (m_framework.empty() ? "\"None\"" : m_framework) + "\n"; + text += "Width x Height : " + std::to_string(m_inputSize.width) + " x " + std::to_string(m_inputSize.height) + "\n"; + text += "Mean RGB : " + std::to_string(m_mean[0]) + " " + std::to_string(m_mean[1]) + " " + std::to_string(m_mean[2]) + "\n"; + text += "Scale : " + std::to_string(m_scaleFactor) + "\n"; + text += "Swap RB? : " + (m_swapRB ? std::string("true") : std::string("false")) + "\n"; + text += "Confidence threshold : " + std::to_string(m_confThreshold) + "\n"; + text += "NMS threshold : " + std::to_string(m_nmsThreshold) + "\n"; + text += "Filter threshold : " + + (m_filterSizeRatio > std::numeric_limits::epsilon() ? std::to_string(m_filterSizeRatio) + : "disabled") + "\n"; + return text; + } + + friend inline std::ostream &operator<<(std::ostream &os, const NetConfig &config) + { + os << config.toString(); + return os; + } + + NetConfig &operator=(const NetConfig &config) + { + m_confThreshold = config.m_confThreshold; + m_nmsThreshold = config.m_nmsThreshold; + m_classNames = config.m_classNames; + m_inputSize = cv::Size(config.m_inputSize.width, config.m_inputSize.height); + m_filterSizeRatio = config.m_filterSizeRatio; + m_mean = cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2]); + m_scaleFactor = config.m_scaleFactor; + m_swapRB = config.m_swapRB; + m_parsingMethodType = config.m_parsingMethodType; + m_modelFilename = config.m_modelFilename; + m_modelConfigFilename = config.m_modelConfigFilename; + m_framework = config.m_framework; + return *this; + } + + friend vpDetectorDNNOpenCV; + } NetConfig; static std::string getAvailableDnnResultsParsingTypes(); static std::string dnnResultsParsingTypeToString(const DNNResultsParsingType &type); @@ -246,7 +519,10 @@ class VISP_EXPORT vpDetectorDNNOpenCV * \param j The JSON object, resulting from the parsing of a JSON file. * \param network The network, that will be initialized from the JSON data. */ - friend inline void ::from_json(const nlohmann::json &j, vpDetectorDNNOpenCV &network); + friend inline void from_json(const nlohmann::json &j, vpDetectorDNNOpenCV &network) + { + network.m_netConfig = j.value("networkSettings", network.m_netConfig); + } /** * \brief Parse the network configuration into JSON format. @@ -254,10 +530,19 @@ class VISP_EXPORT vpDetectorDNNOpenCV * \param j The JSON parser. * \param network The network we want to parse the configuration. */ - friend inline void ::to_json(nlohmann::json &j, const vpDetectorDNNOpenCV &network); + friend inline void to_json(nlohmann::json &j, const vpDetectorDNNOpenCV &network) + { + j = nlohmann::json { + {"networkSettings", network.m_netConfig} + }; + } #endif - friend inline std::ostream &::operator<<(std::ostream &os, const vpDetectorDNNOpenCV &network); + friend inline std::ostream &operator<<(std::ostream &os, const vpDetectorDNNOpenCV &network) + { + os << network.m_netConfig; + return os; + } protected: #if (VISP_HAVE_OPENCV_VERSION == 0x030403) diff --git a/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp b/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp index 28cac5a001..942b131fe9 100644 --- a/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp +++ b/modules/detection/src/dnn/vpDetectorDNNOpenCV.cpp @@ -44,346 +44,6 @@ #include -// Forward declaration to have the methods in the global namespace -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config); -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config); -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config); - -class VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig -{ -private: - float m_confThreshold; /*!< Threshold to filter detections by confidence.*/ - float m_nmsThreshold; /*!< Threshold for Non-Maximum Suppression.*/ - std::vector m_classNames;/*!< Vector containing the names of the different classes the DNN can detect.*/ - cv::Size m_inputSize; /*!< Size of the images the DNN can manipulate. The input images will be resized to match these dimensions.*/ - double m_filterSizeRatio; /*!< Size ratio used by the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods. - If <= 0., the \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods are not used.*/ - cv::Scalar m_mean; /*!< Values for mean subtraction.*/ - double m_scaleFactor; /*!< Scale factor to normalize pixel values.*/ - bool m_swapRB; /* The list of classes the DNN can detect. - */ - inline static std::vector parseClassNamesFile(const std::string &filename) - { - std::vector classNames; - std::ifstream ifs(filename); - std::string line; - while (getline(ifs, line)) { - if (line.find("[") == std::string::npos) { - classNames.push_back(line); - } - else { - std::string lineWithoutBracket; - if (line.find("[") != std::string::npos) { - lineWithoutBracket = line.substr(line.find("[") + 1, line.size() - 2); // Remove opening and closing brackets - } - - while (!lineWithoutBracket.empty()) { - std::string className; - auto start_pos = lineWithoutBracket.find("\""); - auto end_pos = lineWithoutBracket.find("\"", start_pos + 1); - className = lineWithoutBracket.substr(start_pos + 1, end_pos - (start_pos + 1)); - if (!className.empty()) { - classNames.push_back(className); - lineWithoutBracket = lineWithoutBracket.substr(end_pos + 1); - } - } - } - } - return classNames; - } - - /** - * \brief Default constructor of the structure \b vpDetectorDNNOpenCV::NetConfig , required for JSON serialization/deserialization. - */ - inline NetConfig() - : m_confThreshold(0.5f) - , m_nmsThreshold(0.4f) - , m_classNames() - , m_inputSize(300, 300) - , m_filterSizeRatio(0.) - , m_mean(127.5, 127.5, 127.5) - , m_scaleFactor(2.0 / 255.0) - , m_swapRB(true) - , m_parsingMethodType(vpDetectorDNNOpenCV::USER_SPECIFIED) - , m_modelFilename() - , m_modelConfigFilename() - , m_framework() - { - - } - - inline NetConfig(const NetConfig &config) - : m_confThreshold(config.m_confThreshold) - , m_nmsThreshold(config.m_nmsThreshold) - , m_classNames(config.m_classNames) - , m_inputSize(config.m_inputSize.width, config.m_inputSize.height) - , m_filterSizeRatio(config.m_filterSizeRatio) - , m_mean(cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2])) - , m_scaleFactor(config.m_scaleFactor) - , m_swapRB(config.m_swapRB) - , m_parsingMethodType(config.m_parsingMethodType) - , m_modelFilename(config.m_modelFilename) - , m_modelConfigFilename(config.m_modelConfigFilename) - , m_framework(config.m_framework) - { - - } - - /** - * \brief Construct a new Net Config object - * - * \param confThresh The confidence threshold to keep a detection. - * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. - * \param classNames A vector containing the list of classes the DNN can detect. - * \param dnnInputSize The size of the input that the DNN is expecting. - * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput - * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). - * \param mean The mean value we must deduce to each color channel of the image. - * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. - * \param swapRB If true, will swap the red and blue channel of the input image. - * \param parsingType The type of parsing method to use to interpret the DNN raw results. - * \param modelFilename The path towards the DNN weights. - * \param configFilename The path towards the additional DNN configuration file potentially needed. - * \param framework The type of framework used to store the weights of the DNN. - */ - inline NetConfig(float confThresh, const float &nmsThresh, const std::vector &classNames, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. - , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true - , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") - : m_confThreshold(confThresh) - , m_nmsThreshold(nmsThresh) - , m_classNames(classNames) - , m_inputSize(dnnInputSize) - , m_filterSizeRatio(filterSizeRatio) - , m_mean(mean) - , m_scaleFactor(scaleFactor) - , m_swapRB(swapRB) - , m_parsingMethodType(parsingType) - , m_modelFilename(modelFilename) - , m_modelConfigFilename(configFilename) - , m_framework(framework) - { } - - /** - * \brief Construct a new Net Config object - * - * \param confThresh The confidence threshold to keep a detection. - * \param nmsThresh The Non-Maximum Suppression threshold to merge overlapping detections. - * \param classNamesFile The path towards the file containing the classes names, written as a YAML string array or one class name by line. - * \param dnnInputSize The size of the input that the DNN is expecting. - * \param filterSizeRatio The threshold for the size filter that the user can chose to activate or not (see \b vpDetectorDNNOpenCV::filterDetectionSingleClassInput - * and \b vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information). - * \param mean The mean value we must deduce to each color channel of the image. - * \param scaleFactor The scale factor that will be multiplied to each color channel of the image. - * \param swapRB If true, will swap the red and blue channel of the input image. - * \param parsingType The type of parsing method to use to interpret the DNN raw results. - * \param modelFilename The path towards the DNN weights. - * \param configFilename The path towards the additional DNN configuration file potentially needed. - * \param framework The type of framework used to store the weights of the DNN. - */ - inline NetConfig(const float &confThresh, const float &nmsThresh, const std::string &classNamesFile, const cv::Size &dnnInputSize, const double &filterSizeRatio = 0. - , const cv::Scalar &mean = cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor = 2. / 255., const bool &swapRB = true - , const DNNResultsParsingType &parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename = "", const std::string &configFilename = "", const std::string &framework = "") - : m_confThreshold(confThresh) - , m_nmsThreshold(nmsThresh) - , m_inputSize(dnnInputSize) - , m_filterSizeRatio(filterSizeRatio) - , m_mean(mean) - , m_scaleFactor(scaleFactor) - , m_swapRB(swapRB) - , m_parsingMethodType(parsingType) - , m_modelFilename(modelFilename) - , m_modelConfigFilename(configFilename) - , m_framework(framework) - { - m_classNames = parseClassNamesFile(classNamesFile); - } - - inline std::string toString() const - { - std::string text; - text += "Model : " + m_modelFilename + "\n"; - text += "Type : " + vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(m_parsingMethodType) + "\n"; - text += "Config (optional): " + (m_modelConfigFilename.empty() ? "\"None\"" : m_modelConfigFilename) + "\n"; - text += "Framework (optional): " + (m_framework.empty() ? "\"None\"" : m_framework) + "\n"; - text += "Width x Height : " + std::to_string(m_inputSize.width) + " x " + std::to_string(m_inputSize.height) + "\n"; - text += "Mean RGB : " + std::to_string(m_mean[0]) + " " + std::to_string(m_mean[1]) + " " + std::to_string(m_mean[2]) + "\n"; - text += "Scale : " + std::to_string(m_scaleFactor) + "\n"; - text += "Swap RB? : " + (m_swapRB ? std::string("true") : std::string("false")) + "\n"; - text += "Confidence threshold : " + std::to_string(m_confThreshold) + "\n"; - text += "NMS threshold : " + std::to_string(m_nmsThreshold) + "\n"; - text += "Filter threshold : " + - (m_filterSizeRatio > std::numeric_limits::epsilon() ? std::to_string(m_filterSizeRatio) - : "disabled") + "\n"; - return text; - } - - friend std::ostream &::operator<<(std::ostream &os, const NetConfig &config); - - NetConfig &operator=(const NetConfig &config) - { - m_confThreshold = config.m_confThreshold; - m_nmsThreshold = config.m_nmsThreshold; - m_classNames = config.m_classNames; - m_inputSize = cv::Size(config.m_inputSize.width, config.m_inputSize.height); - m_filterSizeRatio = config.m_filterSizeRatio; - m_mean = cv::Scalar(config.m_mean[0], config.m_mean[1], config.m_mean[2]); - m_scaleFactor = config.m_scaleFactor; - m_swapRB = config.m_swapRB; - m_parsingMethodType = config.m_parsingMethodType; - m_modelFilename = config.m_modelFilename; - m_modelConfigFilename = config.m_modelConfigFilename; - m_framework = config.m_framework; - return *this; - } - - friend vpDetectorDNNOpenCV; -}; - -#ifdef VISP_HAVE_NLOHMANN_JSON -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) -{ -#ifdef ENABLE_VISP_NAMESPACE - using namespace VISP_NAMESPACE_NAME; -#endif - config.m_confThreshold = j.value("confidenceThreshold", config.m_confThreshold); - if (config.m_confThreshold <= 0) { - throw vpException(vpException::badValue, "Confidence threshold should be > 0"); - } - - config.m_nmsThreshold = j.value("nmsThreshold", config.m_nmsThreshold); - if (config.m_nmsThreshold <= 0) { - throw vpException(vpException::badValue, "Confidence threshold should be > 0"); - } - - config.m_filterSizeRatio = j.value("filterSizeRatio", config.m_filterSizeRatio); - - config.m_classNames = j.value("classNames", config.m_classNames); - - std::pair resolution = j.value("resolution", std::pair(config.m_inputSize.width, config.m_inputSize.height)); - config.m_inputSize.width = resolution.first; - config.m_inputSize.height = resolution.second; - - std::vector v_mean = j.value("mean", std::vector({ config.m_mean[0], config.m_mean[1], config.m_mean[2] })); - if (v_mean.size() != 3) { - throw(vpException(vpException::dimensionError, "Mean should have size = 3")); - } - config.m_mean = cv::Scalar(v_mean[0], v_mean[1], v_mean[2]); - - config.m_scaleFactor = j.value("scale", config.m_scaleFactor); - config.m_swapRB = j.value("swapRB", config.m_swapRB); - config.m_parsingMethodType = VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::dnnResultsParsingTypeFromString(j.value("parsingType", dnnResultsParsingTypeToString(config.m_parsingMethodType))); - config.m_modelFilename = j.value("modelFile", config.m_modelFilename); - config.m_modelConfigFilename = j.value("configurationFile", config.m_modelConfigFilename); - config.m_framework = j.value("framework", config.m_framework); -} - -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) -{ -#ifdef ENABLE_VISP_NAMESPACE - using namespace VISP_NAMESPACE_NAME; -#endif - std::pair resolution = { config.m_inputSize.width, config.m_inputSize.height }; - std::vector v_mean = { config.m_mean[0], config.m_mean[1], config.m_mean[2] }; - j = nlohmann::json { - {"confidenceThreshold", config.m_confThreshold } , - {"nmsThreshold" , config.m_nmsThreshold } , - {"filterSizeRatio" , config.m_filterSizeRatio} , - {"classNames" , config.m_classNames } , - {"resolution" , resolution } , - {"mean" , v_mean } , - {"scale" , config.m_scaleFactor } , - {"swapRB" , config.m_swapRB } , - {"parsingType" , VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(config.m_parsingMethodType) }, - {"modelFile" , config.m_modelFilename } , - {"configurationFile" , config.m_modelConfigFilename } , - {"framework" , config.m_framework } - }; -} - -/** - * \brief Read the network configuration from JSON. All values are optional and if an argument is not present, - * the default value defined in the constructor is kept - * - * \param j The JSON object, resulting from the parsing of a JSON file. - * \param network The network, that will be initialized from the JSON data. - */ -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) -{ - network.m_netConfig = j.value("networkSettings", network.m_netConfig); -} - -/** - * \brief Parse the network configuration into JSON format. - * - * \param j The JSON parser. - * \param network The network we want to parse the configuration. - */ -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) -{ - j = nlohmann::json { - {"networkSettings", network.m_netConfig} - }; -} -#endif - -std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV::NetConfig &config) -{ - os << config.toString(); - return os; -} - -inline std::ostream &operator<<(std::ostream &os, const VISP_NAMESPACE_ADDRESSING vpDetectorDNNOpenCV &network) -{ - os << network.m_netConfig; - return os; -} - #ifdef ENABLE_VISP_NAMESPACE namespace VISP_NAMESPACE_NAME { From f54b7ee888afc62ec0b46a74501b37cdee46e61d Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 10:08:56 +0200 Subject: [PATCH 18/64] [CLEAN] Fix a typo in vpCHT --- modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h index 97dd15945a..79f52bf180 100644 --- a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h +++ b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h @@ -52,7 +52,7 @@ #endif #if defined(ENABLE_VISP_NAMESPACE) -namespace visp +namespace VISP_NAMESPACE_NAME { #endif From b9324294ba522cc921ddc87ad8f3070106960871 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 11:02:39 +0200 Subject: [PATCH 19/64] [CORE] visp_mbt now compiles + [FIX] Fix some mistakes in core and tracker/dnn --- modules/core/include/visp3/core/vpArray2D.h | 19 +++--- .../include/visp3/core/vpCameraParameters.h | 62 ++++-------------- .../include/visp3/core/vpCannyEdgeDetection.h | 18 +----- modules/core/include/visp3/core/vpColVector.h | 63 +++++-------------- .../include/visp3/core/vpHomogeneousMatrix.h | 33 ++++------ modules/core/include/visp3/core/vpMatrix.h | 10 +-- .../core/include/visp3/core/vpPoseVector.h | 22 +++---- .../core/src/image/vpCannyEdgeDetection.cpp | 17 +++-- modules/core/src/math/matrix/vpColVector.cpp | 6 +- modules/core/src/math/matrix/vpMatrix.cpp | 35 ++++++----- .../include/visp3/dnn_tracker/vpMegaPose.h | 8 ++- .../visp3/dnn_tracker/vpMegaPoseTracker.h | 12 +++- modules/tracker/dnn/src/vpMegaPose.cpp | 11 +++- modules/tracker/dnn/src/vpMegaPoseTracker.cpp | 18 ++++-- .../include/visp3/mbt/vpMbDepthDenseTracker.h | 8 +++ .../visp3/mbt/vpMbDepthNormalTracker.h | 7 +++ .../include/visp3/mbt/vpMbEdgeKltTracker.h | 8 ++- .../mbt/include/visp3/mbt/vpMbEdgeTracker.h | 10 ++- .../include/visp3/mbt/vpMbGenericTracker.h | 10 ++- .../mbt/include/visp3/mbt/vpMbHiddenFaces.h | 16 +++++ .../mbt/include/visp3/mbt/vpMbKltTracker.h | 8 ++- .../mbt/include/visp3/mbt/vpMbScanLine.h | 20 ++++-- .../mbt/include/visp3/mbt/vpMbTracker.h | 9 ++- .../include/visp3/mbt/vpMbtDistanceCircle.h | 9 ++- .../include/visp3/mbt/vpMbtDistanceCylinder.h | 9 ++- .../visp3/mbt/vpMbtDistanceKltCylinder.h | 8 ++- .../visp3/mbt/vpMbtDistanceKltPoints.h | 8 ++- .../mbt/include/visp3/mbt/vpMbtDistanceLine.h | 9 ++- .../include/visp3/mbt/vpMbtFaceDepthDense.h | 7 +++ .../include/visp3/mbt/vpMbtFaceDepthNormal.h | 21 ++++--- .../mbt/include/visp3/mbt/vpMbtMeEllipse.h | 10 ++- .../mbt/include/visp3/mbt/vpMbtMeLine.h | 9 ++- .../mbt/include/visp3/mbt/vpMbtPolygon.h | 9 ++- .../include/visp3/mbt/vpMbtTukeyEstimator.h | 32 +++++++--- .../include/visp3/mbt/vpMbtXmlGenericParser.h | 8 ++- .../mbt/src/depth/vpMbDepthDenseTracker.cpp | 7 +++ .../mbt/src/depth/vpMbDepthNormalTracker.cpp | 7 +++ .../mbt/src/depth/vpMbtFaceDepthDense.cpp | 7 +++ .../mbt/src/depth/vpMbtFaceDepthNormal.cpp | 7 +++ .../tracker/mbt/src/edge/vpMbEdgeTracker.cpp | 7 +++ .../mbt/src/edge/vpMbtDistanceCircle.cpp | 7 +++ .../mbt/src/edge/vpMbtDistanceCylinder.cpp | 7 +++ .../mbt/src/edge/vpMbtDistanceLine.cpp | 7 +++ .../tracker/mbt/src/edge/vpMbtMeEllipse.cpp | 8 ++- modules/tracker/mbt/src/edge/vpMbtMeLine.cpp | 8 ++- .../mbt/src/hybrid/vpMbEdgeKltTracker.cpp | 8 ++- .../tracker/mbt/src/klt/vpMbKltTracker.cpp | 8 ++- .../mbt/src/klt/vpMbtDistanceKltCylinder.cpp | 7 +++ .../mbt/src/klt/vpMbtDistanceKltPoints.cpp | 8 ++- .../tracker/mbt/src/vpMbGenericTracker.cpp | 7 +++ modules/tracker/mbt/src/vpMbScanLine.cpp | 9 ++- modules/tracker/mbt/src/vpMbTracker.cpp | 8 ++- modules/tracker/mbt/src/vpMbtPolygon.cpp | 7 +++ .../tracker/mbt/src/vpMbtXmlGenericParser.cpp | 8 ++- modules/tracker/me/include/visp3/me/vpMe.h | 33 +++------- 55 files changed, 469 insertions(+), 275 deletions(-) diff --git a/modules/core/include/visp3/core/vpArray2D.h b/modules/core/include/visp3/core/vpArray2D.h index 203d5c7700..cb4b2db12d 100644 --- a/modules/core/include/visp3/core/vpArray2D.h +++ b/modules/core/include/visp3/core/vpArray2D.h @@ -57,13 +57,6 @@ template class vpArray2D; #ifdef VISP_HAVE_NLOHMANN_JSON #include -//template -template -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpArray2D &array); - -//template -template -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpArray2D &array); #endif #if defined(ENABLE_VISP_NAMESPACE) @@ -1037,10 +1030,10 @@ template class vpArray2D #ifdef VISP_HAVE_NLOHMANN_JSON //template template - friend void ::from_json(const nlohmann::json &j, vpArray2D &array); + friend void from_json(const nlohmann::json &j, vpArray2D &array); //template template - friend void ::to_json(nlohmann::json &j, const vpArray2D &array); + friend void to_json(nlohmann::json &j, const vpArray2D &array); #endif /*! @@ -1342,9 +1335,6 @@ template <> inline bool vpArray2D::operator==(const vpArray2D &A) * \relates vpArray2D */ template bool vpArray2D::operator!=(const vpArray2D &A) const { return !(*this == A); } -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif #ifdef VISP_HAVE_NLOHMANN_JSON template @@ -1420,4 +1410,9 @@ inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpArray2D j["data"] = data; } #endif + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/core/include/visp3/core/vpCameraParameters.h b/modules/core/include/visp3/core/vpCameraParameters.h index 0dbb6969f2..44d952b7c3 100644 --- a/modules/core/include/visp3/core/vpCameraParameters.h +++ b/modules/core/include/visp3/core/vpCameraParameters.h @@ -49,25 +49,14 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif - -class vpCameraParameters; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - #ifdef VISP_HAVE_NLOHMANN_JSON #include -// Forward declaration to have the to_json in the global namespace -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam); - -// Forward declaration to have the from_json in the global namespace -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam); #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpCameraParameters @@ -317,11 +306,7 @@ void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCameraParame \endcode */ -class VISP_EXPORT -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif - vpCameraParameters +class VISP_EXPORT vpCameraParameters { friend class vpMeterPixelConversion; friend class vpPixelMeterConversion; @@ -463,26 +448,18 @@ class VISP_EXPORT vpCameraParametersProjType m_projModel; //!< used projection model #ifdef VISP_HAVE_NLOHMANN_JSON - friend void ::to_json(nlohmann::json &j, const vpCameraParameters &cam); - friend void ::from_json(const nlohmann::json &j, vpCameraParameters &cam); + friend void to_json(nlohmann::json &j, const vpCameraParameters &cam); + friend void from_json(const nlohmann::json &j, vpCameraParameters &cam); #endif }; #ifdef VISP_HAVE_NLOHMANN_JSON #include -#if defined(ENABLE_VISP_NAMESPACE) -NLOHMANN_JSON_SERIALIZE_ENUM(visp::vpCameraParameters::vpCameraParametersProjType, { - {visp::vpCameraParameters::perspectiveProjWithoutDistortion, "perspectiveWithoutDistortion"}, - {visp::vpCameraParameters::perspectiveProjWithDistortion, "perspectiveWithDistortion"}, - {visp::vpCameraParameters::ProjWithKannalaBrandtDistortion, "kannalaBrandtDistortion"} - }); -#else NLOHMANN_JSON_SERIALIZE_ENUM(vpCameraParameters::vpCameraParametersProjType, { {vpCameraParameters::perspectiveProjWithoutDistortion, "perspectiveWithoutDistortion"}, {vpCameraParameters::perspectiveProjWithDistortion, "perspectiveWithDistortion"}, {vpCameraParameters::ProjWithKannalaBrandtDistortion, "kannalaBrandtDistortion"} }); -#endif /** * \brief Converts camera parameters into a JSON representation. @@ -490,17 +467,8 @@ NLOHMANN_JSON_SERIALIZE_ENUM(vpCameraParameters::vpCameraParametersProjType, { * \param j The resulting JSON object. * \param cam The camera to serialize. */ -inline void to_json(nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -const visp::vpCameraParameters &cam -#else -const vpCameraParameters &cam -#endif -) +inline void to_json(nlohmann::json &j, const vpCameraParameters &cam) { -#if defined(ENABLE_VISP_NAMESPACE) - using namespace VISP_NAMESPACE_NAME; -#endif j["px"] = cam.m_px; j["py"] = cam.m_py; j["u0"] = cam.m_u0; @@ -552,17 +520,8 @@ const vpCameraParameters &cam * \param j The json object to deserialize. * \param cam The modified camera. */ -inline void from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -visp::vpCameraParameters &cam -#else -vpCameraParameters &cam -#endif -) +inline void from_json(const nlohmann::json &j, vpCameraParameters &cam) { -#if defined(ENABLE_VISP_NAMESPACE) - using namespace VISP_NAMESPACE_NAME; -#endif const double px = j.at("px").get(); const double py = j.at("py").get(); const double u0 = j.at("u0").get(); @@ -591,4 +550,7 @@ vpCameraParameters &cam } } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpCannyEdgeDetection.h b/modules/core/include/visp3/core/vpCannyEdgeDetection.h index 9a2acfa321..62999c02fa 100644 --- a/modules/core/include/visp3/core/vpCannyEdgeDetection.h +++ b/modules/core/include/visp3/core/vpCannyEdgeDetection.h @@ -40,23 +40,9 @@ #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif - -class vpCannyEdgeDetection; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - // 3rd parties include #ifdef VISP_HAVE_NLOHMANN_JSON #include - -// Forward declaration to have the methods in the global namespace -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector); -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector); #endif #if defined(ENABLE_VISP_NAMESPACE) @@ -129,7 +115,7 @@ class VISP_EXPORT vpCannyEdgeDetection * \param[in] j : The JSON object, resulting from the parsing of a JSON file. * \param[out] detector : The detector that will be initialized from the JSON data. */ - friend void ::from_json(const nlohmann::json &j, vpCannyEdgeDetection &detector); + friend void from_json(const nlohmann::json &j, vpCannyEdgeDetection &detector); /** * \brief Parse a vpCannyEdgeDetection object into JSON format. @@ -137,7 +123,7 @@ class VISP_EXPORT vpCannyEdgeDetection * \param[out] j : A JSON parser object. * \param[in] detector : The vpCannyEdgeDetection object that must be parsed into JSON format. */ - friend void ::to_json(nlohmann::json &j, const vpCannyEdgeDetection &detector); + friend void to_json(nlohmann::json &j, const vpCannyEdgeDetection &detector); #endif //@} diff --git a/modules/core/include/visp3/core/vpColVector.h b/modules/core/include/visp3/core/vpColVector.h index 3581b915aa..87e26c49ee 100644 --- a/modules/core/include/visp3/core/vpColVector.h +++ b/modules/core/include/visp3/core/vpColVector.h @@ -42,21 +42,8 @@ #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif - -class vpColVector; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - #ifdef VISP_HAVE_NLOHMANN_JSON #include -// Forward declaration to ensure that the methods are in the global namespace -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpColVector &pose); -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpColVector &pose); #endif #if defined(ENABLE_VISP_NAMESPACE) namespace VISP_NAMESPACE_NAME @@ -77,6 +64,10 @@ class vpPoseVector; #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpColVector * \ingroup group_core_matrices @@ -184,11 +175,7 @@ class vpPoseVector; * {"cols":1,"data":[1.0,2.0,3.0,4.0],"rows":4,"type":"vpColVector"} * \endcode */ -class VISP_EXPORT -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif -vpColVector: public vpArray2D +class VISP_EXPORT vpColVector : public vpArray2D { friend class vpMatrix; @@ -1363,7 +1350,7 @@ vpColVector: public vpArray2D * @param j : Resulting json object. * @param v : The object to convert. */ - friend void ::to_json(nlohmann::json &j, const vpColVector &v); + friend void to_json(nlohmann::json &j, const vpColVector &v); /*! * Retrieve a vpColVector object from a JSON representation. @@ -1371,7 +1358,7 @@ vpColVector: public vpArray2D * @param j : JSON representation to convert. * @param v : Converted object. */ - friend void ::from_json(const nlohmann::json &j, vpColVector &v); + friend void from_json(const nlohmann::json &j, vpColVector &v); #endif #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) @@ -1477,14 +1464,6 @@ vpColVector: public vpArray2D #endif }; -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - /*! * \relates vpColVector * Allows to multiply a scalar by a column vector. @@ -1492,36 +1471,19 @@ namespace VISP_NAMESPACE_NAME #ifndef DOXYGEN_SHOULD_SKIP_THIS VISP_EXPORT #endif -VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpColVector &v); +vpColVector operator*(const double &x, const vpColVector &v); #ifdef VISP_HAVE_NLOHMANN_JSON -inline void to_json(nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -const visp::vpColVector &v -#else -const vpColVector &v -#endif -) +inline void to_json(nlohmann::json &j, const vpColVector &v) { -#if defined(ENABLE_VISP_NAMESPACE) - using namespace VISP_NAMESPACE_NAME; -#endif const vpArray2D *asArray = (vpArray2D*) & v; to_json(j, *asArray); j["type"] = "vpColVector"; } -inline void from_json(const nlohmann::json &j, -#if defined(ENABLE_VISP_NAMESPACE) -visp::vpColVector &v -#else -vpColVector &v -#endif -) + +inline void from_json(const nlohmann::json &j, vpColVector &v) { -#if defined(ENABLE_VISP_NAMESPACE) - using namespace VISP_NAMESPACE_NAME; -#endif vpArray2D *asArray = (vpArray2D*) & v; from_json(j, *asArray); if (v.getCols() != 1) { @@ -1529,4 +1491,7 @@ vpColVector &v } } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpHomogeneousMatrix.h b/modules/core/include/visp3/core/vpHomogeneousMatrix.h index 942f6afc11..855f937a53 100644 --- a/modules/core/include/visp3/core/vpHomogeneousMatrix.h +++ b/modules/core/include/visp3/core/vpHomogeneousMatrix.h @@ -68,21 +68,14 @@ class vpPoint; #include #include -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif -class vpHomogeneousMatrix; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - #ifdef VISP_HAVE_NLOHMANN_JSON #include -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T); -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T); #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpHomogeneousMatrix @@ -217,11 +210,7 @@ void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpHomogeneousM {"cols":4,"data":[0.0,0.0,-1.0,0.1,0.0,-1.0,0.0,0.2,-1.0,0.0,0.0,0.3,0.0,0.0,0.0,1.0],"rows":4,"type":"vpHomogeneousMatrix"} \endcode */ -class VISP_EXPORT -#if defined(ENABLE_VISP_NAMESPACE) - visp:: -#endif -vpHomogeneousMatrix: public vpArray2D +class VISP_EXPORT vpHomogeneousMatrix : public vpArray2D { public: vpHomogeneousMatrix(); @@ -405,8 +394,8 @@ vpHomogeneousMatrix: public vpArray2D public: static const std::string jsonTypeName; private: - friend void ::to_json(nlohmann::json &j, const vpHomogeneousMatrix &T); - friend void ::from_json(const nlohmann::json &j, vpHomogeneousMatrix &T); + friend void to_json(nlohmann::json &j, const vpHomogeneousMatrix &T); + friend void from_json(const nlohmann::json &j, vpHomogeneousMatrix &T); // Conversion helper function to avoid circular dependencies and MSVC errors that are not exported in the DLL void parse_json(const nlohmann::json &j); void convert_to_json(nlohmann::json &j) const; @@ -436,15 +425,17 @@ vpHomogeneousMatrix: public vpArray2D }; #ifdef VISP_HAVE_NLOHMANN_JSON -inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T) +inline void to_json(nlohmann::json &j, const vpHomogeneousMatrix &T) { T.convert_to_json(j); } -inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &T) +inline void from_json(const nlohmann::json &j, vpHomogeneousMatrix &T) { T.parse_json(j); } #endif - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpMatrix.h b/modules/core/include/visp3/core/vpMatrix.h index 14e2719b07..9e70dd87d0 100644 --- a/modules/core/include/visp3/core/vpMatrix.h +++ b/modules/core/include/visp3/core/vpMatrix.h @@ -1209,12 +1209,12 @@ const __declspec(selectany) unsigned int vpMatrix::m_lapack_min_size_default = 0 __declspec(selectany) unsigned int vpMatrix::m_lapack_min_size = vpMatrix::m_lapack_min_size_default; #endif -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - #ifndef DOXYGEN_SHOULD_SKIP_THIS VISP_EXPORT #endif -VISP_NAMESPACE_ADDRESSING vpMatrix operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpMatrix &A); +vpMatrix operator*(const double &x, const vpMatrix &A); + +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif diff --git a/modules/core/include/visp3/core/vpPoseVector.h b/modules/core/include/visp3/core/vpPoseVector.h index a5ef1b9f5d..581882a684 100644 --- a/modules/core/include/visp3/core/vpPoseVector.h +++ b/modules/core/include/visp3/core/vpPoseVector.h @@ -55,7 +55,6 @@ namespace VISP_NAMESPACE_NAME #endif class vpRotationMatrix; class vpHomogeneousMatrix; -class vpPoseVector; class vpTranslationVector; class vpThetaUVector; class vpRowVector; @@ -63,12 +62,6 @@ class vpRowVector; } #endif -#ifdef VISP_HAVE_NLOHMANN_JSON -#include -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); -#endif - #ifdef ENABLE_VISP_NAMESPACE namespace VISP_NAMESPACE_NAME { @@ -319,8 +312,8 @@ class VISP_EXPORT vpPoseVector : public vpArray2D public: static const std::string jsonTypeName; private: - friend void ::to_json(nlohmann::json &j, const vpPoseVector &cam); - friend void ::from_json(const nlohmann::json &j, vpPoseVector &cam); + friend void to_json(nlohmann::json &j, const vpPoseVector &cam); + friend void from_json(const nlohmann::json &j, vpPoseVector &cam); // Conversion helper function to avoid circular dependencies and MSVC errors that are not exported in the DLL void parse_json(const nlohmann::json &j); void convert_to_json(nlohmann::json &j) const; @@ -340,21 +333,20 @@ class VISP_EXPORT vpPoseVector : public vpArray2D //@} #endif }; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif #ifdef VISP_HAVE_NLOHMANN_JSON #include -inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpPoseVector &r) +inline void to_json(nlohmann::json &j, const vpPoseVector &r) { r.convert_to_json(j); } -inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpPoseVector &r) +inline void from_json(const nlohmann::json &j, vpPoseVector &r) { r.parse_json(j); } #endif - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/core/src/image/vpCannyEdgeDetection.cpp b/modules/core/src/image/vpCannyEdgeDetection.cpp index 0548a55d51..17b4e50c20 100644 --- a/modules/core/src/image/vpCannyEdgeDetection.cpp +++ b/modules/core/src/image/vpCannyEdgeDetection.cpp @@ -56,12 +56,13 @@ static void scaleFilter( }; #endif -#ifdef VISP_HAVE_NLOHMANN_JSON -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector) -{ #if defined(ENABLE_VISP_NAMESPACE) - using namespace VISP_NAMESPACE_NAME; +namespace VISP_NAMESPACE_NAME +{ #endif +#ifdef VISP_HAVE_NLOHMANN_JSON +void from_json(const nlohmann::json &j, vpCannyEdgeDetection &detector) +{ std::string filteringAndGradientName = vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); filteringAndGradientName = j.value("filteringAndGradientType", filteringAndGradientName); detector.m_filteringAndGradientType = vpImageFilter::vpCannyFiltAndGradTypeFromStr(filteringAndGradientName); @@ -74,9 +75,9 @@ void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpCannyEdgeDet detector.m_upperThresholdRatio = j.value("upperThresholdRatio", detector.m_upperThresholdRatio); } -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetection &detector) +void to_json(nlohmann::json &j, const vpCannyEdgeDetection &detector) { - std::string filteringAndGradientName = VISP_NAMESPACE_ADDRESSING vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); + std::string filteringAndGradientName = vpImageFilter::vpCannyFiltAndGradTypeToStr(detector.m_filteringAndGradientType); j = nlohmann::json { {"filteringAndGradientType", filteringAndGradientName}, {"gaussianSize", detector.m_gaussianKernelSize}, @@ -90,10 +91,6 @@ void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpCannyEdgeDetec } #endif -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif // // Initialization methods vpCannyEdgeDetection::vpCannyEdgeDetection() diff --git a/modules/core/src/math/matrix/vpColVector.cpp b/modules/core/src/math/matrix/vpColVector.cpp index 36dfcf6bfe..6ea4ee5084 100644 --- a/modules/core/src/math/matrix/vpColVector.cpp +++ b/modules/core/src/math/matrix/vpColVector.cpp @@ -1009,9 +1009,6 @@ void vpColVector::insert(const vpColVector &v, unsigned int r, unsigned int c) double vpColVector::euclideanNorm() const { return frobeniusNorm(); } #endif // defined(VISP_BUILD_DEPRECATED_FUNCTIONS) -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpColVector &v) { @@ -1019,3 +1016,6 @@ VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAME vout = v * x; return vout; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/core/src/math/matrix/vpMatrix.cpp b/modules/core/src/math/matrix/vpMatrix.cpp index bcb406d2ea..579b0a1939 100644 --- a/modules/core/src/math/matrix/vpMatrix.cpp +++ b/modules/core/src/math/matrix/vpMatrix.cpp @@ -62,10 +62,6 @@ #include #endif -#if defined(ENABLE_VISP_NAMESPACE) -namespace VISP_NAMESPACE_NAME -{ -#endif #ifdef VISP_HAVE_LAPACK #ifdef VISP_HAVE_GSL #include @@ -73,6 +69,17 @@ namespace VISP_NAMESPACE_NAME #include #elif defined(VISP_HAVE_MKL) #include +#endif +#endif + +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif + +#ifdef VISP_HAVE_LAPACK +#ifdef VISP_HAVE_GSL +#elif defined(VISP_HAVE_MKL) typedef MKL_INT integer; void vpMatrix::blas_dsyev(char jobz, char uplo, unsigned int n_, double *a_data, unsigned int lda_, double *w_data, @@ -4992,13 +4999,13 @@ Row vector : vpRowVector vpMatrix::getRow(unsigned int i) const { return getRow(i, 0, colNum); } /*! - Extract a row vector from a matrix. - \warning All the indexes start from 0 in this function. - \param i : Index of the row to extract. If i=0, the first row is extracted. - \param j_begin : Index of the column that gives the location of the first - element of the row vector to extract. - \param row_size : Size of the row vector to extract. - \return The extracted row vector. +Extract a row vector from a matrix. +\warning All the indexes start from 0 in this function. +\param i : Index of the row to extract.If i = 0, the first row is extracted. +\param j_begin : Index of the column that gives the location of the first +element of the row vector to extract. +\param row_size : Size of the row vector to extract. +\return The extracted row vector. The following example shows how to use this function: \code @@ -6701,9 +6708,6 @@ void vpMatrix::setIdentity(const double &val) } #endif //#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif /*! \relates vpMatrix @@ -6729,3 +6733,6 @@ VISP_NAMESPACE_ADDRESSING vpMatrix operator*(const double &x, const VISP_NAMESPA return C; } +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h b/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h index 7f1d4f9a33..b2b93e6f28 100644 --- a/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h +++ b/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h @@ -51,6 +51,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \class vpMegaPoseEstimate * \ingroup module_dnn_tracker @@ -245,6 +249,8 @@ class VISP_EXPORT vpMegaPose static vpMegaPose::ServerMessage stringToMessage(const std::string &s); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // VISP_HAVE_NLOHMANN_JSON - #endif diff --git a/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPoseTracker.h b/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPoseTracker.h index 5dc6026b89..f04470f2cc 100644 --- a/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPoseTracker.h +++ b/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPoseTracker.h @@ -43,6 +43,10 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /** * \class vpMegaPoseTracker * \ingroup module_dnn_tracker @@ -119,7 +123,7 @@ class VISP_EXPORT vpMegaPoseTracker * @param[in] bb : The bounding box of the object. * @return A future object that will contain the result of the pose estimation. */ - std::future init(const vpImage &I, const vpRect & bb); + std::future init(const vpImage &I, const vpRect &bb); /** * @brief Initialize tracking from an initial pose. The initial pose should be in the neighborhood of the true pose. * The pose should be expressed in the camera frame. @@ -146,7 +150,7 @@ class VISP_EXPORT vpMegaPoseTracker * * @param[in] cTo : The new pose estimate. */ - void updatePose(const vpHomogeneousMatrix& cTo); + void updatePose(const vpHomogeneousMatrix &cTo); private: std::shared_ptr m_megapose; @@ -155,7 +159,9 @@ class VISP_EXPORT vpMegaPoseTracker int m_refinerIterations; bool m_initialized; }; - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif // VISP_HAVE_NLOHMANN_JSON #endif diff --git a/modules/tracker/dnn/src/vpMegaPose.cpp b/modules/tracker/dnn/src/vpMegaPose.cpp index beb4685fdc..ee5bc498c7 100644 --- a/modules/tracker/dnn/src/vpMegaPose.cpp +++ b/modules/tracker/dnn/src/vpMegaPose.cpp @@ -55,6 +55,11 @@ #include using json = nlohmann::json; //! json namespace shortcut +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif + //// Network message utils /*Encode elements to a buffer of bytes*/ @@ -392,7 +397,7 @@ vpMegaPose::vpMegaPose(const std::string &host, int port, const vpCameraParamete throw vpException(vpException::ioError, "Could not connect to server at " + host + ":" + std::to_string(port)); } setIntrinsics(cam, height, width); - } +} vpMegaPose::~vpMegaPose() { @@ -615,7 +620,9 @@ std::vector vpMegaPose::getObjectNames() std::vector result = jsonValue; return result; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #else // Work around to avoid libvisp_dnn_tracker library empty when threads are not used diff --git a/modules/tracker/dnn/src/vpMegaPoseTracker.cpp b/modules/tracker/dnn/src/vpMegaPoseTracker.cpp index 2edca7407d..ea63f4d77a 100644 --- a/modules/tracker/dnn/src/vpMegaPoseTracker.cpp +++ b/modules/tracker/dnn/src/vpMegaPoseTracker.cpp @@ -40,11 +40,15 @@ #include #include +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif std::future vpMegaPoseTracker::init(const vpImage &I, const vpRect &bb) { return std::async(std::launch::async, [&I, &bb, this]() -> vpMegaPoseEstimate { - std::vector bbs = {bb}; - m_poseEstimate = m_megapose->estimatePoses(I, {m_objectLabel}, nullptr, 0.0, &bbs, nullptr)[0]; + std::vector bbs = { bb }; + m_poseEstimate = m_megapose->estimatePoses(I, { m_objectLabel }, nullptr, 0.0, &bbs, nullptr)[0]; m_initialized = true; return m_poseEstimate; }); @@ -65,8 +69,8 @@ std::future vpMegaPoseTracker::track(const vpImage & throw vpException(vpException::notInitialized, "MegaPose tracker was not initialized. Call init before calling track."); } return std::async(std::launch::async, [&I, this]() -> vpMegaPoseEstimate { - std::vector poses = {m_poseEstimate.cTo}; - m_poseEstimate = m_megapose->estimatePoses(I, {m_objectLabel}, nullptr, 0.0, nullptr, &poses, m_refinerIterations)[0]; + std::vector poses = { m_poseEstimate.cTo }; + m_poseEstimate = m_megapose->estimatePoses(I, { m_objectLabel }, nullptr, 0.0, nullptr, &poses, m_refinerIterations)[0]; return m_poseEstimate; }); } @@ -75,9 +79,11 @@ void vpMegaPoseTracker::updatePose(const vpHomogeneousMatrix &cTo) { m_poseEstimate.cTo = cTo; } - +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_dnn_tracker.a(vpMegaPoseTracker.cpp.o) has no symbols -void dummy_vpMegaPoseTracker(){}; +void dummy_vpMegaPoseTracker() { }; #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h index c50db5f04d..54e143d09b 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthDenseTracker.h @@ -34,6 +34,7 @@ #ifndef _vpMbDepthDenseTracker_h_ #define _vpMbDepthDenseTracker_h_ +#include #include #include #include @@ -43,6 +44,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpMbDepthDenseTracker : public virtual vpMbTracker { public: @@ -170,4 +175,7 @@ class VISP_EXPORT vpMbDepthDenseTracker : public virtual vpMbTracker void segmentPointCloud(const std::vector &point_cloud, unsigned int width, unsigned int height); void segmentPointCloud(const vpMatrix &point_cloud, unsigned int width, unsigned int height); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h index cbced0aaaf..14d9a8788f 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbDepthNormalTracker.h @@ -43,6 +43,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpMbDepthNormalTracker : public virtual vpMbTracker { public: @@ -185,4 +189,7 @@ class VISP_EXPORT vpMbDepthNormalTracker : public virtual vpMbTracker void segmentPointCloud(const std::vector &point_cloud, unsigned int width, unsigned int height); void segmentPointCloud(const vpMatrix &point_cloud, unsigned int width, unsigned int height); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h index e2c0508b4e..d8266669b9 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeKltTracker.h @@ -52,6 +52,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMbEdgeKltTracker * \ingroup group_mbt_trackers @@ -350,7 +354,9 @@ class VISP_EXPORT vpMbEdgeKltTracker : void trackSecondLoop(const vpImage &I, vpMatrix &L, vpColVector &_error, const vpHomogeneousMatrix &cMo, unsigned int lvl = 0); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // VISP_HAVE_OPENCV diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeTracker.h index 866a3fdb36..44b58382ab 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbEdgeTracker.h @@ -39,6 +39,7 @@ #ifndef vpMbEdgeTracker_HH #define vpMbEdgeTracker_HH +#include #include #include #include @@ -73,6 +74,11 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! * \class vpMbEdgeTracker * \ingroup group_mbt_trackers @@ -518,5 +524,7 @@ class VISP_EXPORT vpMbEdgeTracker : public virtual vpMbTracker void visibleFace(const vpImage &_I, const vpHomogeneousMatrix &_cMo, bool &newvisibleline); //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h index 2a20a2b9a3..38efd323ff 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h @@ -50,6 +50,10 @@ #include #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMbGenericTracker * \ingroup group_mbt_trackers @@ -866,7 +870,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(vpMbGenericTracker::vpTrackerType, { {vpMbGenericTracker::EDGE_TRACKER, "edge"}, {vpMbGenericTracker::DEPTH_DENSE_TRACKER, "depthDense"}, {vpMbGenericTracker::DEPTH_NORMAL_TRACKER, "depthNormal"} - }); +}); #endif /** @@ -1072,4 +1076,8 @@ inline void from_json(const nlohmann::json &j, vpMbGenericTracker::TrackerWrappe #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif + #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbHiddenFaces.h b/modules/tracker/mbt/include/visp3/mbt/vpMbHiddenFaces.h index 38c233e647..85b36d60e6 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbHiddenFaces.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbHiddenFaces.h @@ -49,10 +49,22 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif template class vpMbHiddenFaces; +// Forward declaration to have the operator in the global namespace template void swap(vpMbHiddenFaces &first, vpMbHiddenFaces &second); +#ifdef ENABLE_VISP_NAMESPACE +} +#endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMbHiddenFaces * @@ -938,6 +950,10 @@ bool vpMbHiddenFaces::isVisibleOgre(const vpTranslationVector &came return Lpol[index]->isvisible; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif + #endif // VISP_HAVE_OGRE #endif // vpMbHiddenFaces diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h index bc9910aea2..7629e4ac2d 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbKltTracker.h @@ -55,6 +55,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMbKltTracker * \ingroup group_mbt_trackers @@ -472,6 +476,8 @@ class VISP_EXPORT vpMbKltTracker : public virtual vpMbTracker const vpHomogeneousMatrix &cdMo); //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // VISP_HAVE_OPENCV diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbScanLine.h b/modules/tracker/mbt/include/visp3/mbt/vpMbScanLine.h index 35f3b4b984..0488a986ac 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbScanLine.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbScanLine.h @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,10 @@ #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbScanLine @@ -80,8 +85,9 @@ class VISP_EXPORT vpMbScanLine typedef std::pair vpMbScanLineEdge; //! Structure to define a scanline intersection. - struct vpMbScanLineSegment { - vpMbScanLineSegment() : type(START), edge(), p(0), P1(0), P2(0), Z1(0), Z2(0), ID(0), b_sample_Y(false) {} + struct vpMbScanLineSegment + { + vpMbScanLineSegment() : type(START), edge(), p(0), P1(0), P2(0), Z1(0), Z2(0), ID(0), b_sample_Y(false) { } vpMbScanLineType type; vpMbScanLineEdge edge; double p; // This value can be either x or y-coordinate value depending if @@ -93,7 +99,8 @@ class VISP_EXPORT vpMbScanLine }; //! vpMbScanLineEdge Comparator. - struct vpMbScanLineEdgeComparator { + struct vpMbScanLineEdgeComparator + { inline bool operator()(const vpMbScanLineEdge &l0, const vpMbScanLineEdge &l1) const { for (unsigned int i = 0; i < 3; ++i) @@ -111,7 +118,8 @@ class VISP_EXPORT vpMbScanLine }; //! vpMbScanLineSegment Comparators. - struct vpMbScanLineSegmentComparator { + struct vpMbScanLineSegmentComparator + { inline bool operator()(const vpMbScanLineSegment &a, const vpMbScanLineSegment &b) const { // return a.p == b.p ? a.type < b.type : a.p < b.p; @@ -197,7 +205,9 @@ class VISP_EXPORT vpMbScanLine static vpPoint mix(const vpPoint &a, const vpPoint &b, double alpha); static double norm(const vpPoint &a, const vpPoint &b); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // doxygen should skip this #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbTracker.h index 7d21b1216f..822b718571 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbTracker.h @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -79,6 +80,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbTracker \ingroup group_mbt_trackers @@ -914,5 +919,7 @@ class VISP_EXPORT vpMbTracker bool samePoint(const vpPoint &P1, const vpPoint &P2) const; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h index 1a2ed07bfe..58ba876e97 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCircle.h @@ -42,12 +42,17 @@ #define vpMbtDistanceCircle_HH #include +#include #include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbtDistanceCircle @@ -249,5 +254,7 @@ class VISP_EXPORT vpMbtDistanceCircle private: void project(const vpHomogeneousMatrix &cMo); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h index 0e8787b932..5c58627fa9 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceCylinder.h @@ -46,6 +46,7 @@ #define vpMbtDistanceCylinder_HH #include +#include #include #include #include @@ -54,6 +55,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbtDistanceCylinder @@ -281,5 +286,7 @@ class VISP_EXPORT vpMbtDistanceCylinder private: void project(const vpHomogeneousMatrix &cMo); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h index f8ac56233c..b770962365 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltCylinder.h @@ -52,6 +52,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbtDistanceKltCylinder @@ -212,7 +216,9 @@ class VISP_EXPORT vpMbtDistanceKltCylinder void updateMask(cv::Mat &mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // VISP_HAVE_OPENCV diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h index 16c69ae071..3c81ab5145 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceKltPoints.h @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbtDistanceKltPoints @@ -212,7 +216,9 @@ class VISP_EXPORT vpMbtDistanceKltPoints void updateMask(cv::Mat &mask, unsigned char _nb = 255, unsigned int _shiftBorder = 0); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // VISP_HAVE_OPENCV diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h index ac64ea07dc..bb34f3b993 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtDistanceLine.h @@ -44,6 +44,7 @@ #ifndef vpMbtDistanceLine_HH #define vpMbtDistanceLine_HH +#include #include #include #include @@ -54,6 +55,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbtDistanceLine @@ -266,5 +271,7 @@ class VISP_EXPORT vpMbtDistanceLine private: void project(const vpHomogeneousMatrix &cMo); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthDense.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthDense.h index 68ec8f5dad..fc96af3947 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthDense.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthDense.h @@ -50,6 +50,10 @@ #define DEBUG_DISPLAY_DEPTH_DENSE 0 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpMbtFaceDepthDense { public: @@ -239,4 +243,7 @@ class VISP_EXPORT vpMbtFaceDepthDense bool samePoint(const vpPoint &P1, const vpPoint &P2) const; }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h index 6efddf40a6..751dcdc9e5 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h @@ -50,6 +50,10 @@ #define DEBUG_DISPLAY_DEPTH_NORMAL 0 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpMbtFaceDepthNormal { public: @@ -312,19 +316,22 @@ class VISP_EXPORT vpMbtFaceDepthNormal bool samePoint(const vpPoint &P1, const vpPoint &P2) const; }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #ifdef VISP_HAVE_NLOHMANN_JSON #include #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS) -NLOHMANN_JSON_SERIALIZE_ENUM(vpMbtFaceDepthNormal::vpFeatureEstimationType, { - {vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION, "robust"}, - {vpMbtFaceDepthNormal::ROBUST_SVD_PLANE_ESTIMATION, "robustSVD"}, - {vpMbtFaceDepthNormal::PCL_PLANE_ESTIMATION, "pcl"} +NLOHMANN_JSON_SERIALIZE_ENUM(VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::vpFeatureEstimationType, { + {VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION, "robust"}, + {VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::ROBUST_SVD_PLANE_ESTIMATION, "robustSVD"}, + {VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::PCL_PLANE_ESTIMATION, "pcl"} }); #else -NLOHMANN_JSON_SERIALIZE_ENUM(vpMbtFaceDepthNormal::vpFeatureEstimationType, { - {vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION, "robust"}, - {vpMbtFaceDepthNormal::ROBUST_SVD_PLANE_ESTIMATION, "robustSVD"} +NLOHMANN_JSON_SERIALIZE_ENUM(VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::vpFeatureEstimationType, { + {VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION, "robust"}, + {VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::ROBUST_SVD_PLANE_ESTIMATION, "robustSVD"} }); #endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtMeEllipse.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtMeEllipse.h index 9d74be7618..a66232eb24 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtMeEllipse.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtMeEllipse.h @@ -42,10 +42,14 @@ #include #include +#include #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMbtMeEllipse * \ingroup group_mbt_features @@ -77,6 +81,8 @@ class VISP_EXPORT vpMbtMeEllipse : public vpMeEllipse void sample(const vpImage &I, bool doNotTrack = false) vp_override; void suppressPoints(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtMeLine.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtMeLine.h index 16d22ae8cc..b27bc5b418 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtMeLine.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtMeLine.h @@ -39,12 +39,17 @@ #ifndef vpMbtMeLine_HH #define vpMbtMeLine_HH +#include #include #include #include #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMbtMeLine * \brief Implementation of a line used by the model-based tracker. @@ -119,7 +124,9 @@ class VISP_EXPORT vpMbtMeLine : public vpMeTracker void reSample(const vpImage &image, const vpImagePoint &ip1, const vpImagePoint &ip2); void updateDelta(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtPolygon.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtPolygon.h index 7b26bbd01c..3508c6ea34 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtPolygon.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtPolygon.h @@ -39,6 +39,7 @@ #ifndef vpMbtPolygon_HH #define vpMbtPolygon_HH +#include #include #include #include @@ -46,6 +47,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMbtPolygon * @@ -155,5 +160,7 @@ class VISP_EXPORT vpMbtPolygon : public vpPolygon3D */ inline void setIsPolygonOriented(const bool &oriented) { this->hasOrientation = oriented; } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtTukeyEstimator.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtTukeyEstimator.h index 166c90bdba..3de8a6297c 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtTukeyEstimator.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtTukeyEstimator.h @@ -38,9 +38,14 @@ #include #include +#include #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif template class vpMbtTukeyEstimator { public: @@ -58,7 +63,9 @@ template class vpMbtTukeyEstimator std::vector m_residues; }; #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * The code bellow previously in vpMbtTuckeyEstimator.cpp produced * a link issue with MinGW-W64 x86_64-8.1.0-posix-seh-rt_v6-rev0 (g++ 8.1.0) @@ -125,6 +132,10 @@ template struct AbsDiff : public std::binary_function } // namespace #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif template class vpMbtTukeyEstimator; template class vpMbtTukeyEstimator; @@ -251,11 +262,11 @@ inline void vpMbtTukeyEstimator::MEstimator_impl_simd(const std::vector inline void vpMbtTukeyEstimator::MEstimator_impl_simd(const std::vector &residues, std::vector &weights, @@ -303,11 +314,11 @@ inline void vpMbtTukeyEstimator::MEstimator_impl_simd(const std::vector< (void)weights; (void)NoiseThreshold; #endif -} + } -/*! - * \relates vpMbtTukeyEstimator - */ + /*! + * \relates vpMbtTukeyEstimator + */ template <> inline void vpMbtTukeyEstimator::MEstimator(const std::vector &residues, std::vector &weights, float NoiseThreshold) @@ -471,6 +482,9 @@ template void vpMbtTukeyEstimator::psiTukey(const T sig, std::vecto } } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtXmlGenericParser.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtXmlGenericParser.h index e9de44f18e..30b31bc828 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtXmlGenericParser.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtXmlGenericParser.h @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpMbtXmlGenericParser \brief Parse an Xml file to extract configuration parameters of a mbtConfig @@ -164,6 +168,8 @@ class VISP_EXPORT vpMbtXmlGenericParser class Impl; Impl *m_impl; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/tracker/mbt/src/depth/vpMbDepthDenseTracker.cpp b/modules/tracker/mbt/src/depth/vpMbDepthDenseTracker.cpp index 34cb7b6f7f..d258338e32 100644 --- a/modules/tracker/mbt/src/depth/vpMbDepthDenseTracker.cpp +++ b/modules/tracker/mbt/src/depth/vpMbDepthDenseTracker.cpp @@ -52,6 +52,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpMbDepthDenseTracker::vpMbDepthDenseTracker() : m_depthDenseHiddenFacesDisplay(), m_depthDenseListOfActiveFaces(), m_denseDepthNbFeatures(0), m_depthDenseFaces(), m_depthDenseSamplingStepX(2), m_depthDenseSamplingStepY(2), m_error_depthDense(), m_L_depthDense(), @@ -824,3 +828,6 @@ void vpMbDepthDenseTracker::initCylinder(const vpPoint & /*p1*/, const vpPoint & void vpMbDepthDenseTracker::initFaceFromCorners(vpMbtPolygon &polygon) { addFace(polygon, false); } void vpMbDepthDenseTracker::initFaceFromLines(vpMbtPolygon &polygon) { addFace(polygon, true); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/depth/vpMbDepthNormalTracker.cpp b/modules/tracker/mbt/src/depth/vpMbDepthNormalTracker.cpp index 8281bc58cd..f029c450d8 100644 --- a/modules/tracker/mbt/src/depth/vpMbDepthNormalTracker.cpp +++ b/modules/tracker/mbt/src/depth/vpMbDepthNormalTracker.cpp @@ -52,6 +52,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpMbDepthNormalTracker::vpMbDepthNormalTracker() : m_depthNormalFeatureEstimationMethod(vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION), m_depthNormalHiddenFacesDisplay(), m_depthNormalListOfActiveFaces(), m_depthNormalListOfDesiredFeatures(), @@ -902,3 +906,6 @@ void vpMbDepthNormalTracker::initCylinder(const vpPoint & /*p1*/, const vpPoint void vpMbDepthNormalTracker::initFaceFromCorners(vpMbtPolygon &polygon) { addFace(polygon, false); } void vpMbDepthNormalTracker::initFaceFromLines(vpMbtPolygon &polygon) { addFace(polygon, true); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/depth/vpMbtFaceDepthDense.cpp b/modules/tracker/mbt/src/depth/vpMbtFaceDepthDense.cpp index 62993ff533..f169391592 100644 --- a/modules/tracker/mbt/src/depth/vpMbtFaceDepthDense.cpp +++ b/modules/tracker/mbt/src/depth/vpMbtFaceDepthDense.cpp @@ -157,6 +157,10 @@ inline float64x2_t v_fma(const float64x2_t &a, const float64x2_t &b, const float } #endif // !USE_OPENCV_HAL && (USE_SSE || USE_NEON) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpMbtFaceDepthDense::vpMbtFaceDepthDense() : m_cam(), m_clippingFlag(vpPolygon3D::NO_CLIPPING), m_distFarClip(100), m_distNearClip(0.001), m_hiddenFace(nullptr), m_planeObject(), m_polygon(nullptr), m_useScanLine(false), @@ -1000,3 +1004,6 @@ void vpMbtFaceDepthDense::setScanLineVisibilityTest(bool v) (*it)->useScanLine = v; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/depth/vpMbtFaceDepthNormal.cpp b/modules/tracker/mbt/src/depth/vpMbtFaceDepthNormal.cpp index ad726e3af1..e65f9cab77 100644 --- a/modules/tracker/mbt/src/depth/vpMbtFaceDepthNormal.cpp +++ b/modules/tracker/mbt/src/depth/vpMbtFaceDepthNormal.cpp @@ -55,6 +55,10 @@ #define USE_SSE 0 #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpMbtFaceDepthNormal::vpMbtFaceDepthNormal() : m_cam(), m_clippingFlag(vpPolygon3D::NO_CLIPPING), m_distFarClip(100), m_distNearClip(0.001), m_hiddenFace(nullptr), m_planeObject(), m_polygon(nullptr), m_useScanLine(false), m_faceActivated(false), @@ -1834,3 +1838,6 @@ void vpMbtFaceDepthNormal::setScanLineVisibilityTest(bool v) (*it)->useScanLine = v; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/edge/vpMbEdgeTracker.cpp b/modules/tracker/mbt/src/edge/vpMbEdgeTracker.cpp index bcf3ac8c3d..ddf4173154 100644 --- a/modules/tracker/mbt/src/edge/vpMbEdgeTracker.cpp +++ b/modules/tracker/mbt/src/edge/vpMbEdgeTracker.cpp @@ -58,6 +58,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor */ @@ -2984,3 +2988,6 @@ void vpMbEdgeTracker::setUseEdgeTracking(const std::string &name, const bool &us } } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/edge/vpMbtDistanceCircle.cpp b/modules/tracker/mbt/src/edge/vpMbtDistanceCircle.cpp index c0d6e8563a..dbebb6e5c3 100644 --- a/modules/tracker/mbt/src/edge/vpMbtDistanceCircle.cpp +++ b/modules/tracker/mbt/src/edge/vpMbtDistanceCircle.cpp @@ -52,6 +52,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor */ @@ -477,3 +481,6 @@ void vpMbtDistanceCircle::computeInteractionMatrixError(const vpHomogeneousMatri } } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/edge/vpMbtDistanceCylinder.cpp b/modules/tracker/mbt/src/edge/vpMbtDistanceCylinder.cpp index 3213e9b607..4babad9117 100644 --- a/modules/tracker/mbt/src/edge/vpMbtDistanceCylinder.cpp +++ b/modules/tracker/mbt/src/edge/vpMbtDistanceCylinder.cpp @@ -56,6 +56,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor */ @@ -877,3 +881,6 @@ void vpMbtDistanceCylinder::computeInteractionMatrixError(const vpHomogeneousMat } } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/edge/vpMbtDistanceLine.cpp b/modules/tracker/mbt/src/edge/vpMbtDistanceLine.cpp index 78ea9a7e93..2c10a84c15 100644 --- a/modules/tracker/mbt/src/edge/vpMbtDistanceLine.cpp +++ b/modules/tracker/mbt/src/edge/vpMbtDistanceLine.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void buildPlane(vpPoint &P, vpPoint &Q, vpPoint &R, vpPlane &plane); void buildLine(vpPoint &P1, vpPoint &P2, vpPoint &P3, vpPoint &P4, vpLine &L); @@ -927,3 +931,6 @@ bool vpMbtDistanceLine::closeToImageBorder(const vpImage &I, cons } return false; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/edge/vpMbtMeEllipse.cpp b/modules/tracker/mbt/src/edge/vpMbtMeEllipse.cpp index 2329446c52..9d49adc9a3 100644 --- a/modules/tracker/mbt/src/edge/vpMbtMeEllipse.cpp +++ b/modules/tracker/mbt/src/edge/vpMbtMeEllipse.cpp @@ -47,6 +47,10 @@ #include // std::fabs #include // numeric_limits +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor that calls the constructor of the class vpMeTracker. */ @@ -372,5 +376,7 @@ void vpMbtMeEllipse::suppressPoints() ++it; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp b/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp index cada111ec9..e806fbf09c 100644 --- a/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp +++ b/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif //! Normalize an angle between -Pi and Pi static void normalizeAngle(double &delta) { @@ -730,5 +734,7 @@ void vpMbtMeLine::bubbleSortJ() #endif m_meList.sort(sortByJ); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/src/hybrid/vpMbEdgeKltTracker.cpp b/modules/tracker/mbt/src/hybrid/vpMbEdgeKltTracker.cpp index 7b6f892e39..a7e73119ed 100644 --- a/modules/tracker/mbt/src/hybrid/vpMbEdgeKltTracker.cpp +++ b/modules/tracker/mbt/src/hybrid/vpMbEdgeKltTracker.cpp @@ -43,6 +43,10 @@ #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpMbEdgeKltTracker::vpMbEdgeKltTracker() : m_thresholdKLT(2.), m_thresholdMBT(2.), m_maxIterKlt(30), m_w_mbt(), m_w_klt(), m_error_hybrid(), m_w_hybrid() { @@ -1490,7 +1494,9 @@ void vpMbEdgeKltTracker::reInitModel(const vpImage &I, const std: m_cMo = cMo; init(I); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_mbt.a(vpMbEdgeKltTracker.cpp.o) has // no symbols diff --git a/modules/tracker/mbt/src/klt/vpMbKltTracker.cpp b/modules/tracker/mbt/src/klt/vpMbKltTracker.cpp index 44b4835cdc..797162251a 100644 --- a/modules/tracker/mbt/src/klt/vpMbKltTracker.cpp +++ b/modules/tracker/mbt/src/klt/vpMbKltTracker.cpp @@ -45,6 +45,10 @@ #include // To detect OSX or IOS using TARGET_OS_IPHONE or TARGET_OS_IOS macro #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif namespace { /*! @@ -1459,7 +1463,9 @@ void vpMbKltTracker::setUseKltTracking(const std::string &name, const bool &useK } } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_mbt.a(vpMbKltTracker.cpp.o) has no symbols void dummy_vpMbKltTracker() { }; diff --git a/modules/tracker/mbt/src/klt/vpMbtDistanceKltCylinder.cpp b/modules/tracker/mbt/src/klt/vpMbtDistanceKltCylinder.cpp index f3faf464de..162ff98f5b 100644 --- a/modules/tracker/mbt/src/klt/vpMbtDistanceKltCylinder.cpp +++ b/modules/tracker/mbt/src/klt/vpMbtDistanceKltCylinder.cpp @@ -47,6 +47,10 @@ #include // To detect OSX or IOS using TARGET_OS_IPHONE or TARGET_OS_IOS macro #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. @@ -681,6 +685,9 @@ double vpMbtDistanceKltCylinder::computeZ(const double &x, const double &y) return cylinder.computeZ(x, y); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: // libvisp_mbt.a(vpMbtDistanceKltCylinder.cpp.o) has no symbols diff --git a/modules/tracker/mbt/src/klt/vpMbtDistanceKltPoints.cpp b/modules/tracker/mbt/src/klt/vpMbtDistanceKltPoints.cpp index 3ba95f9011..ceaaa7132f 100644 --- a/modules/tracker/mbt/src/klt/vpMbtDistanceKltPoints.cpp +++ b/modules/tracker/mbt/src/klt/vpMbtDistanceKltPoints.cpp @@ -47,6 +47,10 @@ #include // To detect OSX or IOS using TARGET_OS_IPHONE or TARGET_OS_IOS macro #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. @@ -652,7 +656,9 @@ std::vector > vpMbtDistanceKltPoints::getModelForDisplay(con return models; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_mbt.a(vpMbtDistanceKltPoints.cpp.o) // has no symbols diff --git a/modules/tracker/mbt/src/vpMbGenericTracker.cpp b/modules/tracker/mbt/src/vpMbGenericTracker.cpp index 4e9665ffa9..295c638030 100644 --- a/modules/tracker/mbt/src/vpMbGenericTracker.cpp +++ b/modules/tracker/mbt/src/vpMbGenericTracker.cpp @@ -46,6 +46,10 @@ using json = nlohmann::json; //! json namespace shortcut #endif +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif vpMbGenericTracker::vpMbGenericTracker() : m_error(), m_L(), m_mapOfCameraTransformationMatrix(), m_mapOfFeatureFactors(), m_mapOfTrackers(), m_percentageGdPt(0.4), m_referenceCameraName("Camera"), m_thresholdOutlier(0.5), m_w(), m_weightedError(), @@ -7423,3 +7427,6 @@ void vpMbGenericTracker::TrackerWrapper::track(const vpImage *con } } #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif diff --git a/modules/tracker/mbt/src/vpMbScanLine.cpp b/modules/tracker/mbt/src/vpMbScanLine.cpp index e8c7b6275f..421463290f 100644 --- a/modules/tracker/mbt/src/vpMbScanLine.cpp +++ b/modules/tracker/mbt/src/vpMbScanLine.cpp @@ -57,7 +57,10 @@ #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpMbScanLine::vpMbScanLine() : w(0), h(0), K(), maskBorder(0), mask(), primitive_ids(), visibility_samples(), depthTreshold(1e-06) #if defined(DEBUG_DISP) @@ -771,5 +774,7 @@ double vpMbScanLine::norm(const vpPoint &a, const vpPoint &b) return sqrt(vpMath::sqr(a.get_X() - b.get_X()) + vpMath::sqr(a.get_Y() - b.get_Y()) + vpMath::sqr(a.get_Z() - b.get_Z())); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/tracker/mbt/src/vpMbTracker.cpp b/modules/tracker/mbt/src/vpMbTracker.cpp index 7782cca57e..4f4d40dc57 100644 --- a/modules/tracker/mbt/src/vpMbTracker.cpp +++ b/modules/tracker/mbt/src/vpMbTracker.cpp @@ -97,8 +97,11 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS - namespace { #if defined(VISP_HAVE_THREADS) @@ -3874,3 +3877,6 @@ void vpMbTracker::setProjectionErrorKernelSize(const unsigned int &size) m_SobelY.resize(size * 2 + 1, size * 2 + 1, false, false); vpImageFilter::getSobelKernelY(m_SobelY.data, size); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/vpMbtPolygon.cpp b/modules/tracker/mbt/src/vpMbtPolygon.cpp index 3950b3760c..6124acc0e8 100644 --- a/modules/tracker/mbt/src/vpMbtPolygon.cpp +++ b/modules/tracker/mbt/src/vpMbtPolygon.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. */ @@ -268,3 +272,6 @@ int main() \sa setMinLineLengthThresh(), setMinPolygonAreaThresh() */ void vpMbtPolygon::setLod(bool use_lod) { this->useLod = use_lod; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/tracker/mbt/src/vpMbtXmlGenericParser.cpp b/modules/tracker/mbt/src/vpMbtXmlGenericParser.cpp index faf8cee7a3..9fe0a1fb89 100644 --- a/modules/tracker/mbt/src/vpMbtXmlGenericParser.cpp +++ b/modules/tracker/mbt/src/vpMbtXmlGenericParser.cpp @@ -43,6 +43,10 @@ #if defined(VISP_HAVE_PUGIXML) #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpMbtXmlGenericParser::Impl @@ -1916,7 +1920,9 @@ void vpMbtXmlGenericParser::setProjectionErrorKernelSize(const unsigned int &siz \param verbose : verbose flag */ void vpMbtXmlGenericParser::setVerbose(bool verbose) { m_impl->setVerbose(verbose); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_core.a(vpMbtXmlGenericParser.cpp.o) has no symbols void dummy_vpMbtXmlGenericParser() { }; diff --git a/modules/tracker/me/include/visp3/me/vpMe.h b/modules/tracker/me/include/visp3/me/vpMe.h index 005602034f..0b47faf42c 100644 --- a/modules/tracker/me/include/visp3/me/vpMe.h +++ b/modules/tracker/me/include/visp3/me/vpMe.h @@ -44,20 +44,8 @@ #include #include -#ifdef ENABLE_VISP_NAMESPACE -namespace VISP_NAMESPACE_NAME -{ -#endif -class vpMe; -#ifdef ENABLE_VISP_NAMESPACE -} -#endif - #ifdef VISP_HAVE_NLOHMANN_JSON #include -// Forward declaration to have the methods in the global namespace -void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpMe &me); -void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpMe &me); #endif #if defined(ENABLE_VISP_NAMESPACE) @@ -547,7 +535,7 @@ class VISP_EXPORT vpMe * @param j : Resulting json object. * @param me : The object to convert. */ - friend void ::to_json(nlohmann::json &j, const vpMe &me); + friend void to_json(nlohmann::json &j, const vpMe &me); /** * @brief Retrieve a vpMe object from a JSON representation @@ -596,21 +584,17 @@ class VISP_EXPORT vpMe * @param j JSON representation to convert * @param me converted object */ - friend void ::from_json(const nlohmann::json &j, vpMe &me); + friend void from_json(const nlohmann::json &j, vpMe &me); #endif }; -#if defined(ENABLE_VISP_NAMESPACE) -} -#endif - #ifdef VISP_HAVE_NLOHMANN_JSON -NLOHMANN_JSON_SERIALIZE_ENUM(VISP_NAMESPACE_ADDRESSING vpMe::vpLikelihoodThresholdType, { - {VISP_NAMESPACE_ADDRESSING vpMe::vpLikelihoodThresholdType::OLD_THRESHOLD, "old"}, - {VISP_NAMESPACE_ADDRESSING vpMe::vpLikelihoodThresholdType::NORMALIZED_THRESHOLD, "normalized"} +NLOHMANN_JSON_SERIALIZE_ENUM(vpMe::vpLikelihoodThresholdType, { + {vpMe::vpLikelihoodThresholdType::OLD_THRESHOLD, "old"}, + {vpMe::vpLikelihoodThresholdType::NORMALIZED_THRESHOLD, "normalized"} }); -inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpMe &me) +inline void to_json(nlohmann::json &j, const vpMe &me) { j = { {"thresholdType", me.getLikelihoodThresholdType()}, @@ -630,7 +614,7 @@ inline void to_json(nlohmann::json &j, const VISP_NAMESPACE_ADDRESSING vpMe &me) }; } -inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpMe &me) +inline void from_json(const nlohmann::json &j, vpMe &me) { if (j.contains("thresholdType")) { me.setLikelihoodThresholdType(j.value("thresholdType", me.getLikelihoodThresholdType())); @@ -668,4 +652,7 @@ inline void from_json(const nlohmann::json &j, VISP_NAMESPACE_ADDRESSING vpMe &m #endif +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif From 07705aa8142103b69539cdda8f1dbf2ce0073d50 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 14:38:30 +0200 Subject: [PATCH 20/64] [CORE] visp_modules compiles when using ENABLE_VISP_NAMESPACE=ON --- modules/robot/include/visp3/robot/vpAfma4.h | 11 +- modules/robot/include/visp3/robot/vpAfma6.h | 38 +-- modules/robot/include/visp3/robot/vpBiclops.h | 9 +- .../include/visp3/robot/vpImageSimulator.h | 9 +- modules/robot/include/visp3/robot/vpPioneer.h | 9 +- .../robot/include/visp3/robot/vpPioneerPan.h | 9 +- modules/robot/include/visp3/robot/vpPololu.h | 8 +- modules/robot/include/visp3/robot/vpPtu46.h | 10 +- .../robot/include/visp3/robot/vpQbDevice.h | 8 +- .../robot/include/visp3/robot/vpQbSoftHand.h | 8 +- .../include/visp3/robot/vpReflexTakktile2.h | 10 +- .../robot/include/visp3/robot/vpRingLight.h | 15 +- modules/robot/include/visp3/robot/vpRobot.h | 15 +- .../robot/include/visp3/robot/vpRobotAfma4.h | 8 +- .../robot/include/visp3/robot/vpRobotAfma6.h | 8 +- .../robot/include/visp3/robot/vpRobotBebop2.h | 8 +- .../include/visp3/robot/vpRobotBiclops.h | 8 +- .../robot/include/visp3/robot/vpRobotCamera.h | 14 +- .../include/visp3/robot/vpRobotException.h | 15 +- .../include/visp3/robot/vpRobotFlirPtu.h | 14 +- .../robot/include/visp3/robot/vpRobotFranka.h | 8 +- .../robot/include/visp3/robot/vpRobotKinova.h | 16 +- .../robot/include/visp3/robot/vpRobotMavsdk.h | 8 +- .../include/visp3/robot/vpRobotPioneer.h | 8 +- .../include/visp3/robot/vpRobotPololuPtu.h | 9 +- .../robot/include/visp3/robot/vpRobotPtu46.h | 9 +- .../include/visp3/robot/vpRobotSimulator.h | 14 +- .../include/visp3/robot/vpRobotTemplate.h | 14 +- .../visp3/robot/vpRobotUniversalRobots.h | 8 +- .../include/visp3/robot/vpRobotViper650.h | 8 +- .../include/visp3/robot/vpRobotViper850.h | 8 +- .../visp3/robot/vpRobotWireFrameSimulator.h | 14 +- .../robot/include/visp3/robot/vpServolens.h | 26 +- .../include/visp3/robot/vpSimulatorAfma6.h | 15 +- .../include/visp3/robot/vpSimulatorCamera.h | 15 +- .../include/visp3/robot/vpSimulatorPioneer.h | 9 +- .../visp3/robot/vpSimulatorPioneerPan.h | 15 +- .../include/visp3/robot/vpSimulatorViper850.h | 15 +- .../robot/include/visp3/robot/vpUnicycle.h | 9 +- modules/robot/include/visp3/robot/vpViper.h | 17 +- .../robot/include/visp3/robot/vpViper650.h | 19 +- .../robot/include/visp3/robot/vpViper850.h | 21 +- .../robot/include/visp3/robot/vpVirtuose.h | 17 +- .../visp3/robot/vpWireFrameSimulator.h | 15 +- .../visp3/robot/vpWireFrameSimulatorTypes.h | 33 ++- .../src/haptic-device/qbdevice/vpQbDevice.cpp | 8 +- .../haptic-device/qbdevice/vpQbSoftHand.cpp | 7 + .../reflex-takktile/vpReflexTakktile2.cpp | 17 +- .../src/haptic-device/virtuose/vpVirtuose.cpp | 9 +- .../src/image-simulator/vpImageSimulator.cpp | 60 +++-- modules/robot/src/light/vpRingLight.cpp | 18 +- .../robot/src/real-robot/afma4/vpAfma4.cpp | 7 + .../src/real-robot/afma4/vpRobotAfma4.cpp | 8 +- .../src/real-robot/afma4/vpServolens.cpp | 23 +- .../robot/src/real-robot/afma6/vpAfma6.cpp | 7 + .../src/real-robot/afma6/vpRobotAfma6.cpp | 8 +- .../src/real-robot/bebop2/vpRobotBebop2.cpp | 8 +- .../private/vpRobotBiclopsController_impl.cpp | 8 +- .../private/vpRobotBiclopsController_impl.h | 12 +- .../src/real-robot/biclops/vpBiclops.cpp | 7 + .../src/real-robot/biclops/vpRobotBiclops.cpp | 8 +- .../real-robot/flir-ptu/vpRobotFlirPtu.cpp | 8 +- .../franka/vpForceTorqueGenerator_impl.cpp | 174 ++++++------- .../franka/vpForceTorqueGenerator_impl.h | 12 +- .../franka/vpJointPosTrajGenerator_impl.cpp | 41 ++-- .../franka/vpJointPosTrajGenerator_impl.h | 8 +- .../franka/vpJointVelTrajGenerator_impl.cpp | 232 +++++++++--------- .../franka/vpJointVelTrajGenerator_impl.h | 20 +- .../src/real-robot/franka/vpRobotFranka.cpp | 8 +- .../src/real-robot/kinova/vpRobotKinova.cpp | 55 +++-- .../src/real-robot/mavsdk/vpRobotMavsdk.cpp | 8 +- .../src/real-robot/pioneer/vpRobotPioneer.cpp | 8 +- .../real-robot/pololu-maestro/vpPololu.cpp | 8 +- .../pololu-maestro/vpRobotPololuPtu.cpp | 8 +- .../robot/src/real-robot/ptu46/vpPtu46.cpp | 7 + .../src/real-robot/ptu46/vpRobotPtu46.cpp | 8 +- .../vpRobotUniversalRobots.cpp | 8 +- .../src/real-robot/viper/vpRobotViper650.cpp | 8 +- .../src/real-robot/viper/vpRobotViper850.cpp | 8 +- .../robot/src/real-robot/viper/vpViper.cpp | 7 + .../robot/src/real-robot/viper/vpViper650.cpp | 7 + .../robot/src/real-robot/viper/vpViper850.cpp | 7 + .../src/robot-simulator/vpRobotCamera.cpp | 8 +- .../src/robot-simulator/vpRobotSimulator.cpp | 9 +- .../vpRobotWireFrameSimulator.cpp | 8 +- .../src/robot-simulator/vpSimulatorAfma6.cpp | 8 +- .../src/robot-simulator/vpSimulatorCamera.cpp | 7 + .../robot-simulator/vpSimulatorPioneer.cpp | 7 + .../robot-simulator/vpSimulatorPioneerPan.cpp | 7 + .../robot-simulator/vpSimulatorViper850.cpp | 8 +- modules/robot/src/vpRobot.cpp | 22 +- modules/robot/src/vpRobotTemplate.cpp | 10 +- .../robot/src/wireframe-simulator/vpArit.cpp | 32 ++- .../robot/src/wireframe-simulator/vpArit.h | 26 +- .../src/wireframe-simulator/vpAritio.cpp | 13 +- .../robot/src/wireframe-simulator/vpAritio.h | 8 +- .../robot/src/wireframe-simulator/vpBound.cpp | 8 +- .../robot/src/wireframe-simulator/vpBound.h | 23 +- .../src/wireframe-simulator/vpBoundio.cpp | 10 +- .../robot/src/wireframe-simulator/vpBoundio.h | 8 +- .../src/wireframe-simulator/vpClipping.cpp | 22 +- .../src/wireframe-simulator/vpClipping.h | 8 +- .../src/wireframe-simulator/vpCoreDisplay.cpp | 8 +- .../src/wireframe-simulator/vpCoreDisplay.h | 8 +- .../robot/src/wireframe-simulator/vpImstack.h | 9 +- .../src/wireframe-simulator/vpKeyword.cpp | 12 +- .../robot/src/wireframe-simulator/vpKeyword.h | 9 +- .../robot/src/wireframe-simulator/vpLex.cpp | 13 +- modules/robot/src/wireframe-simulator/vpLex.h | 9 +- modules/robot/src/wireframe-simulator/vpMy.h | 8 +- .../robot/src/wireframe-simulator/vpMyio.cpp | 8 +- .../robot/src/wireframe-simulator/vpMyio.h | 8 +- .../src/wireframe-simulator/vpParser.cpp | 8 +- .../robot/src/wireframe-simulator/vpParser.h | 8 +- .../src/wireframe-simulator/vpProjection.cpp | 8 +- .../src/wireframe-simulator/vpProjection.h | 8 +- .../src/wireframe-simulator/vpRfstack.cpp | 13 +- .../robot/src/wireframe-simulator/vpRfstack.h | 8 +- .../robot/src/wireframe-simulator/vpScene.cpp | 19 +- .../robot/src/wireframe-simulator/vpScene.h | 21 +- .../src/wireframe-simulator/vpSkipio.cpp | 8 +- .../robot/src/wireframe-simulator/vpSkipio.h | 8 +- .../src/wireframe-simulator/vpTmstack.cpp | 11 +- .../robot/src/wireframe-simulator/vpTmstack.h | 8 +- .../robot/src/wireframe-simulator/vpToken.cpp | 10 +- .../robot/src/wireframe-simulator/vpToken.h | 11 +- .../robot/src/wireframe-simulator/vpView.h | 20 +- .../src/wireframe-simulator/vpViewio.cpp | 8 +- .../robot/src/wireframe-simulator/vpViewio.h | 8 +- .../src/wireframe-simulator/vpVwstack.cpp | 52 ++-- .../robot/src/wireframe-simulator/vpVwstack.h | 8 +- .../vpWireFrameSimulator.cpp | 7 + modules/robot/test/bebop2/testRobotBebop2.cpp | 49 ++-- .../robot/test/qbdevice/testQbSoftHand.cpp | 3 + modules/robot/test/servo-afma4/testAfma4.cpp | 6 +- .../robot/test/servo-afma4/testRobotAfma4.cpp | 6 +- modules/robot/test/servo-afma6/testAfma6.cpp | 6 +- .../robot/test/servo-afma6/testRobotAfma6.cpp | 6 +- .../test/servo-afma6/testRobotAfma6Pose.cpp | 24 +- .../test/servo-flir-ptu/testRobotFlirPtu.cpp | 3 + .../testFrankaCartForceTorque-2.cpp | 34 ++- .../testFrankaCartForceTorque.cpp | 34 ++- .../servo-franka/testFrankaCartVelocity-2.cpp | 28 ++- .../servo-franka/testFrankaCartVelocity-3.cpp | 28 ++- .../servo-franka/testFrankaCartVelocity.cpp | 28 ++- .../test/servo-franka/testFrankaGetPose.cpp | 60 +++-- .../servo-franka/testFrankaJointPosition.cpp | 25 +- .../servo-franka/testFrankaJointTorque.cpp | 32 ++- .../testFrankaJointVelocity-2.cpp | 25 +- .../testFrankaJointVelocity-3.cpp | 25 +- .../servo-franka/testFrankaJointVelocity.cpp | 28 ++- .../testFrankaJointVelocityLimits.cpp | 27 +- .../testPixhawkDroneKeyboard.cpp | 3 + ...estPixhawkDronePositionAbsoluteControl.cpp | 3 + ...estPixhawkDronePositionRelativeControl.cpp | 3 + .../servo-pixhawk/testPixhawkDroneTakeoff.cpp | 3 + .../testPixhawkDroneVelocityControl.cpp | 3 + .../testPixhawkRoverVelocityControl.cpp | 3 + .../test/servo-pololu/testPololuPosition.cpp | 4 + .../test/servo-pololu/testPololuVelocity.cpp | 4 + .../testUniversalRobotsCartPosition.cpp | 3 + .../testUniversalRobotsCartVelocity.cpp | 3 + .../testUniversalRobotsGetData.cpp | 3 + .../testUniversalRobotsJointPosition.cpp | 3 + .../testUniversalRobotsJointVelocity.cpp | 3 + .../servo-viper/testRobotViper650-frames.cpp | 6 +- .../servo-viper/testRobotViper850-frames.cpp | 7 +- .../test/servo-viper/testRobotViper850.cpp | 20 +- .../servo-viper/testRobotViper850Pose.cpp | 24 +- .../robot/test/servo-viper/testViper650.cpp | 22 +- .../robot/test/servo-viper/testViper850.cpp | 22 +- modules/robot/test/virtuose/testVirtuose.cpp | 5 +- .../robot/test/virtuose/testVirtuoseAfma6.cpp | 14 +- .../test/virtuose/testVirtuoseHapticBox.cpp | 42 ++-- .../test/virtuose/testVirtuoseJointLimits.cpp | 49 ++-- .../virtuose/testVirtuosePeriodicFunction.cpp | 4 + .../test/virtuose/testVirtuoseWithGlove.cpp | 11 +- .../include/visp3/sensor/vp1394CMUGrabber.h | 24 +- .../include/visp3/sensor/vp1394TwoGrabber.h | 35 +-- .../sensor/include/visp3/sensor/vpComedi.h | 8 +- .../include/visp3/sensor/vpDirectShowDevice.h | 9 +- .../visp3/sensor/vpDirectShowGrabber.h | 7 + .../visp3/sensor/vpDirectShowGrabberImpl.h | 9 +- .../visp3/sensor/vpDirectShowSampleGrabberI.h | 8 +- .../visp3/sensor/vpFlyCaptureGrabber.h | 20 +- .../sensor/vpForceTorqueAtiNetFTSensor.h | 8 +- .../visp3/sensor/vpForceTorqueAtiSensor.h | 8 +- .../visp3/sensor/vpForceTorqueIitSensor.h | 11 +- .../sensor/include/visp3/sensor/vpKinect.h | 11 +- .../sensor/include/visp3/sensor/vpLaserScan.h | 14 +- .../include/visp3/sensor/vpLaserScanner.h | 17 +- modules/sensor/include/visp3/sensor/vpMocap.h | 12 +- .../include/visp3/sensor/vpMocapQualisys.h | 8 +- .../include/visp3/sensor/vpMocapVicon.h | 9 +- .../visp3/sensor/vpOccipitalStructure.h | 8 +- .../include/visp3/sensor/vpPylonFactory.h | 25 +- .../include/visp3/sensor/vpPylonGrabber.h | 25 +- .../sensor/include/visp3/sensor/vpRealSense.h | 8 +- .../include/visp3/sensor/vpRealSense2.h | 8 +- .../sensor/include/visp3/sensor/vpScanPoint.h | 22 +- .../sensor/include/visp3/sensor/vpSickLDMRS.h | 21 +- .../include/visp3/sensor/vpUeyeGrabber.h | 8 +- .../include/visp3/sensor/vpV4l2Grabber.h | 8 +- modules/sensor/src/force-torque/vpComedi.cpp | 8 +- .../vpForceTorqueAtiNetFTSensor.cpp | 24 +- .../force-torque/vpForceTorqueAtiSensor.cpp | 16 +- .../force-torque/vpForceTorqueIitSensor.cpp | 20 +- .../framegrabber/1394/vp1394CMUGrabber.cpp | 49 ++-- .../framegrabber/1394/vp1394TwoGrabber.cpp | 88 +++---- .../directshow/vpDirectShowDevice.cpp | 10 +- .../directshow/vpDirectShowGrabber.cpp | 10 +- .../directshow/vpDirectShowGrabberImpl.cpp | 93 +++---- .../directshow/vpDirectShowSampleGrabberI.cpp | 71 ++++-- .../flycapture/vpFlyCaptureGrabber.cpp | 9 +- .../src/framegrabber/pylon/vpPylonFactory.cpp | 10 +- .../framegrabber/pylon/vpPylonGrabberGigE.cpp | 34 ++- .../framegrabber/pylon/vpPylonGrabberGigE.h | 8 +- .../framegrabber/pylon/vpPylonGrabberUsb.cpp | 25 +- .../framegrabber/pylon/vpPylonGrabberUsb.h | 8 +- .../src/framegrabber/ueye/vpUeyeGrabber.cpp | 8 +- .../framegrabber/ueye/vpUeyeGrabber_impl.h | 19 +- .../src/framegrabber/v4l2/vpV4l2Grabber.cpp | 8 +- .../src/laserscanner/sick/vpSickLDMRS.cpp | 28 ++- modules/sensor/src/mocap/vpMocapQualisys.cpp | 46 ++-- modules/sensor/src/mocap/vpMocapVicon.cpp | 28 ++- .../sensor/src/rgb-depth/kinect/vpKinect.cpp | 8 +- .../vpOccipitalStructure.cpp | 8 +- .../src/rgb-depth/realsense/vpRealSense.cpp | 8 +- .../src/rgb-depth/realsense/vpRealSense2.cpp | 8 +- .../rgb-depth/realsense/vpRealSense_impl.h | 7 + .../sensor/test/force-torque/testComedi.cpp | 3 + .../test/force-torque/testForceTorqueAti.cpp | 6 +- .../testForceTorqueAtiNetFTSensor.cpp | 21 +- .../force-torque/testForceTorqueIitSensor.cpp | 6 +- .../test/framegrabber/test1394TwoGrabber.cpp | 8 +- .../test/framegrabber/test1394TwoResetBus.cpp | 8 +- .../test/framegrabber/testPylonGrabber.cpp | 12 +- .../sensor/test/mocap/testMocapQualisys.cpp | 4 + modules/sensor/test/mocap/testMocapVicon.cpp | 4 + .../testOccipitalStructure_Core_images.cpp | 3 + .../testOccipitalStructure_Core_imu.cpp | 3 + .../testOccipitalStructure_Core_pcl.cpp | 3 + .../test/rgb-depth/testRealSense2_D435.cpp | 3 + .../rgb-depth/testRealSense2_D435_align.cpp | 4 + .../rgb-depth/testRealSense2_D435_opencv.cpp | 3 + .../rgb-depth/testRealSense2_D435_pcl.cpp | 3 + .../test/rgb-depth/testRealSense2_SR300.cpp | 4 + .../rgb-depth/testRealSense2_T265_images.cpp | 3 + .../testRealSense2_T265_images_odometry.cpp | 3 + ...tRealSense2_T265_images_odometry_async.cpp | 3 + .../rgb-depth/testRealSense2_T265_imu.cpp | 3 + .../testRealSense2_T265_odometry.cpp | 3 + .../testRealSense2_T265_undistort.cpp | 3 + 253 files changed, 2762 insertions(+), 1153 deletions(-) diff --git a/modules/robot/include/visp3/robot/vpAfma4.h b/modules/robot/include/visp3/robot/vpAfma4.h index f203268fe7..562fc3a7e5 100644 --- a/modules/robot/include/visp3/robot/vpAfma4.h +++ b/modules/robot/include/visp3/robot/vpAfma4.h @@ -99,17 +99,22 @@ */ #include +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpAfma4 { public: vpAfma4(); /*! Destructor that does nothing. */ - virtual ~vpAfma4(){}; + virtual ~vpAfma4() { }; /** @name Inherited functionalities from vpAfma4 */ //@{ @@ -150,7 +155,9 @@ class VISP_EXPORT vpAfma4 vpHomogeneousMatrix _eMc; // Camera extrinsic parameters: effector to camera }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * Local variables: * c-basic-offset: 2 diff --git a/modules/robot/include/visp3/robot/vpAfma6.h b/modules/robot/include/visp3/robot/vpAfma6.h index f916f45d46..bffaeba5f3 100644 --- a/modules/robot/include/visp3/robot/vpAfma6.h +++ b/modules/robot/include/visp3/robot/vpAfma6.h @@ -33,9 +33,6 @@ * *****************************************************************************/ -#ifndef _vpAfma6_h -#define _vpAfma6_h - /*! \file vpAfma6.h @@ -44,6 +41,21 @@ */ +#ifndef _vpAfma6_h +#define _vpAfma6_h + +#include + +#include +#include +#include +#include +#include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpAfma6 @@ -65,13 +77,6 @@ set this tool during robot initialisation or using set_eMc(). */ - -#include -#include -#include -#include -#include - class VISP_EXPORT vpAfma6 { public: @@ -120,7 +125,8 @@ class VISP_EXPORT vpAfma6 static const char *const CONST_INTEL_D435_CAMERA_NAME; //! List of possible tools that can be attached to the robot end-effector. - typedef enum { + typedef enum + { TOOL_CCMOP, /*!< Pneumatic CCMOP gripper. */ TOOL_GRIPPER, /*!< Pneumatic gripper with 2 fingers. */ TOOL_VACUUM, /*!< Pneumatic vaccum gripper. */ @@ -135,7 +141,7 @@ class VISP_EXPORT vpAfma6 public: vpAfma6(); /*! Destructor that does nothing. */ - virtual ~vpAfma6(){}; + virtual ~vpAfma6() { }; /** @name Inherited functionalities from vpAfma6 */ //@{ @@ -145,8 +151,8 @@ class VISP_EXPORT vpAfma6 void init(vpAfma6::vpAfma6ToolType tool, const std::string &filename); void init(vpAfma6::vpAfma6ToolType tool, const vpHomogeneousMatrix &eMc_); void - init(vpAfma6::vpAfma6ToolType tool, - vpCameraParameters::vpCameraParametersProjType projModel = vpCameraParameters::perspectiveProjWithoutDistortion); + init(vpAfma6::vpAfma6ToolType tool, + vpCameraParameters::vpCameraParametersProjType projModel = vpCameraParameters::perspectiveProjWithoutDistortion); vpHomogeneousMatrix getForwardKinematics(const vpColVector &q) const; int getInverseKinematics(const vpHomogeneousMatrix &fMc, vpColVector &q, const bool &nearest = true, @@ -211,5 +217,7 @@ class VISP_EXPORT vpAfma6 // Used projection model vpCameraParameters::vpCameraParametersProjType projModel; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpBiclops.h b/modules/robot/include/visp3/robot/vpBiclops.h index e0af4beac1..8a31393891 100644 --- a/modules/robot/include/visp3/robot/vpBiclops.h +++ b/modules/robot/include/visp3/robot/vpBiclops.h @@ -36,11 +36,16 @@ #include +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpBiclops * @@ -319,5 +324,7 @@ class VISP_EXPORT vpBiclops */ friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpBiclops &dummy); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpImageSimulator.h b/modules/robot/include/visp3/robot/vpImageSimulator.h index e781d4bd47..b09faff0cc 100644 --- a/modules/robot/include/visp3/robot/vpImageSimulator.h +++ b/modules/robot/include/visp3/robot/vpImageSimulator.h @@ -129,6 +129,7 @@ #include #include +#include #include #include #include @@ -138,6 +139,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpImageSimulator { public: @@ -302,7 +307,9 @@ class VISP_EXPORT vpImageSimulator void getRoi(const unsigned int &Iwidth, const unsigned int &Iheight, const vpCameraParameters &cam, const std::vector &point, vpRect &rect); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif /* diff --git a/modules/robot/include/visp3/robot/vpPioneer.h b/modules/robot/include/visp3/robot/vpPioneer.h index daed355600..9f441856fd 100644 --- a/modules/robot/include/visp3/robot/vpPioneer.h +++ b/modules/robot/include/visp3/robot/vpPioneer.h @@ -33,10 +33,15 @@ #ifndef VPPIONEER_H #define VPPIONEER_H +#include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpPioneer * @@ -138,5 +143,7 @@ class VISP_EXPORT vpPioneer : public vpUnicycle eJe_[5][1] = 1; // wz } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpPioneerPan.h b/modules/robot/include/visp3/robot/vpPioneerPan.h index e8d882b639..45b5c2ed23 100644 --- a/modules/robot/include/visp3/robot/vpPioneerPan.h +++ b/modules/robot/include/visp3/robot/vpPioneerPan.h @@ -33,11 +33,16 @@ #ifndef VPPIONEERPAN_H #define VPPIONEERPAN_H +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpPioneerPan * @@ -222,5 +227,7 @@ class VISP_EXPORT vpPioneerPan : public vpUnicycle vpHomogeneousMatrix mMp_; // constant vpHomogeneousMatrix pMe_; // depends on q pan }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpPololu.h b/modules/robot/include/visp3/robot/vpPololu.h index c0d62ab647..8a9c7a726c 100644 --- a/modules/robot/include/visp3/robot/vpPololu.h +++ b/modules/robot/include/visp3/robot/vpPololu.h @@ -44,6 +44,10 @@ class RPMSerialInterface; +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpPololu * \ingroup group_robot_real_arm @@ -328,6 +332,8 @@ class VISP_EXPORT vpPololu */ void VelocityCmdThread(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpPtu46.h b/modules/robot/include/visp3/robot/vpPtu46.h index 01c8ab91a0..25fd67620d 100644 --- a/modules/robot/include/visp3/robot/vpPtu46.h +++ b/modules/robot/include/visp3/robot/vpPtu46.h @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpPtu46 @@ -81,7 +85,7 @@ class VISP_EXPORT vpPtu46 public: /* Methodes publiques */ vpPtu46(void); /*! Destructor that does nothing. */ - virtual ~vpPtu46(){}; + virtual ~vpPtu46() { }; /** @name Inherited functionalities from vpPtu46 */ //@{ @@ -99,5 +103,7 @@ class VISP_EXPORT vpPtu46 //@} friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpPtu46 &constant); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpQbDevice.h b/modules/robot/include/visp3/robot/vpQbDevice.h index 034df6731e..8e37faaaf6 100644 --- a/modules/robot/include/visp3/robot/vpQbDevice.h +++ b/modules/robot/include/visp3/robot/vpQbDevice.h @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpQbDevice @@ -112,6 +116,8 @@ class VISP_EXPORT vpQbDevice int m_max_repeats; //!< Max number of trials to send a command. bool m_init_done; //!< Flag used to indicate if the device is initialized. }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpQbSoftHand.h b/modules/robot/include/visp3/robot/vpQbSoftHand.h index 3b26d947fc..76e5a752a2 100644 --- a/modules/robot/include/visp3/robot/vpQbSoftHand.h +++ b/modules/robot/include/visp3/robot/vpQbSoftHand.h @@ -40,6 +40,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpQbSoftHand * @@ -95,6 +99,8 @@ class VISP_EXPORT vpQbSoftHand : public vpQbDevice void setPosition(const vpColVector &position, const int &id = 1); void setPosition(const vpColVector &position, double speed_factor, double stiffness, const int &id = 1); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpReflexTakktile2.h b/modules/robot/include/visp3/robot/vpReflexTakktile2.h index e5ef4be753..1fca78976e 100644 --- a/modules/robot/include/visp3/robot/vpReflexTakktile2.h +++ b/modules/robot/include/visp3/robot/vpReflexTakktile2.h @@ -44,6 +44,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpReflexTakktile2 @@ -84,7 +88,7 @@ class VISP_EXPORT vpReflexTakktile2 std::vector error_state; HandInfo(); - ~HandInfo() {} + ~HandInfo() { } friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const HandInfo &hand); }; @@ -155,6 +159,8 @@ class VISP_EXPORT vpReflexTakktile2 class Impl; Impl *m_impl; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpRingLight.h b/modules/robot/include/visp3/robot/vpRingLight.h index bbcc213837..eb4e3ba4c9 100644 --- a/modules/robot/include/visp3/robot/vpRingLight.h +++ b/modules/robot/include/visp3/robot/vpRingLight.h @@ -33,14 +33,14 @@ * *****************************************************************************/ -#ifndef vpRingLight_h -#define vpRingLight_h - /*! \file vpRingLight.h \brief Ring light management under unix. */ +#ifndef vpRingLight_h +#define vpRingLight_h + #include #if defined(VISP_HAVE_MODULE_IO) && defined(VISP_HAVE_PARPORT) @@ -49,6 +49,11 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRingLight @@ -117,7 +122,9 @@ class VISP_EXPORT vpRingLight private: vpParallelPort parport; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobot.h b/modules/robot/include/visp3/robot/vpRobot.h index afe660e3ae..dd933776bc 100644 --- a/modules/robot/include/visp3/robot/vpRobot.h +++ b/modules/robot/include/visp3/robot/vpRobot.h @@ -33,19 +33,24 @@ * *****************************************************************************/ -#ifndef vpRobot_H -#define vpRobot_H - /*! \file vpRobot.h \brief class that defines a generic virtual robot */ +#ifndef vpRobot_H +#define vpRobot_H + #include +#include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobot \ingroup group_robot_real_gantry group_robot_real_cylindrical @@ -181,5 +186,7 @@ class VISP_EXPORT vpRobot vpControlFrameType getRobotFrame(void) const { return frameRobot; } //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotAfma4.h b/modules/robot/include/visp3/robot/vpRobotAfma4.h index 3f32584850..49af4e02e8 100644 --- a/modules/robot/include/visp3/robot/vpRobotAfma4.h +++ b/modules/robot/include/visp3/robot/vpRobotAfma4.h @@ -54,6 +54,10 @@ extern "C" { #include "trycatch.h" } +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotAfma4 @@ -266,6 +270,8 @@ class VISP_EXPORT vpRobotAfma4 : public vpAfma4, public vpRobot void stopMotion(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif /* #ifndef vpRobotAfma4_h */ diff --git a/modules/robot/include/visp3/robot/vpRobotAfma6.h b/modules/robot/include/visp3/robot/vpRobotAfma6.h index a31f56d6d8..121e996c39 100644 --- a/modules/robot/include/visp3/robot/vpRobotAfma6.h +++ b/modules/robot/include/visp3/robot/vpRobotAfma6.h @@ -55,6 +55,10 @@ extern "C" { #include "trycatch.h" } +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotAfma6 @@ -315,6 +319,8 @@ class VISP_EXPORT vpRobotAfma6 : public vpAfma6, public vpRobot void stopMotion(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif /* #ifndef vpRobotAfma6_h */ diff --git a/modules/robot/include/visp3/robot/vpRobotBebop2.h b/modules/robot/include/visp3/robot/vpRobotBebop2.h index 3c4576607b..e8e9244e58 100644 --- a/modules/robot/include/visp3/robot/vpRobotBebop2.h +++ b/modules/robot/include/visp3/robot/vpRobotBebop2.h @@ -59,6 +59,10 @@ extern "C" { #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotBebop2 @@ -249,6 +253,8 @@ class VISP_EXPORT vpRobotBebop2 ARCONTROLLER_DICTIONARY_ELEMENT_t *elementDictionary, void *customData); //*** ***// }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif //#ifdef VISP_HAVE_ARSDK #endif //#ifndef _vpRobotBebop2_h_ diff --git a/modules/robot/include/visp3/robot/vpRobotBiclops.h b/modules/robot/include/visp3/robot/vpRobotBiclops.h index d4c0ac0416..82b82d7219 100644 --- a/modules/robot/include/visp3/robot/vpRobotBiclops.h +++ b/modules/robot/include/visp3/robot/vpRobotBiclops.h @@ -57,6 +57,10 @@ /* --- CLASS -------------------------------------------------------------- */ /* ------------------------------------------------------------------------ */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotBiclops * @@ -439,7 +443,9 @@ class VISP_EXPORT vpRobotBiclops : public vpBiclops, public vpRobot // } //#endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif /* #ifndef _vpRobotBiclops_h_ */ #endif diff --git a/modules/robot/include/visp3/robot/vpRobotCamera.h b/modules/robot/include/visp3/robot/vpRobotCamera.h index 5eace8d3ce..f5556d4a4a 100644 --- a/modules/robot/include/visp3/robot/vpRobotCamera.h +++ b/modules/robot/include/visp3/robot/vpRobotCamera.h @@ -33,14 +33,14 @@ * *****************************************************************************/ -#ifndef vpRobotCamera_H -#define vpRobotCamera_H - /*! \file vpRobotCamera.h \brief class that defines the simplest robot : a free flying camera */ +#ifndef vpRobotCamera_H +#define vpRobotCamera_H + #include #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotCamera \ingroup group_robot_simu_camera @@ -132,6 +136,8 @@ class VISP_EXPORT vpRobotCamera : public vpRobotSimulator void getDisplacement(const vpRobot::vpControlFrameType /* frame */, vpColVector & /* q */) vp_override { }; void setPosition(const vpRobot::vpControlFrameType /* frame */, const vpColVector & /* q */) vp_override { }; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotException.h b/modules/robot/include/visp3/robot/vpRobotException.h index acf7b01cee..b47d7795c5 100644 --- a/modules/robot/include/visp3/robot/vpRobotException.h +++ b/modules/robot/include/visp3/robot/vpRobotException.h @@ -31,19 +31,24 @@ * Exception that can be emitted by the vpRobot class and its derivatives. */ -#ifndef _vpRobotException_h_ -#define _vpRobotException_h_ - /*! * \file vpRobotException.h * \brief error that can be emitted by the vpRobot class and its derivatives */ +#ifndef _vpRobotException_h_ +#define _vpRobotException_h_ + +#include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotException * \brief Error that can be emitted by the vpRobot class and its derivatives. @@ -115,5 +120,7 @@ class VISP_EXPORT vpRobotException : public vpException */ explicit vpRobotException(int id) : vpException(id) { } }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotFlirPtu.h b/modules/robot/include/visp3/robot/vpRobotFlirPtu.h index 1000af16d4..d581d5ff9b 100644 --- a/modules/robot/include/visp3/robot/vpRobotFlirPtu.h +++ b/modules/robot/include/visp3/robot/vpRobotFlirPtu.h @@ -33,14 +33,14 @@ * *****************************************************************************/ -#ifndef vpRobotFlirPtu_h -#define vpRobotFlirPtu_h - /*! \file vpRobotFlirPtu.h Interface for Flir Ptu Cpi robot. */ +#ifndef vpRobotFlirPtu_h +#define vpRobotFlirPtu_h + #include #ifdef VISP_HAVE_FLIR_PTU_SDK @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotFlirPtu \ingroup group_robot_real_arm @@ -166,6 +170,8 @@ class VISP_EXPORT vpRobotFlirPtu : public vpRobot int m_njoints; double m_positioning_velocity; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotFranka.h b/modules/robot/include/visp3/robot/vpRobotFranka.h index 22b3d632ab..fafa046ebf 100644 --- a/modules/robot/include/visp3/robot/vpRobotFranka.h +++ b/modules/robot/include/visp3/robot/vpRobotFranka.h @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotFranka * @@ -353,6 +357,8 @@ class VISP_EXPORT vpRobotFranka : public vpRobot void stopMotion(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // #ifndef __vpRobotFranka_h_ diff --git a/modules/robot/include/visp3/robot/vpRobotKinova.h b/modules/robot/include/visp3/robot/vpRobotKinova.h index 885483b683..044ebe53f9 100644 --- a/modules/robot/include/visp3/robot/vpRobotKinova.h +++ b/modules/robot/include/visp3/robot/vpRobotKinova.h @@ -33,9 +33,6 @@ * *****************************************************************************/ -#ifndef vpRobotKinova_h -#define vpRobotKinova_h - /*! \file vpRobotKinova.h @@ -44,6 +41,9 @@ */ +#ifndef vpRobotKinova_h +#define vpRobotKinova_h + #include #ifdef VISP_HAVE_JACOSDK @@ -60,7 +60,7 @@ #elif _WIN32 #include #include -#include +#include #include #include #include @@ -69,6 +69,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotKinova @@ -178,6 +182,8 @@ class VISP_EXPORT vpRobotKinova : public vpRobot int (*KinovaSetAngularControl)(); int (*KinovaSetCartesianControl)(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotMavsdk.h b/modules/robot/include/visp3/robot/vpRobotMavsdk.h index 376fcd2025..6b126d6242 100644 --- a/modules/robot/include/visp3/robot/vpRobotMavsdk.h +++ b/modules/robot/include/visp3/robot/vpRobotMavsdk.h @@ -51,6 +51,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotMavsdk * @@ -157,6 +161,8 @@ class VISP_EXPORT vpRobotMavsdk class vpRobotMavsdkImpl; vpRobotMavsdkImpl *m_impl; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifdef VISP_HAVE_MAVSDK #endif // #ifndef vpRobotMavsdk_h_ diff --git a/modules/robot/include/visp3/robot/vpRobotPioneer.h b/modules/robot/include/visp3/robot/vpRobotPioneer.h index 6c6f847e43..8afaabad0e 100644 --- a/modules/robot/include/visp3/robot/vpRobotPioneer.h +++ b/modules/robot/include/visp3/robot/vpRobotPioneer.h @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotPioneer * @@ -130,7 +134,9 @@ class VISP_EXPORT vpRobotPioneer : public vpRobot, public vpPioneer, public ArRo protected: bool isInitialized; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // VPROBOTPIONEER_H diff --git a/modules/robot/include/visp3/robot/vpRobotPololuPtu.h b/modules/robot/include/visp3/robot/vpRobotPololuPtu.h index 4620c8567a..1efb91a647 100644 --- a/modules/robot/include/visp3/robot/vpRobotPololuPtu.h +++ b/modules/robot/include/visp3/robot/vpRobotPololuPtu.h @@ -41,7 +41,10 @@ #include #include - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotPololuPtu * \ingroup group_robot_real_arm @@ -268,6 +271,8 @@ class VISP_EXPORT vpRobotPololuPtu : public vpRobot bool m_verbose; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotPtu46.h b/modules/robot/include/visp3/robot/vpRobotPtu46.h index 302f48fe22..58376b0400 100644 --- a/modules/robot/include/visp3/robot/vpRobotPtu46.h +++ b/modules/robot/include/visp3/robot/vpRobotPtu46.h @@ -59,7 +59,10 @@ /* ------------------------------------------------------------------------ */ /* --- CLASS ------------------------------------------------------------- */ /* ------------------------------------------------------------------------ */ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotPtu46 @@ -122,7 +125,9 @@ class VISP_EXPORT vpRobotPtu46 : public vpPtu46, public vpRobot void stopMotion(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif /* #ifndef _vpRobotPtu46_h_ */ #endif diff --git a/modules/robot/include/visp3/robot/vpRobotSimulator.h b/modules/robot/include/visp3/robot/vpRobotSimulator.h index b6d87cbe0d..f2e37583a9 100644 --- a/modules/robot/include/visp3/robot/vpRobotSimulator.h +++ b/modules/robot/include/visp3/robot/vpRobotSimulator.h @@ -31,19 +31,23 @@ * Basic class used to make robot simulators. */ -#ifndef vpRobotSimulator_HH -#define vpRobotSimulator_HH - /*! * \file vpRobotSimulator.h * \brief Basic class used to make robot simulators. */ +#ifndef vpRobotSimulator_HH +#define vpRobotSimulator_HH + #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotSimulator * @@ -80,5 +84,7 @@ class VISP_EXPORT vpRobotSimulator : public vpRobot virtual inline void setSamplingTime(const double &delta_t) { this->delta_t_ = delta_t; } //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotTemplate.h b/modules/robot/include/visp3/robot/vpRobotTemplate.h index 0b732f1871..8f88a34d08 100644 --- a/modules/robot/include/visp3/robot/vpRobotTemplate.h +++ b/modules/robot/include/visp3/robot/vpRobotTemplate.h @@ -31,19 +31,23 @@ * Defines a robot just to show which function you must implement. */ -#ifndef vpRobotTemplate_h -#define vpRobotTemplate_h - /*! * \file vpRobotTemplate.h * Defines a robot just to show which function you must implement. */ +#ifndef vpRobotTemplate_h +#define vpRobotTemplate_h + #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotTemplate * \ingroup group_robot_real_template @@ -84,5 +88,7 @@ class VISP_EXPORT vpRobotTemplate : public vpRobot protected: vpHomogeneousMatrix m_eMc; //!< Constant transformation between end-effector and tool (or camera) frame }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotUniversalRobots.h b/modules/robot/include/visp3/robot/vpRobotUniversalRobots.h index 3ea8684179..cbea11b83e 100644 --- a/modules/robot/include/visp3/robot/vpRobotUniversalRobots.h +++ b/modules/robot/include/visp3/robot/vpRobotUniversalRobots.h @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotUniversalRobots @@ -136,6 +140,8 @@ class VISP_EXPORT vpRobotUniversalRobots : public vpRobot double m_max_linear_acceleration; vpRobot::vpControlFrameType m_vel_control_frame; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpRobotViper650.h b/modules/robot/include/visp3/robot/vpRobotViper650.h index 5b1a9323b7..885daa2108 100644 --- a/modules/robot/include/visp3/robot/vpRobotViper650.h +++ b/modules/robot/include/visp3/robot/vpRobotViper650.h @@ -55,6 +55,10 @@ extern "C" { #include "trycatch.h" } +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRobotViper650 @@ -465,6 +469,8 @@ class VISP_EXPORT vpRobotViper650 : public vpViper650, public vpRobot private: double m_maxRotationVelocity_joint6; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif /* #ifndef vpRobotViper650_h */ diff --git a/modules/robot/include/visp3/robot/vpRobotViper850.h b/modules/robot/include/visp3/robot/vpRobotViper850.h index ba9ea8b336..db5e57bdd7 100644 --- a/modules/robot/include/visp3/robot/vpRobotViper850.h +++ b/modules/robot/include/visp3/robot/vpRobotViper850.h @@ -63,6 +63,10 @@ extern "C" { #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ! \class vpRobotViper850 @@ -478,6 +482,8 @@ class VISP_EXPORT vpRobotViper850 : public vpViper850, public vpRobot private: double maxRotationVelocity_joint6; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif /* #ifndef vpRobotViper850_h */ diff --git a/modules/robot/include/visp3/robot/vpRobotWireFrameSimulator.h b/modules/robot/include/visp3/robot/vpRobotWireFrameSimulator.h index a84db8f60c..f33cd0baed 100644 --- a/modules/robot/include/visp3/robot/vpRobotWireFrameSimulator.h +++ b/modules/robot/include/visp3/robot/vpRobotWireFrameSimulator.h @@ -31,14 +31,14 @@ * Basic class used to make robot simulators. */ -#ifndef vpRobotWireFrameSimulator_HH -#define vpRobotWireFrameSimulator_HH - /*! * \file vpRobotWireFrameSimulator.h * \brief Basic class used to make robot simulators. */ +#ifndef vpRobotWireFrameSimulator_HH +#define vpRobotWireFrameSimulator_HH + #include #if defined(VISP_HAVE_MODULE_GUI) && defined(VISP_HAVE_THREADS) @@ -58,6 +58,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpRobotWireFrameSimulator * @@ -411,6 +415,8 @@ class VISP_EXPORT vpRobotWireFrameSimulator : protected vpWireFrameSimulator, pu virtual void get_fMi(vpHomogeneousMatrix *fMit) = 0; //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpServolens.h b/modules/robot/include/visp3/robot/vpServolens.h index fbffd072c0..67249095e4 100644 --- a/modules/robot/include/visp3/robot/vpServolens.h +++ b/modules/robot/include/visp3/robot/vpServolens.h @@ -34,13 +34,6 @@ * *****************************************************************************/ -#ifndef _vpServolens_h_ -#define _vpServolens_h_ - -#include - -#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) - /*! \file vpServolens.h @@ -50,9 +43,21 @@ */ +#ifndef _vpServolens_h_ +#define _vpServolens_h_ + +#include + +#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) + #include +#include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpServolens @@ -90,7 +95,8 @@ class VISP_EXPORT vpServolens { public: typedef enum { ZOOM = 1, FOCUS = 2, IRIS = 3 } vpServoType; - typedef enum { + typedef enum + { ZOOM_MAX = 10000, // Valeur maxi zoom (mm/100) ZOOM_MIN = 1000, // Valeur mini zoom (mm/100) FOCUS_MAX = 1500, // Valeur maxi focus (metres/100) @@ -130,6 +136,8 @@ class VISP_EXPORT vpServolens int remfd; // file pointer of the host's tty bool isinit; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpSimulatorAfma6.h b/modules/robot/include/visp3/robot/vpSimulatorAfma6.h index b15ebe6bdf..f20f336122 100644 --- a/modules/robot/include/visp3/robot/vpSimulatorAfma6.h +++ b/modules/robot/include/visp3/robot/vpSimulatorAfma6.h @@ -31,14 +31,15 @@ * Class which provides a simulator for the robot Afma6. */ -#ifndef vpSimulatorAfma6_HH -#define vpSimulatorAfma6_HH - /*! * \file vpSimulatorAfma6.h * \brief Class which provides a simulator for the robot Afma6. */ +#ifndef vpSimulatorAfma6_HH +#define vpSimulatorAfma6_HH + +#include #include #include @@ -46,6 +47,10 @@ #if defined(VISP_HAVE_MODULE_GUI) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpSimulatorAfma6 * @@ -257,7 +262,9 @@ class VISP_EXPORT vpSimulatorAfma6 : public vpRobotWireFrameSimulator, public vp void updateArticularPosition() vp_override; //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpSimulatorCamera.h b/modules/robot/include/visp3/robot/vpSimulatorCamera.h index fa3c77c01b..afafb3024a 100644 --- a/modules/robot/include/visp3/robot/vpSimulatorCamera.h +++ b/modules/robot/include/visp3/robot/vpSimulatorCamera.h @@ -31,20 +31,25 @@ * Defines the simplest robot : a free flying camera. */ -#ifndef vpSimulatorCamera_H -#define vpSimulatorCamera_H - /*! * \file vpSimulatorCamera.h * \brief class that defines the simplest robot : a free flying camera */ +#ifndef vpSimulatorCamera_H +#define vpSimulatorCamera_H + #include +#include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpSimulatorCamera * @@ -128,5 +133,7 @@ class VISP_EXPORT vpSimulatorCamera : public vpRobotSimulator void getDisplacement(const vpRobot::vpControlFrameType /* frame */, vpColVector & /* q */) vp_override { }; void setPosition(const vpRobot::vpControlFrameType /* frame */, const vpColVector & /* q */) vp_override { }; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpSimulatorPioneer.h b/modules/robot/include/visp3/robot/vpSimulatorPioneer.h index 7df272f7b4..9bc5b4dc67 100644 --- a/modules/robot/include/visp3/robot/vpSimulatorPioneer.h +++ b/modules/robot/include/visp3/robot/vpSimulatorPioneer.h @@ -41,12 +41,17 @@ */ #include +#include #include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpSimulatorPioneer * @@ -130,5 +135,7 @@ class VISP_EXPORT vpSimulatorPioneer : public vpPioneer, public vpRobotSimulator void getDisplacement(const vpRobot::vpControlFrameType /* frame */, vpColVector & /* q */) vp_override { }; void setPosition(const vpRobot::vpControlFrameType /* frame */, const vpColVector & /* q */) vp_override { }; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpSimulatorPioneerPan.h b/modules/robot/include/visp3/robot/vpSimulatorPioneerPan.h index 5af9d8d45c..690ef1c8f3 100644 --- a/modules/robot/include/visp3/robot/vpSimulatorPioneerPan.h +++ b/modules/robot/include/visp3/robot/vpSimulatorPioneerPan.h @@ -31,22 +31,27 @@ * Pioneer mobile robot equipped with a pan head simulator without display. */ -#ifndef vpSimulatorPioneerPan_H -#define vpSimulatorPioneerPan_H - /*! * \file vpSimulatorPioneerPan.h * \brief class that defines the Pioneer mobile robot simulator equipped * with a camera able to move in pan. */ +#ifndef vpSimulatorPioneerPan_H +#define vpSimulatorPioneerPan_H + #include +#include #include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpSimulatorPioneerPan * @@ -131,5 +136,7 @@ class VISP_EXPORT vpSimulatorPioneerPan : public vpPioneerPan, public vpRobotSim void getDisplacement(const vpRobot::vpControlFrameType /* frame */, vpColVector & /* q */) vp_override { }; void setPosition(const vpRobot::vpControlFrameType /* frame */, const vpColVector & /* q */) vp_override { }; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpSimulatorViper850.h b/modules/robot/include/visp3/robot/vpSimulatorViper850.h index 854f7646f9..b849c86cba 100644 --- a/modules/robot/include/visp3/robot/vpSimulatorViper850.h +++ b/modules/robot/include/visp3/robot/vpSimulatorViper850.h @@ -31,14 +31,15 @@ * Class which provides a simulator for the robot Viper850. */ -#ifndef vpSimulatorViper850_HH -#define vpSimulatorViper850_HH - /*! * \file vpSimulatorViper850.h * \brief Class which provides a simulator for the robot Viper850.. */ +#ifndef vpSimulatorViper850_HH +#define vpSimulatorViper850_HH + +#include #include #if defined(VISP_HAVE_MODULE_GUI) && defined(VISP_HAVE_THREADS) @@ -46,6 +47,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpSimulatorViper850 * @@ -284,7 +289,9 @@ class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public void updateArticularPosition() vp_override; //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpUnicycle.h b/modules/robot/include/visp3/robot/vpUnicycle.h index 15e74fed3d..67d6d12d07 100644 --- a/modules/robot/include/visp3/robot/vpUnicycle.h +++ b/modules/robot/include/visp3/robot/vpUnicycle.h @@ -33,10 +33,15 @@ #ifndef VPUNICYCLE_H #define VPUNICYCLE_H +#include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpUnicycle * @@ -114,5 +119,7 @@ class VISP_EXPORT vpUnicycle vpHomogeneousMatrix cMe_; // Camera frame to mobile platform frame vpMatrix eJe_; // Robot jacobian }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpViper.h b/modules/robot/include/visp3/robot/vpViper.h index 465f81500a..4fcb6c7332 100644 --- a/modules/robot/include/visp3/robot/vpViper.h +++ b/modules/robot/include/visp3/robot/vpViper.h @@ -33,9 +33,6 @@ * *****************************************************************************/ -#ifndef vpViper_h -#define vpViper_h - /*! \file vpViper.h @@ -44,13 +41,21 @@ */ +#ifndef vpViper_h +#define vpViper_h + #include +#include #include #include #include #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpViper @@ -111,7 +116,7 @@ class VISP_EXPORT vpViper { public: vpViper(); - virtual ~vpViper(){}; + virtual ~vpViper() { }; /** @name Inherited functionalities from vpViper */ //@{ @@ -169,5 +174,7 @@ class VISP_EXPORT vpViper vpColVector joint_max; // Maximal value of the joints vpColVector joint_min; // Minimal value of the joints }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpViper650.h b/modules/robot/include/visp3/robot/vpViper650.h index ab2082ae04..8a39f65c07 100644 --- a/modules/robot/include/visp3/robot/vpViper650.h +++ b/modules/robot/include/visp3/robot/vpViper650.h @@ -31,17 +31,22 @@ * Interface for the ADEPT Viper 650 robot. */ -#ifndef vpViper650_h -#define vpViper650_h - -#include - /*! * \file vpViper650.h * * Modelization of the ADEPT Viper 650 robot. */ +#ifndef vpViper650_h +#define vpViper650_h + +#include +#include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpViper650 * @@ -165,5 +170,7 @@ class VISP_EXPORT vpViper650 : public vpViper // Used projection model vpCameraParameters::vpCameraParametersProjType projModel; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpViper850.h b/modules/robot/include/visp3/robot/vpViper850.h index 2a04d80c5a..93d93d2586 100644 --- a/modules/robot/include/visp3/robot/vpViper850.h +++ b/modules/robot/include/visp3/robot/vpViper850.h @@ -31,19 +31,22 @@ * Interface for the ADEPT Viper 850 robot. */ -#ifndef vpViper850_h -#define vpViper850_h - - -#include -#include - /*! * \file vpViper850.h * * Modelization of the ADEPT Viper 850 robot. */ +#ifndef vpViper850_h +#define vpViper850_h + +#include +#include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpViper850 * @@ -167,5 +170,7 @@ class VISP_EXPORT vpViper850 : public vpViper // Used projection model vpCameraParameters::vpCameraParametersProjType projModel; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpVirtuose.h b/modules/robot/include/visp3/robot/vpVirtuose.h index 80222a272f..257bffa3c7 100644 --- a/modules/robot/include/visp3/robot/vpVirtuose.h +++ b/modules/robot/include/visp3/robot/vpVirtuose.h @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + \file vpVirtuose.h + \brief Wrapper over Haption Virtuose SDK to control haptic devices. +*/ + #ifndef _vpVirtuose_h_ #define _vpVirtuose_h_ @@ -45,10 +50,10 @@ #include -/*! - \file vpVirtuose.h - \brief Wrapper over Haption Virtuose SDK to control haptic devices. -*/ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpVirtuose \ingroup group_robot_haptic @@ -225,6 +230,8 @@ class VISP_EXPORT vpVirtuose float m_period; unsigned int m_njoints; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/include/visp3/robot/vpWireFrameSimulator.h b/modules/robot/include/visp3/robot/vpWireFrameSimulator.h index 88d0d29a63..167aa23280 100644 --- a/modules/robot/include/visp3/robot/vpWireFrameSimulator.h +++ b/modules/robot/include/visp3/robot/vpWireFrameSimulator.h @@ -33,13 +33,14 @@ * *****************************************************************************/ -#ifndef vpWireFrameSimulator_HH -#define vpWireFrameSimulator_HH - /*! \file vpWireFrameSimulator.h \brief Implementation of a wire frame simulator. */ + +#ifndef vpWireFrameSimulator_HH +#define vpWireFrameSimulator_HH + #include // std::fabs #include #include // numeric_limits @@ -58,6 +59,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpWireFrameSimulator @@ -603,5 +608,7 @@ class VISP_EXPORT vpWireFrameSimulator const vpHomogeneousMatrix &fMo, const vpHomogeneousMatrix &cMf); //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/include/visp3/robot/vpWireFrameSimulatorTypes.h b/modules/robot/include/visp3/robot/vpWireFrameSimulatorTypes.h index 3ae751a3b6..c3d25bac4d 100644 --- a/modules/robot/include/visp3/robot/vpWireFrameSimulatorTypes.h +++ b/modules/robot/include/visp3/robot/vpWireFrameSimulatorTypes.h @@ -39,7 +39,10 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif typedef unsigned short Index; typedef char Type; typedef float Matrix[4][4]; @@ -64,13 +67,15 @@ typedef float Matrix[4][4]; * sommets: si (nbr > DEFAULT_VSIZE) | alors ptr est alloue et libere * dynamiquement | sinon ptr = tbl fsi; */ -typedef struct { +typedef struct +{ Index nbr; /* nombre de sommets */ Index *ptr; /* liste dynamique */ Index tbl[DEFAULT_VSIZE]; } Vertex_list; -typedef struct { +typedef struct +{ unsigned is_polygonal : 1; /* face polygonale */ unsigned is_visible : 1; /* face affichable */ #ifdef face_edge @@ -82,21 +87,25 @@ typedef struct { #endif // face_normal } Face; -typedef struct { +typedef struct +{ Index nbr; /* nombre de faces */ Face *ptr; /* liste dynamique */ } Face_list; -typedef struct { +typedef struct +{ float x, y, z; } Point3f; -typedef struct { +typedef struct +{ Index nbr; /* nombre de points */ Point3f *ptr; /* liste dynamique */ } Point3f_list; -typedef struct { +typedef struct +{ unsigned is_display : 1; /* surface affichable */ unsigned is_polygonal : 1; /* surface polyedrique */ Type type; /* type de la primitive */ @@ -110,15 +119,19 @@ typedef struct { #endif // face_normal } Bound; -typedef struct { +typedef struct +{ Index nbr; /* nombre de surfaces */ Bound *ptr; /* liste dynamique */ } Bound_list; -typedef struct { +typedef struct +{ char *name; /* nom de la scene */ Bound_list bound; /* liste de surfaces */ } Bound_scene; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/haptic-device/qbdevice/vpQbDevice.cpp b/modules/robot/src/haptic-device/qbdevice/vpQbDevice.cpp index 7c022269f1..e65ee361e5 100644 --- a/modules/robot/src/haptic-device/qbdevice/vpQbDevice.cpp +++ b/modules/robot/src/haptic-device/qbdevice/vpQbDevice.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpQbDevice::Impl { @@ -737,5 +741,7 @@ void vpQbDevice::setMaxRepeats(const int &max_repeats) m_max_repeats = max_repeats; m_impl->setMaxRepeats(m_max_repeats); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/haptic-device/qbdevice/vpQbSoftHand.cpp b/modules/robot/src/haptic-device/qbdevice/vpQbSoftHand.cpp index 5f5e3c3322..11393b24d0 100644 --- a/modules/robot/src/haptic-device/qbdevice/vpQbSoftHand.cpp +++ b/modules/robot/src/haptic-device/qbdevice/vpQbSoftHand.cpp @@ -40,6 +40,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor that does nothing. * To connect to a device call init(). @@ -204,4 +208,7 @@ void vpQbSoftHand::setPosition(const vpColVector &position, double speed_factor, vpTime::wait(t0, delta_t); } while (!vpMath::equal(q[0], position[0], precision) && !(current_failures > 1)); } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/haptic-device/reflex-takktile/vpReflexTakktile2.cpp b/modules/robot/src/haptic-device/reflex-takktile/vpReflexTakktile2.cpp index 667abc5a34..e6a6ed80c3 100644 --- a/modules/robot/src/haptic-device/reflex-takktile/vpReflexTakktile2.cpp +++ b/modules/robot/src/haptic-device/reflex-takktile/vpReflexTakktile2.cpp @@ -42,13 +42,17 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpReflexTakktile2::Impl : public reflex_driver2::ReflexDriver { public: - Impl() {} + Impl() { } - ~Impl() {} + ~Impl() { } }; #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -119,9 +123,8 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpReflexTakktile2:: */ vpReflexTakktile2::vpReflexTakktile2() : m_network_interface(), m_finger_file_name(), m_tactile_file_name(), m_motor_file_name(), m_hand_info(), - m_impl(new Impl()) -{ -} + m_impl(new Impl()) +{ } /*! * Destructor. @@ -325,5 +328,7 @@ void vpReflexTakktile2::open() * \param milliseconds : Duration in [ms]. */ void vpReflexTakktile2::wait(int milliseconds) { m_impl->wait(milliseconds); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/haptic-device/virtuose/vpVirtuose.cpp b/modules/robot/src/haptic-device/virtuose/vpVirtuose.cpp index e14fb6d859..7f87042a23 100644 --- a/modules/robot/src/haptic-device/virtuose/vpVirtuose.cpp +++ b/modules/robot/src/haptic-device/virtuose/vpVirtuose.cpp @@ -42,7 +42,10 @@ #include #ifdef VISP_HAVE_VIRTUOSE - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor. * Set command type to virtual mechanism by default (impedance mode). @@ -1043,7 +1046,9 @@ void vpVirtuose::stopPeriodicFunction() else std::cout << "Haptic loop closed." << std::endl; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning void dummy_vpVirtuose() { }; diff --git a/modules/robot/src/image-simulator/vpImageSimulator.cpp b/modules/robot/src/image-simulator/vpImageSimulator.cpp index d71babc2db..e3bbdfaf15 100644 --- a/modules/robot/src/image-simulator/vpImageSimulator.cpp +++ b/modules/robot/src/image-simulator/vpImageSimulator.cpp @@ -45,6 +45,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. @@ -57,9 +61,9 @@ */ vpImageSimulator::vpImageSimulator(const vpColorPlan &col) : cMt(), pt(), ptClipped(), interp(SIMPLE), normal_obj(), normal_Cam(), normal_Cam_optim(), distance(1.), - visible_result(1.), visible(false), X0_2_optim(nullptr), frobeniusNorm_u(0.), fronbniusNorm_v(0.), vbase_u(), - vbase_v(), vbase_u_optim(nullptr), vbase_v_optim(nullptr), Xinter_optim(nullptr), listTriangle(), colorI(col), Ig(), Ic(), - rect(), cleanPrevImage(false), setBackgroundTexture(false), bgColor(vpColor::white), focal(), needClipping(false) + visible_result(1.), visible(false), X0_2_optim(nullptr), frobeniusNorm_u(0.), fronbniusNorm_v(0.), vbase_u(), + vbase_v(), vbase_u_optim(nullptr), vbase_v_optim(nullptr), Xinter_optim(nullptr), listTriangle(), colorI(col), Ig(), Ic(), + rect(), cleanPrevImage(false), setBackgroundTexture(false), bgColor(vpColor::white), focal(), needClipping(false) { for (int i = 0; i < 4; i++) X[i].resize(3); @@ -94,10 +98,10 @@ vpImageSimulator::vpImageSimulator(const vpColorPlan &col) */ vpImageSimulator::vpImageSimulator(const vpImageSimulator &text) : cMt(), pt(), ptClipped(), interp(SIMPLE), normal_obj(), normal_Cam(), normal_Cam_optim(), distance(1.), - visible_result(1.), visible(false), X0_2_optim(nullptr), frobeniusNorm_u(0.), fronbniusNorm_v(0.), vbase_u(), - vbase_v(), vbase_u_optim(nullptr), vbase_v_optim(nullptr), Xinter_optim(nullptr), listTriangle(), colorI(GRAY_SCALED), Ig(), - Ic(), rect(), cleanPrevImage(false), setBackgroundTexture(false), bgColor(vpColor::white), focal(), - needClipping(false) + visible_result(1.), visible(false), X0_2_optim(nullptr), frobeniusNorm_u(0.), fronbniusNorm_v(0.), vbase_u(), + vbase_v(), vbase_u_optim(nullptr), vbase_v_optim(nullptr), Xinter_optim(nullptr), listTriangle(), colorI(GRAY_SCALED), Ig(), + Ic(), rect(), cleanPrevImage(false), setBackgroundTexture(false), bgColor(vpColor::white), focal(), + needClipping(false) { pt.resize(4); for (unsigned int i = 0; i < 4; i++) { @@ -224,11 +228,12 @@ void vpImageSimulator::getImage(vpImage &I, const vpCameraParamet if (getPixel(ip, Ipixelplan)) { *(bitmap + i * width + j) = Ipixelplan; } - } else if (colorI == COLORED) { + } + else if (colorI == COLORED) { vpRGBa Ipixelplan; if (getPixel(ip, Ipixelplan)) { unsigned char pixelgrey = - (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B); + (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B); *(bitmap + i * width + j) = pixelgrey; } } @@ -344,12 +349,13 @@ void vpImageSimulator::getImage(vpImage &I, const vpCameraParamet zBuffer[i][j] = Xinter_optim[2]; } } - } else if (colorI == COLORED) { + } + else if (colorI == COLORED) { vpRGBa Ipixelplan; if (getPixel(ip, Ipixelplan)) { if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0) { unsigned char pixelgrey = - (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B); + (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B); *(bitmap + i * width + j) = pixelgrey; zBuffer[i][j] = Xinter_optim[2]; } @@ -407,7 +413,8 @@ void vpImageSimulator::getImage(vpImage &I, const vpCameraParameters &ca pixelcolor.B = Ipixelplan; *(bitmap + i * width + j) = pixelcolor; } - } else if (colorI == COLORED) { + } + else if (colorI == COLORED) { vpRGBa Ipixelplan; if (getPixel(ip, Ipixelplan)) { *(bitmap + i * width + j) = Ipixelplan; @@ -528,7 +535,8 @@ void vpImageSimulator::getImage(vpImage &I, const vpCameraParameters &ca zBuffer[i][j] = Xinter_optim[2]; } } - } else if (colorI == COLORED) { + } + else if (colorI == COLORED) { vpRGBa Ipixelplan; if (getPixel(ip, Ipixelplan)) { if (Xinter_optim[2] < zBuffer[i][j] || zBuffer[i][j] < 0) { @@ -724,11 +732,12 @@ void vpImageSimulator::getImage(vpImage &I, std::listgetPixel(ip, Ipixelplan); *(bitmap + i * width + j) = Ipixelplan; - } else if (simList[indice]->colorI == COLORED) { + } + else if (simList[indice]->colorI == COLORED) { vpRGBa Ipixelplan(255, 255, 255); simList[indice]->getPixel(ip, Ipixelplan); unsigned char pixelgrey = - (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B); + (unsigned char)(0.2126 * Ipixelplan.R + 0.7152 * Ipixelplan.G + 0.0722 * Ipixelplan.B); *(bitmap + i * width + j) = pixelgrey; } } @@ -926,7 +935,8 @@ void vpImageSimulator::getImage(vpImage &I, std::list pixelcolor.G = Ipixelplan; pixelcolor.B = Ipixelplan; *(bitmap + i * width + j) = pixelcolor; - } else if (simList[indice]->colorI == COLORED) { + } + else if (simList[indice]->colorI == COLORED) { vpRGBa Ipixelplan(255, 255, 255); simList[indice]->getPixel(ip, Ipixelplan); // unsigned char pixelgrey = 0.2126 * Ipixelplan.R + 0.7152 * @@ -977,7 +987,8 @@ void vpImageSimulator::setCameraPosition(const vpHomogeneousMatrix &cMt_) if (angle > 0) { visible = true; - } else { + } + else { visible = false; } @@ -1263,7 +1274,8 @@ bool vpImageSimulator::getPixel(const vpImagePoint &iP, unsigned char &Ipixelpla else if (interp == SIMPLE) Ipixelplan = Ig[(unsigned int)i2][(unsigned int)j2]; return true; - } else + } + else return false; } @@ -1316,7 +1328,8 @@ bool vpImageSimulator::getPixel(vpImage &Isrc, const vpImagePoint else if (interp == SIMPLE) Ipixelplan = Isrc[(unsigned int)i2][(unsigned int)j2]; return true; - } else + } + else return false; } @@ -1368,7 +1381,8 @@ bool vpImageSimulator::getPixel(const vpImagePoint &iP, vpRGBa &Ipixelplan) else if (interp == SIMPLE) Ipixelplan = Ic[(unsigned int)i2][(unsigned int)j2]; return true; - } else + } + else return false; } @@ -1420,7 +1434,8 @@ bool vpImageSimulator::getPixel(vpImage &Isrc, const vpImagePoint &iP, v else if (interp == SIMPLE) Ipixelplan = Isrc[(unsigned int)i2][(unsigned int)j2]; return true; - } else + } + else return false; } @@ -1536,3 +1551,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpImageSimulator & os << ""; return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/light/vpRingLight.cpp b/modules/robot/src/light/vpRingLight.cpp index 27f469e6ea..5bb6334786 100644 --- a/modules/robot/src/light/vpRingLight.cpp +++ b/modules/robot/src/light/vpRingLight.cpp @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + \file vpRingLight.cpp + \brief Ring light management under unix. +*/ + #include #if defined(VISP_HAVE_MODULE_IO) && defined(VISP_HAVE_PARPORT) @@ -48,11 +53,10 @@ #include #include -/*! - \file vpRingLight.cpp - \brief Ring light management under unix. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Constructor to access to the ring light device connected to the parallel @@ -212,7 +216,9 @@ void vpRingLight::off() // vpTRACE("Send 0x%x = %d\n", data, data); parport.sendData(data); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRingLight.cpp.o) has no symbols void dummy_vpRingLight() { }; diff --git a/modules/robot/src/real-robot/afma4/vpAfma4.cpp b/modules/robot/src/real-robot/afma4/vpAfma4.cpp index 264f1a1ad8..b2075e60f1 100644 --- a/modules/robot/src/real-robot/afma4/vpAfma4.cpp +++ b/modules/robot/src/real-robot/afma4/vpAfma4.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ----------------------------------------------------------------------- */ /* --- STATIC ------------------------------------------------------------ */ /* ---------------------------------------------------------------------- */ @@ -600,3 +604,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpAfma4 &afma4) return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/real-robot/afma4/vpRobotAfma4.cpp b/modules/robot/src/real-robot/afma4/vpRobotAfma4.cpp index cdfac7c7e9..5dcb5a97c2 100644 --- a/modules/robot/src/real-robot/afma4/vpRobotAfma4.cpp +++ b/modules/robot/src/real-robot/afma4/vpRobotAfma4.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ---------------------------------------------------------------------- */ /* --- STATIC ----------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ @@ -1752,7 +1756,9 @@ void vpRobotAfma4::getDisplacement(vpRobot::vpControlFrameType frame, vpColVecto throw vpRobotException(vpRobotException::lowLevelError, "Cannot get velocity."); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotAfma4.cpp.o) has no symbols void dummy_vpRobotAfma4() { }; diff --git a/modules/robot/src/real-robot/afma4/vpServolens.cpp b/modules/robot/src/real-robot/afma4/vpServolens.cpp index f4a8bc9fa0..8f1b5798e1 100644 --- a/modules/robot/src/real-robot/afma4/vpServolens.cpp +++ b/modules/robot/src/real-robot/afma4/vpServolens.cpp @@ -59,13 +59,17 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. Does nothing. \sa open() */ -vpServolens::vpServolens() : remfd(0), isinit(false) {} +vpServolens::vpServolens() : remfd(0), isinit(false) { } /*! Open and initialize the Servolens serial link at 9600 bauds, 7 @@ -512,16 +516,19 @@ bool vpServolens::getPosition(vpServoType servo, unsigned int &position) const if (c >= '0' && c <= '9') { *pt_posit++ = c; /* sauvegarde de la position */ lecture_posit_en_cours = 1; - } else if (lecture_posit_en_cours) { + } + else if (lecture_posit_en_cours) { fin_lect_posit = 1; *pt_posit = '\0'; - } else + } + else posit_car = 0; break; } - } else { - // Timout sur la lecture, on retoure FALSE + } + else { + // Timout sur la lecture, on retoure FALSE return false; } } while (!fin_lect_posit); @@ -710,7 +717,7 @@ bool vpServolens::read(char *c, long timeout_s) const } fd_set readfds; /* list of fds for select to listen to */ - struct timeval timeout = {timeout_s, 0}; // seconde, micro-sec + struct timeval timeout = { timeout_s, 0 }; // seconde, micro-sec FD_ZERO(&readfds); FD_SET(static_cast(this->remfd), &readfds); @@ -793,5 +800,7 @@ bool vpServolens::clean(const char *in, char *out) const } return (error); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/real-robot/afma6/vpAfma6.cpp b/modules/robot/src/real-robot/afma6/vpAfma6.cpp index 93f1e324c2..f8052b42a7 100644 --- a/modules/robot/src/real-robot/afma6/vpAfma6.cpp +++ b/modules/robot/src/real-robot/afma6/vpAfma6.cpp @@ -58,6 +58,10 @@ /* --- STATIC ------------------------------------------------------------ */ /* ---------------------------------------------------------------------- */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif static const char *opt_Afma6[] = { "JOINT_MAX", "JOINT_MIN", "LONG_56", "COUPL_56", "CAMERA", "eMc_ROT_XYZ", "eMc_TRANS_XYZ", nullptr }; @@ -1590,3 +1594,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpAfma6 &afma6) return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/real-robot/afma6/vpRobotAfma6.cpp b/modules/robot/src/real-robot/afma6/vpRobotAfma6.cpp index 0cbc49a76c..7360594789 100644 --- a/modules/robot/src/real-robot/afma6/vpRobotAfma6.cpp +++ b/modules/robot/src/real-robot/afma6/vpRobotAfma6.cpp @@ -51,6 +51,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ---------------------------------------------------------------------- */ /* --- STATIC ----------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ @@ -2307,7 +2311,9 @@ bool vpRobotAfma6::checkJointLimits(vpColVector &jointsStatus) return status; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotAfma6.cpp.o) has no symbols void dummy_vpRobotAfma6() { }; diff --git a/modules/robot/src/real-robot/bebop2/vpRobotBebop2.cpp b/modules/robot/src/real-robot/bebop2/vpRobotBebop2.cpp index feb38b1155..39380c4af6 100644 --- a/modules/robot/src/real-robot/bebop2/vpRobotBebop2.cpp +++ b/modules/robot/src/real-robot/bebop2/vpRobotBebop2.cpp @@ -72,6 +72,10 @@ extern "C" { + z : down */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif bool vpRobotBebop2::m_running = false; ARCONTROLLER_Device_t *vpRobotBebop2::m_deviceController = nullptr; @@ -2002,7 +2006,9 @@ void vpRobotBebop2::commandReceivedCallback(eARCONTROLLER_DICTIONARY_KEY command } #undef TAG - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotBebop2.cpp.o) has // no symbols diff --git a/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp index bf9231b1ac..b7b6938534 100644 --- a/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp +++ b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.cpp @@ -52,6 +52,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpRobotBiclops::vpRobotBiclopsController::vpRobotBiclopsController() : m_biclops(), m_axisMask(0), m_panAxis(nullptr), m_tiltAxis(nullptr), m_vergeAxis(nullptr), m_panProfile(), m_tiltProfile(), m_vergeProfile(), m_shm(), m_stopControllerThread(false) @@ -350,7 +354,9 @@ vpRobotBiclops::vpRobotBiclopsController::shmType vpRobotBiclops::vpRobotBiclops return tmp_shm; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: // libvisp_robot.a(vpRobotBiclopsController.cpp.o) has no symbols diff --git a/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.h b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.h index abdcff0d92..df2f90b513 100644 --- a/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.h +++ b/modules/robot/src/real-robot/biclops/private/vpRobotBiclopsController_impl.h @@ -45,6 +45,10 @@ #include // Contrib for Biclops sdk #include // Contrib for Biclops sdk +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #if defined(_WIN32) class VISP_EXPORT Biclops; // needed for dll creation #endif @@ -242,9 +246,11 @@ class VISP_EXPORT vpRobotBiclops::vpRobotBiclopsController shmType m_shm; bool m_stopControllerThread; }; - -#endif /* #ifndef _vpRobotBiclopsController_h_ */ +#ifdef ENABLE_VISP_NAMESPACE +} +#endif +#endif // #ifdef VISP_HAVE_BICLOPS #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS -#endif +#endif /* #ifndef _vpRobotBiclopsController_h_ */ diff --git a/modules/robot/src/real-robot/biclops/vpBiclops.cpp b/modules/robot/src/real-robot/biclops/vpBiclops.cpp index 95b9763943..722b7ddeea 100644 --- a/modules/robot/src/real-robot/biclops/vpBiclops.cpp +++ b/modules/robot/src/real-robot/biclops/vpBiclops.cpp @@ -37,6 +37,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const unsigned int vpBiclops::ndof = 2; const float vpBiclops::h = 0.048f; const float vpBiclops::panJointLimit = (float)(M_PI); @@ -257,3 +261,6 @@ void vpBiclops::get_fJe(const vpColVector &q, vpMatrix &fJe) const fJe[5][0] = 1; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp b/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp index a22d01df94..095630ae4f 100644 --- a/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp +++ b/modules/robot/src/real-robot/biclops/vpRobotBiclops.cpp @@ -55,6 +55,10 @@ //#define VP_DEBUG_MODE 12 // Activate debug level up to 12 #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ---------------------------------------------------------------------- */ /* --- STATIC ------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -852,7 +856,9 @@ void vpRobotBiclops::getDisplacement(vpRobot::vpControlFrameType frame, vpColVec m_q_previous = q_current; // Update for next call of this method } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotBiclops.cpp.o) has no symbols void dummy_vpRobotBiclops() { }; diff --git a/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp b/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp index 0f45047691..ddba0e9bb8 100644 --- a/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp +++ b/modules/robot/src/real-robot/flir-ptu/vpRobotFlirPtu.cpp @@ -52,6 +52,10 @@ extern "C" { #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Emergency stops the robot if the program is interrupted by a SIGINT @@ -946,7 +950,9 @@ double vpRobotFlirPtu::tics2deg(int axis, int tics) { return (tics * m_res[axis] \sa pos2rad() */ double vpRobotFlirPtu::tics2rad(int axis, int tics) { return vpMath::rad(tics2deg(axis, tics)); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotFlirPtu.cpp.o) has // no symbols diff --git a/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.cpp b/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.cpp index 36fe1eaf32..8bccebaf53 100644 --- a/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.cpp +++ b/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.cpp @@ -54,6 +54,10 @@ #include // TODO: Remove when initial_position var is removed +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpColVector ft_cart_des_prev(6, 0); void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bool &stop, const std::string &log_folder, @@ -77,7 +81,7 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo Eigen::Map > initial_gravity(gravity_array.data()); initial_tau_ext = initial_tau_measured - initial_gravity; - franka::Torques zero_torques{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; + franka::Torques zero_torques { {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} }; Eigen::VectorXd tau_joint_d(7), tau_cart_d(6); for (size_t i = 0; i < 7; i++) { tau_joint_d[i] = 0; @@ -123,7 +127,7 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo if (frame == vpRobot::CAMERA_FRAME || frame == vpRobot::REFERENCE_FRAME || frame == vpRobot::END_EFFECTOR_FRAME) { for (size_t i = 0; i < 7; i++) { gnuplot << "plot 'tau_d.log' u " << i + 1 << " title \"tau_d" << i + 1 << "\", 'tau_mes.log' u " << i + 1 - << " title \"tau_mes" << i + 1 << "\"" << std::endl; + << " title \"tau_mes" << i + 1 << "\"" << std::endl; gnuplot << "\npause -1\n" << std::endl; } } @@ -139,9 +143,9 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo std::ofstream log_tau_diff_prev; auto force_joint_control_callback = - [=, &log_time, &log_tau_cmd, &log_tau_d, &log_tau_mes, &time, &model, &initial_position, &stop, &zero_torques, - &robot_state, &tau_joint_d, &tau_error_integral, &mutex, - &tau_J_des](const franka::RobotState &state, franka::Duration period) -> franka::Torques { + [=, &log_time, &log_tau_cmd, &log_tau_d, &log_tau_mes, &time, &model, &initial_position, &stop, &zero_torques, + &robot_state, &tau_joint_d, &tau_error_integral, &mutex, + &tau_J_des](const franka::RobotState &state, franka::Duration period) -> franka::Torques { time += period.toSec(); if (time == 0.0) { @@ -174,18 +178,18 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo // FF + PI control tau_cmd << tau_joint_d + k_p * (tau_joint_d - tau_ext) + k_i * tau_error_integral; - std::array tau_d_array{}; + std::array tau_d_array {}; Eigen::VectorXd::Map(&tau_d_array[0], 7) = tau_cmd; if (!log_folder.empty()) { log_time << time << std::endl; log_tau_cmd << std::fixed << std::setprecision(8) << tau_cmd[0] << " " << tau_cmd[1] << " " << tau_cmd[2] << " " - << tau_cmd[3] << " " << tau_cmd[4] << " " << tau_cmd[5] << " " << tau_cmd[6] << std::endl; + << tau_cmd[3] << " " << tau_cmd[4] << " " << tau_cmd[5] << " " << tau_cmd[6] << std::endl; log_tau_d << std::fixed << std::setprecision(8) << tau_joint_d[0] << " " << tau_joint_d[1] << " " - << tau_joint_d[2] << " " << tau_joint_d[3] << " " << tau_joint_d[4] << " " << tau_joint_d[5] << " " - << tau_joint_d[6] << std::endl; + << tau_joint_d[2] << " " << tau_joint_d[3] << " " << tau_joint_d[4] << " " << tau_joint_d[5] << " " + << tau_joint_d[6] << std::endl; log_tau_mes << std::fixed << std::setprecision(8) << tau_ext[0] << " " << tau_ext[1] << " " << tau_ext[2] << " " - << tau_ext[3] << " " << tau_ext[4] << " " << tau_ext[5] << " " << tau_ext[6] << std::endl; + << tau_ext[3] << " " << tau_ext[4] << " " << tau_ext[5] << " " << tau_ext[6] << std::endl; } if (stop) { @@ -199,97 +203,97 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo } return tau_d_array; - }; + }; auto force_cart_control_callback = [=, &log_time, &log_tau_cmd, &log_tau_d, &log_tau_mes, &log_tau_diff, - &log_tau_diff_prev, &time, &model, /*&initial_position, */ - &stop, &zero_torques, &robot_state, &tau_cart_d, &tau_error_integral, &mutex, - &ft_cart_des](const franka::RobotState &state, - franka::Duration period) -> franka::Torques { - time += period.toSec(); + &log_tau_diff_prev, &time, &model, /*&initial_position, */ + &stop, &zero_torques, &robot_state, &tau_cart_d, &tau_error_integral, &mutex, + &ft_cart_des](const franka::RobotState &state, + franka::Duration period) -> franka::Torques { + time += period.toSec(); - Eigen::VectorXd tau_d(7), tau_cmd(7), tau_ext(7), desired_tau(7); + Eigen::VectorXd tau_d(7), tau_cmd(7), tau_ext(7), desired_tau(7); - if (time == 0.0) { - tau_d << 0, 0, 0, 0, 0, 0, 0; - tau_ext << 0, 0, 0, 0, 0, 0, 0; + if (time == 0.0) { + tau_d << 0, 0, 0, 0, 0, 0, 0; + tau_ext << 0, 0, 0, 0, 0, 0, 0; - if (!log_folder.empty()) { - log_time.open(log_folder + "/time.log"); - log_tau_cmd.open(log_folder + "/tau_cmd.log"); - log_tau_d.open(log_folder + "/tau_d.log"); - log_tau_mes.open(log_folder + "/tau_mes.log"); - log_tau_diff.open(log_folder + "/tau_diff.log"); - log_tau_diff_prev.open(log_folder + "/tau_diff_prev.log"); - } + if (!log_folder.empty()) { + log_time.open(log_folder + "/time.log"); + log_tau_cmd.open(log_folder + "/tau_cmd.log"); + log_tau_d.open(log_folder + "/tau_d.log"); + log_tau_mes.open(log_folder + "/tau_mes.log"); + log_tau_diff.open(log_folder + "/tau_diff.log"); + log_tau_diff_prev.open(log_folder + "/tau_diff_prev.log"); } + } - { - std::lock_guard lock(mutex); - robot_state = state; - } + { + std::lock_guard lock(mutex); + robot_state = state; + } - // get state variables - std::array jacobian_array = model.zeroJacobian(franka::Frame::kEndEffector, state); + // get state variables + std::array jacobian_array = model.zeroJacobian(franka::Frame::kEndEffector, state); - Eigen::Map > jacobian(jacobian_array.data()); - Eigen::Map > tau_measured(state.tau_J.data()); - Eigen::Map > gravity(gravity_array.data()); + Eigen::Map > jacobian(jacobian_array.data()); + Eigen::Map > tau_measured(state.tau_J.data()); + Eigen::Map > gravity(gravity_array.data()); - tau_ext << tau_measured - gravity - initial_tau_ext; + tau_ext << tau_measured - gravity - initial_tau_ext; - tau_error_integral += period.toSec() * (tau_d - tau_ext); + tau_error_integral += period.toSec() * (tau_d - tau_ext); - // Apply force with gradually increasing the force - for (size_t i = 0; i < 7; i++) { - tau_cart_d[i] = filter_gain * ft_cart_des[i] + (1 - filter_gain) * tau_cart_d[i]; - } + // Apply force with gradually increasing the force + for (size_t i = 0; i < 7; i++) { + tau_cart_d[i] = filter_gain * ft_cart_des[i] + (1 - filter_gain) * tau_cart_d[i]; + } - tau_d << jacobian.transpose() * tau_cart_d; + tau_d << jacobian.transpose() * tau_cart_d; - // FF + PI control - tau_cmd << tau_d + k_p * (tau_d - tau_ext) + k_i * tau_error_integral; + // FF + PI control + tau_cmd << tau_d + k_p * (tau_d - tau_ext) + k_i * tau_error_integral; - std::array tau_d_array{}; - Eigen::VectorXd::Map(&tau_d_array[0], 7) = tau_cmd; + std::array tau_d_array {}; + Eigen::VectorXd::Map(&tau_d_array[0], 7) = tau_cmd; - if (!log_folder.empty()) { - log_time << time << std::endl; - log_tau_cmd << std::fixed << std::setprecision(8) << tau_cmd[0] << " " << tau_cmd[1] << " " << tau_cmd[2] << " " - << tau_cmd[3] << " " << tau_cmd[4] << " " << tau_cmd[5] << " " << tau_cmd[6] << std::endl; - log_tau_d << std::fixed << std::setprecision(8) << tau_d[0] << " " << tau_d[1] << " " << tau_d[2] << " " - << tau_d[3] << " " << tau_d[4] << " " << tau_d[5] << " " << tau_d[6] << std::endl; - log_tau_mes << std::fixed << std::setprecision(8) << tau_ext[0] << " " << tau_ext[1] << " " << tau_ext[2] << " " - << tau_ext[3] << " " << tau_ext[4] << " " << tau_ext[5] << " " << tau_ext[6] << std::endl; - log_tau_diff << std::fixed << std::setprecision(8); - for (size_t i = 0; i < ft_cart_des.size(); i++) { - log_tau_diff << ft_cart_des[i] - tau_cart_d[i] << " "; - } - log_tau_diff << std::endl; + if (!log_folder.empty()) { + log_time << time << std::endl; + log_tau_cmd << std::fixed << std::setprecision(8) << tau_cmd[0] << " " << tau_cmd[1] << " " << tau_cmd[2] << " " + << tau_cmd[3] << " " << tau_cmd[4] << " " << tau_cmd[5] << " " << tau_cmd[6] << std::endl; + log_tau_d << std::fixed << std::setprecision(8) << tau_d[0] << " " << tau_d[1] << " " << tau_d[2] << " " + << tau_d[3] << " " << tau_d[4] << " " << tau_d[5] << " " << tau_d[6] << std::endl; + log_tau_mes << std::fixed << std::setprecision(8) << tau_ext[0] << " " << tau_ext[1] << " " << tau_ext[2] << " " + << tau_ext[3] << " " << tau_ext[4] << " " << tau_ext[5] << " " << tau_ext[6] << std::endl; + log_tau_diff << std::fixed << std::setprecision(8); + for (size_t i = 0; i < ft_cart_des.size(); i++) { + log_tau_diff << ft_cart_des[i] - tau_cart_d[i] << " "; + } + log_tau_diff << std::endl; - log_tau_diff_prev << std::fixed << std::setprecision(8); - for (size_t i = 0; i < ft_cart_des.size(); i++) { - log_tau_diff_prev << ft_cart_des[i] - ft_cart_des_prev[i] << " "; - } - log_tau_diff_prev << std::endl; + log_tau_diff_prev << std::fixed << std::setprecision(8); + for (size_t i = 0; i < ft_cart_des.size(); i++) { + log_tau_diff_prev << ft_cart_des[i] - ft_cart_des_prev[i] << " "; } + log_tau_diff_prev << std::endl; + } - if (stop) { - if (!log_folder.empty()) { - log_time.close(); - log_tau_cmd.close(); - log_tau_d.close(); - log_tau_mes.close(); - log_tau_diff.close(); - log_tau_diff_prev.close(); - } - return franka::MotionFinished(zero_torques); + if (stop) { + if (!log_folder.empty()) { + log_time.close(); + log_tau_cmd.close(); + log_tau_d.close(); + log_tau_mes.close(); + log_tau_diff.close(); + log_tau_diff_prev.close(); } + return franka::MotionFinished(zero_torques); + } - ft_cart_des_prev = ft_cart_des; + ft_cart_des_prev = ft_cart_des; - return tau_d_array; - }; + return tau_d_array; + }; #if !(VISP_HAVE_FRANKA_VERSION < 0x000500) double cutoff_frequency = 10; @@ -302,7 +306,8 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo try { robot->control(force_joint_control_callback, true, cutoff_frequency); break; - } catch (const franka::ControlException &e) { + } + catch (const franka::ControlException &e) { std::cerr << "Warning: communication error: " << e.what() << "\nRetry attempt: " << attempt << std::endl; robot->automaticErrorRecovery(); if (attempt == nbAttempts) @@ -319,7 +324,8 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo try { robot->control(force_cart_control_callback, true, cutoff_frequency); break; - } catch (const franka::ControlException &e) { + } + catch (const franka::ControlException &e) { std::cerr << "Warning: communication error: " << e.what() << "\nRetry attempt: " << attempt << std::endl; robot->automaticErrorRecovery(); if (attempt == nbAttempts) @@ -333,8 +339,10 @@ void vpForceTorqueGenerator::control_thread(franka::Robot *robot, std::atomic_bo } } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpForceTorqueGenerator.cpp.o) has no symbols -void dummy_vpForceTorqueGenerator(){}; +void dummy_vpForceTorqueGenerator() { }; #endif // VISP_HAVE_FRANKA diff --git a/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.h b/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.h index 05e1bc47dd..d1b904d5d5 100644 --- a/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.h +++ b/modules/robot/src/real-robot/franka/vpForceTorqueGenerator_impl.h @@ -54,17 +54,23 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpForceTorqueGenerator { public: - vpForceTorqueGenerator() {} - virtual ~vpForceTorqueGenerator() {} + vpForceTorqueGenerator() { } + virtual ~vpForceTorqueGenerator() { } void control_thread(franka::Robot *robot, std::atomic_bool &stop, const std::string &log_folder, const vpRobot::vpControlFrameType &frame, const std::array &tau_J_des, const vpColVector &ft_cart_des, franka::RobotState &robot_state, std::mutex &mutex, const double &filter_gain, const bool &activate_pi_controller); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.cpp b/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.cpp index d9ea9f759d..dad91e0c4e 100644 --- a/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.cpp +++ b/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.cpp @@ -50,9 +50,13 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpJointPosTrajGenerator::vpJointPosTrajGenerator(double speed_factor, const std::array &q_goal) : m_q_goal(7), m_q_start(7), m_delta_q(7), m_dq_max_sync(7), m_t_1_sync(7), m_t_2_sync(7), m_t_f_sync(7), m_q_1(7), - m_dq_max(7), m_ddq_max_start(7), m_ddq_max_goal(7) + m_dq_max(7), m_ddq_max_start(7), m_ddq_max_goal(7) { for (size_t i = 0; i < 7; i++) { m_q_goal[i] = q_goal[i]; @@ -75,26 +79,30 @@ bool vpJointPosTrajGenerator::calculateDesiredValues(double t, vpColVector &delt vpColVector t_d = m_t_2_sync - m_t_1_sync; vpColVector delta_t_2_sync = m_t_f_sync - m_t_2_sync; - std::array joint_motion_finished{}; + std::array joint_motion_finished {}; for (size_t i = 0; i < 7; i++) { if (std::abs(m_delta_q[i]) < kDeltaQMotionFinished) { delta_q_d[i] = 0.; joint_motion_finished[i] = true; - } else { + } + else { if (t < m_t_1_sync[i]) { delta_q_d[i] = -1.0 / std::pow(m_t_1_sync[i], 3.0) * m_dq_max_sync[i] * sign_delta_q[i] * - (0.5 * t - m_t_1_sync[i]) * std::pow(t, 3.0); - } else if (t >= m_t_1_sync[i] && t < m_t_2_sync[i]) { + (0.5 * t - m_t_1_sync[i]) * std::pow(t, 3.0); + } + else if (t >= m_t_1_sync[i] && t < m_t_2_sync[i]) { delta_q_d[i] = m_q_1[i] + (t - m_t_1_sync[i]) * m_dq_max_sync[i] * sign_delta_q[i]; - } else if (t >= m_t_2_sync[i] && t < m_t_f_sync[i]) { + } + else if (t >= m_t_2_sync[i] && t < m_t_f_sync[i]) { delta_q_d[i] = m_delta_q[i] + 0.5 * - (1.0 / std::pow(delta_t_2_sync[i], 3.0) * - (t - m_t_1_sync[i] - 2.0 * delta_t_2_sync[i] - t_d[i]) * - std::pow((t - m_t_1_sync[i] - t_d[i]), 3.0) + - (2.0 * t - 2.0 * m_t_1_sync[i] - delta_t_2_sync[i] - 2.0 * t_d[i])) * - m_dq_max_sync[i] * sign_delta_q[i]; - } else { + (1.0 / std::pow(delta_t_2_sync[i], 3.0) * + (t - m_t_1_sync[i] - 2.0 * delta_t_2_sync[i] - t_d[i]) * + std::pow((t - m_t_1_sync[i] - t_d[i]), 3.0) + + (2.0 * t - 2.0 * m_t_1_sync[i] - delta_t_2_sync[i] - 2.0 * t_d[i])) * + m_dq_max_sync[i] * sign_delta_q[i]; + } + else { delta_q_d[i] = m_delta_q[i]; joint_motion_finished[i] = true; } @@ -120,8 +128,8 @@ void vpJointPosTrajGenerator::calculateSynchronizedValues() if (std::abs(m_delta_q[i]) < (3.0 / 4.0 * (std::pow(m_dq_max[i], 2.0) / m_ddq_max_start[i]) + 3.0 / 4.0 * (std::pow(m_dq_max[i], 2.0) / m_ddq_max_goal[i]))) { dq_max_reach[i] = - std::sqrt(4.0 / 3.0 * m_delta_q[i] * sign_delta_q[i] * (m_ddq_max_start[i] * m_ddq_max_goal[i]) / - (m_ddq_max_start[i] + m_ddq_max_goal[i])); + std::sqrt(4.0 / 3.0 * m_delta_q[i] * sign_delta_q[i] * (m_ddq_max_start[i] * m_ddq_max_goal[i]) / + (m_ddq_max_start[i] + m_ddq_max_goal[i])); } t_1[i] = 1.5 * dq_max_reach[i] / m_ddq_max_start[i]; delta_t_2[i] = 1.5 * dq_max_reach[i] / m_ddq_max_goal[i]; @@ -174,7 +182,10 @@ franka::JointPositions vpJointPosTrajGenerator::operator()(const franka::RobotSt output.motion_finished = motion_finished; return output; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpJointPosTrajGenerator.cpp.o) has no symbols -void dummy_vpJointPosTrajGenerator(){}; +void dummy_vpJointPosTrajGenerator() { }; #endif diff --git a/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.h b/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.h index b266abf114..66858d983a 100644 --- a/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.h +++ b/modules/robot/src/real-robot/franka/vpJointPosTrajGenerator_impl.h @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /** * An example showing how to generate a joint pose motion to a goal position. Adapted from: * Wisama Khalil and Etienne Dombre. 2002. Modeling, Identification and Control of Robots @@ -100,6 +104,8 @@ class vpJointPosTrajGenerator double m_time = 0.0; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/real-robot/franka/vpJointVelTrajGenerator_impl.cpp b/modules/robot/src/real-robot/franka/vpJointVelTrajGenerator_impl.cpp index e357b4d1ba..0f6d3cabde 100644 --- a/modules/robot/src/real-robot/franka/vpJointVelTrajGenerator_impl.cpp +++ b/modules/robot/src/real-robot/franka/vpJointVelTrajGenerator_impl.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void vpJointVelTrajGenerator::control_thread(franka::Robot *robot, std::atomic_bool &stop, const std::string &log_folder, const vpRobot::vpControlFrameType &frame, const vpHomogeneousMatrix &eMc, @@ -203,116 +207,116 @@ void vpJointVelTrajGenerator::control_thread(franka::Robot *robot, std::atomic_b &time, &model, &q_prev, &v_cart_des, &stop, &robot_state, &mutex](const franka::RobotState &state, franka::Duration period) -> franka::JointVelocities { - time += period.toSec(); - - static vpJointVelTrajGenerator joint_vel_traj_generator; - - if (time == 0.0) { - if (!log_folder.empty()) { - log_time.open(log_folder + "/time.log"); - log_q_mes.open(log_folder + "/q-mes.log"); - log_dq_mes.open(log_folder + "/dq-mes.log"); - log_dq_des.open(log_folder + "/dq-des.log"); - log_dq_cmd.open(log_folder + "/dq-cmd.log"); - log_v_des.open(log_folder + "/v-des.log"); - } - q_prev = state.q_d; - joint_vel_traj_generator.init(state.q_d, q_min, q_max, dq_max, ddq_max, delta_t); - } - - { - std::lock_guard lock(mutex); - robot_state = state; - } - - // Get robot Jacobian - if (frame == vpRobot::END_EFFECTOR_FRAME || frame == vpRobot::TOOL_FRAME) { - std::array jacobian = model.bodyJacobian(franka::Frame::kEndEffector, state); - // Convert row-major to col-major - for (size_t i = 0; i < 6; i++) { // TODO make a function - for (size_t j = 0; j < 7; j++) { - eJe[i][j] = jacobian[j * 6 + i]; - } - } - } - else if (frame == vpRobot::REFERENCE_FRAME) { - std::array jacobian = model.zeroJacobian(franka::Frame::kEndEffector, state); - // Convert row-major to col-major - for (size_t i = 0; i < 6; i++) { // TODO make a function - for (size_t j = 0; j < 7; j++) { - fJe[i][j] = jacobian[j * 6 + i]; - } - } - } - - // Compute joint velocity - vpColVector q_dot; - if (frame == vpRobot::END_EFFECTOR_FRAME) { - q_dot = eJe.pseudoInverse() * v_cart_des; // TODO introduce try catch - } - else if (frame == vpRobot::TOOL_FRAME) { - q_dot = (cVe * eJe).pseudoInverse() * v_cart_des; // TODO introduce try catch - } - else if (frame == vpRobot::REFERENCE_FRAME) { - q_dot = (cVe * fJe).pseudoInverse() * v_cart_des; // TODO introduce try catch - } - - std::array dq_des_eigen; - for (size_t i = 0; i < 7; i++) // TODO create a function to convert - dq_des_eigen[i] = q_dot[i]; - - std::array q_cmd; - std::array dq_cmd; - - auto dq_des_ = dq_des_eigen; - if (stop) { // Stop asked - for (auto &dq_ : dq_des_) { - dq_ = 0.0; - } - } - - joint_vel_traj_generator.applyVel(dq_des_, q_cmd, dq_cmd); - - if (!log_folder.empty()) { - log_time << time << std::endl; - log_q_mes << std::fixed << std::setprecision(8) << state.q_d[0] << " " << state.q_d[1] << " " << state.q_d[2] - << " " << state.q_d[3] << " " << state.q_d[4] << " " << state.q_d[5] << " " << state.q_d[6] - << std::endl; - log_dq_mes << std::fixed << std::setprecision(8) << state.dq_d[0] << " " << state.dq_d[1] << " " << state.dq_d[2] - << " " << state.dq_d[3] << " " << state.dq_d[4] << " " << state.dq_d[5] << " " << state.dq_d[6] - << std::endl; - log_dq_cmd << std::fixed << std::setprecision(8) << dq_cmd[0] << " " << dq_cmd[1] << " " << dq_cmd[2] << " " - << dq_cmd[3] << " " << dq_cmd[4] << " " << dq_cmd[5] << " " << dq_cmd[6] << std::endl; - log_dq_des << std::fixed << std::setprecision(8) << dq_des_[0] << " " << dq_des_[1] << " " << dq_des_[2] << " " - << dq_des_[3] << " " << dq_des_[4] << " " << dq_des_[5] << " " << dq_des_[6] << std::endl; - log_v_des << std::fixed << std::setprecision(8) << v_cart_des[0] << " " << v_cart_des[1] << " " << v_cart_des[2] - << " " << v_cart_des[3] << " " << v_cart_des[4] << " " << v_cart_des[5] << std::endl; - } - - franka::JointVelocities velocities = { dq_cmd[0], dq_cmd[1], dq_cmd[2], dq_cmd[3], dq_cmd[4], dq_cmd[5], dq_cmd[6] }; - - if (stop) { - unsigned int nb_joint_stop = 0; - const double q_eps = 1e-6; // Motion finished - for (size_t i = 0; i < 7; i++) { - if (std::abs(state.q_d[i] - q_prev[i]) < q_eps) { - nb_joint_stop++; - } - } - if (nb_joint_stop == 7) { - if (!log_folder.empty()) { - log_time.close(); - log_q_mes.close(); - log_dq_mes.close(); - log_dq_des.close(); - log_dq_cmd.close(); - log_v_des.close(); - } - return franka::MotionFinished(velocities); - } - } - - q_prev = state.q_d; + time += period.toSec(); + + static vpJointVelTrajGenerator joint_vel_traj_generator; + + if (time == 0.0) { + if (!log_folder.empty()) { + log_time.open(log_folder + "/time.log"); + log_q_mes.open(log_folder + "/q-mes.log"); + log_dq_mes.open(log_folder + "/dq-mes.log"); + log_dq_des.open(log_folder + "/dq-des.log"); + log_dq_cmd.open(log_folder + "/dq-cmd.log"); + log_v_des.open(log_folder + "/v-des.log"); + } + q_prev = state.q_d; + joint_vel_traj_generator.init(state.q_d, q_min, q_max, dq_max, ddq_max, delta_t); + } + + { + std::lock_guard lock(mutex); + robot_state = state; + } + + // Get robot Jacobian + if (frame == vpRobot::END_EFFECTOR_FRAME || frame == vpRobot::TOOL_FRAME) { + std::array jacobian = model.bodyJacobian(franka::Frame::kEndEffector, state); + // Convert row-major to col-major + for (size_t i = 0; i < 6; i++) { // TODO make a function + for (size_t j = 0; j < 7; j++) { + eJe[i][j] = jacobian[j * 6 + i]; + } + } + } + else if (frame == vpRobot::REFERENCE_FRAME) { + std::array jacobian = model.zeroJacobian(franka::Frame::kEndEffector, state); + // Convert row-major to col-major + for (size_t i = 0; i < 6; i++) { // TODO make a function + for (size_t j = 0; j < 7; j++) { + fJe[i][j] = jacobian[j * 6 + i]; + } + } + } + + // Compute joint velocity + vpColVector q_dot; + if (frame == vpRobot::END_EFFECTOR_FRAME) { + q_dot = eJe.pseudoInverse() * v_cart_des; // TODO introduce try catch + } + else if (frame == vpRobot::TOOL_FRAME) { + q_dot = (cVe * eJe).pseudoInverse() * v_cart_des; // TODO introduce try catch + } + else if (frame == vpRobot::REFERENCE_FRAME) { + q_dot = (cVe * fJe).pseudoInverse() * v_cart_des; // TODO introduce try catch + } + + std::array dq_des_eigen; + for (size_t i = 0; i < 7; i++) // TODO create a function to convert + dq_des_eigen[i] = q_dot[i]; + + std::array q_cmd; + std::array dq_cmd; + + auto dq_des_ = dq_des_eigen; + if (stop) { // Stop asked + for (auto &dq_ : dq_des_) { + dq_ = 0.0; + } + } + + joint_vel_traj_generator.applyVel(dq_des_, q_cmd, dq_cmd); + + if (!log_folder.empty()) { + log_time << time << std::endl; + log_q_mes << std::fixed << std::setprecision(8) << state.q_d[0] << " " << state.q_d[1] << " " << state.q_d[2] + << " " << state.q_d[3] << " " << state.q_d[4] << " " << state.q_d[5] << " " << state.q_d[6] + << std::endl; + log_dq_mes << std::fixed << std::setprecision(8) << state.dq_d[0] << " " << state.dq_d[1] << " " << state.dq_d[2] + << " " << state.dq_d[3] << " " << state.dq_d[4] << " " << state.dq_d[5] << " " << state.dq_d[6] + << std::endl; + log_dq_cmd << std::fixed << std::setprecision(8) << dq_cmd[0] << " " << dq_cmd[1] << " " << dq_cmd[2] << " " + << dq_cmd[3] << " " << dq_cmd[4] << " " << dq_cmd[5] << " " << dq_cmd[6] << std::endl; + log_dq_des << std::fixed << std::setprecision(8) << dq_des_[0] << " " << dq_des_[1] << " " << dq_des_[2] << " " + << dq_des_[3] << " " << dq_des_[4] << " " << dq_des_[5] << " " << dq_des_[6] << std::endl; + log_v_des << std::fixed << std::setprecision(8) << v_cart_des[0] << " " << v_cart_des[1] << " " << v_cart_des[2] + << " " << v_cart_des[3] << " " << v_cart_des[4] << " " << v_cart_des[5] << std::endl; + } + + franka::JointVelocities velocities = { dq_cmd[0], dq_cmd[1], dq_cmd[2], dq_cmd[3], dq_cmd[4], dq_cmd[5], dq_cmd[6] }; + + if (stop) { + unsigned int nb_joint_stop = 0; + const double q_eps = 1e-6; // Motion finished + for (size_t i = 0; i < 7; i++) { + if (std::abs(state.q_d[i] - q_prev[i]) < q_eps) { + nb_joint_stop++; + } + } + if (nb_joint_stop == 7) { + if (!log_folder.empty()) { + log_time.close(); + log_q_mes.close(); + log_dq_mes.close(); + log_dq_des.close(); + log_dq_cmd.close(); + log_v_des.close(); + } + return franka::MotionFinished(velocities); + } + } + + q_prev = state.q_d; #if (VISP_HAVE_FRANKA_VERSION < 0x000500) // state.q_d contains the last joint velocity command received by the robot. @@ -323,10 +327,10 @@ void vpJointVelTrajGenerator::control_thread(franka::Robot *robot, std::atomic_b // by the robot will prevent from getting discontinuity errors. // Note that if the robot does not receive a command it will try to extrapolate // the desired behavior assuming a constant acceleration model - return limitRate(ddq_max, velocities.dq, state.dq_d); + return limitRate(ddq_max, velocities.dq, state.dq_d); #else // With libfranka 0.5.0 franka::control enables limit_rate by default - return velocities; + return velocities; #endif }; @@ -623,7 +627,9 @@ std::array vpJointVelTrajGenerator::limitRate(const std::array +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpJointVelTrajGenerator { public: vpJointVelTrajGenerator() : m_status(), m_delta_q(), m_delta_q_max(), m_delta_q_acc(), m_q_final(), m_sign(), m_q_cmd(), m_q_cmd_prev(), - m_dist_AD(), m_dq_des(), m_dq_des_prev(), m_dist_to_final(), m_flagSpeed(), m_q_min(), m_q_max(), m_dq_max(), - m_ddq_max(), m_njoints(7), m_delta_t(0.001), m_flagJointLimit(false) - { - } - virtual ~vpJointVelTrajGenerator() {} + m_dist_AD(), m_dq_des(), m_dq_des_prev(), m_dist_to_final(), m_flagSpeed(), m_q_min(), m_q_max(), m_dq_max(), + m_ddq_max(), m_njoints(7), m_delta_t(0.001), m_flagJointLimit(false) + { } + virtual ~vpJointVelTrajGenerator() { } void applyVel(const std::array &dq_des, std::array &q_cmd, std::array &dq_cmd); @@ -81,7 +84,8 @@ class vpJointVelTrajGenerator const std::array &last_desired_values); private: - typedef enum { + typedef enum + { FLAGACC, // Axis in acceleration FLAGCTE, // Axis at constant velocity FLAGDEC, // Axis in deceleration @@ -116,6 +120,8 @@ class vpJointVelTrajGenerator const double m_offset_joint_limit = vpMath::rad(1); // stop before joint limit (rad) const double m_delta_q_min = 1e-9; // Delta q minimum (rad) }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/real-robot/franka/vpRobotFranka.cpp b/modules/robot/src/real-robot/franka/vpRobotFranka.cpp index 579dc4ffe1..f370aac969 100644 --- a/modules/robot/src/real-robot/franka/vpRobotFranka.cpp +++ b/modules/robot/src/real-robot/franka/vpRobotFranka.cpp @@ -45,6 +45,10 @@ #include "vpJointPosTrajGenerator_impl.h" #include "vpJointVelTrajGenerator_impl.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. @@ -1348,7 +1352,9 @@ int vpRobotFranka::gripperGrasp(double grasping_width, double speed, double forc return EXIT_SUCCESS; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotFranka.cpp.o) has // no symbols diff --git a/modules/robot/src/real-robot/kinova/vpRobotKinova.cpp b/modules/robot/src/real-robot/kinova/vpRobotKinova.cpp index 0b82a0095e..b00e7f0c2a 100644 --- a/modules/robot/src/real-robot/kinova/vpRobotKinova.cpp +++ b/modules/robot/src/real-robot/kinova/vpRobotKinova.cpp @@ -33,6 +33,11 @@ * *****************************************************************************/ +/*! + * \file vpRobotKinova.cpp + * \brief Interface for Kinova Jaco2 robot. + */ + #include #ifdef VISP_HAVE_JACOSDK @@ -40,20 +45,19 @@ #include #include -/*! - * \file vpRobotKinova.cpp - * \brief Interface for Kinova Jaco2 robot. - */ - #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor that consider a 6 DoF Jaco arm. Use setDoF() to change the degrees of freedom. */ vpRobotKinova::vpRobotKinova() : m_eMc(), m_plugin_location("./"), m_verbose(false), m_plugin_loaded(false), m_devices_count(0), - m_devices_list(nullptr), m_active_device(-1), m_command_layer(CMD_LAYER_UNSET), m_command_layer_handle() + m_devices_list(nullptr), m_active_device(-1), m_command_layer(CMD_LAYER_UNSET), m_command_layer_handle() { init(); } @@ -78,7 +82,8 @@ void vpRobotKinova::setDoF(unsigned int dof) { if (dof == 4 || dof == 6 || dof == 7) { nDof = dof; - } else { + } + else { throw(vpException(vpException::fatalError, "Unsupported Kinova Jaco degrees of freedom: %d. Possible values are 4, 6 or 7.", dof)); } @@ -518,7 +523,8 @@ void vpRobotKinova::getPosition(const vpRobot::vpControlFrameType frame, vpColVe if (frame == JOINT_STATE) { getJointPosition(position); - } else if (frame == END_EFFECTOR_FRAME) { + } + else if (frame == END_EFFECTOR_FRAME) { CartesianPosition currentCommand; // We get the actual cartesian position of the robot KinovaGetCartesianCommand(currentCommand); @@ -529,7 +535,8 @@ void vpRobotKinova::getPosition(const vpRobot::vpControlFrameType frame, vpColVe position[3] = currentCommand.Coordinates.ThetaX; position[4] = currentCommand.Coordinates.ThetaY; position[5] = currentCommand.Coordinates.ThetaZ; - } else { + } + else { std::cout << "Not implemented ! " << std::endl; } } @@ -635,7 +642,8 @@ void vpRobotKinova::setPosition(const vpRobot::vpControlFrameType frame, const v std::cout << "Move robot to joint position [rad rad rad rad rad rad]: " << q.t() << std::endl; } KinovaSendBasicTrajectory(pointToSend); - } else if (frame == vpRobot::END_EFFECTOR_FRAME) { + } + else if (frame == vpRobot::END_EFFECTOR_FRAME) { if (q.size() != 6) { throw(vpException(vpException::fatalError, "Cannot move robot to cartesian position of dim %d that is not a 6-dim vector", q.size())); @@ -659,7 +667,8 @@ void vpRobotKinova::setPosition(const vpRobot::vpControlFrameType frame, const v } KinovaSendBasicTrajectory(pointToSend); - } else { + } + else { throw(vpException(vpException::fatalError, "Cannot move robot to a cartesian position. Only joint positioning is implemented")); } @@ -707,7 +716,7 @@ void vpRobotKinova::loadPlugin() #ifdef __linux__ // We load the API std::string plugin_name = (m_command_layer == CMD_LAYER_USB) ? std::string("Kinova.API.USBCommandLayerUbuntu.so") - : std::string("Kinova.API.EthCommandLayerUbuntu.so"); + : std::string("Kinova.API.EthCommandLayerUbuntu.so"); std::string plugin = vpIoTools::createFilePath(m_plugin_location, plugin_name); if (m_verbose) { std::cout << "Load plugin: \"" << plugin << "\"" << std::endl; @@ -718,7 +727,7 @@ void vpRobotKinova::loadPlugin() // We load the functions from the library KinovaCloseAPI = (int (*)())dlsym(m_command_layer_handle, (prefix + std::string("CloseAPI")).c_str()); KinovaGetAngularCommand = - (int (*)(AngularPosition &))dlsym(m_command_layer_handle, (prefix + std::string("GetAngularCommand")).c_str()); + (int (*)(AngularPosition &))dlsym(m_command_layer_handle, (prefix + std::string("GetAngularCommand")).c_str()); KinovaGetCartesianCommand = (int (*)(CartesianPosition &))dlsym( m_command_layer_handle, (prefix + std::string("GetCartesianCommand")).c_str()); KinovaGetDevices = (int (*)(KinovaDevice devices[MAX_KINOVA_DEVICE], int &result))dlsym( @@ -727,17 +736,17 @@ void vpRobotKinova::loadPlugin() KinovaInitFingers = (int (*)())dlsym(m_command_layer_handle, (prefix + std::string("InitFingers")).c_str()); KinovaMoveHome = (int (*)())dlsym(m_command_layer_handle, (prefix + std::string("MoveHome")).c_str()); KinovaSendBasicTrajectory = - (int (*)(TrajectoryPoint))dlsym(m_command_layer_handle, (prefix + std::string("SendBasicTrajectory")).c_str()); + (int (*)(TrajectoryPoint))dlsym(m_command_layer_handle, (prefix + std::string("SendBasicTrajectory")).c_str()); KinovaSetActiveDevice = - (int (*)(KinovaDevice devices))dlsym(m_command_layer_handle, (prefix + std::string("SetActiveDevice")).c_str()); + (int (*)(KinovaDevice devices))dlsym(m_command_layer_handle, (prefix + std::string("SetActiveDevice")).c_str()); KinovaSetAngularControl = - (int (*)())dlsym(m_command_layer_handle, (prefix + std::string("SetAngularControl")).c_str()); + (int (*)())dlsym(m_command_layer_handle, (prefix + std::string("SetAngularControl")).c_str()); KinovaSetCartesianControl = - (int (*)())dlsym(m_command_layer_handle, (prefix + std::string("SetCartesianControl")).c_str()); + (int (*)())dlsym(m_command_layer_handle, (prefix + std::string("SetCartesianControl")).c_str()); #elif _WIN32 // We load the API. std::string plugin_name = (m_command_layer == CMD_LAYER_USB) ? std::string("CommandLayerWindows.dll") - : std::string("CommandLayerEthernet.dll"); + : std::string("CommandLayerEthernet.dll"); std::string plugin = vpIoTools::createFilePath(m_plugin_location, plugin_name); if (m_verbose) { std::cout << "Load plugin: \"" << plugin << "\"" << std::endl; @@ -748,9 +757,9 @@ void vpRobotKinova::loadPlugin() KinovaCloseAPI = (int (*)())GetProcAddress(m_command_layer_handle, "CloseAPI"); KinovaGetAngularCommand = (int (*)(AngularPosition &))GetProcAddress(m_command_layer_handle, "GetAngularCommand"); KinovaGetCartesianCommand = - (int (*)(CartesianPosition &))GetProcAddress(m_command_layer_handle, "GetCartesianCommand"); + (int (*)(CartesianPosition &))GetProcAddress(m_command_layer_handle, "GetCartesianCommand"); KinovaGetDevices = - (int (*)(KinovaDevice[MAX_KINOVA_DEVICE], int &))GetProcAddress(m_command_layer_handle, "GetDevices"); + (int (*)(KinovaDevice[MAX_KINOVA_DEVICE], int &))GetProcAddress(m_command_layer_handle, "GetDevices"); KinovaInitAPI = (int (*)())GetProcAddress(m_command_layer_handle, "InitAPI"); KinovaInitFingers = (int (*)())GetProcAddress(m_command_layer_handle, "InitFingers"); KinovaMoveHome = (int (*)())GetProcAddress(m_command_layer_handle, "MoveHome"); @@ -869,9 +878,11 @@ void vpRobotKinova::setActiveDevice(int device) KinovaSetActiveDevice(m_devices_list[m_active_device]); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotKinova.cpp.o) has // no symbols -void dummy_vpRobotKinova(){}; +void dummy_vpRobotKinova() { }; #endif diff --git a/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp b/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp index b7859649ac..45f6e038ee 100644 --- a/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp +++ b/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp @@ -59,6 +59,10 @@ using std::chrono::seconds; using std::this_thread::sleep_for; using namespace std::chrono_literals; +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpRobotMavsdk::vpRobotMavsdkImpl { @@ -1578,7 +1582,9 @@ void vpRobotMavsdk::setVerbose(bool verbose) { m_impl->setVerbose(verbose); } * all the other vehicles are considered with flying capabilities. */ bool vpRobotMavsdk::hasFlyingCapability() { return m_impl->getFlyingCapability(); } - +#ifdef ENABLE_VISP_NAMESPACE + } +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotMavsdk.cpp.o) has no symbols void dummy_vpRobotMavsdk() { }; diff --git a/modules/robot/src/real-robot/pioneer/vpRobotPioneer.cpp b/modules/robot/src/real-robot/pioneer/vpRobotPioneer.cpp index 84658c4d3f..cefc286a4e 100644 --- a/modules/robot/src/real-robot/pioneer/vpRobotPioneer.cpp +++ b/modules/robot/src/real-robot/pioneer/vpRobotPioneer.cpp @@ -45,6 +45,10 @@ #ifdef VISP_HAVE_PIONEER +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor that initializes Aria. */ @@ -234,7 +238,9 @@ vpColVector vpRobotPioneer::getVelocity(const vpRobot::vpControlFrameType frame) getVelocity(frame, velocity); return velocity; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotPioneer.cpp.o) has no symbols void dummy_vpRobotPioneer() { }; diff --git a/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp b/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp index 3f631be8fe..d72b4d3318 100644 --- a/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp +++ b/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp @@ -47,6 +47,10 @@ std::chrono::milliseconds millis(1); +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif RPMSerialInterface *vpPololu::m_interface = nullptr; int vpPololu::m_nb_servo = 0; @@ -331,7 +335,9 @@ void vpPololu::VelocityCmdThread() std::this_thread::sleep_for(20 * millis); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpPololu.cpp.o) has no symbols void dummy_vpPololu() { }; diff --git a/modules/robot/src/real-robot/pololu-maestro/vpRobotPololuPtu.cpp b/modules/robot/src/real-robot/pololu-maestro/vpRobotPololuPtu.cpp index 253dce7c61..2cffa318df 100644 --- a/modules/robot/src/real-robot/pololu-maestro/vpRobotPololuPtu.cpp +++ b/modules/robot/src/real-robot/pololu-maestro/vpRobotPololuPtu.cpp @@ -40,6 +40,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpRobotPololuPtu::vpRobotPololuPtu(const std::string &device, int baudrate, bool verbose) : m_verbose(verbose) { @@ -289,7 +293,9 @@ void vpRobotPololuPtu::getPosition(const vpRobot::vpControlFrameType frame, vpCo q[0] = m_pan.getAngularPosition(); q[1] = m_tilt.getAngularPosition(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotPololuPtu.cpp.o) has no symbols void dummy_vpRobotPololuPtu() { }; diff --git a/modules/robot/src/real-robot/ptu46/vpPtu46.cpp b/modules/robot/src/real-robot/ptu46/vpPtu46.cpp index 755bd43b2b..7b11be3a91 100644 --- a/modules/robot/src/real-robot/ptu46/vpPtu46.cpp +++ b/modules/robot/src/real-robot/ptu46/vpPtu46.cpp @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ------------------------------------------------------------------------ */ /* --- COMPUTE ------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -291,3 +295,6 @@ void vpPtu46::get_fJe(const vpColVector &q, vpMatrix &fJe) const fJe[4][1] = -c1; fJe[5][0] = 1; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/real-robot/ptu46/vpRobotPtu46.cpp b/modules/robot/src/real-robot/ptu46/vpRobotPtu46.cpp index 8cfa8d0484..b9962629b5 100644 --- a/modules/robot/src/real-robot/ptu46/vpRobotPtu46.cpp +++ b/modules/robot/src/real-robot/ptu46/vpRobotPtu46.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ---------------------------------------------------------------------- */ /* --- STATIC ------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -768,7 +772,9 @@ void vpRobotPtu46::getDisplacement(vpRobot::vpControlFrameType frame, vpColVecto } } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotPtu46.cpp.o) has no symbols void dummy_vpRobotPtu46() { }; diff --git a/modules/robot/src/real-robot/universal-robots/vpRobotUniversalRobots.cpp b/modules/robot/src/real-robot/universal-robots/vpRobotUniversalRobots.cpp index daed273a17..2ef8a392f6 100644 --- a/modules/robot/src/real-robot/universal-robots/vpRobotUniversalRobots.cpp +++ b/modules/robot/src/real-robot/universal-robots/vpRobotUniversalRobots.cpp @@ -40,6 +40,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor. * - set eMc transformation to eye() @@ -872,7 +876,9 @@ vpRobot::vpRobotStateType vpRobotUniversalRobots::setRobotState(vpRobot::vpRobot return vpRobot::setRobotState(newState); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotUniversalRobots.cpp.o) has no symbols void dummy_vpRobotUniversalRobots() { }; diff --git a/modules/robot/src/real-robot/viper/vpRobotViper650.cpp b/modules/robot/src/real-robot/viper/vpRobotViper650.cpp index bbca9c63e8..d4a50b1d9e 100644 --- a/modules/robot/src/real-robot/viper/vpRobotViper650.cpp +++ b/modules/robot/src/real-robot/viper/vpRobotViper650.cpp @@ -51,6 +51,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ---------------------------------------------------------------------- */ /* --- STATIC ----------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ @@ -2557,7 +2561,9 @@ void vpRobotViper650::closeGripper() const throw vpRobotException(vpRobotException::lowLevelError, "Cannot close the gripper."); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotViper650.cpp.o) has // no symbols diff --git a/modules/robot/src/real-robot/viper/vpRobotViper850.cpp b/modules/robot/src/real-robot/viper/vpRobotViper850.cpp index 56e2861579..8990447a97 100644 --- a/modules/robot/src/real-robot/viper/vpRobotViper850.cpp +++ b/modules/robot/src/real-robot/viper/vpRobotViper850.cpp @@ -51,6 +51,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* ---------------------------------------------------------------------- */ /* --- STATIC ----------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ @@ -2631,7 +2635,9 @@ void vpRobotViper850::setMaxRotationVelocityJoint6(double w6_max) \return Maximum rotation velocity on joint 6 expressed in rad/s. */ double vpRobotViper850::getMaxRotationVelocityJoint6() const { return maxRotationVelocity_joint6; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotViper850.cpp.o) has // no symbols diff --git a/modules/robot/src/real-robot/viper/vpViper.cpp b/modules/robot/src/real-robot/viper/vpViper.cpp index 0425c47140..5732e43cde 100644 --- a/modules/robot/src/real-robot/viper/vpViper.cpp +++ b/modules/robot/src/real-robot/viper/vpViper.cpp @@ -52,6 +52,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const unsigned int vpViper::njoint = 6; /*! @@ -1286,3 +1290,6 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpViper &viper) return os; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/real-robot/viper/vpViper650.cpp b/modules/robot/src/real-robot/viper/vpViper650.cpp index a2848c9810..13554566a6 100644 --- a/modules/robot/src/real-robot/viper/vpViper650.cpp +++ b/modules/robot/src/real-robot/viper/vpViper650.cpp @@ -48,6 +48,10 @@ static const char *opt_viper650[] = { "CAMERA", "eMc_ROT_XYZ", "eMc_TRANS_XYZ", nullptr }; +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef VISP_HAVE_VIPER650_DATA const std::string vpViper650::CONST_EMC_MARLIN_F033C_WITHOUT_DISTORTION_FILENAME = std::string(VISP_VIPER650_DATA_PATH) + @@ -828,3 +832,6 @@ void vpViper650::getCameraParameters(vpCameraParameters &cam, const vpImage #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Constructor. @@ -246,7 +250,9 @@ void vpRobotCamera::setPosition(const vpHomogeneousMatrix &cMw) this->cMw_ = cMw; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpRobotCamera.cpp.o) has no symbols void dummy_vpRobotCamera() { }; diff --git a/modules/robot/src/robot-simulator/vpRobotSimulator.cpp b/modules/robot/src/robot-simulator/vpRobotSimulator.cpp index c131bdce4f..d984c63bf7 100644 --- a/modules/robot/src/robot-simulator/vpRobotSimulator.cpp +++ b/modules/robot/src/robot-simulator/vpRobotSimulator.cpp @@ -37,7 +37,14 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor that sets the sampling time by default to 40ms. */ -vpRobotSimulator::vpRobotSimulator() : vpRobot(), delta_t_(0.040f) {} +vpRobotSimulator::vpRobotSimulator() : vpRobot(), delta_t_(0.040f) { } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/robot-simulator/vpRobotWireFrameSimulator.cpp b/modules/robot/src/robot-simulator/vpRobotWireFrameSimulator.cpp index 9e5d3e32f9..36c4264146 100644 --- a/modules/robot/src/robot-simulator/vpRobotWireFrameSimulator.cpp +++ b/modules/robot/src/robot-simulator/vpRobotWireFrameSimulator.cpp @@ -43,6 +43,10 @@ #include "../wireframe-simulator/vpScene.h" #include "../wireframe-simulator/vpVwstack.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor */ @@ -354,7 +358,9 @@ vpHomogeneousMatrix vpRobotWireFrameSimulator::get_cMo() delete[] fMit; return cMoTemp; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: // libvisp_robot.a(vpRobotWireFrameSimulator.cpp.o) has no symbols diff --git a/modules/robot/src/robot-simulator/vpSimulatorAfma6.cpp b/modules/robot/src/robot-simulator/vpSimulatorAfma6.cpp index 4a68074d8b..9940ef3f4f 100644 --- a/modules/robot/src/robot-simulator/vpSimulatorAfma6.cpp +++ b/modules/robot/src/robot-simulator/vpSimulatorAfma6.cpp @@ -51,6 +51,10 @@ #include "../wireframe-simulator/vpScene.h" #include "../wireframe-simulator/vpVwstack.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const double vpSimulatorAfma6::defaultPositioningVelocity = 25.0; /*! @@ -2467,7 +2471,9 @@ bool vpSimulatorAfma6::setPosition(const vpHomogeneousMatrix &cdMo_, vpImage #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor that sets the transformation between world frame and camera frame to identity. @@ -238,3 +242,6 @@ void vpSimulatorCamera::setPosition(const vpHomogeneousMatrix &wMc) this->wMc_ = wMc; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/robot-simulator/vpSimulatorPioneer.cpp b/modules/robot/src/robot-simulator/vpSimulatorPioneer.cpp index 8ac4d4eeb6..6a053fadff 100644 --- a/modules/robot/src/robot-simulator/vpSimulatorPioneer.cpp +++ b/modules/robot/src/robot-simulator/vpSimulatorPioneer.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Constructor. @@ -216,3 +220,6 @@ void vpSimulatorPioneer::getPosition(const vpRobot::vpControlFrameType frame, vp break; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/robot-simulator/vpSimulatorPioneerPan.cpp b/modules/robot/src/robot-simulator/vpSimulatorPioneerPan.cpp index b34b6a89fc..1888cf1e8e 100644 --- a/modules/robot/src/robot-simulator/vpSimulatorPioneerPan.cpp +++ b/modules/robot/src/robot-simulator/vpSimulatorPioneerPan.cpp @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Constructor. @@ -231,3 +235,6 @@ void vpSimulatorPioneerPan::getPosition(const vpRobot::vpControlFrameType frame, break; } } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/robot-simulator/vpSimulatorViper850.cpp b/modules/robot/src/robot-simulator/vpSimulatorViper850.cpp index b0780323d1..fd909fab6c 100644 --- a/modules/robot/src/robot-simulator/vpSimulatorViper850.cpp +++ b/modules/robot/src/robot-simulator/vpSimulatorViper850.cpp @@ -51,6 +51,10 @@ #include "../wireframe-simulator/vpScene.h" #include "../wireframe-simulator/vpVwstack.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const double vpSimulatorViper850::defaultPositioningVelocity = 25.0; /*! @@ -2358,7 +2362,9 @@ void vpSimulatorViper850::initialiseObjectRelativeToCamera(const vpHomogeneousMa fMo = fMit[7] * cMo_; m_mutex_scene.unlock(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_robot.a(vpSimulatorViper850.cpp.o) // has no symbols diff --git a/modules/robot/src/vpRobot.cpp b/modules/robot/src/vpRobot.cpp index 157997457c..3fceb70ef5 100644 --- a/modules/robot/src/vpRobot.cpp +++ b/modules/robot/src/vpRobot.cpp @@ -37,6 +37,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const double vpRobot::maxTranslationVelocityDefault = 0.2; const double vpRobot::maxRotationVelocityDefault = 0.7; @@ -49,17 +53,16 @@ const double vpRobot::maxRotationVelocityDefault = 0.7; vpRobot::vpRobot(void) : stateRobot(vpRobot::STATE_STOP), frameRobot(vpRobot::CAMERA_FRAME), - maxTranslationVelocity(maxTranslationVelocityDefault), maxRotationVelocity(maxRotationVelocityDefault), nDof(0), - eJe(), eJeAvailable(false), fJe(), fJeAvailable(false), areJointLimitsAvailable(false), qmin(nullptr), qmax(nullptr), - verbose_(true) -{ -} + maxTranslationVelocity(maxTranslationVelocityDefault), maxRotationVelocity(maxRotationVelocityDefault), nDof(0), + eJe(), eJeAvailable(false), fJe(), fJeAvailable(false), areJointLimitsAvailable(false), qmin(nullptr), qmax(nullptr), + verbose_(true) +{ } vpRobot::vpRobot(const vpRobot &robot) : stateRobot(vpRobot::STATE_STOP), frameRobot(vpRobot::CAMERA_FRAME), - maxTranslationVelocity(maxTranslationVelocityDefault), maxRotationVelocity(maxRotationVelocityDefault), nDof(0), - eJe(), eJeAvailable(false), fJe(), fJeAvailable(false), areJointLimitsAvailable(false), qmin(nullptr), qmax(nullptr), - verbose_(true) + maxTranslationVelocity(maxTranslationVelocityDefault), maxRotationVelocity(maxRotationVelocityDefault), nDof(0), + eJe(), eJeAvailable(false), fJe(), fJeAvailable(false), areJointLimitsAvailable(false), qmin(nullptr), qmax(nullptr), + verbose_(true) { *this = robot; } @@ -268,3 +271,6 @@ void vpRobot::setMaxRotationVelocity(double w_max) \return Maximum rotation velocity expressed in rad/s. */ double vpRobot::getMaxRotationVelocity(void) const { return this->maxRotationVelocity; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/vpRobotTemplate.cpp b/modules/robot/src/vpRobotTemplate.cpp index 523774c265..f778a16ebb 100644 --- a/modules/robot/src/vpRobotTemplate.cpp +++ b/modules/robot/src/vpRobotTemplate.cpp @@ -45,6 +45,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic initialization. */ @@ -277,7 +281,8 @@ void vpRobotTemplate::getPosition(const vpRobot::vpControlFrameType frame, vpCol { if (frame == JOINT_STATE) { getJointPosition(q); - } else { + } + else { std::cout << "Not implemented ! " << std::endl; } } @@ -307,3 +312,6 @@ void vpRobotTemplate::getDisplacement(const vpRobot::vpControlFrameType frame, v (void)q; std::cout << "Not implemented ! " << std::endl; } +#ifdef ENABLE_VISP_NAMESPACE +} +#endif diff --git a/modules/robot/src/wireframe-simulator/vpArit.cpp b/modules/robot/src/wireframe-simulator/vpArit.cpp index 4e1455bb93..69edf6d819 100644 --- a/modules/robot/src/wireframe-simulator/vpArit.cpp +++ b/modules/robot/src/wireframe-simulator/vpArit.cpp @@ -44,6 +44,10 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "fprintf_matrix" affiche une matrice sur un fichier. * Entree : @@ -282,10 +286,11 @@ float cosin_to_angle(float ca, float sa) if (FABS(ca) < M_EPSILON) { a = (sa > (float)0.0) ? (float)M_PI_2 : (float)(-M_PI_2); - } else { + } + else { a = (float)atan((double)(sa / ca)); if (ca < (float)0.0) - a += (sa > (float)0.0) ? (float)M_PI : (float)(-M_PI); + a += (sa >(float)0.0) ? (float)M_PI : (float)(-M_PI); } return (a); } @@ -353,7 +358,8 @@ float norm_vector(Vector *vp) vp->x /= norm; vp->y /= norm; vp->z /= norm; - } else { + } + else { static char proc_name[] = "norm_vector"; fprintf(stderr, "%s: nul vector\n", proc_name); } @@ -499,13 +505,16 @@ void upright_vector(Vector *vp, Vector *up) if (FABS(vp->z) > M_EPSILON) { /* x et y sont fixes */ up->z = -(vp->x + vp->y) / vp->z; up->x = up->y = 1.0; - } else if (FABS(vp->y) > M_EPSILON) { /* x et z sont fixes */ + } + else if (FABS(vp->y) > M_EPSILON) { /* x et z sont fixes */ up->y = -(vp->x + vp->z) / vp->y; up->x = up->z = 1.0; - } else if (FABS(vp->x) > M_EPSILON) { /* y et z sont fixes */ + } + else if (FABS(vp->x) > M_EPSILON) { /* y et z sont fixes */ up->x = -(vp->y + vp->z) / vp->x; up->y = up->z = 1.0; - } else { + } + else { static char proc_name[] = "upright_vector"; up->x = up->y = up->z = 0.0; fprintf(stderr, "%s: nul vector\n", proc_name); @@ -568,7 +577,8 @@ void Matrix_to_Rotate(Matrix m, Vector *vp) cx = m[2][2] / cy; SET_COORD3(*vp, cosin_to_angle(cx, sx), cosin_to_angle(cy, sy), cosin_to_angle(cz, sz)); - } else { /* RZ = 0 => Ry = +/- 90 degres */ + } + else { /* RZ = 0 => Ry = +/- 90 degres */ sx = m[1][1]; cx = -m[2][1]; @@ -618,9 +628,9 @@ void Position_to_Matrix(AritPosition *pp, Matrix m) void Rotate_to_Matrix(Vector *vp, Matrix m) { float rx = vp->x * (float)M_PI / (float)180.0, /* passage en radians */ - ry = vp->y * (float)M_PI / (float)180.0, rz = vp->z * (float)M_PI / (float)180.0; + ry = vp->y * (float)M_PI / (float)180.0, rz = vp->z * (float)M_PI / (float)180.0; float cx = (float)cos((double)rx), sx = (float)sin((double)rx), cy = (float)cos((double)ry), - sy = (float)sin((double)ry), cz = (float)cos((double)rz), sz = (float)sin((double)rz); + sy = (float)sin((double)ry), cz = (float)cos((double)rz), sz = (float)sin((double)rz); m[0][0] = cy * cz; m[1][0] = (sx * sy * cz) - (cx * sz); @@ -742,5 +752,7 @@ void Translate_to_Matrix(Vector *vp, Matrix m) m[3][1] = vp->y; m[3][2] = vp->z; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpArit.h b/modules/robot/src/wireframe-simulator/vpArit.h index 2e043502ad..dd0b73c88f 100644 --- a/modules/robot/src/wireframe-simulator/vpArit.h +++ b/modules/robot/src/wireframe-simulator/vpArit.h @@ -149,23 +149,32 @@ #define M_POLY2(x, a, b, c) (M_POLY1((x), (a), (b)) * (x) + (c)) #define M_POLY3(x, a, b, c, d) (M_POLY2((x), (a), (b), (c)) * (x) + (d)) -typedef struct { +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +typedef struct +{ int x, y; } Point2i; -typedef struct { +typedef struct +{ short x, y; } Point2s; -typedef struct { +typedef struct +{ int x, y, z; } Point3i; -typedef struct { +typedef struct +{ float x, y, z, w; } Point4f; -typedef struct { +typedef struct +{ float x, y, z; } Vector; @@ -185,7 +194,8 @@ typedef struct { * S = Sx.Sy.Sz Matrice d'homothetie sur les axes; * T = Tx.Ty.Tz Matrice de translation sur les axes. */ -typedef struct { +typedef struct +{ Vector rotate; /* vecteur rotation */ Vector scale; /* vecteur homothetie */ Vector translate; /* vecteur translation */ @@ -242,6 +252,8 @@ void Translate_to_Matrix(Vector *vp, Matrix m); void fscanf_Point3f(Point3f *pp); void fscanf_Vector(Vector *vp); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpAritio.cpp b/modules/robot/src/wireframe-simulator/vpAritio.cpp index d5cd1d50bf..1d6c5e9f4a 100644 --- a/modules/robot/src/wireframe-simulator/vpAritio.cpp +++ b/modules/robot/src/wireframe-simulator/vpAritio.cpp @@ -49,6 +49,11 @@ #include "vpToken.h" #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "fprintf_Position" ecrit en ascii un positionnement. * Entree : @@ -68,7 +73,7 @@ void fprintf_Position(FILE *f, AritPosition *pp) */ void fscanf_Point3f(Point3f *pp) { - static const char *err_tbl[] = {"float expected (coordinate ", " of point)"}; + static const char *err_tbl[] = { "float expected (coordinate ", " of point)" }; int t; /* Lecture de la premiere coordonnee du point. */ @@ -97,7 +102,7 @@ void fscanf_Point3f(Point3f *pp) */ void fscanf_Vector(Vector *vp) { - static const char *err_tbl[] = {"float expected (coordinate ", " of vector)"}; + static const char *err_tbl[] = { "float expected (coordinate ", " of vector)" }; int t; @@ -135,5 +140,7 @@ void fscanf_Position(AritPosition *pp) fscanf_Vector(&pp->translate); poperr(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpAritio.h b/modules/robot/src/wireframe-simulator/vpAritio.h index 847e2f5351..897f5d2e9a 100644 --- a/modules/robot/src/wireframe-simulator/vpAritio.h +++ b/modules/robot/src/wireframe-simulator/vpAritio.h @@ -50,10 +50,16 @@ #include "vpArit.h" #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void fprintf_Position(FILE *f, AritPosition *pp); void fscanf_Point3f(Point3f *pp); void fscanf_Vector(Vector *vp); void fscanf_Position(AritPosition *pp); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpBound.cpp b/modules/robot/src/wireframe-simulator/vpBound.cpp index b02f2358e1..ab65b56a76 100644 --- a/modules/robot/src/wireframe-simulator/vpBound.cpp +++ b/modules/robot/src/wireframe-simulator/vpBound.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "free_Bound" libere la memoire d'une surface. * Les champs "bound.face.edge" ne sont pas utilises. @@ -217,5 +221,7 @@ void malloc_Bound_scene(Bound_scene *bsp, const char *name, Index bn) strcpy(bsp->name, name); bsp->bound.nbr = 0; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpBound.h b/modules/robot/src/wireframe-simulator/vpBound.h index 10ead99c45..6cbc540744 100644 --- a/modules/robot/src/wireframe-simulator/vpBound.h +++ b/modules/robot/src/wireframe-simulator/vpBound.h @@ -78,34 +78,43 @@ #define VECTOR_NBR 6144 #endif // face_normal +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifdef face_edge -typedef struct { +typedef struct +{ Index v0, v1; /* extremites */ Index f0, f1; /* faces */ } Edge; #endif // face_edge #ifdef face_edge -typedef struct { +typedef struct +{ Index nbr; /* nombre d'aretes */ Edge *ptr; /* liste dynamique */ } Edge_list; #endif // face_edge #ifdef face_normal -typedef struct { +typedef struct +{ Index nbr; /* nombre de vecteurs */ Vector *ptr; /* liste dynamique */ } Vector_list; #endif // face_normal -typedef struct { +typedef struct +{ float xmin, xmax; /* bornes sur l'axe x */ float ymin, ymax; /* bornes sur l'axe y */ float zmin, zmax; /* bornes sur l'axe z */ } Bounding_box; -typedef struct { +typedef struct +{ Index nbr; /* nombre de scenes */ Bound_scene *ptr; /* liste dynamique */ } Bound_scene_list; @@ -116,6 +125,8 @@ void free_Bound_scene(Bound_scene *bsp); void malloc_Bound(Bound *bp, Type type, int polygonal, Index fn, Index pn); void malloc_huge_Bound(Bound *bp); void malloc_Bound_scene(Bound_scene *bsp, const char *name, Index bn); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpBoundio.cpp b/modules/robot/src/wireframe-simulator/vpBoundio.cpp index 885dc77f69..e3429e758a 100644 --- a/modules/robot/src/wireframe-simulator/vpBoundio.cpp +++ b/modules/robot/src/wireframe-simulator/vpBoundio.cpp @@ -55,6 +55,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "fscanf_Bound" lit en ascii une surface. * Entree : @@ -158,7 +162,7 @@ void fscanf_Face_list(Face_list *lp) */ void fscanf_Point3f_list(Point3f_list *lp) { - static const char *err_tbl[] = {"float expected (coordinate ", " of point)"}; + static const char *err_tbl[] = { "float expected (coordinate ", " of point)" }; Point3f *pp; /* point courant */ Point3f *pend; /* borne de "pp" */ @@ -201,5 +205,7 @@ void fscanf_Point3f_list(Point3f_list *lp) pp->z = (t == T_INT) ? (float)myint : myfloat; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpBoundio.h b/modules/robot/src/wireframe-simulator/vpBoundio.h index 297dbba28d..fdf1561040 100644 --- a/modules/robot/src/wireframe-simulator/vpBoundio.h +++ b/modules/robot/src/wireframe-simulator/vpBoundio.h @@ -49,9 +49,15 @@ #include "vpBound.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void fscanf_Bound(Bound *bp); void fscanf_Face_list(Face_list *lp); void fscanf_Point3f_list(Point3f_list *lp); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpClipping.cpp b/modules/robot/src/wireframe-simulator/vpClipping.cpp index e4fa204653..9059463cec 100644 --- a/modules/robot/src/wireframe-simulator/vpClipping.cpp +++ b/modules/robot/src/wireframe-simulator/vpClipping.cpp @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif static void inter(Byte mask, Index v0, Index v1); static void point_4D_3D(Point4f *p4, int size, Byte *cp, Point3f *p3); @@ -119,7 +123,7 @@ void open_clipping(void) throw vpException(vpException::fatalError, "Error in open_clipping"); } #else - || (poly_tmp = (Index *)malloc(VERTEX_NBR * sizeof(Index))) == NULL) { + || (poly_tmp = (Index *)malloc(VERTEX_NBR * sizeof(Index))) == NULL) { static char proc_name[] = "open_clipping"; perror(proc_name); throw vpException(vpException::fatalError, "Error in open_clipping"); @@ -175,17 +179,20 @@ static Index clipping(Byte mask, Index vni, Index *pi, Index *po) if (ins == IS_INSIDE) { if (inp == IS_INSIDE) { /* arete interieure */ *po++ = vp; - } else { /* intersection */ + } + else { /* intersection */ inter(mask, vs, vp); *po++ = point4f_nbr++; } - } else { + } + else { if (inp == IS_INSIDE) { /* intersection */ inter(mask, vs, vp); *po++ = point4f_nbr++; *po++ = vp; vno++; - } else { /* arete exterieure */ + } + else { /* arete exterieure */ vno--; } } @@ -398,7 +405,8 @@ static void point_4D_3D(Point4f *p4, int size, Byte *cp, Point3f *p3) p3->x = p4->x / w; /* projection 4D en 3D */ p3->y = p4->y / w; p3->z = p4->z / w; - } else { /* marque invisible */ + } + else { /* marque invisible */ p3->z = -1.0; } } @@ -458,5 +466,7 @@ Byte where_is_Point4f(Point4f *p4) b |= IS_FRONT; return (b); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpClipping.h b/modules/robot/src/wireframe-simulator/vpClipping.h index 32ef60994a..704fee16f4 100644 --- a/modules/robot/src/wireframe-simulator/vpClipping.h +++ b/modules/robot/src/wireframe-simulator/vpClipping.h @@ -53,12 +53,18 @@ #include "vpBound.h" #include "vpMy.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void open_clipping(void); void open_clipping(void); void close_clipping(void); Bound *clipping_Bound(Bound *bp, Matrix m); void set_Point4f_code(Point4f *p4, int size, Byte *cp); Byte where_is_Point4f(Point4f *p4); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpCoreDisplay.cpp b/modules/robot/src/wireframe-simulator/vpCoreDisplay.cpp index f77e4151bd..72dce0def4 100644 --- a/modules/robot/src/wireframe-simulator/vpCoreDisplay.cpp +++ b/modules/robot/src/wireframe-simulator/vpCoreDisplay.cpp @@ -51,6 +51,10 @@ #include "vpView.h" #include "vpVwstack.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * POINT2I : * Tableau de points 2D dans l'espace ecran servant a l'affichage fil-de-fer. @@ -220,5 +224,7 @@ void wireframe_Face(Face *fp, Point2i *pp) SET_COORD2(*cp, pp[*vp].x, pp[*vp].y); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpCoreDisplay.h b/modules/robot/src/wireframe-simulator/vpCoreDisplay.h index 544af033a7..59e13f1018 100644 --- a/modules/robot/src/wireframe-simulator/vpCoreDisplay.h +++ b/modules/robot/src/wireframe-simulator/vpCoreDisplay.h @@ -47,11 +47,17 @@ #include "vpArit.h" #include "vpBound.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void open_display(void); void close_display(void); void point_3D_2D(Point3f *p3, Index size, int xsize, int ysize, Point2i *p2); void set_Bound_face_display(Bound *bp, Byte b); void wireframe_Face(Face *fp, Point2i *pp); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpImstack.h b/modules/robot/src/wireframe-simulator/vpImstack.h index 60ef76271c..6ee503daf6 100644 --- a/modules/robot/src/wireframe-simulator/vpImstack.h +++ b/modules/robot/src/wireframe-simulator/vpImstack.h @@ -43,13 +43,18 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void fprintf_imstack(void); void load_imstack(void); void pop_imstack(void); void push_imstack(void); void swap_imstack(void); void add_imstack(void); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpKeyword.cpp b/modules/robot/src/wireframe-simulator/vpKeyword.cpp index 09959683d3..0ecdee4f10 100644 --- a/modules/robot/src/wireframe-simulator/vpKeyword.cpp +++ b/modules/robot/src/wireframe-simulator/vpKeyword.cpp @@ -48,7 +48,10 @@ #include #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif static void open_hash(void); static void close_hash(void); static int hashpjw(const char *str); @@ -62,7 +65,8 @@ static char *get_keyword(void); #define PRIME 211 #define NEXT(x) (x) = (x)->next -typedef struct bucket { +typedef struct bucket +{ struct bucket *next; /* element suivant */ char *ident; /* identifateur */ Byte length; /* longueur de "ident" */ @@ -231,5 +235,7 @@ Index get_symbol(char *ident, int length) } return (0); /* identificateur */ } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpKeyword.h b/modules/robot/src/wireframe-simulator/vpKeyword.h index 53486bd92d..3a61999463 100644 --- a/modules/robot/src/wireframe-simulator/vpKeyword.h +++ b/modules/robot/src/wireframe-simulator/vpKeyword.h @@ -45,10 +45,15 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void open_keyword(Keyword *kwp); void close_keyword(void); Index get_symbol(char *ident, int length); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpLex.cpp b/modules/robot/src/wireframe-simulator/vpLex.cpp index 615a8d7db1..3230ee86dd 100644 --- a/modules/robot/src/wireframe-simulator/vpLex.cpp +++ b/modules/robot/src/wireframe-simulator/vpLex.cpp @@ -55,6 +55,10 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif static void count(void); static void next_source(void); @@ -135,7 +139,7 @@ const char *lex_errtbl[] = {/* table des messages d'erreur */ "unexpected EOF in string or char constant", "newline in string or char constant", "string expected", - ""}; + "" }; char *mytext = NULL; int mylength = 0; @@ -726,7 +730,8 @@ static void next_source(void) *buf = EOF; *topbuf = EOB; /* sentinelle de fin de fichier */ mysptr = buf; - } else { + } + else { topbuf = buf + size; *topbuf = EOB; /* sentinelle de fin de buffer */ @@ -840,5 +845,7 @@ void pusherr(const char *str) } err_stack[size_stack++] = str; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpLex.h b/modules/robot/src/wireframe-simulator/vpLex.h index 837c6d6a3d..a0ebb8395a 100644 --- a/modules/robot/src/wireframe-simulator/vpLex.h +++ b/modules/robot/src/wireframe-simulator/vpLex.h @@ -46,7 +46,10 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void open_lex(void); void close_lex(void); int lex(void); @@ -58,6 +61,8 @@ void pusherr(const char *str); void popuperr(const char *str); void poperr(void); int lexecho(FILE *f, int token); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpMy.h b/modules/robot/src/wireframe-simulator/vpMy.h index ec3cb0f6f6..00615a4f83 100644 --- a/modules/robot/src/wireframe-simulator/vpMy.h +++ b/modules/robot/src/wireframe-simulator/vpMy.h @@ -85,7 +85,13 @@ (B) = (T); \ } +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif typedef unsigned char Byte; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpMyio.cpp b/modules/robot/src/wireframe-simulator/vpMyio.cpp index 0455bffe9c..b192501cb2 100644 --- a/modules/robot/src/wireframe-simulator/vpMyio.cpp +++ b/modules/robot/src/wireframe-simulator/vpMyio.cpp @@ -52,6 +52,10 @@ extern char *mytext; /* chaine du symbole courant */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "fscanf_float" lit en ascii un nombre flottant. * Entree : @@ -123,5 +127,7 @@ void fscanf_Type(Type *ip) lexerr("start", "integer expected", NULL); *ip = (Type)myint; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpMyio.h b/modules/robot/src/wireframe-simulator/vpMyio.h index 73e49dc263..74e665786a 100644 --- a/modules/robot/src/wireframe-simulator/vpMyio.h +++ b/modules/robot/src/wireframe-simulator/vpMyio.h @@ -49,11 +49,17 @@ #include "vpMy.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void fscanf_float(float *fp); void fscanf_Index(Index *ip); void fscanf_int(int *ip); void fscanf_string(char **str); void fscanf_Type(Type *ip); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpParser.cpp b/modules/robot/src/wireframe-simulator/vpParser.cpp index 4bbd3b4cd6..ac9f097155 100644 --- a/modules/robot/src/wireframe-simulator/vpParser.cpp +++ b/modules/robot/src/wireframe-simulator/vpParser.cpp @@ -47,6 +47,10 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "parser" fait l'analyse syntaxique du fichier source. * Entree/Sortie : @@ -93,5 +97,7 @@ void parser(Bound_scene *bsp) break; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpParser.h b/modules/robot/src/wireframe-simulator/vpParser.h index 7557f0257e..10b55d2dd1 100644 --- a/modules/robot/src/wireframe-simulator/vpParser.h +++ b/modules/robot/src/wireframe-simulator/vpParser.h @@ -47,7 +47,13 @@ #include "vpBound.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void parser(Bound_scene *bsp); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpProjection.cpp b/modules/robot/src/wireframe-simulator/vpProjection.cpp index fd08273c39..a65dfb622c 100644 --- a/modules/robot/src/wireframe-simulator/vpProjection.cpp +++ b/modules/robot/src/wireframe-simulator/vpProjection.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "View_to_Matrix" constuit la matrice homogene de projection * a partir des parametres de la prise de vue. @@ -231,5 +235,7 @@ void set_perspective(View_parameters *vp, Matrix wc) m[3][3] = 0.0; postmult_matrix(wc, m); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpProjection.h b/modules/robot/src/wireframe-simulator/vpProjection.h index e1602aa510..105dce24a7 100644 --- a/modules/robot/src/wireframe-simulator/vpProjection.h +++ b/modules/robot/src/wireframe-simulator/vpProjection.h @@ -47,9 +47,15 @@ #include "vpArit.h" #include "vpView.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void View_to_Matrix(View_parameters *vp, Matrix m); void set_parallel(View_parameters *vp, Matrix wc); void set_perspective(View_parameters *vp, Matrix wc); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpRfstack.cpp b/modules/robot/src/wireframe-simulator/vpRfstack.cpp index dbac55bd7b..b08fb48f8e 100644 --- a/modules/robot/src/wireframe-simulator/vpRfstack.cpp +++ b/modules/robot/src/wireframe-simulator/vpRfstack.cpp @@ -48,9 +48,13 @@ #include #define STACKSIZE 32 -static int stack[STACKSIZE] = {vpDEFAULT_REMOVE}; /* pile */ +static int stack[STACKSIZE] = { vpDEFAULT_REMOVE }; /* pile */ static int *sp = stack; /* sommet */ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "fprintf_rfstack" affiche le sommet * de la pile des drapeaux d'elimination de faces. @@ -130,7 +134,8 @@ void pop_rfstack(void) static char proc_name[] = "pop_rfstack"; fprintf(stderr, "%s: stack underflow\n", proc_name); return; - } else + } + else sp--; } @@ -176,5 +181,7 @@ void add_rfstack(int i) { *sp |= i; } * de la pile des drapeaux d'elimination de faces. */ void sub_rfstack(int i) { *sp &= ~i; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpRfstack.h b/modules/robot/src/wireframe-simulator/vpRfstack.h index 9c93afe124..9aa405ffcc 100644 --- a/modules/robot/src/wireframe-simulator/vpRfstack.h +++ b/modules/robot/src/wireframe-simulator/vpRfstack.h @@ -45,6 +45,10 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void fprintf_rfstack(FILE *fp); int *get_rfstack(void); void load_rfstack(int i); @@ -53,6 +57,8 @@ void push_rfstack(void); void swap_rfstack(void); void add_rfstack(int i); void sub_rfstack(int i); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpScene.cpp b/modules/robot/src/wireframe-simulator/vpScene.cpp index 6ea256b597..05ef8fe70c 100644 --- a/modules/robot/src/wireframe-simulator/vpScene.cpp +++ b/modules/robot/src/wireframe-simulator/vpScene.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* Get the extension of the file and return it */ @@ -138,7 +142,8 @@ void set_scene_wrl(const char *str, Bound_scene *sc, float factor) sceneGraphVRML2 = tovrml2.getVRML2SceneGraph(); sceneGraphVRML2->ref(); sceneGraph->unref(); - } else { + } + else { sceneGraphVRML2 = SoDB::readAllVRML(&in); if (sceneGraphVRML2 == NULL) { /*return -1;*/ @@ -256,7 +261,8 @@ void ifsToBound(Bound *bptr, std::list &ifs_list) nbFace++; indSize.push_back(indice); indice = 0; - } else + } + else indice++; } } @@ -280,7 +286,8 @@ void ifsToBound(Bound *bptr, std::list &ifs_list) if (ifs->index[j] != -1) { bptr->face.ptr[indice].vertex.ptr[iter] = (Index)(ifs->index[j] + offset); iter++; - } else { + } + else { iter = 0; indice++; } @@ -297,7 +304,7 @@ void destroyIfs(std::list &ifs_list) ifs_list.clear(); } #else -void set_scene_wrl(const char * /*str*/, Bound_scene * /*sc*/, float /*factor*/) {} +void set_scene_wrl(const char * /*str*/, Bound_scene * /*sc*/, float /*factor*/) { } #endif /* @@ -310,5 +317,7 @@ void vp2jlc_matrix(const vpHomogeneousMatrix &vpM, Matrix &jlcM) jlcM[j][i] = (float)vpM[i][j]; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpScene.h b/modules/robot/src/wireframe-simulator/vpScene.h index e530eaa817..b556adb0bf 100644 --- a/modules/robot/src/wireframe-simulator/vpScene.h +++ b/modules/robot/src/wireframe-simulator/vpScene.h @@ -64,16 +64,27 @@ #include #include -typedef struct indexFaceSet { - indexFaceSet() : nbPt(0), pt(), nbIndex(0), index(){}; +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +typedef struct indexFaceSet +{ + indexFaceSet() : nbPt(0), pt(), nbIndex(0), index() { }; int nbPt; std::vector pt; int nbIndex; std::vector index; } indexFaceSet; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif typedef enum { BND_MODEL, WRL_MODEL, UNKNOWN_MODEL } Model_3D; Model_3D getExtension(const char *file); @@ -86,6 +97,8 @@ void extractFaces(SoVRMLIndexedFaceSet *face_set, indexFaceSet *ifs); void ifsToBound(Bound *, std::list &); void destroyIfs(std::list &); #endif - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpSkipio.cpp b/modules/robot/src/wireframe-simulator/vpSkipio.cpp index a58d5ea2b1..aeaeae6edc 100644 --- a/modules/robot/src/wireframe-simulator/vpSkipio.cpp +++ b/modules/robot/src/wireframe-simulator/vpSkipio.cpp @@ -47,6 +47,10 @@ #include "vpToken.h" #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "skip_cmd" saute les structures d'une commande * jusqu'a reconnaitre le debut d'une nouvelle commande. @@ -97,5 +101,7 @@ void skip_keyword(int token, const char *err) } lexerr("start", err, NULL); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpSkipio.h b/modules/robot/src/wireframe-simulator/vpSkipio.h index 181e0b377f..910389bb47 100644 --- a/modules/robot/src/wireframe-simulator/vpSkipio.h +++ b/modules/robot/src/wireframe-simulator/vpSkipio.h @@ -45,8 +45,14 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void skip_cmd(void); void skip_keyword(int token, const char *err); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpTmstack.cpp b/modules/robot/src/wireframe-simulator/vpTmstack.cpp index f93f3beb8f..7626b8a37d 100644 --- a/modules/robot/src/wireframe-simulator/vpTmstack.cpp +++ b/modules/robot/src/wireframe-simulator/vpTmstack.cpp @@ -50,6 +50,10 @@ #define STACKSIZE 32 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif static Matrix stack[STACKSIZE] /* = IDENTITY_MATRIX*/; /* pile */ static Matrix *sp = stack; /* sommet */ @@ -83,7 +87,8 @@ void pop_tmstack(void) static char proc_name[] = "pop_tmstack"; fprintf(stderr, "%s: stack underflow\n", proc_name); return; - } else + } + else sp--; } @@ -195,5 +200,7 @@ void prescale_tmstack(Vector *vp) { prescale_matrix(*sp, vp); } * vp Vecteur de translation. */ void pretranslate_tmstack(Vector *vp) { pretrans_matrix(*sp, vp); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpTmstack.h b/modules/robot/src/wireframe-simulator/vpTmstack.h index 686d001340..0d4333b0cc 100644 --- a/modules/robot/src/wireframe-simulator/vpTmstack.h +++ b/modules/robot/src/wireframe-simulator/vpTmstack.h @@ -47,6 +47,10 @@ #include "vpArit.h" #include "vpMy.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif Matrix *get_tmstack(void); void load_tmstack(Matrix m); void pop_tmstack(void); @@ -61,6 +65,8 @@ void premult_tmstack(Matrix m); void prerotate_tmstack(Vector *vp); void prescale_tmstack(Vector *vp); void pretranslate_tmstack(Vector *vp); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpToken.cpp b/modules/robot/src/wireframe-simulator/vpToken.cpp index 0f23b6ef1a..7d674e5b60 100644 --- a/modules/robot/src/wireframe-simulator/vpToken.cpp +++ b/modules/robot/src/wireframe-simulator/vpToken.cpp @@ -44,6 +44,10 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif Keyword keyword_tbl[] = {/* tableau des mots cles termine par NULL*/ {"above", T_ABOVE}, {"back", T_BACK}, @@ -67,6 +71,8 @@ Keyword keyword_tbl[] = {/* tableau des mots cles termine par NULL*/ {"vrp", T_VRP}, {"vup", T_VUP}, {"window", T_WINDOW}, - {NULL, T_NULL}}; - + {NULL, T_NULL} }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpToken.h b/modules/robot/src/wireframe-simulator/vpToken.h index dd6a8cab8f..2f257bf3f7 100644 --- a/modules/robot/src/wireframe-simulator/vpToken.h +++ b/modules/robot/src/wireframe-simulator/vpToken.h @@ -45,7 +45,12 @@ #include -typedef struct { +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +typedef struct +{ const char *ident; /* identifateur */ Index token; /* code du jeton */ } Keyword; @@ -62,7 +67,9 @@ extern int mylength; extern int mylineno; extern char *mytext; extern Keyword keyword_tbl[]; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* * Jetons superieurs a 270 (voir "../mylex/token.h"). */ diff --git a/modules/robot/src/wireframe-simulator/vpView.h b/modules/robot/src/wireframe-simulator/vpView.h index 9ce5c8b600..4367de4123 100644 --- a/modules/robot/src/wireframe-simulator/vpView.h +++ b/modules/robot/src/wireframe-simulator/vpView.h @@ -139,6 +139,10 @@ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 \ } +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * CAMERA PARAMETERS * _________________ @@ -151,7 +155,8 @@ * twist Angle de rotation sur l'axe de visee (eye,target) en degres. * speed Vitesse sur l'axe de visee (eye,target). */ -typedef struct { +typedef struct +{ Point3f eye; /* position de l'observateur */ Point3f target; /* point vise */ float focal; /* focale de la camera */ @@ -160,17 +165,20 @@ typedef struct { float speed; /* vitesse sur l'axe de visee */ } Camera_parameters; -typedef struct { +typedef struct +{ float umin, umax; /* bords gauche et droit */ float vmin, vmax; /* bords inferieur et superieur */ } View_window; -typedef struct { +typedef struct +{ float front; /* plan avant ("hither") */ float back; /* plan arriere ("yon") */ } View_depth; -typedef struct { +typedef struct +{ Type type; /* type de la projection */ Point3f cop; /* centre de projection */ Point3f vrp; /* point de reference de visee */ @@ -179,6 +187,8 @@ typedef struct { View_window vwd; /* fenetre de projection */ View_depth depth; /* profondeurs de decoupages */ } View_parameters; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpViewio.cpp b/modules/robot/src/wireframe-simulator/vpViewio.cpp index 29bd02a610..56c6670483 100644 --- a/modules/robot/src/wireframe-simulator/vpViewio.cpp +++ b/modules/robot/src/wireframe-simulator/vpViewio.cpp @@ -53,6 +53,10 @@ #include "vpToken.h" #include "vpViewio.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /* * La procedure "fscanf_Remove" lit en ascii les parametres d'elimination * des faces. @@ -163,5 +167,7 @@ void fscanf_View_parameters(View_parameters *vp) fscanf_float(&vp->depth.back); poperr(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpViewio.h b/modules/robot/src/wireframe-simulator/vpViewio.h index 09eaa9b5d8..e3f65e713d 100644 --- a/modules/robot/src/wireframe-simulator/vpViewio.h +++ b/modules/robot/src/wireframe-simulator/vpViewio.h @@ -50,8 +50,14 @@ #include "vpMy.h" #include "vpView.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void fscanf_Remove(Byte *bp); void fscanf_View_parameters(View_parameters *vp); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpVwstack.cpp b/modules/robot/src/wireframe-simulator/vpVwstack.cpp index 2bf5ec895c..1e0dfce906 100644 --- a/modules/robot/src/wireframe-simulator/vpVwstack.cpp +++ b/modules/robot/src/wireframe-simulator/vpVwstack.cpp @@ -54,7 +54,11 @@ #define STACKSIZE 4 -static View_parameters stack[STACKSIZE] = {vpDEFAULT_VIEW}; +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif +static View_parameters stack[STACKSIZE] = { vpDEFAULT_VIEW }; static View_parameters *sp = stack; /* @@ -147,7 +151,8 @@ void pop_vwstack(void) static char proc_name[] = "pop_vwstack"; fprintf(stderr, "%s: stack underflow\n", proc_name); return; - } else + } + else sp--; } @@ -197,15 +202,18 @@ void add_vwstack(const char *path, ...) if (strcmp(argv, "cop") == 0) { /* initialise le centre de projection */ SET_COORD3(sp->cop, (float)va_arg(ap, double), (float)va_arg(ap, double), (float)va_arg(ap, double)); - } else if (strcmp(argv, "depth") == 0) { - /* initialise les distances des plans de decoupage */ + } + else if (strcmp(argv, "depth") == 0) { + /* initialise les distances des plans de decoupage */ sp->depth.front = (float)va_arg(ap, double); sp->depth.back = (float)va_arg(ap, double); - } else if (strcmp(argv, "type") == 0) { - /* initialise le type de projection */ + } + else if (strcmp(argv, "type") == 0) { + /* initialise le type de projection */ sp->type = (Type)va_arg(ap, int); - } else if (strcmp(argv, "vpn") == 0) { - /* initialise le vecteur normal au plan */ + } + else if (strcmp(argv, "vpn") == 0) { + /* initialise le vecteur normal au plan */ float x = (float)va_arg(ap, double); float y = (float)va_arg(ap, double); float z = (float)va_arg(ap, double); @@ -216,14 +224,17 @@ void add_vwstack(const char *path, ...) std::fabs(z) <= std::numeric_limits::epsilon()) { static char proc_name[] = "add_vwstack"; fprintf(stderr, "%s: bad vpn\n", proc_name); - } else { + } + else { SET_COORD3(sp->vpn, x, y, z); } - } else if (strcmp(argv, "vrp") == 0) { - /* initialise le vecteur de reference */ + } + else if (strcmp(argv, "vrp") == 0) { + /* initialise le vecteur de reference */ SET_COORD3(sp->vrp, (float)va_arg(ap, double), (float)va_arg(ap, double), (float)va_arg(ap, double)); - } else if (strcmp(argv, "vup") == 0) { - /* initialise le vecteur haut du plan */ + } + else if (strcmp(argv, "vup") == 0) { + /* initialise le vecteur haut du plan */ float x = (float)va_arg(ap, double); float y = (float)va_arg(ap, double); float z = (float)va_arg(ap, double); @@ -234,20 +245,25 @@ void add_vwstack(const char *path, ...) std::fabs(z) <= std::numeric_limits::epsilon()) { static char proc_name[] = "add_vwstack"; fprintf(stderr, "%s: bad vup\n", proc_name); - } else { + } + else { SET_COORD3(sp->vup, x, y, z); } - } else if (strcmp(argv, "window") == 0) { - /* initialise la fenetre de projection */ + } + else if (strcmp(argv, "window") == 0) { + /* initialise la fenetre de projection */ sp->vwd.umin = (float)va_arg(ap, double); sp->vwd.umax = (float)va_arg(ap, double); sp->vwd.vmin = (float)va_arg(ap, double); sp->vwd.vmax = (float)va_arg(ap, double); - } else { + } + else { static char proc_name[] = "add_vwstack"; fprintf(stderr, "%s: bad argument\n", proc_name); } va_end(ap); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpVwstack.h b/modules/robot/src/wireframe-simulator/vpVwstack.h index 41c54f3cef..f76dc46441 100644 --- a/modules/robot/src/wireframe-simulator/vpVwstack.h +++ b/modules/robot/src/wireframe-simulator/vpVwstack.h @@ -47,6 +47,10 @@ #include "vpView.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif void fprintf_vwstack(FILE *fp, char *argv); View_parameters *get_vwstack(void); void load_vwstack(View_parameters *vp); @@ -54,6 +58,8 @@ void pop_vwstack(void); void push_vwstack(void); void swap_vwstack(void); void add_vwstack(const char *path, ...); - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/robot/src/wireframe-simulator/vpWireFrameSimulator.cpp b/modules/robot/src/wireframe-simulator/vpWireFrameSimulator.cpp index ebb3d2bef6..6fd7d83384 100644 --- a/modules/robot/src/wireframe-simulator/vpWireFrameSimulator.cpp +++ b/modules/robot/src/wireframe-simulator/vpWireFrameSimulator.cpp @@ -66,6 +66,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif extern Point2i *point2i; extern Point2i *listpoint2i; @@ -1608,3 +1612,6 @@ vpImagePoint vpWireFrameSimulator::projectCameraTrajectory(const vpImage] [--hd-resolution] [--verbose] [-v]" - << " [--help] [-h]\n" - << std::endl - << "Description:\n" - << " --ip \n" - << " IP address of the drone to which you want to connect (default : 192.168.42.1).\n\n" - << " --hd-resolution\n" - << " Enables HD 720p video instead of default 480p.\n\n" - << " --verbose, -v\n" - << " Enables verbose (drone information messages are then displayed).\n\n" - << " --help, -h\n" - << " Print help message.\n\n" - << std::endl; + << " " << argv[0] << " [--ip ] [--hd-resolution] [--verbose] [-v]" + << " [--help] [-h]\n" + << std::endl + << "Description:\n" + << " --ip \n" + << " IP address of the drone to which you want to connect (default : 192.168.42.1).\n\n" + << " --hd-resolution\n" + << " Enables HD 720p video instead of default 480p.\n\n" + << " --verbose, -v\n" + << " Enables verbose (drone information messages are then displayed).\n\n" + << " --help, -h\n" + << " Print help message.\n\n" + << std::endl; return EXIT_SUCCESS; - } else { + } + else { std::cout << "Error : unknown parameter " << argv[i] << std::endl - << "See " << argv[0] << " --help" << std::endl; + << "See " << argv[0] << " --help" << std::endl; return EXIT_FAILURE; } } @@ -132,12 +139,14 @@ int main(int argc, char **argv) drone.land(); - } else { + } + else { std::cout << "Error : failed to setup drone control" << std::endl; } std::cout << "-- End of test --" << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Caught an exception: " << e << std::endl; } #else diff --git a/modules/robot/test/qbdevice/testQbSoftHand.cpp b/modules/robot/test/qbdevice/testQbSoftHand.cpp index d0e5e7408e..0eaacccd47 100644 --- a/modules/robot/test/qbdevice/testQbSoftHand.cpp +++ b/modules/robot/test/qbdevice/testQbSoftHand.cpp @@ -46,6 +46,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if defined(VISP_HAVE_QBDEVICE) && defined(VISP_HAVE_THREADS) std::cout << "Test qbSoftHand device" << std::endl; try { diff --git a/modules/robot/test/servo-afma4/testAfma4.cpp b/modules/robot/test/servo-afma4/testAfma4.cpp index 0b0fa6182c..298b3b78a0 100644 --- a/modules/robot/test/servo-afma4/testAfma4.cpp +++ b/modules/robot/test/servo-afma4/testAfma4.cpp @@ -49,6 +49,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "a test for vpAfma4 class..." << std::endl; @@ -58,7 +61,8 @@ int main() std::cout << afma4 << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-afma4/testRobotAfma4.cpp b/modules/robot/test/servo-afma4/testRobotAfma4.cpp index 97ca657036..8e65e317ce 100644 --- a/modules/robot/test/servo-afma4/testRobotAfma4.cpp +++ b/modules/robot/test/servo-afma4/testRobotAfma4.cpp @@ -50,6 +50,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "A test for vpRobotAfma4 class..." << std::endl; @@ -58,7 +61,8 @@ int main() std::cout << afma4 << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-afma6/testAfma6.cpp b/modules/robot/test/servo-afma6/testAfma6.cpp index ef4810b823..257d5146d6 100644 --- a/modules/robot/test/servo-afma6/testAfma6.cpp +++ b/modules/robot/test/servo-afma6/testAfma6.cpp @@ -49,6 +49,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "a test for vpAfma6 class..." << std::endl; @@ -88,7 +91,8 @@ int main() std::cout << cam << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-afma6/testRobotAfma6.cpp b/modules/robot/test/servo-afma6/testRobotAfma6.cpp index 7e80d7cbc5..1630015582 100644 --- a/modules/robot/test/servo-afma6/testRobotAfma6.cpp +++ b/modules/robot/test/servo-afma6/testRobotAfma6.cpp @@ -50,6 +50,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "a test for vpRobotAfma6 class..." << std::endl; @@ -88,7 +91,8 @@ int main() afma6.getCameraParameters(cam, 640, 480); std::cout << cam << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-afma6/testRobotAfma6Pose.cpp b/modules/robot/test/servo-afma6/testRobotAfma6Pose.cpp index b5815aa50f..550171b4bd 100644 --- a/modules/robot/test/servo-afma6/testRobotAfma6Pose.cpp +++ b/modules/robot/test/servo-afma6/testRobotAfma6Pose.cpp @@ -60,6 +60,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { // Create an image B&W container vpImage I; @@ -169,10 +172,10 @@ int main() cMo.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; - // Get the robot position in the reference frame +// Get the robot position in the reference frame vpHomogeneousMatrix rMc; vpColVector p; // position x,y,z,rx,ry,rz robot.getPosition(vpRobotAfma6::REFERENCE_FRAME, p); @@ -190,8 +193,8 @@ int main() rMc.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; robot.getPosition(vpRobotAfma6::ARTICULAR_FRAME, p); std::cout << "Robot pose in articular: " << p << std::endl; @@ -201,8 +204,8 @@ int main() rMc.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; vpHomogeneousMatrix rMo; rMo = rMc * cMo; @@ -210,10 +213,11 @@ int main() rMo.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-flir-ptu/testRobotFlirPtu.cpp b/modules/robot/test/servo-flir-ptu/testRobotFlirPtu.cpp index 4413a2edc5..a7f55c3f4f 100644 --- a/modules/robot/test/servo-flir-ptu/testRobotFlirPtu.cpp +++ b/modules/robot/test/servo-flir-ptu/testRobotFlirPtu.cpp @@ -49,6 +49,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string opt_portname; int opt_baudrate = 9600; bool opt_network = false; diff --git a/modules/robot/test/servo-franka/testFrankaCartForceTorque-2.cpp b/modules/robot/test/servo-franka/testFrankaCartForceTorque-2.cpp index 2a380f1dae..5003faf60a 100644 --- a/modules/robot/test/servo-franka/testFrankaCartForceTorque-2.cpp +++ b/modules/robot/test/servo-franka/testFrankaCartForceTorque-2.cpp @@ -49,17 +49,22 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; std::string log_folder; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { log_folder = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--log_folder ] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -70,10 +75,10 @@ int main(int argc, char **argv) robot.connect(robot_ip); std::cout << "WARNING: This example will move the robot! " << std::endl - << "- Please make sure to have the user stop button at hand!" << std::endl - << "- Please make also sure the end-effector is in contact with a flat surface such as a foam board!" - << std::endl - << "Press Enter to continue..." << std::endl; + << "- Please make sure to have the user stop button at hand!" << std::endl + << "- Please make also sure the end-effector is in contact with a flat surface such as a foam board!" + << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -97,7 +102,7 @@ int main(int argc, char **argv) static bool change_ft = true; if (change_ft) { std::cout << "Apply cartesian force/torque in a loop for " << delta_t / 2. << " sec : " << ft_d.t() - << std::endl; + << std::endl; } change_ft = false; } @@ -106,16 +111,19 @@ int main(int argc, char **argv) robot.setRobotState(vpRobot::STATE_STOP); vpTime::wait(100); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaCartForceTorque.cpp b/modules/robot/test/servo-franka/testFrankaCartForceTorque.cpp index 94d30fd499..f20f4a4c4d 100644 --- a/modules/robot/test/servo-franka/testFrankaCartForceTorque.cpp +++ b/modules/robot/test/servo-franka/testFrankaCartForceTorque.cpp @@ -49,17 +49,22 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; std::string log_folder; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { log_folder = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--log_folder ] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -70,10 +75,10 @@ int main(int argc, char **argv) robot.connect(robot_ip); std::cout << "WARNING: This example will move the robot! " << std::endl - << "- Please make sure to have the user stop button at hand!" << std::endl - << "- Please make also sure the end-effector is in contact with a flat surface such as a foam board!" - << std::endl - << "Press Enter to continue..." << std::endl; + << "- Please make sure to have the user stop button at hand!" << std::endl + << "- Please make also sure the end-effector is in contact with a flat surface such as a foam board!" + << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -94,7 +99,7 @@ int main(int argc, char **argv) static bool change_ft = true; if (change_ft) { std::cout << "Apply cartesian force/torque in a loop for " << delta_t / 2. << " sec : " << ft_d.t() - << std::endl; + << std::endl; } change_ft = false; } @@ -103,16 +108,19 @@ int main(int argc, char **argv) robot.setRobotState(vpRobot::STATE_STOP); vpTime::wait(100); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaCartVelocity-2.cpp b/modules/robot/test/servo-franka/testFrankaCartVelocity-2.cpp index 1a5f61f9ac..532cf35159 100644 --- a/modules/robot/test/servo-franka/testFrankaCartVelocity-2.cpp +++ b/modules/robot/test/servo-franka/testFrankaCartVelocity-2.cpp @@ -49,17 +49,22 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; std::string log_folder; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { log_folder = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--log_folder ] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -70,8 +75,8 @@ int main(int argc, char **argv) robot.setLogFolder(log_folder); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -140,16 +145,19 @@ int main(int argc, char **argv) std::cout << "Ask to stop the robot " << std::endl; robot.setRobotState(vpRobot::STATE_STOP); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaCartVelocity-3.cpp b/modules/robot/test/servo-franka/testFrankaCartVelocity-3.cpp index c67ea1f358..2c0de38e77 100644 --- a/modules/robot/test/servo-franka/testFrankaCartVelocity-3.cpp +++ b/modules/robot/test/servo-franka/testFrankaCartVelocity-3.cpp @@ -49,17 +49,22 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; std::string log_folder; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { log_folder = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--log_folder ] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -70,8 +75,8 @@ int main(int argc, char **argv) robot.setLogFolder(log_folder); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -124,16 +129,19 @@ int main(int argc, char **argv) std::cout << "Ask to stop the robot " << std::endl; robot.setRobotState(vpRobot::STATE_STOP); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaCartVelocity.cpp b/modules/robot/test/servo-franka/testFrankaCartVelocity.cpp index 4eaa455b06..f24d927899 100644 --- a/modules/robot/test/servo-franka/testFrankaCartVelocity.cpp +++ b/modules/robot/test/servo-franka/testFrankaCartVelocity.cpp @@ -49,17 +49,22 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; std::string log_folder; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { log_folder = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--log_folder ] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -70,8 +75,8 @@ int main(int argc, char **argv) robot.setLogFolder(log_folder); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -121,16 +126,19 @@ int main(int argc, char **argv) std::cout << "Ask to stop the robot " << std::endl; robot.setRobotState(vpRobot::STATE_STOP); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaGetPose.cpp b/modules/robot/test/servo-franka/testFrankaGetPose.cpp index 6c9e464d7e..5a356bf0f2 100644 --- a/modules/robot/test/servo-franka/testFrankaGetPose.cpp +++ b/modules/robot/test/servo-franka/testFrankaGetPose.cpp @@ -49,14 +49,18 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -78,16 +82,19 @@ int main(int argc, char **argv) robot.getPosition(vpRobot::END_EFFECTOR_FRAME, fPe); std::cout << "fMe pose vector: " << fPe.t() << std::endl; std::cout << "fMe pose matrix: \n" << vpHomogeneousMatrix(fPe) << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -127,16 +134,19 @@ int main(int argc, char **argv) } } std::cout << "eeMk: \n" << eeMk << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command line option set by default to 192.168.1.1. " - << std::endl; + << " or if you specified the right IP using --ip command line option set by default to 192.168.1.1. " + << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -157,16 +167,19 @@ int main(int argc, char **argv) vpColVector coriolis; robot.getCoriolis(coriolis); std::cout << "Coriolis vector: " << coriolis.t() << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command line option set by default to 192.168.1.1. " - << std::endl; + << " or if you specified the right IP using --ip command line option set by default to 192.168.1.1. " + << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -193,16 +206,19 @@ int main(int argc, char **argv) robot.get_eJe(q, eJe); std::cout << "Jacobian eJe:\n" << eJe << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command line option set by default to 192.168.1.1. " - << std::endl; + << " or if you specified the right IP using --ip command line option set by default to 192.168.1.1. " + << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaJointPosition.cpp b/modules/robot/test/servo-franka/testFrankaJointPosition.cpp index 3ae5f10392..6d49f7741c 100644 --- a/modules/robot/test/servo-franka/testFrankaJointPosition.cpp +++ b/modules/robot/test/servo-franka/testFrankaJointPosition.cpp @@ -49,14 +49,18 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -66,8 +70,8 @@ int main(int argc, char **argv) robot.connect(robot_ip); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -80,16 +84,19 @@ int main(int argc, char **argv) robot.setRobotState(vpRobot::STATE_POSITION_CONTROL); std::cout << "Move to joint position: " << q.t() << std::endl; robot.setPosition(vpRobot::JOINT_STATE, q); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaJointTorque.cpp b/modules/robot/test/servo-franka/testFrankaJointTorque.cpp index 0a551f6838..6a373e73f7 100644 --- a/modules/robot/test/servo-franka/testFrankaJointTorque.cpp +++ b/modules/robot/test/servo-franka/testFrankaJointTorque.cpp @@ -49,17 +49,22 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; std::string log_folder; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { log_folder = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--log_folder ] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -70,10 +75,10 @@ int main(int argc, char **argv) robot.connect(robot_ip); std::cout << "WARNING: This example will move the robot! " << std::endl - << "- Please make sure to have the user stop button at hand!" << std::endl - << "- Please make also sure the end-effector is in contact with a flat surface such as a foam board!" - << std::endl - << "Press Enter to continue..." << std::endl; + << "- Please make sure to have the user stop button at hand!" << std::endl + << "- Please make also sure the end-effector is in contact with a flat surface such as a foam board!" + << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -95,16 +100,19 @@ int main(int argc, char **argv) robot.setRobotState(vpRobot::STATE_STOP); vpTime::wait(100); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaJointVelocity-2.cpp b/modules/robot/test/servo-franka/testFrankaJointVelocity-2.cpp index f6d7eaa401..a10e021803 100644 --- a/modules/robot/test/servo-franka/testFrankaJointVelocity-2.cpp +++ b/modules/robot/test/servo-franka/testFrankaJointVelocity-2.cpp @@ -49,14 +49,18 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -66,8 +70,8 @@ int main(int argc, char **argv) robot.connect(robot_ip); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -111,16 +115,19 @@ int main(int argc, char **argv) std::cout << "Ask to stop the robot " << std::endl; robot.setRobotState(vpRobot::STATE_STOP); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaJointVelocity-3.cpp b/modules/robot/test/servo-franka/testFrankaJointVelocity-3.cpp index bc9bd87071..39698a41b2 100644 --- a/modules/robot/test/servo-franka/testFrankaJointVelocity-3.cpp +++ b/modules/robot/test/servo-franka/testFrankaJointVelocity-3.cpp @@ -49,14 +49,18 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -66,8 +70,8 @@ int main(int argc, char **argv) robot.connect(robot_ip); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -127,16 +131,19 @@ int main(int argc, char **argv) std::cout << "Ask to stop the robot " << std::endl; robot.setRobotState(vpRobot::STATE_STOP); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaJointVelocity.cpp b/modules/robot/test/servo-franka/testFrankaJointVelocity.cpp index 9e81c7807f..8f543f6704 100644 --- a/modules/robot/test/servo-franka/testFrankaJointVelocity.cpp +++ b/modules/robot/test/servo-franka/testFrankaJointVelocity.cpp @@ -49,17 +49,22 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; std::string log_folder; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--log_folder" && i + 1 < argc) { log_folder = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--log_folder ] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -70,8 +75,8 @@ int main(int argc, char **argv) robot.setLogFolder(log_folder); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -114,16 +119,19 @@ int main(int argc, char **argv) std::cout << "Ask to stop the robot " << std::endl; robot.setRobotState(vpRobot::STATE_STOP); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-franka/testFrankaJointVelocityLimits.cpp b/modules/robot/test/servo-franka/testFrankaJointVelocityLimits.cpp index ba61bd7796..e895283946 100644 --- a/modules/robot/test/servo-franka/testFrankaJointVelocityLimits.cpp +++ b/modules/robot/test/servo-franka/testFrankaJointVelocityLimits.cpp @@ -49,14 +49,18 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.1.1"; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--ip" && i + 1 < argc) { robot_ip = std::string(argv[i + 1]); - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << argv[0] << " [--ip 192.168.1.1] [--help] [-h]" - << "\n"; + << "\n"; return EXIT_SUCCESS; } } @@ -66,8 +70,8 @@ int main(int argc, char **argv) robot.connect(robot_ip); std::cout << "WARNING: This example will move the robot! " - << "Please make sure to have the user stop button at hand!" << std::endl - << "Press Enter to continue..." << std::endl; + << "Please make sure to have the user stop button at hand!" << std::endl + << "Press Enter to continue..." << std::endl; std::cin.ignore(); /* @@ -92,7 +96,7 @@ int main(int argc, char **argv) double delta_t = 10.0; // Time in second std::cout << "Modify the maximum allowed joint velocity to: " << vel << " rad/s or " << vpMath::deg(vel) << " deg/s" - << std::endl; + << std::endl; robot.setMaxRotationVelocity(vel); std::cout << "Apply joint vel " << dq_d.t() << " for " << delta_t << " sec " << std::endl; robot.setRobotState(vpRobot::STATE_VELOCITY_CONTROL); @@ -122,16 +126,19 @@ int main(int argc, char **argv) std::cout << "Stop the robot " << std::endl; robot.setRobotState(vpRobot::STATE_STOP); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "ViSP exception: " << e.what() << std::endl; return EXIT_FAILURE; - } catch (const franka::NetworkException &e) { + } + catch (const franka::NetworkException &e) { std::cout << "Franka network exception: " << e.what() << std::endl; std::cout << "Check if you are connected to the Franka robot" - << " or if you specified the right IP using --ip command" - << " line option set by default to 192.168.1.1. " << std::endl; + << " or if you specified the right IP using --ip command" + << " line option set by default to 192.168.1.1. " << std::endl; return EXIT_FAILURE; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << "Franka exception: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-pixhawk/testPixhawkDroneKeyboard.cpp b/modules/robot/test/servo-pixhawk/testPixhawkDroneKeyboard.cpp index 3881565ce2..bbf582366e 100644 --- a/modules/robot/test/servo-pixhawk/testPixhawkDroneKeyboard.cpp +++ b/modules/robot/test/servo-pixhawk/testPixhawkDroneKeyboard.cpp @@ -54,6 +54,9 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif bool handleKeyboardInput(vpRobotMavsdk &drone, int key, bool &flying, double &lastCommandTime) { bool running = true; diff --git a/modules/robot/test/servo-pixhawk/testPixhawkDronePositionAbsoluteControl.cpp b/modules/robot/test/servo-pixhawk/testPixhawkDronePositionAbsoluteControl.cpp index 4b652acf43..a07cab8a38 100644 --- a/modules/robot/test/servo-pixhawk/testPixhawkDronePositionAbsoluteControl.cpp +++ b/modules/robot/test/servo-pixhawk/testPixhawkDronePositionAbsoluteControl.cpp @@ -64,6 +64,9 @@ void usage(const std::string &bin_name) int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif if (argc != 2) { usage(argv[0]); return EXIT_SUCCESS; diff --git a/modules/robot/test/servo-pixhawk/testPixhawkDronePositionRelativeControl.cpp b/modules/robot/test/servo-pixhawk/testPixhawkDronePositionRelativeControl.cpp index 519e82574c..160a9842bc 100644 --- a/modules/robot/test/servo-pixhawk/testPixhawkDronePositionRelativeControl.cpp +++ b/modules/robot/test/servo-pixhawk/testPixhawkDronePositionRelativeControl.cpp @@ -64,6 +64,9 @@ void usage(const std::string &bin_name) int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif if (argc != 2) { usage(argv[0]); return EXIT_SUCCESS; diff --git a/modules/robot/test/servo-pixhawk/testPixhawkDroneTakeoff.cpp b/modules/robot/test/servo-pixhawk/testPixhawkDroneTakeoff.cpp index c97e39649a..d3b6fc4bc2 100644 --- a/modules/robot/test/servo-pixhawk/testPixhawkDroneTakeoff.cpp +++ b/modules/robot/test/servo-pixhawk/testPixhawkDroneTakeoff.cpp @@ -64,6 +64,9 @@ void usage(const std::string &bin_name) int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif if (argc != 2) { usage(argv[0]); return EXIT_SUCCESS; diff --git a/modules/robot/test/servo-pixhawk/testPixhawkDroneVelocityControl.cpp b/modules/robot/test/servo-pixhawk/testPixhawkDroneVelocityControl.cpp index fca58e6ac2..a5424fe836 100644 --- a/modules/robot/test/servo-pixhawk/testPixhawkDroneVelocityControl.cpp +++ b/modules/robot/test/servo-pixhawk/testPixhawkDroneVelocityControl.cpp @@ -69,6 +69,9 @@ void usage(const std::string &bin_name) int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif if (argc != 2) { usage(argv[0]); return EXIT_SUCCESS; diff --git a/modules/robot/test/servo-pixhawk/testPixhawkRoverVelocityControl.cpp b/modules/robot/test/servo-pixhawk/testPixhawkRoverVelocityControl.cpp index 26dcd0cea0..bb83c1fd9f 100644 --- a/modules/robot/test/servo-pixhawk/testPixhawkRoverVelocityControl.cpp +++ b/modules/robot/test/servo-pixhawk/testPixhawkRoverVelocityControl.cpp @@ -69,6 +69,9 @@ void usage(const std::string &bin_name) int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif if (argc != 2) { usage(argv[0]); return EXIT_SUCCESS; diff --git a/modules/robot/test/servo-pololu/testPololuPosition.cpp b/modules/robot/test/servo-pololu/testPololuPosition.cpp index deaf385e19..46d526aa69 100644 --- a/modules/robot/test/servo-pololu/testPololuPosition.cpp +++ b/modules/robot/test/servo-pololu/testPololuPosition.cpp @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char **argv, int error, const std::string &device, int baudrate, int channel, unsigned short pwm_min, unsigned short pwm_max, float angle_min, float angle_max) { diff --git a/modules/robot/test/servo-pololu/testPololuVelocity.cpp b/modules/robot/test/servo-pololu/testPololuVelocity.cpp index 97387918e0..01f23a7427 100644 --- a/modules/robot/test/servo-pololu/testPololuVelocity.cpp +++ b/modules/robot/test/servo-pololu/testPololuVelocity.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char **argv, int error, const std::string &device, int baudrate, int channel, unsigned short pwm_min, unsigned short pwm_max, float angle_min, float angle_max) { diff --git a/modules/robot/test/servo-universal-robots/testUniversalRobotsCartPosition.cpp b/modules/robot/test/servo-universal-robots/testUniversalRobotsCartPosition.cpp index 032adcbcd3..95e87ae733 100644 --- a/modules/robot/test/servo-universal-robots/testUniversalRobotsCartPosition.cpp +++ b/modules/robot/test/servo-universal-robots/testUniversalRobotsCartPosition.cpp @@ -49,6 +49,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.0.100"; for (int i = 1; i < argc; i++) { diff --git a/modules/robot/test/servo-universal-robots/testUniversalRobotsCartVelocity.cpp b/modules/robot/test/servo-universal-robots/testUniversalRobotsCartVelocity.cpp index f1ca50e1b9..c28b4e0ae4 100644 --- a/modules/robot/test/servo-universal-robots/testUniversalRobotsCartVelocity.cpp +++ b/modules/robot/test/servo-universal-robots/testUniversalRobotsCartVelocity.cpp @@ -49,6 +49,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.0.100"; for (int i = 1; i < argc; i++) { diff --git a/modules/robot/test/servo-universal-robots/testUniversalRobotsGetData.cpp b/modules/robot/test/servo-universal-robots/testUniversalRobotsGetData.cpp index b4efff7e50..aa4ecff68d 100644 --- a/modules/robot/test/servo-universal-robots/testUniversalRobotsGetData.cpp +++ b/modules/robot/test/servo-universal-robots/testUniversalRobotsGetData.cpp @@ -49,6 +49,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.0.100"; for (int i = 1; i < argc; i++) { diff --git a/modules/robot/test/servo-universal-robots/testUniversalRobotsJointPosition.cpp b/modules/robot/test/servo-universal-robots/testUniversalRobotsJointPosition.cpp index 62512b5990..82b4225940 100644 --- a/modules/robot/test/servo-universal-robots/testUniversalRobotsJointPosition.cpp +++ b/modules/robot/test/servo-universal-robots/testUniversalRobotsJointPosition.cpp @@ -49,6 +49,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.0.100"; for (int i = 1; i < argc; i++) { diff --git a/modules/robot/test/servo-universal-robots/testUniversalRobotsJointVelocity.cpp b/modules/robot/test/servo-universal-robots/testUniversalRobotsJointVelocity.cpp index 059ecf1a1a..e5d5ac688b 100644 --- a/modules/robot/test/servo-universal-robots/testUniversalRobotsJointVelocity.cpp +++ b/modules/robot/test/servo-universal-robots/testUniversalRobotsJointVelocity.cpp @@ -49,6 +49,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string robot_ip = "192.168.0.100"; for (int i = 1; i < argc; i++) { diff --git a/modules/robot/test/servo-viper/testRobotViper650-frames.cpp b/modules/robot/test/servo-viper/testRobotViper650-frames.cpp index cfb09e8490..e5f17dff01 100644 --- a/modules/robot/test/servo-viper/testRobotViper650-frames.cpp +++ b/modules/robot/test/servo-viper/testRobotViper650-frames.cpp @@ -44,6 +44,9 @@ #ifdef VISP_HAVE_VIPER650 +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif bool pose_equal(const vpHomogeneousMatrix &M1, const vpHomogeneousMatrix &M2, double epsilon = 1e-6) { vpTranslationVector t1, t2; @@ -364,7 +367,8 @@ int main() std::cout << "The end" << std::endl; std::cout << "Test succeed" << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Test failed with exception: " << e.getMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-viper/testRobotViper850-frames.cpp b/modules/robot/test/servo-viper/testRobotViper850-frames.cpp index c39257f247..36095a38d1 100644 --- a/modules/robot/test/servo-viper/testRobotViper850-frames.cpp +++ b/modules/robot/test/servo-viper/testRobotViper850-frames.cpp @@ -43,7 +43,9 @@ #include #ifdef VISP_HAVE_VIPER850 - +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif bool pose_equal(const vpHomogeneousMatrix &M1, const vpHomogeneousMatrix &M2, double epsilon = 1e-6) { vpTranslationVector t1, t2; @@ -364,7 +366,8 @@ int main() std::cout << "The end" << std::endl; std::cout << "Test succeed" << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Test failed with exception: " << e.getMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-viper/testRobotViper850.cpp b/modules/robot/test/servo-viper/testRobotViper850.cpp index 1132a41485..81905b60b5 100644 --- a/modules/robot/test/servo-viper/testRobotViper850.cpp +++ b/modules/robot/test/servo-viper/testRobotViper850.cpp @@ -49,6 +49,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "a test for vpRobotViper850 class..." << std::endl; @@ -62,8 +65,8 @@ int main() std::cout << cam << std::endl; std::cout << "-- Settings associated to the Marlin F033C camera without " - "distortion ---" - << std::endl; + "distortion ---" + << std::endl; viper850.init(vpViper850::TOOL_MARLIN_F033C_CAMERA); std::cout << viper850 << std::endl; @@ -71,8 +74,8 @@ int main() std::cout << cam << std::endl; std::cout << "-- Settings associated to the Marlin F033C camera with " - "distortion ------" - << std::endl; + "distortion ------" + << std::endl; viper850.init(vpViper850::TOOL_MARLIN_F033C_CAMERA, vpCameraParameters::perspectiveProjWithDistortion); std::cout << viper850 << std::endl; viper850.getCameraParameters(cam, 640, 480); @@ -95,11 +98,12 @@ int main() rzyz.build(R); std::cout << "fMe:" << std::endl - << "\tt: " << t.t() << std::endl - << "\trzyz (deg): " << vpMath::deg(rzyz[0]) << " " << vpMath::deg(rzyz[1]) << " " << vpMath::deg(rzyz[2]) - << std::endl; + << "\tt: " << t.t() << std::endl + << "\trzyz (deg): " << vpMath::deg(rzyz[0]) << " " << vpMath::deg(rzyz[1]) << " " << vpMath::deg(rzyz[2]) + << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-viper/testRobotViper850Pose.cpp b/modules/robot/test/servo-viper/testRobotViper850Pose.cpp index f16d8993c4..d86eee79de 100644 --- a/modules/robot/test/servo-viper/testRobotViper850Pose.cpp +++ b/modules/robot/test/servo-viper/testRobotViper850Pose.cpp @@ -61,6 +61,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { // Create an image B&W container vpImage I; @@ -171,10 +174,10 @@ int main() cMo.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; - // Get the robot position in the reference frame +// Get the robot position in the reference frame vpHomogeneousMatrix rMc; vpColVector p; // position x,y,z,rx,ry,rz robot.getPosition(vpRobotViper850::REFERENCE_FRAME, p); @@ -192,8 +195,8 @@ int main() rMc.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; robot.getPosition(vpRobotViper850::ARTICULAR_FRAME, p); std::cout << "Robot pose in articular: " << p << std::endl; @@ -203,8 +206,8 @@ int main() rMc.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; vpHomogeneousMatrix rMo; rMo = rMc * cMo; @@ -212,10 +215,11 @@ int main() rMo.extract(R); r.build(R); std::cout << " rotation: " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) << " deg" - << std::endl - << std::endl; + << std::endl + << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-viper/testViper650.cpp b/modules/robot/test/servo-viper/testViper650.cpp index f69fb60cd3..9d378ade85 100644 --- a/modules/robot/test/servo-viper/testViper650.cpp +++ b/modules/robot/test/servo-viper/testViper650.cpp @@ -48,6 +48,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "a test for vpViper650 class..." << std::endl; @@ -61,8 +64,8 @@ int main() std::cout << cam << std::endl; std::cout << "-- Settings associated to the Marlin F033C camera without " - "distortion ---" - << std::endl; + "distortion ---" + << std::endl; viper650.init(vpViper650::TOOL_MARLIN_F033C_CAMERA); std::cout << viper650 << std::endl; @@ -70,8 +73,8 @@ int main() std::cout << cam << std::endl; std::cout << "-- Settings associated to the Marlin F033C camera with " - "distortion ------" - << std::endl; + "distortion ------" + << std::endl; viper650.init(vpViper650::TOOL_MARLIN_F033C_CAMERA, vpCameraParameters::perspectiveProjWithDistortion); std::cout << viper650 << std::endl; viper650.getCameraParameters(cam, 640, 480); @@ -104,13 +107,14 @@ int main() r.build(R); std::cout << "fMe:" << std::endl - << "\tt: " << t.t() << std::endl - << "\trzyz (rad): " << r.t() << std::endl - << "\trzyz (deg): " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) - << std::endl; + << "\tt: " << t.t() << std::endl + << "\trzyz (rad): " << r.t() << std::endl + << "\trzyz (deg): " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) + << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/servo-viper/testViper850.cpp b/modules/robot/test/servo-viper/testViper850.cpp index 4cc9f7ff6b..d358ff741a 100644 --- a/modules/robot/test/servo-viper/testViper850.cpp +++ b/modules/robot/test/servo-viper/testViper850.cpp @@ -48,6 +48,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "a test for vpViper850 class..." << std::endl; @@ -61,8 +64,8 @@ int main() std::cout << cam << std::endl; std::cout << "-- Settings associated to the Marlin F033C camera without " - "distortion ---" - << std::endl; + "distortion ---" + << std::endl; viper850.init(vpViper850::TOOL_MARLIN_F033C_CAMERA); std::cout << viper850 << std::endl; @@ -70,8 +73,8 @@ int main() std::cout << cam << std::endl; std::cout << "-- Settings associated to the Marlin F033C camera with " - "distortion ------" - << std::endl; + "distortion ------" + << std::endl; viper850.init(vpViper850::TOOL_MARLIN_F033C_CAMERA, vpCameraParameters::perspectiveProjWithDistortion); std::cout << viper850 << std::endl; viper850.getCameraParameters(cam, 640, 480); @@ -104,13 +107,14 @@ int main() r.build(R); std::cout << "fMe:" << std::endl - << "\tt: " << t.t() << std::endl - << "\trzyz (rad): " << r.t() << std::endl - << "\trzyz (deg): " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) - << std::endl; + << "\tt: " << t.t() << std::endl + << "\trzyz (rad): " << r.t() << std::endl + << "\trzyz (deg): " << vpMath::deg(r[0]) << " " << vpMath::deg(r[1]) << " " << vpMath::deg(r[2]) + << std::endl; return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/virtuose/testVirtuose.cpp b/modules/robot/test/virtuose/testVirtuose.cpp index 0aeb73fe53..5e3e9cc635 100644 --- a/modules/robot/test/virtuose/testVirtuose.cpp +++ b/modules/robot/test/virtuose/testVirtuose.cpp @@ -43,6 +43,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if defined(VISP_HAVE_VIRTUOSE) std::string opt_ip = "localhost"; int opt_port = 5000; @@ -90,7 +93,7 @@ int main(int argc, char **argv) catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; - } +} #else (void)argc; (void)argv; diff --git a/modules/robot/test/virtuose/testVirtuoseAfma6.cpp b/modules/robot/test/virtuose/testVirtuoseAfma6.cpp index 1fed2313f5..da2fabb95d 100644 --- a/modules/robot/test/virtuose/testVirtuoseAfma6.cpp +++ b/modules/robot/test/virtuose/testVirtuoseAfma6.cpp @@ -50,6 +50,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if defined(VISP_HAVE_VIRTUOSE) && defined(VISP_HAVE_AFMA6) vpRobotAfma6 robot; try { @@ -111,11 +114,13 @@ int main() force_feedback_robot[i] = (max[i] - robot_cart_position[i]) * force_increase_rate; if (force_feedback_robot[i] <= -force_limit) force_feedback_robot[i] = -force_limit; - } else if (robot_cart_position[i] <= min[i]) { + } + else if (robot_cart_position[i] <= min[i]) { force_feedback_robot[i] = (min[i] - robot_cart_position[i]) * force_increase_rate; if (force_feedback_robot[i] >= force_limit) force_feedback_robot[i] = force_limit; - } else + } + else force_feedback_robot[i] = 0; } vpColVector force_feedback_virt = rMv.getRotationMatrix().inverse() * force_feedback_robot; @@ -137,10 +142,11 @@ int main() robot.stopMotion(); virtuose.setPowerOff(); std::cout << "The end" << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { robot.stopMotion(); std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; - } +} #else std::cout << "You should install Virtuose SDK to use this binary..." << std::endl; #endif diff --git a/modules/robot/test/virtuose/testVirtuoseHapticBox.cpp b/modules/robot/test/virtuose/testVirtuoseHapticBox.cpp index 87f59f55a8..0f59d69555 100644 --- a/modules/robot/test/virtuose/testVirtuoseHapticBox.cpp +++ b/modules/robot/test/virtuose/testVirtuoseHapticBox.cpp @@ -49,6 +49,9 @@ #include #if defined(VISP_HAVE_VIRTUOSE) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif void CallBackVirtuose(VirtContext VC, void *ptr) { @@ -221,11 +224,13 @@ void CallBackVirtuose(VirtContext VC, void *ptr) forceFeedback[i] = (p_min[i] - localPosition[i]) * force_increase_rate; if (forceFeedback[i] >= force_limit) forceFeedback[i] = force_limit; - } else if ((p_max[i] <= localPosition[i])) { + } + else if ((p_max[i] <= localPosition[i])) { forceFeedback[i] = (p_max[i] - localPosition[i]) * force_increase_rate; if (forceFeedback[i] <= -force_limit) forceFeedback[i] = -force_limit; - } else + } + else forceFeedback[i] = 0; } @@ -249,19 +254,19 @@ int main(int argc, char **argv) opt_port = std::atoi(argv[i + 1]); else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << "\nUsage: " << argv[0] - << " [--ip ] [--port ]" - " [--help] [-h]\n" - << std::endl - << "Description: " << std::endl - << " --ip " << std::endl - << "\tHost IP address. Default value: \"localhost\"." << std::endl - << std::endl - << " --port " << std::endl - << "\tCommunication port. Default value: 5000." << std::endl - << "\tSuggested values: " << std::endl - << "\t- 5000 to communicate with the Virtuose." << std::endl - << "\t- 53210 to communicate with the Virtuose equipped with the Glove." << std::endl - << std::endl; + << " [--ip ] [--port ]" + " [--help] [-h]\n" + << std::endl + << "Description: " << std::endl + << " --ip " << std::endl + << "\tHost IP address. Default value: \"localhost\"." << std::endl + << std::endl + << " --port " << std::endl + << "\tCommunication port. Default value: 5000." << std::endl + << "\tSuggested values: " << std::endl + << "\t- 5000 to communicate with the Virtuose." << std::endl + << "\t- 53210 to communicate with the Virtuose equipped with the Glove." << std::endl + << std::endl; return EXIT_SUCCESS; } } @@ -288,7 +293,8 @@ int main(int argc, char **argv) vpTime::sleepMs(1000); } std::cout << "The end" << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } @@ -299,8 +305,8 @@ int main(int argc, char **argv) int main() { std::cout << "You should install pthread and/or Virtuose API to use this " - "binary..." - << std::endl; + "binary..." + << std::endl; return EXIT_SUCCESS; } #endif diff --git a/modules/robot/test/virtuose/testVirtuoseJointLimits.cpp b/modules/robot/test/virtuose/testVirtuoseJointLimits.cpp index cc30868670..1f468e66b5 100644 --- a/modules/robot/test/virtuose/testVirtuoseJointLimits.cpp +++ b/modules/robot/test/virtuose/testVirtuoseJointLimits.cpp @@ -49,20 +49,24 @@ #if defined(VISP_HAVE_VIRTUOSE) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void CallBackVirtuose(VirtContext VC, void *ptr) { (void)VC; vpVirtuose *p_virtuose = (vpVirtuose *)ptr; - float maxQ[6] = {0.7811045051f, -0.07668215036f, 2.481732368f, 2.819076777f, 1.044736624f, 2.687076807f}; - float minQ[6] = {-0.8011951447f, -1.648244739f, 0.7439950705f, -3.022218227f, -1.260564089f, -2.054088593f}; + float maxQ[6] = { 0.7811045051f, -0.07668215036f, 2.481732368f, 2.819076777f, 1.044736624f, 2.687076807f }; + float minQ[6] = { -0.8011951447f, -1.648244739f, 0.7439950705f, -3.022218227f, -1.260564089f, -2.054088593f }; unsigned int numJoint = 6; vpColVector feedbackRegion(numJoint, 0); vpColVector forceFeedback(numJoint, 0); int feedbackRegionFactor = 10; - float saturationForce[6] = {5, 5, 5, 2.5, 2.5, 2.5}; + float saturationForce[6] = { 5, 5, 5, 2.5, 2.5, 2.5 }; for (unsigned int iter = 0; iter < numJoint; iter++) feedbackRegion[iter] = (maxQ[iter] - minQ[iter]) / feedbackRegionFactor; @@ -73,13 +77,15 @@ void CallBackVirtuose(VirtContext VC, void *ptr) for (unsigned int iter = 0; iter < numJoint; iter++) { if (currentQ[iter] >= (maxQ[iter] - feedbackRegion[iter])) { forceFeedback[iter] = - -saturationForce[iter] * pow((currentQ[iter] - maxQ[iter] + feedbackRegion[iter]) / feedbackRegion[iter], 2); + -saturationForce[iter] * pow((currentQ[iter] - maxQ[iter] + feedbackRegion[iter]) / feedbackRegion[iter], 2); std::cout << "WARNING! Getting close to the maximum joint limit. Joint #" << iter + 1 << std::endl; - } else if (currentQ[iter] <= (minQ[iter] + feedbackRegion[iter])) { + } + else if (currentQ[iter] <= (minQ[iter] + feedbackRegion[iter])) { forceFeedback[iter] = - saturationForce[iter] * pow((minQ[iter] + feedbackRegion[iter] - currentQ[iter]) / feedbackRegion[iter], 2); + saturationForce[iter] * pow((minQ[iter] + feedbackRegion[iter] - currentQ[iter]) / feedbackRegion[iter], 2); std::cout << "WARNING! Getting close to the minimum joint limit. Joint #" << iter + 1 << std::endl; - } else { + } + else { forceFeedback[iter] = 0; std::cout << "Safe zone" << std::endl; } @@ -105,19 +111,19 @@ int main(int argc, char **argv) opt_port = std::atoi(argv[i + 1]); else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << "\nUsage: " << argv[0] - << " [--ip ] [--port ]" - " [--help] [-h]\n" - << std::endl - << "Description: " << std::endl - << " --ip " << std::endl - << "\tHost IP address. Default value: \"localhost\"." << std::endl - << std::endl - << " --port " << std::endl - << "\tCommunication port. Default value: 5000." << std::endl - << "\tSuggested values: " << std::endl - << "\t- 5000 to communicate with the Virtuose." << std::endl - << "\t- 53210 to communicate with the Virtuose equipped with the Glove." << std::endl - << std::endl; + << " [--ip ] [--port ]" + " [--help] [-h]\n" + << std::endl + << "Description: " << std::endl + << " --ip " << std::endl + << "\tHost IP address. Default value: \"localhost\"." << std::endl + << std::endl + << " --port " << std::endl + << "\tCommunication port. Default value: 5000." << std::endl + << "\tSuggested values: " << std::endl + << "\t- 5000 to communicate with the Virtuose." << std::endl + << "\t- 53210 to communicate with the Virtuose equipped with the Glove." << std::endl + << std::endl; return EXIT_SUCCESS; ; } @@ -186,7 +192,8 @@ int main(int argc, char **argv) } std::cout << "The end" << std::endl; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getStringMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/robot/test/virtuose/testVirtuosePeriodicFunction.cpp b/modules/robot/test/virtuose/testVirtuosePeriodicFunction.cpp index 5f58664655..bc53164298 100644 --- a/modules/robot/test/virtuose/testVirtuosePeriodicFunction.cpp +++ b/modules/robot/test/virtuose/testVirtuosePeriodicFunction.cpp @@ -44,6 +44,10 @@ #if defined(VISP_HAVE_VIRTUOSE) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void CallBackVirtuose(VirtContext VC, void *ptr) { (void)VC; diff --git a/modules/robot/test/virtuose/testVirtuoseWithGlove.cpp b/modules/robot/test/virtuose/testVirtuoseWithGlove.cpp index 65d4551b2f..7c82ae79ba 100644 --- a/modules/robot/test/virtuose/testVirtuoseWithGlove.cpp +++ b/modules/robot/test/virtuose/testVirtuoseWithGlove.cpp @@ -58,6 +58,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif int port = 53210; std::string ip = "localhost"; @@ -77,11 +80,11 @@ int main() std::cout << "After init" << std::endl; #if 0 // Get joint position - for (size_t device=0; device < virtuose.size(); device ++) { + for (size_t device = 0; device < virtuose.size(); device++) { std::cout << "Number of joints: " << virtuose[device].getJointsNumber() - << " Joint position: " << virtuose[device].getArticularPosition().t() << std::endl - << " Cartesian position: " << virtuose[device].getAvatarPosition().t() << std::endl; - // std::cout << "Joint velocity: " << virtuose.getArticularVelocity().t() << std::endl; + << " Joint position: " << virtuose[device].getArticularPosition().t() << std::endl + << " Cartesian position: " << virtuose[device].getAvatarPosition().t() << std::endl; +// std::cout << "Joint velocity: " << virtuose.getArticularVelocity().t() << std::endl; } #endif bool end = false; diff --git a/modules/sensor/include/visp3/sensor/vp1394CMUGrabber.h b/modules/sensor/include/visp3/sensor/vp1394CMUGrabber.h index c4674b5648..33ed317138 100644 --- a/modules/sensor/include/visp3/sensor/vp1394CMUGrabber.h +++ b/modules/sensor/include/visp3/sensor/vp1394CMUGrabber.h @@ -37,6 +37,11 @@ * *****************************************************************************/ +/*! + \file vp1394CMUGrabber.h + \brief Firewire cameras video capture based on CMU 1394 Digital Camera SDK. +*/ + #ifndef vp1394CMUGrabber_h #define vp1394CMUGrabber_h @@ -55,11 +60,10 @@ #include #include -/*! - \file vp1394CMUGrabber.h - \brief Firewire cameras video capture based on CMU 1394 Digital Camera SDK. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vp1394CMUGrabber @@ -237,7 +241,8 @@ class VISP_EXPORT vp1394CMUGrabber : public vpFrameGrabber color = vp1394CMUGrabber::MONO16; break; } - } else if (_format == 1) { + } + else if (_format == 1) { switch (_mode) { case 0: color = vp1394CMUGrabber::YUV422; @@ -264,7 +269,8 @@ class VISP_EXPORT vp1394CMUGrabber : public vpFrameGrabber color = vp1394CMUGrabber::MONO16; break; } - } else if (_format == 2) { + } + else if (_format == 2) { switch (_mode) { case 0: color = vp1394CMUGrabber::YUV422; @@ -332,6 +338,8 @@ class VISP_EXPORT vp1394CMUGrabber : public vpFrameGrabber private: void initCamera(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vp1394TwoGrabber.h b/modules/sensor/include/visp3/sensor/vp1394TwoGrabber.h index 7344ac2f6f..b504ab473a 100644 --- a/modules/sensor/include/visp3/sensor/vp1394TwoGrabber.h +++ b/modules/sensor/include/visp3/sensor/vp1394TwoGrabber.h @@ -58,6 +58,23 @@ #if defined(VISP_HAVE_DC1394) +/* + * Interface with libdc1394 2.x + */ +#include + +#include +#include +#include + +#include +#include +#include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vp1394TwoGrabber @@ -161,20 +178,6 @@ \endcode */ - -/* - * Interface with libdc1394 2.x - */ -#include - -#include -#include -#include - -#include -#include -#include - class VISP_EXPORT vp1394TwoGrabber : public vpFrameGrabber { @@ -460,6 +463,8 @@ class VISP_EXPORT vp1394TwoGrabber : public vpFrameGrabber dc1394camera_list_t *list; #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpComedi.h b/modules/sensor/include/visp3/sensor/vpComedi.h index cb8a718065..46478b7441 100644 --- a/modules/sensor/include/visp3/sensor/vpComedi.h +++ b/modules/sensor/include/visp3/sensor/vpComedi.h @@ -45,6 +45,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpComedi @@ -174,6 +178,8 @@ class VISP_EXPORT vpComedi std::vector m_chanlist; /*!< Channel list */ //@} }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpDirectShowDevice.h b/modules/sensor/include/visp3/sensor/vpDirectShowDevice.h index a1bc1b131b..279a93a7d8 100644 --- a/modules/sensor/include/visp3/sensor/vpDirectShowDevice.h +++ b/modules/sensor/include/visp3/sensor/vpDirectShowDevice.h @@ -49,6 +49,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class VISP_EXPORT vpDirectShowDevice { @@ -59,7 +63,7 @@ class VISP_EXPORT vpDirectShowDevice bool inUse; // true if the device is already used by a grabber public: - vpDirectShowDevice() : inUse(false) {} + vpDirectShowDevice() : inUse(false) { } explicit vpDirectShowDevice(const CComPtr &moniker) : inUse(false) { init(moniker); } bool init(const CComPtr &moniker); @@ -76,6 +80,9 @@ class VISP_EXPORT vpDirectShowDevice friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDirectShowDevice &dev); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpDirectShowGrabber.h b/modules/sensor/include/visp3/sensor/vpDirectShowGrabber.h index a91492b014..8e41378ab0 100644 --- a/modules/sensor/include/visp3/sensor/vpDirectShowGrabber.h +++ b/modules/sensor/include/visp3/sensor/vpDirectShowGrabber.h @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class vpDirectShowGrabberImpl; /*! @@ -110,5 +114,8 @@ class VISP_EXPORT vpDirectShowGrabber : public vpFrameGrabber // Get current capture MediaType int getMediaType(); }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpDirectShowGrabberImpl.h b/modules/sensor/include/visp3/sensor/vpDirectShowGrabberImpl.h index b525ed0f65..0691ed6a20 100644 --- a/modules/sensor/include/visp3/sensor/vpDirectShowGrabberImpl.h +++ b/modules/sensor/include/visp3/sensor/vpDirectShowGrabberImpl.h @@ -51,6 +51,11 @@ #include #include #include + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpDirectShowGrabberImpl \brief class for windows direct show devices - implementation @@ -208,7 +213,9 @@ class VISP_EXPORT vpDirectShowGrabberImpl : public vpFrameGrabber // Frees the format block in an AM_MEDIA_TYPE structure void MyFreeMediaType(AM_MEDIA_TYPE &mt); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpDirectShowSampleGrabberI.h b/modules/sensor/include/visp3/sensor/vpDirectShowSampleGrabberI.h index 2b42fa9358..beb6b74ec8 100644 --- a/modules/sensor/include/visp3/sensor/vpDirectShowSampleGrabberI.h +++ b/modules/sensor/include/visp3/sensor/vpDirectShowSampleGrabberI.h @@ -51,6 +51,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! This class is needed in order to implement a callback function associated with the grabber @@ -96,7 +100,9 @@ class VISP_EXPORT vpDirectShowSampleGrabberI : public ISampleGrabberCB friend class vpDirectShowGrabberImpl; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpFlyCaptureGrabber.h b/modules/sensor/include/visp3/sensor/vpFlyCaptureGrabber.h index 415902323a..11bf15b012 100644 --- a/modules/sensor/include/visp3/sensor/vpFlyCaptureGrabber.h +++ b/modules/sensor/include/visp3/sensor/vpFlyCaptureGrabber.h @@ -33,6 +33,12 @@ * *****************************************************************************/ +/*! + \file vpFlyCaptureGrabber.h + \brief Wrapper over PointGrey FlyCapture SDK to capture images from + PointGrey cameras. +*/ + #ifndef _vpFlyCaptureGrabber_h_ #define _vpFlyCaptureGrabber_h_ @@ -44,11 +50,11 @@ #include -/*! - \file vpFlyCaptureGrabber.h - \brief Wrapper over PointGrey FlyCapture SDK to capture images from - PointGrey cameras. -*/ +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! \class vpFlyCaptureGrabber \ingroup group_sensor_camera @@ -231,6 +237,8 @@ class VISP_EXPORT vpFlyCaptureGrabber : public vpFrameGrabber bool m_connected; //!< true if camera connected bool m_capture; //!< true is capture started }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpForceTorqueAtiNetFTSensor.h b/modules/sensor/include/visp3/sensor/vpForceTorqueAtiNetFTSensor.h index f4dcd6e53f..9425a88f03 100644 --- a/modules/sensor/include/visp3/sensor/vpForceTorqueAtiNetFTSensor.h +++ b/modules/sensor/include/visp3/sensor/vpForceTorqueAtiNetFTSensor.h @@ -45,6 +45,10 @@ // is not supported on win XP #ifdef VISP_HAVE_FUNC_INET_NTOP +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpForceTorqueAtiNetFTSensor * @@ -159,6 +163,8 @@ class VISP_EXPORT vpForceTorqueAtiNetFTSensor : public vpUDPClient vpColVector m_ft; bool m_is_streaming_started; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpForceTorqueAtiSensor.h b/modules/sensor/include/visp3/sensor/vpForceTorqueAtiSensor.h index e743a158bc..df24765ec4 100644 --- a/modules/sensor/include/visp3/sensor/vpForceTorqueAtiSensor.h +++ b/modules/sensor/include/visp3/sensor/vpForceTorqueAtiSensor.h @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpForceTorqueAtiSensor * @@ -113,6 +117,8 @@ class VISP_EXPORT vpForceTorqueAtiSensor : public vpComedi unsigned short m_num_channels; //!< Number of channels available from the sensor vpColVector m_sample_bias; //!< Sample value used for bias }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpForceTorqueIitSensor.h b/modules/sensor/include/visp3/sensor/vpForceTorqueIitSensor.h index 6923c6be71..83d0ad5be1 100644 --- a/modules/sensor/include/visp3/sensor/vpForceTorqueIitSensor.h +++ b/modules/sensor/include/visp3/sensor/vpForceTorqueIitSensor.h @@ -55,6 +55,11 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! \class vpForceTorqueIitSensor \ingroup group_sensor_ft @@ -168,7 +173,7 @@ class VISP_EXPORT vpForceTorqueIitSensor vpColVector m_ft; vpColVector m_ft_filt; - ftSensorsConnected m_ftSensorsData{}; + ftSensorsConnected m_ftSensorsData {}; std::atomic m_acquisitionEnabled; std::atomic m_dataValid; @@ -180,6 +185,8 @@ class VISP_EXPORT vpForceTorqueIitSensor std::mutex m_mutex; int m_warmupMilliseconds; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpKinect.h b/modules/sensor/include/visp3/sensor/vpKinect.h index d5f73273e3..824a9d781e 100644 --- a/modules/sensor/include/visp3/sensor/vpKinect.h +++ b/modules/sensor/include/visp3/sensor/vpKinect.h @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpKinect @@ -121,7 +125,8 @@ class VISP_EXPORT vpKinect : public Freenect::FreenectDevice /*! Depth map resolution. */ - typedef enum { + typedef enum + { DMAP_LOW_RES, /*!< Depth map has a resolution of 320 by 240. */ DMAP_MEDIUM_RES /*!< Depth map has a resolution of 640 by 480. */ } vpDMResolution; @@ -175,7 +180,9 @@ class VISP_EXPORT vpKinect : public Freenect::FreenectDevice unsigned int height; // height of the rgb image unsigned int width; // width of the rgb image }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpLaserScan.h b/modules/sensor/include/visp3/sensor/vpLaserScan.h index bd63f47772..217364bc0b 100644 --- a/modules/sensor/include/visp3/sensor/vpLaserScan.h +++ b/modules/sensor/include/visp3/sensor/vpLaserScan.h @@ -32,8 +32,6 @@ * Laser scan data structure. * *****************************************************************************/ -#ifndef vpLaserScan_h -#define vpLaserScan_h /*! \file vpLaserScan.h @@ -42,10 +40,18 @@ */ +#ifndef vpLaserScan_h +#define vpLaserScan_h + +#include #include "visp3/sensor/vpScanPoint.h" #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpLaserScan @@ -122,5 +128,7 @@ class /*VISP_EXPORT*/ vpLaserScan short stopAngle; unsigned short numPoints; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpLaserScanner.h b/modules/sensor/include/visp3/sensor/vpLaserScanner.h index 2800588bb4..a0a552e90c 100644 --- a/modules/sensor/include/visp3/sensor/vpLaserScanner.h +++ b/modules/sensor/include/visp3/sensor/vpLaserScanner.h @@ -32,10 +32,6 @@ * Generic laser scanner. * *****************************************************************************/ -#ifndef vpLaserScanner_h -#define vpLaserScanner_h - -#include "visp3/core/vpConfig.h" /*! @@ -44,6 +40,15 @@ \brief Implements a generic laser scanner. */ +#ifndef vpLaserScanner_h +#define vpLaserScanner_h + +#include "visp3/core/vpConfig.h" + +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpLaserScanner @@ -72,5 +77,7 @@ class /*VISP_EXPORT*/ vpLaserScanner std::string ip; int port; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpMocap.h b/modules/sensor/include/visp3/sensor/vpMocap.h index 0d60744f64..be24dd7d4e 100644 --- a/modules/sensor/include/visp3/sensor/vpMocap.h +++ b/modules/sensor/include/visp3/sensor/vpMocap.h @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMocap * \ingroup group_sensor_mocap @@ -52,11 +56,11 @@ class VISP_EXPORT vpMocap /*! * Default constructor that turns off the verbose mode. */ - vpMocap() : m_verbose(false), m_serverAddr(){}; + vpMocap() : m_verbose(false), m_serverAddr() { }; /*! * Destructor. */ - virtual ~vpMocap(){}; + virtual ~vpMocap() { }; /*! * Close connexion with the motion capture device. @@ -104,5 +108,7 @@ class VISP_EXPORT vpMocap bool m_verbose; std::string m_serverAddr; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // vpMocap_h diff --git a/modules/sensor/include/visp3/sensor/vpMocapQualisys.h b/modules/sensor/include/visp3/sensor/vpMocapQualisys.h index 255f9da79d..91e3d778d5 100644 --- a/modules/sensor/include/visp3/sensor/vpMocapQualisys.h +++ b/modules/sensor/include/visp3/sensor/vpMocapQualisys.h @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpMocapQualisys * \ingroup group_sensor_mocap @@ -67,6 +71,8 @@ class VISP_EXPORT vpMocapQualisys : public vpMocap class vpMocapQualisysImpl; vpMocapQualisysImpl *m_impl; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // vpMocapQualisys_h diff --git a/modules/sensor/include/visp3/sensor/vpMocapVicon.h b/modules/sensor/include/visp3/sensor/vpMocapVicon.h index aa44ec1605..903676ea1a 100644 --- a/modules/sensor/include/visp3/sensor/vpMocapVicon.h +++ b/modules/sensor/include/visp3/sensor/vpMocapVicon.h @@ -41,6 +41,11 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! *\class vpMocapVicon * \ingroup group_sensor_mocap @@ -67,6 +72,8 @@ class VISP_EXPORT vpMocapVicon : public vpMocap class vpMocapViconImpl; vpMocapViconImpl *m_impl; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif // vpMocapVicon_h diff --git a/modules/sensor/include/visp3/sensor/vpOccipitalStructure.h b/modules/sensor/include/visp3/sensor/vpOccipitalStructure.h index cb1cbca048..e88847db7c 100644 --- a/modules/sensor/include/visp3/sensor/vpOccipitalStructure.h +++ b/modules/sensor/include/visp3/sensor/vpOccipitalStructure.h @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpOccipitalStructure @@ -359,6 +363,8 @@ class VISP_EXPORT vpOccipitalStructure void getColoredPointcloud(pcl::PointCloud::Ptr &pointcloud); #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpPylonFactory.h b/modules/sensor/include/visp3/sensor/vpPylonFactory.h index d2ddcd010d..c1338e11a0 100644 --- a/modules/sensor/include/visp3/sensor/vpPylonFactory.h +++ b/modules/sensor/include/visp3/sensor/vpPylonFactory.h @@ -35,6 +35,12 @@ * *****************************************************************************/ +/*! + \file vpPylonFactory.h + \brief Description: Factory class used to create vpPylonGrabber + instances. +*/ + #ifndef _vpPylonFactory_h_ #define _vpPylonFactory_h_ @@ -44,12 +50,10 @@ #ifdef VISP_HAVE_PYLON -/*! - \file vpPylonFactory.h - \brief Description: Factory class used to create vpPylonGrabber - instances. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \brief Factory singleton class to create vpPylonGrabber subclass instances. @@ -72,7 +76,8 @@ class VISP_EXPORT vpPylonFactory /*! Device class of cameras. */ - enum DeviceClass { + enum DeviceClass + { BASLER_GIGE, //!< Basler GigE camera. BASLER_USB //!< Basler USB camera. }; @@ -81,12 +86,14 @@ class VISP_EXPORT vpPylonFactory private: //! Default constructor. - vpPylonFactory(){}; + vpPylonFactory() { }; vpPylonFactory(vpPylonFactory const &); void operator=(vpPylonFactory const &); Pylon::PylonAutoInitTerm m_autoInitTerm; //!< Auto initialize and terminate object for pylon SDK. }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifdef VISP_HAVE_PYLON #endif // #ifndef _vpPylonFactory_h_ diff --git a/modules/sensor/include/visp3/sensor/vpPylonGrabber.h b/modules/sensor/include/visp3/sensor/vpPylonGrabber.h index 726b7064ba..800ce77fe0 100644 --- a/modules/sensor/include/visp3/sensor/vpPylonGrabber.h +++ b/modules/sensor/include/visp3/sensor/vpPylonGrabber.h @@ -36,6 +36,12 @@ * *****************************************************************************/ +/*! + \file vpPylonGrabber.h + \brief Wrapper over Basler Pylon SDK to capture images from Basler + cameras. +*/ + #ifndef _vpPylonGrabber_h_ #define _vpPylonGrabber_h_ @@ -58,12 +64,10 @@ #include -/*! - \file vpPylonGrabber.h - \brief Wrapper over Basler Pylon SDK to capture images from Basler - cameras. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpPylonGrabber \ingroup group_sensor_camera @@ -99,11 +103,12 @@ class VISP_EXPORT vpPylonGrabber : public vpFrameGrabber /*! Default destructor. */ - virtual ~vpPylonGrabber(){}; + virtual ~vpPylonGrabber() { }; /*! Valid values for user set names. */ - enum UserSetName { + enum UserSetName + { USERSET_DEFAULT, //!< The default user set. USERSET_USERSET1, //!< User set 1. USERSET_USERSET2, //!< User set 2. @@ -390,6 +395,8 @@ class VISP_EXPORT vpPylonGrabber : public vpFrameGrabber */ virtual void stopCapture() = 0; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifdef VISP_HAVE_PYLON #endif // #ifndef _vpPylonGrabber_h_ diff --git a/modules/sensor/include/visp3/sensor/vpRealSense.h b/modules/sensor/include/visp3/sensor/vpRealSense.h index cc27cd0235..5ee9f188b9 100644 --- a/modules/sensor/include/visp3/sensor/vpRealSense.h +++ b/modules/sensor/include/visp3/sensor/vpRealSense.h @@ -55,6 +55,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRealSense @@ -456,6 +460,8 @@ class VISP_EXPORT vpRealSense void initStream(); }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpRealSense2.h b/modules/sensor/include/visp3/sensor/vpRealSense2.h index 9c0e40158b..2e6e08e71a 100644 --- a/modules/sensor/include/visp3/sensor/vpRealSense2.h +++ b/modules/sensor/include/visp3/sensor/vpRealSense2.h @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpRealSense2 @@ -405,6 +409,8 @@ class VISP_EXPORT vpRealSense2 pcl::PointCloud::Ptr &pointcloud); #endif }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpScanPoint.h b/modules/sensor/include/visp3/sensor/vpScanPoint.h index 28904ce659..3a9a41b595 100644 --- a/modules/sensor/include/visp3/sensor/vpScanPoint.h +++ b/modules/sensor/include/visp3/sensor/vpScanPoint.h @@ -32,9 +32,17 @@ * Single laser scanner point. * *****************************************************************************/ + +/*! + \file vpScanPoint.h + + \brief Implements a single laser scanner point. +*/ + #ifndef vpScanPoint_h #define vpScanPoint_h +#include #include #include // std::fabs @@ -43,12 +51,10 @@ #include #include -/*! - \file vpScanPoint.h - - \brief Implements a single laser scanner point. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpScanPoint @@ -244,5 +250,7 @@ inline std::ostream &operator<<(std::ostream &s, const vpScanPoint &p) return s; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpSickLDMRS.h b/modules/sensor/include/visp3/sensor/vpSickLDMRS.h index a1bddca0c2..e9a92448bb 100644 --- a/modules/sensor/include/visp3/sensor/vpSickLDMRS.h +++ b/modules/sensor/include/visp3/sensor/vpSickLDMRS.h @@ -32,6 +32,13 @@ * Sick LD-MRS laser driver. * *****************************************************************************/ + +/*! + * \file vpSickLDMRS.h + * + * \brief Driver for the Sick LD-MRS laser scanner. + */ + #ifndef vpSickLDMRS_h #define vpSickLDMRS_h @@ -50,12 +57,10 @@ #include #include -/*! - * \file vpSickLDMRS.h - * - * \brief Driver for the Sick LD-MRS laser scanner. - */ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpSickLDMRS * @@ -156,7 +161,9 @@ class VISP_EXPORT vpSickLDMRS : public vpLaserScanner bool isFirstMeasure; size_t maxlen_body; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpUeyeGrabber.h b/modules/sensor/include/visp3/sensor/vpUeyeGrabber.h index 2a0370c23b..b9abc08a89 100644 --- a/modules/sensor/include/visp3/sensor/vpUeyeGrabber.h +++ b/modules/sensor/include/visp3/sensor/vpUeyeGrabber.h @@ -41,6 +41,10 @@ #ifdef VISP_HAVE_UEYE +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * \class vpUeyeGrabber * \ingroup group_sensor_camera @@ -120,6 +124,8 @@ class VISP_EXPORT vpUeyeGrabber class vpUeyeGrabberImpl; vpUeyeGrabberImpl *m_impl; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h b/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h index d335e16f68..14d4e5bb38 100644 --- a/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h +++ b/modules/sensor/include/visp3/sensor/vpV4l2Grabber.h @@ -54,6 +54,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpV4l2Grabber @@ -346,6 +350,8 @@ class VISP_EXPORT vpV4l2Grabber : public vpFrameGrabber vpV4l2FrameFormatType m_frameformat; vpV4l2PixelFormatType m_pixelformat; }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif #endif diff --git a/modules/sensor/src/force-torque/vpComedi.cpp b/modules/sensor/src/force-torque/vpComedi.cpp index f02ed55a17..e8f27bd519 100644 --- a/modules/sensor/src/force-torque/vpComedi.cpp +++ b/modules/sensor/src/force-torque/vpComedi.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. */ @@ -170,7 +174,9 @@ std::string vpComedi::getPhyDataUnits() const } return units; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vpComedi.cpp.o) has symbols void dummy_vpComedi() { }; diff --git a/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp b/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp index 60034baf8f..6b64cb5e74 100644 --- a/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp +++ b/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp @@ -46,7 +46,8 @@ #ifdef VISP_HAVE_FUNC_INET_NTOP #ifndef DOXYGEN_SHOULD_SKIP_THIS -typedef struct response_struct { +typedef struct response_struct +{ uint32_t rdt_sequence; uint32_t ft_sequence; uint32_t status; @@ -54,6 +55,10 @@ typedef struct response_struct { } RESPONSE; #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor that set counts per force to 1000000, counts per torque to 1000000000 and scaling factor to 1. * Note that counts per force, counts per torque and scaling factor are used to transform force / torque in user units @@ -62,9 +67,8 @@ typedef struct response_struct { */ vpForceTorqueAtiNetFTSensor::vpForceTorqueAtiNetFTSensor() : vpUDPClient(), m_counts_per_force(1000000), m_counts_per_torque(1000000000), m_scaling_factor(1), m_ft_bias(6, 0), - m_data_count(0), m_data_count_prev(0), m_ft(6, 0), m_is_streaming_started(false) -{ -} + m_data_count(0), m_data_count_prev(0), m_ft(6, 0), m_is_streaming_started(false) +{ } /*! * Constructor that initializes an Eternet UDP connection to a given hostname and port. @@ -73,9 +77,8 @@ vpForceTorqueAtiNetFTSensor::vpForceTorqueAtiNetFTSensor() */ vpForceTorqueAtiNetFTSensor::vpForceTorqueAtiNetFTSensor(const std::string &hostname, int port) : vpUDPClient(hostname, port), m_counts_per_force(1000000), m_counts_per_torque(1000000000), m_scaling_factor(1), - m_ft_bias(6, 0), m_data_count(0), m_data_count_prev(0), m_ft(6, 0), m_is_streaming_started(false) -{ -} + m_ft_bias(6, 0), m_data_count(0), m_data_count_prev(0), m_ft(6, 0), m_is_streaming_started(false) +{ } /*! * Start high-speed real-time Net F/T streaming. @@ -175,7 +178,8 @@ void vpForceTorqueAtiNetFTSensor::bias(unsigned int n_counts) if (n_counts == 0) { m_ft_bias = getForceTorque(); - } else { + } + else { for (unsigned int i = 0; i < n_counts; i++) { ft_bias_tmp += getForceTorque(); waitForNewData(); @@ -272,5 +276,7 @@ bool vpForceTorqueAtiNetFTSensor::waitForNewData(unsigned int timeout) return false; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/sensor/src/force-torque/vpForceTorqueAtiSensor.cpp b/modules/sensor/src/force-torque/vpForceTorqueAtiSensor.cpp index b65ca6e197..7df66c3668 100644 --- a/modules/sensor/src/force-torque/vpForceTorqueAtiSensor.cpp +++ b/modules/sensor/src/force-torque/vpForceTorqueAtiSensor.cpp @@ -44,13 +44,16 @@ static Calibration *s_calibinfo = nullptr; //!< Struct containing calibration information +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor. */ vpForceTorqueAtiSensor::vpForceTorqueAtiSensor() : m_calibfile(""), m_index(1), m_num_axes(6), m_num_channels(6), m_sample_bias() -{ -} +{ } /*! * Open the connection to the device. @@ -255,7 +258,8 @@ std::ostream &operator<<(std::ostream &os, const vpForceTorqueAtiSensor &ati) char *units; if ((s_calibinfo->AxisNames[i])[0] == 'F') { units = s_calibinfo->ForceUnits; - } else + } + else units = s_calibinfo->TorqueUnits; os << s_calibinfo->AxisNames[i] << ": " << s_calibinfo->MaxLoads[i] << " " << units << std::endl; } @@ -276,9 +280,11 @@ std::ostream &operator<<(std::ostream &os, const vpForceTorqueAtiSensor &ati) return os; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: // libvisp_sensor.a(vpForceTorqueAtiSensor.cpp.o) has no symbols -void dummy_vpForceTorqueAtiSensor(){}; +void dummy_vpForceTorqueAtiSensor() { }; #endif diff --git a/modules/sensor/src/force-torque/vpForceTorqueIitSensor.cpp b/modules/sensor/src/force-torque/vpForceTorqueIitSensor.cpp index d111f26664..90ba9c141d 100644 --- a/modules/sensor/src/force-torque/vpForceTorqueIitSensor.cpp +++ b/modules/sensor/src/force-torque/vpForceTorqueIitSensor.cpp @@ -45,6 +45,10 @@ #if defined(VISP_HAVE_FT_IIT_SDK) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. @@ -52,8 +56,8 @@ */ vpForceTorqueIitSensor::vpForceTorqueIitSensor() : m_ftLib(), m_numSensorsInLib(0), m_ft(6, 0), m_ft_filt(6, 0), m_ftSensorsData(), m_acquisitionEnabled(false), - m_dataValid(false), m_connected(false), m_acquisitionThread(), m_timeCur(), m_timePrev(), m_mutex(), - m_warmupMilliseconds(500) + m_dataValid(false), m_connected(false), m_acquisitionThread(), m_timeCur(), m_timePrev(), m_mutex(), + m_warmupMilliseconds(500) { // Get number of connected in library sensors m_numSensorsInLib = m_ftLib._getNumberOfConnectedSensors(); @@ -140,7 +144,8 @@ void vpForceTorqueIitSensor::acquisitionLoop() auto warmup_milliseconds = std::chrono::duration_cast(m_timeCur - time_init).count(); if (warmup_milliseconds > m_warmupMilliseconds) { m_dataValid = true; - } else { + } + else { continue; } @@ -207,7 +212,8 @@ vpColVector vpForceTorqueIitSensor::getForceTorque(bool filtered) const std::lock_guard lock(m_mutex); if (filtered) { return m_ft_filt; - } else { + } + else { return m_ft; } } @@ -235,9 +241,11 @@ void vpForceTorqueIitSensor::stopStreaming() m_acquisitionThread.join(); } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning: // libvisp_sensor.a(vpForceTorqueIitSensor.cpp.o) has no symbols -void dummy_vpForceTorqueIitSensor(){}; +void dummy_vpForceTorqueIitSensor() { }; #endif diff --git a/modules/sensor/src/framegrabber/1394/vp1394CMUGrabber.cpp b/modules/sensor/src/framegrabber/1394/vp1394CMUGrabber.cpp index a2364259b1..0122822869 100644 --- a/modules/sensor/src/framegrabber/1394/vp1394CMUGrabber.cpp +++ b/modules/sensor/src/framegrabber/1394/vp1394CMUGrabber.cpp @@ -42,13 +42,17 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Basic constructor. */ vp1394CMUGrabber::vp1394CMUGrabber() : index(0), // If a camera was not selected the first one (index = 0) will // be used - _format(-1), _mode(-1), _fps(-1), _modeauto(true), _gain(0), _shutter(0), _color(vp1394CMUGrabber::UNKNOWN) + _format(-1), _mode(-1), _fps(-1), _modeauto(true), _gain(0), _shutter(0), _color(vp1394CMUGrabber::UNKNOWN) { // public members init = false; @@ -244,7 +248,7 @@ void vp1394CMUGrabber::acquire(vpImage &I) close(); vpERROR_TRACE("Format conversion not implemented. Acquisition failed."); throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. " - "Acquisition failed.")); + "Acquisition failed.")); break; }; @@ -308,7 +312,7 @@ void vp1394CMUGrabber::acquire(vpImage &I) close(); vpERROR_TRACE("Format conversion not implemented. Acquisition failed."); throw(vpFrameGrabberException(vpFrameGrabberException::otherError, "Format conversion not implemented. " - "Acquisition failed.")); + "Acquisition failed.")); break; }; } @@ -397,20 +401,21 @@ void vp1394CMUGrabber::setGain(unsigned short gain) if (_gain < min) { _gain = min; std::cout << "vp1394CMUGrabber warning: Desired gain register value of " - "IEEE 1394 camera number " - << index << " can't be less than " << _gain << std::endl; - } else if (_gain > max) { + "IEEE 1394 camera number " + << index << " can't be less than " << _gain << std::endl; + } + else if (_gain > max) { _gain = max; std::cout << "vp1394CMUGrabber warning: Desired gain register value of " - "IEEE 1394 camera number " - << index << " can't be greater than " << _gain << std::endl; + "IEEE 1394 camera number " + << index << " can't be greater than " << _gain << std::endl; } Control->SetAutoMode(false); if (Control->SetValue(_gain) != CAM_SUCCESS) { std::cout << "vp1394CMUGrabber warning: Can't set gain register value of " - "IEEE 1394 camera number " - << index << std::endl; + "IEEE 1394 camera number " + << index << std::endl; } } @@ -460,19 +465,20 @@ void vp1394CMUGrabber::setShutter(unsigned short shutter) if (_shutter < min) { _shutter = min; std::cout << "vp1394CMUGrabber warning: Desired exposure time register " - "value of IEEE 1394 camera number " - << index << " can't be less than " << _shutter << std::endl; - } else if (_shutter > max) { + "value of IEEE 1394 camera number " + << index << " can't be less than " << _shutter << std::endl; + } + else if (_shutter > max) { _shutter = max; std::cout << "vp1394CMUGrabber warning: Desired exposure time register " - "value of IEEE 1394 camera number " - << index << " can't be greater than " << _shutter << std::endl; + "value of IEEE 1394 camera number " + << index << " can't be greater than " << _shutter << std::endl; } Control->SetAutoMode(false); if (Control->SetValue(_shutter) != CAM_SUCCESS) { std::cout << "vp1394CMUGrabber warning: Can't set exposure time register " - "value of IEEE 1394 camera number " - << index << std::endl; + "value of IEEE 1394 camera number " + << index << std::endl; } } @@ -486,7 +492,8 @@ void vp1394CMUGrabber::displayCameraDescription(int cam_id) camera->GetNodeDescription(cam_id, buf, 512); std::cout << "Camera " << cam_id << ": " << buf << std::endl; - } else { + } + else { std::cout << "Camera " << cam_id << ": camera not found" << std::endl; } } @@ -749,9 +756,11 @@ vp1394CMUGrabber &vp1394CMUGrabber::operator>>(vpImage &I) this->acquire(I); return *this; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vp1394CMUGrabber.cpp.o) has // no symbols -void dummy_vp1394CMUGrabber(){}; +void dummy_vp1394CMUGrabber() { }; #endif diff --git a/modules/sensor/src/framegrabber/1394/vp1394TwoGrabber.cpp b/modules/sensor/src/framegrabber/1394/vp1394TwoGrabber.cpp index fec67e35d9..e2e7185b02 100644 --- a/modules/sensor/src/framegrabber/1394/vp1394TwoGrabber.cpp +++ b/modules/sensor/src/framegrabber/1394/vp1394TwoGrabber.cpp @@ -52,6 +52,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const char *vp1394TwoGrabber::strVideoMode[DC1394_VIDEO_MODE_NUM] = { "MODE_160x120_YUV444", "MODE_320x240_YUV422", "MODE_640x480_YUV411", "MODE_640x480_YUV422", "MODE_640x480_RGB8", "MODE_640x480_MONO8", "MODE_640x480_MONO16", "MODE_800x600_YUV422", @@ -1278,22 +1282,22 @@ void vp1394TwoGrabber::setFormat7ROI(unsigned int left, unsigned int top, unsign setCapture(DC1394_ON); setTransmission(DC1394_ON); + } } -} -/*! + /*! - Open ohci and asign handle to it and get the camera nodes and - describe them as we find them. + Open ohci and asign handle to it and get the camera nodes and + describe them as we find them. - \param reset : If "true", reset the bus attached to the first - camera found. Bus reset may help to make firewire working if the - program was not properly stopped by a CTRL-C. + \param reset : If "true", reset the bus attached to the first + camera found. Bus reset may help to make firewire working if the + program was not properly stopped by a CTRL-C. - \exception initializationError : If a raw1394 handle can't be aquired, - or if no camera is found. + \exception initializationError : If a raw1394 handle can't be aquired, + or if no camera is found. - \sa close() - */ + \sa close() + */ void vp1394TwoGrabber::initialize(bool reset) { if (init == false) { @@ -1359,7 +1363,7 @@ void vp1394TwoGrabber::initialize(bool reset) "`ohci1394' are loaded \n" " - if you have read/write access to /dev/raw1394\n\n"); throw(vpFrameGrabberException(vpFrameGrabberException::initializationError, "Unable to look for cameras")); - } + } #endif if (num_cameras == 0) { @@ -1397,7 +1401,7 @@ void vp1394TwoGrabber::initialize(bool reset) } init = true; - } +} } /*! @@ -1429,23 +1433,23 @@ void vp1394TwoGrabber::open() else { if (status == DC1394_ON) { vpTRACE("ISO transmission refuses to stop"); - } + } #ifdef VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 // No yet in the new API cameras[camera_id]->is_iso_on = status; #endif - } - //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > - // libdc1394-2.0.0-rc7 } - //#endif + //#ifdef VISP_HAVE_DC1394_CAMERA_ENUMERATE // new API > + // libdc1394-2.0.0-rc7 } + //#endif + } setCamera(camera_id); // setIsoSpeed(DC1394_ISO_SPEED_400); setCapture(DC1394_ON); setTransmission(DC1394_ON); camIsOpen[camera_id] = true; - } +} } /*! @@ -1495,8 +1499,8 @@ void vp1394TwoGrabber::close() #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 dc1394_free_camera(cameras[i]); #endif + } } - } if (camIsOpen != nullptr) { delete[] camIsOpen; camIsOpen = nullptr; @@ -1537,21 +1541,21 @@ void vp1394TwoGrabber::close() } init = false; - } -} + } + } -/*! + /*! - Set the ring buffer size used for the capture. - To know the current ring buffer size see getRingBufferSize(). + Set the ring buffer size used for the capture. + To know the current ring buffer size see getRingBufferSize(). - \param size : Ring buffer size. + \param size : Ring buffer size. - \exception vpFrameGrabberException::settingError : If ring buffer size is - not valid. + \exception vpFrameGrabberException::settingError : If ring buffer size is + not valid. - \sa getRingBufferSize() -*/ + \sa getRingBufferSize() + */ void vp1394TwoGrabber::setRingBufferSize(unsigned int size) { if (size < 1) { @@ -2767,22 +2771,22 @@ void vp1394TwoGrabber::printCameraInfo() #elif defined VISP_HAVE_DC1394_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7 dc1394_print_feature_set(&features); #endif - } - std::cout << "----------------------------------------------------------" << std::endl; } + std::cout << "----------------------------------------------------------" << std::endl; + } -/*! + /*! - Converts the video mode identifier into a string containing the description - of the mode. + Converts the video mode identifier into a string containing the description + of the mode. - \param videomode : The camera capture video mode. + \param videomode : The camera capture video mode. - \return A string describing the mode, an empty string if the mode is not - supported. + \return A string describing the mode, an empty string if the mode is not + supported. - \sa string2videoMode() -*/ + \sa string2videoMode() + */ std::string vp1394TwoGrabber::videoMode2string(vp1394TwoVideoModeType videomode) { std::string _str = ""; @@ -3399,7 +3403,9 @@ vp1394TwoGrabber &vp1394TwoGrabber::operator>>(vpImage &I) this->acquire(I); return *this; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vp1394TwoGrabber.cpp.o) has // no symbols diff --git a/modules/sensor/src/framegrabber/directshow/vpDirectShowDevice.cpp b/modules/sensor/src/framegrabber/directshow/vpDirectShowDevice.cpp index aaeb7b171d..0662916732 100644 --- a/modules/sensor/src/framegrabber/directshow/vpDirectShowDevice.cpp +++ b/modules/sensor/src/framegrabber/directshow/vpDirectShowDevice.cpp @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Initialize the vpDirectShowDevice with the moniker's information \param pMoniker The moniker that contains the device's information @@ -111,10 +115,12 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDirectShowDevice &dev) { return os << dev.name << std::endl << dev.desc << std::endl << dev.devPath; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vpDirectShowDevice.cpp.o) // has no symbols -void dummy_vpDirectShowDevice(){}; +void dummy_vpDirectShowDevice() { }; #endif #endif diff --git a/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabber.cpp b/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabber.cpp index 4fd5d3123f..acf031910d 100644 --- a/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabber.cpp +++ b/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabber.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Returns the number of rows in the grabbed image */ @@ -188,9 +192,11 @@ bool vpDirectShowGrabber::setMediaType(int mediaTypeID) { return grabber->setMed \return the current mediaTypeID */ int vpDirectShowGrabber::getMediaType() { return grabber->getMediaType(); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vpDirectShowGrabber.cpp.o) // has no symbols -void dummy_vpDirectShowGrabber(){}; +void dummy_vpDirectShowGrabber() { }; #endif diff --git a/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabberImpl.cpp b/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabberImpl.cpp index a1603b4244..a02cfa8e1b 100644 --- a/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabberImpl.cpp +++ b/modules/sensor/src/framegrabber/directshow/vpDirectShowGrabberImpl.cpp @@ -40,6 +40,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif vpDirectShowDevice *vpDirectShowGrabberImpl::deviceList = nullptr; unsigned int vpDirectShowGrabberImpl::nbDevices; @@ -237,7 +241,8 @@ bool vpDirectShowGrabberImpl::createDeviceList(CComPtr &ppVideoInp // if we can't get the device properties, skip to the next device j++; nbDevices--; - } else { + } + else { i++; j++; } @@ -288,7 +293,8 @@ bool vpDirectShowGrabberImpl::getDevice(unsigned int n, CComPtr &pp // now the device is in use deviceList[n].setInUse(); deviceFound = true; - } else { + } + else { break; } // we can't get the device's filter, quit } @@ -438,16 +444,16 @@ bool vpDirectShowGrabberImpl::checkSourceType(CComPtr &pCapSourcePin) // get the fourcc code format = ((bmpInfo.biCompression & 0xFF000000) >> 24) | ((bmpInfo.biCompression & 0x00FF0000) >> 8) | - ((bmpInfo.biCompression & 0x0000FF00) << 8) | (bmpInfo.biCompression & 0x000000FF) << 24; + ((bmpInfo.biCompression & 0x0000FF00) << 8) | (bmpInfo.biCompression & 0x000000FF) << 24; std::cout << "This format is not one of the standard YUV or RGB format " - "supported by DirectShow.\n" - << "FourCC : " << (char)(bmpInfo.biCompression & 0x000000FF) - << (char)((bmpInfo.biCompression & 0x0000FF00) >> 8) << (char)((bmpInfo.biCompression & 0x00FF0000) >> 16) - << (char)((bmpInfo.biCompression & 0xFF000000) >> 24) << std::endl; + "supported by DirectShow.\n" + << "FourCC : " << (char)(bmpInfo.biCompression & 0x000000FF) + << (char)((bmpInfo.biCompression & 0x0000FF00) >> 8) << (char)((bmpInfo.biCompression & 0x00FF0000) >> 16) + << (char)((bmpInfo.biCompression & 0xFF000000) >> 24) << std::endl; - // Y800 is top-down oriented so the image doesn't have to be flipped - // vertically +// Y800 is top-down oriented so the image doesn't have to be flipped +// vertically if (format == 'Y800') { sgCB.invertedSource = false; } @@ -461,8 +467,8 @@ bool vpDirectShowGrabberImpl::checkSourceType(CComPtr &pCapSourcePin) // needs invertedSource sets to true else { std::cout << "Unknown FourCC compression type, assuming top-down " - "orientation. Image may be inverted." - << std::endl; + "orientation. Image may be inverted." + << std::endl; sgCB.invertedSource = false; // consider that the image is topdown oriented by default } } @@ -812,17 +818,18 @@ bool vpDirectShowGrabberImpl::setFormat(unsigned int width, unsigned int height, LONGLONG ActualFrameDuration; if (FAILED(hr = pVideoControl->GetCurrentActualFrameRate(pCapSourcePin, &ActualFrameDuration))) std::cout << "Current format (not sure): " << width << " x " << height << " at " - << 10000000 / pVih->AvgTimePerFrame << " fps" << std::endl - << std::endl; + << 10000000 / pVih->AvgTimePerFrame << " fps" << std::endl + << std::endl; else { std::cout << "Current format : " << width << " x " << height << " at " << 10000000 / ActualFrameDuration - << " fps" << std::endl - << std::endl; + << " fps" << std::endl + << std::endl; pVih->AvgTimePerFrame = ActualFrameDuration; } found = true; } - } else { + } + else { if ((unsigned int)lWidth == width && (unsigned int)lHeight == height) { pVih->AvgTimePerFrame = scc.MinFrameInterval; // set the capture media type and the grabber media type @@ -834,8 +841,8 @@ bool vpDirectShowGrabberImpl::setFormat(unsigned int width, unsigned int height, pVih = (VIDEOINFOHEADER *)sgCB.connectedMediaType.pbFormat; found = true; std::cout << "Current format : " << width << " x " << height << " at " - << (10000000 / pVih->AvgTimePerFrame) << " fps" << std::endl - << std::endl; + << (10000000 / pVih->AvgTimePerFrame) << " fps" << std::endl + << std::endl; } } } @@ -847,11 +854,11 @@ bool vpDirectShowGrabberImpl::setFormat(unsigned int width, unsigned int height, if (!found) if (framerate != nullptr) std::cout << "The " << width << " x " << height << " at " << framerate - << " fps source image format is not available. " << std::endl - << std::endl; + << " fps source image format is not available. " << std::endl + << std::endl; else std::cout << "The " << width << " x " << height << "source image size is not available. " << std::endl - << std::endl; + << std::endl; return found; } @@ -947,29 +954,29 @@ bool vpDirectShowGrabberImpl::getStreamCapabilities() std::cout << "subtype : I420" << std::endl; else std::cout << "subtype (not supported) :" << (char)(pVih->bmiHeader.biCompression & 0x000000FF) - << (char)((pVih->bmiHeader.biCompression & 0x0000FF00) >> 8) - << (char)((pVih->bmiHeader.biCompression & 0x00FF0000) >> 16) - << (char)((pVih->bmiHeader.biCompression & 0xFF000000) >> 24) << std::endl; + << (char)((pVih->bmiHeader.biCompression & 0x0000FF00) >> 8) + << (char)((pVih->bmiHeader.biCompression & 0x00FF0000) >> 16) + << (char)((pVih->bmiHeader.biCompression & 0xFF000000) >> 24) << std::endl; std::cout << "image size : " << pVih->bmiHeader.biWidth << " x " << pVih->bmiHeader.biHeight << std::endl; std::cout << "framerate range: [" << 10000000 / scc.MaxFrameInterval << "," << 10000000 / scc.MinFrameInterval - << "]" << std::endl - << std::endl; + << "]" << std::endl + << std::endl; - /* - long frameRateNum; - LONGLONG *frameRateList; - if(FAILED(hr = - pVideoControl->GetFrameRateList(pCapSourcePin,iFormat,dimensions, - //inputs &frameRateNum, &frameRateList))) //outputs return false; - for(int i=0; i<(int)frameRateNum ; - i++) - { - std::cout<<(float)(10000000/frameRateList[i])<<" - fps"<GetFrameRateList(pCapSourcePin,iFormat,dimensions, + //inputs &frameRateNum, &frameRateList))) //outputs return false; + for(int i=0; i<(int)frameRateNum ; + i++) + { + std::cout<<(float)(10000000/frameRateList[i])<<" + fps"< #if (defined(VISP_HAVE_DIRECTSHOW)) +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Constructor - creates the semaphore */ @@ -116,7 +120,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo flip); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -125,11 +130,12 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo // reset the demand boolean acqGrayDemand = false; } - } else { + } + else { unsigned long FourCC; FourCC = ((bmpInfo.biCompression & 0xFF000000) >> 24) | ((bmpInfo.biCompression & 0x00FF0000) >> 8) | - ((bmpInfo.biCompression & 0x0000FF00) << 8) | (bmpInfo.biCompression & 0x000000FF) << 24; - // if the buffer contains a like YUV420 image + ((bmpInfo.biCompression & 0x0000FF00) << 8) | (bmpInfo.biCompression & 0x000000FF) << 24; + // if the buffer contains a like YUV420 image if (connectedMediaType.subtype == MEDIASUBTYPE_IYUV || FourCC == 'I420') { // if it was an RGBa image demand if (acqRGBaDemand) { @@ -140,7 +146,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo rgbaIm->getHeight()); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -150,8 +157,9 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo acqGrayDemand = false; } - } else if (connectedMediaType.subtype == MEDIASUBTYPE_YV12) { - // if it was an RGBa image demand + } + else if (connectedMediaType.subtype == MEDIASUBTYPE_YV12) { + // if it was an RGBa image demand if (acqRGBaDemand) { // first, resizes the image as needed rgbaIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -160,7 +168,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo rgbaIm->getHeight()); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -169,8 +178,9 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo // reset the demand boolean acqGrayDemand = false; } - } else if (connectedMediaType.subtype == MEDIASUBTYPE_YVU9) { - // if it was an RGBa image demand + } + else if (connectedMediaType.subtype == MEDIASUBTYPE_YVU9) { + // if it was an RGBa image demand if (acqRGBaDemand) { // first, resizes the image as needed rgbaIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -179,7 +189,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo rgbaIm->getHeight()); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -188,8 +199,9 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo // reset the demand boolean acqGrayDemand = false; } - } else if (connectedMediaType.subtype == MEDIASUBTYPE_YUY2 || connectedMediaType.subtype == MEDIASUBTYPE_YUYV) { - // if it was an RGBa image demand + } + else if (connectedMediaType.subtype == MEDIASUBTYPE_YUY2 || connectedMediaType.subtype == MEDIASUBTYPE_YUYV) { + // if it was an RGBa image demand if (acqRGBaDemand) { // first, resizes the image as needed rgbaIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -198,7 +210,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo rgbaIm->getWidth() * rgbaIm->getHeight()); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -207,8 +220,9 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo // reset the demand boolean acqGrayDemand = false; } - } else if (connectedMediaType.subtype == MEDIASUBTYPE_YVYU) { - // if it was an RGBa image demand + } + else if (connectedMediaType.subtype == MEDIASUBTYPE_YVYU) { + // if it was an RGBa image demand if (acqRGBaDemand) { // first, resizes the image as needed rgbaIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -217,7 +231,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo rgbaIm->getWidth() * rgbaIm->getHeight()); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -226,8 +241,9 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo // reset the demand boolean acqGrayDemand = false; } - } else if (connectedMediaType.subtype == MEDIASUBTYPE_UYVY) { - // if it was an RGBa image demand + } + else if (connectedMediaType.subtype == MEDIASUBTYPE_UYVY) { + // if it was an RGBa image demand if (acqRGBaDemand) { // first, resizes the image as needed rgbaIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -236,7 +252,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo rgbaIm->getWidth() * rgbaIm->getHeight()); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -245,8 +262,9 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo // reset the demand boolean acqGrayDemand = false; } - } else if (connectedMediaType.subtype == MEDIASUBTYPE_RGB32) { - // if it was an RGBa image demand + } + else if (connectedMediaType.subtype == MEDIASUBTYPE_RGB32) { + // if it was an RGBa image demand if (acqRGBaDemand) { // first, resizes the image as needed rgbaIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -256,7 +274,8 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo memcpy(rgbaIm->bitmap, pBuffer, 4 * rgbaIm->getWidth() * rgbaIm->getHeight()); // reset the demand boolean acqRGBaDemand = false; - } else // if it was a grayscale image demand + } + else // if it was a grayscale image demand { // first, resizes the image as needed grayIm->resize(abs(bmpInfo.biHeight), bmpInfo.biWidth); @@ -274,11 +293,13 @@ STDMETHODIMP vpDirectShowSampleGrabberI::BufferCB(double Time, BYTE *pBuffer, lo } return S_OK; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: // libvisp_sensor.a(vpDirectShowSampleGrabberI.cpp.o) has no symbols -void dummy_vpDirectShowSampleGrabberI(){}; +void dummy_vpDirectShowSampleGrabberI() { }; #endif #endif diff --git a/modules/sensor/src/framegrabber/flycapture/vpFlyCaptureGrabber.cpp b/modules/sensor/src/framegrabber/flycapture/vpFlyCaptureGrabber.cpp index a96ae4e684..b4bbdc440e 100644 --- a/modules/sensor/src/framegrabber/flycapture/vpFlyCaptureGrabber.cpp +++ b/modules/sensor/src/framegrabber/flycapture/vpFlyCaptureGrabber.cpp @@ -46,6 +46,11 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif + /*! Default constructor that consider the first camera found on the bus as active. @@ -1401,7 +1406,9 @@ vpFlyCaptureGrabber &vpFlyCaptureGrabber::operator>>(vpImage &I) this->acquire(I); return *this; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning: // libvisp_flycapture.a(vpFlyCaptureGrabber.cpp.o) has no symbols diff --git a/modules/sensor/src/framegrabber/pylon/vpPylonFactory.cpp b/modules/sensor/src/framegrabber/pylon/vpPylonFactory.cpp index 68320a1fe5..3e8f4965ed 100644 --- a/modules/sensor/src/framegrabber/pylon/vpPylonFactory.cpp +++ b/modules/sensor/src/framegrabber/pylon/vpPylonFactory.cpp @@ -48,6 +48,10 @@ #include "vpPylonGrabberGigE.h" #include "vpPylonGrabberUsb.h" +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \brief Get the vpPylonFactory singleton. */ @@ -81,9 +85,11 @@ vpPylonGrabber *vpPylonFactory::createPylonGrabber(DeviceClass dev_class) break; } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning: // libvisp_pylon.a(vpPylonFactory.cpp.o) has no symbols -void dummy_vpPylonFactory(){}; +void dummy_vpPylonFactory() { }; #endif // #ifdef VISP_HAVE_PYLON diff --git a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.cpp b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.cpp index 88217022fe..247dfe503e 100644 --- a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.cpp +++ b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor that consider the first camera found on the bus as active. @@ -116,7 +120,8 @@ Pylon::CInstantCamera *vpPylonGrabberGigE::getCameraHandler() if (m_connected == true) { return &m_camera; - } else { + } + else { return nullptr; } } @@ -379,10 +384,12 @@ float vpPylonGrabberGigE::setGain(bool gain_auto, float gain_value) if (GenApi::IsWritable(m_camera.GainAbs)) { m_camera.GainAbs.SetValue(gain_value); return m_camera.GainAbs.GetValue(); - } else if (GenApi::IsWritable(m_camera.GainRaw)) { + } + else if (GenApi::IsWritable(m_camera.GainRaw)) { m_camera.GainRaw.SetValue(gain_value); return m_camera.GainRaw.GetValue(); - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set gain."); } @@ -407,10 +414,12 @@ float vpPylonGrabberGigE::setBlackLevel(float blacklevel_value) if (GenApi::IsWritable(m_camera.BlackLevelAbs)) { m_camera.BlackLevelAbs.SetValue(blacklevel_value); return m_camera.BlackLevelAbs.GetValue(); - } else if (GenApi::IsWritable(m_camera.BlackLevelRaw)) { + } + else if (GenApi::IsWritable(m_camera.BlackLevelRaw)) { m_camera.BlackLevelRaw.SetValue(blacklevel_value); return m_camera.BlackLevelRaw.GetValue(); - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set blacklevel."); } @@ -448,10 +457,12 @@ float vpPylonGrabberGigE::setExposure(bool exposure_on, bool exposure_auto, floa if (GenApi::IsWritable(m_camera.ExposureTimeAbs)) { m_camera.ExposureTimeAbs.SetValue(exposure_value * 1000); return m_camera.ExposureTimeAbs.GetValue() * 0.001; - } else if (GenApi::IsWritable(m_camera.ExposureTimeRaw)) { + } + else if (GenApi::IsWritable(m_camera.ExposureTimeRaw)) { m_camera.ExposureTimeRaw.SetValue(exposure_value); return m_camera.ExposureTimeRaw.GetValue(); - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set exposure."); } @@ -477,7 +488,8 @@ float vpPylonGrabberGigE::setGamma(bool gamma_on, float gamma_value) if (GenApi::IsWritable(m_camera.Gamma)) { m_camera.Gamma.SetValue(gamma_value); return m_camera.Gamma.GetValue(); - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set gamma."); } @@ -802,9 +814,11 @@ vpPylonGrabber &vpPylonGrabberGigE::operator>>(vpImage &I) acquire(I); return *this; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning: // libvisp_pylon.a(vpPylonGrabberGigE.cpp.o) has no symbols -void dummy_vpPylonGrabberGigE(){}; +void dummy_vpPylonGrabberGigE() { }; #endif // #ifdef VISP_HAVE_PYLON diff --git a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.h b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.h index 90e12ad8f3..4e6e35e21d 100644 --- a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.h +++ b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberGigE.h @@ -52,6 +52,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpPylonGrabberGigE @@ -122,6 +126,8 @@ class VISP_EXPORT vpPylonGrabberGigE : public vpPylonGrabber unsigned int m_numCameras; //!< Number of connected GigE cameras bool m_connected; //!< true if camera connected }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifdef VISP_HAVE_PYLON #endif // #ifndef _vpPylonGrabberGigE_h_ diff --git a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.cpp b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.cpp index 114d1780d2..fb38de5802 100644 --- a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.cpp +++ b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.cpp @@ -48,6 +48,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor that consider the first camera found on the bus as active. @@ -116,7 +120,8 @@ Pylon::CInstantCamera *vpPylonGrabberUsb::getCameraHandler() if (m_connected == true) { return &m_camera; - } else { + } + else { return nullptr; } } @@ -373,7 +378,8 @@ float vpPylonGrabberUsb::setGain(bool gain_auto, float gain_value) if (GenApi::IsWritable(m_camera.Gain)) { m_camera.Gain.SetValue(gain_value); return m_camera.Gain.GetValue(); - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set gain."); } @@ -398,7 +404,8 @@ float vpPylonGrabberUsb::setBlackLevel(float blacklevel_value) if (GenApi::IsWritable(m_camera.BlackLevel)) { m_camera.BlackLevel.SetValue(blacklevel_value); return m_camera.BlackLevel.GetValue(); - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set blacklevel."); } @@ -436,7 +443,8 @@ float vpPylonGrabberUsb::setExposure(bool exposure_on, bool exposure_auto, float if (GenApi::IsWritable(m_camera.ExposureTime)) { m_camera.ExposureTime.SetValue(exposure_value * 1000); return m_camera.ExposureTime.GetValue() * 0.001; - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set exposure."); } @@ -462,7 +470,8 @@ float vpPylonGrabberUsb::setGamma(bool gamma_on, float gamma_value) else m_camera.Gamma.SetValue(1); return m_camera.Gamma.GetValue(); - } else + } + else throw vpException(vpException::notImplementedError, "Don't know how to set gamma."); } @@ -787,9 +796,11 @@ vpPylonGrabber &vpPylonGrabberUsb::operator>>(vpImage &I) acquire(I); return *this; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning: // libvisp_pylon.a(vpPylonGrabberUsb.cpp.o) has no symbols -void dummy_vpPylonGrabberUsb(){}; +void dummy_vpPylonGrabberUsb() { }; #endif // #ifdef VISP_HAVE_PYLON diff --git a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.h b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.h index 2c6bdf3e57..47422d4001 100644 --- a/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.h +++ b/modules/sensor/src/framegrabber/pylon/vpPylonGrabberUsb.h @@ -52,6 +52,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpPylonGrabberUsb @@ -122,6 +126,8 @@ class VISP_EXPORT vpPylonGrabberUsb : public vpPylonGrabber unsigned int m_numCameras; //!< Number of connected USB cameras bool m_connected; //!< true if camera connected }; - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif // #ifdef VISP_HAVE_PYLON #endif // #ifndef _vpPylonGrabberUsb_h_ diff --git a/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber.cpp b/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber.cpp index d82d1250b0..11f67c69da 100644 --- a/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber.cpp +++ b/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber.cpp @@ -65,6 +65,10 @@ } \ } +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \brief image buffer properties structure */ struct sBufferProps { @@ -1425,7 +1429,9 @@ void vpUeyeGrabber::setWhiteBalance(bool auto_wb) { m_impl->setWhiteBalance(auto * \param[in] verbose : true to enable, false to disable verbose mode. */ void vpUeyeGrabber::setVerbose(bool verbose) { m_impl->setVerbose(verbose); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vpUeyeGrabber.cpp.o) has no symbols void dummy_vpUeyeGrabber() { }; diff --git a/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber_impl.h b/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber_impl.h index 7f6e1c85de..6e0d2b5c3a 100644 --- a/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber_impl.h +++ b/modules/sensor/src/framegrabber/ueye/vpUeyeGrabber_impl.h @@ -35,6 +35,10 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif class CameraList { public: @@ -84,13 +88,16 @@ class CameraList if (is_GetCameraList(m_pCamList) == IS_SUCCESS) { // SelectCamera (0); ret = true; - } else { + } + else { ret = false; } - } else { + } + else { ret = false; } - } else { + } + else { ret = false; } @@ -173,7 +180,8 @@ class CameraList { if (m_pCamList) { return (unsigned int)m_pCamList->dwCount; - } else { + } + else { return 0; } } @@ -182,6 +190,9 @@ class CameraList PUEYE_CAMERA_LIST m_pCamList; UEYE_CAMERA_INFO m_CamInfo; }; +#ifdef ENABLE_VISP_NAMESPACE +} +#endif /* ********************************************************************************************** diff --git a/modules/sensor/src/framegrabber/v4l2/vpV4l2Grabber.cpp b/modules/sensor/src/framegrabber/v4l2/vpV4l2Grabber.cpp index c2016a70d4..115f10d040 100644 --- a/modules/sensor/src/framegrabber/v4l2/vpV4l2Grabber.cpp +++ b/modules/sensor/src/framegrabber/v4l2/vpV4l2Grabber.cpp @@ -60,6 +60,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif const unsigned int vpV4l2Grabber::DEFAULT_INPUT = 2; const unsigned int vpV4l2Grabber::DEFAULT_SCALE = 2; const __u32 vpV4l2Grabber::MAX_INPUTS = 16; @@ -1465,7 +1469,9 @@ vpV4l2Grabber &vpV4l2Grabber::operator>>(vpImage &I) this->acquire(I); return *this; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vpV4l2Grabber.cpp.o) has no symbols void dummy_vpV4l2Grabber() { }; diff --git a/modules/sensor/src/laserscanner/sick/vpSickLDMRS.cpp b/modules/sensor/src/laserscanner/sick/vpSickLDMRS.cpp index bd983c069a..b187073e62 100644 --- a/modules/sensor/src/laserscanner/sick/vpSickLDMRS.cpp +++ b/modules/sensor/src/laserscanner/sick/vpSickLDMRS.cpp @@ -33,6 +33,13 @@ * *****************************************************************************/ +/*! + + \file vpSickLDMRS.cpp + + \brief Driver for the Sick LD-MRS laser scanner. +*/ + #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) #include @@ -52,13 +59,10 @@ #include #include -/*! - - \file vpSickLDMRS.cpp - - \brief Driver for the Sick LD-MRS laser scanner. -*/ - +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor that initialize the Ethernet address to @@ -139,9 +143,11 @@ bool vpSickLDMRS::setup() if (res < 0 && errno != EINTR) { fprintf(stderr, "Error connecting to server %d - %s\n", errno, strerror(errno)); return false; - } else if (res > 0) { + } + else if (res > 0) { fprintf(stderr, "ok"); - } else { + } + else { fprintf(stderr, "Timeout in select() - Cancelling!\n"); return false; } @@ -275,5 +281,7 @@ bool vpSickLDMRS::measure(vpLaserScan laserscan[4]) } return true; } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #endif diff --git a/modules/sensor/src/mocap/vpMocapQualisys.cpp b/modules/sensor/src/mocap/vpMocapQualisys.cpp index 6b88f638e8..5e288f0dbc 100644 --- a/modules/sensor/src/mocap/vpMocapQualisys.cpp +++ b/modules/sensor/src/mocap/vpMocapQualisys.cpp @@ -46,15 +46,18 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpMocapQualisys::vpMocapQualisysImpl { public: vpMocapQualisysImpl() : m_rtProtocol(), m_basePort(22222), m_udpPort(6734), m_majorVersion(1), m_minorVersion(19), m_bigEndian(false), - m_dataAvailable(false), m_streamFrames(false), m_verbose(false), m_serverAddr() - { - } + m_dataAvailable(false), m_streamFrames(false), m_verbose(false), m_serverAddr() + { } virtual ~vpMocapQualisysImpl() { close(); } @@ -75,7 +78,8 @@ class vpMocapQualisys::vpMocapQualisysImpl vpTime::sleepMs(1000); } - } else { + } + else { if (m_verbose) { std::cout << "Qualisys connected" << std::endl; } @@ -101,7 +105,8 @@ class vpMocapQualisys::vpMocapQualisysImpl vpTime::sleepMs(1000); } - } else { + } + else { if (m_verbose && !readSettingsOK) { std::cout << "Reading 6DOF settings succeded." << std::endl; } @@ -114,7 +119,8 @@ class vpMocapQualisys::vpMocapQualisysImpl std::cout << "Reading 6DOF settings timeout: " << std::endl; } return false; - } else { + } + else { for (auto i = 0; i < 6; i++) { if (!m_streamFrames) { if (!m_rtProtocol.StreamFrames(CRTProtocol::RateAllFrames, 0, m_udpPort, nullptr, CRTProtocol::cComponent6d)) { @@ -125,7 +131,8 @@ class vpMocapQualisys::vpMocapQualisysImpl vpTime::sleepMs(1000); } m_streamFrames = true; - } else { + } + else { if (m_verbose) { std::cout << "Starting to stream 6DOF data" << std::endl; } @@ -148,7 +155,8 @@ class vpMocapQualisys::vpMocapQualisysImpl const char *pTmpStr = m_rtProtocol.Get6DOFBodyName(iBody); if (pTmpStr) { name = std::string(pTmpStr); - } else { + } + else { if (m_verbose) { std::cout << "Unknown body" << std::endl; } @@ -167,7 +175,8 @@ class vpMocapQualisys::vpMocapQualisysImpl } return true; - } else { + } + else { return false; } } @@ -190,7 +199,8 @@ class vpMocapQualisys::vpMocapQualisysImpl } if (all_bodies) { bodies_pose[bodyName] = bodyPose; - } else if (bodyPose.isValid()) { + } + else if (bodyPose.isValid()) { bodies_pose[bodyName] = bodyPose; } } @@ -210,13 +220,15 @@ class vpMocapQualisys::vpMocapQualisysImpl std::cout << "I found bodyName" << body_name << std::endl; } return true; - } else { + } + else { std::cout << "The body " << body_name << " was not found in Qualisys. Please check the name you typed." - << std::endl; + << std::endl; return false; } - } else { + } + else { std::cout << "Error : could not process data from Qualisys" << std::endl; return false; @@ -248,7 +260,7 @@ class vpMocapQualisys::vpMocapQualisysImpl /*! * Default constructor. */ -vpMocapQualisys::vpMocapQualisys() : m_impl(new vpMocapQualisysImpl()) {} +vpMocapQualisys::vpMocapQualisys() : m_impl(new vpMocapQualisysImpl()) { } /*! * Destructor. @@ -302,9 +314,11 @@ void vpMocapQualisys::setServerAddress(const std::string &serverAddr) { m_impl-> * \param[in] verbose : When true enable verbose mode, otherwise disable verbose mode. */ void vpMocapQualisys::setVerbose(bool verbose) { m_impl->setVerbose(verbose); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning: // libvisp_sensor.a(vpMocapQualisys.cpp.o) has no symbols -void dummy_vpMocapQualisys(){}; +void dummy_vpMocapQualisys() { }; #endif diff --git a/modules/sensor/src/mocap/vpMocapVicon.cpp b/modules/sensor/src/mocap/vpMocapVicon.cpp index 480cb612c5..785d42a81e 100644 --- a/modules/sensor/src/mocap/vpMocapVicon.cpp +++ b/modules/sensor/src/mocap/vpMocapVicon.cpp @@ -48,11 +48,15 @@ using namespace ViconDataStreamSDK::CPP; +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif #ifndef DOXYGEN_SHOULD_SKIP_THIS class vpMocapVicon::vpMocapViconImpl { public: - vpMocapViconImpl() : m_DirectClient(), m_verbose(false), m_serverAddr() {} + vpMocapViconImpl() : m_DirectClient(), m_verbose(false), m_serverAddr() { } virtual ~vpMocapViconImpl() { close(); } void close() @@ -126,7 +130,8 @@ class vpMocapVicon::vpMocapViconImpl std::cout << "Error : Could not get pose from body n°" << iBody << std::endl; return false; - } else { + } + else { bodyPose[0][3] = m_DirectClient.GetSegmentGlobalTranslation(bodyName, rootSegment).Translation[0] / 1000.0; bodyPose[1][3] = m_DirectClient.GetSegmentGlobalTranslation(bodyName, rootSegment).Translation[1] / 1000.0; bodyPose[2][3] = m_DirectClient.GetSegmentGlobalTranslation(bodyName, rootSegment).Translation[2] / 1000.0; @@ -142,7 +147,8 @@ class vpMocapVicon::vpMocapViconImpl } if (all_bodies) { bodies_pose[bodyName] = bodyPose; - } else if (bodyPose.isValid()) { + } + else if (bodyPose.isValid()) { bodies_pose[bodyName] = bodyPose; } } @@ -158,13 +164,15 @@ class vpMocapVicon::vpMocapViconImpl if (bodies_pose.find(body_name) != bodies_pose.end()) { body_pose = bodies_pose[body_name]; return true; - } else { + } + else { std::cout << "The body " << body_name << " was not found in Vicon. Please check the name you typed." - << std::endl; + << std::endl; return false; } - } else { + } + else { std::cout << "Error : could not process data from Vicon" << std::endl; return false; @@ -208,7 +216,7 @@ class vpMocapVicon::vpMocapViconImpl /*! * Default constructor that creates a direct client (not a multi-cast client). */ -vpMocapVicon::vpMocapVicon() : m_impl(new vpMocapViconImpl()) {} +vpMocapVicon::vpMocapVicon() : m_impl(new vpMocapViconImpl()) { } /*! * Destructor. @@ -263,9 +271,11 @@ void vpMocapVicon::setServerAddress(const std::string &serverAddr) { m_impl->set * \param[in] verbose : When true enable verbose mode, otherwise disable verbose mode. */ void vpMocapVicon::setVerbose(bool verbose) { m_impl->setVerbose(verbose); } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #else // Work around to avoid warning: // libvisp_sensor.a(vpMocapVicon.cpp.o) has no symbols -void dummy_vpMocapVicon(){}; +void dummy_vpMocapVicon() { }; #endif diff --git a/modules/sensor/src/rgb-depth/kinect/vpKinect.cpp b/modules/sensor/src/rgb-depth/kinect/vpKinect.cpp index b4970068b8..0a4b7c1912 100644 --- a/modules/sensor/src/rgb-depth/kinect/vpKinect.cpp +++ b/modules/sensor/src/rgb-depth/kinect/vpKinect.cpp @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! Default constructor. */ @@ -290,7 +294,9 @@ void vpKinect::warpRGBFrame(const vpImage &Irgb, const vpImage &I } } } - +#ifdef ENABLE_VISP_NAMESPACE +} +#endif #elif !defined(VISP_BUILD_SHARED_LIBS) // Work around to avoid warning: libvisp_sensor.a(vpKinect.cpp.o) has no symbols void dummy_vpKinect() { }; diff --git a/modules/sensor/src/rgb-depth/occipital_structure/vpOccipitalStructure.cpp b/modules/sensor/src/rgb-depth/occipital_structure/vpOccipitalStructure.cpp index 807dc70318..af1d8aa6b9 100644 --- a/modules/sensor/src/rgb-depth/occipital_structure/vpOccipitalStructure.cpp +++ b/modules/sensor/src/rgb-depth/occipital_structure/vpOccipitalStructure.cpp @@ -52,6 +52,10 @@ #define MANUAL_POINTCLOUD 1 +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif /*! * Default constructor. */ @@ -1216,5 +1220,7 @@ void vpOccipitalStructure::getColoredPointcloud(pcl::PointCloud #endif +#ifdef ENABLE_VISP_NAMESPACE +namespace VISP_NAMESPACE_NAME +{ +#endif template void vp_rs_get_frame_data_impl(const rs::device *m_device, const std::map &m_intrinsics, const rs::stream &stream, vpImage &data) @@ -443,4 +447,7 @@ void vp_rs_get_pointcloud_impl(const rs::device *m_device, const std::map] [--port ]" - << " [--no-display] [-d] [--help] [-h]\n" - << std::endl; + << " [--ip ] [--port ]" + << " [--no-display] [-d] [--help] [-h]\n" + << std::endl; return EXIT_SUCCESS; } } @@ -117,7 +120,8 @@ int main(int argc, char **argv) vpDisplay::displayText(plotter->I, 20, 80, "Left click to quit", vpColor::red); if (bias) { vpDisplay::displayText(plotter->I, 40, 80, "Right click to unbias", vpColor::red); - } else { + } + else { vpDisplay::displayText(plotter->I, 40, 80, "Right click to bias", vpColor::red); } vpMouseButton::vpMouseButtonType button; @@ -125,19 +129,22 @@ int main(int argc, char **argv) if (vpDisplay::getClick(plotter->I, button, false)) { if (button == vpMouseButton::button1) { end = true; - } else if (button == vpMouseButton::button3) { + } + else if (button == vpMouseButton::button3) { bias = !bias; if (bias) { std::cout << "Bias F/T sensor" << std::endl; ati_net_ft.bias(); - } else { + } + else { std::cout << "Unbias F/T sensor" << std::endl; ati_net_ft.unbias(); } } } vpDisplay::flush(plotter->I); - } else { + } + else { std::cout << "F/T: " << ft.t() << std::endl; if (nbacq > 30) { end = true; diff --git a/modules/sensor/test/force-torque/testForceTorqueIitSensor.cpp b/modules/sensor/test/force-torque/testForceTorqueIitSensor.cpp index ce6eea2e85..85960bf797 100644 --- a/modules/sensor/test/force-torque/testForceTorqueIitSensor.cpp +++ b/modules/sensor/test/force-torque/testForceTorqueIitSensor.cpp @@ -46,6 +46,9 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #ifdef VISP_HAVE_FT_IIT_SDK bool opt_no_display = false; bool opt_filtered = false; @@ -113,7 +116,8 @@ int main(int argc, char **argv) } } vpDisplay::flush(plotter->I); - } else { + } + else { std::cout << "F/T: " << ft.t() << std::endl; if (nbacq > 30) { end = true; diff --git a/modules/sensor/test/framegrabber/test1394TwoGrabber.cpp b/modules/sensor/test/framegrabber/test1394TwoGrabber.cpp index fa6b308793..305cfb4bb3 100644 --- a/modules/sensor/test/framegrabber/test1394TwoGrabber.cpp +++ b/modules/sensor/test/framegrabber/test1394TwoGrabber.cpp @@ -59,6 +59,9 @@ */ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "IEEE1394 test in progress..." << std::endl; @@ -112,7 +115,8 @@ int main() filename = outputpath + "/imagetest2.pgm"; std::cout << "Write image: " << filename << std::endl; vpImageIo::write(I, filename); - } catch (...) { + } + catch (...) { vpCERROR << "Failure: exit" << std::endl; } } @@ -121,7 +125,7 @@ int main() { vpTRACE("Ieee 1394 grabber capabilities are not available...\n" "You should install libdc1394-2 to use this binary."); -} + } #endif diff --git a/modules/sensor/test/framegrabber/test1394TwoResetBus.cpp b/modules/sensor/test/framegrabber/test1394TwoResetBus.cpp index 59924dcbf7..39ce19f116 100644 --- a/modules/sensor/test/framegrabber/test1394TwoResetBus.cpp +++ b/modules/sensor/test/framegrabber/test1394TwoResetBus.cpp @@ -65,6 +65,9 @@ */ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "IEEE1394 bus reset in progress..." << std::endl; vp1394TwoGrabber g; @@ -75,7 +78,8 @@ int main() g.acquire(I); // std::cout << "write /tmp/test.pgm" << std::endl; // vpImageIo::write(I, "/tmp/test.pgm"); - } catch (...) { + } + catch (...) { vpCERROR << "Failure: exit" << std::endl; } } @@ -84,7 +88,7 @@ int main() { vpTRACE("Ieee 1394 grabber capabilities are not available...\n" "You should install libdc1394-2 to use this binary."); -} + } #endif diff --git a/modules/sensor/test/framegrabber/testPylonGrabber.cpp b/modules/sensor/test/framegrabber/testPylonGrabber.cpp index d47bac33d6..1d2049346c 100644 --- a/modules/sensor/test/framegrabber/testPylonGrabber.cpp +++ b/modules/sensor/test/framegrabber/testPylonGrabber.cpp @@ -58,6 +58,9 @@ */ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::cout << "Basler camera test with Pylon in progress..." << std::endl; @@ -121,11 +124,14 @@ int main() filename = outputpath + "/imagetest2.pgm"; std::cout << "Write image: " << filename << std::endl; vpImageIo::write(I, filename); - } catch (const vpException &e) { + } + catch (const vpException &e) { vpCERROR << e.what() << std::endl; - } catch (const std::exception &e) { + } + catch (const std::exception &e) { vpCERROR << e.what() << std::endl; - } catch (...) { + } + catch (...) { vpCERROR << "Failure: exit" << std::endl; } } diff --git a/modules/sensor/test/mocap/testMocapQualisys.cpp b/modules/sensor/test/mocap/testMocapQualisys.cpp index 4df6172314..599e879735 100644 --- a/modules/sensor/test/mocap/testMocapQualisys.cpp +++ b/modules/sensor/test/mocap/testMocapQualisys.cpp @@ -49,6 +49,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool g_quit = false; /*! diff --git a/modules/sensor/test/mocap/testMocapVicon.cpp b/modules/sensor/test/mocap/testMocapVicon.cpp index 0c8c3a8830..614e270424 100644 --- a/modules/sensor/test/mocap/testMocapVicon.cpp +++ b/modules/sensor/test/mocap/testMocapVicon.cpp @@ -51,6 +51,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool g_quit = false; /*! diff --git a/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_images.cpp b/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_images.cpp index 5cb41fd510..7a9d40b793 100644 --- a/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_images.cpp +++ b/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_images.cpp @@ -53,6 +53,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { double t; unsigned int display_scale = 1; diff --git a/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_imu.cpp b/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_imu.cpp index 57f4f386b1..cd7eb66bfa 100644 --- a/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_imu.cpp +++ b/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_imu.cpp @@ -50,6 +50,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { double initial_ts, ts; vpOccipitalStructure sc; diff --git a/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_pcl.cpp b/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_pcl.cpp index f8cfad120e..2bd8ff8efc 100644 --- a/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_pcl.cpp +++ b/modules/sensor/test/rgb-depth/testOccipitalStructure_Core_pcl.cpp @@ -55,6 +55,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { unsigned int display_scale = 1; vpOccipitalStructure sc; diff --git a/modules/sensor/test/rgb-depth/testRealSense2_D435.cpp b/modules/sensor/test/rgb-depth/testRealSense2_D435.cpp index a6e6ef61f8..cbd0b7848c 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_D435.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_D435.cpp @@ -52,6 +52,9 @@ int main(int argc, char *argv[]) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif bool show_info = false; for (int i = 1; i < argc; i++) { diff --git a/modules/sensor/test/rgb-depth/testRealSense2_D435_align.cpp b/modules/sensor/test/rgb-depth/testRealSense2_D435_align.cpp index 866839352a..9c85d173b4 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_D435_align.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_D435_align.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void createDepthHist(std::vector &histogram2, const pcl::PointCloud::Ptr &pointcloud, diff --git a/modules/sensor/test/rgb-depth/testRealSense2_D435_opencv.cpp b/modules/sensor/test/rgb-depth/testRealSense2_D435_opencv.cpp index 40c5f3e4d4..ee66c39441 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_D435_opencv.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_D435_opencv.cpp @@ -155,6 +155,9 @@ void frame_to_mat(const rs2::frame &f, cv::Mat &img) int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif const int width = 640, height = 480, fps = 60; vpRealSense2 rs; rs2::config config; diff --git a/modules/sensor/test/rgb-depth/testRealSense2_D435_pcl.cpp b/modules/sensor/test/rgb-depth/testRealSense2_D435_pcl.cpp index 85a54d5fbf..f934a202ac 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_D435_pcl.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_D435_pcl.cpp @@ -54,6 +54,9 @@ int main(int argc, char *argv[]) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif bool opt_pcl_color = false; bool opt_show_infrared2 = false; bool display_helper = false; diff --git a/modules/sensor/test/rgb-depth/testRealSense2_SR300.cpp b/modules/sensor/test/rgb-depth/testRealSense2_SR300.cpp index 961b7c9d2e..73911e5884 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_SR300.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_SR300.cpp @@ -62,6 +62,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_VISUALIZATION) diff --git a/modules/sensor/test/rgb-depth/testRealSense2_T265_images.cpp b/modules/sensor/test/rgb-depth/testRealSense2_T265_images.cpp index a72de4d844..35f90ba403 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_T265_images.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_T265_images.cpp @@ -51,6 +51,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { double ts; unsigned int display_scale = 2; diff --git a/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry.cpp b/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry.cpp index ab7ec4d130..91f62efa5f 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry.cpp @@ -54,6 +54,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpHomogeneousMatrix cMw, cMw_0; vpHomogeneousMatrix cextMw(0, 0, 2, 0, 0, 0); // External camera view for pose visualization vpColVector odo_vel, odo_acc, imu_acc, imu_vel; diff --git a/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry_async.cpp b/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry_async.cpp index 77a54db24f..19cad8c1ef 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry_async.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_T265_images_odometry_async.cpp @@ -55,6 +55,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpHomogeneousMatrix cMw, cMw_0; vpHomogeneousMatrix cextMw(0, 0, 2, 0, 0, 0); // External camera view for pose visualization. vpColVector odo_vel, odo_acc, imu_acc, imu_vel; diff --git a/modules/sensor/test/rgb-depth/testRealSense2_T265_imu.cpp b/modules/sensor/test/rgb-depth/testRealSense2_T265_imu.cpp index a16868d488..104b458484 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_T265_imu.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_T265_imu.cpp @@ -51,6 +51,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpColVector imu_acc, imu_vel; try { diff --git a/modules/sensor/test/rgb-depth/testRealSense2_T265_odometry.cpp b/modules/sensor/test/rgb-depth/testRealSense2_T265_odometry.cpp index ec2ad878ba..4f71c7bcfe 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_T265_odometry.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_T265_odometry.cpp @@ -51,6 +51,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpHomogeneousMatrix cMw, cMw_0; vpHomogeneousMatrix cextMw(0, 0, 2, 0, 0, 0); // External camera view for pose visualization unsigned int confidence; diff --git a/modules/sensor/test/rgb-depth/testRealSense2_T265_undistort.cpp b/modules/sensor/test/rgb-depth/testRealSense2_T265_undistort.cpp index 27210cc8e0..1a47dcd07d 100644 --- a/modules/sensor/test/rgb-depth/testRealSense2_T265_undistort.cpp +++ b/modules/sensor/test/rgb-depth/testRealSense2_T265_undistort.cpp @@ -53,6 +53,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { vpCameraParameters cam_left; unsigned int display_scale = 2; From 13186d628c8e6653c1f8b005252c52c476e04de9 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 15:03:32 +0200 Subject: [PATCH 21/64] [TEST][FIX] Fixed some missing using namespace in the tests --- modules/core/include/visp3/core/vpMatrix.h | 2 +- .../image-with-dataset/testGaussianFilter.cpp | 12 +-- .../core/test/math/testEigenConversion.cpp | 74 +++++++++---------- .../include/visp3/imgproc/vpContours.h | 8 +- .../test/with-dataset/testAutoThreshold.cpp | 12 +-- .../with-dataset/testConnectedComponents.cpp | 4 +- .../test/with-dataset/testContours.cpp | 34 ++++----- .../test/with-dataset/testFloodFill.cpp | 12 +-- .../imgproc/test/with-dataset/testImgproc.cpp | 28 +++---- modules/io/test/testJsonArgumentParser.cpp | 24 +++--- .../test/framegrabber/testPylonGrabber.cpp | 3 + .../tracking-with-dataset/testTrackDot.cpp | 25 ++++--- .../perfGenericTracker.cpp | 4 + .../testGenericTracker.cpp | 8 +- .../testGenericTrackerCAOParsing.cpp | 6 +- .../testGenericTrackerDepth.cpp | 4 + .../testGenericTrackerDeterminist.cpp | 4 + .../testMbtJsonSettings.cpp | 6 +- .../testMbtXmlGenericParser.cpp | 7 +- .../tracker/mbt/test/testTukeyEstimator.cpp | 15 ++-- 20 files changed, 169 insertions(+), 123 deletions(-) diff --git a/modules/core/include/visp3/core/vpMatrix.h b/modules/core/include/visp3/core/vpMatrix.h index 9e70dd87d0..e46930374c 100644 --- a/modules/core/include/visp3/core/vpMatrix.h +++ b/modules/core/include/visp3/core/vpMatrix.h @@ -41,6 +41,7 @@ #ifndef _vpMatrix_H_ #define _vpMatrix_H_ +#include #if defined(ENABLE_VISP_NAMESPACE) namespace VISP_NAMESPACE_NAME { @@ -57,7 +58,6 @@ class vpForceTwistMatrix; #endif #include -#include #include #include #include diff --git a/modules/core/test/image-with-dataset/testGaussianFilter.cpp b/modules/core/test/image-with-dataset/testGaussianFilter.cpp index 0b014ac38b..8051517ad0 100644 --- a/modules/core/test/image-with-dataset/testGaussianFilter.cpp +++ b/modules/core/test/image-with-dataset/testGaussianFilter.cpp @@ -33,18 +33,14 @@ * *****************************************************************************/ -#include - -#ifdef ENABLE_VISP_NAMESPACE -using namespace VISP_NAMESPACE_NAME; -#endif - /*! \example testGaussianFilter.cpp \brief Test Gaussian filter. */ +#include + #if defined(VISP_HAVE_SIMDLIB) && defined(VISP_HAVE_CATCH2) && (VISP_HAVE_DATASET_VERSION >= 0x030400) #define CATCH_CONFIG_RUNNER #include @@ -53,6 +49,10 @@ using namespace VISP_NAMESPACE_NAME; #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + TEST_CASE("Test vpGaussianFilter (unsigned char)") { const std::string filepath = vpIoTools::createFilePath(vpIoTools::getViSPImagesDataPath(), "Klimt/Klimt.pgm"); diff --git a/modules/core/test/math/testEigenConversion.cpp b/modules/core/test/math/testEigenConversion.cpp index 3400c627a1..88a9204165 100644 --- a/modules/core/test/math/testEigenConversion.cpp +++ b/modules/core/test/math/testEigenConversion.cpp @@ -74,11 +74,11 @@ TEST_CASE("vpMatrix <--> Eigen::MatrixXd/Matrix3Xd conversion", "[eigen_conversi { Eigen::MatrixXd eigen_m; - vp::visp2eigen(visp_m, eigen_m); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m); std::cout << "Eigen MatrixXd:\n" << eigen_m << std::endl; vpMatrix visp_m2; - vp::eigen2visp(eigen_m, visp_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m2); std::cout << "ViSP vpMatrix:\n" << visp_m2 << std::endl; REQUIRE(visp_m == visp_m2); @@ -86,11 +86,11 @@ TEST_CASE("vpMatrix <--> Eigen::MatrixXd/Matrix3Xd conversion", "[eigen_conversi } { Eigen::Matrix3Xd eigen_m; - vp::visp2eigen(visp_m, eigen_m); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m); std::cout << "Eigen Matrix3Xd:\n" << eigen_m << std::endl; vpMatrix visp_m2; - vp::eigen2visp(eigen_m, visp_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m2); std::cout << "ViSP vpMatrix:\n" << visp_m2 << std::endl; REQUIRE(visp_m == visp_m2); @@ -114,18 +114,18 @@ TEST_CASE("Eigen::MatrixXd <--> vpMatrix conversion", "[eigen_conversion]") std::cout << "Eigen Matrix (row major: " << eigen_m.IsRowMajor << "):\n" << eigen_m << std::endl; vpMatrix visp_m; - vp::eigen2visp(eigen_m, visp_m); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m); std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl; Eigen::MatrixXd eigen_m2; - vp::visp2eigen(visp_m, eigen_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2); std::cout << "Eigen MatrixXd (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl; vpMatrix visp_m2; - vp::eigen2visp(eigen_m2, visp_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; - } +} TEST_CASE("Eigen::MatrixX4d <--> vpMatrix conversion", "[eigen_conversion]") { @@ -143,18 +143,18 @@ TEST_CASE("Eigen::MatrixX4d <--> vpMatrix conversion", "[eigen_conversion]") std::cout << "Eigen MatrixX4d (row major: " << eigen_m.IsRowMajor << "):\n" << eigen_m << std::endl; vpMatrix visp_m; - vp::eigen2visp(eigen_m, visp_m); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m); std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl; Eigen::MatrixX4d eigen_m2; - vp::visp2eigen(visp_m, eigen_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2); std::cout << "Eigen MatrixX4d (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl; vpMatrix visp_m2; - vp::eigen2visp(eigen_m2, visp_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; - } +} TEST_CASE("Eigen::Matrix <--> vpMatrix conversion", "[eigen_conversion]") { @@ -172,18 +172,18 @@ TEST_CASE("Eigen::Matrix <--> vpMatrix conve std::cout << "Eigen Matrix (RowMajor):\n" << eigen_m << std::endl; vpMatrix visp_m; - vp::eigen2visp(eigen_m, visp_m); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m); std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl; Eigen::MatrixXd eigen_m2; - vp::visp2eigen(visp_m, eigen_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2); std::cout << "Eigen MatrixXd (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl; vpMatrix visp_m2; - vp::eigen2visp(eigen_m2, visp_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; - } +} TEST_CASE("Eigen::Matrix <--> vpMatrix conversion", "[eigen_conversion]") { @@ -201,28 +201,28 @@ TEST_CASE("Eigen::Matrix <--> vpMatrix conve std::cout << "Eigen Matrix (ColMajor):\n" << eigen_m << std::endl; vpMatrix visp_m; - vp::eigen2visp(eigen_m, visp_m); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m); std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl; Eigen::MatrixXd eigen_m2; - vp::visp2eigen(visp_m, eigen_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2); std::cout << "Eigen MatrixXd (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl; vpMatrix visp_m2; - vp::eigen2visp(eigen_m2, visp_m2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2); REQUIRE(visp_m == visp_m2); std::cout << std::endl; - } +} TEST_CASE("vpHomogeneousMatrix <--> Eigen::Matrix4d conversion", "[eigen_conversion]") { vpHomogeneousMatrix visp_cMo(0.1, 0.2, 0.3, 0.1, 0.2, 0.3); Eigen::Matrix4d eigen_cMo; - vp::visp2eigen(visp_cMo, eigen_cMo); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_cMo, eigen_cMo); std::cout << "Eigen Matrix4d cMo:\n" << eigen_cMo << std::endl; vpHomogeneousMatrix visp_cMo2; - vp::eigen2visp(eigen_cMo, visp_cMo2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_cMo, visp_cMo2); std::cout << "ViSP vpHomogeneousMatrix cMo:\n" << visp_cMo2 << std::endl; REQUIRE(visp_cMo == visp_cMo2); std::cout << std::endl; @@ -232,12 +232,12 @@ TEST_CASE("vpHomogeneousMatrix <--> Eigen::Matrix4f + double casting conversion" { vpHomogeneousMatrix visp_cMo; // identity for float to double casting Eigen::Matrix4d eigen_cMo_tmp; - vp::visp2eigen(visp_cMo, eigen_cMo_tmp); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_cMo, eigen_cMo_tmp); Eigen::Matrix4f eigen_cMo = eigen_cMo_tmp.cast(); std::cout << "Eigen Matrix4f cMo:\n" << eigen_cMo << std::endl; vpHomogeneousMatrix visp_cMo2; - vp::eigen2visp(eigen_cMo.cast(), visp_cMo2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_cMo.cast(), visp_cMo2); std::cout << "ViSP vpHomogeneousMatrix cMo:\n" << visp_cMo2 << std::endl; REQUIRE(visp_cMo == visp_cMo2); std::cout << std::endl; @@ -247,11 +247,11 @@ TEST_CASE("vpQuaternionVector <--> Eigen::Quaternionf conversion", "[eigen_conve { vpQuaternionVector visp_quaternion(0, 1, 2, 3); Eigen::Quaternionf eigen_quaternion; - vp::visp2eigen(visp_quaternion, eigen_quaternion); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_quaternion, eigen_quaternion); std::cout << "Eigen quaternion: " << eigen_quaternion << std::endl; vpQuaternionVector visp_quaternion2; - vp::eigen2visp(eigen_quaternion, visp_quaternion2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_quaternion, visp_quaternion2); std::cout << "ViSP quaternion: " << visp_quaternion2.t() << std::endl; REQUIRE(visp_quaternion == visp_quaternion2); std::cout << std::endl; @@ -261,11 +261,11 @@ TEST_CASE("vpThetaUVector <--> Eigen::AngleAxisf conversion", "[eigen_conversion { vpThetaUVector visp_thetau(0, 1, 2); Eigen::AngleAxisf eigen_angle_axis; - vp::visp2eigen(visp_thetau, eigen_angle_axis); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_thetau, eigen_angle_axis); std::cout << "Eigen AngleAxis: " << eigen_angle_axis << std::endl; vpThetaUVector visp_thetau2; - vp::eigen2visp(eigen_angle_axis, visp_thetau2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_angle_axis, visp_thetau2); std::cout << "ViSP AngleAxis: " << visp_thetau2.t() << std::endl; REQUIRE(visp_thetau == visp_thetau2); std::cout << std::endl; @@ -276,11 +276,11 @@ TEST_CASE("vpColVector <--> Eigen::VectorXd conversion", "[eigen_conversion]") vpColVector visp_col(4, 4); visp_col = 10; Eigen::VectorXd eigen_col; - vp::visp2eigen(visp_col, eigen_col); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_col, eigen_col); std::cout << "Eigen VectorXd: " << eigen_col.transpose() << std::endl; vpColVector visp_col2; - vp::eigen2visp(eigen_col, visp_col2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_col, visp_col2); std::cout << "ViSP vpColVector: " << visp_col2.t() << std::endl; REQUIRE(visp_col == visp_col2); std::cout << std::endl; @@ -291,11 +291,11 @@ TEST_CASE("vpRowVector <--> Eigen::RowVectorXd conversion", "[eigen_conversion]" vpRowVector visp_row(4, 10); visp_row = 10; Eigen::RowVectorXd eigen_row; - vp::visp2eigen(visp_row, eigen_row); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_row, eigen_row); std::cout << "Eigen RowVectorXd: " << eigen_row << std::endl; vpRowVector visp_row2; - vp::eigen2visp(eigen_row, visp_row2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row, visp_row2); std::cout << "ViSP vpRowVector: " << visp_row2 << std::endl; REQUIRE(visp_row == visp_row2); std::cout << std::endl; @@ -306,15 +306,15 @@ TEST_CASE("Eigen::RowVector4d <--> vpRowVector conversion", "[eigen_conversion]" Eigen::RowVector4d eigen_row; eigen_row << 9, 8, 7, 6; vpRowVector visp_row; - vp::eigen2visp(eigen_row, visp_row); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row, visp_row); std::cout << "ViSP vpRowVector: " << visp_row << std::endl; Eigen::RowVector4d eigen_row2; - vp::visp2eigen(visp_row, eigen_row2); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_row, eigen_row2); std::cout << "Eigen RowVector4d: " << eigen_row2 << std::endl; vpRowVector visp_row2; - vp::eigen2visp(eigen_row2, visp_row2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row2, visp_row2); REQUIRE(visp_row == visp_row2); std::cout << std::endl; } @@ -324,11 +324,11 @@ TEST_CASE("vpRowVector <--> Eigen::RowVector4d conversion", "[eigen_conversion]" vpRowVector visp_row(4, 10); visp_row = 10; Eigen::RowVector4d eigen_row; - vp::visp2eigen(visp_row, eigen_row); + VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_row, eigen_row); std::cout << "Eigen RowVector4d: " << eigen_row << std::endl; vpRowVector visp_row2; - vp::eigen2visp(eigen_row, visp_row2); + VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row, visp_row2); std::cout << "ViSP vpRowVector: " << visp_row2 << std::endl; REQUIRE(visp_row == visp_row2); std::cout << std::endl; diff --git a/modules/imgproc/include/visp3/imgproc/vpContours.h b/modules/imgproc/include/visp3/imgproc/vpContours.h index 7252feb2fd..adb76b0f94 100644 --- a/modules/imgproc/include/visp3/imgproc/vpContours.h +++ b/modules/imgproc/include/visp3/imgproc/vpContours.h @@ -74,11 +74,13 @@ #include #include -#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) -namespace vp +#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS +#define VISP_CONTOURS_NAMESPACE vp #else -namespace VISP_NAMESPACE_NAME +#define VISP_CONTOURS_NAMESPACE VISP_NAMESPACE_NAME #endif + +namespace VISP_CONTOURS_NAMESPACE { /*! diff --git a/modules/imgproc/test/with-dataset/testAutoThreshold.cpp b/modules/imgproc/test/with-dataset/testAutoThreshold.cpp index 79e9ae70f9..c4b0cad733 100644 --- a/modules/imgproc/test/with-dataset/testAutoThreshold.cpp +++ b/modules/imgproc/test/with-dataset/testAutoThreshold.cpp @@ -252,7 +252,7 @@ int main(int argc, const char **argv) // Huang double t = vpTime::measureTimeMs(); - double threshold = vp::autoThreshold(I_thresh, vp::AUTO_THRESHOLD_HUANG); + double threshold = VISP_IMGPROC_NAMESPACE::autoThreshold(I_thresh, VISP_IMGPROC_NAMESPACE::AUTO_THRESHOLD_HUANG); t = vpTime::measureTimeMs() - t; std::cout << "\nAutomatic thresholding (Huang): " << threshold << " ; t=" << t << " ms" << std::endl; @@ -263,7 +263,7 @@ int main(int argc, const char **argv) // Intermodes I_thresh = I; t = vpTime::measureTimeMs(); - threshold = vp::autoThreshold(I_thresh, vp::AUTO_THRESHOLD_INTERMODES); + threshold = VISP_IMGPROC_NAMESPACE::autoThreshold(I_thresh, VISP_IMGPROC_NAMESPACE::AUTO_THRESHOLD_INTERMODES); t = vpTime::measureTimeMs() - t; std::cout << "\nAutomatic thresholding (Intermodes): " << threshold << " ; t=" << t << " ms" << std::endl; @@ -274,7 +274,7 @@ int main(int argc, const char **argv) // IsoData I_thresh = I; t = vpTime::measureTimeMs(); - threshold = vp::autoThreshold(I_thresh, vp::AUTO_THRESHOLD_ISODATA); + threshold = VISP_IMGPROC_NAMESPACE::autoThreshold(I_thresh, VISP_IMGPROC_NAMESPACE::AUTO_THRESHOLD_ISODATA); t = vpTime::measureTimeMs() - t; std::cout << "\nAutomatic thresholding (IsoData): " << threshold << " ; t=" << t << " ms" << std::endl; @@ -285,7 +285,7 @@ int main(int argc, const char **argv) // Mean I_thresh = I; t = vpTime::measureTimeMs(); - threshold = vp::autoThreshold(I_thresh, vp::AUTO_THRESHOLD_MEAN); + threshold = VISP_IMGPROC_NAMESPACE::autoThreshold(I_thresh, VISP_IMGPROC_NAMESPACE::AUTO_THRESHOLD_MEAN); t = vpTime::measureTimeMs() - t; std::cout << "\nAutomatic thresholding (Mean): " << threshold << " ; t=" << t << " ms" << std::endl; @@ -296,7 +296,7 @@ int main(int argc, const char **argv) // Otsu I_thresh = I; t = vpTime::measureTimeMs(); - threshold = vp::autoThreshold(I_thresh, vp::AUTO_THRESHOLD_OTSU); + threshold = VISP_IMGPROC_NAMESPACE::autoThreshold(I_thresh, VISP_IMGPROC_NAMESPACE::AUTO_THRESHOLD_OTSU); t = vpTime::measureTimeMs() - t; std::cout << "\nAutomatic thresholding (Otsu): " << threshold << " ; t=" << t << " ms" << std::endl; @@ -307,7 +307,7 @@ int main(int argc, const char **argv) // Triangle I_thresh = I; t = vpTime::measureTimeMs(); - threshold = vp::autoThreshold(I_thresh, vp::AUTO_THRESHOLD_TRIANGLE); + threshold = VISP_IMGPROC_NAMESPACE::autoThreshold(I_thresh, VISP_IMGPROC_NAMESPACE::AUTO_THRESHOLD_TRIANGLE); t = vpTime::measureTimeMs() - t; std::cout << "\nAutomatic thresholding (Triangle): " << threshold << " ; t=" << t << " ms" << std::endl; diff --git a/modules/imgproc/test/with-dataset/testConnectedComponents.cpp b/modules/imgproc/test/with-dataset/testConnectedComponents.cpp index 8b8b8fe2dd..6c06ac98ea 100644 --- a/modules/imgproc/test/with-dataset/testConnectedComponents.cpp +++ b/modules/imgproc/test/with-dataset/testConnectedComponents.cpp @@ -295,7 +295,7 @@ int main(int argc, const char **argv) vpImage labels_connex4; int nbComponents = 0; double t = vpTime::measureTimeMs(); - vp::connectedComponents(I, labels_connex4, nbComponents, vpImageMorphology::CONNEXITY_4); + VISP_IMGPROC_NAMESPACE::connectedComponents(I, labels_connex4, nbComponents, vpImageMorphology::CONNEXITY_4); t = vpTime::measureTimeMs() - t; std::cout << "\n4-connexity connected components:" << std::endl; std::cout << "Time: " << t << " ms" << std::endl; @@ -303,7 +303,7 @@ int main(int argc, const char **argv) vpImage labels_connex8; t = vpTime::measureTimeMs(); - vp::connectedComponents(I, labels_connex8, nbComponents, vpImageMorphology::CONNEXITY_8); + VISP_IMGPROC_NAMESPACE::connectedComponents(I, labels_connex8, nbComponents, vpImageMorphology::CONNEXITY_8); t = vpTime::measureTimeMs() - t; std::cout << "\n8-connexity connected components:" << std::endl; std::cout << "Time: " << t << " ms" << std::endl; diff --git a/modules/imgproc/test/with-dataset/testContours.cpp b/modules/imgproc/test/with-dataset/testContours.cpp index 60f263c317..439135cc8f 100644 --- a/modules/imgproc/test/with-dataset/testContours.cpp +++ b/modules/imgproc/test/with-dataset/testContours.cpp @@ -171,15 +171,15 @@ void printImage(const vpImage &I, const std::string &name) } } -void displayContourInfo(const vp::vpContour &contour, int level) +void displayContourInfo(const VISP_CONTOURS_NAMESPACE::vpContour &contour, int level) { std::cout << "\nContour:" << std::endl; std::cout << "\tlevel: " << level << std::endl; - std::cout << "\tcontour type: " << (contour.m_contourType == vp::CONTOUR_OUTER ? "outer contour" : "hole contour") + std::cout << "\tcontour type: " << (contour.m_contourType == VISP_CONTOURS_NAMESPACE::CONTOUR_OUTER ? "outer contour" : "hole contour") << std::endl; std::cout << "\tnb children: " << contour.m_children.size() << std::endl; - for (std::vector::const_iterator it = contour.m_children.begin(); it != contour.m_children.end(); + for (std::vector::const_iterator it = contour.m_children.begin(); it != contour.m_children.end(); ++it) { displayContourInfo(**it, level + 1); } @@ -279,10 +279,10 @@ int main(int argc, const char **argv) std::cout << "Test with image data:" << std::endl; printImage(I_test_data, "I_test_data"); - vp::vpContour vp_contours; + VISP_CONTOURS_NAMESPACE::vpContour vp_contours; std::vector > contours; double t = vpTime::measureTimeMs(); - vp::findContours(I_test_data, vp_contours, contours); + VISP_CONTOURS_NAMESPACE::findContours(I_test_data, vp_contours, contours); t = vpTime::measureTimeMs() - t; displayContourInfo(vp_contours, 0); @@ -304,7 +304,7 @@ int main(int argc, const char **argv) vpImageIo::write(I2, filename); t = vpTime::measureTimeMs(); - vp::findContours(I, vp_contours, contours); + VISP_CONTOURS_NAMESPACE::findContours(I, vp_contours, contours); t = vpTime::measureTimeMs() - t; displayContourInfo(vp_contours, 0); @@ -313,50 +313,50 @@ int main(int argc, const char **argv) // Draw and save vpImage I_draw_contours(I2.getHeight(), I2.getWidth(), 0); - vp::drawContours(I_draw_contours, contours); + VISP_CONTOURS_NAMESPACE::drawContours(I_draw_contours, contours); filename = vpIoTools::createFilePath(opath, "Klimt_contours_extracted.pgm"); vpImageIo::write(I_draw_contours, filename); vpImage I_draw_contours_color(I2.getHeight(), I2.getWidth(), vpRGBa(0, 0, 0)); - vp::drawContours(I_draw_contours_color, contours, vpColor::red); + VISP_CONTOURS_NAMESPACE::drawContours(I_draw_contours_color, contours, vpColor::red); filename = vpIoTools::createFilePath(opath, "Klimt_contours_extracted_color.ppm"); vpImageIo::write(I_draw_contours_color, filename); // Test retrieve list - vp::findContours(I, vp_contours, contours, vp::CONTOUR_RETR_LIST); + VISP_CONTOURS_NAMESPACE::findContours(I, vp_contours, contours, VISP_CONTOURS_NAMESPACE::CONTOUR_RETR_LIST); vpImage I_draw_contours_list(I2.getHeight(), I2.getWidth(), 0); vpImage I_tmp_list(I.getHeight(), I.getWidth(), 0); - vp::drawContours(I_tmp_list, contours); + VISP_CONTOURS_NAMESPACE::drawContours(I_tmp_list, contours); contours.clear(); - for (std::vector::const_iterator it = vp_contours.m_children.begin(); + for (std::vector::const_iterator it = vp_contours.m_children.begin(); it != vp_contours.m_children.end(); ++it) { contours.push_back((*it)->m_points); } - vp::drawContours(I_draw_contours_list, contours); + VISP_CONTOURS_NAMESPACE::drawContours(I_draw_contours_list, contours); std::cout << "(I_tmp_list == I_draw_contours_list)? " << (I_tmp_list == I_draw_contours_list) << std::endl; filename = vpIoTools::createFilePath(opath, "Klimt_contours_extracted_list.pgm"); vpImageIo::write(I_draw_contours_list, filename); // Test retrieve external - vp::findContours(I, vp_contours, contours, vp::CONTOUR_RETR_EXTERNAL); + VISP_CONTOURS_NAMESPACE::findContours(I, vp_contours, contours, VISP_CONTOURS_NAMESPACE::CONTOUR_RETR_EXTERNAL); vpImage I_draw_contours_external(I2.getHeight(), I2.getWidth(), 0); vpImage I_tmp_external(I.getHeight(), I.getWidth(), 0); - vp::drawContours(I_tmp_external, contours); + VISP_CONTOURS_NAMESPACE::drawContours(I_tmp_external, contours); contours.clear(); - for (std::vector::const_iterator it = vp_contours.m_children.begin(); + for (std::vector::const_iterator it = vp_contours.m_children.begin(); it != vp_contours.m_children.end(); ++it) { contours.push_back((*it)->m_points); } - vp::drawContours(I_draw_contours_external, contours); + VISP_CONTOURS_NAMESPACE::drawContours(I_draw_contours_external, contours); std::cout << "(I_tmp_external == I_draw_contours_external)? " << (I_tmp_external == I_draw_contours_external) << std::endl; @@ -369,7 +369,7 @@ int main(int argc, const char **argv) (unsigned char)255); t = vpTime::measureTimeMs(); - vp::fillHoles(I_holes); + VISP_CONTOURS_NAMESPACE::fillHoles(I_holes); t = vpTime::measureTimeMs() - t; std::cout << "\nFill Holes: " << t << " ms" << std::endl; diff --git a/modules/imgproc/test/with-dataset/testFloodFill.cpp b/modules/imgproc/test/with-dataset/testFloodFill.cpp index ba3a449f5f..3078d69496 100644 --- a/modules/imgproc/test/with-dataset/testFloodFill.cpp +++ b/modules/imgproc/test/with-dataset/testFloodFill.cpp @@ -279,21 +279,21 @@ int main(int argc, const char **argv) vpImage I_check_8_connexity(image_data_check_8_connexity, 8, 8, true); // Test flood fill on test data 4-connexity - vp::floodFill(I_test_flood_fill_4_connexity, vpImagePoint(2, 2), 0, 1, vpImageMorphology::CONNEXITY_4); + VISP_IMGPROC_NAMESPACE::floodFill(I_test_flood_fill_4_connexity, vpImagePoint(2, 2), 0, 1, vpImageMorphology::CONNEXITY_4); printImage(I_test_flood_fill_4_connexity, "I_test_flood_fill_4_connexity"); if (I_test_flood_fill_4_connexity != I_check_4_connexity) { - throw vpException(vpException::fatalError, "Problem with vp::floodFill() and 4-connexity!"); + throw vpException(vpException::fatalError, "Problem with VISP_IMGPROC_NAMESPACE::floodFill() and 4-connexity!"); } std::cout << "\n(I_test_flood_fill_4_connexity == I_check_4_connexity)? " << (I_test_flood_fill_4_connexity == I_check_4_connexity) << std::endl; // Test flood fill on test data 8-connexity - vp::floodFill(I_test_flood_fill_8_connexity, vpImagePoint(2, 2), 0, 1, vpImageMorphology::CONNEXITY_8); + VISP_IMGPROC_NAMESPACE::floodFill(I_test_flood_fill_8_connexity, vpImagePoint(2, 2), 0, 1, vpImageMorphology::CONNEXITY_8); printImage(I_test_flood_fill_8_connexity, "I_test_flood_fill_8_connexity"); if (I_test_flood_fill_8_connexity != I_check_8_connexity) { - throw vpException(vpException::fatalError, "Problem with vp::floodFill() and 8-connexity!"); + throw vpException(vpException::fatalError, "Problem with VISP_IMGPROC_NAMESPACE::floodFill() and 8-connexity!"); } std::cout << "\n(I_test_flood_fill_8_connexity == I_check_8_connexity)? " << (I_test_flood_fill_8_connexity == I_check_8_connexity) << std::endl; @@ -313,7 +313,7 @@ int main(int argc, const char **argv) vpImage I_klimt_flood_fill_4_connexity = I_klimt; double t = vpTime::measureTimeMs(); - vp::floodFill(I_klimt_flood_fill_4_connexity, vpImagePoint(seed_y, seed_x), 0, 255, vpImageMorphology::CONNEXITY_4); + VISP_IMGPROC_NAMESPACE::floodFill(I_klimt_flood_fill_4_connexity, vpImagePoint(seed_y, seed_x), 0, 255, vpImageMorphology::CONNEXITY_4); t = vpTime::measureTimeMs() - t; std::cout << "Flood fill on Klimt image (4-connexity): " << t << " ms" << std::endl; @@ -322,7 +322,7 @@ int main(int argc, const char **argv) vpImage I_klimt_flood_fill_8_connexity = I_klimt; t = vpTime::measureTimeMs(); - vp::floodFill(I_klimt_flood_fill_8_connexity, vpImagePoint(seed_y, seed_x), 0, 255, vpImageMorphology::CONNEXITY_8); + VISP_IMGPROC_NAMESPACE::floodFill(I_klimt_flood_fill_8_connexity, vpImagePoint(seed_y, seed_x), 0, 255, vpImageMorphology::CONNEXITY_8); t = vpTime::measureTimeMs() - t; std::cout << "Flood fill on Klimt image (8-connexity): " << t << " ms" << std::endl; filename = vpIoTools::createFilePath(opath, "Klimt_flood_fill_8_connexity.pgm"); diff --git a/modules/imgproc/test/with-dataset/testImgproc.cpp b/modules/imgproc/test/with-dataset/testImgproc.cpp index 9e94047d9c..8cbf71bcab 100644 --- a/modules/imgproc/test/with-dataset/testImgproc.cpp +++ b/modules/imgproc/test/with-dataset/testImgproc.cpp @@ -256,7 +256,7 @@ int main(int argc, const char **argv) double alpha = 1.5, beta = -10.0; vpImage I_color_adjust; double t = vpTime::measureTimeMs(); - vp::adjust(I_color, I_color_adjust, alpha, beta); + VISP_IMGPROC_NAMESPACE::adjust(I_color, I_color_adjust, alpha, beta); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color adjust: " << t << " ms" << std::endl; @@ -267,7 +267,7 @@ int main(int argc, const char **argv) // Equalize Histogram vpImage I_color_equalize_histogram; t = vpTime::measureTimeMs(); - vp::equalizeHistogram(I_color, I_color_equalize_histogram); + VISP_IMGPROC_NAMESPACE::equalizeHistogram(I_color, I_color_equalize_histogram); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color histogram equalization: " << t << " ms" << std::endl; @@ -279,7 +279,7 @@ int main(int argc, const char **argv) vpImage I_color_gamma_correction; float gamma = 2.2f; t = vpTime::measureTimeMs(); - vp::gammaCorrection(I_color, I_color_gamma_correction, gamma); + VISP_IMGPROC_NAMESPACE::gammaCorrection(I_color, I_color_gamma_correction, gamma); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color gamma correction: " << t << " ms" << std::endl; @@ -290,7 +290,7 @@ int main(int argc, const char **argv) // Retinex vpImage I_color_retinex; t = vpTime::measureTimeMs(); - vp::retinex(I_color, I_color_retinex); + VISP_IMGPROC_NAMESPACE::retinex(I_color, I_color_retinex); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color retinex: " << t << " ms" << std::endl; @@ -301,7 +301,7 @@ int main(int argc, const char **argv) // Stretch contrast vpImage I_color_stretch_contrast; t = vpTime::measureTimeMs(); - vp::stretchContrast(I_color, I_color_stretch_contrast); + VISP_IMGPROC_NAMESPACE::stretchContrast(I_color, I_color_stretch_contrast); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color contrast stretching: " << t << " ms" << std::endl; @@ -312,7 +312,7 @@ int main(int argc, const char **argv) // Stretch Contrast HSV vpImage I_color_stretch_contrast_HSV; t = vpTime::measureTimeMs(); - vp::stretchContrastHSV(I_color, I_color_stretch_contrast_HSV); + VISP_IMGPROC_NAMESPACE::stretchContrastHSV(I_color, I_color_stretch_contrast_HSV); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color HSV contrast stretching: " << t << " ms" << std::endl; @@ -324,7 +324,7 @@ int main(int argc, const char **argv) vpImage I_color_unsharp_mask; const float sigma = 1.0f; t = vpTime::measureTimeMs(); - vp::unsharpMask(I_color, I_color_unsharp_mask, sigma); + VISP_IMGPROC_NAMESPACE::unsharpMask(I_color, I_color_unsharp_mask, sigma); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color unsharp mask: " << t << " ms" << std::endl; @@ -335,7 +335,7 @@ int main(int argc, const char **argv) // CLAHE vpImage I_color_clahe; t = vpTime::measureTimeMs(); - vp::clahe(I_color, I_color_clahe, 50); + VISP_IMGPROC_NAMESPACE::clahe(I_color, I_color_clahe, 50); t = vpTime::measureTimeMs() - t; std::cout << "Time to do color CLAHE: " << t << " ms" << std::endl; @@ -359,7 +359,7 @@ int main(int argc, const char **argv) vpImage I_adjust; beta = -20.0; t = vpTime::measureTimeMs(); - vp::adjust(I, I_adjust, alpha, beta); + VISP_IMGPROC_NAMESPACE::adjust(I, I_adjust, alpha, beta); t = vpTime::measureTimeMs() - t; std::cout << "Time to do grayscale adjust: " << t << " ms" << std::endl; @@ -370,7 +370,7 @@ int main(int argc, const char **argv) // Equalize Histogram vpImage I_equalize_histogram; t = vpTime::measureTimeMs(); - vp::equalizeHistogram(I, I_equalize_histogram); + VISP_IMGPROC_NAMESPACE::equalizeHistogram(I, I_equalize_histogram); t = vpTime::measureTimeMs() - t; std::cout << "Time to do grayscale histogram equalization: " << t << " ms" << std::endl; @@ -382,7 +382,7 @@ int main(int argc, const char **argv) vpImage I_gamma_correction; gamma = 1.8f; t = vpTime::measureTimeMs(); - vp::gammaCorrection(I, I_gamma_correction, gamma); + VISP_IMGPROC_NAMESPACE::gammaCorrection(I, I_gamma_correction, gamma); t = vpTime::measureTimeMs() - t; std::cout << "Time to do grayscale gamma correction: " << t << " ms" << std::endl; @@ -393,7 +393,7 @@ int main(int argc, const char **argv) // Stretch contrast vpImage I_stretch_contrast; t = vpTime::measureTimeMs(); - vp::stretchContrast(I, I_stretch_contrast); + VISP_IMGPROC_NAMESPACE::stretchContrast(I, I_stretch_contrast); t = vpTime::measureTimeMs() - t; std::cout << "Time to do grayscale contrast stretching: " << t << " ms" << std::endl; @@ -404,7 +404,7 @@ int main(int argc, const char **argv) // Unsharp Mask vpImage I_unsharp_mask; t = vpTime::measureTimeMs(); - vp::unsharpMask(I, I_unsharp_mask, sigma); + VISP_IMGPROC_NAMESPACE::unsharpMask(I, I_unsharp_mask, sigma); t = vpTime::measureTimeMs() - t; std::cout << "Time to do grayscale unsharp mask: " << t << " ms" << std::endl; @@ -415,7 +415,7 @@ int main(int argc, const char **argv) // CLAHE vpImage I_clahe; t = vpTime::measureTimeMs(); - vp::clahe(I, I_clahe, 50); + VISP_IMGPROC_NAMESPACE::clahe(I, I_clahe, 50); t = vpTime::measureTimeMs() - t; std::cout << "Time to do grayscale CLAHE: " << t << " ms" << std::endl; diff --git a/modules/io/test/testJsonArgumentParser.cpp b/modules/io/test/testJsonArgumentParser.cpp index be315000a0..9a783aea74 100644 --- a/modules/io/test/testJsonArgumentParser.cpp +++ b/modules/io/test/testJsonArgumentParser.cpp @@ -49,6 +49,10 @@ using json = nlohmann::json; //! json namespace shortcut #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + std::pair> convertToArgcAndArgv(const std::vector &args) { std::vector argvs; @@ -93,7 +97,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") json j = loadJson(jsonPath); modify(j); saveJson(j, jsonPath); - }; + }; GIVEN("Some specific arguments") { @@ -139,7 +143,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") THEN("Calling the parser without any argument fails") { const int argc = 1; - const char *argv [] = { + const char *argv[] = { "program" }; @@ -149,7 +153,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") THEN("Calling the parser with only the JSON file works") { const int argc = 3; - const char *argv [] = { + const char *argv[] = { "program", "--config", jsonPath.c_str() @@ -165,7 +169,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") THEN("Calling the parser by specifying the json argument but leaving the file path empty throws an error") { const int argc = 2; - const char *argv [] = { + const char *argv[] = { "program", "--config", }; @@ -176,7 +180,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") const int argc = 3; for (const auto &jsonElem : j.items()) { modifyJson([&jsonElem](json &j) { j.erase(jsonElem.key()); }); - const char *argv [] = { + const char *argv[] = { "program", "--config", jsonPath.c_str() @@ -189,7 +193,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") const int argc = 3; for (const auto &jsonElem : j.items()) { modifyJson([&jsonElem](json &j) { j[jsonElem.key()] = nullptr; }); - const char *argv [] = { + const char *argv[] = { "program", "--config", jsonPath.c_str() @@ -200,7 +204,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") THEN("Calling the parser with an invalid json file path throws an error") { const int argc = 3; - const char *argv [] = { + const char *argv[] = { "program", "--config", "some_invalid_json/file/path.json" @@ -289,7 +293,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") { float bcopy = b; const int argc = 1; - const char *argv [] = { + const char *argv[] = { "program" }; @@ -308,7 +312,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") { float bcopy = b; const int argc = 1; - const char *argv [] = { + const char *argv[] = { "program" }; @@ -351,7 +355,7 @@ SCENARIO("Parsing arguments from JSON file", "[json]") } } -int main(int argc, char *argv []) +int main(int argc, char *argv[]) { Catch::Session session; // There must be exactly one instance session.applyCommandLine(argc, argv); diff --git a/modules/sensor/test/framegrabber/testPylonGrabber.cpp b/modules/sensor/test/framegrabber/testPylonGrabber.cpp index 1d2049346c..569d189928 100644 --- a/modules/sensor/test/framegrabber/testPylonGrabber.cpp +++ b/modules/sensor/test/framegrabber/testPylonGrabber.cpp @@ -138,6 +138,9 @@ int main() #else int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpTRACE("Basler Pylon grabber capabilities are not available...\n" "You should install pylon SDK to use this binary."); } diff --git a/modules/tracker/blob/test/tracking-with-dataset/testTrackDot.cpp b/modules/tracker/blob/test/tracking-with-dataset/testTrackDot.cpp index ff04770ebb..443658b5c1 100644 --- a/modules/tracker/blob/test/tracking-with-dataset/testTrackDot.cpp +++ b/modules/tracker/blob/test/tracking-with-dataset/testTrackDot.cpp @@ -64,6 +64,10 @@ // List of allowed command line options #define GETOPTARGS "cdi:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool getOptions(int argc, const char **argv, std::string &ipath, bool &click_allowed, bool &display); void usage(const char *name, const char *badparam, std::string ipath); @@ -205,8 +209,8 @@ int main(int argc, const char **argv) if (ipath != env_ipath) { std::cout << std::endl << "WARNING: " << std::endl; std::cout << " Since -i " - << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl - << " we skip the environment variable." << std::endl; + << " is different from VISP_IMAGE_PATH=" << env_ipath << std::endl + << " we skip the environment variable." << std::endl; } } @@ -215,9 +219,9 @@ int main(int argc, const char **argv) usage(argv[0], nullptr, ipath); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Use -i option or set VISP_INPUT_IMAGE_PATH " << std::endl - << " environment variable to specify the location of the " << std::endl - << " image path where test images are located." << std::endl - << std::endl; + << " environment variable to specify the location of the " << std::endl + << " image path where test images are located." << std::endl + << std::endl; return EXIT_FAILURE; } @@ -237,11 +241,12 @@ int main(int argc, const char **argv) vpCTRACE << "Load: " << filename << std::endl; vpImageIo::read(I, filename); - } catch (...) { + } + catch (...) { std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot read " << filename << std::endl; std::cerr << " Check your -i " << ipath << " option " << std::endl - << " or VISP_INPUT_IMAGE_PATH environment variable." << std::endl; + << " or VISP_INPUT_IMAGE_PATH environment variable." << std::endl; return EXIT_FAILURE; } @@ -276,7 +281,8 @@ int main(int argc, const char **argv) dot.initTracking(I, ip); if (opt_display) { dot.setGraphics(true); - } else { + } + else { dot.setGraphics(false); } dot.setComputeMoments(true); @@ -299,7 +305,8 @@ int main(int argc, const char **argv) } } return EXIT_SUCCESS; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return EXIT_FAILURE; } diff --git a/modules/tracker/mbt/test/generic-with-dataset/perfGenericTracker.cpp b/modules/tracker/mbt/test/generic-with-dataset/perfGenericTracker.cpp index 94c13ca1a5..a89da3b411 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/perfGenericTracker.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/perfGenericTracker.cpp @@ -49,6 +49,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { bool runBenchmark = false; diff --git a/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp b/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp index cc551630d4..47d4a6cf99 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp @@ -64,6 +64,10 @@ #define GETOPTARGS "i:dsclt:e:DmCh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void usage(const char *name, const char *badparam) @@ -709,7 +713,7 @@ int main(int argc, const char *argv[]) "KLT module or OpenCV is not available.\nTest is not run." << std::endl; return EXIT_SUCCESS; - } + } #endif // Test if an input path is set @@ -742,7 +746,7 @@ int main(int argc, const char *argv[]) std::cout << "Test succeed" << std::endl; return EXIT_SUCCESS; - } +} catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; return EXIT_FAILURE; diff --git a/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerCAOParsing.cpp b/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerCAOParsing.cpp index f0163bbcaf..6dbf3e7668 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerCAOParsing.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerCAOParsing.cpp @@ -43,6 +43,10 @@ #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + static std::string ipath = vpIoTools::getViSPImagesDataPath(); TEST_CASE("vpMbGenericTracker load CAO model Linux line ending", "[vpMbGenericTracker CAO parsing]") @@ -64,7 +68,7 @@ TEST_CASE("vpMbGenericTracker load CAO model Linux line ending", "[vpMbGenericTr TEST_CASE("vpMbGenericTracker load CAO model Windows line ending", "[vpMbGenericTracker CAO parsing]") { const std::string cao_filename = - vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_windows_line_ending.cao"); + vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_windows_line_ending.cao"); vpMbGenericTracker tracker; const bool verbose = true; REQUIRE_NOTHROW(tracker.loadModel(cao_filename, verbose)); diff --git a/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDepth.cpp b/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDepth.cpp index d331aacc41..1f8626364b 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDepth.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDepth.cpp @@ -61,6 +61,10 @@ #define GETOPTARGS "i:dcle:mCh" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { void usage(const char *name, const char *badparam) diff --git a/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDeterminist.cpp b/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDeterminist.cpp index 95334199c3..12c818da42 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDeterminist.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/testGenericTrackerDeterminist.cpp @@ -51,6 +51,10 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace { bool read_data(int cpt, vpImage &I) diff --git a/modules/tracker/mbt/test/generic-with-dataset/testMbtJsonSettings.cpp b/modules/tracker/mbt/test/generic-with-dataset/testMbtJsonSettings.cpp index bdbdd80fcf..614488462b 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/testMbtJsonSettings.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/testMbtJsonSettings.cpp @@ -49,6 +49,10 @@ using json = nlohmann::json; //! json namespace shortcut #define CATCH_CONFIG_RUNNER #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + vpMbGenericTracker baseTrackerConstructor() { const std::vector names = { "C1", "C2" }; @@ -158,7 +162,7 @@ SCENARIO("MBT JSON Serialization", "[json]") json j = loadJson(jsonPath); modify(j); saveJson(j, jsonPath); - }; + }; REQUIRE_NOTHROW(t1.saveConfigFile(jsonPath)); THEN("Reloading this tracker has the same basic properties") diff --git a/modules/tracker/mbt/test/generic-with-dataset/testMbtXmlGenericParser.cpp b/modules/tracker/mbt/test/generic-with-dataset/testMbtXmlGenericParser.cpp index c78650c1bd..ad109fa5dc 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/testMbtXmlGenericParser.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/testMbtXmlGenericParser.cpp @@ -44,6 +44,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #if defined(VISP_HAVE_PUGIXML) && (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)) std::string visp_images_dir = vpIoTools::getViSPImagesDataPath(); if (vpIoTools::checkDirectory(visp_images_dir + "/xml")) { @@ -156,7 +159,7 @@ int main() return EXIT_FAILURE; } } - } + } #elif !(defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV)) std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl; #elif !(defined(VISP_HAVE_PUGIXML)) @@ -165,4 +168,4 @@ int main() std::cout << "Test succeed" << std::endl; return EXIT_SUCCESS; -} + } diff --git a/modules/tracker/mbt/test/testTukeyEstimator.cpp b/modules/tracker/mbt/test/testTukeyEstimator.cpp index 6b9aa248fa..b6ad7c55e0 100644 --- a/modules/tracker/mbt/test/testTukeyEstimator.cpp +++ b/modules/tracker/mbt/test/testTukeyEstimator.cpp @@ -49,6 +49,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif size_t nb_elements = 1000; int nb_iterations = 100; double stdev = 0.5, mean = 0.0, noise_threshold = 1e-3; @@ -88,8 +91,8 @@ int main() for (size_t i = 0; i < weights.size(); i++) { if (!vpMath::equal(weights[i], weights_col[(unsigned int)i], noise_threshold)) { std::cerr << "Difference between vpRobust::TUKEY and " - "vpMbtTukeyEstimator (double)!" - << std::endl; + "vpMbtTukeyEstimator (double)!" + << std::endl; std::cerr << "weights_col[" << i << "]=" << weights_col[(unsigned int)i] << std::endl; std::cerr << "weights[" << i << "]=" << weights[i] << std::endl; return EXIT_FAILURE; @@ -128,8 +131,8 @@ int main() for (size_t i = 0; i < weights.size(); i++) { if (!vpMath::equal(weights[i], weights_col[(unsigned int)i], noise_threshold)) { std::cerr << "Difference between vpRobust::TUKEY and " - "vpMbtTukeyEstimator (float)!" - << std::endl; + "vpMbtTukeyEstimator (float)!" + << std::endl; std::cerr << "weights_col[" << i << "]=" << weights_col[(unsigned int)i] << std::endl; std::cerr << "weights[" << i << "]=" << weights[i] << std::endl; return EXIT_FAILURE; @@ -164,8 +167,8 @@ int main() for (size_t i = 0; i < weights.size(); i++) { if (!vpMath::equal(weights[(unsigned int)i], weights_col[(unsigned int)i], noise_threshold)) { std::cerr << "Difference between vpRobust::TUKEY and " - "vpMbtTukeyEstimator (float)!" - << std::endl; + "vpMbtTukeyEstimator (float)!" + << std::endl; std::cerr << "weights_col[" << i << "]=" << weights_col[(unsigned int)i] << std::endl; std::cerr << "weights[" << i << "]=" << weights[(unsigned int)i] << std::endl; return EXIT_FAILURE; From 1a8469eb559bd6b4a06e3fe5ec300658469ee7f8 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 16:43:14 +0200 Subject: [PATCH 22/64] [FIX] Various fixes related to VISP_BUILD_DEPRECATED_FUNCTIONS --- .../include/visp3/core/vpEigenConversion.h | 25 +++--- modules/core/include/visp3/core/vpHinkley.h | 8 ++ modules/core/include/visp3/core/vpIoTools.h | 2 +- .../src/math/matrix/vpEigenConversion.cpp | 14 ++-- modules/core/src/tools/file/vpIoTools.cpp | 30 +++---- .../include/visp3/imgproc/vpContours.h | 20 ++--- .../imgproc/include/visp3/imgproc/vpImgproc.h | 82 +++++++++---------- modules/imgproc/src/vpCLAHE.cpp | 4 + modules/imgproc/src/vpConnectedComponents.cpp | 3 + modules/imgproc/src/vpContours.cpp | 3 + modules/imgproc/src/vpFloodFill.cpp | 3 + modules/imgproc/src/vpImgproc.cpp | 3 + modules/imgproc/src/vpMorph.cpp | 5 +- modules/imgproc/src/vpRetinex.cpp | 4 + modules/imgproc/src/vpThreshold.cpp | 3 + 15 files changed, 122 insertions(+), 87 deletions(-) diff --git a/modules/core/include/visp3/core/vpEigenConversion.h b/modules/core/include/visp3/core/vpEigenConversion.h index 165e3325f5..0d04be4dbe 100644 --- a/modules/core/include/visp3/core/vpEigenConversion.h +++ b/modules/core/include/visp3/core/vpEigenConversion.h @@ -41,6 +41,7 @@ #include #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) +// The following macro forces us to us #define VISP_EIGEN_CONVERSION_NAMESPACE vp #else #define VISP_EIGEN_CONVERSION_NAMESPACE VISP_NAMESPACE_NAME @@ -50,38 +51,38 @@ namespace VISP_EIGEN_CONVERSION_NAMESPACE { #ifdef VISP_HAVE_EIGEN3 /* Eigen to ViSP */ -VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, vpMatrix &dst); +VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpMatrix &dst); -VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, vpHomogeneousMatrix &dst); +VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &dst); -template void eigen2visp(const Eigen::Quaternion &src, vpQuaternionVector &dst) +template void eigen2visp(const Eigen::Quaternion &src, VISP_NAMESPACE_ADDRESSING vpQuaternionVector &dst) { dst.build(src.x(), src.y(), src.z(), src.w()); } -template void eigen2visp(const Eigen::AngleAxis &src, vpThetaUVector &dst) +template void eigen2visp(const Eigen::AngleAxis &src, VISP_NAMESPACE_ADDRESSING vpThetaUVector &dst) { dst.build(src.angle() * src.axis()(0), src.angle() * src.axis()(1), src.angle() * src.axis()(2)); } -VISP_EXPORT void eigen2visp(const Eigen::VectorXd &src, vpColVector &dst); +VISP_EXPORT void eigen2visp(const Eigen::VectorXd &src, VISP_NAMESPACE_ADDRESSING vpColVector &dst); -VISP_EXPORT void eigen2visp(const Eigen::RowVectorXd &src, vpRowVector &dst); +VISP_EXPORT void eigen2visp(const Eigen::RowVectorXd &src, VISP_NAMESPACE_ADDRESSING vpRowVector &dst); /* ViSP to Eigen */ -template void visp2eigen(const vpMatrix &src, Eigen::MatrixBase &dst) +template void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpMatrix &src, Eigen::MatrixBase &dst) { dst = Eigen::Map >(src.data, src.getRows(), src.getCols()); } -template void visp2eigen(const vpHomogeneousMatrix &src, Eigen::MatrixBase &dst) +template void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &src, Eigen::MatrixBase &dst) { dst = Eigen::Map >(src.data, src.getRows(), src.getCols()); } -template void visp2eigen(const vpQuaternionVector &src, Eigen::Quaternion &dst) +template void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpQuaternionVector &src, Eigen::Quaternion &dst) { dst.w() = static_cast(src.w()); dst.x() = static_cast(src.x()); @@ -89,7 +90,7 @@ template void visp2eigen(const vpQuaternionVector &src, Eigen::Q dst.z() = static_cast(src.z()); } -template void visp2eigen(const vpThetaUVector &src, Eigen::AngleAxis &dst) +template void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpThetaUVector &src, Eigen::AngleAxis &dst) { dst.angle() = static_cast(src.getTheta()); dst.axis()(0) = static_cast(src.getU()[0]); @@ -97,9 +98,9 @@ template void visp2eigen(const vpThetaUVector &src, Eigen::Angle dst.axis()(2) = static_cast(src.getU()[2]); } -VISP_EXPORT void visp2eigen(const vpColVector &src, Eigen::VectorXd &dst); +VISP_EXPORT void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpColVector &src, Eigen::VectorXd &dst); -VISP_EXPORT void visp2eigen(const vpRowVector &src, Eigen::RowVectorXd &dst); +VISP_EXPORT void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpRowVector &src, Eigen::RowVectorXd &dst); #endif } // namespace vp #endif diff --git a/modules/core/include/visp3/core/vpHinkley.h b/modules/core/include/visp3/core/vpHinkley.h index 5c07f0fea1..1b78905f8b 100644 --- a/modules/core/include/visp3/core/vpHinkley.h +++ b/modules/core/include/visp3/core/vpHinkley.h @@ -42,6 +42,11 @@ #include #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) + +#if defined(ENABLE_VISP_NAMESPACE) +namespace VISP_NAMESPACE_NAME +{ +#endif /*! \class vpHinkley \deprecated This class is deprecated. You should rather use vpStatisticalTestHinkley. @@ -166,5 +171,8 @@ class VISP_EXPORT vpHinkley double Tk; double Nk; }; +#if defined(ENABLE_VISP_NAMESPACE) +} +#endif #endif #endif diff --git a/modules/core/include/visp3/core/vpIoTools.h b/modules/core/include/visp3/core/vpIoTools.h index d5bc19a294..f20bb6ea30 100644 --- a/modules/core/include/visp3/core/vpIoTools.h +++ b/modules/core/include/visp3/core/vpIoTools.h @@ -56,7 +56,7 @@ #include #if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98 -namespace VISP_NAMESPACE_NAME +namespace visp { // https://github.com/BinomialLLC/basis_universal/blob/ad9386a4a1cf2a248f7bbd45f543a7448db15267/encoder/basisu_miniz.h#L665 static inline unsigned long vp_mz_crc32(unsigned long crc, const unsigned char *ptr, size_t buf_len) diff --git a/modules/core/src/math/matrix/vpEigenConversion.cpp b/modules/core/src/math/matrix/vpEigenConversion.cpp index ee2e306856..bf2236cfa7 100644 --- a/modules/core/src/math/matrix/vpEigenConversion.cpp +++ b/modules/core/src/math/matrix/vpEigenConversion.cpp @@ -39,24 +39,24 @@ namespace VISP_EIGEN_CONVERSION_NAMESPACE { #ifdef VISP_HAVE_EIGEN3 /* Eigen to ViSP */ -void eigen2visp(const Eigen::MatrixXd &src, vpMatrix &dst) +void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpMatrix &dst) { dst.resize(static_cast(src.rows()), static_cast(src.cols()), false, false); Eigen::Map >(&dst.data[0], src.rows(), src.cols()) = src; } -void eigen2visp(const Eigen::MatrixXd &src, vpHomogeneousMatrix &dst) +void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &dst) { if ((src.rows() != 4) || (src.cols() != 4)) { - throw vpException(vpException::dimensionError, "Input Eigen Matrix must be of size (4,4)!"); + throw VISP_NAMESPACE_ADDRESSING vpException(VISP_NAMESPACE_ADDRESSING vpException::dimensionError, "Input Eigen Matrix must be of size (4,4)!"); } Eigen::Map >(&dst.data[0], src.rows(), src.cols()) = src; } -void eigen2visp(const Eigen::VectorXd &src, vpColVector &dst) +void eigen2visp(const Eigen::VectorXd &src, VISP_NAMESPACE_ADDRESSING vpColVector &dst) { dst.resize(static_cast(src.rows())); #if (VP_VERSION_INT(EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION) < 0x030300) @@ -70,7 +70,7 @@ void eigen2visp(const Eigen::VectorXd &src, vpColVector &dst) } } -void eigen2visp(const Eigen::RowVectorXd &src, vpRowVector &dst) +void eigen2visp(const Eigen::RowVectorXd &src, VISP_NAMESPACE_ADDRESSING vpRowVector &dst) { dst.resize(static_cast(src.cols())); #if (VP_VERSION_INT(EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION) < 0x030300) @@ -84,9 +84,9 @@ void eigen2visp(const Eigen::RowVectorXd &src, vpRowVector &dst) } } -void visp2eigen(const vpColVector &src, Eigen::VectorXd &dst) { dst = Eigen::VectorXd::Map(src.data, src.size()); } +void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpColVector &src, Eigen::VectorXd &dst) { dst = Eigen::VectorXd::Map(src.data, src.size()); } -void visp2eigen(const vpRowVector &src, Eigen::RowVectorXd &dst) +void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpRowVector &src, Eigen::RowVectorXd &dst) { dst = Eigen::RowVectorXd::Map(src.data, src.size()); } diff --git a/modules/core/src/tools/file/vpIoTools.cpp b/modules/core/src/tools/file/vpIoTools.cpp index 028e8fe80d..fe530afa1c 100644 --- a/modules/core/src/tools/file/vpIoTools.cpp +++ b/modules/core/src/tools/file/vpIoTools.cpp @@ -126,13 +126,13 @@ using namespace buminiz; #include -char VISP_NAMESPACE_ADDRESSING cnpy::BigEndianTest() +char visp::cnpy::BigEndianTest() { int x = 1; return (((reinterpret_cast(&x))[0]) ? '<' : '>'); } -char VISP_NAMESPACE_ADDRESSING cnpy::map_type(const std::type_info &t) +char visp::cnpy::map_type(const std::type_info &t) { if (t == typeid(float)) { return 'f'; } if (t == typeid(double)) { return 'f'; } @@ -159,7 +159,7 @@ char VISP_NAMESPACE_ADDRESSING cnpy::map_type(const std::type_info &t) else { return '?'; } } -void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(unsigned char *buffer, size_t &word_size, std::vector &shape, bool &fortran_order) +void visp::cnpy::parse_npy_header(unsigned char *buffer, size_t &word_size, std::vector &shape, bool &fortran_order) { uint16_t header_len = *reinterpret_cast(buffer+8); std::string header(reinterpret_cast(buffer+9), header_len); @@ -194,7 +194,7 @@ void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(unsigned char *buffer, siz word_size = atoi(str_ws.substr(0, loc2).c_str()); } -void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(FILE *fp, size_t &word_size, std::vector &shape, bool &fortran_order) +void visp::cnpy::parse_npy_header(FILE *fp, size_t &word_size, std::vector &shape, bool &fortran_order) { char buffer[256]; size_t res = fread(buffer, sizeof(char), 11, fp); @@ -250,7 +250,7 @@ void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(FILE *fp, size_t &word_siz word_size = atoi(str_ws.substr(0, loc2).c_str()); } -void VISP_NAMESPACE_ADDRESSING cnpy::parse_zip_footer(FILE *fp, uint16_t &nrecs, size_t &global_header_size, size_t &global_header_offset) +void visp::cnpy::parse_zip_footer(FILE *fp, uint16_t &nrecs, size_t &global_header_size, size_t &global_header_offset) { std::vector footer(22); fseek(fp, -22, SEEK_END); @@ -274,14 +274,14 @@ void VISP_NAMESPACE_ADDRESSING cnpy::parse_zip_footer(FILE *fp, uint16_t &nrecs, UNUSED(comment_len); assert(comment_len == 0); } -VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npy_file(FILE *fp) +visp::cnpy::NpyArray load_the_npy_file(FILE *fp) { std::vector shape; size_t word_size; bool fortran_order; - VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(fp, word_size, shape, fortran_order); + visp::cnpy::parse_npy_header(fp, word_size, shape, fortran_order); - VISP_NAMESPACE_ADDRESSING cnpy::NpyArray arr(shape, word_size, fortran_order); + visp::cnpy::NpyArray arr(shape, word_size, fortran_order); size_t nread = fread(arr.data(), 1, arr.num_bytes(), fp); if (nread != arr.num_bytes()) { throw std::runtime_error("load_the_npy_file: failed fread"); @@ -289,7 +289,7 @@ VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npy_file(FILE *fp) return arr; } -VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t uncompr_bytes) +visp::cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t uncompr_bytes) { std::vector buffer_compr(compr_bytes); std::vector buffer_uncompr(uncompr_bytes); @@ -321,9 +321,9 @@ VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t c std::vector shape; size_t word_size; bool fortran_order; - VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(&buffer_uncompr[0], word_size, shape, fortran_order); + visp::cnpy::parse_npy_header(&buffer_uncompr[0], word_size, shape, fortran_order); - VISP_NAMESPACE_ADDRESSING cnpy::NpyArray array(shape, word_size, fortran_order); + visp::cnpy::NpyArray array(shape, word_size, fortran_order); size_t offset = uncompr_bytes - array.num_bytes(); memcpy(array.data(), &buffer_uncompr[0]+offset, array.num_bytes()); @@ -339,7 +339,7 @@ VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t c \warning This function has only been tested on little endian platform. \note Original library: cnpy with MIT license. */ -VISP_NAMESPACE_ADDRESSING cnpy::npz_t VISP_NAMESPACE_ADDRESSING cnpy::npz_load(std::string fname) +visp::cnpy::npz_t visp::cnpy::npz_load(std::string fname) { FILE *fp = fopen(fname.c_str(), "rb"); @@ -347,7 +347,7 @@ VISP_NAMESPACE_ADDRESSING cnpy::npz_t VISP_NAMESPACE_ADDRESSING cnpy::npz_load(s throw std::runtime_error("npz_load: Error! Unable to open file "+fname+"!"); } - VISP_NAMESPACE_ADDRESSING cnpy::npz_t arrays; + visp::cnpy::npz_t arrays; bool quit = false; while (!quit) { std::vector local_header(30); @@ -404,7 +404,7 @@ VISP_NAMESPACE_ADDRESSING cnpy::npz_t VISP_NAMESPACE_ADDRESSING cnpy::npz_load(s \warning This function has only been tested on little endian platform. \note Original library: cnpy with MIT license. */ -VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npz_load(std::string fname, std::string varname) +visp::cnpy::NpyArray visp::cnpy::npz_load(std::string fname, std::string varname) { FILE *fp = fopen(fname.c_str(), "rb"); @@ -469,7 +469,7 @@ VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npz_loa \warning This function has only been tested on little endian platform. \note Original library: cnpy with MIT license. */ -VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npy_load(std::string fname) +visp::cnpy::NpyArray visp::cnpy::npy_load(std::string fname) { FILE *fp = fopen(fname.c_str(), "rb"); diff --git a/modules/imgproc/include/visp3/imgproc/vpContours.h b/modules/imgproc/include/visp3/imgproc/vpContours.h index adb76b0f94..bd1d422684 100644 --- a/modules/imgproc/include/visp3/imgproc/vpContours.h +++ b/modules/imgproc/include/visp3/imgproc/vpContours.h @@ -160,7 +160,7 @@ struct vpDirection { vpDirection direction; int directionSize = static_cast(LAST_DIRECTION); - int idx = vpMath::modulo(static_cast(m_direction) - 1, directionSize); + int idx = VISP_NAMESPACE_ADDRESSING vpMath::modulo(static_cast(m_direction) - 1, directionSize); direction.m_direction = vpDirectionType(idx); return direction; @@ -172,17 +172,17 @@ struct vpDirection * @param point Current point coordinate. * @return Next point coordinate along the contour. */ - vpImagePoint active(const vpImage &I, const vpImagePoint &point) + VISP_NAMESPACE_ADDRESSING vpImagePoint active(const VISP_NAMESPACE_ADDRESSING vpImage &I, const VISP_NAMESPACE_ADDRESSING vpImagePoint &point) { int yy = static_cast(point.get_i() + m_diry[static_cast(m_direction)]); int xx = static_cast(point.get_j() + m_dirx[static_cast(m_direction)]); if ((xx < 0) || (xx >= static_cast(I.getWidth())) || (yy < 0) || (yy >= static_cast(I.getHeight()))) { - return vpImagePoint(-1, -1); + return VISP_NAMESPACE_ADDRESSING vpImagePoint(-1, -1); } int pixel = I[yy][xx]; - return pixel != 0 ? vpImagePoint(yy, xx) : vpImagePoint(-1, -1); + return pixel != 0 ? VISP_NAMESPACE_ADDRESSING vpImagePoint(yy, xx) : VISP_NAMESPACE_ADDRESSING vpImagePoint(-1, -1); } }; @@ -218,7 +218,7 @@ struct vpContour //! Parent contour vpContour *m_parent; //! Vector of points belonging to the contour - std::vector m_points; + std::vector m_points; /*! * Default constructor. @@ -319,7 +319,7 @@ struct vpContour * \param contours : Detected contours. * \param grayValue : Drawing grayscale color. */ -VISP_EXPORT void drawContours(vpImage &I, const std::vector > &contours, +VISP_EXPORT void drawContours(VISP_NAMESPACE_ADDRESSING vpImage &I, const std::vector > &contours, unsigned char grayValue = 255); /*! @@ -331,8 +331,8 @@ VISP_EXPORT void drawContours(vpImage &I, const std::vector &I, const std::vector > &contours, - const vpColor &color); +VISP_EXPORT void drawContours(VISP_NAMESPACE_ADDRESSING vpImage &I, const std::vector > &contours, + const VISP_NAMESPACE_ADDRESSING vpColor &color); /*! * \ingroup group_imgproc_contours @@ -345,8 +345,8 @@ VISP_EXPORT void drawContours(vpImage &I, const std::vector &I_original, vpContour &contours, - std::vector > &contourPts, +VISP_EXPORT void findContours(const VISP_NAMESPACE_ADDRESSING vpImage &I_original, vpContour &contours, + std::vector > &contourPts, const vpContourRetrievalType &retrievalMode = CONTOUR_RETR_TREE); } // namespace diff --git a/modules/imgproc/include/visp3/imgproc/vpImgproc.h b/modules/imgproc/include/visp3/imgproc/vpImgproc.h index 677d8a925f..b0bf57ed12 100644 --- a/modules/imgproc/include/visp3/imgproc/vpImgproc.h +++ b/modules/imgproc/include/visp3/imgproc/vpImgproc.h @@ -196,7 +196,7 @@ VISP_EXPORT vpGammaColorHandling vpGammaColorHandlingFromString(const std::strin * \param alpha : Multiplication coefficient. * \param beta : Constant value added to the old intensity. */ -VISP_EXPORT void adjust(vpImage &I, double alpha, double beta); +VISP_EXPORT void adjust(VISP_NAMESPACE_ADDRESSING vpImage &I, double alpha, double beta); /*! * \ingroup group_imgproc_brightness @@ -209,7 +209,7 @@ VISP_EXPORT void adjust(vpImage &I, double alpha, double beta); * \param alpha : Multiplication coefficient. * \param beta : Constant value added to the old intensity. */ -VISP_EXPORT void adjust(const vpImage &I1, vpImage &I2, double alpha, double beta); +VISP_EXPORT void adjust(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, double alpha, double beta); /*! * \ingroup group_imgproc_brightness @@ -221,7 +221,7 @@ VISP_EXPORT void adjust(const vpImage &I1, vpImage * \param alpha : Multiplication coefficient. * \param beta : Constant value added to the old intensity. */ -VISP_EXPORT void adjust(vpImage &I, const double alpha, double beta); +VISP_EXPORT void adjust(VISP_NAMESPACE_ADDRESSING vpImage &I, const double alpha, double beta); /*! * \ingroup group_imgproc_brightness @@ -234,7 +234,7 @@ VISP_EXPORT void adjust(vpImage &I, const double alpha, double beta); * \param alpha : Multiplication coefficient. * \param beta : Constant value added to the old intensity. */ -VISP_EXPORT void adjust(const vpImage &I1, vpImage &I2, double alpha, double beta); +VISP_EXPORT void adjust(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, double alpha, double beta); /*! * \ingroup group_imgproc_brightness @@ -265,7 +265,7 @@ VISP_EXPORT void adjust(const vpImage &I1, vpImage &I2, double a * boxes of the given block size only and interpolates for locations in * between. */ -VISP_EXPORT void clahe(const vpImage &I1, vpImage &I2, int blockRadius = 150, +VISP_EXPORT void clahe(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, int blockRadius = 150, int bins = 256, float slope = 3.0f, bool fast = true); /*! @@ -295,7 +295,7 @@ VISP_EXPORT void clahe(const vpImage &I1, vpImage * boxes of the given block size only and interpolates for locations in * between. */ -VISP_EXPORT void clahe(const vpImage &I1, vpImage &I2, int blockRadius = 150, int bins = 256, +VISP_EXPORT void clahe(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, int blockRadius = 150, int bins = 256, float slope = 3.0f, bool fast = true); /*! @@ -308,7 +308,7 @@ VISP_EXPORT void clahe(const vpImage &I1, vpImage &I2, int block * \param I : The grayscale image to apply histogram equalization. * \param p_mask : If set, a boolean mask to take into account only the points for which the mask is true. */ -VISP_EXPORT void equalizeHistogram(vpImage &I, const vpImage *p_mask = nullptr); +VISP_EXPORT void equalizeHistogram(VISP_NAMESPACE_ADDRESSING vpImage &I, const VISP_NAMESPACE_ADDRESSING vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_histogram @@ -321,8 +321,8 @@ VISP_EXPORT void equalizeHistogram(vpImage &I, const vpImage &I1, vpImage &I2, - const vpImage *p_mask = nullptr); +VISP_EXPORT void equalizeHistogram(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, + const VISP_NAMESPACE_ADDRESSING vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_histogram @@ -337,7 +337,7 @@ VISP_EXPORT void equalizeHistogram(const vpImage &I1, vpImage &I, bool useHSV = false); +VISP_EXPORT void equalizeHistogram(VISP_NAMESPACE_ADDRESSING vpImage &I, bool useHSV = false); /*! * \ingroup group_imgproc_histogram @@ -353,7 +353,7 @@ VISP_EXPORT void equalizeHistogram(vpImage &I, bool useHSV = false); * value channel (in HSV space), otherwise the histogram equalization is * performed independently on the RGB channels. */ -VISP_EXPORT void equalizeHistogram(const vpImage &I1, vpImage &I2, bool useHSV = false); +VISP_EXPORT void equalizeHistogram(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, bool useHSV = false); /*! * \ingroup group_imgproc_gamma @@ -370,8 +370,8 @@ VISP_EXPORT void equalizeHistogram(const vpImage &I1, vpImage &I * \param[in] p_mask : If different from nullptr, permits to indicate which points must be taken into account by setting * them to true. */ -VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, const vpGammaMethod &method = GAMMA_MANUAL, - const vpImage *p_mask = nullptr); +VISP_EXPORT void gammaCorrection(VISP_NAMESPACE_ADDRESSING vpImage &I, const float &gamma, const vpGammaMethod &method = GAMMA_MANUAL, + const VISP_NAMESPACE_ADDRESSING vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_gamma @@ -389,8 +389,8 @@ VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, * \param[in] p_mask : If different from nullptr, permits to indicate which points must be taken into account by setting * them to true. */ -VISP_EXPORT void gammaCorrection(const vpImage &I1, vpImage &I2, const float &gamma, - const vpGammaMethod &method = GAMMA_MANUAL, const vpImage *p_mask = nullptr); +VISP_EXPORT void gammaCorrection(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, const float &gamma, + const vpGammaMethod &method = GAMMA_MANUAL, const VISP_NAMESPACE_ADDRESSING vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_gamma @@ -405,8 +405,8 @@ VISP_EXPORT void gammaCorrection(const vpImage &I1, vpImage &I, const float &gamma, const vpGammaColorHandling &colorHandling = GAMMA_RGB, - const vpGammaMethod &method = GAMMA_MANUAL, const vpImage *p_mask = nullptr); +VISP_EXPORT void gammaCorrection(VISP_NAMESPACE_ADDRESSING vpImage &I, const float &gamma, const vpGammaColorHandling &colorHandling = GAMMA_RGB, + const vpGammaMethod &method = GAMMA_MANUAL, const VISP_NAMESPACE_ADDRESSING vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_gamma @@ -422,9 +422,9 @@ VISP_EXPORT void gammaCorrection(vpImage &I, const float &gamma, const v * \param[in] p_mask : If different from nullptr, permits to indicate which points must be taken into account by setting * them to true. */ -VISP_EXPORT void gammaCorrection(const vpImage &I1, vpImage &I2, const float &gamma, +VISP_EXPORT void gammaCorrection(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, const float &gamma, const vpGammaColorHandling &colorHandling = GAMMA_RGB, - const vpGammaMethod &method = GAMMA_MANUAL, const vpImage *p_mask = nullptr); + const vpGammaMethod &method = GAMMA_MANUAL, const VISP_NAMESPACE_ADDRESSING vpImage *p_mask = nullptr); /*! * \ingroup group_imgproc_retinex @@ -447,7 +447,7 @@ VISP_EXPORT void gammaCorrection(const vpImage &I1, vpImage &I2, * \param kernelSize : Kernel size for the gaussian blur * operation. If -1, the kernel size is calculated from the image size. */ -VISP_EXPORT void retinex(vpImage &I, int scale = 240, int scaleDiv = 3, int level = RETINEX_UNIFORM, +VISP_EXPORT void retinex(VISP_NAMESPACE_ADDRESSING vpImage &I, int scale = 240, int scaleDiv = 3, int level = RETINEX_UNIFORM, double dynamic = 1.2, int kernelSize = -1); /*! @@ -472,7 +472,7 @@ VISP_EXPORT void retinex(vpImage &I, int scale = 240, int scaleDiv = 3, * \param kernelSize : Kernel size for the gaussian blur * operation. If -1, the kernel size is calculated from the image size. */ -VISP_EXPORT void retinex(const vpImage &I1, vpImage &I2, int scale = 240, int scaleDiv = 3, +VISP_EXPORT void retinex(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2, int scale = 240, int scaleDiv = 3, int level = RETINEX_UNIFORM, double dynamic = 1.2, int kernelSize = -1); /*! @@ -482,7 +482,7 @@ VISP_EXPORT void retinex(const vpImage &I1, vpImage &I2, int sca * * \param I : The grayscale image to stretch the contrast. */ -VISP_EXPORT void stretchContrast(vpImage &I); +VISP_EXPORT void stretchContrast(VISP_NAMESPACE_ADDRESSING vpImage &I); /*! * \ingroup group_imgproc_contrast @@ -492,7 +492,7 @@ VISP_EXPORT void stretchContrast(vpImage &I); * \param I1 : The first input grayscale image. * \param I2 : The second output grayscale image. */ -VISP_EXPORT void stretchContrast(const vpImage &I1, vpImage &I2); +VISP_EXPORT void stretchContrast(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2); /*! * \ingroup group_imgproc_contrast @@ -501,7 +501,7 @@ VISP_EXPORT void stretchContrast(const vpImage &I1, vpImage &I); +VISP_EXPORT void stretchContrast(VISP_NAMESPACE_ADDRESSING vpImage &I); /*! * \ingroup group_imgproc_contrast @@ -511,7 +511,7 @@ VISP_EXPORT void stretchContrast(vpImage &I); * \param I1 : The first input color image. * \param I2 : The second output color image. */ -VISP_EXPORT void stretchContrast(const vpImage &I1, vpImage &I2); +VISP_EXPORT void stretchContrast(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2); /*! * \ingroup group_imgproc_contrast @@ -521,7 +521,7 @@ VISP_EXPORT void stretchContrast(const vpImage &I1, vpImage &I2) * * \param I : The color image to stretch the contrast in the HSV color space. */ -VISP_EXPORT void stretchContrastHSV(vpImage &I); +VISP_EXPORT void stretchContrastHSV(VISP_NAMESPACE_ADDRESSING vpImage &I); /*! * \ingroup group_imgproc_contrast @@ -532,7 +532,7 @@ VISP_EXPORT void stretchContrastHSV(vpImage &I); * \param I1 : The first input color image. * \param I2 : The second output color image. */ -VISP_EXPORT void stretchContrastHSV(const vpImage &I1, vpImage &I2); +VISP_EXPORT void stretchContrastHSV(const VISP_NAMESPACE_ADDRESSING vpImage &I1, VISP_NAMESPACE_ADDRESSING vpImage &I2); /*! * \ingroup group_imgproc_sharpening @@ -543,7 +543,7 @@ VISP_EXPORT void stretchContrastHSV(const vpImage &I1, vpImage & * \param sigma : Standard deviation for Gaussian kernel. * \param weight : Weight (between [0 - 1[) for the sharpening process. */ -VISP_EXPORT void unsharpMask(vpImage &I, float sigma, double weight = 0.6); +VISP_EXPORT void unsharpMask(VISP_NAMESPACE_ADDRESSING vpImage &I, float sigma, double weight = 0.6); /*! * \ingroup group_imgproc_sharpening @@ -555,7 +555,7 @@ VISP_EXPORT void unsharpMask(vpImage &I, float sigma, double weig * \param sigma : Standard deviation for Gaussian kernel. * \param weight : Weight (between [0 - 1[) for the sharpening process. */ -VISP_EXPORT void unsharpMask(const vpImage &I, vpImage &Ires, float sigma, +VISP_EXPORT void unsharpMask(const VISP_NAMESPACE_ADDRESSING vpImage &I, VISP_NAMESPACE_ADDRESSING vpImage &Ires, float sigma, double weight = 0.6); /*! @@ -567,7 +567,7 @@ VISP_EXPORT void unsharpMask(const vpImage &I, vpImage &I, float sigma, double weight = 0.6); +VISP_EXPORT void unsharpMask(VISP_NAMESPACE_ADDRESSING vpImage &I, float sigma, double weight = 0.6); /*! * \ingroup group_imgproc_sharpening @@ -579,7 +579,7 @@ VISP_EXPORT void unsharpMask(vpImage &I, float sigma, double weight = 0. * \param sigma : Standard deviation for Gaussian kernel. * \param weight : Weight (between [0 - 1[) for the sharpening process. */ -VISP_EXPORT void unsharpMask(const vpImage &I, vpImage &Ires, float sigma, double weight = 0.6); +VISP_EXPORT void unsharpMask(const VISP_NAMESPACE_ADDRESSING vpImage &I, VISP_NAMESPACE_ADDRESSING vpImage &Ires, float sigma, double weight = 0.6); /*! * \ingroup group_imgproc_connected_components @@ -591,8 +591,8 @@ VISP_EXPORT void unsharpMask(const vpImage &I, vpImage &Ires, fl * \param nbComponents : Number of connected components. * \param connexity : Type of connexity. */ -VISP_EXPORT void connectedComponents(const vpImage &I, vpImage &labels, int &nbComponents, - const vpImageMorphology::vpConnexityType &connexity = vpImageMorphology::CONNEXITY_4); +VISP_EXPORT void connectedComponents(const VISP_NAMESPACE_ADDRESSING vpImage &I, VISP_NAMESPACE_ADDRESSING vpImage &labels, int &nbComponents, + const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity = VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4); /*! * \ingroup group_imgproc_morph @@ -601,10 +601,10 @@ VISP_EXPORT void connectedComponents(const vpImage &I, vpImage &I +VISP_EXPORT void fillHoles(VISP_NAMESPACE_ADDRESSING vpImage &I #if USE_OLD_FILL_HOLE , - const vpImageMorphology::vpConnexityType &connexity = vpImageMorphology::CONNEXITY_4 + const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity = VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4 #endif ); @@ -619,9 +619,9 @@ VISP_EXPORT void fillHoles(vpImage &I * \param newValue : New value to flood fill. * \param connexity : Type of connexity. */ -VISP_EXPORT void floodFill(vpImage &I, const vpImagePoint &seedPoint, const unsigned char oldValue, +VISP_EXPORT void floodFill(VISP_NAMESPACE_ADDRESSING vpImage &I, const VISP_NAMESPACE_ADDRESSING vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, - const vpImageMorphology::vpConnexityType &connexity = vpImageMorphology::CONNEXITY_4); + const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity = VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4); /*! * \ingroup group_imgproc_morph @@ -641,9 +641,9 @@ VISP_EXPORT void floodFill(vpImage &I, const vpImagePoint &seedPo * \param h_kp1 : Image morphologically reconstructed. * \param connexity : Type of connexity. */ -VISP_EXPORT void reconstruct(const vpImage &marker, const vpImage &mask, - vpImage &h_kp1 /*alias I */, - const vpImageMorphology::vpConnexityType &connexity = vpImageMorphology::CONNEXITY_4); +VISP_EXPORT void reconstruct(const VISP_NAMESPACE_ADDRESSING vpImage &marker, const VISP_NAMESPACE_ADDRESSING vpImage &mask, + VISP_NAMESPACE_ADDRESSING vpImage &h_kp1 /*alias I */, + const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity = VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4); /*! * \ingroup group_imgproc_threshold @@ -655,7 +655,7 @@ VISP_EXPORT void reconstruct(const vpImage &marker, const vpImage * \param backgroundValue : Value to set to the background. * \param foregroundValue : Value to set to the foreground. */ -VISP_EXPORT unsigned char autoThreshold(vpImage &I, const vpAutoThresholdMethod &method, +VISP_EXPORT unsigned char autoThreshold(VISP_NAMESPACE_ADDRESSING vpImage &I, const vpAutoThresholdMethod &method, const unsigned char backgroundValue = 0, const unsigned char foregroundValue = 255); diff --git a/modules/imgproc/src/vpCLAHE.cpp b/modules/imgproc/src/vpCLAHE.cpp index 88ed860bb0..2095ff78d0 100644 --- a/modules/imgproc/src/vpCLAHE.cpp +++ b/modules/imgproc/src/vpCLAHE.cpp @@ -86,6 +86,10 @@ namespace VISP_NAMESPACE_NAME #endif { +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif + int fastRound(float value) { return static_cast(value + 0.5f); } void clipHistogram(const std::vector &hist, std::vector &clippedHist, int limit) diff --git a/modules/imgproc/src/vpConnectedComponents.cpp b/modules/imgproc/src/vpConnectedComponents.cpp index 00f98acff8..7e6350ce98 100644 --- a/modules/imgproc/src/vpConnectedComponents.cpp +++ b/modules/imgproc/src/vpConnectedComponents.cpp @@ -45,6 +45,9 @@ namespace vp namespace VISP_NAMESPACE_NAME #endif { +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif void getNeighbors(const vpImage &I, std::queue &listOfNeighbors, unsigned int i, unsigned int j, const vpImageMorphology::vpConnexityType &connexity) diff --git a/modules/imgproc/src/vpContours.cpp b/modules/imgproc/src/vpContours.cpp index c67aa67516..c89002e704 100644 --- a/modules/imgproc/src/vpContours.cpp +++ b/modules/imgproc/src/vpContours.cpp @@ -76,6 +76,9 @@ namespace vp namespace VISP_NAMESPACE_NAME #endif { +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif bool fromTo(const vpImagePoint &from, const vpImagePoint &to, vpDirection &direction) { diff --git a/modules/imgproc/src/vpFloodFill.cpp b/modules/imgproc/src/vpFloodFill.cpp index 3bfca2b9ce..ae92fc0638 100644 --- a/modules/imgproc/src/vpFloodFill.cpp +++ b/modules/imgproc/src/vpFloodFill.cpp @@ -72,6 +72,9 @@ namespace vp namespace VISP_NAMESPACE_NAME #endif { +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif void floodFill(vpImage &I, const vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const vpImageMorphology::vpConnexityType &connexity) diff --git a/modules/imgproc/src/vpImgproc.cpp b/modules/imgproc/src/vpImgproc.cpp index 91ebeb8f9c..6d3480f2ed 100644 --- a/modules/imgproc/src/vpImgproc.cpp +++ b/modules/imgproc/src/vpImgproc.cpp @@ -66,6 +66,9 @@ namespace VISP_IMGPROC_NAMESPACE { +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif std::string vpGammaMethodList(const std::string &pref, const std::string &sep, const std::string &suf) { diff --git a/modules/imgproc/src/vpMorph.cpp b/modules/imgproc/src/vpMorph.cpp index f6b652819f..16b50d2a95 100644 --- a/modules/imgproc/src/vpMorph.cpp +++ b/modules/imgproc/src/vpMorph.cpp @@ -45,6 +45,9 @@ namespace vp namespace VISP_NAMESPACE_NAME #endif { +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif void fillHoles(vpImage &I #if USE_OLD_FILL_HOLE @@ -94,8 +97,8 @@ void fillHoles(vpImage &I for (unsigned int i = 0; i < I.getHeight(); ++i) { for (unsigned int j = 0; j < I.getWidth(); ++j) { I[i][j] = 255 - I_reconstruct[i + 1][j + 1]; - } } +} #else // Create flood fill mask vpImage flood_fill_mask(I.getHeight() + 2, I.getWidth() + 2, 0); diff --git a/modules/imgproc/src/vpRetinex.cpp b/modules/imgproc/src/vpRetinex.cpp index 248d9260ed..b4ce7dd61a 100644 --- a/modules/imgproc/src/vpRetinex.cpp +++ b/modules/imgproc/src/vpRetinex.cpp @@ -97,6 +97,10 @@ namespace VISP_NAMESPACE_NAME #define MAX_RETINEX_SCALES 8 +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif + std::vector retinexScalesDistribution(int scaleDiv, int level, int scale) { std::vector scales(MAX_RETINEX_SCALES); diff --git a/modules/imgproc/src/vpThreshold.cpp b/modules/imgproc/src/vpThreshold.cpp index 9b9d531adc..2841c641c6 100644 --- a/modules/imgproc/src/vpThreshold.cpp +++ b/modules/imgproc/src/vpThreshold.cpp @@ -46,6 +46,9 @@ namespace vp namespace VISP_NAMESPACE_NAME #endif { +#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE) +using namespace VISP_NAMESPACE_NAME; +#endif bool isBimodal(const std::vector &hist_float) { From ffdf6fe9cb5eb597cf5856013187195fd646b801 Mon Sep 17 00:00:00 2001 From: rlagneau Date: Mon, 27 May 2024 19:30:13 +0200 Subject: [PATCH 23/64] [WIP] With -DENABLE_VISP_NAMESPACE=OFF, visp_tutorials compiles, with -DENABLE_VISP_NAMESPACE=ON compilation error in tutorial-ibvs-4pts-json --- cmake/templates/vpConfig.h.in | 3 +- .../tutorial-bridge-opencv-camera-param.cpp | 6 +- .../opencv/tutorial-bridge-opencv-image.cpp | 4 + .../opencv/tutorial-bridge-opencv-matrix.cpp | 6 +- tutorial/computer-vision/pose_helper.cpp | 12 +- tutorial/computer-vision/pose_helper.h | 7 +- .../tutorial-homography-from-points.cpp | 8 +- .../tutorial-pose-from-planar-object.cpp | 5 + .../tutorial-pose-from-points-image.cpp | 7 +- .../tutorial-pose-from-points-live.cpp | 5 +- ...torial-pose-from-points-realsense-T265.cpp | 3 + .../tutorial-pose-from-qrcode-image.cpp | 9 +- .../tutorial-barcode-detector-live.cpp | 3 + .../barcode/tutorial-barcode-detector.cpp | 8 +- .../tutorial-dnn-object-detection-live.cpp | 4 + .../dnn/tutorial-dnn-tensorrt-live.cpp | 4 + .../tutorial-face-detector-live-threaded.cpp | 5 + .../face/tutorial-face-detector-live.cpp | 5 +- .../detection/face/tutorial-face-detector.cpp | 11 +- .../tutorial-matching-keypoint-SIFT.cpp | 4 + .../tutorial-matching-keypoint-homography.cpp | 13 +- .../matching/tutorial-matching-keypoint.cpp | 4 + ...torial-detection-object-mbt-deprecated.cpp | 3 + .../object/tutorial-detection-object-mbt.cpp | 3 + ...orial-detection-object-mbt2-deprecated.cpp | 4 + .../object/tutorial-detection-object-mbt2.cpp | 4 + ...-apriltag-detector-live-T265-realsense.cpp | 6 +- ...-apriltag-detector-live-rgbd-realsense.cpp | 5 +- ...ltag-detector-live-rgbd-structure-core.cpp | 69 +++++--- .../tag/tutorial-apriltag-detector-live.cpp | 4 + .../tag/tutorial-apriltag-detector.cpp | 7 +- .../grabber/tutorial-grabber-1394-writer.cpp | 4 + tutorial/grabber/tutorial-grabber-1394.cpp | 6 +- tutorial/grabber/tutorial-grabber-CMU1394.cpp | 7 +- .../grabber/tutorial-grabber-basler-pylon.cpp | 6 +- tutorial/grabber/tutorial-grabber-bebop2.cpp | 4 + .../grabber/tutorial-grabber-flycapture.cpp | 4 + .../grabber/tutorial-grabber-ids-ueye.cpp | 6 +- .../tutorial-grabber-multiple-realsense.cpp | 6 +- .../tutorial-grabber-opencv-threaded.cpp | 5 + tutorial/grabber/tutorial-grabber-opencv.cpp | 8 +- .../tutorial-grabber-realsense-T265.cpp | 6 +- .../grabber/tutorial-grabber-realsense.cpp | 4 + ...torial-grabber-rgbd-D435-structurecore.cpp | 8 +- .../tutorial-grabber-structure-core.cpp | 4 + .../tutorial-grabber-v4l2-threaded.cpp | 5 + tutorial/grabber/tutorial-grabber-v4l2.cpp | 4 + tutorial/grabber/tutorial-video-reader.cpp | 4 + tutorial/grabber/tutorial-video-recorder.cpp | 4 + .../pcl-visualizer/ClassUsingPclViewer.cpp | 4 + .../gui/pcl-visualizer/ClassUsingPclViewer.h | 10 +- .../pcl-visualizer/tutorial-pcl-viewer.cpp | 4 + tutorial/image/drawingHelpers.cpp | 4 + tutorial/image/drawingHelpers.h | 59 +++---- tutorial/image/tutorial-canny.cpp | 4 + tutorial/image/tutorial-draw-circle.cpp | 13 +- tutorial/image/tutorial-draw-cross.cpp | 5 + tutorial/image/tutorial-draw-frame.cpp | 20 ++- tutorial/image/tutorial-draw-line.cpp | 8 +- tutorial/image/tutorial-draw-point.cpp | 7 +- tutorial/image/tutorial-draw-rectangle.cpp | 7 +- tutorial/image/tutorial-draw-text.cpp | 8 +- tutorial/image/tutorial-event-keyboard.cpp | 5 + tutorial/image/tutorial-export-image.cpp | 5 + tutorial/image/tutorial-image-colormap.cpp | 4 + tutorial/image/tutorial-image-converter.cpp | 4 + .../tutorial-image-display-scaled-auto.cpp | 8 +- .../tutorial-image-display-scaled-manu.cpp | 8 +- tutorial/image/tutorial-image-display.cpp | 8 +- tutorial/image/tutorial-image-filter.cpp | 6 +- .../image/tutorial-image-manipulation.cpp | 12 +- tutorial/image/tutorial-image-reader.cpp | 11 +- tutorial/image/tutorial-image-viewer.cpp | 11 +- tutorial/image/tutorial-undistort.cpp | 5 + .../image/tutorial-video-manipulation.cpp | 161 ++++++++++-------- tutorial/image/tutorial-viewer.cpp | 10 +- .../autothreshold/tutorial-autothreshold.cpp | 21 ++- .../tutorial-brightness-adjustment.cpp | 47 ++--- .../tutorial-connected-components.cpp | 23 ++- tutorial/imgproc/contour/tutorial-contour.cpp | 50 +++--- .../tutorial-contrast-sharpening.cpp | 46 +++-- .../count-coins/tutorial-count-coins.cpp | 40 +++-- .../flood-fill/tutorial-flood-fill.cpp | 7 +- .../hough-transform/drawingHelpers.cpp | 4 + .../imgproc/hough-transform/drawingHelpers.h | 19 ++- .../hough-transform/tutorial-circle-hough.cpp | 12 +- tutorial/kalman/tutorial-ukf.cpp | 8 +- tutorial/matlab/tutorial-matlab.cpp | 5 + tutorial/mean-drift/tutorial-meandrift.cpp | 4 + tutorial/misc/npz/tutorial-npz.cpp | 4 + .../munkres/tutorial-munkres-assignment.cpp | 4 + .../robot/flir-ptu/tutorial-flir-ptu-ibvs.cpp | 5 + .../visp/mbot-apriltag-2D-half-vs.cpp | 70 +++++--- .../raspberry/visp/mbot-apriltag-ibvs.cpp | 5 + .../raspberry/visp/mbot-apriltag-pbvs.cpp | 7 +- .../mbot/raspberry/visp/test-serial-mbot.cpp | 5 + .../color/tutorial-hsv-range-tuner.cpp | 4 + .../color/tutorial-hsv-segmentation-basic.cpp | 5 + .../tutorial-hsv-segmentation-pcl-viewer.cpp | 4 + .../color/tutorial-hsv-segmentation-pcl.cpp | 4 + .../color/tutorial-hsv-segmentation.cpp | 6 +- .../image/tutorial-image-simulator.cpp | 10 +- tutorial/trace/tutorial-trace.cpp | 5 + .../blob/tutorial-blob-auto-tracker.cpp | 8 +- .../tutorial-blob-tracker-live-firewire.cpp | 6 +- .../blob/tutorial-blob-tracker-live-v4l2.cpp | 4 + ...l-megapose-live-single-object-tracking.cpp | 4 + .../tutorial-klt-tracker-live-v4l2.cpp | 6 +- .../tutorial-klt-tracker-with-reinit.cpp | 8 +- .../keypoint/tutorial-klt-tracker.cpp | 7 +- ...torial-mb-generic-tracker-apriltag-rs2.cpp | 9 +- ...ial-mb-generic-tracker-apriltag-webcam.cpp | 7 +- ...torial-mb-generic-tracker-rgbd-blender.cpp | 5 + ...mb-generic-tracker-rgbd-realsense-json.cpp | 6 +- ...rial-mb-generic-tracker-rgbd-realsense.cpp | 4 + ...mb-generic-tracker-rgbd-structure-core.cpp | 4 + .../tutorial-mb-generic-tracker-rgbd.cpp | 5 + ...utorial-mb-generic-tracker-stereo-mono.cpp | 6 +- .../tutorial-mb-generic-tracker-stereo.cpp | 6 +- .../tutorial-mb-generic-tracker-full.cpp | 5 + .../tutorial-mb-generic-tracker-live.cpp | 5 +- .../tutorial-mb-generic-tracker-read.cpp | 5 + .../tutorial-mb-generic-tracker-save.cpp | 5 + .../generic/tutorial-mb-generic-tracker.cpp | 5 + .../old/edges/tutorial-mb-edge-tracker.cpp | 5 + .../old/generic/tutorial-mb-tracker-full.cpp | 4 + .../old/generic/tutorial-mb-tracker.cpp | 6 +- .../old/hybrid/tutorial-mb-hybrid-tracker.cpp | 4 + .../old/keypoint/tutorial-mb-klt-tracker.cpp | 6 +- .../tutorial-me-ellipse-tracker.cpp | 91 +++++----- .../moving-edges/tutorial-me-line-tracker.cpp | 3 + .../tutorial-template-tracker.cpp | 10 +- .../ibvs/tutorial-ibvs-4pts-display.cpp | 8 +- .../tutorial-ibvs-4pts-image-tracking.cpp | 8 +- .../ibvs/tutorial-ibvs-4pts-json.cpp | 5 + .../ibvs/tutorial-ibvs-4pts-ogre-tracking.cpp | 12 +- .../ibvs/tutorial-ibvs-4pts-ogre.cpp | 15 +- ...-4pts-plotter-continuous-gain-adaptive.cpp | 7 +- ...torial-ibvs-4pts-plotter-gain-adaptive.cpp | 10 +- .../ibvs/tutorial-ibvs-4pts-plotter.cpp | 8 +- .../tutorial-ibvs-4pts-wireframe-camera.cpp | 8 +- ...torial-ibvs-4pts-wireframe-robot-afma6.cpp | 10 +- ...torial-ibvs-4pts-wireframe-robot-viper.cpp | 10 +- .../visual-servo/ibvs/tutorial-ibvs-4pts.cpp | 5 + 144 files changed, 1113 insertions(+), 413 deletions(-) diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index 20a64ae3c1..7d189f5063 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -114,11 +114,10 @@ // Defined if the user wants to protect the classes in a dedicated visp namespace #cmakedefine ENABLE_VISP_NAMESPACE -#ifdef ENABLE_VISP_NAMESPACE #define VISP_NAMESPACE_NAME visp +#ifdef ENABLE_VISP_NAMESPACE #define VISP_NAMESPACE_ADDRESSING visp:: #else -#define VISP_NAMESPACE_NAME #define VISP_NAMESPACE_ADDRESSING #endif diff --git a/tutorial/bridge/opencv/tutorial-bridge-opencv-camera-param.cpp b/tutorial/bridge/opencv/tutorial-bridge-opencv-camera-param.cpp index 39744ae15b..33303df158 100644 --- a/tutorial/bridge/opencv/tutorial-bridge-opencv-camera-param.cpp +++ b/tutorial/bridge/opencv/tutorial-bridge-opencv-camera-param.cpp @@ -1,6 +1,7 @@ //! \example tutorial-bridge-opencv-camera-param.cpp #include #include +#include #include #include @@ -11,7 +12,10 @@ int main() { - //! [Set ViSP camera parameters] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif +//! [Set ViSP camera parameters] double u0 = 326.6; double v0 = 215.0; double px = 582.7; diff --git a/tutorial/bridge/opencv/tutorial-bridge-opencv-image.cpp b/tutorial/bridge/opencv/tutorial-bridge-opencv-image.cpp index 09434f9c52..aebd60ca44 100644 --- a/tutorial/bridge/opencv/tutorial-bridge-opencv-image.cpp +++ b/tutorial/bridge/opencv/tutorial-bridge-opencv-image.cpp @@ -1,6 +1,7 @@ //! \example tutorial-bridge-opencv-image.cpp #include +#include #include #include @@ -11,6 +12,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // From ViSP to OpenCV conversion { //! [Load ViSP color image] diff --git a/tutorial/bridge/opencv/tutorial-bridge-opencv-matrix.cpp b/tutorial/bridge/opencv/tutorial-bridge-opencv-matrix.cpp index af960a6ce1..698bf5f237 100644 --- a/tutorial/bridge/opencv/tutorial-bridge-opencv-matrix.cpp +++ b/tutorial/bridge/opencv/tutorial-bridge-opencv-matrix.cpp @@ -1,4 +1,5 @@ //! \example tutorial-bridge-opencv-matrix.cpp +#include #include #include @@ -10,6 +11,9 @@ int main() { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif { std::cout << "From OpenCV to ViSP conversion" << std::endl; //! [Create OpenCV matrix] @@ -48,6 +52,6 @@ int main() std::cout << "M: \n" << M << std::endl; std::cout << "M_cv: \n" << M_cv << std::endl; //! [Modify ViSP matrix] - } +} #endif } diff --git a/tutorial/computer-vision/pose_helper.cpp b/tutorial/computer-vision/pose_helper.cpp index c84de7bc49..587deae021 100644 --- a/tutorial/computer-vision/pose_helper.cpp +++ b/tutorial/computer-vision/pose_helper.cpp @@ -4,6 +4,10 @@ #include "pose_helper.h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + //! [Compute pose] void computePose(std::vector &point, const std::vector &ip, const vpCameraParameters &cam, bool init, vpHomogeneousMatrix &cMo) @@ -45,7 +49,8 @@ std::vector track(vpImage &I, std::vector & dot[i].initTracking(I); vpDisplay::flush(I); } - } else { + } + else { for (unsigned int i = 0; i < dot.size(); i++) { dot[i].track(I); } @@ -64,9 +69,10 @@ std::vector track(vpImage &I, std::vector & } return ip; - } catch (...) { + } + catch (...) { std::cout << "Traking lost" << std::endl; throw(vpException(vpException::fatalError, "Tracking lost")); - } +} } #endif diff --git a/tutorial/computer-vision/pose_helper.h b/tutorial/computer-vision/pose_helper.h index 692f8c5096..a90e31dd65 100644 --- a/tutorial/computer-vision/pose_helper.h +++ b/tutorial/computer-vision/pose_helper.h @@ -4,15 +4,16 @@ //! [Include] #include #include +#include #include #include //! [Include] -void computePose(std::vector &point, const std::vector &ip, const vpCameraParameters &cam, - bool init, vpHomogeneousMatrix &cMo); +void computePose(std::vector &point, const std::vector &ip, const VISP_NAMESPACE_ADDRESSING vpCameraParameters &cam, + bool init, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &cMo); #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV) -std::vector track(vpImage &I, std::vector &dot, bool init); +std::vector track(VISP_NAMESPACE_ADDRESSING vpImage &I, std::vector &dot, bool init); #endif #endif diff --git a/tutorial/computer-vision/tutorial-homography-from-points.cpp b/tutorial/computer-vision/tutorial-homography-from-points.cpp index b604278bc1..7ae965dff1 100644 --- a/tutorial/computer-vision/tutorial-homography-from-points.cpp +++ b/tutorial/computer-vision/tutorial-homography-from-points.cpp @@ -1,5 +1,6 @@ //! \example tutorial-homography-from-points.cpp +#include //! [Include] #include //! [Include] @@ -7,6 +8,9 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif //! [Set 3D points] double L = 0.1; std::vector oP; @@ -76,6 +80,6 @@ int main() //! [Project] // Project the position in pixel of point 3 from the homography std::cout << "Estimation from homography: Point 3 in pixels in frame a: " << vpHomography::project(cam, aHb, iPb) - << std::endl; - //! [Project] + << std::endl; +//! [Project] } diff --git a/tutorial/computer-vision/tutorial-pose-from-planar-object.cpp b/tutorial/computer-vision/tutorial-pose-from-planar-object.cpp index f1ca025acf..6c22bae85d 100644 --- a/tutorial/computer-vision/tutorial-pose-from-planar-object.cpp +++ b/tutorial/computer-vision/tutorial-pose-from-planar-object.cpp @@ -2,6 +2,7 @@ // Core #include +#include #include #include #include @@ -23,6 +24,10 @@ // Check if std:c++17 or higher #if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))) && defined(VISP_HAVE_DISPLAY) && defined(VISP_HAVE_PUGIXML) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Local helper namespace { diff --git a/tutorial/computer-vision/tutorial-pose-from-points-image.cpp b/tutorial/computer-vision/tutorial-pose-from-points-image.cpp index 5cc8e7faa3..afaf01af70 100644 --- a/tutorial/computer-vision/tutorial-pose-from-points-image.cpp +++ b/tutorial/computer-vision/tutorial-pose-from-points-image.cpp @@ -1,5 +1,6 @@ /*! \example tutorial-pose-from-points-image.cpp */ +#include #include #include #include @@ -12,6 +13,9 @@ int main(int, char *argv[]) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { //! [Read image] vpImage I; @@ -82,7 +86,8 @@ int main(int, char *argv[]) vpTime::wait(40); //! [Slow down] } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/computer-vision/tutorial-pose-from-points-live.cpp b/tutorial/computer-vision/tutorial-pose-from-points-live.cpp index b6c99b2c54..8710c9d118 100644 --- a/tutorial/computer-vision/tutorial-pose-from-points-live.cpp +++ b/tutorial/computer-vision/tutorial-pose-from-points-live.cpp @@ -33,6 +33,9 @@ int main(int argc, char **argv) #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) && defined(VISP_HAVE_PUGIXML) && \ (defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || \ defined(HAVE_OPENCV_VIDEOIO) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_intrinsic_file; // xml file obtained from camera calibration std::string opt_camera_name; // corresponding camera name in the xml calibration file @@ -233,4 +236,4 @@ int main(int argc, char **argv) "use this example" << std::endl; #endif -} + } diff --git a/tutorial/computer-vision/tutorial-pose-from-points-realsense-T265.cpp b/tutorial/computer-vision/tutorial-pose-from-points-realsense-T265.cpp index c0165739a7..ca624086c4 100644 --- a/tutorial/computer-vision/tutorial-pose-from-points-realsense-T265.cpp +++ b/tutorial/computer-vision/tutorial-pose-from-points-realsense-T265.cpp @@ -13,6 +13,9 @@ int main(int argc, char **argv) { #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) && \ defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { double opt_square_width = 0.12; int opt_camera_index = 1; // camera index: 1. Left, 2.Right diff --git a/tutorial/computer-vision/tutorial-pose-from-qrcode-image.cpp b/tutorial/computer-vision/tutorial-pose-from-qrcode-image.cpp index b4b5bfa96a..a9170ab86b 100644 --- a/tutorial/computer-vision/tutorial-pose-from-qrcode-image.cpp +++ b/tutorial/computer-vision/tutorial-pose-from-qrcode-image.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-pose-from-qrcode-image.cpp */ +#include #include #include #include @@ -13,6 +14,9 @@ int main(int, char *argv[]) { #if defined(VISP_HAVE_ZBAR) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { vpImage I; vpImageIo::read(I, vpIoTools::getParent(argv[0]) + "/data/bar-code.pgm"); @@ -64,7 +68,7 @@ int main(int, char *argv[]) computePose(point, p, cam, init, cMo); // resulting pose is available in cMo var std::cout << "Pose translation (meter): " << cMo.getTranslationVector().t() << std::endl - << "Pose rotation (quaternion): " << vpQuaternionVector(cMo.getRotationMatrix()).t() << std::endl; + << "Pose rotation (quaternion): " << vpQuaternionVector(cMo.getRotationMatrix()).t() << std::endl; vpDisplay::displayFrame(I, cMo, cam, 0.05, vpColor::none, 3); } } @@ -76,7 +80,8 @@ int main(int, char *argv[]) vpTime::wait(40); } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } #else diff --git a/tutorial/detection/barcode/tutorial-barcode-detector-live.cpp b/tutorial/detection/barcode/tutorial-barcode-detector-live.cpp index 34f788d806..f00a29b3b2 100644 --- a/tutorial/detection/barcode/tutorial-barcode-detector-live.cpp +++ b/tutorial/detection/barcode/tutorial-barcode-detector-live.cpp @@ -17,6 +17,9 @@ int main(int argc, const char **argv) { #if (defined(VISP_HAVE_V4L2) || defined(HAVE_OPENCV_VIDEOIO)) && (defined(VISP_HAVE_ZBAR) || defined(VISP_HAVE_DMTX)) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif int opt_device = 0; int opt_barcode = 0; // 0=QRCode, 1=DataMatrix diff --git a/tutorial/detection/barcode/tutorial-barcode-detector.cpp b/tutorial/detection/barcode/tutorial-barcode-detector.cpp index f00d6c0216..00bfb1dba3 100644 --- a/tutorial/detection/barcode/tutorial-barcode-detector.cpp +++ b/tutorial/detection/barcode/tutorial-barcode-detector.cpp @@ -14,6 +14,9 @@ int main(int argc, const char **argv) #if (defined(VISP_HAVE_ZBAR) || defined(VISP_HAVE_DMTX)) && \ (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) //! [Macro defined] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { vpImage I; vpImageIo::read(I, "bar-code.pgm"); @@ -38,7 +41,7 @@ int main(int argc, const char **argv) opt_barcode = atoi(argv[i + 1]); else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << "Usage: " << argv[0] << " [--code-type <0 for QR code | 1 for DataMatrix code>] [--help] [-h]" - << std::endl; + << std::endl; return EXIT_SUCCESS; } } @@ -93,7 +96,8 @@ int main(int argc, const char **argv) vpDisplay::getClick(I); } delete detector; - } catch (const vpException &e) { +} + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } #else diff --git a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp index f8eeeb869b..44f670a142 100644 --- a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp +++ b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp @@ -15,6 +15,10 @@ using json = nlohmann::json; //! json namespace shortcut #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { DETECTION_CONTAINER_MAP = 0, diff --git a/tutorial/detection/dnn/tutorial-dnn-tensorrt-live.cpp b/tutorial/detection/dnn/tutorial-dnn-tensorrt-live.cpp index 945935689f..e5ba552623 100644 --- a/tutorial/detection/dnn/tutorial-dnn-tensorrt-live.cpp +++ b/tutorial/detection/dnn/tutorial-dnn-tensorrt-live.cpp @@ -43,6 +43,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + //! [Preprocess image] void preprocessImage(cv::Mat &img, float *gpu_input, const nvinfer1::Dims &dims, float meanR, float meanG, float meanB) { diff --git a/tutorial/detection/face/tutorial-face-detector-live-threaded.cpp b/tutorial/detection/face/tutorial-face-detector-live-threaded.cpp index 46c45a5922..63bf19e8d6 100644 --- a/tutorial/detection/face/tutorial-face-detector-live-threaded.cpp +++ b/tutorial/detection/face/tutorial-face-detector-live-threaded.cpp @@ -1,6 +1,7 @@ //! \example tutorial-face-detector-live-threaded.cpp #include +#include #include #include #include @@ -16,6 +17,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; diff --git a/tutorial/detection/face/tutorial-face-detector-live.cpp b/tutorial/detection/face/tutorial-face-detector-live.cpp index 614dd26a59..7c6c3df58f 100644 --- a/tutorial/detection/face/tutorial-face-detector-live.cpp +++ b/tutorial/detection/face/tutorial-face-detector-live.cpp @@ -12,9 +12,12 @@ #include #endif -int main(int argc, const char *argv []) +int main(int argc, const char *argv[]) { #if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_OBJDETECT) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_face_cascade_name = "./haarcascade_frontalface_alt.xml"; unsigned int opt_device = 0; diff --git a/tutorial/detection/face/tutorial-face-detector.cpp b/tutorial/detection/face/tutorial-face-detector.cpp index b9f280b2ba..bb02af1130 100644 --- a/tutorial/detection/face/tutorial-face-detector.cpp +++ b/tutorial/detection/face/tutorial-face-detector.cpp @@ -1,4 +1,5 @@ //! \example tutorial-face-detector.cpp +#include #include #include #include @@ -11,6 +12,9 @@ int main(int argc, const char *argv[]) { //! [Macro defined] #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_OBJDETECT) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif //! [Macro defined] try { //! [Default settings] @@ -25,7 +29,7 @@ int main(int argc, const char *argv[]) opt_video = std::string(argv[i + 1]); else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << "Usage: " << argv[0] << " [--haar ] [--video ]" - << " [--help] [-h]" << std::endl; + << " [--help] [-h]" << std::endl; return EXIT_SUCCESS; } } @@ -83,9 +87,10 @@ int main(int argc, const char *argv[]) } if (!exit_requested) vpDisplay::getClick(I); - } catch (const vpException &e) { - std::cout << e.getMessage() << std::endl; } + catch (const vpException &e) { + std::cout << e.getMessage() << std::endl; +} #else (void)argc; (void)argv; diff --git a/tutorial/detection/matching/tutorial-matching-keypoint-SIFT.cpp b/tutorial/detection/matching/tutorial-matching-keypoint-SIFT.cpp index 7eadee3d54..c0ecfae1da 100644 --- a/tutorial/detection/matching/tutorial-matching-keypoint-SIFT.cpp +++ b/tutorial/detection/matching/tutorial-matching-keypoint-SIFT.cpp @@ -1,4 +1,5 @@ //! \example tutorial-matching-keypoint-SIFT.cpp +#include #include #include #include @@ -13,6 +14,9 @@ int main() (defined(VISP_HAVE_OPENCV_NONFREE) || defined(VISP_HAVE_OPENCV_XFEATURES2D) || \ (VISP_HAVE_OPENCV_VERSION >= 0x030411 && CV_MAJOR_VERSION < 4) || (VISP_HAVE_OPENCV_VERSION >= 0x040400)) //! [Define] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpImage I; vpVideoReader reader; diff --git a/tutorial/detection/matching/tutorial-matching-keypoint-homography.cpp b/tutorial/detection/matching/tutorial-matching-keypoint-homography.cpp index 39cf868001..6d6841f033 100644 --- a/tutorial/detection/matching/tutorial-matching-keypoint-homography.cpp +++ b/tutorial/detection/matching/tutorial-matching-keypoint-homography.cpp @@ -1,4 +1,5 @@ //! \example tutorial-matching-keypoint-homography.cpp +#include #include #include #include @@ -8,6 +9,9 @@ int main(int argc, const char **argv) { #if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif //! [Select method] int method = 0; @@ -76,8 +80,8 @@ int main(int argc, const char **argv) //! [Matching] std::vector iPref(nbMatch), - iPcur(nbMatch); // Coordinates in pixels (for display only) - //! [Allocation] + iPcur(nbMatch); // Coordinates in pixels (for display only) + //! [Allocation] std::vector mPref_x(nbMatch), mPref_y(nbMatch); std::vector mPcur_x(nbMatch), mPcur_y(nbMatch); std::vector inliers(nbMatch); @@ -99,7 +103,8 @@ int main(int argc, const char **argv) (unsigned int)(mPref_x.size() * 0.25), 2.0 / cam.get_px(), true); else vpHomography::robust(mPref_x, mPref_y, mPcur_x, mPcur_y, curHref, inliers, residual, 0.4, 4, true); - } catch (...) { + } + catch (...) { std::cout << "Cannot compute homography from matches..." << std::endl; } @@ -132,7 +137,7 @@ int main(int argc, const char **argv) if (vpDisplay::getClick(Idisp, false)) break; - } +} vpDisplay::getClick(Idisp); #else diff --git a/tutorial/detection/matching/tutorial-matching-keypoint.cpp b/tutorial/detection/matching/tutorial-matching-keypoint.cpp index 399cd1bb66..35ba74a970 100644 --- a/tutorial/detection/matching/tutorial-matching-keypoint.cpp +++ b/tutorial/detection/matching/tutorial-matching-keypoint.cpp @@ -1,4 +1,5 @@ //! \example tutorial-matching-keypoint.cpp +#include #include #include #include @@ -11,6 +12,9 @@ int main() //! [Define] #if defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) //! [Define] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpImage I; vpVideoReader reader; diff --git a/tutorial/detection/object/tutorial-detection-object-mbt-deprecated.cpp b/tutorial/detection/object/tutorial-detection-object-mbt-deprecated.cpp index 391d81ba60..08c453db35 100644 --- a/tutorial/detection/object/tutorial-detection-object-mbt-deprecated.cpp +++ b/tutorial/detection/object/tutorial-detection-object-mbt-deprecated.cpp @@ -11,6 +11,9 @@ int main(int argc, char **argv) { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif //! [MBT code] try { std::string videoname = "teabox.mp4"; diff --git a/tutorial/detection/object/tutorial-detection-object-mbt.cpp b/tutorial/detection/object/tutorial-detection-object-mbt.cpp index d9d0ac470e..e89818b640 100644 --- a/tutorial/detection/object/tutorial-detection-object-mbt.cpp +++ b/tutorial/detection/object/tutorial-detection-object-mbt.cpp @@ -11,6 +11,9 @@ int main(int argc, char **argv) { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif //! [MBT code] try { std::string videoname = "teabox.mp4"; diff --git a/tutorial/detection/object/tutorial-detection-object-mbt2-deprecated.cpp b/tutorial/detection/object/tutorial-detection-object-mbt2-deprecated.cpp index e612206bb2..0972f4df6c 100644 --- a/tutorial/detection/object/tutorial-detection-object-mbt2-deprecated.cpp +++ b/tutorial/detection/object/tutorial-detection-object-mbt2-deprecated.cpp @@ -8,6 +8,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) void learnCube(const vpImage &I, vpMbEdgeTracker &tracker, vpKeyPoint &keypoint_learning, int id) { diff --git a/tutorial/detection/object/tutorial-detection-object-mbt2.cpp b/tutorial/detection/object/tutorial-detection-object-mbt2.cpp index bbe9259b55..7fad75ebd1 100644 --- a/tutorial/detection/object/tutorial-detection-object-mbt2.cpp +++ b/tutorial/detection/object/tutorial-detection-object-mbt2.cpp @@ -8,6 +8,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_FEATURES2D) void learnCube(const vpImage &I, vpMbGenericTracker &tracker, vpKeyPoint &keypoint_learning, int id) { diff --git a/tutorial/detection/tag/tutorial-apriltag-detector-live-T265-realsense.cpp b/tutorial/detection/tag/tutorial-apriltag-detector-live-T265-realsense.cpp index a19648d3be..40ac282dfb 100644 --- a/tutorial/detection/tag/tutorial-apriltag-detector-live-T265-realsense.cpp +++ b/tutorial/detection/tag/tutorial-apriltag-detector-live-T265-realsense.cpp @@ -22,6 +22,10 @@ int main(int argc, const char **argv) #if defined(VISP_HAVE_APRILTAG) && defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)) //! [Macro defined] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpDetectorAprilTag::vpAprilTagFamily tagFamily = vpDetectorAprilTag::TAG_36h11; vpDetectorAprilTag::vpPoseEstimationMethod poseEstimationMethod = vpDetectorAprilTag::HOMOGRAPHY_VIRTUAL_VS; double tagSize = 0.053; @@ -214,7 +218,7 @@ int main(int argc, const char **argv) } catch (const vpException &e) { std::cerr << "Catch an exception: " << e.getMessage() << std::endl; - } +} return EXIT_SUCCESS; #else diff --git a/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp b/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp index 6fbe8ae7d6..958917fd0b 100644 --- a/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp +++ b/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-realsense.cpp @@ -17,6 +17,9 @@ int main(int argc, const char **argv) //! [Macro defined] #if defined(VISP_HAVE_APRILTAG) && defined(VISP_HAVE_REALSENSE2) //! [Macro defined] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpDetectorAprilTag::vpAprilTagFamily tagFamily = vpDetectorAprilTag::TAG_36h11; vpDetectorAprilTag::vpPoseEstimationMethod poseEstimationMethod = vpDetectorAprilTag::HOMOGRAPHY_VIRTUAL_VS; @@ -264,7 +267,7 @@ int main(int argc, const char **argv) } catch (const vpException &e) { std::cerr << "Catch an exception: " << e.getMessage() << std::endl; - } +} return EXIT_SUCCESS; #else diff --git a/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-structure-core.cpp b/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-structure-core.cpp index 54a4c158db..55e9d6a5b8 100644 --- a/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-structure-core.cpp +++ b/tutorial/detection/tag/tutorial-apriltag-detector-live-rgbd-structure-core.cpp @@ -18,6 +18,9 @@ int main(int argc, const char **argv) //! [Macro defined] #if defined(VISP_HAVE_APRILTAG) && defined(VISP_HAVE_OCCIPITAL_STRUCTURE) //! [Macro defined] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpDetectorAprilTag::vpAprilTagFamily tagFamily = vpDetectorAprilTag::TAG_36h11; vpDetectorAprilTag::vpPoseEstimationMethod poseEstimationMethod = vpDetectorAprilTag::HOMOGRAPHY_VIRTUAL_VS; @@ -39,36 +42,46 @@ int main(int argc, const char **argv) for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--pose_method" && i + 1 < argc) { poseEstimationMethod = (vpDetectorAprilTag::vpPoseEstimationMethod)atoi(argv[i + 1]); - } else if (std::string(argv[i]) == "--tag_size" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--tag_size" && i + 1 < argc) { tagSize = atof(argv[i + 1]); - } else if (std::string(argv[i]) == "--quad_decimate" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--quad_decimate" && i + 1 < argc) { quad_decimate = (float)atof(argv[i + 1]); - } else if (std::string(argv[i]) == "--nthreads" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--nthreads" && i + 1 < argc) { nThreads = atoi(argv[i + 1]); - } else if (std::string(argv[i]) == "--display_tag") { + } + else if (std::string(argv[i]) == "--display_tag") { display_tag = true; - } else if (std::string(argv[i]) == "--display_off") { + } + else if (std::string(argv[i]) == "--display_off") { display_off = true; - } else if (std::string(argv[i]) == "--color" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--color" && i + 1 < argc) { color_id = atoi(argv[i + 1]); - } else if (std::string(argv[i]) == "--thickness" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--thickness" && i + 1 < argc) { thickness = (unsigned int)atoi(argv[i + 1]); - } else if (std::string(argv[i]) == "--tag_family" && i + 1 < argc) { + } + else if (std::string(argv[i]) == "--tag_family" && i + 1 < argc) { tagFamily = (vpDetectorAprilTag::vpAprilTagFamily)atoi(argv[i + 1]); - } else if (std::string(argv[i]) == "--z_aligned") { + } + else if (std::string(argv[i]) == "--z_aligned") { align_frame = true; - } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { + } + else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << "Usage: " << argv[0] - << " [--tag_size (default: 0.053)]" - " [--quad_decimate (default: 1)]" - " [--nthreads (default: 1)]" - " [--pose_method (0: HOMOGRAPHY, 1: HOMOGRAPHY_VIRTUAL_VS, " - " 2: DEMENTHON_VIRTUAL_VS, 3: LAGRANGE_VIRTUAL_VS, " - " 4: BEST_RESIDUAL_VIRTUAL_VS, 5: HOMOGRAPHY_ORTHOGONAL_ITERATION) (default: 0)]" - " [--tag_family (0: TAG_36h11, 1: TAG_36h10 (DEPRECATED), 2: TAG_36ARTOOLKIT (DEPRECATED)," - " 3: TAG_25h9, 4: TAG_25h7 (DEPRECATED), 5: TAG_16h5, 6: TAG_CIRCLE21h7, 7: TAG_CIRCLE49h12," - " 8: TAG_CUSTOM48h12, 9: TAG_STANDARD41h12, 10: TAG_STANDARD52h13) (default: 0)]" - " [--display_tag] [--z_aligned]"; + << " [--tag_size (default: 0.053)]" + " [--quad_decimate (default: 1)]" + " [--nthreads (default: 1)]" + " [--pose_method (0: HOMOGRAPHY, 1: HOMOGRAPHY_VIRTUAL_VS, " + " 2: DEMENTHON_VIRTUAL_VS, 3: LAGRANGE_VIRTUAL_VS, " + " 4: BEST_RESIDUAL_VIRTUAL_VS, 5: HOMOGRAPHY_ORTHOGONAL_ITERATION) (default: 0)]" + " [--tag_family (0: TAG_36h11, 1: TAG_36h10 (DEPRECATED), 2: TAG_36ARTOOLKIT (DEPRECATED)," + " 3: TAG_25h9, 4: TAG_25h7 (DEPRECATED), 5: TAG_16h5, 6: TAG_CIRCLE21h7, 7: TAG_CIRCLE49h12," + " 8: TAG_CUSTOM48h12, 9: TAG_STANDARD41h12, 10: TAG_STANDARD52h13) (default: 0)]" + " [--display_tag] [--z_aligned]"; #if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) std::cout << " [--display_off] [--color ] [--thickness ]"; #endif @@ -166,7 +179,8 @@ int main(int argc, const char **argv) if (!vpMath::isNaN(I_depth_raw[i][j])) { float Z = I_depth_raw[i][j] * 0.001; // Transform depth to meters. depthMap[i][j] = Z; - } else { + } + else { depthMap[i][j] = 0; } } @@ -197,9 +211,11 @@ int main(int argc, const char **argv) &confidence_index)) { if (confidence_index > 0.5) { vpDisplay::displayFrame(I_color2, cMo, cam, tagSize / 2, vpColor::none, 3); - } else if (confidence_index > 0.25) { + } + else if (confidence_index > 0.25) { vpDisplay::displayFrame(I_color2, cMo, cam, tagSize / 2, vpColor::orange, 3); - } else { + } + else { vpDisplay::displayFrame(I_color2, cMo, cam, tagSize / 2, vpColor::red, 3); } std::stringstream ss; @@ -229,8 +245,8 @@ int main(int argc, const char **argv) std::cout << "Benchmark loop processing time" << std::endl; std::cout << "Mean / Median / Std: " << vpMath::getMean(time_vec) << " ms" - << " ; " << vpMath::getMedian(time_vec) << " ms" - << " ; " << vpMath::getStdev(time_vec) << " ms" << std::endl; + << " ; " << vpMath::getMedian(time_vec) << " ms" + << " ; " << vpMath::getStdev(time_vec) << " ms" << std::endl; if (!display_off) { delete d1; @@ -238,7 +254,8 @@ int main(int argc, const char **argv) delete d3; } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cerr << "Catch an exception: " << e.getMessage() << std::endl; } diff --git a/tutorial/detection/tag/tutorial-apriltag-detector-live.cpp b/tutorial/detection/tag/tutorial-apriltag-detector-live.cpp index b3e758e41e..6f31a5c9cc 100644 --- a/tutorial/detection/tag/tutorial-apriltag-detector-live.cpp +++ b/tutorial/detection/tag/tutorial-apriltag-detector-live.cpp @@ -36,6 +36,10 @@ int main(int argc, const char **argv) defined(HAVE_OPENCV_VIDEOIO) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)) //! [Macro defined] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + int opt_device = 0; // For OpenCV and V4l2 grabber to set the camera device vpDetectorAprilTag::vpAprilTagFamily tagFamily = vpDetectorAprilTag::TAG_36h11; vpDetectorAprilTag::vpPoseEstimationMethod poseEstimationMethod = vpDetectorAprilTag::HOMOGRAPHY_VIRTUAL_VS; diff --git a/tutorial/detection/tag/tutorial-apriltag-detector.cpp b/tutorial/detection/tag/tutorial-apriltag-detector.cpp index 87ba939cfa..52f39d1aab 100644 --- a/tutorial/detection/tag/tutorial-apriltag-detector.cpp +++ b/tutorial/detection/tag/tutorial-apriltag-detector.cpp @@ -2,6 +2,7 @@ //! [Include] #include //! [Include] +#include #include #include #include @@ -14,6 +15,10 @@ int main(int argc, const char **argv) #if defined(VISP_HAVE_APRILTAG) && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)) //! [Macro defined] +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + std::string input_filename = "AprilTag.pgm"; vpDetectorAprilTag::vpAprilTagFamily tagFamily = vpDetectorAprilTag::TAG_36h11; vpDetectorAprilTag::vpPoseEstimationMethod poseEstimationMethod = vpDetectorAprilTag::HOMOGRAPHY_VIRTUAL_VS; @@ -205,7 +210,7 @@ int main(int argc, const char **argv) } catch (const vpException &e) { std::cerr << "Catch an exception: " << e.getMessage() << std::endl; - } +} #else (void)argc; diff --git a/tutorial/grabber/tutorial-grabber-1394-writer.cpp b/tutorial/grabber/tutorial-grabber-1394-writer.cpp index 4d3a381eac..9200e9d847 100644 --- a/tutorial/grabber/tutorial-grabber-1394-writer.cpp +++ b/tutorial/grabber/tutorial-grabber-1394-writer.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-1394-writer.cpp */ +#include #include #include #include @@ -7,6 +8,9 @@ int main(int argc, char **) { #ifdef VISP_HAVE_DC1394 +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif #ifdef VISP_HAVE_DISPLAY vpDisplay *d = vpDisplayFactory::displayFactory(); #else diff --git a/tutorial/grabber/tutorial-grabber-1394.cpp b/tutorial/grabber/tutorial-grabber-1394.cpp index d495fccb1e..c223ffc0f8 100644 --- a/tutorial/grabber/tutorial-grabber-1394.cpp +++ b/tutorial/grabber/tutorial-grabber-1394.cpp @@ -1,4 +1,5 @@ //! \example tutorial-grabber-1394.cpp +#include #include #include #include @@ -59,6 +60,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_DC1394) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_seqname; int opt_record_mode = 0; @@ -173,7 +177,7 @@ int main(int argc, const char *argv[]) } catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; - } +} #else (void)argc; (void)argv; diff --git a/tutorial/grabber/tutorial-grabber-CMU1394.cpp b/tutorial/grabber/tutorial-grabber-CMU1394.cpp index e0b00f7a1c..979e2e750b 100644 --- a/tutorial/grabber/tutorial-grabber-CMU1394.cpp +++ b/tutorial/grabber/tutorial-grabber-CMU1394.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-CMU1394.cpp */ +#include #include #include #include @@ -6,6 +7,9 @@ int main() { #ifdef VISP_HAVE_CMU1394 +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { vpImage I; @@ -31,7 +35,8 @@ int main() if (vpDisplay::getClick(I, false)) // A click to exit break; } - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } #else diff --git a/tutorial/grabber/tutorial-grabber-basler-pylon.cpp b/tutorial/grabber/tutorial-grabber-basler-pylon.cpp index dc08bb5b45..6842a3a5df 100644 --- a/tutorial/grabber/tutorial-grabber-basler-pylon.cpp +++ b/tutorial/grabber/tutorial-grabber-basler-pylon.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-basler-pylon.cpp */ +#include #include #include #include @@ -74,6 +75,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_PYLON) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { unsigned int opt_device = 0; std::string opt_type("GigE"); @@ -195,7 +199,7 @@ int main(int argc, const char *argv[]) } catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; - } +} #else (void)argc; (void)argv; diff --git a/tutorial/grabber/tutorial-grabber-bebop2.cpp b/tutorial/grabber/tutorial-grabber-bebop2.cpp index ab2c985e3a..fc830c07a4 100644 --- a/tutorial/grabber/tutorial-grabber-bebop2.cpp +++ b/tutorial/grabber/tutorial-grabber-bebop2.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-bebop2.cpp */ +#include #include #include #include @@ -73,6 +74,9 @@ void usage(const char *argv[], int error) int main(int argc, const char **argv) { #if defined(VISP_HAVE_ARSDK) && defined(VISP_HAVE_FFMPEG) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_seqname; int opt_record_mode = 0; diff --git a/tutorial/grabber/tutorial-grabber-flycapture.cpp b/tutorial/grabber/tutorial-grabber-flycapture.cpp index feb532ddc6..0587053c03 100644 --- a/tutorial/grabber/tutorial-grabber-flycapture.cpp +++ b/tutorial/grabber/tutorial-grabber-flycapture.cpp @@ -1,4 +1,5 @@ //! \example tutorial-grabber-flycapture.cpp +#include #include #include #include @@ -61,6 +62,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_FLYCAPTURE) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_seqname; int opt_record_mode = 0; diff --git a/tutorial/grabber/tutorial-grabber-ids-ueye.cpp b/tutorial/grabber/tutorial-grabber-ids-ueye.cpp index fe6886eec0..69649ac72c 100644 --- a/tutorial/grabber/tutorial-grabber-ids-ueye.cpp +++ b/tutorial/grabber/tutorial-grabber-ids-ueye.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-ids-ueye.cpp */ +#include #include #include #include @@ -108,6 +109,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_UEYE) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { unsigned int opt_device = 0; std::string opt_seqname; @@ -362,7 +366,7 @@ int main(int argc, const char *argv[]) } catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; - } +} #else (void)argc; (void)argv; diff --git a/tutorial/grabber/tutorial-grabber-multiple-realsense.cpp b/tutorial/grabber/tutorial-grabber-multiple-realsense.cpp index c086ec8974..fba367e955 100644 --- a/tutorial/grabber/tutorial-grabber-multiple-realsense.cpp +++ b/tutorial/grabber/tutorial-grabber-multiple-realsense.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-multiple-realsense.cpp */ +#include #include #include #include @@ -14,6 +15,9 @@ int main(int argc, char **argv) { #if defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)) \ && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::vector > type_serial_nb; std::vector cam_found; @@ -116,7 +120,7 @@ int main(int argc, char **argv) if (clicked) { break; } - } +} #else (void)argc; (void)argv; diff --git a/tutorial/grabber/tutorial-grabber-opencv-threaded.cpp b/tutorial/grabber/tutorial-grabber-opencv-threaded.cpp index 78bb337b40..d26379506b 100644 --- a/tutorial/grabber/tutorial-grabber-opencv-threaded.cpp +++ b/tutorial/grabber/tutorial-grabber-opencv-threaded.cpp @@ -2,6 +2,7 @@ //! [capture-multi-threaded declaration] #include +#include #include #include #include @@ -15,6 +16,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Possible capture states typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; //! [capture-multi-threaded declaration] diff --git a/tutorial/grabber/tutorial-grabber-opencv.cpp b/tutorial/grabber/tutorial-grabber-opencv.cpp index c41aab74b1..8d5c7c2398 100644 --- a/tutorial/grabber/tutorial-grabber-opencv.cpp +++ b/tutorial/grabber/tutorial-grabber-opencv.cpp @@ -1,5 +1,6 @@ /*! \example tutorial-grabber-opencv.cpp */ #include +#include #include #include #include @@ -71,6 +72,9 @@ void usage(const char *argv[], int error) // 1 to dial with a second camera attached to the computer int main(int argc, const char *argv[]) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif int opt_device = 0; std::string opt_seqname; int opt_record_mode = 0; @@ -179,7 +183,7 @@ int main(int argc, const char *argv[]) } catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; - } +} #else (void)argc; (void)argv; @@ -190,4 +194,4 @@ int main(int argc, const char *argv[]) std::cout << "This tutorial should be built with c++11 support" << std::endl; #endif #endif -} + } diff --git a/tutorial/grabber/tutorial-grabber-realsense-T265.cpp b/tutorial/grabber/tutorial-grabber-realsense-T265.cpp index 2fab7ac820..ba84aa4f91 100644 --- a/tutorial/grabber/tutorial-grabber-realsense-T265.cpp +++ b/tutorial/grabber/tutorial-grabber-realsense-T265.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-realsense-T265.cpp */ +#include #include #include #include @@ -57,6 +58,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_REALSENSE2) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0)) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_seqname_left = "left-%04d.png", opt_seqname_right = "right-%04d.png"; int opt_record_mode = 0; @@ -170,7 +174,7 @@ int main(int argc, const char *argv[]) } catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; - } +} #else (void)argc; (void)argv; diff --git a/tutorial/grabber/tutorial-grabber-realsense.cpp b/tutorial/grabber/tutorial-grabber-realsense.cpp index 958b866b5f..33079dd2f4 100644 --- a/tutorial/grabber/tutorial-grabber-realsense.cpp +++ b/tutorial/grabber/tutorial-grabber-realsense.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-realsense.cpp */ +#include #include #include #include @@ -77,6 +78,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_REALSENSE) || defined(VISP_HAVE_REALSENSE2) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_seqname; int opt_record_mode = 0; diff --git a/tutorial/grabber/tutorial-grabber-rgbd-D435-structurecore.cpp b/tutorial/grabber/tutorial-grabber-rgbd-D435-structurecore.cpp index 442aa99755..ae6bffd600 100644 --- a/tutorial/grabber/tutorial-grabber-rgbd-D435-structurecore.cpp +++ b/tutorial/grabber/tutorial-grabber-rgbd-D435-structurecore.cpp @@ -1,6 +1,7 @@ /*! \example tutorial-grabber-rgbd-D435-structurecore.cpp */ #include +#include #include #include #include @@ -13,6 +14,9 @@ int main(int argc, char **argv) { #if defined(VISP_HAVE_REALSENSE2) && defined(VISP_HAVE_OCCIPITAL_STRUCTURE) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // Both cameras can stream color and depth in 640x480 resolution. unsigned int width = 640, height = 480; @@ -68,8 +72,8 @@ int main(int argc, char **argv) if (vpDisplay::getClick(I_color_rs, false) || vpDisplay::getClick(I_color_sc, false) || vpDisplay::getClick(I_depth_rs, false) || vpDisplay::getClick(I_depth_sc, false)) { break; - } - } +} +} #else (void)argc; (void)argv; diff --git a/tutorial/grabber/tutorial-grabber-structure-core.cpp b/tutorial/grabber/tutorial-grabber-structure-core.cpp index f3e9417d62..b2b98db961 100644 --- a/tutorial/grabber/tutorial-grabber-structure-core.cpp +++ b/tutorial/grabber/tutorial-grabber-structure-core.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-structure-core.cpp */ +#include #include #include #include @@ -73,6 +74,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_OCCIPITAL_STRUCTURE) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string opt_seqname_visible = "visible-%04d.png", opt_seqname_depth = "depth-%04d.png"; int opt_record_mode = 0; diff --git a/tutorial/grabber/tutorial-grabber-v4l2-threaded.cpp b/tutorial/grabber/tutorial-grabber-v4l2-threaded.cpp index f607f1da63..a2d5c49357 100644 --- a/tutorial/grabber/tutorial-grabber-v4l2-threaded.cpp +++ b/tutorial/grabber/tutorial-grabber-v4l2-threaded.cpp @@ -1,6 +1,7 @@ //! \example tutorial-grabber-v4l2-threaded.cpp //! [capture-multi-threaded declaration] #include +#include #include #include #include @@ -11,6 +12,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; //! [capture-multi-threaded declaration] diff --git a/tutorial/grabber/tutorial-grabber-v4l2.cpp b/tutorial/grabber/tutorial-grabber-v4l2.cpp index a65213fd7a..2671185948 100644 --- a/tutorial/grabber/tutorial-grabber-v4l2.cpp +++ b/tutorial/grabber/tutorial-grabber-v4l2.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-grabber-v4l2.cpp */ +#include #include #include #include @@ -77,6 +78,9 @@ void usage(const char *argv[], int error) int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_THREADS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { int opt_device = 0; unsigned int opt_scale = 1; // Default value is 2 in the constructor. Turn diff --git a/tutorial/grabber/tutorial-video-reader.cpp b/tutorial/grabber/tutorial-video-reader.cpp index 38fdaf40dd..5dec916e84 100644 --- a/tutorial/grabber/tutorial-video-reader.cpp +++ b/tutorial/grabber/tutorial-video-reader.cpp @@ -1,4 +1,5 @@ //! \example tutorial-video-reader.cpp +#include #include //! [Include] #include @@ -14,6 +15,9 @@ int main(int argc, char **argv) { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_VIDEOIO) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::string videoname = "video.mp4"; diff --git a/tutorial/grabber/tutorial-video-recorder.cpp b/tutorial/grabber/tutorial-video-recorder.cpp index 7fb3501604..32b3e79de9 100644 --- a/tutorial/grabber/tutorial-video-recorder.cpp +++ b/tutorial/grabber/tutorial-video-recorder.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-video-recorder.cpp */ +#include #include #include #include @@ -29,6 +30,9 @@ int main(int argc, const char *argv[]) { #if (defined(VISP_HAVE_V4L2) || defined(HAVE_OPENCV_VIDEOIO)) && defined(VISP_HAVE_DISPLAY) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string opt_videoname = "video-recorded.mpg"; int opt_device = 0; diff --git a/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp b/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp index 215b37d28b..90284a0641 100644 --- a/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp +++ b/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.cpp @@ -12,6 +12,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + //! [Z coordinates computation] double zFunction(const double &x, const double &y, const unsigned int order) { diff --git a/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.h b/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.h index f66ef3041e..6dc62e71cb 100644 --- a/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.h +++ b/tutorial/gui/pcl-visualizer/ClassUsingPclViewer.h @@ -12,9 +12,9 @@ class ClassUsingPclViewer { private: - vpTranslationVector m_t; /*!< The translation between the noise-free point cloud and the possibly noisy, translated + rotated one*/ - vpRotationMatrix m_R; /*!< The rotation between the noise-free point cloud and the possibly noisy, translated + rotated one*/ - vpHomogeneousMatrix m_cMo; /*!< The homogeneous matrix expressing the pose of the noise-free point cloud with regard to the possibly noisy, translated + rotated one.*/ + VISP_NAMESPACE_ADDRESSING vpTranslationVector m_t; /*!< The translation between the noise-free point cloud and the possibly noisy, translated + rotated one*/ + VISP_NAMESPACE_ADDRESSING vpRotationMatrix m_R; /*!< The rotation between the noise-free point cloud and the possibly noisy, translated + rotated one*/ + VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix m_cMo; /*!< The homogeneous matrix expressing the pose of the noise-free point cloud with regard to the possibly noisy, translated + rotated one.*/ double m_minX; /*!< The minimum value of the X coordinate, expressed in the noise-free frame.*/ double m_maxX; /*!< The maximum value of the X coordinate, expressed in the noise-free frame.*/ @@ -25,7 +25,7 @@ class ClassUsingPclViewer unsigned int m_m; /*!< Number of points along the Y-axis.*/ double m_dY; // m_dY = (m_maxY - m_minY)/(m_m-1) - vpPclViewer m_visualizer; /*!< The PCL-based visualizer.*/ + VISP_NAMESPACE_ADDRESSING vpPclViewer m_visualizer; /*!< The PCL-based visualizer.*/ /** * @brief Generate a noise-free grid of point, and a possibly noisy one, which is translated and rotated with regarded to the noise-free one. @@ -34,7 +34,7 @@ class ClassUsingPclViewer * @param order The order of the polynomial surface that is generated. * @return std::pair */ - std::pair generateControlPoints(const double &addedNoise, const unsigned int &order, vpColVector &confidenceWeights); + std::pair generateControlPoints(const double &addedNoise, const unsigned int &order, VISP_NAMESPACE_ADDRESSING vpColVector &confidenceWeights); public: /** * @brief Construct a new object. diff --git a/tutorial/gui/pcl-visualizer/tutorial-pcl-viewer.cpp b/tutorial/gui/pcl-visualizer/tutorial-pcl-viewer.cpp index 03023ea6e3..5cb95bcd54 100644 --- a/tutorial/gui/pcl-visualizer/tutorial-pcl-viewer.cpp +++ b/tutorial/gui/pcl-visualizer/tutorial-pcl-viewer.cpp @@ -14,6 +14,10 @@ #include "ClassUsingPclViewer.h" //! [Class include] +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + //! [Enum for mode choice] /** * @brief Enumeration permitting to choose between running the blocking-mode display diff --git a/tutorial/image/drawingHelpers.cpp b/tutorial/image/drawingHelpers.cpp index 5cff95008e..2737a6cd9c 100644 --- a/tutorial/image/drawingHelpers.cpp +++ b/tutorial/image/drawingHelpers.cpp @@ -32,6 +32,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + #if defined(VISP_HAVE_X11) vpDisplayX drawingHelpers::d_Iinput; vpDisplayX drawingHelpers::d_dIx; diff --git a/tutorial/image/drawingHelpers.h b/tutorial/image/drawingHelpers.h index cc2619554a..3b2c618e78 100644 --- a/tutorial/image/drawingHelpers.h +++ b/tutorial/image/drawingHelpers.h @@ -30,6 +30,7 @@ #ifndef _drawingHelpers_h_ #define _drawingHelpers_h_ +#include #include #include #include @@ -38,35 +39,35 @@ namespace drawingHelpers { #if defined(VISP_HAVE_X11) -extern vpDisplayX d_Iinput; -extern vpDisplayX d_dIx; -extern vpDisplayX d_dIy; -extern vpDisplayX d_IcannyVisp; -extern vpDisplayX d_IcannyImgFilter; +extern VISP_NAMESPACE_ADDRESSING vpDisplayX d_Iinput; +extern VISP_NAMESPACE_ADDRESSING vpDisplayX d_dIx; +extern VISP_NAMESPACE_ADDRESSING vpDisplayX d_dIy; +extern VISP_NAMESPACE_ADDRESSING vpDisplayX d_IcannyVisp; +extern VISP_NAMESPACE_ADDRESSING vpDisplayX d_IcannyImgFilter; #elif defined(HAVE_OPENCV_HIGHGUI) -extern vpDisplayOpenCV d_Iinput; -extern vpDisplayOpenCV d_dIx; -extern vpDisplayOpenCV d_dIy; -extern vpDisplayOpenCV d_IcannyVisp; -extern vpDisplayOpenCV d_IcannyImgFilter; +extern VISP_NAMESPACE_ADDRESSING vpDisplayOpenCV d_Iinput; +extern VISP_NAMESPACE_ADDRESSING vpDisplayOpenCV d_dIx; +extern VISP_NAMESPACE_ADDRESSING vpDisplayOpenCV d_dIy; +extern VISP_NAMESPACE_ADDRESSING vpDisplayOpenCV d_IcannyVisp; +extern VISP_NAMESPACE_ADDRESSING vpDisplayOpenCV d_IcannyImgFilter; #elif defined(VISP_HAVE_GTK) -extern vpDisplayGTK d_Iinput; -extern vpDisplayGTK d_dIx; -extern vpDisplayGTK d_dIy; -extern vpDisplayGTK d_IcannyVisp; -extern vpDisplayGTK d_IcannyImgFilter; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGTK d_Iinput; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGTK d_dIx; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGTK d_dIy; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGTK d_IcannyVisp; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGTK d_IcannyImgFilter; #elif defined(VISP_HAVE_GDI) -extern vpDisplayGDI d_Iinput; -extern vpDisplayGDI d_dIx; -extern vpDisplayGDI d_dIy; -extern vpDisplayGDI d_IcannyVisp; -extern vpDisplayGDI d_IcannyImgFilter; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGDI d_Iinput; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGDI d_dIx; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGDI d_dIy; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGDI d_IcannyVisp; +extern VISP_NAMESPACE_ADDRESSING vpDisplayGDI d_IcannyImgFilter; #elif defined(VISP_HAVE_D3D9) -extern vpDisplayD3D d_Iinput; -extern vpDisplayD3D d_dIx; -extern vpDisplayD3D d_dIy; -extern vpDisplayD3D d_IcannyVisp; -extern vpDisplayD3D d_IcannyImgFilter; +extern VISP_NAMESPACE_ADDRESSING vpDisplayD3D d_Iinput; +extern VISP_NAMESPACE_ADDRESSING vpDisplayD3D d_dIx; +extern VISP_NAMESPACE_ADDRESSING vpDisplayD3D d_dIy; +extern VISP_NAMESPACE_ADDRESSING vpDisplayD3D d_IcannyVisp; +extern VISP_NAMESPACE_ADDRESSING vpDisplayD3D d_IcannyImgFilter; #endif /** @@ -79,8 +80,8 @@ extern vpDisplayD3D d_IcannyImgFilter; * \param[out] p_IcannyimgFilter If different from nullptr, pointer towards the result of the vpImageFilter::canny * method. */ -void init(vpImage &Iinput, vpImage &IcannyVisp, vpImage *p_dIx, - vpImage *p_dIy, vpImage *p_IcannyimgFilter); +void init(VISP_NAMESPACE_ADDRESSING vpImage &Iinput, VISP_NAMESPACE_ADDRESSING vpImage &IcannyVisp, VISP_NAMESPACE_ADDRESSING vpImage *p_dIx, + VISP_NAMESPACE_ADDRESSING vpImage *p_dIy, VISP_NAMESPACE_ADDRESSING vpImage *p_IcannyimgFilter); /** * \brief Display a gray-scale image. @@ -88,7 +89,7 @@ void init(vpImage &Iinput, vpImage &IcannyVisp, vp * \param[out] I The gray-scale image to display. * \param[in] title The title of the window. */ -void display(vpImage &I, const std::string &title); +void display(VISP_NAMESPACE_ADDRESSING vpImage &I, const std::string &title); /** * \brief Catch the user clicks to know if the user wants to stop the program. @@ -98,7 +99,7 @@ void display(vpImage &I, const std::string &title); * \return true The user wants to continue the application. * \return false The user wants to stop the application. */ -bool waitForClick(const vpImage &I, const bool &blockingMode); +bool waitForClick(const VISP_NAMESPACE_ADDRESSING vpImage &I, const bool &blockingMode); } #endif diff --git a/tutorial/image/tutorial-canny.cpp b/tutorial/image/tutorial-canny.cpp index 0513b49ef2..ee606553fa 100644 --- a/tutorial/image/tutorial-canny.cpp +++ b/tutorial/image/tutorial-canny.cpp @@ -41,6 +41,10 @@ #include "drawingHelpers.h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + template void computeMeanMaxStdev(const vpImage &I, float &mean, float &max, float &stdev) { diff --git a/tutorial/image/tutorial-draw-circle.cpp b/tutorial/image/tutorial-draw-circle.cpp index ac8bc89203..02e5893277 100644 --- a/tutorial/image/tutorial-draw-circle.cpp +++ b/tutorial/image/tutorial-draw-circle.cpp @@ -1,10 +1,15 @@ //! \example tutorial-draw-circle.cpp +#include #include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); vpImage I_rgb(2160, 3840, vpColor(0, 0, 0)); @@ -46,9 +51,9 @@ int main() #if defined(VISP_HAVE_DISPLAY) if (d) { delete d; - } -#endif } +#endif + } { //! [Circle draw color] @@ -73,9 +78,9 @@ int main() #if defined(VISP_HAVE_DISPLAY) if (d) { delete d; - } -#endif } +#endif +} } catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; diff --git a/tutorial/image/tutorial-draw-cross.cpp b/tutorial/image/tutorial-draw-cross.cpp index 4e5d9b8b82..e09c7cdbe3 100644 --- a/tutorial/image/tutorial-draw-cross.cpp +++ b/tutorial/image/tutorial-draw-cross.cpp @@ -1,8 +1,13 @@ //! \example tutorial-draw-cross.cpp +#include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); try { diff --git a/tutorial/image/tutorial-draw-frame.cpp b/tutorial/image/tutorial-draw-frame.cpp index 051cf39e5e..f5279f87ea 100644 --- a/tutorial/image/tutorial-draw-frame.cpp +++ b/tutorial/image/tutorial-draw-frame.cpp @@ -1,10 +1,15 @@ //! \example tutorial-draw-frame.cpp +#include #include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); try { @@ -20,7 +25,7 @@ int main() double dTheta = 45; double dOffset = 0.25; - std::string axisName[3] = {"x", "y", "z"}; + std::string axisName[3] = { "x", "y", "z" }; double px = 600; double py = 600; double u0 = 320; double v0 = 240; @@ -28,13 +33,11 @@ int main() vpCameraParameters cam; // Camera initialization with a perspective projection without distortion model - cam.initPersProjWithoutDistortion(px,py,u0,v0); + cam.initPersProjWithoutDistortion(px, py, u0, v0); - for(unsigned int idAxis = 0; idAxis < 3; idAxis ++) - { + for (unsigned int idAxis = 0; idAxis < 3; idAxis++) { unsigned int tOffset = 0; - for(double theta = -180; theta < 180; theta += dTheta) - { + for (double theta = -180; theta < 180; theta += dTheta) { vpTranslationVector t(0.05, 0.25 * (idAxis + 1), 0.37); vpRxyzVector r(0, 0, 0); t[0] = t[0] + tOffset * dOffset; @@ -49,7 +52,7 @@ int main() ss_name << axisName[idAxis]; //! [frame] - vpDisplay::displayFrame(I, cMo, cam, 0.1, vpColor::none, 1, vpImagePoint(), ss_name.str(), vpColor::yellow, vpImagePoint(40,40)); + vpDisplay::displayFrame(I, cMo, cam, 0.1, vpColor::none, 1, vpImagePoint(), ss_name.str(), vpColor::yellow, vpImagePoint(40, 40)); //! [frame] } } @@ -57,7 +60,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-draw-line.cpp b/tutorial/image/tutorial-draw-line.cpp index 438ffaa585..a821dc742f 100644 --- a/tutorial/image/tutorial-draw-line.cpp +++ b/tutorial/image/tutorial-draw-line.cpp @@ -1,9 +1,14 @@ //! \example tutorial-draw-line.cpp +#include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); try { @@ -23,7 +28,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-draw-point.cpp b/tutorial/image/tutorial-draw-point.cpp index fd4aaaad8b..0ef2f483cd 100644 --- a/tutorial/image/tutorial-draw-point.cpp +++ b/tutorial/image/tutorial-draw-point.cpp @@ -1,9 +1,13 @@ //! \example tutorial-draw-point.cpp +#include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpImage I(2160, 3840, 128); try { @@ -22,7 +26,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-draw-rectangle.cpp b/tutorial/image/tutorial-draw-rectangle.cpp index d9d463a90e..6df992720b 100644 --- a/tutorial/image/tutorial-draw-rectangle.cpp +++ b/tutorial/image/tutorial-draw-rectangle.cpp @@ -1,9 +1,13 @@ //! \example tutorial-draw-rectangle.cpp +#include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpImage I(2160, 3840, 128); try { @@ -23,7 +27,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { +} + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-draw-text.cpp b/tutorial/image/tutorial-draw-text.cpp index b93b4ea4f0..7a7533abff 100644 --- a/tutorial/image/tutorial-draw-text.cpp +++ b/tutorial/image/tutorial-draw-text.cpp @@ -1,9 +1,14 @@ //! \example tutorial-draw-text.cpp +#include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); try { @@ -24,7 +29,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-event-keyboard.cpp b/tutorial/image/tutorial-event-keyboard.cpp index e89f724b51..719f8ac168 100644 --- a/tutorial/image/tutorial-event-keyboard.cpp +++ b/tutorial/image/tutorial-event-keyboard.cpp @@ -1,4 +1,5 @@ //! \example tutorial-event-keyboard.cpp +#include #include #include #include @@ -7,6 +8,10 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(240, 320); // Create a black image #if defined(VISP_HAVE_X11) vpDisplay *d = new vpDisplayX; diff --git a/tutorial/image/tutorial-export-image.cpp b/tutorial/image/tutorial-export-image.cpp index 83c292ac55..a2da8e9d88 100644 --- a/tutorial/image/tutorial-export-image.cpp +++ b/tutorial/image/tutorial-export-image.cpp @@ -1,4 +1,5 @@ //! \example tutorial-export-image.cpp +#include #include #include #include @@ -8,6 +9,10 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(240, 320, 255); // Create a black grey level image vpImage Ioverlay; diff --git a/tutorial/image/tutorial-image-colormap.cpp b/tutorial/image/tutorial-image-colormap.cpp index 0145bab17c..6c0ad762f1 100644 --- a/tutorial/image/tutorial-image-colormap.cpp +++ b/tutorial/image/tutorial-image-colormap.cpp @@ -1,6 +1,7 @@ /*! \example tutorial-image-colormap.cpp */ #include #include +#include #include #include #include @@ -11,6 +12,9 @@ int main() { #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { std::map colormaps_str = { {vpColormap::COLORMAP_AUTUMN, "Colormap Autumn"}, diff --git a/tutorial/image/tutorial-image-converter.cpp b/tutorial/image/tutorial-image-converter.cpp index 59e5a9bf9d..08c82c38b8 100644 --- a/tutorial/image/tutorial-image-converter.cpp +++ b/tutorial/image/tutorial-image-converter.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-image-converter.cpp */ +#include #include #include @@ -10,6 +11,9 @@ int main() { #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_HIGHGUI) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_IMGCODECS) +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif try { cv::Mat A; #if VISP_HAVE_OPENCV_VERSION >= 0x030200 diff --git a/tutorial/image/tutorial-image-display-scaled-auto.cpp b/tutorial/image/tutorial-image-display-scaled-auto.cpp index ec79c42dc6..56b19ce47e 100644 --- a/tutorial/image/tutorial-image-display-scaled-auto.cpp +++ b/tutorial/image/tutorial-image-display-scaled-auto.cpp @@ -1,9 +1,14 @@ //! \example tutorial-image-display-scaled-auto.cpp +#include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); try { @@ -23,7 +28,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-image-display-scaled-manu.cpp b/tutorial/image/tutorial-image-display-scaled-manu.cpp index cb02b1f6d3..89dc444311 100644 --- a/tutorial/image/tutorial-image-display-scaled-manu.cpp +++ b/tutorial/image/tutorial-image-display-scaled-manu.cpp @@ -1,9 +1,14 @@ //! \example tutorial-image-display-scaled-manu.cpp +#include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); try { @@ -20,7 +25,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-image-display.cpp b/tutorial/image/tutorial-image-display.cpp index 55b5c8fa3b..fd96c43e61 100644 --- a/tutorial/image/tutorial-image-display.cpp +++ b/tutorial/image/tutorial-image-display.cpp @@ -1,9 +1,14 @@ //! \example tutorial-image-display.cpp +#include #include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage I(2160, 3840, 128); try { @@ -19,7 +24,8 @@ int main() vpDisplay::flush(I); std::cout << "A click to quit..." << std::endl; vpDisplay::getClick(I); - } catch (const vpException &e) { +} + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; } } diff --git a/tutorial/image/tutorial-image-filter.cpp b/tutorial/image/tutorial-image-filter.cpp index 6c0522d15d..fba5382461 100644 --- a/tutorial/image/tutorial-image-filter.cpp +++ b/tutorial/image/tutorial-image-filter.cpp @@ -1,5 +1,5 @@ //! \example tutorial-image-filter.cpp - +#include #include #include #include @@ -8,6 +8,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void display(vpImage &I, const std::string &title); void display(vpImage &D, const std::string &title); diff --git a/tutorial/image/tutorial-image-manipulation.cpp b/tutorial/image/tutorial-image-manipulation.cpp index 162ba6837c..1ec8753b58 100644 --- a/tutorial/image/tutorial-image-manipulation.cpp +++ b/tutorial/image/tutorial-image-manipulation.cpp @@ -1,8 +1,13 @@ /*! \example tutorial-image-manipulation.cpp */ +#include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + try { vpImage gray_image(240, 320); vpImage color_image(240, 320); @@ -18,9 +23,10 @@ int main() unsigned int icolor_max = color_image.getHeight() - 1; unsigned int jcolor_max = color_image.getWidth() - 1; std::cout << "Color image, last pixel RGB components: " << (int)color_image[icolor_max][jcolor_max].R << " " - << (int)color_image[icolor_max][jcolor_max].G << " " << (int)color_image[icolor_max][jcolor_max].B - << std::endl; - } catch (const vpException &e) { + << (int)color_image[icolor_max][jcolor_max].G << " " << (int)color_image[icolor_max][jcolor_max].B + << std::endl; + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } } diff --git a/tutorial/image/tutorial-image-reader.cpp b/tutorial/image/tutorial-image-reader.cpp index 3a95dcafb1..0114fc32e4 100644 --- a/tutorial/image/tutorial-image-reader.cpp +++ b/tutorial/image/tutorial-image-reader.cpp @@ -1,15 +1,22 @@ /*! \example tutorial-image-reader.cpp */ +#include #include int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + try { vpImage I; vpImageIo::read(I, "monkey.jpeg"); vpImageIo::write(I, "monkey.png"); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << e.getMessage() << std::endl; - } catch (...) { + } + catch (...) { std::cout << "Unsupported image format" << std::endl; } } diff --git a/tutorial/image/tutorial-image-viewer.cpp b/tutorial/image/tutorial-image-viewer.cpp index 32853d3a33..ce0c0e7d6e 100644 --- a/tutorial/image/tutorial-image-viewer.cpp +++ b/tutorial/image/tutorial-image-viewer.cpp @@ -1,4 +1,5 @@ /*! \example tutorial-image-viewer.cpp */ +#include #include #include #include @@ -7,6 +8,10 @@ int main() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + try { vpImage I; vpImageIo::read(I, "monkey.ppm"); @@ -32,12 +37,14 @@ int main() try { vpImageIo::write(I, "monkey-out.jpg"); vpImageIo::write(O, "monkey-out-with-overlay.jpg"); - } catch (...) { + } + catch (...) { std::cout << "Cannot write the image: unsupported format..." << std::endl; } vpDisplay::getClick(I); - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e << std::endl; } } diff --git a/tutorial/image/tutorial-undistort.cpp b/tutorial/image/tutorial-undistort.cpp index d72b2d8932..938ace2ea3 100644 --- a/tutorial/image/tutorial-undistort.cpp +++ b/tutorial/image/tutorial-undistort.cpp @@ -1,4 +1,5 @@ //! \example tutorial-undistort.cpp +#include #include #include #include @@ -6,6 +7,10 @@ int main(int argc, char **argv) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + std::string opt_input_image = "chessboard.jpg"; std::string opt_camera_file = "camera.xml"; std::string opt_camera_name = "Camera"; diff --git a/tutorial/image/tutorial-video-manipulation.cpp b/tutorial/image/tutorial-video-manipulation.cpp index e63b5799c3..2fdd025f21 100644 --- a/tutorial/image/tutorial-video-manipulation.cpp +++ b/tutorial/image/tutorial-video-manipulation.cpp @@ -1,4 +1,5 @@ //! \example tutorial-video-manipulation.cpp +#include #include #include #include @@ -12,62 +13,66 @@ void usage(const char *argv[], int error) { std::cout << "Synopsis" << std::endl - << " " << argv[0] << " [--in