diff --git a/CMakeLists.txt b/CMakeLists.txt index 300a3b42de..696695995d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -628,6 +628,23 @@ if(USE_PCL) vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES) endif() +# ---------------------------------------------------------------------------- +# Handle OpenCV 2.4.8 as minimal version +# ---------------------------------------------------------------------------- +if(USE_OPENCV) + if(OpenCV_VERSION) + if(OpenCV_VERSION VERSION_LESS "2.4.8") + message(WARNING "OpenCV 3rd party was detected but its version ${OpenCV_VERSION} is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.") + unset(USE_OPENCV) + set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE) + endif() + else() + message(WARNING "OpenCV 3rd party was detected but its version cannot be found or is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.") + unset(USE_OPENCV) + set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE) + endif() +endif() + # ---------------------------------------------------------------------------- # Handle cxx standard depending on specific 3rd parties. Should be before module parsing and VISP3rdParty.cmake include # ---------------------------------------------------------------------------- @@ -642,7 +659,7 @@ endif() if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_14) if(USE_FTIITSDK) - message(WARNING "IIT force-torque SDK 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable IIT force-torque usage turning USE_OPENCV=OFF.") + message(WARNING "IIT force-torque SDK 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable IIT force-torque usage turning USE_FTIITSDK=OFF.") unset(USE_FTIITSDK) set(USE_FTIITSDK OFF CACHE BOOL "Include IIT force-torque SDK support" FORCE) endif() @@ -694,13 +711,14 @@ if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_11) message(WARNING "std::thread was detected but needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable std::thread usage turning USE_THREADS=OFF.") unset(USE_THREADS) set(USE_THREADS OFF CACHE BOOL "Include std::thread support" FORCE) - elseif(UNIX) - # Apriltag on unix needs pthread. On windows we are using pthread built-in - if(Threads_FOUND) - set(USE_PTHREAD ON) # for AprilTag only - endif() endif() endif() + +if(UNIX AND Threads_FOUND) + # Apriltag on unix needs native pthread. On windows we are using pthread built-in + set(USE_PTHREAD ON) # for AprilTag only +endif() + # ---------------------------------------------------------------------------- # Build-in 3rd parties. Should be after c++ standard potential modification # ---------------------------------------------------------------------------- @@ -1732,7 +1750,7 @@ status("") status(" Optimization: ") status(" Use OpenMP:" USE_OPENMP THEN "yes" ELSE "no") status(" Use std::thread:" USE_THREADS THEN "yes" ELSE "no") -status(" Use pthread:" USE_PHREADS THEN "yes" ELSE "no") +status(" Use pthread:" USE_PTHREAD THEN "yes" ELSE "no") status(" Use pthread (built-in):" WITH_PTHREAD THEN "yes (ver ${PTHREADS_VERSION})" ELSE "no") status(" Use simdlib (built-in):" WITH_SIMDLIB THEN "yes" ELSE "no") status("") diff --git a/ChangeLog.txt b/ChangeLog.txt index d8a85ed998..57df379736 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -18,6 +18,7 @@ ViSP 3.x.x (Version in development) . End of supporting c++98 standard. As a consequence, ViSP is no more compatible with Ubuntu 12.04 . vpDisplay::displayCharString() is marked deprecated. Use vpDisplay::displayText() instead - New features and improvements + . OpenCV 2.4.8 is the minimal supported version . Introduce applications in apps folder, a collection of useful tools that have a dependency to the install target . Bump minimal c++ standard to c++11 @@ -30,6 +31,8 @@ ViSP 3.x.x (Version in development) https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-tracking-mb-generic-rgbd-Blender.html . New tutorial: Installation from prebuilt Conda packages for Linux / OSX / Windows https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-conda-package.html + . New tutorial: Using Statistical Process Control to monitor your signal + https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-spc.html - Bug fixed . [#1251] Bug in vpDisplay::displayFrame() . [#1270] Build issue around std::clamp and optional header which are not found with cxx17 @@ -40,6 +43,8 @@ ViSP 3.x.x (Version in development) . [#1279] Issue in vpPoseVector json serialization . [#1296] Unable to parse camera parameters with vpXmlParserCamera::parse() when camera name is empty . [#1307] Cannot set cxx standard when configuring for Visual Studio + . [#1320] Broken links in the documentation + . [#1341] SVD computation fails with Lapack when m < n ---------------------------------------------- ViSP 3.6.0 (released September 22, 2023) - Contributors: diff --git a/cmake/AddExtraCompilationFlags.cmake b/cmake/AddExtraCompilationFlags.cmake index 0cec5eef4e..7adb63f986 100644 --- a/cmake/AddExtraCompilationFlags.cmake +++ b/cmake/AddExtraCompilationFlags.cmake @@ -117,7 +117,8 @@ if(USE_OPENMP) add_extra_compiler_option("${OpenMP_CXX_FLAGS}") endif() -if(USE_THREADS) +if(USE_THREADS OR USE_PTHREAD) + # Condider the case of Apriltags on Unix that needs pthread if(THREADS_HAVE_PTHREAD_ARG) add_extra_compiler_option("-pthread") endif() diff --git a/doc/tutorial/tracking/tutorial-tracking-keypoint.dox b/doc/tutorial/tracking/tutorial-tracking-keypoint.dox index 8b8dc838cf..d89aa57098 100644 --- a/doc/tutorial/tracking/tutorial-tracking-keypoint.dox +++ b/doc/tutorial/tracking/tutorial-tracking-keypoint.dox @@ -35,7 +35,7 @@ It can also be run with [--init-by-click] option. In that case, the user can sel $ ./tutorial-klt-tracker --init-by-click \endcode -Here is the line by line explanation of the source : +Here is the line by line explanation of the source : \snippet tutorial-klt-tracker.cpp Include @@ -60,19 +60,19 @@ This image \c I is then converted into \c cvI, an OpenCV image format that will \snippet tutorial-klt-tracker.cpp Convert to OpenCV image -We also create a window associated to \c I, at position (0,0) in the screen, with "Klt tracking" as title, and display image \c I. +We also create a window associated to \c I, at position (0,0) in the screen, with "Klt tracking" as title, and display image \c I. \snippet tutorial-klt-tracker.cpp Init display - + From now we have to create an instance of the tracker and set the parameters of the Harris keypoint detector. \snippet tutorial-klt-tracker.cpp Create tracker - + The tracker is then initialized on \c cvI image. \snippet tutorial-klt-tracker.cpp Init tracker -With the next line the user can know how many keypoints were detected automatically or selected by the user during initialization. +With the next line the user can know how many keypoints were detected automatically or selected by the user during initialization. \snippet tutorial-klt-tracker.cpp How many features @@ -92,7 +92,7 @@ We are waiting for a mouse click event on image \c I to end the program. \section tracking_keypoint_klt_init KLT tracker with re-initialisation -Once initialized, the number of tracked features decreases over the time. Depending on a criteria, it may sense to detect and track new features online. A possible criteria is for example to compare the number of currently tracked features to the initial number of detected features. If less than a given percentage of features are tracked, you can start a new detection. +Once initialized, the number of tracked features decreases over the time. Depending on a criteria, it may sense to detect and track new features online. A possible criteria is for example to compare the number of currently tracked features to the initial number of detected features. If less than a given percentage of features are tracked, you can start a new detection. To get the number of detected or tracked features just call: @@ -107,10 +107,10 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e \code if (reader.getFrameIndex() == 25) { std::cout << "Re initialize the tracker" << std::endl; -#if (VISP_HAVE_OPENCV_VERSION >= 0x020408) + // Save of previous features std::vector prev_features = tracker.getFeatures(); - + // Start a new feature detection tracker.initTracking(cvI); std::vector new_features = tracker.getFeatures(); @@ -122,7 +122,7 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e // Test if a previous feature is not redundant with one of the newly detected is_redundant = false; for (size_t j=0; j < new_features.size(); j++){ - distance = sqrt(vpMath::sqr(new_features[j].x-prev_features[i].x) + distance = sqrt(vpMath::sqr(new_features[j].x-prev_features[i].x) + vpMath::sqr(new_features[j].y-prev_features[i].y)); if(distance < minDistance_){ is_redundant = true; @@ -135,9 +135,6 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e //std::cout << "Add previous feature with index " << i << std::endl; tracker.addFeature(prev_features[i]); } -#else - ... -#endif } // Track the features tracker.track(cvI); diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 592d13f381..884f6bae92 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -71,7 +71,7 @@ visp_add_subdirectory(direct-visual-servoing REQUIRED_DEPS visp_core visp_robo visp_add_subdirectory(homography REQUIRED_DEPS visp_core visp_vision visp_io) visp_add_subdirectory(image REQUIRED_DEPS visp_core visp_io) visp_add_subdirectory(manual REQUIRED_DEPS visp_core visp_sensor visp_vs visp_robot visp_ar visp_vision visp_io visp_gui) -visp_add_subdirectory(math REQUIRED_DEPS visp_core visp_vision visp_io) +visp_add_subdirectory(math REQUIRED_DEPS visp_core visp_io) visp_add_subdirectory(moments/image REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui) visp_add_subdirectory(moments/points REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui) visp_add_subdirectory(moments/polygon REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui) diff --git a/example/math/quadprog.cpp b/example/math/quadprog.cpp index 58c96eb47b..6d89a741a2 100644 --- a/example/math/quadprog.cpp +++ b/example/math/quadprog.cpp @@ -105,7 +105,7 @@ int main(int argc, char **argv) r = randV(o) * 5; C = randM(p, n) * 5; - // make sure Cx <= d has a solution within Ax = b + // make sure Cx <= d has a solution within Ax = b vpColVector x = A.solveBySVD(b); d = C * x; for (int i = 0; i < p; ++i) diff --git a/example/math/quadprog_eq.cpp b/example/math/quadprog_eq.cpp index 0605f4e7c6..72d9ef40b1 100644 --- a/example/math/quadprog_eq.cpp +++ b/example/math/quadprog_eq.cpp @@ -105,6 +105,7 @@ int main(int argc, char **argv) C = randM(p, n) * 5; // make sure Cx <= d has a solution within Ax = b + vpColVector x = A.solveBySVD(b); d = C * x; for (int i = 0; i < p; ++i) diff --git a/modules/core/include/visp3/core/vpArray2D.h b/modules/core/include/visp3/core/vpArray2D.h index 5847aca8db..1644e15f37 100644 --- a/modules/core/include/visp3/core/vpArray2D.h +++ b/modules/core/include/visp3/core/vpArray2D.h @@ -320,7 +320,14 @@ template class vpArray2D // Reallocation of this->data array this->dsize = nrows * ncols; - this->data = (Type *)realloc(this->data, this->dsize * sizeof(Type)); + Type *tmp_data = reinterpret_cast(realloc(this->data, this->dsize * sizeof(Type))); + if (tmp_data) { + this->data = tmp_data; + } + else { + this->data = nullptr; + } + if ((nullptr == this->data) && (0 != this->dsize)) { if (copyTmp != nullptr) { delete[] copyTmp; @@ -328,7 +335,13 @@ template class vpArray2D throw(vpException(vpException::memoryAllocationError, "Memory allocation error when allocating 2D array data")); } - this->rowPtrs = (Type **)realloc(this->rowPtrs, nrows * sizeof(Type *)); + Type **tmp_rowPtrs = reinterpret_cast(realloc(this->rowPtrs, nrows * sizeof(Type *))); + if (tmp_rowPtrs) { + this->rowPtrs = tmp_rowPtrs; + } + else { + this->rowPtrs = nullptr; + } if ((nullptr == this->rowPtrs) && (0 != this->dsize)) { if (copyTmp != nullptr) { delete[] copyTmp; @@ -389,11 +402,18 @@ template class vpArray2D rowNum = nrows; colNum = ncols; - rowPtrs = reinterpret_cast(realloc(rowPtrs, nrows * sizeof(Type *))); - // Update rowPtrs - Type **t_ = rowPtrs; - for (unsigned int i = 0; i < dsize; i += ncols) { - *t_++ = data + i; + if (rowPtrs) { + Type **tmp = reinterpret_cast(realloc(rowPtrs, nrows * sizeof(Type *))); + if (tmp) { + this->rowPtrs = tmp; + } + } + if (rowPtrs) { + // Update rowPtrs + Type **t_ = rowPtrs; + for (unsigned int i = 0; i < dsize; i += ncols) { + *t_++ = data + i; + } } } @@ -458,8 +478,12 @@ template class vpArray2D vpArray2D &operator=(vpArray2D &&other) noexcept { if (this != &other) { - free(data); - free(rowPtrs); + if (data) { + free(data); + } + if (rowPtrs) { + free(rowPtrs); + } rowNum = other.rowNum; colNum = other.colNum; diff --git a/modules/core/include/visp3/core/vpHinkley.h b/modules/core/include/visp3/core/vpHinkley.h index 6d9ee47e07..046e6fa8ae 100644 --- a/modules/core/include/visp3/core/vpHinkley.h +++ b/modules/core/include/visp3/core/vpHinkley.h @@ -43,6 +43,7 @@ #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) /*! \class vpHinkley + \deprecated This class is deprecated. You should rather use vpStatisticalTestHinkley. \ingroup group_core_math_tools \brief This class implements the Hinkley's cumulative sum test. @@ -89,7 +90,7 @@ N_{k^{'}} = 0 \f$. */ -class vp_deprecated vpHinkley +class VISP_EXPORT vpHinkley { public: /*! \enum vpHinkleyJumpType @@ -103,9 +104,9 @@ class vp_deprecated vpHinkley } vpHinkleyJumpType; public: - vpHinkley(); + vp_deprecated vpHinkley(); virtual ~vpHinkley(); - vpHinkley(double alpha, double delta); + vp_deprecated vpHinkley(double alpha, double delta); void init(); void init(double alpha, double delta); diff --git a/modules/core/include/visp3/core/vpImage.h b/modules/core/include/visp3/core/vpImage.h index 7962847d84..db1cb3d1d1 100644 --- a/modules/core/include/visp3/core/vpImage.h +++ b/modules/core/include/visp3/core/vpImage.h @@ -844,7 +844,9 @@ vpImage::vpImage(const vpImage &I) : bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true) { resize(I.getHeight(), I.getWidth()); - memcpy(static_cast(bitmap), static_cast(I.bitmap), I.npixels * sizeof(Type)); + if (bitmap) { + memcpy(static_cast(bitmap), static_cast(I.bitmap), I.npixels * sizeof(Type)); + } } #if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher diff --git a/modules/core/include/visp3/core/vpImageConvert.h b/modules/core/include/visp3/core/vpImageConvert.h index 1e566d531a..6d48456f6b 100644 --- a/modules/core/include/visp3/core/vpImageConvert.h +++ b/modules/core/include/visp3/core/vpImageConvert.h @@ -49,7 +49,7 @@ #include #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) -#include +#include #include #endif diff --git a/modules/core/include/visp3/core/vpImageFilter.h b/modules/core/include/visp3/core/vpImageFilter.h index ee989955fa..ca778c813f 100644 --- a/modules/core/include/visp3/core/vpImageFilter.h +++ b/modules/core/include/visp3/core/vpImageFilter.h @@ -88,7 +88,7 @@ class VISP_EXPORT vpImageFilter } else { // Need to reset the image because some points will not be computed - I.resize(height, width, static_cast(0.)); + I.resize(height, width, static_cast(0)); } } @@ -227,7 +227,7 @@ class VISP_EXPORT vpImageFilter cv::Mat cv_I, cv_dIx, cv_dIy; vpImageConvert::convert(I, cv_I); computePartialDerivatives(cv_I, cv_dIx, cv_dIy, computeDx, computeDy, normalize, gaussianKernelSize, - gaussianStdev, apertureGradient, filteringType); + static_cast(gaussianStdev), apertureGradient, filteringType); if (computeDx) { vpImageConvert::convert(cv_dIx, dIx); } @@ -796,9 +796,9 @@ class VISP_EXPORT vpImageFilter FilterType result = static_cast(0.); for (unsigned int i = 1; i <= stop; ++i) { - result += filter[i] * static_cast(I[r][c + i] + I[r][c - i]); + result += filter[i] * static_cast(I[r][c + i] + I[r][c - i]); } - return result + filter[0] * static_cast(I[r][c]); + return result + filter[0] * static_cast(I[r][c]); } #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/modules/core/include/visp3/core/vpImageTools.h b/modules/core/include/visp3/core/vpImageTools.h index 6c8fa38269..58a910d885 100644 --- a/modules/core/include/visp3/core/vpImageTools.h +++ b/modules/core/include/visp3/core/vpImageTools.h @@ -57,6 +57,7 @@ #include #include #include +#include #if defined(_OPENMP) #include @@ -1113,12 +1114,12 @@ void vpImageTools::resize(const vpImage &I, vpImage &Ires, const vpI #endif for (int i = 0; i < static_cast(Ires.getHeight()); i++) { const float v = (i + half) * scaleY - half; - const int v0 = static_cast(v); + const float v0 = std::floor(v); const float yFrac = v - v0; for (unsigned int j = 0; j < Ires.getWidth(); j++) { const float u = (j + half) * scaleX - half; - const int u0 = static_cast(u); + const float u0 = std::floor(u); const float xFrac = u - u0; if (method == INTERPOLATION_NEAREST) { diff --git a/modules/core/include/visp3/core/vpMunkres.h b/modules/core/include/visp3/core/vpMunkres.h index 802994da05..6d27fd48d2 100644 --- a/modules/core/include/visp3/core/vpMunkres.h +++ b/modules/core/include/visp3/core/vpMunkres.h @@ -314,8 +314,8 @@ inline vpMunkres::STEP_T vpMunkres::stepSix(std::vector > &cos template inline std::vector > vpMunkres::run(std::vector > costs) { - const auto original_row_size = costs.size(); - const auto original_col_size = costs.front().size(); + const auto original_row_size = static_cast(costs.size()); + const auto original_col_size = static_cast(costs.front().size()); const auto sq_size = std::max(original_row_size, original_col_size); auto mask = std::vector >( diff --git a/modules/core/include/visp3/core/vpRxyzVector.h b/modules/core/include/visp3/core/vpRxyzVector.h index 9c13ec776c..2a72c79a65 100644 --- a/modules/core/include/visp3/core/vpRxyzVector.h +++ b/modules/core/include/visp3/core/vpRxyzVector.h @@ -137,37 +137,37 @@ class vpThetaUVector; from the build rotation matrix. \code -#include -#include -#include -#include + #include + #include + #include + #include -int main() -{ - vpRxyzVector rxyz; + int main() + { + vpRxyzVector rxyz; - // Initialise the Euler angles - rxyz[0] = vpMath::rad( 45.f); // phi angle in rad around x axis - rxyz[1] = vpMath::rad(-30.f); // theta angle in rad around y axis - rxyz[2] = vpMath::rad( 90.f); // psi angle in rad around z axis + // Initialise the Euler angles + rxyz[0] = vpMath::rad( 45.f); // phi angle in rad around x axis + rxyz[1] = vpMath::rad(-30.f); // theta angle in rad around y axis + rxyz[2] = vpMath::rad( 90.f); // psi angle in rad around z axis - // Construct a rotation matrix from the Euler angles - vpRotationMatrix R(rxyz); + // Construct a rotation matrix from the Euler angles + vpRotationMatrix R(rxyz); - // Extract the Euler angles around x,y,z axis from a rotation matrix - rxyz.buildFrom(R); + // Extract the Euler angles around x,y,z axis from a rotation matrix + rxyz.buildFrom(R); - // Print the extracted Euler angles. Values are the same than the - // one used for initialization - std::cout << rxyz; + // Print the extracted Euler angles. Values are the same than the + // one used for initialization + std::cout << rxyz; - // Since the rotation vector is 3 values column vector, the - // transpose operation produce a row vector. - vpRowVector rxyz_t = rxyz.t(); + // Since the rotation vector is 3 values column vector, the + // transpose operation produce a row vector. + vpRowVector rxyz_t = rxyz.t(); - // Print the transpose row vector - std::cout << rxyz_t << std::endl; -} + // Print the transpose row vector + std::cout << rxyz_t << std::endl; + } \endcode */ diff --git a/modules/core/include/visp3/core/vpStatisticalTestAbstract.h b/modules/core/include/visp3/core/vpStatisticalTestAbstract.h index dbf9604a2d..cd7e0454e9 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestAbstract.h +++ b/modules/core/include/visp3/core/vpStatisticalTestAbstract.h @@ -1,7 +1,7 @@ /**************************************************************************** * * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * -*****************************************************************************/ + */ + /*! * \file vpStatisticalTestAbstract.h * \brief Base class for Statistical Process Control methods implementation. diff --git a/modules/core/include/visp3/core/vpStatisticalTestEWMA.h b/modules/core/include/visp3/core/vpStatisticalTestEWMA.h index 134debf418..63893668c9 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestEWMA.h +++ b/modules/core/include/visp3/core/vpStatisticalTestEWMA.h @@ -1,7 +1,7 @@ /**************************************************************************** * * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * -*****************************************************************************/ + */ + /*! * \file vpStatisticalTestEWMA.h * \brief Statistical Process Control Exponentially Weighted Moving Average implementation. diff --git a/modules/core/include/visp3/core/vpStatisticalTestHinkley.h b/modules/core/include/visp3/core/vpStatisticalTestHinkley.h index e07d4b1591..9a8dcc2724 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestHinkley.h +++ b/modules/core/include/visp3/core/vpStatisticalTestHinkley.h @@ -1,7 +1,7 @@ /**************************************************************************** * * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * -*****************************************************************************/ + */ + /*! * \file vpStatisticalTestHinkley.h * \brief Statistical Process Control Hinkley's test implementation. diff --git a/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h b/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h index fdb9f09ebf..8a39d7d8f0 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h +++ b/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h @@ -1,7 +1,7 @@ /**************************************************************************** * * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * -*****************************************************************************/ + */ + /*! * \file vpStatisticalTestMeanAdjustedCUSUM.h * \brief Statistical Process Control mean adjusted CUSUM implementation. diff --git a/modules/core/include/visp3/core/vpStatisticalTestShewhart.h b/modules/core/include/visp3/core/vpStatisticalTestShewhart.h index 32c543086a..9954831496 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestShewhart.h +++ b/modules/core/include/visp3/core/vpStatisticalTestShewhart.h @@ -1,7 +1,7 @@ /**************************************************************************** * * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * -*****************************************************************************/ + */ + /*! * \file vpStatisticalTestShewhart.h * \brief Statistical Process Control Shewhart's test implementation. diff --git a/modules/core/include/visp3/core/vpStatisticalTestSigma.h b/modules/core/include/visp3/core/vpStatisticalTestSigma.h index 3c0f10facd..210da6eba0 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestSigma.h +++ b/modules/core/include/visp3/core/vpStatisticalTestSigma.h @@ -1,7 +1,7 @@ /**************************************************************************** * * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * -*****************************************************************************/ + */ + /*! * \file vpStatisticalTestSigma.h * \brief Statistical Process Control sigma test implementation. diff --git a/modules/core/src/image/vpImageCircle.cpp b/modules/core/src/image/vpImageCircle.cpp index 2bf69365e5..ffeb35c263 100644 --- a/modules/core/src/image/vpImageCircle.cpp +++ b/modules/core/src/image/vpImageCircle.cpp @@ -1043,7 +1043,7 @@ void incrementIfIsInMask(const vpImage &mask, const int &width, const int unsigned int vpImageCircle::computePixelsInMask(const vpImage &mask) const { - const int xm = m_center.get_u(), ym = m_center.get_v(); + const float xm = static_cast(m_center.get_u()), ym = static_cast(m_center.get_v()); const float r_float = static_cast(m_radius); const int width = mask.getWidth(); const int height = mask.getHeight(); @@ -1073,14 +1073,14 @@ unsigned int vpImageCircle::computePixelsInMask(const vpImage &mask) const float sin_theta = std::sin(theta); float rcos_pos = r_float * cos_theta; float rsin_pos = r_float * sin_theta; - x1 = xm + rcos_pos; // theta - y1 = ym + rsin_pos; // theta - x2 = xm - rsin_pos; // theta + pi - y2 = ym + rcos_pos; // theta + pi - x3 = xm - rcos_pos; // theta + pi/2 - y3 = ym - rsin_pos; // theta + pi/2 - x4 = xm + rsin_pos; // theta + pi - y4 = ym - rcos_pos; // theta + pi + x1 = static_cast(xm + rcos_pos); // theta + y1 = static_cast(ym + rsin_pos); // theta + x2 = static_cast(xm - rsin_pos); // theta + pi + y2 = static_cast(ym + rcos_pos); // theta + pi + x3 = static_cast(xm - rcos_pos); // theta + pi/2 + y3 = static_cast(ym - rsin_pos); // theta + pi/2 + x4 = static_cast(xm + rsin_pos); // theta + pi + y4 = static_cast(ym - rcos_pos); // theta + pi incrementIfIsInMask(mask, width, height, x1, y1, count); incrementIfIsInMask(mask, width, height, x2, y2, count); incrementIfIsInMask(mask, width, height, x3, y3, count); diff --git a/modules/core/src/image/vpImageFilter.cpp b/modules/core/src/image/vpImageFilter.cpp index fffa9016d0..a19508fa56 100644 --- a/modules/core/src/image/vpImageFilter.cpp +++ b/modules/core/src/image/vpImageFilter.cpp @@ -1119,7 +1119,7 @@ void vpImageFilter::canny(const vpImage &Isrc, vpImage @@ -170,18 +169,18 @@ vpRxyzVector vpRxyzVector::buildFrom(const std::vector &rxyz) \param v : Angle value to set for each element of the vector. -\code -#include -#include + \code + #include + #include -int main() -{ - vpRxyzVector v; + int main() + { + vpRxyzVector v; - // Initialise the rotation vector - v = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees -} -\endcode + // Initialise the rotation vector + v = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees + } + \endcode */ vpRxyzVector &vpRxyzVector::operator=(double v) { @@ -196,23 +195,22 @@ vpRxyzVector &vpRxyzVector::operator=(double v) Copy operator that initializes a \f$R_{xyz}=(\varphi,\theta,\psi)\f$ Euler angles vector from a 3-dimension column vector. - \param rxyz : 3-dimension vector containing the values of the rotation -vector. - -\code -#include + \param rxyz : 3-dimension vector containing the values of the rotation vector. -int main() -{ - vpColVector v(3); - v[0] = 0.1; - v[1] = 0.2; - v[2] = 0.3; - vpRxyzVector rxyz; - rxyz = v; - // rxyz is now equal to v : 0.1, 0.2, 0.3 -} -\endcode + \code + #include + + int main() + { + vpColVector v(3); + v[0] = 0.1; + v[1] = 0.2; + v[2] = 0.3; + vpRxyzVector rxyz; + rxyz = v; + // rxyz is now equal to v : 0.1, 0.2, 0.3 + } + \endcode */ vpRxyzVector &vpRxyzVector::operator=(const vpColVector &rxyz) { @@ -230,17 +228,17 @@ vpRxyzVector &vpRxyzVector::operator=(const vpColVector &rxyz) /*! Set vector from a list of 3 double angle values in radians. \code -#include + #include -int main() -{ - vpRxyzVector rxyz = {M_PI, 0, M_PI_2}; - std::cout << "rxyz: " << rxyz.t() << std::endl; -} + int main() + { + vpRxyzVector rxyz = {M_PI, 0, M_PI_2}; + std::cout << "rxyz: " << rxyz.t() << std::endl; + } \endcode It produces the following printings: \code -rxyz: 3.141592654 0 1.570796327 + rxyz: 3.141592654 0 1.570796327 \endcode \sa operator<<() */ diff --git a/modules/core/src/math/transformation/vpRzyxVector.cpp b/modules/core/src/math/transformation/vpRzyxVector.cpp index 523e917e93..1d8c7613e2 100644 --- a/modules/core/src/math/transformation/vpRzyxVector.cpp +++ b/modules/core/src/math/transformation/vpRzyxVector.cpp @@ -176,18 +176,18 @@ vpRzyxVector vpRzyxVector::buildFrom(const std::vector &rzyx) \param v : Angle value to set for each element of the vector. -\code -#include -#include + \code + #include + #include -int main() -{ - vpRzyxVector v; + int main() + { + vpRzyxVector v; - // Initialise the rotation vector - v = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees -} -\endcode + // Initialise the rotation vector + v = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees + } + \endcode */ vpRzyxVector &vpRzyxVector::operator=(double v) { @@ -202,23 +202,22 @@ vpRzyxVector &vpRzyxVector::operator=(double v) Copy operator that initializes a \f$R_{zyx}=(\varphi,\theta,\psi)\f$ Euler angles vector from a 3-dimension column vector. - \param rzyx : 3-dimension vector containing the values of the rotation -vector. - -\code -#include + \param rzyx : 3-dimension vector containing the values of the rotation vector. -int main() -{ - vpColVector v(3); - v[0] = 0.1; - v[1] = 0.2; - v[2] = 0.3; - vpRzyxVector rzyx; - rzyx = v; - // rzyx is now equal to v : 0.1, 0.2, 0.3 -} -\endcode + \code + #include + + int main() + { + vpColVector v(3); + v[0] = 0.1; + v[1] = 0.2; + v[2] = 0.3; + vpRzyxVector rzyx; + rzyx = v; + // rzyx is now equal to v : 0.1, 0.2, 0.3 + } + \endcode */ vpRzyxVector &vpRzyxVector::operator=(const vpColVector &rzyx) { @@ -236,17 +235,17 @@ vpRzyxVector &vpRzyxVector::operator=(const vpColVector &rzyx) /*! Set vector from a list of 3 double angle values in radians. \code -#include + #include -int main() -{ - vpRzyxVector rzyx = {M_PI, 0, M_PI_2}; - std::cout << "rzyx: " << rzyx.t() << std::endl; -} + int main() + { + vpRzyxVector rzyx = {M_PI, 0, M_PI_2}; + std::cout << "rzyx: " << rzyx.t() << std::endl; + } \endcode It produces the following printings: \code -rzyx: 3.141592654 0 1.570796327 + zyx: 3.141592654 0 1.570796327 \endcode \sa operator<<() */ diff --git a/modules/core/src/math/transformation/vpRzyzVector.cpp b/modules/core/src/math/transformation/vpRzyzVector.cpp index e396fb5fdb..f3fe667c06 100644 --- a/modules/core/src/math/transformation/vpRzyzVector.cpp +++ b/modules/core/src/math/transformation/vpRzyzVector.cpp @@ -31,8 +31,7 @@ * Description: * Euler angles parameterization for the rotation. * Rzyz(phi,theta,psi) = Rot(z,phi)Rot(y,theta)Rot(z,psi) - * -*****************************************************************************/ + */ #include #include @@ -154,18 +153,18 @@ vpRzyzVector vpRzyzVector::buildFrom(const std::vector &rzyz) \param v : Angle value to set for each element of the vector. -\code -#include -#include + \code + #include + #include -int main() -{ - vpRzyzVector r; + int main() + { + vpRzyzVector r; - // Initialise the rotation vector - r = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees -} -\endcode + // Initialise the rotation vector + r = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees + } + \endcode */ vpRzyzVector &vpRzyzVector::operator=(double v) { @@ -193,23 +192,22 @@ void vpRzyzVector::buildFrom(double phi, double theta, double psi) Copy operator that initializes a \f$R_{zyz}=(\varphi,\theta,\psi)\f$ Euler angles vector from a 3-dimension column vector. - \param rzyz : 3-dimension vector containing the values of the rotation -vector. - -\code -#include + \param rzyz : 3-dimension vector containing the values of the rotation vector. -int main() -{ - vpColVector v(3); - v[0] = 0.1; - v[1] = 0.2; - v[2] = 0.3; - vpRzyxVector rzyz; - rzyz = v; - // rzyz is now equal to v : 0.1, 0.2, 0.3 -} -\endcode + \code + #include + + int main() + { + vpColVector v(3); + v[0] = 0.1; + v[1] = 0.2; + v[2] = 0.3; + vpRzyxVector rzyz; + rzyz = v; + // rzyz is now equal to v : 0.1, 0.2, 0.3 + } + \endcode */ vpRzyzVector &vpRzyzVector::operator=(const vpColVector &rzyz) { @@ -227,17 +225,17 @@ vpRzyzVector &vpRzyzVector::operator=(const vpColVector &rzyz) /*! Set vector from a list of 3 double angle values in radians. \code -#include + #include -int main() -{ - vpRzyzVector rzyz = {M_PI, 0, M_PI_2}; - std::cout << "rzyz: " << rzyz.t() << std::endl; -} + int main() + { + vpRzyzVector rzyz = {M_PI, 0, M_PI_2}; + std::cout << "rzyz: " << rzyz.t() << std::endl; + } \endcode It produces the following printings: \code -rzyz: 3.141592654 0 1.570796327 + rzyz: 3.141592654 0 1.570796327 \endcode \sa operator<<() */ diff --git a/modules/core/src/math/transformation/vpThetaUVector.cpp b/modules/core/src/math/transformation/vpThetaUVector.cpp index d9738d6dba..3f4ae7355a 100644 --- a/modules/core/src/math/transformation/vpThetaUVector.cpp +++ b/modules/core/src/math/transformation/vpThetaUVector.cpp @@ -30,13 +30,11 @@ * * Description: * Theta U parameterization for the rotation. - * -*****************************************************************************/ + */ /*! -\file vpThetaUVector.cpp -\brief class that consider the case of the Theta U parameterization for the -rotation + \file vpThetaUVector.cpp + \brief class that consider the case of the Theta U parameterization for the rotation */ #include // std::fabs @@ -85,17 +83,17 @@ vpThetaUVector::vpThetaUVector(const vpQuaternionVector &q) : vpRotationVector(3 /*! Build a \f$\theta {\bf u}\f$ vector from 3 angles in radians. \code -#include + #include -int main() -{ - vpThetaUVector tu(0, M_PI_2, M_PI); - std::cout << "tu: " << tu.t() << std::endl; -} + int main() + { + vpThetaUVector tu(0, M_PI_2, M_PI); + std::cout << "tu: " << tu.t() << std::endl; + } \endcode It produces the following printings: \code -tu: 0 1.570796327 3.141592654 + tu: 0 1.570796327 3.141592654 \endcode */ vpThetaUVector::vpThetaUVector(double tux, double tuy, double tuz) : vpRotationVector(3) { buildFrom(tux, tuy, tuz); } @@ -273,21 +271,20 @@ vpThetaUVector vpThetaUVector::buildFrom(const vpColVector &tu) Initialize each element of the \f$\theta {\bf u}\f$ vector to the same angle value \e v. - \param v : Angle value to set for each element of the \f$\theta {\bf - u}\f$ vector. + \param v : Angle value to set for each element of the \f$\theta {\bf u}\f$ vector. -\code -#include -#include + \code + #include + #include -int main() -{ - vpThetaUVector tu; + int main() + { + vpThetaUVector tu; - // Initialise the theta U rotation vector - tu = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees -} -\endcode + // Initialise the theta U rotation vector + tu = vpMath::rad( 45.f); // All the 3 angles are set to 45 degrees + } + \endcode */ vpThetaUVector &vpThetaUVector::operator=(double v) { @@ -300,25 +297,24 @@ vpThetaUVector &vpThetaUVector::operator=(double v) /*! Copy operator that initializes a \f$\theta {\bf u}\f$ vector from a -3-dimension column vector \e tu. + 3-dimension column vector \e tu. - \param tu : 3-dimension vector containing the values of the \f$\theta {\bf -u}\f$ vector. + \param tu : 3-dimension vector containing the values of the \f$\theta {\bf u}\f$ vector. -\code -#include + \code + #include -int main() -{ - vpColVector v(3); - v[0] = 0.1; - v[1] = 0.2; - v[2] = 0.3; - vpThetaUVector tu; - tu = v; - // tu is now equal to v : 0.1, 0.2, 0.3 -} -\endcode + int main() + { + vpColVector v(3); + v[0] = 0.1; + v[1] = 0.2; + v[2] = 0.3; + vpThetaUVector tu; + tu = v; + // tu is now equal to v : 0.1, 0.2, 0.3 + } + \endcode */ vpThetaUVector &vpThetaUVector::operator=(const vpColVector &tu) { @@ -344,18 +340,18 @@ vpThetaUVector &vpThetaUVector::operator=(const vpColVector &tu) The following example shows how to use this function: \code -#include + #include -int main() -{ - vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)); + int main() + { + vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)); - double theta; - vpColVector u; - M.getRotationMatrix().getThetaUVector().extract(theta, u); - std::cout << "theta: " << theta << std::endl; - std::cout << "u : " << u.t() << std::endl; -} + double theta; + vpColVector u; + M.getRotationMatrix().getThetaUVector().extract(theta, u); + std::cout << "theta: " << theta << std::endl; + std::cout << "u : " << u.t() << std::endl; + } \endcode \sa getTheta(), getU() @@ -377,21 +373,21 @@ void vpThetaUVector::extract(double &theta, vpColVector &u) const /*! Get the rotation angle \f$ \theta \f$ from the \f$ \theta {\bf u} \f$ -representation. + representation. \return Rotation angle \f$ \theta \f$ in rad. The following example shows how to use this function: \code -#include + #include -int main() -{ - vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)); + int main() + { + vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), vpMath::rad(30)); - std::cout << "theta: " << M.getRotationMatrix().getThetaUVector().getTheta() << std::endl; - std::cout << "u : " << M.getRotationMatrix().getThetaUVector().getU().t() << std::endl; -} + std::cout << "theta: " << M.getRotationMatrix().getThetaUVector().getTheta() << std::endl; + std::cout << "u : " << M.getRotationMatrix().getThetaUVector().getU().t() << std::endl; + } \endcode \sa getTheta(), extract() @@ -401,22 +397,22 @@ double vpThetaUVector::getTheta() const { return sqrt(data[0] * data[0] + data[1 /*! Get the unit vector \f$\bf u \f$ from the \f$ \theta {\bf u} \f$ -representation. + representation. \return 3-dim unit vector \f${\bf u} = (u_{x},u_{y},u_{z})^{\top} \f$ representing the rotation axis. The following example shows how to use this function: \code -#include + #include -int main() -{ - vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), pMath::rad(30)); + int main() + { + vpHomogeneousMatrix M(0, 0, 1., vpMath::rad(10), vpMath::rad(20), pMath::rad(30)); - std::cout << "theta: " << M.getRotationMatrix().getThetaUVector().getTheta() << std::endl; - std::cout << "u : " << M.getRotationMatrix().getThetaUVector().getU().t() << std::endl; -} + std::cout << "theta: " << M.getRotationMatrix().getThetaUVector().getTheta() << std::endl; + std::cout << "u : " << M.getRotationMatrix().getThetaUVector().getU().t() << std::endl; + } \endcode \sa getTheta(), extract() @@ -471,17 +467,17 @@ vpThetaUVector vpThetaUVector::operator*(const vpThetaUVector &tu_b) const /*! Set vector from a list of 3 double angle values in radians. \code -#include + #include -int main() -{ - vpThetaUVector tu = {M_PI, 0, M_PI_2}; - std::cout << "tu: " << tu.t() << std::endl; -} + int main() + { + vpThetaUVector tu = {M_PI, 0, M_PI_2}; + std::cout << "tu: " << tu.t() << std::endl; + } \endcode It produces the following printings: \code -tu: 3.141592654 0 1.570796327 + tu: 3.141592654 0 1.570796327 \endcode \sa operator<<() */ diff --git a/modules/core/src/math/transformation/vpTranslationVector.cpp b/modules/core/src/math/transformation/vpTranslationVector.cpp index 19767242a8..74a22cfa14 100644 --- a/modules/core/src/math/transformation/vpTranslationVector.cpp +++ b/modules/core/src/math/transformation/vpTranslationVector.cpp @@ -30,8 +30,7 @@ * * Description: * Translation vector. - * -*****************************************************************************/ + */ #include #include @@ -236,7 +235,7 @@ vpTranslationVector vpTranslationVector::operator+(const vpTranslationVector &tv \return The sum of the current translation vector (*this) and the column vector to add. -\code + \code vpTranslationVector t1(1,2,3); vpColVector v(3); v[0] = 4; @@ -510,17 +509,17 @@ vpTranslationVector &vpTranslationVector::operator=(double x) /*! Set vector from a list of 3 double values in meters. \code -#include + #include -int main() -{ - vpTranslationVector t = {0, 0.1, 0.5}; - std::cout << "t: " << t.t() << std::endl; -} + int main() + { + vpTranslationVector t = {0, 0.1, 0.5}; + std::cout << "t: " << t.t() << std::endl; + } \endcode It produces the following printings: \code -t: 0 0.1 0.5 + t: 0 0.1 0.5 \endcode \sa operator<<() */ @@ -544,18 +543,18 @@ vpTranslationVector &vpTranslationVector::operator=(const std::initializer_list< The following example shows how to initialize a translation vector from a list of 3 values [meter]. \code -#include + #include -int main() -{ - vpTranslationVector t; - t << 0, 0.1, 0.5; - std::cout << "t: " << t.t() << std::endl; -} + int main() + { + vpTranslationVector t; + t << 0, 0.1, 0.5; + std::cout << "t: " << t.t() << std::endl; + } \endcode It produces the following printings: \code -t: 0 0.1 0.5 + t: 0 0.1 0.5 \endcode \sa operator,() @@ -574,18 +573,18 @@ vpTranslationVector &vpTranslationVector::operator<<(double val) The following example shows how to initialize a translations vector from a list of 3 values [meter]. \code -#include + #include -int main() -{ - vpTranslationVector t; - t << 0, 0.1, 0.5; - std::cout << "t: " << t.t() << std::endl; -} + int main() + { + vpTranslationVector t; + t << 0, 0.1, 0.5; + std::cout << "t: " << t.t() << std::endl; + } \endcode It produces the following printings: \code -t: 0 0.1 0.5 + t: 0 0.1 0.5 \endcode \sa operator<<() @@ -742,7 +741,7 @@ double vpTranslationVector::frobeniusNorm() const vector t(m). \return The value \f[\sum{i=0}^{m} t_i^{2}\f]. - */ +*/ double vpTranslationVector::sumSquare() const { double sum_square = 0.0; diff --git a/modules/core/src/tools/file/vpIoTools.cpp b/modules/core/src/tools/file/vpIoTools.cpp index f02b4279b5..f4b25f22af 100644 --- a/modules/core/src/tools/file/vpIoTools.cpp +++ b/modules/core/src/tools/file/vpIoTools.cpp @@ -832,20 +832,15 @@ bool vpIoTools::checkDirectory(const std::string &dirname) std::string _dirname = path(dirname); if (VP_STAT(_dirname.c_str(), &stbuf) != 0) { - std::cout << "DEBUG 1 _dirname: " << _dirname << " is not a dir" << std::endl; // Test adding the separator if not already present if (_dirname.at(_dirname.size() - 1) != separator) { - std::cout << "DEBUG 2 test if _dirname + separator: " << _dirname + separator << " is a dir ?" << std::endl; if (VP_STAT((_dirname + separator).c_str(), &stbuf) != 0) { - std::cout << "DEBUG 2 _dirname + separator: " << _dirname + separator << " is not a dir" << std::endl; return false; } } // Test removing the separator if already present if (_dirname.at(_dirname.size() - 1) == separator) { - std::cout << "DEBUG 2 test if _dirname - separator: " << _dirname.substr(0, _dirname.size() - 1) << " is a dir ?" << std::endl; if (VP_STAT((_dirname.substr(0, _dirname.size() - 1)).c_str(), &stbuf) != 0) { - std::cout << "DEBUG 3 _dirname - separator: " << _dirname.substr(0, _dirname.size() - 1) << " is not a dir" << std::endl; return false; } } @@ -2071,16 +2066,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; @@ -2092,16 +2087,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/test/image-with-dataset/perfColorConversion.cpp b/modules/core/test/image-with-dataset/perfColorConversion.cpp index 03d24abf5b..e6df803d23 100644 --- a/modules/core/test/image-with-dataset/perfColorConversion.cpp +++ b/modules/core/test/image-with-dataset/perfColorConversion.cpp @@ -47,7 +47,7 @@ #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC) #include -#include +#include #endif static std::string ipath = vpIoTools::getViSPImagesDataPath(); diff --git a/modules/core/test/image-with-dataset/perfGaussianFilter.cpp b/modules/core/test/image-with-dataset/perfGaussianFilter.cpp index 62adcee3c9..e557cf30ce 100644 --- a/modules/core/test/image-with-dataset/perfGaussianFilter.cpp +++ b/modules/core/test/image-with-dataset/perfGaussianFilter.cpp @@ -47,7 +47,7 @@ #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC) #include -#include +#include #endif static const std::string ipath = vpIoTools::getViSPImagesDataPath(); diff --git a/modules/core/test/image-with-dataset/perfImageResize.cpp b/modules/core/test/image-with-dataset/perfImageResize.cpp index 69cd7d90ca..98fb426a42 100644 --- a/modules/core/test/image-with-dataset/perfImageResize.cpp +++ b/modules/core/test/image-with-dataset/perfImageResize.cpp @@ -48,7 +48,7 @@ #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC) #include -#include +#include #endif static const std::string ipath = vpIoTools::getViSPImagesDataPath(); diff --git a/modules/core/test/image-with-dataset/testConversion.cpp b/modules/core/test/image-with-dataset/testConversion.cpp index c164315390..5386640292 100644 --- a/modules/core/test/image-with-dataset/testConversion.cpp +++ b/modules/core/test/image-with-dataset/testConversion.cpp @@ -47,7 +47,7 @@ #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC) #include -#include +#include #endif /*! diff --git a/modules/core/test/math/testMatrix.cpp b/modules/core/test/math/testMatrix.cpp index 65f6f0b6c4..b894a63a42 100644 --- a/modules/core/test/math/testMatrix.cpp +++ b/modules/core/test/math/testMatrix.cpp @@ -53,6 +53,29 @@ namespace { +bool test_memory(unsigned int nrows, unsigned int ncols, const vpMatrix &M, const std::string &matrix_name, bool pointer_is_null) +{ + if (pointer_is_null) { + if (M.data) { + std::cerr << "Wrong data pointer (" << M.data << ") in matrix " << matrix_name << ": should be null" << std::endl; + } + } + else { + if (!M.data) { + std::cerr << "Wrong data pointer (" << M.data << ") in matrix " << matrix_name << ": should be non null" << std::endl; + return false; + } + } + + if (M.getRows() != nrows || M.getCols() != ncols) { + std::cerr << "Wrong matrix " << matrix_name << "(" << nrows << ", " << ncols << " size: " + << M.getRows() << " x " << M.getCols() << std::endl; + return false; + } + std::cout << "Test matrix " << matrix_name << " succeed" << std::endl; + return true; +} + bool test(const std::string &s, const vpMatrix &M, const std::vector &bench) { static unsigned int cpt = 0; @@ -122,6 +145,28 @@ int main(int argc, char *argv[]) } } + { + unsigned int nrows = 2, ncols = 3; + vpMatrix A(nrows, ncols); + if (test_memory(nrows, ncols, A, "A", false) == false) { + return EXIT_FAILURE; + } + vpMatrix B, C; + if (test_memory(0, 0, B, "B", true) == false) { + return EXIT_FAILURE; + } + if (test_memory(0, 0, C, "C", true)== false) { + return EXIT_FAILURE; + } + B = A; + if (test_memory(nrows, ncols, B, "B", false)== false) { + return EXIT_FAILURE; + } + B = C; + if (test_memory(0, 0, C, "C", true)== false) { + return EXIT_FAILURE; + } + } { const double val = 10.0; vpMatrix M, M2(5, 5, val); diff --git a/modules/gui/include/visp3/gui/vpDisplayOpenCV.h b/modules/gui/include/visp3/gui/vpDisplayOpenCV.h index ca9ce797d9..dc1b858583 100644 --- a/modules/gui/include/visp3/gui/vpDisplayOpenCV.h +++ b/modules/gui/include/visp3/gui/vpDisplayOpenCV.h @@ -168,14 +168,8 @@ class VISP_EXPORT vpDisplayOpenCV : public vpDisplay // private: //#ifndef DOXYGEN_SHOULD_SKIP_THIS // vpDisplayOpenCV(const vpDisplayOpenCV &) - // : vpDisplay(), - // #if (VISP_HAVE_OPENCV_VERSION < 0x020408) - // background(nullptr), col(nullptr), cvcolor(), font(nullptr), - // #else - // background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), - // fontScale(0.8f), - // #endif - // fontHeight(10), x_move(0), y_move(0) , move(false), + // : vpDisplay(), background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), + // fontScale(0.8f), fontHeight(10), x_move(0), y_move(0) , move(false), // x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false), // x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), // x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false), diff --git a/modules/gui/src/display/vpDisplayOpenCV.cpp b/modules/gui/src/display/vpDisplayOpenCV.cpp index a31918ab57..5ab98348dc 100644 --- a/modules/gui/src/display/vpDisplayOpenCV.cpp +++ b/modules/gui/src/display/vpDisplayOpenCV.cpp @@ -101,11 +101,7 @@ unsigned int vpDisplayOpenCV::m_nbWindows = 0; */ vpDisplayOpenCV::vpDisplayOpenCV(vpImage &I, vpScaleType scaleType) : vpDisplay(), -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - m_background(nullptr), col(nullptr), cvcolor(), font(nullptr), -#else m_background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f), -#endif fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false), x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false), x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0), @@ -141,11 +137,7 @@ vpDisplayOpenCV::vpDisplayOpenCV(vpImage &I, vpScaleType scaleTyp vpDisplayOpenCV::vpDisplayOpenCV(vpImage &I, int x, int y, const std::string &title, vpScaleType scaleType) : vpDisplay(), -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - m_background(nullptr), col(nullptr), cvcolor(), font(nullptr), -#else m_background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f), -#endif fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false), x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false), x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0), @@ -175,11 +167,7 @@ vpDisplayOpenCV::vpDisplayOpenCV(vpImage &I, int x, int y, const */ vpDisplayOpenCV::vpDisplayOpenCV(vpImage &I, vpScaleType scaleType) : -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - m_background(nullptr), col(nullptr), cvcolor(), font(nullptr), -#else m_background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f), -#endif fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false), x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false), x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0), @@ -211,11 +199,7 @@ vpDisplayOpenCV::vpDisplayOpenCV(vpImage &I, vpScaleType scaleType) */ vpDisplayOpenCV::vpDisplayOpenCV(vpImage &I, int x, int y, const std::string &title, vpScaleType scaleType) : -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - m_background(nullptr), col(nullptr), cvcolor(), font(nullptr), -#else m_background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f), -#endif fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false), x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false), x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0), @@ -249,11 +233,7 @@ int main() */ vpDisplayOpenCV::vpDisplayOpenCV(int x, int y, const std::string &title) : -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - m_background(nullptr), col(nullptr), cvcolor(), font(nullptr), -#else m_background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f), -#endif fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false), x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false), x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0), @@ -309,11 +289,7 @@ int main() */ vpDisplayOpenCV::vpDisplayOpenCV() : -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - m_background(nullptr), col(nullptr), cvcolor(), font(nullptr), -#else m_background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN), fontScale(0.8f), -#endif fontHeight(10), x_move(0), y_move(0), move(false), x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false), x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false), x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false), x_lbuttonup(0), y_lbuttonup(0), lbuttonup(false), x_mbuttonup(0), y_mbuttonup(0), mbuttonup(false), x_rbuttonup(0), @@ -326,9 +302,6 @@ vpDisplayOpenCV::vpDisplayOpenCV() vpDisplayOpenCV::~vpDisplayOpenCV() { closeDisplay(); -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvReleaseImage(&m_background); -#endif } /*! @@ -388,15 +361,13 @@ void vpDisplayOpenCV::init(unsigned int w, unsigned int h, int x, int y, const s this->m_width = w / m_scale; this->m_height = h / m_scale; - if (x != -1) + if (x != -1) { this->m_windowXPosition = x; - if (y != -1) + } + if (y != -1) { this->m_windowYPosition = y; -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - int flags = CV_WINDOW_AUTOSIZE; -#else + } int flags = cv::WINDOW_AUTOSIZE; -#endif if (m_title.empty()) { if (!title.empty()) { @@ -426,19 +397,10 @@ void vpDisplayOpenCV::init(unsigned int w, unsigned int h, int x, int y, const s m_listTitles.push_back(m_title); } -/* Create the window*/ -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - if (cvNamedWindow(this->m_title.c_str(), flags) < 0) { - throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV was not built with a display device")); - } -#else + /* Create the window*/ cv::namedWindow(this->m_title, flags); -#endif -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvMoveWindow(this->m_title.c_str(), this->m_windowXPosition, this->m_windowYPosition); -#else cv::moveWindow(this->m_title.c_str(), this->m_windowXPosition, this->m_windowYPosition); -#endif + move = false; lbuttondown = false; mbuttondown = false; @@ -446,13 +408,9 @@ void vpDisplayOpenCV::init(unsigned int w, unsigned int h, int x, int y, const s lbuttonup = false; mbuttonup = false; rbuttonup = false; -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvSetMouseCallback(this->m_title.c_str(), on_mouse, this); - col = new CvScalar[vpColor::id_unknown]; -#else + cv::setMouseCallback(this->m_title, on_mouse, this); col = new cv::Scalar[vpColor::id_unknown]; -#endif /* Create color */ vpColor pcolor; // Predefined colors @@ -493,18 +451,10 @@ void vpDisplayOpenCV::init(unsigned int w, unsigned int h, int x, int y, const s pcolor = vpColor::darkGray; col[vpColor::id_darkGray] = CV_RGB(pcolor.R, pcolor.G, pcolor.B); -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - font = new CvFont; - cvInitFont(font, CV_FONT_HERSHEY_PLAIN, 0.70f, 0.70f); - CvSize fontSize; - int baseline; - cvGetTextSize("A", font, &fontSize, &baseline); -#else int thickness = 1; cv::Size fontSize; int baseline; fontSize = cv::getTextSize("A", font, fontScale, thickness, &baseline); -#endif fontHeight = fontSize.height + baseline; m_displayHasBeenInitialized = true; @@ -557,11 +507,7 @@ void vpDisplayOpenCV::setWindowPosition(int winx, int winy) if (m_displayHasBeenInitialized) { this->m_windowXPosition = winx; this->m_windowYPosition = winy; -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvMoveWindow(this->m_title.c_str(), winx, winy); -#else cv::moveWindow(this->m_title.c_str(), winx, winy); -#endif } else { throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV not initialized")); @@ -581,46 +527,6 @@ void vpDisplayOpenCV::setWindowPosition(int winx, int winy) void vpDisplayOpenCV::displayImage(const vpImage &I) { if (m_displayHasBeenInitialized) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - int depth = 8; - int channels = 3; - CvSize size = cvSize((int)this->m_width, (int)this->m_height); - if (m_background != nullptr) { - if (m_background->nChannels != channels || m_background->depth != depth || - m_background->height != (int)m_height || m_background->width != (int)m_width) { - if (m_background->nChannels != 0) - cvReleaseImage(&m_background); - m_background = cvCreateImage(size, depth, channels); - } - } - else { - m_background = cvCreateImage(size, depth, channels); - } - - if (m_scale == 1) { - for (unsigned int i = 0; i < m_height; i++) { - unsigned char *dst_24 = (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep); - for (unsigned int j = 0; j < m_width; j++) { - unsigned char val = I[i][j]; - *(dst_24++) = val; - *(dst_24++) = val; - *(dst_24++) = val; - } - } - } - else { - for (unsigned int i = 0; i < m_height; i++) { - unsigned char *dst_24 = (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep); - for (unsigned int j = 0; j < m_width; j++) { - unsigned char val = I[i * m_scale][j * m_scale]; - *(dst_24++) = val; - *(dst_24++) = val; - *(dst_24++) = val; - } - } - } - -#else int depth = CV_8U; int channels = 3; cv::Size size((int)m_width, (int)m_height); @@ -651,8 +557,6 @@ void vpDisplayOpenCV::displayImage(const vpImage &I) } } } -#endif - } else { throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV not initialized")); @@ -678,56 +582,6 @@ void vpDisplayOpenCV::displayImageROI(const vpImage &I, const vpI unsigned int h) { if (m_displayHasBeenInitialized) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - int depth = 8; - int channels = 3; - CvSize size = cvSize((int)this->m_width, (int)this->m_height); - if (m_background != nullptr) { - if (m_background->nChannels != channels || m_background->depth != depth || - m_background->height != (int)m_height || m_background->width != (int)m_width) { - if (m_background->nChannels != 0) - cvReleaseImage(&m_background); - m_background = cvCreateImage(size, depth, channels); - } - } - else { - m_background = cvCreateImage(size, depth, channels); - } - - if (m_scale == 1) { - unsigned int i_min = (unsigned int)iP.get_i(); - unsigned int j_min = (unsigned int)iP.get_j(); - unsigned int i_max = std::min(i_min + h, m_height); - unsigned int j_max = std::min(j_min + w, m_width); - for (unsigned int i = i_min; i < i_max; i++) { - unsigned char *dst_24 = - (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep + j_min * 3); - for (unsigned int j = j_min; j < j_max; j++) { - unsigned char val = I[i][j]; - *(dst_24++) = val; - *(dst_24++) = val; - *(dst_24++) = val; - } - } - } - else { - int i_min = std::max((int)ceil(iP.get_i() / m_scale), 0); - int j_min = std::max((int)ceil(iP.get_j() / m_scale), 0); - int i_max = std::min((int)ceil((iP.get_i() + h) / m_scale), (int)m_height); - int j_max = std::min((int)ceil((iP.get_j() + w) / m_scale), (int)m_width); - for (int i = i_min; i < i_max; i++) { - unsigned char *dst_24 = - (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep + j_min * 3); - for (int j = j_min; j < j_max; j++) { - unsigned char val = I[i * m_scale][j * m_scale]; - *(dst_24++) = val; - *(dst_24++) = val; - *(dst_24++) = val; - } - } - } - -#else int depth = CV_8U; int channels = 3; cv::Size size((int)m_width, (int)m_height); @@ -766,7 +620,6 @@ void vpDisplayOpenCV::displayImageROI(const vpImage &I, const vpI } } } -#endif } else { throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV not initialized")); @@ -778,7 +631,7 @@ void vpDisplayOpenCV::displayImageROI(const vpImage &I, const vpI \warning Display has to be initialized. - \warning suppres the overlay drawing + \warning suppress the overlay drawing \param I : Image to display. @@ -788,45 +641,6 @@ void vpDisplayOpenCV::displayImage(const vpImage &I) { if (m_displayHasBeenInitialized) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - int depth = 8; - int channels = 3; - CvSize size = cvSize((int)this->m_width, (int)this->m_height); - if (m_background != nullptr) { - if (m_background->nChannels != channels || m_background->depth != depth || - m_background->height != (int)m_height || m_background->width != (int)m_width) { - if (m_background->nChannels != 0) - cvReleaseImage(&m_background); - m_background = cvCreateImage(size, depth, channels); - } - } - else { - m_background = cvCreateImage(size, depth, channels); - } - - if (m_scale == 1) { - for (unsigned int i = 0; i < m_height; i++) { - unsigned char *dst_24 = (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep); - for (unsigned int j = 0; j < m_width; j++) { - vpRGBa val = I[i][j]; - *(dst_24++) = val.B; - *(dst_24++) = val.G; - *(dst_24++) = val.R; - } - } - } - else { - for (unsigned int i = 0; i < m_height; i++) { - unsigned char *dst_24 = (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep); - for (unsigned int j = 0; j < m_width; j++) { - vpRGBa val = I[i * m_scale][j * m_scale]; - *(dst_24++) = val.B; - *(dst_24++) = val.G; - *(dst_24++) = val.R; - } - } - } -#else int depth = CV_8U; int channels = 3; cv::Size size((int)this->m_width, (int)this->m_height); @@ -857,7 +671,6 @@ void vpDisplayOpenCV::displayImage(const vpImage &I) } } } -#endif } else { throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV not initialized")); @@ -882,55 +695,6 @@ void vpDisplayOpenCV::displayImage(const vpImage &I) void vpDisplayOpenCV::displayImageROI(const vpImage &I, const vpImagePoint &iP, unsigned int w, unsigned int h) { if (m_displayHasBeenInitialized) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - int depth = 8; - int channels = 3; - CvSize size = cvSize((int)this->m_width, (int)this->m_height); - if (m_background != nullptr) { - if (m_background->nChannels != channels || m_background->depth != depth || - m_background->height != (int)m_height || m_background->width != (int)m_width) { - if (m_background->nChannels != 0) - cvReleaseImage(&m_background); - m_background = cvCreateImage(size, depth, channels); - } - } - else { - m_background = cvCreateImage(size, depth, channels); - } - - if (m_scale == 1) { - unsigned int i_min = (unsigned int)iP.get_i(); - unsigned int j_min = (unsigned int)iP.get_j(); - unsigned int i_max = std::min(i_min + h, m_height); - unsigned int j_max = std::min(j_min + w, m_width); - for (unsigned int i = i_min; i < i_max; i++) { - unsigned char *dst_24 = - (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep + j_min * 3); - for (unsigned int j = j_min; j < j_max; j++) { - vpRGBa val = I[i][j]; - *(dst_24++) = val.B; - *(dst_24++) = val.G; - *(dst_24++) = val.R; - } - } - } - else { - int i_min = std::max((int)ceil(iP.get_i() / m_scale), 0); - int j_min = std::max((int)ceil(iP.get_j() / m_scale), 0); - int i_max = std::min((int)ceil((iP.get_i() + h) / m_scale), (int)m_height); - int j_max = std::min((int)ceil((iP.get_j() + w) / m_scale), (int)m_width); - for (int i = i_min; i < i_max; i++) { - unsigned char *dst_24 = - (unsigned char *)m_background->imageData + (int)(i * m_background->widthStep + j_min * 3); - for (int j = j_min; j < j_max; j++) { - vpRGBa val = I[i * m_scale][j * m_scale]; - *(dst_24++) = val.B; - *(dst_24++) = val.G; - *(dst_24++) = val.R; - } - } - } -#else int depth = CV_8U; int channels = 3; cv::Size size((int)this->m_width, (int)this->m_height); @@ -969,7 +733,6 @@ void vpDisplayOpenCV::displayImageROI(const vpImage &I, const vpImagePoi } } } -#endif } else { throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV not initialized")); @@ -996,19 +759,8 @@ void vpDisplayOpenCV::closeDisplay() delete[] col; col = nullptr; } -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - if (font != nullptr) { - delete font; - font = nullptr; - } -#endif if (m_displayHasBeenInitialized) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvDestroyWindow(this->m_title.c_str()); -#else cv::destroyWindow(this->m_title); -#endif - for (size_t i = 0; i < m_listTitles.size(); i++) { if (m_title == m_listTitles[i]) { m_listTitles.erase(m_listTitles.begin() + (long int)i); @@ -1030,13 +782,8 @@ void vpDisplayOpenCV::closeDisplay() void vpDisplayOpenCV::flushDisplay() { if (m_displayHasBeenInitialized) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvShowImage(this->m_title.c_str(), m_background); - cvWaitKey(5); -#else cv::imshow(this->m_title, m_background); cv::waitKey(5); -#endif } else { throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV not initialized")); @@ -1052,13 +799,8 @@ void vpDisplayOpenCV::flushDisplayROI(const vpImagePoint & /*iP*/, const unsigne const unsigned int /*height*/) { if (m_displayHasBeenInitialized) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvShowImage(this->m_title.c_str(), m_background); - cvWaitKey(5); -#else cv::imshow(this->m_title.c_str(), m_background); cv::waitKey(5); -#endif } else { throw(vpDisplayException(vpDisplayException::notInitializedError, "OpenCV not initialized")); @@ -1141,27 +883,15 @@ void vpDisplayOpenCV::displayText(const vpImagePoint &ip, const std::string &tex { if (m_displayHasBeenInitialized) { if (color.id < vpColor::id_unknown) { -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvPutText(m_background, text, - cvPoint(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale + fontHeight)), font, - col[color.id]); -#else cv::putText(m_background, text, cv::Point(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale + fontHeight)), font, fontScale, col[color.id]); -#endif } else { cvcolor = CV_RGB(color.R, color.G, color.B); -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvPutText(m_background, text, - cvPoint(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale + fontHeight)), font, - cvcolor); -#else cv::putText(m_background, text, cv::Point(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale + fontHeight)), font, fontScale, cvcolor); -#endif } } else { @@ -1197,11 +927,7 @@ void vpDisplayOpenCV::displayCircle(const vpImagePoint ¢er, unsigned int rad if (fill == false) { int cv_thickness = static_cast(thickness); -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvCircle(m_background, cvPoint(x, y), r, cv_color, cv_thickness); -#else cv::circle(m_background, cv::Point(x, y), r, cv_color, cv_thickness); -#endif } else { #if VISP_HAVE_OPENCV_VERSION >= 0x030000 @@ -1210,13 +936,8 @@ void vpDisplayOpenCV::displayCircle(const vpImagePoint ¢er, unsigned int rad int filled = CV_FILLED; #endif double opacity = static_cast(color.A) / 255.0; -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - overlay([x, y, r, cv_color, filled](cv::Mat image) { cvCircle(image, cvPoint(x, y), r, cv_color, filled); }, - opacity); -#else overlay([x, y, r, cv_color, filled](cv::Mat image) { cv::circle(image, cv::Point(x, y), r, cv_color, filled); }, opacity); -#endif } } else { @@ -1313,27 +1034,15 @@ void vpDisplayOpenCV::displayLine(const vpImagePoint &ip1, const vpImagePoint &i { if (m_displayHasBeenInitialized) { if (color.id < vpColor::id_unknown) { -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvLine(m_background, cvPoint(vpMath::round(ip1.get_u() / m_scale), vpMath::round(ip1.get_v() / m_scale)), - cvPoint(vpMath::round(ip2.get_u() / m_scale), vpMath::round(ip2.get_v() / m_scale)), col[color.id], - (int)thickness); -#else cv::line(m_background, cv::Point(vpMath::round(ip1.get_u() / m_scale), vpMath::round(ip1.get_v() / m_scale)), cv::Point(vpMath::round(ip2.get_u() / m_scale), vpMath::round(ip2.get_v() / m_scale)), col[color.id], (int)thickness); -#endif } else { cvcolor = CV_RGB(color.R, color.G, color.B); -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvLine(m_background, cvPoint(vpMath::round(ip1.get_u() / m_scale), vpMath::round(ip1.get_v() / m_scale)), - cvPoint(vpMath::round(ip2.get_u() / m_scale), vpMath::round(ip2.get_v() / m_scale)), cvcolor, - (int)thickness); -#else cv::line(m_background, cv::Point(vpMath::round(ip1.get_u() / m_scale), vpMath::round(ip1.get_v() / m_scale)), cv::Point(vpMath::round(ip2.get_u() / m_scale), vpMath::round(ip2.get_v() / m_scale)), cvcolor, (int)thickness); -#endif } } else { @@ -1352,27 +1061,15 @@ void vpDisplayOpenCV::displayPoint(const vpImagePoint &ip, const vpColor &color, if (m_displayHasBeenInitialized) { for (unsigned int i = 0; i < thickness; i++) { if (color.id < vpColor::id_unknown) { -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvLine(m_background, cvPoint(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale)), - cvPoint(vpMath::round(ip.get_u() / m_scale + thickness - 1), vpMath::round(ip.get_v() / m_scale)), - col[color.id], (int)thickness); -#else cv::line(m_background, cv::Point(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale)), cv::Point(vpMath::round(ip.get_u() / m_scale + thickness - 1), vpMath::round(ip.get_v() / m_scale)), col[color.id], (int)thickness); -#endif } else { cvcolor = CV_RGB(color.R, color.G, color.B); -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvLine(m_background, cvPoint(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale)), - cvPoint(vpMath::round(ip.get_u() / m_scale + thickness - 1), vpMath::round(ip.get_v() / m_scale)), - cvcolor, (int)thickness); -#else cv::line(m_background, cv::Point(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale)), cv::Point(vpMath::round(ip.get_u() / m_scale + thickness - 1), vpMath::round(ip.get_v() / m_scale)), cvcolor, (int)thickness); -#endif } } } @@ -1414,11 +1111,7 @@ void vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, unsigned int if (fill == false) { int cv_thickness = static_cast(thickness); -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvRectangle(m_background, cvPoint(left, top), cvPoint(right, bottom), cv_color, cv_thickness); -#else cv::rectangle(m_background, cv::Point(left, top), cv::Point(right, bottom), cv_color, cv_thickness); -#endif } else { #if VISP_HAVE_OPENCV_VERSION >= 0x030000 @@ -1427,17 +1120,10 @@ void vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, unsigned int int filled = CV_FILLED; #endif double opacity = static_cast(color.A) / 255.0; -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - overlay([left, top, right, bottom, cv_color, filled]( - cv::Mat image) { cvRectangle(image, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled); }, - opacity); -#else - overlay( - [left, top, right, bottom, cv_color, filled](cv::Mat image) { - cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled); + overlay([left, top, right, bottom, cv_color, filled](cv::Mat image) { + cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled); }, opacity); -#endif } } else { @@ -1476,11 +1162,7 @@ void vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, const vpImag if (fill == false) { int cv_thickness = static_cast(thickness); -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvRectangle(m_background, cvPoint(left, top), cvPoint(right, bottom), cv_color, cv_thickness); -#else cv::rectangle(m_background, cv::Point(left, top), cv::Point(right, bottom), cv_color, cv_thickness); -#endif } else { #if VISP_HAVE_OPENCV_VERSION >= 0x030000 @@ -1489,17 +1171,10 @@ void vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, const vpImag int filled = CV_FILLED; #endif double opacity = static_cast(color.A) / 255.0; -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - overlay([left, top, right, bottom, cv_color, filled]( - cv::Mat image) { cvRectangle(image, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled); }, - opacity); -#else - overlay( - [left, top, right, bottom, cv_color, filled](cv::Mat image) { - cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled); + overlay([left, top, right, bottom, cv_color, filled](cv::Mat image) { + cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled); }, opacity); -#endif } } else { @@ -1537,11 +1212,7 @@ void vpDisplayOpenCV::displayRectangle(const vpRect &rectangle, const vpColor &c if (fill == false) { int cv_thickness = static_cast(thickness); -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - cvRectangle(m_background, cvPoint(left, top), cvPoint(right, bottom), cv_color, cv_thickness); -#else cv::rectangle(m_background, cv::Point(left, top), cv::Point(right, bottom), cv_color, cv_thickness); -#endif } else { #if VISP_HAVE_OPENCV_VERSION >= 0x030000 @@ -1550,17 +1221,10 @@ void vpDisplayOpenCV::displayRectangle(const vpRect &rectangle, const vpColor &c int filled = CV_FILLED; #endif double opacity = static_cast(color.A) / 255.0; -#if VISP_HAVE_OPENCV_VERSION < 0x020408 - overlay([left, top, right, bottom, cv_color, filled]( - cv::Mat image) { cvRectangle(image, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled); }, - opacity); -#else - overlay( - [left, top, right, bottom, cv_color, filled](cv::Mat image) { - cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled); + overlay([left, top, right, bottom, cv_color, filled](cv::Mat image) { + cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled); }, opacity); -#endif } } else { @@ -1606,12 +1270,9 @@ bool vpDisplayOpenCV::getClick(bool blocking) ret = true; rbuttondown = false; } - if (blocking) -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvWaitKey(10); -#else + if (blocking) { cv::waitKey(10); -#endif + } } while (ret == false && blocking == true); } else { @@ -1674,12 +1335,9 @@ bool vpDisplayOpenCV::getClick(vpImagePoint &ip, bool blocking) ip.set_v(v); rbuttondown = false; } - if (blocking) -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvWaitKey(10); -#else + if (blocking) { cv::waitKey(10); -#endif + } } while (ret == false && blocking == true); } else { @@ -1746,12 +1404,9 @@ bool vpDisplayOpenCV::getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonTyp button = vpMouseButton::button3; rbuttondown = false; } - if (blocking) -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvWaitKey(10); -#else + if (blocking) { cv::waitKey(10); -#endif + } } while (ret == false && blocking == true); } else { @@ -1820,12 +1475,9 @@ bool vpDisplayOpenCV::getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonT button = vpMouseButton::button3; rbuttonup = false; } - if (blocking) -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - cvWaitKey(10); -#else + if (blocking) { cv::waitKey(10); -#endif + } } while (ret == false && blocking == true); } else { @@ -1848,77 +1500,49 @@ void vpDisplayOpenCV::on_mouse(int event, int x, int y, int /*flags*/, void *dis { vpDisplayOpenCV *disp = static_cast(display); switch (event) { -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - case CV_EVENT_MOUSEMOVE: -#else case cv::EVENT_MOUSEMOVE: -#endif { disp->move = true; disp->x_move = x; disp->y_move = y; break; } -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - case CV_EVENT_LBUTTONDOWN: -#else case cv::EVENT_LBUTTONDOWN: -#endif { disp->lbuttondown = true; disp->x_lbuttondown = x; disp->y_lbuttondown = y; break; } -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - case CV_EVENT_MBUTTONDOWN: -#else case cv::EVENT_MBUTTONDOWN: -#endif { disp->mbuttondown = true; disp->x_mbuttondown = x; disp->y_mbuttondown = y; break; } -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - case CV_EVENT_RBUTTONDOWN: -#else case cv::EVENT_RBUTTONDOWN: -#endif { disp->rbuttondown = true; disp->x_rbuttondown = x; disp->y_rbuttondown = y; break; } -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - case CV_EVENT_LBUTTONUP: -#else case cv::EVENT_LBUTTONUP: -#endif { disp->lbuttonup = true; disp->x_lbuttonup = x; disp->y_lbuttonup = y; break; } -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - case CV_EVENT_MBUTTONUP: -#else case cv::EVENT_MBUTTONUP: -#endif { disp->mbuttonup = true; disp->x_mbuttonup = x; disp->y_mbuttonup = y; break; } -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - case CV_EVENT_RBUTTONUP: -#else case cv::EVENT_RBUTTONUP: -#endif { disp->rbuttonup = true; disp->x_rbuttonup = x; @@ -1956,11 +1580,7 @@ bool vpDisplayOpenCV::getKeyboardEvent(bool blocking) else delay = 10; -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - int key_pressed = cvWaitKey(delay); -#else int key_pressed = cv::waitKey(delay); -#endif if (key_pressed == -1) return false; @@ -1999,11 +1619,7 @@ bool vpDisplayOpenCV::getKeyboardEvent(std::string &key, bool blocking) else delay = 10; -#if (VISP_HAVE_OPENCV_VERSION < 0x020408) - int key_pressed = cvWaitKey(delay); -#else int key_pressed = cv::waitKey(delay); -#endif if (key_pressed == -1) return false; else { @@ -2161,7 +1777,7 @@ void vpDisplayOpenCV::overlay(std::function overlay_function, d overlay = m_background.clone(); } else { - // Shallow copy + // Shallow copy overlay = m_background; } diff --git a/modules/imgproc/src/vpImgproc.cpp b/modules/imgproc/src/vpImgproc.cpp index 8496c6ebd2..9a9e9a66cb 100644 --- a/modules/imgproc/src/vpImgproc.cpp +++ b/modules/imgproc/src/vpImgproc.cpp @@ -322,7 +322,7 @@ void gammaCorrectionLogMethod(vpImage &I, const vpImage *p_ I.getMinMaxValue(inputMin, inputMax); unsigned char inputRange = inputMax - inputMin; - float gamma_computed = (std::log(128.f) - std::log(256.f)) / (std::log(mean) - std::log(inputRange)); + float gamma_computed = static_cast((std::log(128.f) - std::log(256.f)) / (std::log(mean) - std::log(inputRange))); float inverse_gamma = 1.f / gamma_computed; // Construct the look-up table @@ -397,19 +397,19 @@ void gammaCorrectionClassificationBasedMethod(vpImage &I, const v float gamma = 0.f; if (isAlreadyHighContrast) { // Case medium to high contrast image - gamma = std::exp((1.f - (meanNormalized + stdevNormalized))/2.f); + gamma = static_cast(std::exp((1.f - (meanNormalized + stdevNormalized))/2.f)); } else { // Case low contrast image #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) - gamma = -std::log2(stdevNormalized); + gamma = -static_cast(std::log2(stdevNormalized)); #else - gamma = -std::log(stdevNormalized) / std::log(2); + gamma = -static_cast(std::log(stdevNormalized) / std::log(2)); #endif } if (meanNormalized < 0.5) { // Case dark image - float meanPowerGamma = std::pow(meanNormalized, gamma); + float meanPowerGamma = static_cast(std::pow(meanNormalized, gamma)); for (unsigned int i = 0; i <= 255; i++) { float iNormalized = static_cast(i)/255.f; float iPowerGamma = std::pow(iNormalized, gamma); @@ -500,7 +500,7 @@ void gammaCorrectionSpatialBased(vpImage &I, const vpImage vpImageTools::resize(I_8_blur, L_8, width, height, vpImageTools::INTERPOLATION_CUBIC); const float alpha = 0.5f; unsigned int size = height * width; - float stdev = I.getStdev(p_mask); + float stdev = static_cast(I.getStdev(p_mask)); float p; if (stdev <= 40) { p = 2.f; @@ -546,7 +546,7 @@ void gammaCorrectionSpatialBased(vpImage &I, const vpImage *p_mask vpImage I_gray(height, width); for (unsigned int i = 0; i < size; ++i) { vpRGBa rgb = I.bitmap[i]; - I_gray.bitmap[i] = 0.299 * rgb.R + 0.587 * rgb.G + 0.114 *rgb.B; + I_gray.bitmap[i] = static_cast(0.299 * rgb.R + 0.587 * rgb.G + 0.114 * rgb.B); } vpImage I_2, I_4, I_8; I_gray.subsample(2, 2, I_2); @@ -565,7 +565,7 @@ void gammaCorrectionSpatialBased(vpImage &I, const vpImage *p_mask vpImageTools::resize(I_8_blur, L_8, width, height, vpImageTools::INTERPOLATION_CUBIC); const float alpha = 0.5f; - float stdev = I.getStdev(p_mask); + float stdev = static_cast(I.getStdev(p_mask)); float p; if (stdev <= 40) { p = 2.f; @@ -601,7 +601,7 @@ void gammaCorrection(vpImage &I, const float &gamma, const vpGamm { float inverse_gamma = 1.0; if ((gamma > 0) && (method == GAMMA_MANUAL)) { - inverse_gamma = 1.0 / gamma; + inverse_gamma = 1.0f / gamma; // Construct the look-up table unsigned char lut[256]; for (unsigned int i = 0; i < 256; i++) { diff --git a/modules/imgproc/test/with-dataset/testImgproc.cpp b/modules/imgproc/test/with-dataset/testImgproc.cpp index ba009c23fe..3f2fb03636 100644 --- a/modules/imgproc/test/with-dataset/testImgproc.cpp +++ b/modules/imgproc/test/with-dataset/testImgproc.cpp @@ -273,7 +273,7 @@ int main(int argc, const char **argv) // Gamma correction vpImage I_color_gamma_correction; - double gamma = 2.2; + float gamma = 2.2f; t = vpTime::measureTimeMs(); vp::gammaCorrection(I_color, I_color_gamma_correction, gamma); t = vpTime::measureTimeMs() - t; @@ -376,7 +376,7 @@ int main(int argc, const char **argv) // Gamma correction vpImage I_gamma_correction; - gamma = 1.8; + gamma = 1.8f; t = vpTime::measureTimeMs(); vp::gammaCorrection(I, I_gamma_correction, gamma); t = vpTime::measureTimeMs() - t; diff --git a/modules/io/src/image/private/vpImageIoOpenCV.cpp b/modules/io/src/image/private/vpImageIoOpenCV.cpp index 80a5466150..dceed26214 100644 --- a/modules/io/src/image/private/vpImageIoOpenCV.cpp +++ b/modules/io/src/image/private/vpImageIoOpenCV.cpp @@ -175,7 +175,7 @@ void readOpenCV(vpImage &I, const std::string &filename) */ void readPNGfromMemOpenCV(const std::vector &buffer, vpImage &I) { - cv::Mat1b buf(buffer.size(), 1, const_cast(buffer.data())); + cv::Mat1b buf(static_cast(buffer.size()), 1, const_cast(buffer.data())); cv::Mat1b img = cv::imdecode(buf, cv::IMREAD_GRAYSCALE); I.resize(img.rows, img.cols); std::copy(img.begin(), img.end(), I.bitmap); @@ -189,7 +189,7 @@ void readPNGfromMemOpenCV(const std::vector &buffer, vpImage &buffer, vpImage &I_color) { - cv::Mat1b buf(buffer.size(), 1, const_cast(buffer.data())); + cv::Mat1b buf(static_cast(buffer.size()), 1, const_cast(buffer.data())); cv::Mat3b img = cv::imdecode(buf, cv::IMREAD_COLOR); vpImageConvert::convert(img, I_color); } diff --git a/modules/io/src/image/private/vpImageIoStb.cpp b/modules/io/src/image/private/vpImageIoStb.cpp index 33dc4afa26..55c6699977 100644 --- a/modules/io/src/image/private/vpImageIoStb.cpp +++ b/modules/io/src/image/private/vpImageIoStb.cpp @@ -149,7 +149,7 @@ void readPNGfromMemStb(const std::vector &buffer, vpImage(buffer.size()), &x, &y, &comp, req_channels); assert(comp == req_channels); I.init(buffer_read, y, x, true); @@ -165,7 +165,7 @@ void readPNGfromMemStb(const std::vector &buffer, vpImage &buffer, vpImage &I_color) { int x = 0, y = 0, comp = 0; - unsigned char *buffer_read = stbi_load_from_memory(buffer.data(), buffer.size(), &x, &y, &comp, 0); + unsigned char *buffer_read = stbi_load_from_memory(buffer.data(), static_cast(buffer.size()), &x, &y, &comp, 0); if (comp == 4) { const bool copyData = true; diff --git a/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp b/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp index 43cc96719d..3f631be8fe 100644 --- a/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp +++ b/modules/robot/src/real-robot/pololu-maestro/vpPololu.cpp @@ -122,7 +122,7 @@ unsigned short vpPololu::radToPwm(float angle) const float a = m_range_pwm / m_range_angle; float b = m_min_pwm - m_min_angle * a; - return (a * angle + b); + return static_cast(a * angle + b); } bool vpPololu::connected() const @@ -194,7 +194,7 @@ void vpPololu::setAngularPosition(float pos_rad, float vel_rad_s) { if ((m_min_angle <= pos_rad) && (pos_rad <= m_max_angle)) { unsigned short pos_pwm = radToPwm(pos_rad); - unsigned short pos_speed = std::fabs(radSToSpeed(vel_rad_s)); + unsigned short pos_speed = static_cast(std::fabs(radSToSpeed(vel_rad_s))); // Handle the case where pos_speed = 0 which corresponds to the pwm max speed if (pos_speed == 0) { pos_speed = 1; diff --git a/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp b/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp index 03cc98fa22..cada111ec9 100644 --- a/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp +++ b/modules/tracker/mbt/src/edge/vpMbtMeLine.cpp @@ -173,9 +173,11 @@ void vpMbtMeLine::sample(const vpImage &I, bool doNoTrack) vpImagePoint iP; iP.set_i(is); iP.set_j(js); + unsigned int is_uint = static_cast(is); + unsigned int js_uint = static_cast(js); // If point is in the image, add to the sample list - if ((!outOfImage(iP, (int)(m_me->getRange() + m_me->getMaskSize() + 1), nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j()) - && inMeMaskCandidates(m_maskCandidates, iP.get_i(), iP.get_j())) { + if ((!outOfImage(iP, (int)(m_me->getRange() + m_me->getMaskSize() + 1), nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint) + && inMeMaskCandidates(m_maskCandidates, is_uint, js_uint)) { vpMeSite pix; pix.init(iP.get_i(), iP.get_j(), m_delta, 0, m_sign); pix.setDisplay(m_selectDisplay); diff --git a/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp b/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp index 664f440e9a..8f400cc72d 100644 --- a/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeEllipse.cpp @@ -65,7 +65,7 @@ vpMeEllipse::vpMeEllipse(const vpMeEllipse &me_ellipse) m_alphamin(me_ellipse.m_alphamin), m_alphamax(me_ellipse.m_alphamax), m_uc(me_ellipse.m_uc), m_vc(me_ellipse.m_vc), m_n20(me_ellipse.m_n20), m_n11(me_ellipse.m_n11), m_n02(me_ellipse.m_n02), m_expectedDensity(me_ellipse.m_expectedDensity), m_numberOfGoodPoints(me_ellipse.m_numberOfGoodPoints), - m_trackCircle(me_ellipse.m_trackCircle), m_trackArc(me_ellipse.m_trackArc) + m_trackCircle(me_ellipse.m_trackCircle), m_trackArc(me_ellipse.m_trackArc), m_arcEpsilon(me_ellipse.m_arcEpsilon) { } vpMeEllipse::~vpMeEllipse() @@ -300,8 +300,10 @@ void vpMeEllipse::sample(const vpImage &I, bool doNotTrack) computePointOnEllipse(ang, iP); // If point is in the image, add to the sample list // Check done in (i,j) frame) - if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j()) - && inMeMaskCandidates(m_maskCandidates, iP.get_i(), iP.get_j())) { + unsigned int is_uint = static_cast(iP.get_i()); + unsigned int js_uint = static_cast(iP.get_j()); + if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint) + && inMeMaskCandidates(m_maskCandidates, is_uint, js_uint)) { const unsigned int crossSize = 5; vpDisplay::displayCross(I, iP, crossSize, vpColor::red); @@ -361,7 +363,9 @@ unsigned int vpMeEllipse::plugHoles(const vpImage &I) while (ang < (nextang - incr)) { vpImagePoint iP; computePointOnEllipse(ang, iP); - if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j())) { + unsigned int is_uint = static_cast(iP.get_i()); + unsigned int js_uint = static_cast(iP.get_j()); + if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint)) { double theta = computeTheta(iP); vpMeSite pix; pix.init(iP.get_i(), iP.get_j(), theta); @@ -420,7 +424,9 @@ unsigned int vpMeEllipse::plugHoles(const vpImage &I) ang = (nextang + ang) / 2.0; // point added at mid angle vpImagePoint iP; computePointOnEllipse(ang, iP); - if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j())) { + unsigned int is_uint = static_cast(iP.get_i()); + unsigned int js_uint = static_cast(iP.get_j()); + if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint)) { double theta = computeTheta(iP); vpMeSite pix; pix.init(iP.get_i(), iP.get_j(), theta); @@ -479,7 +485,9 @@ unsigned int vpMeEllipse::plugHoles(const vpImage &I) for (unsigned int i = 0; i < nbpts; ++i) { vpImagePoint iP; computePointOnEllipse(ang, iP); - if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j())) { + unsigned int is_uint = static_cast(iP.get_i()); + unsigned int js_uint = static_cast(iP.get_j()); + if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint)) { double theta = computeTheta(iP); vpMeSite pix; pix.init(iP.get_i(), iP.get_j(), theta); @@ -529,7 +537,9 @@ unsigned int vpMeEllipse::plugHoles(const vpImage &I) for (unsigned int i = 0; i < nbpts; ++i) { vpImagePoint iP; computePointOnEllipse(ang, iP); - if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j())) { + unsigned int is_uint = static_cast(iP.get_i()); + unsigned int js_uint = static_cast(iP.get_j()); + if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint)) { double theta = computeTheta(iP); vpMeSite pix; pix.init(iP.get_i(), iP.get_j(), theta); @@ -1241,7 +1251,7 @@ void vpMeEllipse::initTracking(const vpImage &I, const vpColVecto computeAbeFromNij(); computeKiFromNij(); - if (m_trackArc) { + if (m_trackArc && pt1 && pt2) { m_alpha1 = computeAngleOnEllipse(*pt1); m_alpha2 = computeAngleOnEllipse(*pt2); if ((m_alpha2 <= m_alpha1) || (std::fabs(m_alpha2 - m_alpha1) < m_arcEpsilon)) { diff --git a/modules/tracker/me/src/moving-edges/vpMeLine.cpp b/modules/tracker/me/src/moving-edges/vpMeLine.cpp index 41501bd559..39e01e785f 100644 --- a/modules/tracker/me/src/moving-edges/vpMeLine.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeLine.cpp @@ -161,9 +161,11 @@ void vpMeLine::sample(const vpImage &I, bool doNotTrack) vpImagePoint iP; iP.set_i(is); iP.set_j(js); + unsigned int is_uint = static_cast(is); + unsigned int js_uint = static_cast(js); // If point is in the image, add to the sample list - if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j()) - && inMeMaskCandidates(m_maskCandidates, iP.get_i(), iP.get_j())) { + if ((!outOfImage(iP, 0, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint) + && inMeMaskCandidates(m_maskCandidates, is_uint, js_uint)) { vpMeSite pix; pix.init(iP.get_i(), iP.get_j(), m_delta, 0, m_sign); pix.setDisplay(m_selectDisplay); @@ -523,16 +525,18 @@ void vpMeLine::seekExtremities(const vpImage &I) for (int i = 0; i < 3; i++) { P.m_ifloat = P.m_ifloat + di * sample_step; - P.m_i = (int)P.m_ifloat; + P.m_i = static_cast(P.m_ifloat); P.m_jfloat = P.m_jfloat + dj * sample_step; - P.m_j = (int)P.m_jfloat; + P.m_j = static_cast(P.m_jfloat); vpImagePoint iP; iP.set_i(P.m_ifloat); iP.set_j(P.m_jfloat); - if ((!outOfImage(iP, 5, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j()) - && inMeMaskCandidates(m_maskCandidates, iP.get_i(), iP.get_j())) { + unsigned int is_uint = static_cast(P.m_ifloat); + unsigned int js_uint = static_cast(P.m_jfloat); + if ((!outOfImage(iP, 5, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint) + && inMeMaskCandidates(m_maskCandidates, is_uint, js_uint)) { P.track(I, m_me, false); if (P.getState() == vpMeSite::NO_SUPPRESSION) { @@ -553,16 +557,18 @@ void vpMeLine::seekExtremities(const vpImage &I) P.setDisplay(m_selectDisplay); for (int i = 0; i < 3; i++) { P.m_ifloat = P.m_ifloat - di * sample_step; - P.m_i = (int)P.m_ifloat; + P.m_i = static_cast(P.m_ifloat); P.m_jfloat = P.m_jfloat - dj * sample_step; - P.m_j = (int)P.m_jfloat; + P.m_j = static_cast(P.m_jfloat); vpImagePoint iP; iP.set_i(P.m_ifloat); iP.set_j(P.m_jfloat); - if ((!outOfImage(iP, 5, nbrows, nbcols)) && inRoiMask(m_mask, iP.get_i(), iP.get_j()) - && inMeMaskCandidates(m_maskCandidates, iP.get_i(), iP.get_j())) { + unsigned int is_uint = static_cast(P.m_ifloat); + unsigned int js_uint = static_cast(P.m_jfloat); + if ((!outOfImage(iP, 5, nbrows, nbcols)) && inRoiMask(m_mask, is_uint, js_uint) + && inMeMaskCandidates(m_maskCandidates, is_uint, js_uint)) { P.track(I, m_me, false); if (P.getState() == vpMeSite::NO_SUPPRESSION) { diff --git a/modules/vision/src/homography-estimation/vpHomographyRansac.cpp b/modules/vision/src/homography-estimation/vpHomographyRansac.cpp index 80db43742d..816b71785d 100644 --- a/modules/vision/src/homography-estimation/vpHomographyRansac.cpp +++ b/modules/vision/src/homography-estimation/vpHomographyRansac.cpp @@ -432,7 +432,7 @@ bool vpHomography::ransac(const std::vector &xb, const std::vector= nbInliersConsensus) { - const unsigned int nbConsensus = best_consensus.size(); + const unsigned int nbConsensus = static_cast(best_consensus.size()); std::vector xa_best(nbConsensus); std::vector ya_best(nbConsensus); std::vector xb_best(nbConsensus); diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index ae1233344b..dc23975c96 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -28,7 +28,7 @@ endif() visp_add_subdirectory(bridge/opencv REQUIRED_DEPS visp_core visp_io) visp_add_subdirectory(computer-vision REQUIRED_DEPS visp_core visp_blob visp_vision visp_io visp_gui visp_detection visp_sensor) visp_add_subdirectory(grabber REQUIRED_DEPS visp_core visp_sensor visp_io visp_gui) -visp_add_subdirectory(gui/pcl-visualizer REQUIRED_DEPS visp_core visp_gui) +visp_add_subdirectory(gui/pcl-visualizer REQUIRED_DEPS visp_core visp_gui visp_io) visp_add_subdirectory(detection/barcode REQUIRED_DEPS visp_core visp_detection visp_io visp_gui visp_sensor) visp_add_subdirectory(detection/dnn REQUIRED_DEPS visp_core visp_detection visp_io visp_gui visp_sensor) visp_add_subdirectory(detection/face REQUIRED_DEPS visp_core visp_detection visp_io visp_gui visp_sensor) diff --git a/tutorial/gui/pcl-visualizer/CMakeLists.txt b/tutorial/gui/pcl-visualizer/CMakeLists.txt index 9f559fa083..de775cc076 100644 --- a/tutorial/gui/pcl-visualizer/CMakeLists.txt +++ b/tutorial/gui/pcl-visualizer/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.5) project(tutorial-gui-pcl-visualizer) -find_package(VISP REQUIRED visp_core visp_gui) +find_package(VISP REQUIRED visp_core visp_gui visp_io) # set the list of source files set(tutorial_cpp diff --git a/tutorial/image/tutorial-image-converter.cpp b/tutorial/image/tutorial-image-converter.cpp index 15c96d7037..59e5a9bf9d 100644 --- a/tutorial/image/tutorial-image-converter.cpp +++ b/tutorial/image/tutorial-image-converter.cpp @@ -4,7 +4,7 @@ #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC) #include -#include +#include #endif int main() diff --git a/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp b/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp index f3f97493bb..6d7a61fa1d 100644 --- a/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp +++ b/tutorial/tracking/keypoint/tutorial-klt-tracker.cpp @@ -24,8 +24,8 @@ int main(int argc, const char *argv[]) opt_subsample = static_cast(std::atoi(argv[i + 1])); else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { std::cout << "Usage: " << argv[0] - << " [--videoname