diff --git a/ChangeLog.txt b/ChangeLog.txt index c059cb9485..de94bbf181 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -8,7 +8,7 @@ ViSP 3.5.1 (under development) - Contributors: . Fabien Spindler, Souriya Trinh, Romain Lagneau, Antonio Marino, Samuel Felton, - Francois Chaumette, Olivier Roussel + Francois Chaumette, Olivier Roussel, Julien Dufour, Joudy Nader - New classes . vpMocapVicon an interface over Vicon motion capture system . vpMocapQualisys an interface over Qualisys motion capture system @@ -49,6 +49,7 @@ ViSP 3.5.1 (under development) . In moving-edges ellipse tracker (vpMeEllipse and vpMbTracker and its derived classes), change sample step parameter to consider the distance between moving-edges in pixels rather than an angular value in deg as it was in the previous releases + . ViSP is available as a Conda package - Tutorials . New tutorial to list all the hardware (robot, camera, depth camera, lidar, mocap, haptic devices, F/T sensor) supported by ViSP @@ -99,6 +100,7 @@ ViSP 3.5.1 (under development) . [#1160] MBT does not estimate dof set by the user using vpMbTracker::setEstimatedDoF() . [#1176] ViSP cannot be built with a subset of OpenCV modules . [#1198] Unable to save multiple cameras in a same xml file + . [#1228] Unable to use visp conda package to link visp as a 3rd party ---------------------------------------------- ViSP 3.5.0 (released February 15, 2022) - Contributors: diff --git a/cmake/PCLTools.cmake b/cmake/PCLTools.cmake index 9d36b33601..067620172b 100644 --- a/cmake/PCLTools.cmake +++ b/cmake/PCLTools.cmake @@ -254,6 +254,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) mark_as_advanced(ENSENSO_INCLUDE_DIR ENSENSO_LIBRARY) + mark_as_advanced(flann_DIR) mark_as_advanced(FLANN_INCLUDE_DIR) mark_as_advanced(FLANN_INCLUDE_DIRS) mark_as_advanced(FLANN_LIBRARY) @@ -295,6 +296,17 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) mark_as_advanced(Qt5Quick_DIR) # Requested on macOS with pcl 1.12.1 mark_as_advanced(Qt5_DIR) # Requested on macOS with pcl 1.12.1 + # Requested on macOS with pcl 1.13.1 + mark_as_advanced(Qt6CoreTools_DIR Qt6Core_DIR Qt6BusTools_DIR Qt6GuiTools_DIR Qt6Gui_DIR Qt6OpenGLWidgets_DIR) + mark_as_advanced(Qt6OpenGL_DIR Qt6WidgetsTools_DIR Qt6Widgets_DIR) + mark_as_advanced(Qt6DBusTools_DIR Qt6DBus_DIR Qt6Network_DIR Qt6QmlCompilerPlusPrivate_DIR) + mark_as_advanced(Qt6QmlIntegration_DIR Qt6QmlModels_DIR Qt6QmlTools_DIR Qt6Qml_DIR Qt6Quick_DIR Qt6Sql_DIR) + mark_as_advanced(Qt6_DIR) + mark_as_advanced(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH) + mark_as_advanced(QT_ADDITIONAL_PACKAGES_PREFIX_PATH) + mark_as_advanced(MACDEPLOYQT_EXECUTABLE) + mark_as_advanced(WrapOpenGL_AGL) + mark_as_advanced(OPENNI2_INCLUDE_DIR) mark_as_advanced(OPENNI2_INCLUDE_DIRS) mark_as_advanced(OPENNI2_LIBRARY) @@ -303,6 +315,9 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) mark_as_advanced(OPENNI_INCLUDE_DIRS) mark_as_advanced(OPENNI_LIBRARY) + mark_as_advanced(PCAP_INCLUDE_DIR) # Requested on macOS with pcl 1.13.1 + mark_as_advanced(PCAP_LIBRARY) # Requested on macOS with pcl 1.13.1 + mark_as_advanced(USB_10_INCLUDE_DIR) mark_as_advanced(USB_10_LIBRARY) @@ -325,6 +340,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) mark_as_advanced(OPENGL_GLES3_INCLUDE_DIR) mark_as_advanced(VTK_MPI_NUMPROCS) + mark_as_advanced(VTK_DIR) # Requested on macOS with pcl 1.12.1 mark_as_advanced(TBB_DIR) diff --git a/example/servo-universal-robots/CMakeLists.txt b/example/servo-universal-robots/CMakeLists.txt index 7662a1e01c..2e702d50db 100644 --- a/example/servo-universal-robots/CMakeLists.txt +++ b/example/servo-universal-robots/CMakeLists.txt @@ -71,7 +71,7 @@ if(VISP_HAVE_REALSENSE2) list(APPEND CXX_FLAGS_MUTE_WARNINGS "-Wno-unqualified-std-cast-call") endif() -vp_set_source_file_compile_flag(servoUniversalRobotsIBVS.cpp ${CXX_FLAGS_MUTE_WARNINGS}) -vp_set_source_file_compile_flag(servoUniversalRobotsPBVS.cpp ${CXX_FLAGS_MUTE_WARNINGS}) -vp_set_source_file_compile_flag(UniversalRobotsMoveToPosition.cpp ${CXX_FLAGS_MUTE_WARNINGS}) -vp_set_source_file_compile_flag(UniversalRobotsSavePosition.cpp ${CXX_FLAGS_MUTE_WARNINGS}) +visp_set_source_file_compile_flag(servoUniversalRobotsIBVS.cpp ${CXX_FLAGS_MUTE_WARNINGS}) +visp_set_source_file_compile_flag(servoUniversalRobotsPBVS.cpp ${CXX_FLAGS_MUTE_WARNINGS}) +visp_set_source_file_compile_flag(UniversalRobotsMoveToPosition.cpp ${CXX_FLAGS_MUTE_WARNINGS}) +visp_set_source_file_compile_flag(UniversalRobotsSavePosition.cpp ${CXX_FLAGS_MUTE_WARNINGS}) diff --git a/modules/core/include/visp3/core/vpDisplay.h b/modules/core/include/visp3/core/vpDisplay.h index 87c2ecb7f7..f45d4f8539 100644 --- a/modules/core/include/visp3/core/vpDisplay.h +++ b/modules/core/include/visp3/core/vpDisplay.h @@ -33,8 +33,8 @@ * *****************************************************************************/ -#ifndef vpDisplay_h -#define vpDisplay_h +#ifndef _vpDisplay_h_ +#define _vpDisplay_h_ #include #include @@ -309,9 +309,9 @@ class VISP_EXPORT vpDisplay when \e fill is set to false. */ inline virtual void displayCircle(const vpImageCircle &circle, const vpColor &color, bool fill = false, - unsigned int thickness = 1) + unsigned int thickness = 1) { - this->displayCircle(circle.getCenter(), circle.getRadius(), color, fill, thickness); + this->displayCircle(circle.getCenter(), static_cast(circle.getRadius()), color, fill, thickness); } /*! diff --git a/modules/core/include/visp3/core/vpImageFilter.h b/modules/core/include/visp3/core/vpImageFilter.h index 80fb105d4b..f1f4aff6bf 100644 --- a/modules/core/include/visp3/core/vpImageFilter.h +++ b/modules/core/include/visp3/core/vpImageFilter.h @@ -70,7 +70,7 @@ class VISP_EXPORT vpImageFilter { public: static void canny(const vpImage &I, vpImage &Ic, unsigned int gaussianFilterSize, - double thresholdCanny, unsigned int apertureSobel); + float thresholdCanny, unsigned int apertureSobel); /*! Apply a 1x3 derivative filter to an image pixel. @@ -955,12 +955,14 @@ class VISP_EXPORT vpImageFilter throw(vpImageException(vpImageException::incorrectInitializationError, "Bad Gaussian filter size")); if (sigma <= 0) - sigma = (size - 1) / 6.0; + sigma = static_cast((size - 1) / 6.0); int middle = (int)(size - 1) / 2; - FilterType sigma2 = vpMath::sqr(sigma); + FilterType sigma2 = static_cast(vpMath::sqr(sigma)); + FilterType coef1 = static_cast(1. / (sigma * sqrt(2. * M_PI))); + FilterType _2_sigma2 = static_cast(2. * sigma2); for (int i = 0; i <= middle; i++) { - filter[i] = (1. / (sigma * sqrt(2. * M_PI))) * exp(-(i * i) / (2. * sigma2)); + filter[i] = coef1 * exp(-(i * i) / _2_sigma2); } if (normalize) { // renormalization @@ -997,22 +999,25 @@ class VISP_EXPORT vpImageFilter throw(vpImageException(vpImageException::incorrectInitializationError, "Bad Gaussian filter size")); if (sigma <= 0) - sigma = (size - 1) / 6.0; + sigma = static_cast((size - 1) / 6.0); int middle = (int)(size - 1) / 2; - FilterType sigma2 = vpMath::sqr(sigma); + FilterType sigma2 = static_cast(vpMath::sqr(sigma)); + FilterType coef_1 = static_cast(1. / (sigma * sqrt(2. * M_PI))); + FilterType coef_1_over_2 = coef_1 / static_cast(2.); + FilterType _2_coef_1 = static_cast(2.) * coef_1; + FilterType _2_sigma2 = static_cast(2. * sigma2); filter[0] = 0.; for (int i = 1; i <= middle; i++) { - filter[i] = -(1. / (sigma * sqrt(2. * M_PI))) * - (exp(-((i + 1) * (i + 1)) / (2. * sigma2)) - exp(-((i - 1) * (i - 1)) / (2. * sigma2))) / 2.; + filter[i] = -coef_1_over_2 * (static_cast(exp(-((i + 1) * (i + 1)) / _2_sigma2)) - static_cast(exp(-((i - 1) * (i - 1)) / _2_sigma2))); } if (normalize) { FilterType sum = 0; for (int i = 1; i <= middle; i++) { - sum += 2. * (1. / (sigma * sqrt(2. * M_PI))) * exp(-(i * i) / (2. * sigma2)); + sum += _2_coef_1 * static_cast(exp(-(i * i) / _2_sigma2)); } - sum += (1. / (sigma * sqrt(2. * M_PI))); + sum += coef_1; for (int i = 1; i <= middle; i++) { filter[i] = filter[i] / sum; @@ -1217,11 +1222,11 @@ class VISP_EXPORT vpImageFilter } #if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) - static double computeCannyThreshold(const cv::Mat &cv_I, const cv::Mat *p_cv_blur, double &lowerThresh); - static double computeCannyThreshold(const vpImage &I, double &lowerThresh); - static double median(const cv::Mat &cv_I); - static double median(const vpImage &Isrc); - static std::vector median(const vpImage &Isrc); + static float computeCannyThreshold(const cv::Mat &cv_I, const cv::Mat *p_cv_blur, float &lowerThresh); + static float computeCannyThreshold(const vpImage &I, float &lowerThresh); + static float median(const cv::Mat &cv_I); + static float median(const vpImage &Isrc); + static std::vector median(const vpImage &Isrc); #endif }; diff --git a/modules/core/include/visp3/core/vpThread.h b/modules/core/include/visp3/core/vpThread.h index d0c0adcb75..d59708467c 100644 --- a/modules/core/include/visp3/core/vpThread.h +++ b/modules/core/include/visp3/core/vpThread.h @@ -61,7 +61,7 @@ Windows. There are two examples implemented in testMutex.cpp and testThread.cpp to - show how to use this class. The content of test-thread.cpp that hightlights + show how to use this class. The content of test-thread.cpp that highlights the main functionalities of this class is given hereafter: \snippet testThread.cpp Code @@ -86,7 +86,7 @@ class vpThread Default constructor that does nothing. To attach a function to this thread of execution you need to call create(). */ - vpThread() : m_handle(), m_isCreated(false), m_isJoinable(false) {} + vpThread() : m_handle(), m_isCreated(false), m_isJoinable(false) { } /*! Construct a thread object that represents a new joinable thread of diff --git a/modules/core/src/display/vpDisplay_rgba.cpp b/modules/core/src/display/vpDisplay_rgba.cpp index faef9e1327..1023c614a9 100644 --- a/modules/core/src/display/vpDisplay_rgba.cpp +++ b/modules/core/src/display/vpDisplay_rgba.cpp @@ -147,7 +147,7 @@ void vpDisplay::displayCharString(const vpImage &I, int i, int j, const void vpDisplay::displayCircle(const vpImage &I, const vpImageCircle &circle, const vpColor &color, bool fill, unsigned int thickness) { - vp_display_display_circle(I, circle.getCenter(), circle.getRadius(), color, fill, thickness); + vp_display_display_circle(I, circle.getCenter(), static_cast(circle.getRadius()), color, fill, thickness); } /*! diff --git a/modules/core/src/display/vpDisplay_uchar.cpp b/modules/core/src/display/vpDisplay_uchar.cpp index 2a511729de..af42deedc4 100644 --- a/modules/core/src/display/vpDisplay_uchar.cpp +++ b/modules/core/src/display/vpDisplay_uchar.cpp @@ -148,7 +148,7 @@ void vpDisplay::displayCharString(const vpImage &I, int i, int j, void vpDisplay::displayCircle(const vpImage &I, const vpImageCircle &circle, const vpColor &color, bool fill, unsigned int thickness) { - vp_display_display_circle(I, circle.getCenter(), circle.getRadius(), color, fill, thickness); + vp_display_display_circle(I, circle.getCenter(), static_cast(circle.getRadius()), color, fill, thickness); } /*! diff --git a/modules/core/src/image/vpCannyEdgeDetection.cpp b/modules/core/src/image/vpCannyEdgeDetection.cpp index 54132d5b5d..a9a050cd36 100644 --- a/modules/core/src/image/vpCannyEdgeDetection.cpp +++ b/modules/core/src/image/vpCannyEdgeDetection.cpp @@ -143,7 +143,7 @@ vpCannyEdgeDetection::detect(const vpImage &I) float lowerThreshold = m_lowerThreshold; if (m_lowerThreshold < 0) { // Applying Canny recommendation to have the upper threshold 3 times greater than the lower threshold. - lowerThreshold = m_upperThreshold / 3.; + lowerThreshold = m_upperThreshold / 3.f; } performHysteresisThresholding(lowerThreshold, upperThreshold); @@ -269,7 +269,7 @@ getAbsoluteTheta(const vpImage &dIx, const vpImage &dIy, const int absoluteTheta = 90.; } else { - absoluteTheta = vpMath::deg(std::abs(std::atan(dy / dx))); + absoluteTheta = static_cast(vpMath::deg(std::abs(std::atan(dy / dx)))); } return absoluteTheta; } diff --git a/modules/core/src/image/vpImageFilter.cpp b/modules/core/src/image/vpImageFilter.cpp index 470cc2da1a..52538ace0e 100644 --- a/modules/core/src/image/vpImageFilter.cpp +++ b/modules/core/src/image/vpImageFilter.cpp @@ -148,11 +148,11 @@ void vpImageFilter::sepFilter(const vpImage &I, vpImage & * The algorithm is based on based on https://github.com/arnaudgelas/OpenCVExamples/blob/master/cvMat/Statistics/Median/Median.cpp * \param[in] channel : Single channel image in OpenCV format. */ -double vpImageFilter::median(const cv::Mat &channel) +float vpImageFilter::median(const cv::Mat &channel) { - double m = (channel.rows * channel.cols) / 2; + float m = (channel.rows * channel.cols) / 2.f; int bin = 0; - double med = -1.0; + float med = -1.0f; int histSize = 256; float range[] = { 0, 256 }; @@ -165,7 +165,7 @@ double vpImageFilter::median(const cv::Mat &channel) for (int i = 0; i < histSize && med < 0.0; ++i) { bin += cvRound(hist.at(i)); if (bin > m && med < 0.0) - med = i; + med = static_cast(i); } return med; @@ -175,9 +175,10 @@ double vpImageFilter::median(const cv::Mat &channel) * \brief Calculates the median value of a single channel. * The algorithm is based on based on https://github.com/arnaudgelas/OpenCVExamples/blob/master/cvMat/Statistics/Median/Median.cpp * \param[in] Isrc : Gray-level image in ViSP format. + * \return Gray level image median value. * \sa \ref vpImageFilter::median() "vpImageFilter::median(const cv::Mat)" */ -double vpImageFilter::median(const vpImage &Isrc) +float vpImageFilter::median(const vpImage &Isrc) { cv::Mat cv_I; vpImageConvert::convert(Isrc, cv_I); @@ -188,17 +189,17 @@ double vpImageFilter::median(const vpImage &Isrc) * \brief Calculates the median value of a vpRGBa image. * The result is ordered in RGB format. * \param[in] Isrc : RGB image in ViSP format. Alpha channel is ignored. - * \return std::vector meds such as meds[0] = red-channel-median meds[1] = green-channel-median + * \return std::vector meds such as meds[0] = red-channel-median, meds[1] = green-channel-median * and meds[2] = blue-channel-median. * \sa \ref vpImageFilter::median() "vpImageFilter::median(const cv::Mat)" */ -std::vector vpImageFilter::median(const vpImage &Isrc) +std::vector vpImageFilter::median(const vpImage &Isrc) { cv::Mat cv_I_bgr; vpImageConvert::convert(Isrc, cv_I_bgr); std::vector channels; cv::split(cv_I_bgr, channels); - std::vector meds(3); + std::vector meds(3); const int orderMeds[] = { 2, 1, 0 }; // To keep the order R, G, B const int orderCvChannels[] = { 0, 1, 2 }; // Because the order of the cv::Mat is B, G, R for (unsigned int i = 0; i < 3; i++) { @@ -213,9 +214,9 @@ std::vector vpImageFilter::median(const vpImage &Isrc) * \param[in] cv_I : The image, in cv format. * \param[in] p_cv_blur : If different from nullptr, must contain a blurred version of cv_I. * \param[out] lowerThresh : The lower threshold for the Canny edge filter. - * \return double The upper Canny edge filter threshold. + * \return The upper Canny edge filter threshold. */ -double vpImageFilter::computeCannyThreshold(const cv::Mat &cv_I, const cv::Mat *p_cv_blur, double &lowerThresh) +float vpImageFilter::computeCannyThreshold(const cv::Mat &cv_I, const cv::Mat *p_cv_blur, float &lowerThresh) { cv::Mat cv_I_blur; if (p_cv_blur != nullptr) { @@ -232,10 +233,10 @@ double vpImageFilter::computeCannyThreshold(const cv::Mat &cv_I, const cv::Mat * cv::Mat cv_I_scaled_down; resize(cv_I_blur, cv_I_scaled_down, cv::Size(), scale_down, scale_down, cv::INTER_NEAREST); - double median_pix = vpImageFilter::median(cv_I_scaled_down); - double lower = std::max(0., 0.7 * median_pix); - double upper = std::min(255., 1.3 * median_pix); - upper = std::max(1., upper); + float median_pix = vpImageFilter::median(cv_I_scaled_down); + float lower = std::max(0.f, 0.7f * median_pix); + float upper = std::min(255.f, 1.3f * median_pix); + upper = std::max(1.f, upper); lowerThresh = lower; return upper; } @@ -245,9 +246,9 @@ double vpImageFilter::computeCannyThreshold(const cv::Mat &cv_I, const cv::Mat * * * \param[in] I : The gray-scale image, in ViSP format. * \param[in] lowerThresh : Canny lower threshold. - * \return double The upper Canny edge filter threshold. + * \return The upper Canny edge filter threshold. */ -double vpImageFilter::computeCannyThreshold(const vpImage &I, double &lowerThresh) +float vpImageFilter::computeCannyThreshold(const vpImage &I, float &lowerThresh) { cv::Mat cv_I; vpImageConvert::convert(I, cv_I); @@ -295,14 +296,14 @@ int main() \param apertureSobel : Size of the mask for the Sobel operator (odd number). */ void vpImageFilter::canny(const vpImage &Isrc, vpImage &Ires, - unsigned int gaussianFilterSize, double thresholdCanny, unsigned int apertureSobel) + unsigned int gaussianFilterSize, float thresholdCanny, unsigned int apertureSobel) { #if defined(HAVE_OPENCV_IMGPROC) cv::Mat img_cvmat, cv_I_blur, edges_cvmat; vpImageConvert::convert(Isrc, img_cvmat); cv::GaussianBlur(img_cvmat, cv_I_blur, cv::Size((int)gaussianFilterSize, (int)gaussianFilterSize), 0, 0); - double upperCannyThresh = thresholdCanny; - double lowerCannyThresh = thresholdCanny / 3.; + float upperCannyThresh = thresholdCanny; + float lowerCannyThresh = thresholdCanny / 3.f; if (upperCannyThresh < 0) { upperCannyThresh = computeCannyThreshold(img_cvmat, &cv_I_blur, lowerCannyThresh); } diff --git a/modules/core/test/image-with-dataset/testImageFilter.cpp b/modules/core/test/image-with-dataset/testImageFilter.cpp index e6c2be967d..408144adee 100644 --- a/modules/core/test/image-with-dataset/testImageFilter.cpp +++ b/modules/core/test/image-with-dataset/testImageFilter.cpp @@ -552,8 +552,8 @@ int main(int argc, const char *argv[]) I_median_rgba[r][c].B = 3 * (r * 3 + c); } } - std::vector median_rgba = vpImageFilter::median(I_median_rgba); - std::vector expected_median_rgba = { 4, 8, 12 }; + std::vector median_rgba = vpImageFilter::median(I_median_rgba); + std::vector expected_median_rgba = { 4.f, 8.f, 12.f }; for (unsigned int i = 0; i < 3; i++) { bool test_local = (median_rgba[i] == expected_median_rgba[i]); test &= test_local; diff --git a/modules/gui/CMakeLists.txt b/modules/gui/CMakeLists.txt index 10fe60c3ef..85483a04b5 100644 --- a/modules/gui/CMakeLists.txt +++ b/modules/gui/CMakeLists.txt @@ -43,6 +43,7 @@ if(USE_X11) list(APPEND opt_libs ${X11_LIBRARIES}) mark_as_advanced(X11_xcb_icccm_INCLUDE_PATH) mark_as_advanced(X11_xcb_icccm_LIB) + mark_as_advanced(X11_xcb_xkb_INCLUDE_PATH) endif() if(USE_GTK2) list(APPEND opt_incs ${GTK2_INCLUDE_DIRS}) diff --git a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h index f549759318..b81a7a20db 100644 --- a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h +++ b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h @@ -105,20 +105,20 @@ class VISP_EXPORT vpCircleHoughTransform public: vpCircleHoughTransformParameters() : m_gaussianKernelSize(5) - , m_gaussianStdev(1.) + , m_gaussianStdev(1.f) , m_sobelKernelSize(3) - , m_cannyThresh(-1) + , m_cannyThresh(-1.f) , m_edgeMapFilteringNbIter(1) , m_centerXlimits(std::pair(std::numeric_limits::min(), std::numeric_limits::max())) , m_centerYlimits(std::pair(std::numeric_limits::min(), std::numeric_limits::max())) , m_minRadius(0) , m_maxRadius(1000) , m_dilatationNbIter(1) - , m_centerThresh(50.) - , m_radiusRatioThresh(2.) - , m_circlePerfectness(0.9) - , m_centerMinDist(15.) - , m_mergingRadiusDiffThresh(1.5 * (float)m_centerMinDist) + , m_centerThresh(50.f) + , m_radiusRatioThresh(2.f) + , m_circlePerfectness(0.9f) + , m_centerMinDist(15.f) + , m_mergingRadiusDiffThresh(1.5f * m_centerMinDist) { } @@ -532,7 +532,7 @@ class VISP_EXPORT vpCircleHoughTransform */ inline void setCircleMinRadius(const float &circle_min_radius) { - m_algoParams.m_minRadius = circle_min_radius; + m_algoParams.m_minRadius = static_cast(circle_min_radius); } /*! @@ -541,7 +541,7 @@ class VISP_EXPORT vpCircleHoughTransform */ inline void setCircleMaxRadius(const float &circle_max_radius) { - m_algoParams.m_maxRadius = circle_max_radius; + m_algoParams.m_maxRadius = static_cast(circle_max_radius); } /*! @@ -694,7 +694,7 @@ class VISP_EXPORT vpCircleHoughTransform /*! * Get circles min radius in pixels. */ - inline float getCircleMinRadius() const + inline unsigned int getCircleMinRadius() const { return m_algoParams.m_minRadius; } @@ -702,7 +702,7 @@ class VISP_EXPORT vpCircleHoughTransform /*! * Get circles max radius in pixels. */ - inline float getCircleMaxRadius() const + inline unsigned int getCircleMaxRadius() const { return m_algoParams.m_maxRadius; } diff --git a/modules/imgproc/src/vpCircleHoughTransform.cpp b/modules/imgproc/src/vpCircleHoughTransform.cpp index adeda3a39b..c7291ca8d7 100644 --- a/modules/imgproc/src/vpCircleHoughTransform.cpp +++ b/modules/imgproc/src/vpCircleHoughTransform.cpp @@ -221,7 +221,7 @@ vpCircleHoughTransform::edgeDetection(const vpImage &I) { #if defined(HAVE_OPENCV_IMGPROC) float cannyThresh = m_algoParams.m_cannyThresh; - double lowerThresh; + float lowerThresh; // Apply the Canny edge operator to compute the edge map // The canny method performs Gaussian blur and gradient computation if (m_algoParams.m_cannyThresh < 0.) { @@ -293,7 +293,7 @@ vpCircleHoughTransform::computeCenterCandidates() int minimumXposition = std::max(m_algoParams.m_centerXlimits.first, -1 * (int)m_algoParams.m_maxRadius); int maximumXposition = std::min(m_algoParams.m_centerXlimits.second, (int)(m_algoParams.m_maxRadius + nbCols)); minimumXposition = std::min(minimumXposition, maximumXposition - 1); - float minimumXpositionDouble = minimumXposition; + float minimumXpositionFloat = static_cast(minimumXposition); int offsetX = minimumXposition; int accumulatorWidth = maximumXposition - minimumXposition + 1; if (accumulatorWidth <= 0) { @@ -307,7 +307,7 @@ vpCircleHoughTransform::computeCenterCandidates() int minimumYposition = std::max(m_algoParams.m_centerYlimits.first, -1 * (int)m_algoParams.m_maxRadius); int maximumYposition = std::min(m_algoParams.m_centerYlimits.second, (int)(m_algoParams.m_maxRadius + nbRows)); minimumYposition = std::min(minimumYposition, maximumYposition - 1); - float minimumYpositionDouble = minimumYposition; + float minimumYpositionFloat = static_cast(minimumYposition); int offsetY = minimumYposition; int accumulatorHeight = maximumYposition - minimumYposition + 1; if (accumulatorHeight <= 0) { @@ -338,7 +338,7 @@ vpCircleHoughTransform::computeCenterCandidates() float x1 = (float)c + (float)rad * sx; float y1 = (float)r + (float)rad * sy; - if (x1 < minimumXpositionDouble || y1 < minimumYpositionDouble) { + if (x1 < minimumXpositionFloat || y1 < minimumYpositionFloat) { continue; // If either value is lower than maxRadius, it means that the center is outside the search region. } @@ -346,21 +346,21 @@ vpCircleHoughTransform::computeCenterCandidates() int y_low, y_high; if (x1 > 0.) { - x_low = std::floor(x1); - x_high = std::ceil(x1); + x_low = static_cast(std::floor(x1)); + x_high = static_cast(std::ceil(x1)); } else { - x_low = -1 * std::ceil(-1. * x1); - x_high = -1 * std::floor(-1. * x1); + x_low = -(static_cast(std::ceil(-x1))); + x_high = -(static_cast(std::floor(-x1))); } if (y1 > 0.) { - y_low = std::floor(y1); - y_high = std::ceil(y1); + y_low = static_cast(std::floor(y1)); + y_high = static_cast(std::ceil(y1)); } else { - y_low = -1 * std::ceil(-1. * y1); - y_high = -1 * std::floor(-1. * y1); + y_low = -(static_cast(std::ceil(-1. * y1))); + y_high = -(static_cast(std::floor(-1. * y1))); } auto updateAccumulator = @@ -441,14 +441,14 @@ void vpCircleHoughTransform::computeCircleCandidates() { size_t nbCenterCandidates = m_centerCandidatesList.size(); - unsigned int nbBins = (m_algoParams.m_maxRadius - m_algoParams.m_minRadius + 1)/ m_algoParams.m_centerMinDist; + unsigned int nbBins = static_cast((m_algoParams.m_maxRadius - m_algoParams.m_minRadius + 1)/ m_algoParams.m_centerMinDist); nbBins = std::max((unsigned int)1, nbBins); // Avoid having 0 bins, which causes segfault std::vector radiusAccumList; /*!< Radius accumulator for each center candidates.*/ std::vector radiusActualValueList; /*!< Vector that contains the actual distance between the edge points and the center candidates.*/ unsigned int rmin2 = m_algoParams.m_minRadius * m_algoParams.m_minRadius; - unsigned int rmax2 = m_algoParams.m_maxRadius * m_algoParams.m_maxRadius; - int circlePerfectness2 = m_algoParams.m_circlePerfectness * m_algoParams.m_circlePerfectness; + unsigned int rmax2 = static_cast(m_algoParams.m_maxRadius * m_algoParams.m_maxRadius); + int circlePerfectness2 = static_cast(m_algoParams.m_circlePerfectness * m_algoParams.m_circlePerfectness); for (size_t i = 0; i < nbCenterCandidates; i++) { std::pair centerCandidate = m_centerCandidatesList[i]; @@ -469,12 +469,12 @@ vpCircleHoughTransform::computeCircleCandidates() float gy = m_dIy[edgePoint.first][edgePoint.second]; float grad2 = gx * gx + gy * gy; - int scalProd = rx * gx + ry * gy; - int scalProd2 = scalProd * scalProd; + float scalProd = rx * gx + ry * gy; + float scalProd2 = scalProd * scalProd; if (scalProd2 >= circlePerfectness2 * r2 * grad2) { // Look for the Radius Candidate Bin RCB_k to which d_ij is "the closest" will have an additionnal vote - float r = std::sqrt(r2); - unsigned int r_bin = std::ceil((r - m_algoParams.m_minRadius)/ m_algoParams.m_centerMinDist); + float r = static_cast(std::sqrt(r2)); + unsigned int r_bin = static_cast(std::ceil((r - m_algoParams.m_minRadius)/ m_algoParams.m_centerMinDist)); r_bin = std::min(r_bin, nbBins - 1); radiusAccumList[r_bin]++; radiusActualValueList[r_bin] += r; diff --git a/modules/tracker/me/include/visp3/me/vpMeNurbs.h b/modules/tracker/me/include/visp3/me/vpMeNurbs.h index 3f6a7e5bb2..0ae91e008f 100644 --- a/modules/tracker/me/include/visp3/me/vpMeNurbs.h +++ b/modules/tracker/me/include/visp3/me/vpMeNurbs.h @@ -151,9 +151,9 @@ class VISP_EXPORT vpMeNurbs : public vpMeTracker //! search. bool enableCannyDetection; //! First canny threshold - double cannyTh1; + float cannyTh1; //! Second canny threshold - double cannyTh2; + float cannyTh2; public: vpMeNurbs(); @@ -181,7 +181,7 @@ class VISP_EXPORT vpMeNurbs : public vpMeTracker \param th1 : The first threshold; \param th2 : The second threshold; */ - void setCannyThreshold(double th1, double th2) + void setCannyThreshold(float th1, float th2) { this->cannyTh1 = th1; this->cannyTh2 = th2; diff --git a/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp b/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp index 4bfacc7737..c000eb1587 100644 --- a/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp +++ b/modules/tracker/me/src/moving-edges/vpMeNurbs.cpp @@ -216,7 +216,7 @@ vpMeNurbs::vpMeNurbs() */ vpMeNurbs::vpMeNurbs(const vpMeNurbs &menurbs) : vpMeTracker(menurbs), nurbs(menurbs.nurbs), dist(0.), nbControlPoints(20), beginPtFound(0), endPtFound(0), - enableCannyDetection(false), cannyTh1(100.), cannyTh2(200.) + enableCannyDetection(false), cannyTh1(100.f), cannyTh2(200.f) { dist = menurbs.dist; nbControlPoints = menurbs.nbControlPoints; @@ -547,8 +547,8 @@ void vpMeNurbs::seekExtremitiesCanny(const vpImage &I) std::list ip_edges_list; if (firstBorder != vpImagePoint(-1, -1)) { unsigned int dir; - double fi = firstBorder.get_i(); - double fj = firstBorder.get_j(); + double fi = static_cast(firstBorder.get_i()); + double fj = static_cast(firstBorder.get_j()); double w = Isub.getWidth() - 1; double h = Isub.getHeight() - 1; // if (firstBorder.get_i() == 0) dir = 4; diff --git a/modules/vision/include/visp3/vision/vpPose.h b/modules/vision/include/visp3/vision/vpPose.h index 928305a196..fd5287a4a9 100644 --- a/modules/vision/include/visp3/vision/vpPose.h +++ b/modules/vision/include/visp3/vision/vpPose.h @@ -50,7 +50,6 @@ #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS #include #endif -#include #include #include @@ -412,11 +411,11 @@ class VISP_EXPORT vpPose (void)ip_unused; if (pts.find(ip_id) == end(pts)) { throw(vpException(vpException::fatalError, - "Cannot compute pose with points and image points which do not have the same IDs")); + "Cannot compute pose with points and image points which do not have the same IDs")); } } - std::vector P{}, Q {}; + std::vector P {}, Q {}; // The next line in C++17 produces a build error with Visual Studio 2017, that's why we // use rather C++11 to loop through std::map // for (auto [pt_id, pt] : pts) { diff --git a/tutorial/detection/dnn/CMakeLists.txt b/tutorial/detection/dnn/CMakeLists.txt index 2ad0caa9ef..d726f78737 100644 --- a/tutorial/detection/dnn/CMakeLists.txt +++ b/tutorial/detection/dnn/CMakeLists.txt @@ -36,5 +36,5 @@ foreach(data ${tutorial_data}) endforeach() if(USE_TENSORT) - vp_set_source_file_compile_flag(tutorial-dnn-tensorrt-live.cpp -Wno-deprecated-declarations) + visp_set_source_file_compile_flag(tutorial-dnn-tensorrt-live.cpp -Wno-deprecated-declarations) endif() diff --git a/tutorial/image/tutorial-draw-circle.cpp b/tutorial/image/tutorial-draw-circle.cpp index 9c96ce2762..061d59e14f 100644 --- a/tutorial/image/tutorial-draw-circle.cpp +++ b/tutorial/image/tutorial-draw-circle.cpp @@ -20,10 +20,10 @@ int main() vpDisplay::setTitle(I, "Gray image"); vpDisplay::display(I); //! [Circle display] - vpImageCircle circle(vpImagePoint(I.getHeight()/3, I.getWidth()/3), I.getWidth()/10); + vpImageCircle circle(vpImagePoint(I.getHeight()/3, I.getWidth()/3), I.getWidth()/10.f); // Displays in overlay a red circle on the image // i.e. does not modify I - vpDisplay::displayCircle(I, circle, vpColor::red, 2); + vpDisplay::displayCircle(I, circle, vpColor::red, false, 2); //! [Circle display] vpDisplay::flush(I); vpDisplay::setTitle(I, "Overlay"); @@ -32,7 +32,7 @@ int main() vpDisplay::getClick(I); //! [Circle draw uchar] - vpImageCircle circle2(vpImagePoint(I.getHeight()/3, 2*I.getWidth()/3), I.getWidth()/10); + vpImageCircle circle2(vpImagePoint(I.getHeight()/3, 2*I.getWidth()/3), I.getWidth()/10.f); // Draws a white circle on the image // i.e. modifies I vpImageDraw::drawCircle(I, circle2, 255, 2); @@ -47,7 +47,7 @@ int main() { //! [Circle draw color] - vpImageCircle circle3(vpImagePoint(2*I.getHeight()/3, I.getWidth()/2), I.getWidth()/10); + vpImageCircle circle3(vpImagePoint(2*I.getHeight()/3, I.getWidth()/2), I.getWidth()/10.f); // Draws a blue circle on the image // i.e. modifies I_rgb vpImageDraw::drawCircle(I_rgb, circle3, vpColor::blue, 2); diff --git a/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp b/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp index 36144610ab..94691b70f3 100644 --- a/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp +++ b/tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp @@ -72,8 +72,8 @@ std::string getAvailableTypeInputImage(const std::string &prefix = "<", const st //! [Draw disks] void -drawDisk(vpImage &I, const vpImagePoint ¢er, const unsigned int &radius - , const unsigned int &borderColor, const unsigned int &fillingColor, const unsigned int &thickness, const unsigned int &bckg) +drawDisk(vpImage &I, const vpImagePoint ¢er, const unsigned int &radius, + const unsigned int &borderColor, const unsigned int &fillingColor, const unsigned int &thickness, const unsigned int &bckg) //! [Draw disks] { vpImageDraw::drawCircle(I, center, radius, borderColor, thickness); @@ -146,13 +146,13 @@ generateImage(const TypeInputImage &inputType) } drawDisk(I_src, vpImagePoint(top, left), circleRadius, circleColor, circleColor, circleThickness, bckg); - drawDisk(I_src, vpImagePoint(top, left), circleRadius * 0.50, circleColor / 2, circleColor / 2, circleThickness, circleColor); + drawDisk(I_src, vpImagePoint(top, left), circleRadius / 2, circleColor / 2, circleColor / 2, circleThickness, circleColor); drawDisk(I_src, vpImagePoint(bottom, left), circleRadius, circleColor, circleColor, circleThickness, bckg); - drawDisk(I_src, vpImagePoint(bottom, left), circleRadius * 0.50, circleColor / 2, circleColor / 2, circleThickness, circleColor); + drawDisk(I_src, vpImagePoint(bottom, left), circleRadius / 2, circleColor / 2, circleColor / 2, circleThickness, circleColor); drawDisk(I_src, vpImagePoint(top, right), circleRadius, circleColor, circleColor, circleThickness, bckg); - drawDisk(I_src, vpImagePoint(top, right), circleRadius * 0.50, circleColor / 2, circleColor / 2, circleThickness, circleColor); + drawDisk(I_src, vpImagePoint(top, right), circleRadius / 2, circleColor / 2, circleColor / 2, circleThickness, circleColor); drawDisk(I_src, vpImagePoint(bottom, right), circleRadius, circleColor, circleColor, circleThickness, bckg); - drawDisk(I_src, vpImagePoint(bottom, right), circleRadius * 0.50, circleColor / 2, circleColor / 2, circleThickness, circleColor); + drawDisk(I_src, vpImagePoint(bottom, right), circleRadius / 2, circleColor / 2, circleColor / 2, circleThickness, circleColor); std::cout << "Done drawing" << std::endl << std::flush; return I_src; @@ -196,12 +196,12 @@ int main(int argc, char **argv) const std::string def_jsonFilePath = std::string(""); const int def_nbCirclesToDetect = -1; const int def_gaussianKernelSize = 5; - const double def_gaussianSigma = 1.; + const float def_gaussianSigma = 1.f; const int def_sobelKernelSize = 3; #ifdef HAVE_OPENCV_IMGPROC - const double def_cannyThresh = 150.; + const float def_cannyThresh = 150.f; #else - const double def_cannyThresh = 25.; + const float def_cannyThresh = 25.f; #endif const int def_nbEdgeFilteringIter = 2; const std::pair def_centerXlimits = std::pair(0, 640); @@ -209,31 +209,30 @@ int main(int argc, char **argv) const unsigned int def_minRadius = 0; const unsigned int def_maxRadius = 1000; const int def_dilatationRepet = 1; - const double def_centerThresh = -1.; - const double def_radiusThreshRatio = -1.; - const double def_circlePerfectness = 0.85; - const double def_centerDistanceThresh = 15; - const double def_radiusDifferenceThresh = 15; - + const float def_centerThresh = -1.f; + const float def_radiusThreshRatio = -1.f; + const float def_circlePerfectness = 0.85f; + const float def_centerDistanceThresh = 15.f; + const float def_radiusDifferenceThresh = 15.f; std::string opt_input(def_input); std::string opt_jsonFilePath = def_jsonFilePath; int opt_nbCirclesToDetect = def_nbCirclesToDetect; int opt_gaussianKernelSize = def_gaussianKernelSize; - double opt_gaussianSigma = def_gaussianSigma; + float opt_gaussianSigma = def_gaussianSigma; int opt_sobelKernelSize = def_sobelKernelSize; - double opt_cannyThresh = def_cannyThresh; + float opt_cannyThresh = def_cannyThresh; int opt_nbEdgeFilteringIter = def_nbEdgeFilteringIter; std::pair opt_centerXlimits = def_centerXlimits; std::pair opt_centerYlimits = def_centerYlimits; unsigned int opt_minRadius = def_minRadius; unsigned int opt_maxRadius = def_maxRadius; int opt_dilatationRepet = def_dilatationRepet; - double opt_centerThresh = def_centerThresh; - int opt_radiusThreshRatio = def_radiusThreshRatio; - double opt_circlePerfectness = def_circlePerfectness; - double opt_centerDistanceThresh = def_centerDistanceThresh; - double opt_radiusDifferenceThresh = def_radiusDifferenceThresh; + float opt_centerThresh = def_centerThresh; + float opt_radiusThreshRatio = def_radiusThreshRatio; + float opt_circlePerfectness = def_circlePerfectness; + float opt_centerDistanceThresh = def_centerDistanceThresh; + float opt_radiusDifferenceThresh = def_radiusDifferenceThresh; bool opt_displayCanny = false; for (int i = 1; i < argc; i++) { @@ -257,7 +256,7 @@ int main(int argc, char **argv) i++; } else if (argName == "--gaussian-sigma" && i + 1 < argc) { - opt_gaussianSigma = atof(argv[i + 1]); + opt_gaussianSigma = static_cast(atof(argv[i + 1])); i++; } else if (argName == "--sobel-kernel" && i + 1 < argc) { @@ -265,7 +264,7 @@ int main(int argc, char **argv) i++; } else if (argName == "--canny-thresh" && i + 1 < argc) { - opt_cannyThresh = atof(argv[i + 1]); + opt_cannyThresh = static_cast(atof(argv[i + 1])); i++; } else if (argName == "--edge-filter" && i + 1 < argc) { @@ -282,7 +281,7 @@ int main(int argc, char **argv) i += 2; } else if (argName == "--center-thresh" && i + 1 < argc) { - opt_centerThresh = atof(argv[i + 1]); + opt_centerThresh = static_cast(atof(argv[i + 1])); i++; } else if (argName == "--center-xlim" && i + 2 < argc) { @@ -294,16 +293,16 @@ int main(int argc, char **argv) i += 2; } else if (argName == "--radius-thresh" && i + 1 < argc) { - opt_radiusThreshRatio = atof(argv[i + 1]); + opt_radiusThreshRatio = static_cast(atof(argv[i + 1])); i++; } else if (argName == "--circle-perfectness" && i + 1 < argc) { - opt_circlePerfectness = atof(argv[i + 1]); + opt_circlePerfectness = static_cast(atof(argv[i + 1])); i++; } else if (argName == "--merging-thresh" && i + 2 < argc) { - opt_centerDistanceThresh = atof(argv[i + 1]); - opt_radiusDifferenceThresh = atof(argv[i + 2]); + opt_centerDistanceThresh = static_cast(atof(argv[i + 1])); + opt_radiusDifferenceThresh = static_cast(atof(argv[i + 2])); i += 2; } else if (argName == "--display-edge-map") {