diff --git a/.vscode/settings.json b/.vscode/settings.json index c01e3cc45a..b8e497f10e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -166,7 +166,10 @@ "dense": "cpp", "stdvector": "cpp", "numericaldiff": "cpp", - "source_location": "cpp" + "source_location": "cpp", + "stdfloat": "cpp", + "text_encoding": "cpp", + "print": "cpp" }, "C_Cpp.vcFormat.indent.namespaceContents": false, "editor.formatOnSave": true, diff --git a/3rdparty/apriltag/CMakeLists.txt b/3rdparty/apriltag/CMakeLists.txt index 03a2725d2f..b3308b4e83 100644 --- a/3rdparty/apriltag/CMakeLists.txt +++ b/3rdparty/apriltag/CMakeLists.txt @@ -25,7 +25,7 @@ endif() if(UNIX) if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U__STRICT_ANSI__ -fPIC -std=c99") endif() endif() @@ -35,6 +35,16 @@ if(ENABLE_SOLUTION_FOLDERS) set_target_properties(${APRILTAG_LIBRARY} PROPERTIES FOLDER "3rdparty") endif() +if(VISP_CXX_STANDARD EQUAL VISP_CXX_STANDARD_98) + set(CMAKE_C_STANDARD 99) + set(CMAKE_C_STANDARD_REQUIRED TRUE) + if(UNIX) + if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U__STRICT_ANSI__") + endif() + endif() +endif() + set_target_properties(${APRILTAG_LIBRARY} PROPERTIES OUTPUT_NAME ${APRILTAG_LIBRARY} DEBUG_POSTFIX "${VISP_DEBUG_POSTFIX}" @@ -67,6 +77,7 @@ if(MSVC) vp_set_source_file_compile_flag(tag25h9.c /wd4996) vp_set_source_file_compile_flag(tag36h10.c /wd4996) vp_set_source_file_compile_flag(tag36h11.c /wd4996) + vp_set_source_file_compile_flag(tagCircle21h7.c /wd4996) # disable optimization foreach(f ${tag_srcs}) vp_set_source_file_compile_flag(${f} /O0) diff --git a/cmake/AddExtraCompilationFlags.cmake b/cmake/AddExtraCompilationFlags.cmake index fb17311bd6..74b7be5c91 100644 --- a/cmake/AddExtraCompilationFlags.cmake +++ b/cmake/AddExtraCompilationFlags.cmake @@ -97,6 +97,7 @@ endif() if((NOT VISP_HAVE_NULLPTR) AND (VISP_CXX_STANDARD EQUAL VISP_CXX_STANDARD_98) AND (NOT MSVC)) add_extra_compiler_option("-Wno-c++11-compat") + add_extra_compiler_option("-Wno-c++0x-compat") endif() # Note here ViSPDetectPlatform.cmake should be called before this file to set ARM var diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index efa274b9fc..dd4643bae9 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -1,5 +1,4 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. * Copyright (C) 2005 - 2023 by Inria. All rights reserved. * @@ -30,8 +29,7 @@ * * Description: * ViSP configuration. - * -*****************************************************************************/ + */ #ifndef VP_CONFIG_H #define VP_CONFIG_H @@ -610,6 +608,23 @@ namespace vp = VISP_NAMESPACE_NAME; #include #endif +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) +// was implemented and released in GCC 4.9.0. In older version of GCC, it is not implemented. +// See https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions +// Calling std::regex lead to a segfault on centos 7.2 that has g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11) +#include +#if defined(WINRT) || defined(WIN32) +#define VISP_HAVE_WORKING_REGEX +#elif __cplusplus >= 201103L && \ + (!defined(__GLIBCXX__) || (__cplusplus >= 201402L) || \ + (defined(_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT) || \ + defined(_GLIBCXX_REGEX_STATE_LIMIT) || \ + (defined(_GLIBCXX_RELEASE) && \ + _GLIBCXX_RELEASE > 4))) +#define VISP_HAVE_WORKING_REGEX +#endif +#endif + // Handle portable symbol export. // Defining manually which symbol should be exported is required // under Windows whether MinGW or MSVC is used. diff --git a/doc/config-doxygen.in b/doc/config-doxygen.in index 4b802524dc..8aa93cba61 100644 --- a/doc/config-doxygen.in +++ b/doc/config-doxygen.in @@ -2451,6 +2451,7 @@ PREDEFINED = @DOXYGEN_SHOULD_SKIP_THIS@ \ VISP_HAVE_VIPER850 \ VISP_HAVE_VIPER850_DATA \ VISP_HAVE_VIRTUOSE \ + VISP_HAVE_WORKING_REGEX VISP_HAVE_X11 \ VISP_HAVE_XML2 \ VISP_HAVE_YARP \ diff --git a/example/device/framegrabber/readRealSenseData.cpp b/example/device/framegrabber/readRealSenseData.cpp index f4bde88236..24ba124a22 100644 --- a/example/device/framegrabber/readRealSenseData.cpp +++ b/example/device/framegrabber/readRealSenseData.cpp @@ -68,7 +68,7 @@ #endif #endif -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) #define GETOPTARGS "ci:e:jbzodh" #else #define GETOPTARGS "ci:e:jbodh" @@ -94,7 +94,7 @@ void usage(const char *name, const char *badparam) << " [-c]" << " [-j]" << " [-b]" -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) << " [-z]" #endif << " [-o]" @@ -117,7 +117,7 @@ void usage(const char *name, const char *badparam) << " -b" << std::endl << " Depth and Pointcloud streams are saved in binary format." << std::endl << std::endl -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) << " -z" << std::endl << " Pointcloud stream is saved in NPZ format." << std::endl << std::endl @@ -161,7 +161,7 @@ bool getOptions(int argc, const char *argv[], std::string &input_directory, std: case 'b': force_binary_format = true; break; -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) case 'z': read_npz = true; break; @@ -252,7 +252,7 @@ bool readData(int cpt, const std::string &input_directory, const std::string &pa } } } -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) else { visp::cnpy::npz_t npz_data = visp::cnpy::npz_load(filename_depth); @@ -312,7 +312,7 @@ bool readData(int cpt, const std::string &input_directory, const std::string &pa } } } -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) else if (read_npz) { visp::cnpy::npz_t npz_data = visp::cnpy::npz_load(filename_pointcloud); diff --git a/example/device/framegrabber/saveRealSenseData.cpp b/example/device/framegrabber/saveRealSenseData.cpp index fc14bb66bb..fc18d6e896 100644 --- a/example/device/framegrabber/saveRealSenseData.cpp +++ b/example/device/framegrabber/saveRealSenseData.cpp @@ -74,7 +74,7 @@ #define USE_REALSENSE2 #endif -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) #define GETOPTARGS "se:o:acdpzijCf:bvh" #else #define GETOPTARGS "se:o:acdpijCf:bvh" @@ -97,7 +97,7 @@ void usage(const char *name, const char *badparam, int fps) << " [-d]" << " [-p]" << " [-b]" -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) << " [-z]" #endif << " [-i]" @@ -133,7 +133,7 @@ void usage(const char *name, const char *badparam, int fps) << " -b" << std::endl << " Force depth and pointcloud to be saved in (little-endian) binary format." << std::endl << std::endl -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) << " -z" << std::endl << " Pointcloud is saved in NPZ format." << std::endl << std::endl @@ -220,7 +220,7 @@ bool getOptions(int argc, const char *argv[], bool &save, std::string &pattern, case 'v': depth_hist_visu = true; break; -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) case 'z': save_pcl_npz_format = true; break; @@ -481,7 +481,7 @@ class vpStorageWorker } } } -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) else { ss << m_directory << "/depth_image_" << m_save_pattern << ".npz"; snprintf(buffer, FILENAME_MAX, ss.str().c_str(), m_cpt); @@ -575,7 +575,7 @@ class vpStorageWorker } } else if (m_save_pcl_npz_format) { -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) // Write Npz headers std::vector vec_filename(filename_point_cloud.begin(), filename_point_cloud.end()); // Null-terminated character is handled at reading @@ -708,7 +708,7 @@ int main(int argc, const char *argv[]) std::cout << "save_jpeg: " << save_jpeg << std::endl; std::cout << "stream_fps: " << stream_fps << std::endl; std::cout << "depth_hist_visu: " << depth_hist_visu << std::endl; -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) std::cout << "save_pcl_npz_format: " << save_pcl_npz_format << std::endl; #endif std::cout << "save_force_binary_format: " << save_force_binary_format << std::endl; diff --git a/modules/ar/include/visp3/ar/vpPanda3DCommonFilters.h b/modules/ar/include/visp3/ar/vpPanda3DCommonFilters.h index 9b2dafda5a..8bee8df17b 100644 --- a/modules/ar/include/visp3/ar/vpPanda3DCommonFilters.h +++ b/modules/ar/include/visp3/ar/vpPanda3DCommonFilters.h @@ -53,7 +53,7 @@ class VISP_EXPORT vpPanda3DLuminanceFilter : public vpPanda3DPostProcessFilter void getRender(vpImage &I) const; private: - static const char *FRAGMENT_SHADER; + static const std::string FRAGMENT_SHADER; }; /** @@ -71,7 +71,7 @@ class VISP_EXPORT vpPanda3DGaussianBlur : public vpPanda3DPostProcessFilter void getRender(vpImage &I) const; private: - static const char *FRAGMENT_SHADER; + static const std::string FRAGMENT_SHADER; }; /** @@ -96,7 +96,7 @@ class VISP_EXPORT vpPanda3DCanny : public vpPanda3DPostProcessFilter void setupScene() VP_OVERRIDE; private: - static const char *FRAGMENT_SHADER; + static const std::string FRAGMENT_SHADER; float m_edgeThreshold; }; diff --git a/modules/ar/include/visp3/ar/vpPanda3DGeometryRenderer.h b/modules/ar/include/visp3/ar/vpPanda3DGeometryRenderer.h index c4540b969a..186a102bb0 100644 --- a/modules/ar/include/visp3/ar/vpPanda3DGeometryRenderer.h +++ b/modules/ar/include/visp3/ar/vpPanda3DGeometryRenderer.h @@ -96,11 +96,6 @@ class VISP_EXPORT vpPanda3DGeometryRenderer : public vpPanda3DBaseRenderer vpRenderType m_renderType; PointerTo m_normalDepthTexture; PointerTo m_normalDepthBuffer; - - static const char *SHADER_VERT_NORMAL_AND_DEPTH_OBJECT; - static const char *SHADER_VERT_NORMAL_AND_DEPTH_CAMERA; - static const char *SHADER_FRAG_NORMAL_AND_DEPTH; - }; END_VISP_NAMESPACE #endif //VISP_HAVE_PANDA3D diff --git a/modules/ar/src/panda3d-simulator/vpPanda3DCommonFilters.cpp b/modules/ar/src/panda3d-simulator/vpPanda3DCommonFilters.cpp index 232a2302eb..381ba22121 100644 --- a/modules/ar/src/panda3d-simulator/vpPanda3DCommonFilters.cpp +++ b/modules/ar/src/panda3d-simulator/vpPanda3DCommonFilters.cpp @@ -34,20 +34,15 @@ #if defined(VISP_HAVE_PANDA3D) BEGIN_VISP_NAMESPACE -const char *vpPanda3DLuminanceFilter::FRAGMENT_SHADER = R"shader( -#version 330 - -in vec2 texcoords; - -uniform sampler2D p3d_Texture0; - -out vec4 p3d_FragData; - -void main() { - vec4 v = texture(p3d_Texture0, texcoords); - p3d_FragData.b = 0.299 * v.r + 0.587 * v.g + 0.114 * v.b; -} -)shader"; +const std::string vpPanda3DLuminanceFilter::FRAGMENT_SHADER = +"#version 330\n" +"in vec2 texcoords;\n" +"uniform sampler2D p3d_Texture0;\n" +"out vec4 p3d_FragData;\n" +"void main() {\n" +" vec4 v = texture(p3d_Texture0, texcoords);\n" +" p3d_FragData.b = 0.299 * v.r + 0.587 * v.g + 0.114 * v.b;\n" +"}\n"; vpPanda3DLuminanceFilter::vpPanda3DLuminanceFilter(const std::string &name, std::shared_ptr inputRenderer, bool isOutput) : vpPanda3DPostProcessFilter(name, inputRenderer, isOutput, std::string(vpPanda3DLuminanceFilter::FRAGMENT_SHADER)) @@ -65,42 +60,34 @@ void vpPanda3DLuminanceFilter::getRender(vpImage &I) const vpPanda3DPostProcessFilter::getRenderBasic(I); } -const char *vpPanda3DGaussianBlur::FRAGMENT_SHADER = R"shader( -#version 330 - -in vec2 texcoords; - -uniform sampler2D p3d_Texture0; -uniform vec2 dp; // 1 divided by number of pixels - -const float kernel[25] = float[25]( - 2, 4, 5, 4, 2, - 4, 9, 12, 9, 4, - 5, 12, 15, 12, 5, - 4, 9, 12, 9, 4, - 2, 4, 5, 4, 2 -); -const float normalize = 1 / 159.0; - -vec2 offset[25] = vec2[25]( - vec2(-2*dp.x,-2*dp.y), vec2(-dp.x,-2*dp.y), vec2(0,-2*dp.y), vec2(dp.x,-2*dp.y), vec2(2*dp.x,-2*dp.y), - vec2(-2*dp.x,-dp.y), vec2(-dp.x, -dp.y), vec2(0.0, -dp.y), vec2(dp.x, -dp.y), vec2(2*dp.x,-dp.y), - vec2(-2*dp.x,0.0), vec2(-dp.x, 0.0), vec2(0.0, 0.0), vec2(dp.x, 0.0), vec2(2*dp.x,0.0), - vec2(-2*dp.x, dp.y), vec2(-dp.x, dp.y), vec2(0.0, dp.y), vec2(dp.x, dp.y), vec2(2*dp.x, dp.y), - vec2(-2*dp.x, 2*dp.y), vec2(-dp.x, 2*dp.y), vec2(0.0, 2*dp.y), vec2(dp.x, 2*dp.y), vec2(2*dp.x, 2*dp.y) -); - -out vec4 p3d_FragData; - -void main() { - float v = 0.f; - - for(int i = 0; i < 25; ++i) { - v += kernel[i] * texture(p3d_Texture0, texcoords + offset[i]).b ; - } - p3d_FragData.b = v * normalize; -} -)shader"; +const std::string vpPanda3DGaussianBlur::FRAGMENT_SHADER = +"#version 330\n" +"in vec2 texcoords;\n" +"uniform sampler2D p3d_Texture0;\n" +"uniform vec2 dp; // 1 divided by number of pixels\n" +"const float kernel[25] = float[25](\n" +" 2, 4, 5, 4, 2,\n" +" 4, 9, 12, 9, 4,\n" +" 5, 12, 15, 12, 5,\n" +" 4, 9, 12, 9, 4,\n" +" 2, 4, 5, 4, 2\n" +");\n" +"const float normalize = 1 / 159.0;\n" +"vec2 offset[25] = vec2[25](\n" +" vec2(-2*dp.x,-2*dp.y), vec2(-dp.x,-2*dp.y), vec2(0,-2*dp.y), vec2(dp.x,-2*dp.y), vec2(2*dp.x,-2*dp.y),\n" +" vec2(-2*dp.x,-dp.y), vec2(-dp.x, -dp.y), vec2(0.0, -dp.y), vec2(dp.x, -dp.y), vec2(2*dp.x,-dp.y),\n" +" vec2(-2*dp.x,0.0), vec2(-dp.x, 0.0), vec2(0.0, 0.0), vec2(dp.x, 0.0), vec2(2*dp.x,0.0),\n" +" vec2(-2*dp.x, dp.y), vec2(-dp.x, dp.y), vec2(0.0, dp.y), vec2(dp.x, dp.y), vec2(2*dp.x, dp.y),\n" +" vec2(-2*dp.x, 2*dp.y), vec2(-dp.x, 2*dp.y), vec2(0.0, 2*dp.y), vec2(dp.x, 2*dp.y), vec2(2*dp.x, 2*dp.y)\n" +");\n" +"out vec4 p3d_FragData;\n" +"void main() {\n" +" float v = 0.f;\n" +" for(int i = 0; i < 25; ++i) {\n" +" v += kernel[i] * texture(p3d_Texture0, texcoords + offset[i]).b;\n" +" }\n" +" p3d_FragData.b = v * normalize;\n" +"}\n"; vpPanda3DGaussianBlur::vpPanda3DGaussianBlur(const std::string &name, std::shared_ptr inputRenderer, bool isOutput) : vpPanda3DPostProcessFilter(name, inputRenderer, isOutput, vpPanda3DGaussianBlur::FRAGMENT_SHADER) @@ -120,64 +107,53 @@ void vpPanda3DGaussianBlur::getRender(vpImage &I) const vpPanda3DPostProcessFilter::getRenderBasic(I); } -const char *vpPanda3DCanny::FRAGMENT_SHADER = R"shader( -#version 330 - -in vec2 texcoords; - -uniform sampler2D p3d_Texture0; -uniform vec2 dp; // 1 divided by number of pixels -uniform float edgeThreshold; - -const float kernel[9] = float[9]( - 0.0, 1.0, 0.0, - 1.0,-4.0, 1.0, - 0.0, 1.0, 0.0 -); - -const float kernel_h[9] = float[9]( - -1.0, 0.0, 1.0, - -2.0, 0.0, 2.0, - -1.0, 0.0, 1.0 -); - -const float kernel_v[9] = float[9]( - -1.0, -2.0, -1.0, - 0.0, 0.0, 0.0, - 1.0, 2.0, 1.0 -); - -vec2 offset[9] = vec2[9]( - vec2(-dp.x, -dp.y), vec2(0.0, -dp.y), vec2(dp.x, -dp.y), - vec2(-dp.x, 0.0), vec2(0.0, 0.0), vec2(dp.x, 0.0), - vec2(-dp.x, dp.y), vec2(0.0, dp.y), vec2(dp.x, dp.y) -); - - -out vec4 p3d_FragData; - -void main() { - float sum = 0.f; - for(int i = 0; i < 9; ++i) { - float pix = texture(p3d_Texture0, texcoords + offset[i]).b; - sum += pix * kernel[i]; - } - if(abs(sum * 255.f) > edgeThreshold) { - float sum_h = 0.f; - float sum_v = 0.f; - for(int i = 0; i < 9; ++i) { - float pix = texture(p3d_Texture0, texcoords + offset[i]).b; - sum_h += pix * kernel_h[i]; - sum_v += pix * kernel_v[i]; - } - - vec2 orientationAndValid = sum_h * sum_h + sum_v * sum_v > 0 ? vec2(-atan(sum_v/sum_h), 1.f) : vec2(0.f, 0.f); - p3d_FragData = vec4(sum_h, sum_v, orientationAndValid.x, orientationAndValid.y); - } else { - p3d_FragData = vec4(0.f, 0.f, 0.f, 0.f); - } -} -)shader"; +const std::string vpPanda3DCanny::FRAGMENT_SHADER = +"#version 330\n" +"in vec2 texcoords;\n" +"uniform sampler2D p3d_Texture0;\n" +"uniform vec2 dp; // 1 divided by number of pixels\n" +"uniform float edgeThreshold;\n" +"const float kernel[9] = float[9](\n" +" 0.0, 1.0, 0.0,\n" +" 1.0,-4.0, 1.0,\n" +" 0.0, 1.0, 0.0\n" +");\n" +"const float kernel_h[9] = float[9](\n" +" -1.0, 0.0, 1.0,\n" +" -2.0, 0.0, 2.0,\n" +" -1.0, 0.0, 1.0\n" +");\n" +"const float kernel_v[9] = float[9](\n" +" -1.0, -2.0, -1.0,\n" +" 0.0, 0.0, 0.0,\n" +" 1.0, 2.0, 1.0\n" +");\n" +"vec2 offset[9] = vec2[9](\n" +" vec2(-dp.x, -dp.y), vec2(0.0, -dp.y), vec2(dp.x, -dp.y),\n" +" vec2(-dp.x, 0.0), vec2(0.0, 0.0), vec2(dp.x, 0.0),\n" +" vec2(-dp.x, dp.y), vec2(0.0, dp.y), vec2(dp.x, dp.y)\n" +");\n" +"out vec4 p3d_FragData;\n" +"void main() {\n" +" float sum = 0.f;\n" +" for(int i = 0; i < 9; ++i) {\n" +" float pix = texture(p3d_Texture0, texcoords + offset[i]).b;\n" +" sum += pix * kernel[i];\n" +" }\n" +" if(abs(sum * 255.f) > edgeThreshold) {\n" +" float sum_h = 0.f;\n" +" float sum_v = 0.f;\n" +" for(int i = 0; i < 9; ++i) {\n" +" float pix = texture(p3d_Texture0, texcoords + offset[i]).b;\n" +" sum_h += pix * kernel_h[i];\n" +" sum_v += pix * kernel_v[i];\n" +" }\n" +" vec2 orientationAndValid = sum_h * sum_h + sum_v * sum_v > 0 ? vec2(-atan(sum_v/sum_h), 1.f) : vec2(0.f, 0.f);\n" +" p3d_FragData = vec4(sum_h, sum_v, orientationAndValid.x, orientationAndValid.y);\n" +" } else {\n" +" p3d_FragData = vec4(0.f, 0.f, 0.f, 0.f);\n" +" }\n" +"}\n"; vpPanda3DCanny::vpPanda3DCanny(const std::string &name, std::shared_ptr inputRenderer, bool isOutput, float edgeThreshold) : vpPanda3DPostProcessFilter(name, inputRenderer, isOutput, vpPanda3DCanny::FRAGMENT_SHADER), m_edgeThreshold(edgeThreshold) @@ -195,7 +171,6 @@ void vpPanda3DCanny::setEdgeThreshold(float edgeThreshold) m_renderRoot.set_shader_input("edgeThreshold", LVector2f(m_edgeThreshold)); } - FrameBufferProperties vpPanda3DCanny::getBufferProperties() const { FrameBufferProperties fbp; diff --git a/modules/ar/src/panda3d-simulator/vpPanda3DGeometryRenderer.cpp b/modules/ar/src/panda3d-simulator/vpPanda3DGeometryRenderer.cpp index c1f98c116b..a9d65345ed 100644 --- a/modules/ar/src/panda3d-simulator/vpPanda3DGeometryRenderer.cpp +++ b/modules/ar/src/panda3d-simulator/vpPanda3DGeometryRenderer.cpp @@ -35,62 +35,49 @@ #include BEGIN_VISP_NAMESPACE -const char *vpPanda3DGeometryRenderer::SHADER_VERT_NORMAL_AND_DEPTH_CAMERA = R"shader( -#version 330 -in vec3 p3d_Normal; -in vec4 p3d_Vertex; - -out vec3 oNormal; -uniform mat3 p3d_NormalMatrix; -uniform mat4 p3d_ModelViewMatrix; -uniform mat4 p3d_ModelViewProjectionMatrix; - - -out float distToCamera; - -void main() -{ - - gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex; - oNormal = p3d_NormalMatrix * normalize(p3d_Normal); - vec4 cs_position = p3d_ModelViewMatrix * p3d_Vertex; - distToCamera = -cs_position.z; -} -)shader"; - -const char *vpPanda3DGeometryRenderer::SHADER_VERT_NORMAL_AND_DEPTH_OBJECT = R"shader( - -#version 330 -in vec3 p3d_Normal; -in vec4 p3d_Vertex; -uniform mat4 p3d_ModelViewMatrix; -uniform mat4 p3d_ModelViewProjectionMatrix; -out vec3 oNormal; -out float distToCamera; - -void main() -{ - gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex; - oNormal = vec3(p3d_Normal.x, -p3d_Normal.z, p3d_Normal.y); - vec4 cs_position = p3d_ModelViewMatrix * p3d_Vertex; - distToCamera = -cs_position.z; -} -)shader"; - -const char *vpPanda3DGeometryRenderer::SHADER_FRAG_NORMAL_AND_DEPTH = R"shader( -#version 330 - -in vec3 oNormal; -in float distToCamera; - -out vec4 p3d_FragData; - -void main() -{ - p3d_FragData.bgra = vec4(normalize(oNormal), distToCamera); -} -)shader"; +const std::string SHADER_VERT_NORMAL_AND_DEPTH_CAMERA = +"#version 330\n" +"in vec3 p3d_Normal;\n" +"in vec4 p3d_Vertex;\n" +"uniform mat3 p3d_NormalMatrix;\n" +"uniform mat4 p3d_ModelViewMatrix;\n" +"uniform mat4 p3d_ModelViewProjectionMatrix;\n" +"out vec3 oNormal;\n" +"out float distToCamera;\n" +"void main()\n" +"{\n" +" gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n" +" oNormal = p3d_NormalMatrix * normalize(p3d_Normal);\n" +" vec4 cs_position = p3d_ModelViewMatrix * p3d_Vertex;\n" +" distToCamera = -cs_position.z;\n" +"}\n"; + +const std::string SHADER_VERT_NORMAL_AND_DEPTH_OBJECT = +"#version 330\n" +"in vec3 p3d_Normal;\n" +"in vec4 p3d_Vertex;\n" +"uniform mat4 p3d_ModelViewMatrix;\n" +"uniform mat4 p3d_ModelViewProjectionMatrix;\n" +"out vec3 oNormal;\n" +"out float distToCamera;\n" +"void main()\n" +"{\n" +" gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n" +" oNormal = vec3(p3d_Normal.x, -p3d_Normal.z, p3d_Normal.y);\n" +" vec4 cs_position = p3d_ModelViewMatrix * p3d_Vertex;\n" +" distToCamera = -cs_position.z;\n" +"}\n"; + +const std::string SHADER_FRAG_NORMAL_AND_DEPTH = +"#version 330\n" +"in vec3 oNormal;\n" +"in float distToCamera;\n" +"out vec4 p3d_FragData;\n" +"void main()\n" +"{\n" +" p3d_FragData.bgra = vec4(normalize(oNormal), distToCamera);\n" +"}\n"; std::string renderTypeToName(vpPanda3DGeometryRenderer::vpRenderType type) { diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index dad571c119..7c0778d207 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -331,7 +331,7 @@ vp_glob_module_copy_data("test/math/data/*.pgm" "modules/core" NO_INSTALL) vp_glob_module_copy_data("src/image/private/Rubik-Regular.ttf" "data/font") if(UNIX) - vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp -Wno-misleading-indentation) + vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp -Wno-misleading-indentation -Wno-strict-aliasing) else() vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp /wd4333) endif() diff --git a/modules/core/include/visp3/core/vpIoTools.h b/modules/core/include/visp3/core/vpIoTools.h index 511b1333b5..b35a341ab6 100644 --- a/modules/core/include/visp3/core/vpIoTools.h +++ b/modules/core/include/visp3/core/vpIoTools.h @@ -77,7 +77,7 @@ static inline unsigned long vp_mz_crc32(unsigned long crc, const unsigned char * } #endif // DOXYGEN_SHOULD_SKIP_THIS -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) namespace cnpy { // Copyright (C) 2011 Carl Rogers diff --git a/modules/core/include/visp3/core/vpMath.h b/modules/core/include/visp3/core/vpMath.h index adb42b7c0f..4d9a96d830 100644 --- a/modules/core/include/visp3/core/vpMath.h +++ b/modules/core/include/visp3/core/vpMath.h @@ -314,6 +314,7 @@ class VISP_EXPORT vpMath static double getStdev(const std::vector &v, bool useBesselCorrection = false); static int modulo(int a, int n); + static unsigned int modulo(unsigned int a, unsigned int n); static vpHomogeneousMatrix ned2ecef(double lonDeg, double latDeg, double radius); static vpHomogeneousMatrix enu2ecef(double lonDeg, double latDeg, double radius); diff --git a/modules/core/include/visp3/core/vpNetwork.h b/modules/core/include/visp3/core/vpNetwork.h index 645e00d198..faba5b2947 100644 --- a/modules/core/include/visp3/core/vpNetwork.h +++ b/modules/core/include/visp3/core/vpNetwork.h @@ -260,9 +260,9 @@ class VISP_EXPORT vpNetwork //################################################## /*! - Receives a object. The size of the received object is suppose to be the size - of the type of the object. Note that a received message can correspond to a - deconnection signal. + Receives a object. The size of the object received is assumed to correspond + to the size of the object type. Note that a message received may correspond + to a disconnection signal. \warning Using this function means that you know what kind of object you are suppose to receive, and when you are suppose to receive. If the emitter has @@ -277,7 +277,7 @@ class VISP_EXPORT vpNetwork \param object : Received object. \param sizeOfObject : Size of the received object. - \return the number of bytes received, or -1 if an error occured. + \return the number of bytes received, or -1 if an error occurred. */ template int vpNetwork::receive(T *object, const unsigned int &sizeOfObject) { @@ -360,7 +360,7 @@ template int vpNetwork::receive(T *object, const unsigned int &size \param receptorEmitting : Index of the receptor emitting the message. \param sizeOfObject : Size of the received object. - \return the number of bytes received, or -1 if an error occured. + \return the number of bytes received, or -1 if an error occurred. */ template int vpNetwork::receiveFrom(T *object, const unsigned int &receptorEmitting, const unsigned int &sizeOfObject) diff --git a/modules/core/include/visp3/core/vpParticleFilter.h b/modules/core/include/visp3/core/vpParticleFilter.h index 169de74011..c244af11ac 100644 --- a/modules/core/include/visp3/core/vpParticleFilter.h +++ b/modules/core/include/visp3/core/vpParticleFilter.h @@ -462,7 +462,7 @@ vpParticleFilter::vpParticleFilter(const unsigned int &N, cons vpUniRand seedGenerator(seedForGenerator); for (unsigned int threadId = 0; threadId < m_nbMaxThreads; ++threadId) { for (unsigned int stateId = 0; stateId < sizeState; ++stateId) { - m_noiseGenerators[threadId].push_back(vpGaussRand(stdev[stateId], 0., seedGenerator.uniform(0., 1e9))); + m_noiseGenerators[threadId].push_back(vpGaussRand(stdev[stateId], 0., static_cast(seedGenerator.uniform(0., 1e9)))); } } } diff --git a/modules/core/include/visp3/core/vpStatisticalTestEWMA.h b/modules/core/include/visp3/core/vpStatisticalTestEWMA.h index f2cc7cddcc..0aca73d438 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestEWMA.h +++ b/modules/core/include/visp3/core/vpStatisticalTestEWMA.h @@ -81,9 +81,9 @@ class VISP_EXPORT vpStatisticalTestEWMA : public vpStatisticalTestAbstract virtual void computeDeltaAndLimits(); /** - * \brief Detects if a downward mean drift occured. + * \brief Detects if a downward mean drift occurred. * - * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectUpwardMeanDrift() */ @@ -94,9 +94,9 @@ class VISP_EXPORT vpStatisticalTestEWMA : public vpStatisticalTestAbstract #endif /** - * \brief Detects if an upward mean drift occured on the mean. + * \brief Detects if an upward mean drift occurred on the mean. * - * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectDownwardMeanDrift() */ diff --git a/modules/core/include/visp3/core/vpStatisticalTestHinkley.h b/modules/core/include/visp3/core/vpStatisticalTestHinkley.h index 58203015a7..99906bf5a8 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestHinkley.h +++ b/modules/core/include/visp3/core/vpStatisticalTestHinkley.h @@ -148,9 +148,9 @@ class VISP_EXPORT vpStatisticalTestHinkley : public vpStatisticalTestAbstract #endif /** - * \brief Detects if an upward mean drift occured on the mean. + * \brief Detects if an upward mean drift occurred on the mean. * - * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectDownwardMeanDrift() */ diff --git a/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h b/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h index 6bad84f5f9..ab3903b64c 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h +++ b/modules/core/include/visp3/core/vpStatisticalTestMeanAdjustedCUSUM.h @@ -95,9 +95,9 @@ class VISP_EXPORT vpStatisticalTestMeanAdjustedCUSUM : public vpStatisticalTestA virtual void computeDeltaAndLimits(); /** - * \brief Detects if a downward mean drift occured. + * \brief Detects if a downward mean drift occurred. * - * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectUpwardMeanDrift() */ diff --git a/modules/core/include/visp3/core/vpStatisticalTestShewhart.h b/modules/core/include/visp3/core/vpStatisticalTestShewhart.h index ed12e3aee1..bec70da517 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestShewhart.h +++ b/modules/core/include/visp3/core/vpStatisticalTestShewhart.h @@ -87,7 +87,7 @@ class VISP_EXPORT vpStatisticalTestShewhart : public vpStatisticalTestSigma static std::string vpWecoRulesAlarmToString(const vpWecoRulesAlarm &alarm); static const bool CONST_ALL_WECO_ACTIVATED[COUNT_WECO - 1]; - static const int NB_DATA_SIGNAL = 8; + static const unsigned int NB_DATA_SIGNAL = 8; protected: unsigned int m_nbDataInBuffer; /*!< Indicate how many data are available in the circular buffer.*/ @@ -97,7 +97,7 @@ class VISP_EXPORT vpStatisticalTestShewhart : public vpStatisticalTestSigma bool m_activatedWECOrules[COUNT_WECO - 1]; /*!< The WECO's rules that are activated. The more are activated, the higher the sensitivity of the Shewhart control chart is but the higher the false alarm frequency is.*/ - int m_idCurrentData; /*!< The index of the current data in m_signal.*/ + unsigned int m_idCurrentData; /*!< The index of the current data in m_signal.*/ vpWecoRulesAlarm m_alarm; /*!< The type of alarm raised due to WECO's rules.*/ float m_oneSigmaNegLim; /*!< The \f$ \mu - \sigma \f$ threshold.*/ float m_oneSigmaPosLim; /*!< The \f$ \mu + \sigma \f$ threshold.*/ @@ -114,9 +114,9 @@ class VISP_EXPORT vpStatisticalTestShewhart : public vpStatisticalTestSigma #endif /** - * \brief Detects if a downward mean drift occured. + * \brief Detects if a downward mean drift occurred. * - * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectUpwardMeanDrift() */ @@ -127,9 +127,9 @@ class VISP_EXPORT vpStatisticalTestShewhart : public vpStatisticalTestSigma #endif /** - * \brief Detects if an upward mean drift occured on the mean. + * \brief Detects if an upward mean drift occurred on the mean. * - * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectDownwardMeanDrift() */ diff --git a/modules/core/include/visp3/core/vpStatisticalTestSigma.h b/modules/core/include/visp3/core/vpStatisticalTestSigma.h index b5dd794fca..1b452801a0 100644 --- a/modules/core/include/visp3/core/vpStatisticalTestSigma.h +++ b/modules/core/include/visp3/core/vpStatisticalTestSigma.h @@ -78,9 +78,9 @@ class VISP_EXPORT vpStatisticalTestSigma : public vpStatisticalTestAbstract virtual void computeLimits(); /** - * \brief Detects if a downward mean drift occured. + * \brief Detects if a downward mean drift occurred. * - * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectUpwardMeanDrift() */ @@ -91,9 +91,9 @@ class VISP_EXPORT vpStatisticalTestSigma : public vpStatisticalTestAbstract #endif /** - * \brief Detects if an upward mean drift occured on the mean. + * \brief Detects if an upward mean drift occurred on the mean. * - * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occured, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. + * \return \b vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occurred, \b vpMeanDriftType::MEAN_DRIFT_NONE otherwise. * * \sa detectDownwardMeanDrift() */ diff --git a/modules/core/src/math/misc/vpMath.cpp b/modules/core/src/math/misc/vpMath.cpp index 4bee63795a..4b08463903 100644 --- a/modules/core/src/math/misc/vpMath.cpp +++ b/modules/core/src/math/misc/vpMath.cpp @@ -434,17 +434,28 @@ double vpMath::lineFitting(const std::vector &imPts, double &a, do } /*! - Compute the modified modulo: - - modulo(11, 10) == 1 == 11 % 10 - - modulo(-1, 10) == 9 - - \param a : The dividend. - \param n : The divisor. - - \return The modified modulo of a mod n. -*/ + * Compute the modified modulo: + * - modulo(11, 10) == 1 == 11 % 10 + * - modulo(-1, 10) == 9 + * + * \param a : The dividend. + * \param n : The divisor. + * + * \return The modified modulo of a mod n. + */ int vpMath::modulo(int a, int n) { return ((a % n) + n) % n; } +/*! + * Compute the modified modulo: + * - modulo(11, 10) == 1 == 11 % 10 + * + * \param a : The dividend. + * \param n : The divisor. + * + * \return The modified modulo of a mod n. + */ +unsigned int vpMath::modulo(unsigned int a, unsigned int n) { return ((a % n) + n) % n; } + /*! Compute from a given longitude, latitude and a sphere radius the homogeneous transformation from the NED frame to the ECEF frame: diff --git a/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp b/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp index c32afc8412..0a0cbf36d2 100644 --- a/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp +++ b/modules/core/src/math/misc/vpStatisticalTestShewhart.cpp @@ -43,7 +43,7 @@ #include BEGIN_VISP_NAMESPACE -const int vpStatisticalTestShewhart::NB_DATA_SIGNAL; +const unsigned int vpStatisticalTestShewhart::NB_DATA_SIGNAL; const bool vpStatisticalTestShewhart::CONST_ALL_WECO_ACTIVATED[vpStatisticalTestShewhart::COUNT_WECO - 1] = { true, true, true, true }; std::string vpStatisticalTestShewhart::vpWecoRulesAlarmToString(const vpStatisticalTestShewhart::vpWecoRulesAlarm &alarm) @@ -95,8 +95,8 @@ vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestShewhart::detectDown return vpStatisticalTestAbstract::MEAN_DRIFT_NONE; } vpStatisticalTestAbstract::vpMeanDriftType result = vpStatisticalTestAbstract::MEAN_DRIFT_NONE; - int id = vpMath::modulo(m_idCurrentData - (NB_DATA_SIGNAL - 1), NB_DATA_SIGNAL); - int i = 0; + unsigned int id = vpMath::modulo(m_idCurrentData - (NB_DATA_SIGNAL - 1), NB_DATA_SIGNAL); + unsigned int i = 0; unsigned int nbAboveMean = 0; unsigned int nbAbove2SigmaLimit = 0; unsigned int nbAbove1SigmaLimit = 0; @@ -110,7 +110,7 @@ vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestShewhart::detectDown } if (i > 3 && m_activatedWECOrules[TWO_SIGMA_WECO]) { // Two sigma test - for (int idPrev = vpMath::modulo(id - 2, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { + for (unsigned int idPrev = vpMath::modulo(id - 2, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { if (m_signal[idPrev] <= m_twoSigmaNegLim) { ++nbAbove2SigmaLimit; } @@ -124,7 +124,7 @@ vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestShewhart::detectDown } if (i > 5 && m_activatedWECOrules[ONE_SIGMA_WECO]) { // One sigma test - for (int idPrev = vpMath::modulo(id - 4, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { + for (unsigned int idPrev = vpMath::modulo(id - 4, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { if (m_signal[idPrev] <= m_oneSigmaNegLim) { ++nbAbove1SigmaLimit; } @@ -167,8 +167,8 @@ vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestShewhart::detectUpwa return vpStatisticalTestAbstract::MEAN_DRIFT_NONE; } vpStatisticalTestAbstract::vpMeanDriftType result = vpStatisticalTestAbstract::MEAN_DRIFT_NONE; - int id = vpMath::modulo(m_idCurrentData - (NB_DATA_SIGNAL - 1), NB_DATA_SIGNAL); - int i = 0; + unsigned int id = vpMath::modulo(m_idCurrentData - (NB_DATA_SIGNAL - 1), NB_DATA_SIGNAL); + unsigned int i = 0; unsigned int nbAboveMean = 0; unsigned int nbAbove2SigmaLimit = 0; unsigned int nbAbove1SigmaLimit = 0; @@ -182,7 +182,7 @@ vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestShewhart::detectUpwa } if (i > 3 && m_activatedWECOrules[TWO_SIGMA_WECO]) { // Two sigma test - for (int idPrev = vpMath::modulo(id - 2, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { + for (unsigned int idPrev = vpMath::modulo(id - 2, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { if (m_signal[idPrev] >= m_twoSigmaPosLim) { ++nbAbove2SigmaLimit; } @@ -196,7 +196,7 @@ vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestShewhart::detectUpwa } if (i > 5 && m_activatedWECOrules[ONE_SIGMA_WECO]) { // One sigma test - for (int idPrev = vpMath::modulo(id - 4, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { + for (unsigned int idPrev = vpMath::modulo(id - 4, NB_DATA_SIGNAL); idPrev != id; idPrev = vpMath::modulo(idPrev + 1, NB_DATA_SIGNAL)) { if (m_signal[idPrev] >= m_oneSigmaPosLim) { ++nbAbove1SigmaLimit; } @@ -276,8 +276,8 @@ vpStatisticalTestShewhart::vpStatisticalTestShewhart(const bool &activateWECOrul std::vector vpStatisticalTestShewhart::getSignals() const { std::vector signals; - for (int i = 0; i < NB_DATA_SIGNAL; ++i) { - int id = vpMath::modulo(m_idCurrentData - (NB_DATA_SIGNAL - i - 1), NB_DATA_SIGNAL); + for (unsigned int i = 0; i < NB_DATA_SIGNAL; ++i) { + unsigned int id = vpMath::modulo(m_idCurrentData - (NB_DATA_SIGNAL - i - 1), NB_DATA_SIGNAL); signals.push_back(m_signal[id]); } return signals; diff --git a/modules/core/src/tools/file/vpIoTools_npy.cpp b/modules/core/src/tools/file/vpIoTools_npy.cpp index f2d64cbac2..737711b83f 100644 --- a/modules/core/src/tools/file/vpIoTools_npy.cpp +++ b/modules/core/src/tools/file/vpIoTools_npy.cpp @@ -34,7 +34,7 @@ #include #include -#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98) && defined(VISP_HAVE_MINIZ) +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) #define USE_ZLIB_API 0 #if !USE_ZLIB_API @@ -54,9 +54,6 @@ using namespace buminiz; // Released under MIT License // license available in LICENSE file, or at http://www.opensource.org/licenses/mit-license.php -#include - - char visp::cnpy::BigEndianTest() { int x = 1; @@ -289,7 +286,7 @@ visp::cnpy::npz_t visp::cnpy::npz_load(std::string fname) const unsigned int val_22 = 22; const unsigned int val_30 = 30; while (!quit) { - std::vector local_header(30); + std::vector local_header(val_30); size_t headerres = fread(&local_header[0], sizeof(char), val_30, fp); if (headerres != 30) { throw std::runtime_error("npz_load: failed fread"); @@ -325,8 +322,12 @@ visp::cnpy::npz_t visp::cnpy::npz_load(std::string fname) uint32_t compr_bytes = *reinterpret_cast(&local_header[0] + val_18); uint32_t uncompr_bytes = *reinterpret_cast(&local_header[0] + val_22); - if (compr_method == 0) { arrays[varname] = load_the_npy_file(fp); } - else { arrays[varname] = load_the_npz_array(fp, compr_bytes, uncompr_bytes); } + if (compr_method == 0) { + arrays[varname] = load_the_npy_file(fp); + } + else { + arrays[varname] = load_the_npz_array(fp, compr_bytes, uncompr_bytes); + } } } @@ -361,7 +362,7 @@ visp::cnpy::NpyArray visp::cnpy::npz_load(std::string fname, std::string varname const unsigned int val_22 = 22; const unsigned int val_30 = 30; while (!quit) { - std::vector local_header(30); + std::vector local_header(val_30); size_t header_res = fread(&local_header[0], sizeof(char), val_30, fp); if (header_res != 30) { throw std::runtime_error("npz_load: failed fread"); diff --git a/modules/core/src/tools/network/vpClient.cpp b/modules/core/src/tools/network/vpClient.cpp index 12fc072ba3..d08c34a7dc 100644 --- a/modules/core/src/tools/network/vpClient.cpp +++ b/modules/core/src/tools/network/vpClient.cpp @@ -35,7 +35,7 @@ // Specific case for UWP to introduce a workaround // error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings -#if defined(WINRT) +#if defined(WINRT) || defined(_WIN32) #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS #define _WINSOCK_DEPRECATED_NO_WARNINGS #endif diff --git a/modules/core/src/tools/network/vpNetwork.cpp b/modules/core/src/tools/network/vpNetwork.cpp index 194c6d631b..58cee1755f 100644 --- a/modules/core/src/tools/network/vpNetwork.cpp +++ b/modules/core/src/tools/network/vpNetwork.cpp @@ -35,7 +35,7 @@ // Specific case for UWP to introduce a workaround // error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings -#if defined(WINRT) +#if defined(WINRT) || defined(_WIN32) #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS #define _WINSOCK_DEPRECATED_NO_WARNINGS #endif @@ -174,7 +174,7 @@ int vpNetwork::getReceptorIndex(const char *name) \param req : Request to send. - \return The number of bytes that have been sent, -1 if an error occured. + \return The number of bytes that have been sent, -1 if an error occurred. */ int vpNetwork::sendRequest(vpRequest &req) { return sendRequestTo(req, 0); } @@ -190,7 +190,7 @@ int vpNetwork::sendRequest(vpRequest &req) { return sendRequestTo(req, 0); } \param req : Request to send. \param dest : Index of the receptor receiving the request. - \return The number of bytes that have been sent, -1 if an error occured. + \return The number of bytes that have been sent, -1 if an error occurred. */ int vpNetwork::sendRequestTo(vpRequest &req, const unsigned int &dest) { @@ -242,7 +242,7 @@ int vpNetwork::sendRequestTo(vpRequest &req, const unsigned int &dest) \param req : Request to send. - \return The number of bytes that have been sent, -1 if an error occured. + \return The number of bytes that have been sent, -1 if an error occurred. */ int vpNetwork::sendAndEncodeRequest(vpRequest &req) { @@ -262,7 +262,7 @@ int vpNetwork::sendAndEncodeRequest(vpRequest &req) \param req : Request to send. \param dest : Index of the receptor receiving the request. - \return The number of bytes that have been sent, -1 if an error occured. + \return The number of bytes that have been sent, -1 if an error occurred. */ int vpNetwork::sendAndEncodeRequestTo(vpRequest &req, const unsigned int &dest) { @@ -329,7 +329,7 @@ std::vector vpNetwork::receiveRequestFrom(const unsigned int &receptorEmitt \sa vpNetwork::receiveAndDecodeRequestOnce() \sa vpNetwork::receiveAndDecodeRequestOnceFrom() - \return The number of bytes received, -1 if an error occured. + \return The number of bytes received, -1 if an error occurred. */ int vpNetwork::receiveRequestOnce() { @@ -356,7 +356,7 @@ int vpNetwork::receiveRequestOnce() \param receptorEmitting : Index of the receptor emitting the message. - \return The number of bytes received, -1 if an error occured. + \return The number of bytes received, -1 if an error occurred. */ int vpNetwork::receiveRequestOnceFrom(const unsigned int &receptorEmitting) { @@ -433,7 +433,7 @@ std::vector vpNetwork::receiveAndDecodeRequestFrom(const unsigned int &rece \sa vpNetwork::receiveAndDecodeRequestOnce() \sa vpNetwork::receiveAndDecodeRequestOnceFrom() - \return The number of bytes received, -1 if an error occured. + \return The number of bytes received, -1 if an error occurred. */ int vpNetwork::receiveAndDecodeRequestOnce() { @@ -463,7 +463,7 @@ int vpNetwork::receiveAndDecodeRequestOnce() \param receptorEmitting : Index of the receptor emitting the message. - \return The number of bytes received, -1 if an error occured. + \return The number of bytes received, -1 if an error occurred. */ int vpNetwork::receiveAndDecodeRequestOnceFrom(const unsigned int &receptorEmitting) { @@ -651,7 +651,7 @@ void vpNetwork::privReceiveRequestFrom(const unsigned int &receptorEmitting) \sa vpNetwork::receiveAndDecodeRequestOnce() \sa vpNetwork::receiveAndDecodeRequestOnceFrom() - \return The number of bytes received, -1 if an error occured. + \return The number of bytes received, -1 if an error occurred. */ int vpNetwork::privReceiveRequestOnce() { @@ -739,7 +739,7 @@ int vpNetwork::privReceiveRequestOnce() \param receptorEmitting : Index of the receptor emitting the message. - \return The number of bytes received, -1 if an error occured. + \return The number of bytes received, -1 if an error occurred. */ int vpNetwork::privReceiveRequestOnceFrom(const unsigned int &receptorEmitting) { diff --git a/modules/core/src/tools/network/vpServer.cpp b/modules/core/src/tools/network/vpServer.cpp index 4b71f22158..a8714f291b 100644 --- a/modules/core/src/tools/network/vpServer.cpp +++ b/modules/core/src/tools/network/vpServer.cpp @@ -35,7 +35,7 @@ // Specific case for UWP to introduce a workaround // error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings -#if defined(WINRT) +#if defined(WINRT) || defined(_WIN32) #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS #define _WINSOCK_DEPRECATED_NO_WARNINGS #endif diff --git a/modules/core/test/math/testParticleFilter.cpp b/modules/core/test/math/testParticleFilter.cpp index 4e0f949b0d..de012553db 100644 --- a/modules/core/test/math/testParticleFilter.cpp +++ b/modules/core/test/math/testParticleFilter.cpp @@ -73,8 +73,8 @@ class vpParabolaModel public: inline vpParabolaModel(const unsigned int °ree, const unsigned int &height, const unsigned int &width) : m_degree(degree) - , m_height(static_cast(height)) - , m_width(static_cast(width)) + , m_height(height) + , m_width(width) , m_coeffs(degree + 1, 0.) { } @@ -88,8 +88,8 @@ class vpParabolaModel */ inline vpParabolaModel(const vpColVector &coeffs, const unsigned int &height, const unsigned int &width) : m_degree(coeffs.size() - 1) - , m_height(static_cast(height)) - , m_width(static_cast(width)) + , m_height(height) + , m_width(width) , m_coeffs(coeffs) { } @@ -103,8 +103,8 @@ class vpParabolaModel */ inline vpParabolaModel(const vpMatrix &coeffs, const unsigned int &height, const unsigned int &width) : m_degree(coeffs.getRows() - 1) - , m_height(static_cast(height)) - , m_width(static_cast(width)) + , m_height(height) + , m_width(width) , m_coeffs(coeffs.getCol(0)) { } @@ -163,9 +163,9 @@ class vpParabolaModel * \param[out] b The matrix that contains the v-coordinates. * \return Fill */ - static void fillSystem(const unsigned int °ree, const double &height, const double &width, const std::vector< vpImagePoint> &pts, vpMatrix &A, vpMatrix &b) + static void fillSystem(const unsigned int °ree, const unsigned int &height, const unsigned int&width, const std::vector< vpImagePoint> &pts, vpMatrix &A, vpMatrix &b) { - const unsigned int nbPts = pts.size(); + const unsigned int nbPts = static_cast(pts.size()); const unsigned int nbCoeffs = degree + 1; std::vector normalizedPts; for (const auto &pt: pts) { @@ -197,7 +197,7 @@ class vpParabolaModel { unsigned int width = I.getWidth(); for (unsigned int u = 0; u < width; ++u) { - int v = eval(u); + int v = static_cast(eval(u)); vpDisplay::displayPoint(I, v, u, color, 1); vpDisplay::displayText(I, vertPosLegend, horPosLegend, legend, color); } @@ -206,8 +206,8 @@ class vpParabolaModel private: unsigned int m_degree; /*!< The highest degree of the polynomial.*/ - double m_height; /*!< The height of the input image*/ - double m_width; /*!< The width of the input image*/ + unsigned int m_height; /*!< The height of the input image*/ + unsigned int m_width; /*!< The width of the input image*/ vpColVector m_coeffs; /*!< The coefficient of the polynomial, where m_coeffs[0] is the offset and m_coeffs[m_degree] is the coefficient applied to the highest degree.*/ }; @@ -292,7 +292,7 @@ template void displayGeneratedImage(const vpImage &I, const std::vector &pts, const vpColor &color, const std::string &legend, const unsigned int &vertOffset, const unsigned int &horOffset) { - unsigned int nbPts = pts.size(); + unsigned int nbPts = static_cast(pts.size()); for (unsigned int i = 1; i < nbPts; ++i) { vpDisplay::displayPoint(I, pts[i], color, 1); } @@ -309,7 +309,7 @@ void displayGeneratedImage(const vpImage &I, const std::vector * \param[in] width The maximum x-coordinate. * \return vpParabolaModel The fitter model. */ -vpParabolaModel computeInitialGuess(const std::vector &pts, const unsigned int °ree, const double &height, const double &width) +vpParabolaModel computeInitialGuess(const std::vector &pts, const unsigned int °ree, const unsigned int&height, const unsigned int &width) { vpMatrix A; // The matrix that contains the u^2, u and 1s vpMatrix X; // The matrix we want to estimate, that contains the a, b and c coefficients. @@ -370,7 +370,7 @@ class vpAverageFunctor vpColVector averagePolynomials(const std::vector &particles, const std::vector &weights, const vpParticleFilter>::vpStateAddFunction &/**/) { - const unsigned int nbParticles = particles.size(); + const unsigned int nbParticles = static_cast(particles.size()); const double nbParticlesAsDOuble = static_cast(nbParticles); const double sumWeight = std::accumulate(weights.begin(), weights.end(), 0.); const double nbPointsForAverage = 10. * nbParticlesAsDOuble; @@ -442,7 +442,7 @@ class vpLikelihoodFunctor double likelihood(const vpColVector &coeffs, const std::vector &meas) { double likelihood = 0.; - unsigned int nbPoints = meas.size(); + unsigned int nbPoints = static_cast(meas.size()); vpParabolaModel model(coeffs, m_height, m_width); vpColVector residuals(nbPoints); double rmse = evaluate(meas, model); @@ -463,8 +463,8 @@ class vpLikelihoodFunctor TEST_CASE("2nd-degree", "[vpParticleFilter][Polynomial interpolation]") { /// ----- Simulation parameters ----- - const double width = 600.; //!< The width of the simulated image - const double height = 400.; //!< The height of the simulated image + const unsigned int width = 600; //!< The width of the simulated image + const unsigned int height = 400; //!< The height of the simulated image const unsigned int degree = 2; //!< The degree of the polynomial in the simulated image const unsigned int nbInitPoints = 10; //!< Number of points to compute the initial guess of the PF state const uint64_t seedCurve = 4224; //!< The seed to generate the curve @@ -648,8 +648,8 @@ TEST_CASE("2nd-degree", "[vpParticleFilter][Polynomial interpolation]") TEST_CASE("3rd-degree", "[vpParticleFilter][Polynomial interpolation]") { /// ----- Simulation parameters ----- - const double width = 600.; //!< The width of the simulated image - const double height = 400.; //!< The height of the simulated image + const unsigned int width = 600; //!< The width of the simulated image + const unsigned int height = 400; //!< The height of the simulated image const unsigned int degree = 3; //!< The degree of the polynomial in the simulated image const unsigned int nbInitPoints = 10; //!< Number of points to compute the initial guess of the PF state const uint64_t seedCurve = 4224; //!< The seed to generate the curve diff --git a/modules/core/test/math/testSPC.cpp b/modules/core/test/math/testSPC.cpp index b151517ad6..6aed025caf 100644 --- a/modules/core/test/math/testSPC.cpp +++ b/modules/core/test/math/testSPC.cpp @@ -434,8 +434,8 @@ int main(int argc, const char **argv) std::cerr << "\t2-sigma test failed: " << std::endl; std::vector s = tester.getSignals(); std::cerr << "\t\ts(t) = [ "; - for (size_t i = 0; i < s.size(); ++i) { - std::cerr << s[i] << " "; + for (size_t j = 0; j < s.size(); ++j) { + std::cerr << s[j] << " "; } std::cerr << "]" << std::endl; float limitDown = 0.f, limitUp = 0.f; @@ -483,8 +483,8 @@ int main(int argc, const char **argv) std::cerr << "\t1-sigma test failed: " << std::endl; std::vector s = tester.getSignals(); std::cerr << "\t\ts(t) = [ "; - for (size_t i = 0; i < s.size(); ++i) { - std::cerr << s[i] << " "; + for (size_t j = 0; j < s.size(); ++j) { + std::cerr << s[j] << " "; } std::cerr << "]" << std::endl; float limitDown = 0.f, limitUp = 0.f; @@ -532,8 +532,8 @@ int main(int argc, const char **argv) std::cerr << "\tSame-side test failed: " << std::endl; std::vector s = tester.getSignals(); std::cerr << "\t\ts(t) = [ "; - for (size_t i = 0; i < s.size(); ++i) { - std::cerr << s[i] << " "; + for (size_t j = 0; j < s.size(); ++j) { + std::cerr << s[j] << " "; } std::cerr << "]" << std::endl; float limitDown = 0.f, limitUp = 0.f; @@ -576,8 +576,8 @@ int main(int argc, const char **argv) std::cerr << "\t3-sigma test failed: " << std::endl; std::vector s = tester.getSignals(); std::cerr << "\t\ts(t) = [ "; - for (size_t i = 0; i < s.size(); ++i) { - std::cerr << s[i] << " "; + for (size_t j = 0; j < s.size(); ++j) { + std::cerr << s[j] << " "; } std::cerr << "]" << std::endl; float limitDown = 0.f, limitUp = 0.f; @@ -626,8 +626,8 @@ int main(int argc, const char **argv) std::cerr << "\t2-sigma test failed: " << std::endl; std::vector s = tester.getSignals(); std::cerr << "\t\ts(t) = [ "; - for (size_t i = 0; i < s.size(); ++i) { - std::cerr << s[i] << " "; + for (size_t j = 0; j < s.size(); ++j) { + std::cerr << s[j] << " "; } std::cerr << "]" << std::endl; float limitDown = 0.f, limitUp = 0.f; @@ -676,8 +676,8 @@ int main(int argc, const char **argv) std::cerr << "\t1-sigma test failed: " << std::endl; std::vector s = tester.getSignals(); std::cerr << "\t\ts(t) = [ "; - for (size_t i = 0; i < s.size(); ++i) { - std::cerr << s[i] << " "; + for (size_t j = 0; j < s.size(); ++j) { + std::cerr << s[j] << " "; } std::cerr << "]" << std::endl; float limitDown = 0.f, limitUp = 0.f; @@ -726,8 +726,8 @@ int main(int argc, const char **argv) std::cerr << "\tSame-side test failed: " << std::endl; std::vector s = tester.getSignals(); std::cerr << "\t\ts(t) = [ "; - for (size_t i = 0; i < s.size(); ++i) { - std::cerr << s[i] << " "; + for (size_t j = 0; j < s.size(); ++j) { + std::cerr << s[j] << " "; } std::cerr << "]" << std::endl; float limitDown = 0.f, limitUp = 0.f; diff --git a/modules/core/test/tools/io/testNPZ.cpp b/modules/core/test/tools/io/testNPZ.cpp index 90d9da4ef3..fdc6339039 100644 --- a/modules/core/test/tools/io/testNPZ.cpp +++ b/modules/core/test/tools/io/testNPZ.cpp @@ -40,11 +40,12 @@ #if defined(VISP_HAVE_CATCH2) && \ (defined(_WIN32) || (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))) && \ - defined(VISP_LITTLE_ENDIAN) && defined(VISP_HAVE_MINIZ) + defined(VISP_LITTLE_ENDIAN) && defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) #define CATCH_CONFIG_RUNNER #include #include +#include #include #include @@ -64,7 +65,7 @@ std::string createTmpDir() #elif (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) std::string tmp_dir = "/tmp/" + username; #endif - std::string directory_filename = tmp_dir + "/testNPZ/"; + std::string directory_filename = tmp_dir + "/testNPZ"; vpIoTools::makeDirectory(directory_filename); return directory_filename; @@ -169,7 +170,12 @@ TEST_CASE("Test visp::cnpy::npy_load/npz_save", "[visp::cnpy I/O]") // - https://github.com/rogersce/cnpy/blob/4e8810b1a8637695171ed346ce68f6984e585ef4/cnpy.cpp#L40-L42 // - https://github.com/rogersce/cnpy/blob/4e8810b1a8637695171ed346ce68f6984e585ef4/cnpy.h#L129 // https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable + + // Next CHECK() call may fail when g++ < 5 (case on centos-7-2 ci). That's why we ensure that c++ standard is > 11 + // See https://stackoverflow.com/questions/25123458/is-trivially-copyable-is-not-a-member-of-std +#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_11) CHECK(std::is_trivially_copyable>::value == true); +#endif // https://en.cppreference.com/w/cpp/types/is_trivial // CHECK(std::is_trivial>::value == true); // false @@ -284,7 +290,6 @@ TEST_CASE("Test visp::cnpy::npy_load/npz_save", "[visp::cnpy I/O]") } } } - REQUIRE(vpIoTools::remove(directory_filename)); REQUIRE(!vpIoTools::checkDirectory(directory_filename)); } diff --git a/modules/io/CMakeLists.txt b/modules/io/CMakeLists.txt index fb65d48983..8ae383fad1 100644 --- a/modules/io/CMakeLists.txt +++ b/modules/io/CMakeLists.txt @@ -199,5 +199,5 @@ vp_module_include_directories(${opt_incs}) vp_create_module(${opt_libs}) vp_add_tests() -vp_set_source_file_compile_flag(src/image/private/vpImageIoStb.cpp -Wno-missing-field-initializers -Wno-strict-overflow) +vp_set_source_file_compile_flag(src/image/private/vpImageIoStb.cpp -Wno-missing-field-initializers -Wno-strict-overflow -Wno-deprecated-declarations) vp_set_source_file_compile_flag(src/image/private/vpImageIoTinyEXR.cpp -Wno-strict-overflow -Wno-sign-compare -Wno-type-limits -Wno-unused-but-set-variable) diff --git a/modules/sensor/CMakeLists.txt b/modules/sensor/CMakeLists.txt index 5f8596fac0..1bff7932df 100644 --- a/modules/sensor/CMakeLists.txt +++ b/modules/sensor/CMakeLists.txt @@ -59,7 +59,7 @@ if(USE_DIRECTSHOW) list(APPEND opt_libs ${DIRECTSHOW_LIBRARIES}) endif() if(USE_LIBFREENECT) - list(APPEND opt_incs ${LIBFREENECT_INCLUDE_DIRS}) + list(APPEND opt_system_incs ${LIBFREENECT_INCLUDE_DIRS}) list(APPEND opt_libs ${LIBFREENECT_LIBRARIES}) endif() if(USE_LIBUSB_1) diff --git a/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp b/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp index 485ee2b4cf..fe74264291 100644 --- a/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp +++ b/modules/sensor/src/force-torque/vpForceTorqueAtiNetFTSensor.cpp @@ -62,7 +62,7 @@ BEGIN_VISP_NAMESPACE * (N and Nm). These default values could be changed using setCountsPerForce(), setCountsPerTorque() and * setScalingFactor(). */ -vpForceTorqueAtiNetFTSensor::vpForceTorqueAtiNetFTSensor() + vpForceTorqueAtiNetFTSensor::vpForceTorqueAtiNetFTSensor() : vpUDPClient(), m_counts_per_force(1000000), m_counts_per_torque(1000000000), m_scaling_factor(1), m_ft_bias(6, 0), m_data_count(0), m_data_count_prev(0), m_ft(6, 0), m_is_streaming_started(false) { } @@ -94,10 +94,13 @@ bool vpForceTorqueAtiNetFTSensor::startStreaming() // Since UDP packet could be lost, retry startup 10 times before giving up for (unsigned int i = 0; i < 10; ++i) { int len = 8; - unsigned char request[8]; // The request data sent to the Net F/T - *(uint16_t *)&request[0] = htons(0x1234); // Standard header - *(uint16_t *)&request[2] = htons(0x0002); // Start high-speed streaming (see table 10.1 in Net F/T user manual) - *(uint32_t *)&request[4] = htonl(0); // Infinite sample (see section 10.1 in Net F/T user manual + unsigned char request[8]; // The request data sent to the Net F/T + uint16_t val1 = htons(0x1234); // Standard header + uint16_t val2 = htons(0x0002); // Start high-speed streaming (see table 10.1 in Net F/T user manual) + uint32_t val3 = htons(0); // Infinite sample (see section 10.1 in Net F/T user manual + memcpy(&request[0], &val1, sizeof(val1)); + memcpy(&request[2], &val2, sizeof(val2)); + memcpy(&request[4], &val3, sizeof(val3)); // Send start stream if (send(request, len) != len) { @@ -128,10 +131,13 @@ void vpForceTorqueAtiNetFTSensor::stopStreaming() } int len = 8; - unsigned char request[8]; // The request data sent to the Net F/T - *(uint16_t *)&request[0] = htons(0x1234); // Standard header - *(uint16_t *)&request[2] = htons(0x0000); // Stop streaming (see table 10.1 in Net F/T user manual) - *(uint32_t *)&request[4] = htonl(0); // Infinite sample (see section 10.1 in Net F/T user manual + unsigned char request[8]; // The request data sent to the Net F/T + uint16_t val1 = htons(0x1234); // Standard header + uint16_t val2 = htons(0x0002); // Start high-speed streaming (see table 10.1 in Net F/T user manual) + uint32_t val3 = htons(0); // Infinite sample (see section 10.1 in Net F/T user manual + memcpy(&request[0], &val1, sizeof(val1)); + memcpy(&request[2], &val2, sizeof(val2)); + memcpy(&request[4], &val3, sizeof(val3)); // Send start stream if (send(request, len) != len) { @@ -240,11 +246,18 @@ bool vpForceTorqueAtiNetFTSensor::waitForNewData(unsigned int timeout) unsigned char response[36]; RESPONSE resp; if (receive((void *)response, 36)) { - resp.rdt_sequence = ntohl(*(uint32_t *)&response[0]); - resp.ft_sequence = ntohl(*(uint32_t *)&response[4]); - resp.status = ntohl(*(uint32_t *)&response[8]); + uint32_t resp1, resp2, resp3; + memcpy(&resp1, &response[0], sizeof(uint32_t)); + memcpy(&resp2, &response[4], sizeof(uint32_t)); + memcpy(&resp3, &response[8], sizeof(uint32_t)); + resp.rdt_sequence = ntohl(resp1); + resp.ft_sequence = ntohl(resp2); + resp.status = ntohl(resp3); + for (int i = 0; i < 6; i++) { - resp.FTData[i] = ntohl(*(int32_t *)&response[12 + i * 4]); + int32_t resp4; + memcpy(&resp4, &response[12 + i * 4], sizeof(int32_t)); + resp.FTData[i] = ntohl(resp4); } // Output the response data. if (resp.status) { diff --git a/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp b/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp index 549fc046ba..b64199aca5 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/testGenericTracker.cpp @@ -366,7 +366,7 @@ bool run(const std::string &input_directory, bool opt_click_allowed, bool opt_di // Take the highest thresholds between all CI machines #ifdef VISP_HAVE_COIN3D map_thresh[vpMbGenericTracker::EDGE_TRACKER] = - useScanline ? std::pair(0.005, 6.) : std::pair(0.007, 3.9); + useScanline ? std::pair(0.007, 6.) : std::pair(0.008, 3.9); #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO) map_thresh[vpMbGenericTracker::KLT_TRACKER] = useScanline ? std::pair(0.007, 1.9) : std::pair(0.007, 1.8); diff --git a/modules/tracker/me/src/moving-edges/vpMe.cpp b/modules/tracker/me/src/moving-edges/vpMe.cpp index f9c54129d6..54f4cda864 100644 --- a/modules/tracker/me/src/moving-edges/vpMe.cpp +++ b/modules/tracker/me/src/moving-edges/vpMe.cpp @@ -155,7 +155,7 @@ static bool clipping(vpPoint2Dt A, vpPoint2Dt B, const vpBBoxt &bbox, vpPoint2Dt D[index_3].b = 1; D[index_3].c = -bbox.Ymax; - const int nbP = val_2; + const unsigned int nbP = val_2; vpPoint2Dt P[nbP]; P[index_0] = A; P[index_1] = B; diff --git a/modules/vision/src/pose-estimation/vpPose.cpp b/modules/vision/src/pose-estimation/vpPose.cpp index d237d63869..86a6d869b2 100644 --- a/modules/vision/src/pose-estimation/vpPose.cpp +++ b/modules/vision/src/pose-estimation/vpPose.cpp @@ -348,8 +348,8 @@ double vpPose::computeResidual(const vpHomogeneousMatrix &cMo, const vpCameraPar void vpPose::callLagrangePose(vpHomogeneousMatrix &cMo) { - const int minNbPtLagrangePlan = 4; - const int minNbPtLagrangeNoPlan = 6; + const unsigned int minNbPtLagrangePlan = 4; + const unsigned int minNbPtLagrangeNoPlan = 6; // test if the 3D points are coplanar double a, b, c, d; // To get the plan coefficients if the points are coplanar int coplanar_plane_type = 0; @@ -384,8 +384,8 @@ void vpPose::callLagrangePose(vpHomogeneousMatrix &cMo) bool vpPose::computePose(vpPoseMethodType method, vpHomogeneousMatrix &cMo, FuncCheckValidityPose func) { - const int minNbPtDementhon = 4; - const int minNbPtRansac = 4; + const unsigned int minNbPtDementhon = 4; + const unsigned int minNbPtRansac = 4; std::stringstream errMsgDementhon; errMsgDementhon << "Dementhon method cannot be used in that case " << "(at least " << minNbPtDementhon << " points are required)" diff --git a/modules/vision/src/pose-estimation/vpPoseDementhon.cpp b/modules/vision/src/pose-estimation/vpPoseDementhon.cpp index feee63caea..97b9d1f8e4 100644 --- a/modules/vision/src/pose-estimation/vpPoseDementhon.cpp +++ b/modules/vision/src/pose-estimation/vpPoseDementhon.cpp @@ -408,7 +408,7 @@ void vpPose::poseDementhonPlan(vpHomogeneousMatrix &cMo) // Ensure that if the user chose a threshold > svdThresholdLimit, at least 1 iteration of svd decomposition is performed int nbMaxIter = static_cast(std::max(std::ceil(logNOfSvdThresholdLimit - logNofSvdThresh), 1.)); double svdThreshold = m_dementhonSvThresh; - int irank = 0; + unsigned int irank = 0; int i = 0; const unsigned int expectedRank = 3; while ((i < nbMaxIter) && (!isRankEqualTo3)) { diff --git a/modules/visual_features/include/visp3/visual_features/vpFeatureLuminanceMapping.h b/modules/visual_features/include/visp3/visual_features/vpFeatureLuminanceMapping.h index 895f3bf40e..8b710512c8 100644 --- a/modules/visual_features/include/visp3/visual_features/vpFeatureLuminanceMapping.h +++ b/modules/visual_features/include/visp3/visual_features/vpFeatureLuminanceMapping.h @@ -295,7 +295,7 @@ class VISP_EXPORT vpLuminanceDCT : public vpLuminanceMapping public: vpMatrixZigZagIndex(); /** - * \brief Initalize the ZigZag object. Computes and stores the zigzag indexing for a given matrix size + * \brief Initialize the ZigZag object. Computes and stores the zigzag indexing for a given matrix size * * @param rows the matrix's number of rows * @param cols the matrix's number of cols diff --git a/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h b/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h index 14bb5a731a..1aaefd4f4a 100644 --- a/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h +++ b/modules/visual_features/include/visp3/visual_features/vpGenericFeature.h @@ -216,7 +216,7 @@ class VISP_EXPORT vpGenericFeature : public vpBasicFeature void set_s(const double s0, const double s1, const double s2); private: - typedef enum { errorNotInitalized, errorInitialized, errorHasToBeUpdated } vpGenericFeatureErrorType; + typedef enum { errorNotInitialized, errorInitialized, errorHasToBeUpdated } vpGenericFeatureErrorType; vpMatrix L; vpColVector err; diff --git a/modules/visual_features/src/visual-feature/vpGenericFeature.cpp b/modules/visual_features/src/visual-feature/vpGenericFeature.cpp index 6e0ff2baa5..9544785398 100644 --- a/modules/visual_features/src/visual-feature/vpGenericFeature.cpp +++ b/modules/visual_features/src/visual-feature/vpGenericFeature.cpp @@ -55,7 +55,7 @@ void vpGenericFeature::init() { s = 0; } this constructor. */ -vpGenericFeature::vpGenericFeature() : L(), err(), errorStatus(errorNotInitalized) +vpGenericFeature::vpGenericFeature() : L(), err(), errorStatus(errorNotInitialized) { /* vpERROR_TRACE("You are not allow to use this constructor ") ; @@ -74,7 +74,7 @@ vpGenericFeature::vpGenericFeature() : L(), err(), errorStatus(errorNotInitalize \param dimension_gen_s : Dimension of the generic feature. It corresponds to the number of features you want to create. */ -vpGenericFeature::vpGenericFeature(unsigned int dimension_gen_s) : L(), err(), errorStatus(errorNotInitalized) +vpGenericFeature::vpGenericFeature(unsigned int dimension_gen_s) : L(), err(), errorStatus(errorNotInitialized) { this->dim_s = dimension_gen_s; s.resize(dimension_gen_s); diff --git a/modules/visual_features/test/feature/testLuminanceMapping.cpp b/modules/visual_features/test/feature/testLuminanceMapping.cpp index 02b1a76d5e..8d1b33890c 100644 --- a/modules/visual_features/test/feature/testLuminanceMapping.cpp +++ b/modules/visual_features/test/feature/testLuminanceMapping.cpp @@ -310,9 +310,9 @@ SCENARIO("Using PCA features", "[visual_features]") } } +#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_11) SCENARIO("Using DCT features", "[visual_features]") { - GIVEN("A matrix") { std::vector> data = { @@ -448,6 +448,7 @@ SCENARIO("Using DCT features", "[visual_features]") } } } +#endif int main(int argc, char *argv[]) { diff --git a/tutorial/misc/npz/tutorial-npz.cpp b/tutorial/misc/npz/tutorial-npz.cpp index a8415cfa4d..32859f9d11 100644 --- a/tutorial/misc/npz/tutorial-npz.cpp +++ b/tutorial/misc/npz/tutorial-npz.cpp @@ -35,7 +35,7 @@ // Check if cxx14 or higher #if ((__cplusplus >= 201402L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L))) \ - && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) && defined(VISP_HAVE_MINIZ) + && (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) && defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) #include #include diff --git a/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-all.cpp b/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-all.cpp index 9528d18de5..7ec4a7cb5d 100644 --- a/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-all.cpp +++ b/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-all.cpp @@ -91,7 +91,7 @@ double evaluate(const vpImagePoint &pt, const vpTutoParabolaModel &model) */ double evaluate(const vpColVector &coeffs, const unsigned int &height, const unsigned int &width, const std::vector &pts) { - unsigned int nbPts = pts.size(); + unsigned int nbPts = static_cast(pts.size()); vpColVector residuals(nbPts); vpColVector weights(nbPts, 1.); vpTutoParabolaModel model(coeffs, height, width); @@ -122,7 +122,7 @@ void display(const vpColVector &coeffs, const vpImage &I, const vpColor &colo unsigned int width = I.getWidth(); vpTutoParabolaModel model(coeffs, I.getHeight(), I.getWidth()); for (unsigned int u = 0; u < width; ++u) { - float v = model.eval(u); + unsigned int v = static_cast(model.eval(u)); vpDisplay::displayPoint(I, v, u, color, 1); vpDisplay::displayText(I, vertPosLegend, horPosLegend, "Particle Filter model", color); } @@ -156,7 +156,7 @@ std::vector automaticInitialization(tutorial::vpTutoCommonData &da // Extracting the skeleton of the mask std::vector edgePoints = tutorial::extractSkeleton(data); - unsigned int nbEdgePoints = edgePoints.size(); + unsigned int nbEdgePoints = static_cast(edgePoints.size()); if (nbEdgePoints < nbPtsToUse) { return edgePoints; @@ -172,12 +172,12 @@ std::vector automaticInitialization(tutorial::vpTutoCommonData &da if (nbEdgePoints > nbPtsToUse + 20) { // Avoid extreme points in case it's noise idStart = 10; - idStop = edgePoints.size() - 10; + idStop = static_cast(edgePoints.size()) - 10; } else { // We need to take all the points because we don't have enough idStart = 0; - idStop = edgePoints.size(); + idStop = static_cast(edgePoints.size()); } // Sample uniformly the points starting from the left of the image to the right @@ -222,7 +222,7 @@ std::vector manualInitialization(const tutorial::vpTutoCommonData vpDisplay::displayText(data.m_I_orig, data.m_ipLegend + data.m_legendOffset + data.m_legendOffset, "If not enough points have been selected, a right click has no effect.", data.m_colorLegend); // Display the already selected points - unsigned int nbInitPoints = initPoints.size(); + unsigned int nbInitPoints = static_cast(initPoints.size()); for (unsigned int i = 0; i < nbInitPoints; ++i) { vpDisplay::displayCross(data.m_I_orig, initPoints[i], sizeCross, colorCross, thicknessCross); } @@ -325,14 +325,14 @@ vpColVector computeInitialGuess(tutorial::vpTutoCommonData &data) // Display info about the initialization vpDisplay::display(data.m_I_orig); vpDisplay::displayText(data.m_I_orig, data.m_ipLegend, "Here are the points selected for the initialization.", data.m_colorLegend); - unsigned int nbInitPoints = initPoints.size(); - for (unsigned int i = 0; i < nbInitPoints; ++i) { + size_t nbInitPoints = initPoints.size(); + for (size_t i = 0; i < nbInitPoints; ++i) { const vpImagePoint &ip = initPoints[i]; vpDisplay::displayCross(data.m_I_orig, ip, sizeCross, colorCross, thicknessCross); } // Update display and wait for click - lmsFitter.display(data.m_I_orig, vpColor::red, data.m_ipLegend.get_v() + 2 * data.m_legendOffset.get_v(), data.m_ipLegend.get_u()); + lmsFitter.display(data.m_I_orig, vpColor::red, static_cast(data.m_ipLegend.get_v() + 2 * data.m_legendOffset.get_v()), static_cast(data.m_ipLegend.get_u())); vpDisplay::displayText(data.m_I_orig, data.m_ipLegend + data.m_legendOffset, "A click to continue.", data.m_colorLegend); vpDisplay::flush(data.m_I_orig); vpDisplay::getClick(data.m_I_orig, waitForClick); @@ -370,7 +370,7 @@ class vpTutoAverageFunctor */ vpColVector averagePolynomials(const std::vector &particles, const std::vector &weights, const vpParticleFilter>::vpStateAddFunction &/**/) { - const unsigned int nbParticles = particles.size(); + const unsigned int nbParticles = static_cast(particles.size()); const double nbParticlesAsDOuble = static_cast(nbParticles); // Compute the sum of the weights to be able to determine the "importance" of a particle with regard to the whole set const double sumWeight = std::accumulate(weights.begin(), weights.end(), 0.); @@ -454,7 +454,7 @@ class vpTutoLikelihoodFunctor double likelihood(const vpColVector &coeffs, const std::vector &meas) { double likelihood = 0.; - unsigned int nbPoints = meas.size(); + unsigned int nbPoints = static_cast(meas.size()); // Generate a model from the coefficients stored in the particle state vpTutoParabolaModel model(coeffs, m_height, m_width); @@ -497,8 +497,8 @@ int main(const int argc, const char *argv[]) return returnCode; } tutorial::vpTutoMeanSquareFitting lmsFitter(data.m_degree, data.m_I_orig.getHeight(), data.m_I_orig.getWidth()); - const unsigned int vertOffset = data.m_legendOffset.get_i(); - const unsigned int horOffset = data.m_ipLegend.get_j(); + const unsigned int vertOffset = static_cast(data.m_legendOffset.get_i()); + const unsigned int horOffset = static_cast(data.m_ipLegend.get_j()); const unsigned int legendLmsVert = data.m_I_orig.getHeight() - 3 * vertOffset; const unsigned int legendLmsHor = horOffset; const unsigned int legendPFVert = data.m_I_orig.getHeight() - 2 * vertOffset, legendPFHor = horOffset; @@ -518,9 +518,9 @@ int main(const int argc, const char *argv[]) stdevsPF.push_back(ampliMax / 3.); } unsigned long seedPF; // Seed for the random generators of the PF - const float period = 33.3; // 33.3ms i.e. 30Hz + const float period = 33.3f; // 33.3ms i.e. 30Hz if (data.m_pfSeed < 0) { - seedPF = vpTime::measureTimeMicros(); + seedPF = static_cast(vpTime::measureTimeMicros()); } else { seedPF = data.m_pfSeed; @@ -550,8 +550,8 @@ int main(const int argc, const char *argv[]) //! [Init_plot] #ifdef VISP_HAVE_DISPLAY unsigned int plotHeight = 350, plotWidth = 350; - int plotXpos = data.m_legendOffset.get_u(); - int plotYpos = data.m_I_orig.getHeight() + 4. * data.m_legendOffset.get_v(); + int plotXpos = static_cast(data.m_legendOffset.get_u()); + int plotYpos = static_cast(data.m_I_orig.getHeight() + 4. * data.m_legendOffset.get_v()); vpPlot plot(1, plotHeight, plotWidth, plotXpos, plotYpos, "Root mean-square error"); plot.initGraph(0, 2); plot.setLegend(0, 0, "LMS estimator"); @@ -588,7 +588,7 @@ int main(const int argc, const char *argv[]) double tLms = vpTime::measureTimeMs(); lmsFitter.fit(noisyEdgePoints); double dtLms = vpTime::measureTimeMs() - tLms; - float lmsRootMeanSquareError = lmsFitter.evaluate(edgePoints); + double lmsRootMeanSquareError = lmsFitter.evaluate(edgePoints); std::cout << " [Least-Mean Square method] " << std::endl; std::cout << " Coeffs = [" << lmsFitter.getCoeffs().transpose() << " ]" << std::endl; std::cout << " Root Mean Square Error = " << lmsRootMeanSquareError << " pixels" << std::endl; @@ -608,7 +608,7 @@ int main(const int argc, const char *argv[]) //! [Get_filtered_state] //! [Evaluate_performances] - float pfError = tutorial::evaluate(Xest, data.m_I_orig.getHeight(), data.m_I_orig.getWidth(), edgePoints); + double pfError = tutorial::evaluate(Xest, data.m_I_orig.getHeight(), data.m_I_orig.getWidth(), edgePoints); //! [Evaluate_performances] std::cout << " [Particle Filter method] " << std::endl; std::cout << " Coeffs = [" << Xest.transpose() << " ]" << std::endl; diff --git a/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-lms.cpp b/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-lms.cpp index 381256e595..96f637f1a9 100644 --- a/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-lms.cpp +++ b/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-lms.cpp @@ -57,16 +57,16 @@ int main(const int argc, const char *argv[]) return returnCode; } tutorial::vpTutoMeanSquareFitting lmsFitter(data.m_degree, data.m_I_orig.getHeight(), data.m_I_orig.getWidth()); - const unsigned int vertOffset = data.m_legendOffset.get_i(); - const unsigned int horOffset = data.m_ipLegend.get_j(); + const unsigned int vertOffset = static_cast(data.m_legendOffset.get_i()); + const unsigned int horOffset = static_cast(data.m_ipLegend.get_j()); const unsigned int legendLmsVert = data.m_I_orig.getHeight() - 2 * vertOffset; const unsigned int legendLmsHor = horOffset; //! [Init_plot] #ifdef VISP_HAVE_DISPLAY unsigned int plotHeight = 350, plotWidth = 350; - int plotXpos = data.m_legendOffset.get_u(); - int plotYpos = data.m_I_orig.getHeight() + 4. * data.m_legendOffset.get_v(); + int plotXpos = static_cast(data.m_legendOffset.get_u()); + int plotYpos = static_cast(data.m_I_orig.getHeight() + 4. * data.m_legendOffset.get_v()); vpPlot plot(1, plotHeight, plotWidth, plotXpos, plotYpos, "Root mean-square error"); plot.initGraph(0, 1); plot.setLegend(0, 0, "LMS estimator"); @@ -106,7 +106,7 @@ int main(const int argc, const char *argv[]) lmsFitter.fit(noisyEdgePoints); //! [LMS_interpolation] double dtLms = vpTime::measureTimeMs() - tLms; - float lmsRootMeanSquareError = lmsFitter.evaluate(edgePoints); + double lmsRootMeanSquareError = lmsFitter.evaluate(edgePoints); std::cout << " [Least-Mean Square method] " << std::endl; std::cout << " Coeffs = [" << lmsFitter.getCoeffs().transpose() << " ]" << std::endl; std::cout << " Root Mean Square Error = " << lmsRootMeanSquareError << " pixels" << std::endl; diff --git a/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-pf.cpp b/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-pf.cpp index 9f605abf89..4c48f65328 100644 --- a/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-pf.cpp +++ b/tutorial/particle-filter-curve-fitting/tutorial-pf-curve-fitting-pf.cpp @@ -87,7 +87,7 @@ double evaluate(const vpImagePoint &pt, const vpTutoParabolaModel &model) */ double evaluate(const vpColVector &coeffs, const unsigned int &height, const unsigned int &width, const std::vector &pts) { - unsigned int nbPts = pts.size(); + unsigned int nbPts = static_cast(pts.size()); vpColVector residuals(nbPts); vpColVector weights(nbPts, 1.); vpTutoParabolaModel model(coeffs, height, width); @@ -152,7 +152,7 @@ std::vector automaticInitialization(tutorial::vpTutoCommonData &da // Extracting the skeleton of the mask std::vector edgePoints = tutorial::extractSkeleton(data); - unsigned int nbEdgePoints = edgePoints.size(); + unsigned int nbEdgePoints = static_cast(edgePoints.size()); if (nbEdgePoints < nbPtsToUse) { return edgePoints; @@ -168,12 +168,12 @@ std::vector automaticInitialization(tutorial::vpTutoCommonData &da if (nbEdgePoints > nbPtsToUse + 20) { // Avoid extreme points in case it's noise idStart = 10; - idStop = edgePoints.size() - 10; + idStop = static_cast(edgePoints.size()) - 10; } else { // We need to take all the points because we don't have enough idStart = 0; - idStop = edgePoints.size(); + idStop = static_cast(edgePoints.size()); } // Sample uniformly the points starting from the left of the image to the right @@ -218,7 +218,7 @@ std::vector manualInitialization(const tutorial::vpTutoCommonData vpDisplay::displayText(data.m_I_orig, data.m_ipLegend + data.m_legendOffset + data.m_legendOffset, "If not enough points have been selected, a right click has no effect.", data.m_colorLegend); // Display the already selected points - unsigned int nbInitPoints = initPoints.size(); + unsigned int nbInitPoints = static_cast(initPoints.size()); for (unsigned int i = 0; i < nbInitPoints; ++i) { vpDisplay::displayCross(data.m_I_orig, initPoints[i], sizeCross, colorCross, thicknessCross); } @@ -321,14 +321,14 @@ vpColVector computeInitialGuess(tutorial::vpTutoCommonData &data) // Display info about the initialization vpDisplay::display(data.m_I_orig); vpDisplay::displayText(data.m_I_orig, data.m_ipLegend, "Here are the points selected for the initialization.", data.m_colorLegend); - unsigned int nbInitPoints = initPoints.size(); + unsigned int nbInitPoints = static_cast(initPoints.size()); for (unsigned int i = 0; i < nbInitPoints; ++i) { const vpImagePoint &ip = initPoints[i]; vpDisplay::displayCross(data.m_I_orig, ip, sizeCross, colorCross, thicknessCross); } // Update display and wait for click - lmsFitter.display(data.m_I_orig, vpColor::red, data.m_ipLegend.get_v() + 2 * data.m_legendOffset.get_v(), data.m_ipLegend.get_u()); + lmsFitter.display(data.m_I_orig, vpColor::red, static_cast(data.m_ipLegend.get_v() + 2 * data.m_legendOffset.get_v()), static_cast(data.m_ipLegend.get_u())); vpDisplay::displayText(data.m_I_orig, data.m_ipLegend + data.m_legendOffset, "A click to continue.", data.m_colorLegend); vpDisplay::flush(data.m_I_orig); vpDisplay::getClick(data.m_I_orig, waitForClick); @@ -366,7 +366,7 @@ class vpTutoAverageFunctor */ vpColVector averagePolynomials(const std::vector &particles, const std::vector &weights, const vpParticleFilter>::vpStateAddFunction &/**/) { - const unsigned int nbParticles = particles.size(); + const unsigned int nbParticles = static_cast(particles.size()); const double nbParticlesAsDOuble = static_cast(nbParticles); // Compute the sum of the weights to be able to determine the "importance" of a particle with regard to the whole set const double sumWeight = std::accumulate(weights.begin(), weights.end(), 0.); @@ -450,7 +450,7 @@ class vpTutoLikelihoodFunctor double likelihood(const vpColVector &coeffs, const std::vector &meas) { double likelihood = 0.; - unsigned int nbPoints = meas.size(); + unsigned int nbPoints = static_cast(meas.size()); // Generate a model from the coefficients stored in the particle state vpTutoParabolaModel model(coeffs, m_height, m_width); @@ -492,8 +492,8 @@ int main(const int argc, const char *argv[]) if (returnCode != tutorial::vpTutoCommonData::SOFTWARE_CONTINUE) { return returnCode; } - const unsigned int vertOffset = data.m_legendOffset.get_i(); - const unsigned int horOffset = data.m_ipLegend.get_j(); + const unsigned int vertOffset = static_cast(data.m_legendOffset.get_i()); + const unsigned int horOffset = static_cast(data.m_ipLegend.get_j()); const unsigned int legendPFVert = data.m_I_orig.getHeight() - 2 * vertOffset, legendPFHor = horOffset; // Initialize the attributes of the PF @@ -511,9 +511,9 @@ int main(const int argc, const char *argv[]) stdevsPF.push_back(ampliMax / 3.); } unsigned long seedPF; // Seed for the random generators of the PF - const float period = 33.3; // 33.3ms i.e. 30Hz + const float period = 33.3f; // 33.3ms i.e. 30Hz if (data.m_pfSeed < 0) { - seedPF = vpTime::measureTimeMicros(); + seedPF = static_cast(vpTime::measureTimeMicros()); } else { seedPF = data.m_pfSeed; @@ -543,8 +543,8 @@ int main(const int argc, const char *argv[]) //! [Init_plot] #ifdef VISP_HAVE_DISPLAY unsigned int plotHeight = 350, plotWidth = 350; - int plotXpos = data.m_legendOffset.get_u(); - int plotYpos = data.m_I_orig.getHeight() + 4. * data.m_legendOffset.get_v(); + int plotXpos = static_cast(data.m_legendOffset.get_u()); + int plotYpos = static_cast(data.m_I_orig.getHeight() + 4. * data.m_legendOffset.get_v()); vpPlot plot(1, plotHeight, plotWidth, plotXpos, plotYpos, "Root mean-square error"); plot.initGraph(0, 1); plot.setLegend(0, 0, "PF estimator"); @@ -587,7 +587,7 @@ int main(const int argc, const char *argv[]) //! [Get_filtered_state] //! [Evaluate_performances] - float pfError = tutorial::evaluate(Xest, data.m_I_orig.getHeight(), data.m_I_orig.getWidth(), edgePoints); + double pfError = tutorial::evaluate(Xest, data.m_I_orig.getHeight(), data.m_I_orig.getWidth(), edgePoints); //! [Evaluate_performances] std::cout << " [Particle Filter method] " << std::endl; std::cout << " Coeffs = [" << Xest.transpose() << " ]" << std::endl; diff --git a/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.cpp b/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.cpp index a357909b52..6be7333604 100644 --- a/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.cpp +++ b/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.cpp @@ -40,8 +40,8 @@ using namespace VISP_NAMESPACE_NAME; vpTutoMeanSquareFitting::vpTutoMeanSquareFitting(const unsigned int °ree, const unsigned int &height, const unsigned int &width) : m_degree(degree) - , m_height(static_cast(height)) - , m_width(static_cast(width)) + , m_height(static_cast(height)) + , m_width(static_cast(width)) , m_model(degree, height, width) , m_isFitted(false) { } @@ -68,7 +68,7 @@ double vpTutoMeanSquareFitting::evaluate(const std::vector &pts) if (!m_isFitted) { throw(vpException(vpException::notInitialized, "fit() has not been called.")); } - unsigned int nbPts = pts.size(); + unsigned int nbPts = static_cast(pts.size()); // Compute the mean absolute error double meanSquareError = 0.f; @@ -93,7 +93,7 @@ double vpTutoMeanSquareFitting::evaluate(const vpImagePoint &pt) return squareError; } -double vpTutoMeanSquareFitting::model(const float &u) +double vpTutoMeanSquareFitting::model(const double &u) { if (!m_isFitted) { throw(vpException(vpException::notInitialized, "fit() has not been called.")); diff --git a/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.h b/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.h index 66b771ce83..5e360e1ba4 100644 --- a/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.h +++ b/tutorial/particle-filter-curve-fitting/vpTutoMeanSquareFitting.h @@ -91,7 +91,7 @@ class vpTutoMeanSquareFitting * the underlying polynomial model. * \return double The v-ccordinate that corresponds to the model. */ - double model(const float &u); + double model(const double &u); #ifdef VISP_HAVE_DISPLAY /** @@ -107,7 +107,7 @@ class vpTutoMeanSquareFitting { unsigned int width = I.getWidth(); for (unsigned int u = 0; u < width; ++u) { - int v = model(u); + int v = static_cast(model(u)); VISP_NAMESPACE_ADDRESSING vpDisplay::displayPoint(I, v, u, color, 1); VISP_NAMESPACE_ADDRESSING vpDisplay::displayText(I, vertPosLegend, horPosLegend, "Least-mean square model", color); } @@ -151,8 +151,8 @@ class vpTutoMeanSquareFitting protected: unsigned int m_degree; /*!< The degree of the curve that is estimated*/ - double m_height; /*!< The height of the input image*/ - double m_width; /*!< The width of the input image*/ + unsigned int m_height; /*!< The height of the input image*/ + unsigned int m_width; /*!< The width of the input image*/ vpTutoParabolaModel m_model; /*!< The model of the curve we try to fit.*/ bool m_isFitted; /*!< Set to true if the fit method has been called.*/ }; diff --git a/tutorial/particle-filter-curve-fitting/vpTutoParabolaModel.h b/tutorial/particle-filter-curve-fitting/vpTutoParabolaModel.h index ba71e2cf9f..b8921fa0c7 100644 --- a/tutorial/particle-filter-curve-fitting/vpTutoParabolaModel.h +++ b/tutorial/particle-filter-curve-fitting/vpTutoParabolaModel.h @@ -48,8 +48,8 @@ class vpTutoParabolaModel public: inline vpTutoParabolaModel(const unsigned int °ree, const unsigned int &height, const unsigned int &width) : m_degree(degree) - , m_height(static_cast(height)) - , m_width(static_cast(width)) + , m_height(static_cast(height)) + , m_width(static_cast(width)) , m_coeffs(degree + 1, 0.) { } @@ -63,8 +63,8 @@ class vpTutoParabolaModel */ inline vpTutoParabolaModel(const VISP_NAMESPACE_ADDRESSING vpColVector &coeffs, const unsigned int &height, const unsigned int &width) : m_degree(coeffs.size() - 1) - , m_height(static_cast(height)) - , m_width(static_cast(width)) + , m_height(static_cast(height)) + , m_width(static_cast(width)) , m_coeffs(coeffs) { } @@ -78,8 +78,8 @@ class vpTutoParabolaModel */ inline vpTutoParabolaModel(const VISP_NAMESPACE_ADDRESSING vpMatrix &coeffs, const unsigned int &height, const unsigned int &width) : m_degree(coeffs.getRows() - 1) - , m_height(static_cast(height)) - , m_width(static_cast(width)) + , m_height(static_cast(height)) + , m_width(static_cast(width)) , m_coeffs(coeffs.getCol(0)) { } @@ -136,7 +136,7 @@ class vpTutoParabolaModel //! [Fill_LMS_system] static void fillSystem(const unsigned int °ree, const double &height, const double &width, const std::vector &pts, VISP_NAMESPACE_ADDRESSING vpMatrix &A, VISP_NAMESPACE_ADDRESSING vpMatrix &b) { - const unsigned int nbPts = pts.size(); + const unsigned int nbPts = static_cast(pts.size()); const unsigned int nbCoeffs = degree + 1; std::vector normalizedPts; // Normalization to avoid numerical instability @@ -165,8 +165,8 @@ class vpTutoParabolaModel private: unsigned int m_degree; /*!< The highest degree of the polynomial.*/ - double m_height; /*!< The height of the input image*/ - double m_width; /*!< The width of the input image*/ + unsigned int m_height; /*!< The height of the input image*/ + unsigned int m_width; /*!< The width of the input image*/ VISP_NAMESPACE_ADDRESSING vpColVector m_coeffs; /*!< The coefficient of the polynomial, where m_coeffs[0] is the offset and m_coeffs[m_degree] is the coefficient applied to the highest degree.*/ }; } diff --git a/tutorial/particle-filter-curve-fitting/vpTutoSegmentation.cpp b/tutorial/particle-filter-curve-fitting/vpTutoSegmentation.cpp index d533494be3..8134317ec2 100644 --- a/tutorial/particle-filter-curve-fitting/vpTutoSegmentation.cpp +++ b/tutorial/particle-filter-curve-fitting/vpTutoSegmentation.cpp @@ -119,13 +119,13 @@ std::vector< VISP_NAMESPACE_ADDRESSING vpImagePoint > extractSkeleton(vpTutoComm std::vector< vpImagePoint > addSaltAndPepperNoise(const std::vector< vpImagePoint > &noisefreePts, vpTutoCommonData &data) { - const unsigned int nbNoiseFreePts = noisefreePts.size(); - const unsigned int nbPtsToAdd = data.m_ratioSaltPepperNoise * nbNoiseFreePts; + const unsigned int nbNoiseFreePts = static_cast(noisefreePts.size()); + const unsigned int nbPtsToAdd = static_cast(data.m_ratioSaltPepperNoise * nbNoiseFreePts); const double width = data.m_Iskeleton.getWidth(); const double height = data.m_Iskeleton.getHeight(); data.m_IskeletonNoisy = data.m_Iskeleton; - vpGaussRand rngX(0.1666, 0.5, vpTime::measureTimeMicros()); - vpGaussRand rngY(0.1666, 0.5, vpTime::measureTimeMicros() + 4224); + vpGaussRand rngX(0.1666, 0.5, static_cast(vpTime::measureTimeMicros())); + vpGaussRand rngY(0.1666, 0.5, static_cast(vpTime::measureTimeMicros() + 4224)); std::vector noisyPts = noisefreePts; for (unsigned int i = 0; i < nbPtsToAdd + 1; ++i) { double uNormalized = rngX(); diff --git a/tutorial/particle-filter/tutorial-pf.cpp b/tutorial/particle-filter/tutorial-pf.cpp index bcb5b48de7..7a22de0f1f 100644 --- a/tutorial/particle-filter/tutorial-pf.cpp +++ b/tutorial/particle-filter/tutorial-pf.cpp @@ -604,7 +604,7 @@ int main(const int argc, const char *argv[]) long seedPF = args.m_seedPF; // Seed for the random generators of the PF const int nbThread = args.m_nbThreads; if (seedPF < 0) { - seedPF = vpTime::measureTimeMicros(); + seedPF = static_cast(vpTime::measureTimeMicros()); } //! [Constants_for_the_PF] diff --git a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-full.cpp b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-full.cpp index 6ce2f7e2a5..e0019d148f 100644 --- a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-full.cpp +++ b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-full.cpp @@ -42,7 +42,7 @@ int main(int argc, char **argv) bool opt_display_scale_auto = false; vpColVector opt_dof_to_estimate(6, 1.); // Here we consider 6 dof estimation std::string opt_save; -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) std::string opt_save_results; #endif unsigned int thickness = 2; @@ -72,7 +72,7 @@ int main(int argc, char **argv) else if (std::string(argv[i]) == "--save") { opt_save = std::string(argv[++i]); } -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) else if (std::string(argv[i]) == "--save-results") { opt_save_results = std::string(argv[++i]); } @@ -108,7 +108,7 @@ int main(int argc, char **argv) << " [--downscale-img ]" << " [--dof <0/1 0/1 0/1 0/1 0/1 0/1>]" << " [--save ]" -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) << " [--save-results ]" #endif << " [--display-scale-auto]" @@ -157,7 +157,7 @@ int main(int argc, char **argv) << " is created if it doesn't exist." << " Example: \"result/image-%04d.png\"." << std::endl << std::endl -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) << " --save-results " << std::endl << " Name of the npz file containing cMo data estimated from MBT." << std::endl << " When the name contains a folder like in the next example, the folder" << std::endl @@ -206,7 +206,7 @@ int main(int argc, char **argv) vpIoTools::makeDirectory(parent); } } -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) if (!opt_save_results.empty()) { std::string parent = vpIoTools::getParent(opt_save_results); if (!parent.empty()) { @@ -391,7 +391,7 @@ int main(int argc, char **argv) std::cout << "Initialize tracker on image size: " << I.getWidth() << " x " << I.getHeight() << std::endl; std::vector vec_poses; -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) if (!opt_save_results.empty()) { const unsigned int height = I.getHeight(), width = I.getWidth(); visp::cnpy::npz_save(opt_save_results, "height", &height, { 1 }, "w"); @@ -476,7 +476,7 @@ int main(int argc, char **argv) writer->saveFrame(O); } -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) if (!opt_save_results.empty()) { std::vector vec_pose = poseToVec(cMo); vec_poses.insert(vec_poses.end(), vec_pose.begin(), vec_pose.end()); @@ -488,7 +488,7 @@ int main(int argc, char **argv) } vpDisplay::getClick(I); -#ifdef VISP_HAVE_MINIZ +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) if (!opt_save_results.empty()) { visp::cnpy::npz_save(opt_save_results, "vec_poses", vec_poses.data(), { static_cast(vec_poses.size()/6), 6 }, "a"); } @@ -510,4 +510,4 @@ int main(int argc, char **argv) std::cout << "Install OpenCV and rebuild ViSP to use this example." << std::endl; #endif return EXIT_SUCCESS; - } +} diff --git a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp index 0b301d3464..6b69fc67d3 100644 --- a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp +++ b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp @@ -24,7 +24,7 @@ std::string toString(const std::string &name, int val) int main(int argc, char *argv[]) { -#if defined(VISP_HAVE_DISPLAY) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_MINIZ) +#if defined(VISP_HAVE_DISPLAY) && defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif diff --git a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-save.cpp b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-save.cpp index a16f1cac19..5df4683ebb 100644 --- a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-save.cpp +++ b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-save.cpp @@ -5,7 +5,7 @@ #include -#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_MINIZ) +#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX) #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif