From 03a2e4d9d4d9c2eb993db41af22a7d7c59d83559 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 10:46:04 +0200 Subject: [PATCH 01/15] [DOC] Added important information about how to export a YoloV7 model in the documentation of the detection by DNN tutorial --- doc/tutorial/detection_dnn/tutorial-detection-dnn.dox | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox index 0ab2a417f1..f1752ff8dd 100644 --- a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox +++ b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox @@ -474,6 +474,11 @@ If you want to train your own YoloV7 model, please refer to the [official docume If your dataset is rather small (only hundreds of pictures), you may want to consider to base your training on `yolov7-tiny` network, as it tends to get better results. +**Important note**: if you train your own model, be sure to use the same image size in the `python train.py`, +`python export.py` and `./tutorial-dnn-object-detection-live` commands. Otherwise, it can lead to : +- an error thrown by OpenCV +- the absence of detection by the ONNX model while the Pytorch model works perfectly using the `python detect.py` command. + \subsubsection dnn_supported_yolov8 Yolo v8 You can find the weights (`yolov8s.onnx`) in ONNX format From 54369800e4fde33f42316707ba2f3bf8fcccf776 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 10:50:41 +0200 Subject: [PATCH 02/15] [DOC] Added note about potential issue when following blenderproc tutorial --- doc/tutorial/misc/tutorial-synthetic-blenderproc.dox | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox index 91f04a807a..c22ddd297d 100644 --- a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox +++ b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox @@ -715,6 +715,17 @@ We also download the pretrained yolo model, that we will finetune on our own dat (yolov7) ~/yolov7 $ wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt ``` +**Important note**: while creating the yolov7 virtual environment, you may face the following error: +``` +requirements to build wheel did not run successfully +``` +It can be solved by fixing the version of the Python of the virtual environment: +``` +~/yolov7 $ conda create --name yolov7 pip python=3.10 +~/yolov7 $ conda activate yolov7 +(yolov7) ~/yolov7 $ pip install -r requirements.txt +``` + To fine-tune a YoloV7, we should create two new files: the network configuration and the hyperparameters. We will reuse the ones provided for the tiny model. ``` From 307082c720cba02b49e96c40a7e346700160bb3d Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 10:52:08 +0200 Subject: [PATCH 03/15] [TUTO][FIX] Fixing error when image is RGBa instead of BGR --- .../detection/dnn/tutorial-dnn-object-detection-live.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp index 44f670a142..4f8fe47c1b 100644 --- a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp +++ b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp @@ -338,6 +338,11 @@ int main(int argc, const char *argv[]) cv::Mat frame; while (true) { capture >> frame; + if (frame.type() == CV_8UC4) { + // RGBa format is not supported by the class, converting to BGR format + cv::Mat cpy = frame; + cv::cvtColor(cpy, frame, cv::COLOR_RGBA2BGR); + } if (frame.empty()) break; From a526b11391b0242d4e3fe5a726e307864cde8dee Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Tue, 8 Oct 2024 11:01:01 +0200 Subject: [PATCH 04/15] [DOC] Improved readability of the warnings --- .../detection_dnn/tutorial-detection-dnn.dox | 7 +++---- .../misc/tutorial-synthetic-blenderproc.dox | 13 +++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox index f1752ff8dd..c5897fb046 100644 --- a/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox +++ b/doc/tutorial/detection_dnn/tutorial-detection-dnn.dox @@ -474,10 +474,9 @@ If you want to train your own YoloV7 model, please refer to the [official docume If your dataset is rather small (only hundreds of pictures), you may want to consider to base your training on `yolov7-tiny` network, as it tends to get better results. -**Important note**: if you train your own model, be sure to use the same image size in the `python train.py`, -`python export.py` and `./tutorial-dnn-object-detection-live` commands. Otherwise, it can lead to : -- an error thrown by OpenCV -- the absence of detection by the ONNX model while the Pytorch model works perfectly using the `python detect.py` command. +\warning If you train your own model, be sure to use the same image size in the `python train.py`, +`python export.py` and `./tutorial-dnn-object-detection-live` commands. Otherwise, it can lead to either an error thrown +by OpenCV or the absence of detection by the ONNX model while the Pytorch model works perfectly using the `python detect.py` command. \subsubsection dnn_supported_yolov8 Yolo v8 diff --git a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox index c22ddd297d..e6e576ce6a 100644 --- a/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox +++ b/doc/tutorial/misc/tutorial-synthetic-blenderproc.dox @@ -715,16 +715,9 @@ We also download the pretrained yolo model, that we will finetune on our own dat (yolov7) ~/yolov7 $ wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt ``` -**Important note**: while creating the yolov7 virtual environment, you may face the following error: -``` -requirements to build wheel did not run successfully -``` -It can be solved by fixing the version of the Python of the virtual environment: -``` -~/yolov7 $ conda create --name yolov7 pip python=3.10 -~/yolov7 $ conda activate yolov7 -(yolov7) ~/yolov7 $ pip install -r requirements.txt -``` +\warning While creating the yolov7 virtual environment, you may face the following error: +"requirements to build wheel did not run successfully". It can be solved by fixing the version of the Python of +the virtual environment: `conda create --name yolov7 pip python=3.10` To fine-tune a YoloV7, we should create two new files: the network configuration and the hyperparameters. We will reuse the ones provided for the tiny model. From f32328babc784f317508da953fb216b8c4126858 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Fri, 18 Oct 2024 17:34:24 +0200 Subject: [PATCH 05/15] Introduce a workaround to consider nlohmann_json installed on system and nlohmann_json used as a built in 3rdparty by VTK > 9.2.0 when PCL is enabled. Fixes #1485. --- ci/docker/ubuntu-dep-src/Dockerfile | 18 +++--- ci/docker/ubuntu-dep-src/README.md | 73 ++++++++++++++++++++++ cmake/templates/vpConfig.h.in | 8 +++ modules/gui/src/pointcloud/vpPclViewer.cpp | 2 +- 4 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 ci/docker/ubuntu-dep-src/README.md diff --git a/ci/docker/ubuntu-dep-src/Dockerfile b/ci/docker/ubuntu-dep-src/Dockerfile index 63ab7d1914..ea2f86fc66 100644 --- a/ci/docker/ubuntu-dep-src/Dockerfile +++ b/ci/docker/ubuntu-dep-src/Dockerfile @@ -91,8 +91,8 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && git clone --depth 1 --branch $LATEST_TAG $GIT_ADDRESS \ && cd OpenBLAS \ && mkdir install \ - && make -j$(nproc) \ - && make -j$(nproc) install PREFIX=$(pwd)/install + && make -j$(($(nproc) / 2)) \ + && make -j$(($(nproc) / 2)) install PREFIX=$(pwd)/install ENV OpenBLAS_HOME=${HOME}/visp-ws/3rdparty/OpenBLAS/install @@ -107,7 +107,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && cmake .. -DVTK_ANDROID_BUILD=OFF -DVTK_BUILD_DOCUMENTATION=OFF -DVTK_BUILD_EXAMPLES=OFF -DVTK_BUILD_EXAMPLES=OFF \ -DCMAKE_BUILD_TYPE=Release -DVTK_GROUP_ENABLE_Imaging=DONT_WANT -DVTK_GROUP_ENABLE_MPI=DONT_WANT \ -DVTK_GROUP_ENABLE_Web=DONT_WANT -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/VTK/build/install \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) install ENV VTK_DIR=${HOME}/visp-ws/3rdparty/VTK/build/install @@ -121,7 +121,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && mkdir install \ && cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/opencv/build/install \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) install ENV OpenCV_DIR=${HOME}/visp-ws/3rdparty/opencv/build/install @@ -135,7 +135,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && mkdir install \ && cmake .. -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/librealsense/build/install \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) install ENV REALSENSE2_DIR=${HOME}/visp-ws/3rdparty/librealsense/build/install @@ -149,7 +149,7 @@ RUN cd ${HOME}/visp-ws/3rdparty \ && mkdir install \ && cmake .. -DBUILD_tools=OFF -DBUILD_global_tests=OFF -DPCL_DISABLE_GPU_TESTS=ON -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/3rdparty/pcl/build/install \ - && make -j10 install + && make -j$(($(nproc) / 3)) install ENV PCL_DIR=${HOME}/visp-ws/3rdparty/pcl/build/install @@ -160,7 +160,7 @@ RUN mkdir -p ${HOME}/visp-ws \ && echo "export VISP_WS=${HOME}/visp-ws" >> ${HOME}/.bashrc \ && echo "export VISP_INPUT_IMAGE_PATH=${HOME}/visp-ws/visp-images" >> ${HOME}/.bashrc -# Download ViSP fork +# Download ViSP RUN cd ${HOME}/visp-ws \ && git clone ${GIT_URL} ${GIT_BRANCH_CMD} @@ -169,7 +169,7 @@ RUN cd ${HOME}/visp-ws \ && mkdir visp-build \ && cd visp-build \ && cmake ../visp -DCMAKE_INSTALL_PREFIX=${HOME}/visp-ws/visp-build/install \ - && make -j$(nproc) developer_scripts \ - && make -j$(nproc) install + && make -j$(($(nproc) / 2)) developer_scripts \ + && make -j$(($(nproc) / 2)) install CMD ["/bin/bash"] diff --git a/ci/docker/ubuntu-dep-src/README.md b/ci/docker/ubuntu-dep-src/README.md new file mode 100644 index 0000000000..d51ede189d --- /dev/null +++ b/ci/docker/ubuntu-dep-src/README.md @@ -0,0 +1,73 @@ +# Docker dedicated to check compatibility with 3rd party last releases + +## Build docker image from Dockerfile + +- We suppose here that you already installed docker. +If this is not the case, follow instructions provided for [Ubuntu](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-docker.html#install_docker_engine_ubuntu) or [MacOS](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-docker.html#install_docker_engine_mac). + +- Get ViSP source code + ``` + $ cd $VISP_WS/ + $ git clone https://github.com/lagadic/visp + ``` + +- Build docker image from Dockerfile running the following: + ``` + $ cd $VISP_WS/visp/ci/docker/ubuntu-dep-src + $ docker build -t vispci/vispci:ubuntu-dep-src . + ``` + The version of ViSP that is considered is by default the master branch from github official repo in + https://github.com/lagadic/visp + + There is also the possibility to build visp from a specific repo and branch using `GIT_URL` and `GIT_BRANCH_NAME` + args, like + ``` + $ cd $VISP_WS/visp/ci/docker/ubuntu-dep-src + $ docker build -t vispci/vispci:ubuntu-dep-src --build-arg GIT_URL=https://github.com/lagadic/visp --build-arg GIT_BRANCH_NAME=master . + ``` + +## Start the container + +### On Ubuntu host + +- On your computer running Ubuntu, allow access to the X11 server + ``` + $ xhost +local:docker + non-network local connections being added to access control list + ``` +- Run your Docker container. The following command connects to the ubuntu-dep-src Docker container. + ``` + $ docker run --rm -it --network=host --privileged \ + --env=DISPLAY \ + --env=QT_X11_NO_MITSHM=1 \ + --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw \ + --volume=/dev:/dev \ + vispci/vispci:ubuntu-dep-src + vispci@6c8d67579659:~$ pwd + /home/vispci + ``` + +### On MacOS host + +- Get your MacOS computer IP address + ``` + $ IP=$(/usr/sbin/ipconfig getifaddr en0) + $ echo $IP + $ 192.168.1.18 + ``` +- Allow connections from MacOS to XQuartz + ``` + $ xhost + "$IP" + 192.168.1.18 being added to access control list + ``` +- Run your Docker container. The following command connects to the ubuntu-dep-src Docker container. + ``` + $ docker run --rm -it --network=host --privileged \ + --env=DISPLAY="${IP}:0" \ + --env=QT_X11_NO_MITSHM=1 \ + --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw \ + --volume=/dev:/dev \ + vispci/vispci:ubuntu-dep-src + vispci@6c8d67579659:~$ pwd + /home/vispci + ``` diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index dd4643bae9..17d3be781c 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -527,6 +527,14 @@ namespace vp = VISP_NAMESPACE_NAME; // Defined if nlohmann json parser is found #cmakedefine VISP_HAVE_NLOHMANN_JSON +// Workaround for issue https://github.com/lagadic/visp/issues/1485 +#if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_PCL_VISUALIZATION) +#include +#if VTK_VERSION_NUMBER_QUICK >= VTK_VERSION_CHECK(9, 2, 0) +#include +#endif +#endif + // Define c++ standard values also available in __cplusplus when gcc is used #define VISP_CXX_STANDARD_98 ${VISP_CXX_STANDARD_98} #define VISP_CXX_STANDARD_11 ${VISP_CXX_STANDARD_11} diff --git a/modules/gui/src/pointcloud/vpPclViewer.cpp b/modules/gui/src/pointcloud/vpPclViewer.cpp index 94adb3c48a..dd866f50e8 100644 --- a/modules/gui/src/pointcloud/vpPclViewer.cpp +++ b/modules/gui/src/pointcloud/vpPclViewer.cpp @@ -37,7 +37,7 @@ #include #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) && defined(VISP_HAVE_THREADS) // PCL -#include +#include // ViSP #include From 32df010495b64f707f5247f46f8ec563a27b045e Mon Sep 17 00:00:00 2001 From: Olivier Roussel Date: Thu, 31 Oct 2024 12:10:09 +0100 Subject: [PATCH 06/15] add icu lib on linux CI --- .github/workflows/conda/environment_linux.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/conda/environment_linux.yml b/.github/workflows/conda/environment_linux.yml index 0ee6f44a19..71038ef880 100644 --- a/.github/workflows/conda/environment_linux.yml +++ b/.github/workflows/conda/environment_linux.yml @@ -8,6 +8,7 @@ dependencies: - xorg-libx11 - xorg-libxfixes - mesa-libegl-cos7-x86_64 + - icu - libxml2 - libdc1394 >=2.2.6 - librealsense From 66c5ed3961ec1e788314e0c6174d1a77033e43aa Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Thu, 31 Oct 2024 15:55:13 +0100 Subject: [PATCH 07/15] [FIX] Fixing other architectures CI failure due to change of API --- .github/workflows/other-arch-isolated.yml | 18 +++++++++++------- .github/workflows/other-arch.yml | 9 +++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/other-arch-isolated.yml b/.github/workflows/other-arch-isolated.yml index fae718834e..9952242d71 100644 --- a/.github/workflows/other-arch-isolated.yml +++ b/.github/workflows/other-arch-isolated.yml @@ -29,22 +29,22 @@ jobs: # distro: bullseye # target: ARMV6 - arch: armv7 - distro: ubuntu_latest + distro: ubuntu:latest target: ARMV7 endianness: (Little Endian) - arch: aarch64 - distro: ubuntu_latest + distro: ubuntu:latest endianness: (Little Endian) - arch: riscv64 - distro: ubuntu_latest + distro: ubuntu:latest target: RISC-V endianness: (Little Endian) - arch: ppc64le - distro: ubuntu_latest + distro: ubuntu:latest target: POWER8 endianness: (Little Endian) - arch: s390x - distro: ubuntu_latest + distro: ubuntu:latest target: Z13 endianness: (Big Endian) @@ -54,10 +54,14 @@ jobs: - name: Run on arch uses: uraimo/run-on-arch-action@v2.7.2 + # See issue https://github.com/uraimo/run-on-arch-action/issues/155 for the explanation on the weird use of the arch and distro + # that resulted in error + # ERROR: failed to solve: ${arch}/ubuntu:latest: failed to resolve source metadata for docker.io/${arch}/ubuntu:latest: no match for platform in manifest: not found with: githubToken: ${{ github.token }} - arch: ${{ matrix.arch }} - distro: ${{ matrix.distro }} + arch: none + distro: none + base_image: "--platform=linux/${{ matrix.arch }} ${{ matrix.distro }}" run: | lscpu diff --git a/.github/workflows/other-arch.yml b/.github/workflows/other-arch.yml index 18ccb7c6a1..6a4d6ab9aa 100644 --- a/.github/workflows/other-arch.yml +++ b/.github/workflows/other-arch.yml @@ -32,14 +32,14 @@ jobs: # distro: ubuntu20.04 # target: ARMV7 - arch: aarch64 - distro: ubuntu_latest + distro: ubuntu:latest target: ARMV8 endianness: (Little Endian) # - arch: ppc64le # distro: ubuntu20.04 # target: POWER8 - arch: s390x - distro: ubuntu_latest + distro: ubuntu:latest target: Z13 endianness: (Big Endian) @@ -51,8 +51,9 @@ jobs: uses: uraimo/run-on-arch-action@v2.7.2 with: githubToken: ${{ github.token }} - arch: ${{ matrix.arch }} - distro: ${{ matrix.distro }} + arch: none + distro: none + base_image: "--platform=linux/${{ matrix.arch }} ${{ matrix.distro }}" run: | lscpu From 308aa1db86194ecb082a247cd061a7c88320c49f Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Thu, 31 Oct 2024 17:33:30 +0100 Subject: [PATCH 08/15] Introduce VISP_NLOHMANN_JSON() macro to include nlohmann_json headers. It allows to consider nlohman_json header installed either in the system or the one coming from VTK when PCL is used --- CMakeLists.txt | 20 +++++++++++++++++-- cmake/PCLTools.cmake | 15 ++++++++++++++ cmake/VISPUtils.cmake | 12 ++++++++++- cmake/templates/vpConfig.h.in | 20 +++++++++++-------- doc/tutorial/misc/tutorial-json.dox | 4 ++-- modules/core/CMakeLists.txt | 2 +- modules/core/include/visp3/core/vpArray2D.h | 2 +- .../include/visp3/core/vpCameraParameters.h | 4 ++-- .../include/visp3/core/vpCannyEdgeDetection.h | 2 +- modules/core/include/visp3/core/vpColVector.h | 2 +- .../include/visp3/core/vpHomogeneousMatrix.h | 2 +- .../core/include/visp3/core/vpJsonParsing.h | 2 +- modules/core/include/visp3/core/vpPolygon3D.h | 2 +- .../core/include/visp3/core/vpPoseVector.h | 2 +- modules/core/test/camera/catchJsonCamera.cpp | 2 +- .../test/math/catchJsonArrayConversion.cpp | 2 +- .../visp3/detection/vpDetectorDNNOpenCV.h | 2 +- modules/gui/src/pointcloud/vpPclViewer.cpp | 6 +++--- .../visp3/imgproc/vpCircleHoughTransform.h | 2 +- modules/io/CMakeLists.txt | 2 +- .../include/visp3/io/vpJsonArgumentParser.h | 2 +- modules/io/test/catchJsonArgumentParser.cpp | 2 +- .../include/visp3/dnn_tracker/vpMegaPose.h | 2 +- modules/tracker/mbt/CMakeLists.txt | 2 +- .../include/visp3/mbt/vpMbGenericTracker.h | 2 +- .../include/visp3/mbt/vpMbtFaceDepthNormal.h | 2 +- .../tracker/mbt/src/vpMbGenericTracker.cpp | 2 +- .../catchMbtJsonSettings.cpp | 2 +- modules/tracker/me/include/visp3/me/vpMe.h | 2 +- modules/tracker/me/test/catchJsonMe.cpp | 2 +- .../tutorial-dnn-object-detection-live.cpp | 2 +- ...l-megapose-live-single-object-tracking.cpp | 4 ++-- ...mb-generic-tracker-rgbd-realsense-json.cpp | 2 +- .../ibvs/tutorial-ibvs-4pts-json.cpp | 2 +- 34 files changed, 91 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e365699394..a97bd70bcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -687,6 +687,17 @@ if(USE_PCL) set(PCL_REQUIRED_COMPONENTS "common;filters;io;visualization;segmentation") # Create cmake vars corresponding to pcl components used by ViSP like VISP_HAVE_PCL_COMMON... vp_detect_required_pcl_components(PCL_REQUIRED_COMPONENTS) + + # USE_NLOHMANN_JSON is set to ON if nlohmann_json is installed and found thanks to nlohmann_jsonConfig.cmake. + # VTK that is a PCL 3rd party embbed also a built in version of nlohmann_json. + # Here we add a specific case to consider the nlohmann version coming from VTK when the system version is not found + if(NOT USE_NLOHMANN_JSON) + if(VISP_HAVE_NLOHMANN_JSON_FROM_VTK) + message(WARNING "json 3rd party is detected and used as a VTK 3rd party which is itself a PCL 3rd party. Thus we enable nlohmann json usage turning USE_NLOHMANN_JSON=ON.") + unset(USE_NLOHMANN_JSON) + set(USE_NLOHMANN_JSON ON CACHE BOOL "Include nlohmann json support thanks to VTK" FORCE) + endif() + endif() endif() # ---------------------------------------------------------------------------- @@ -1090,7 +1101,8 @@ VP_SET(VISP_HAVE_THREADS TRUE IF (BUILD_MODULE_visp_core AND USE_THREADS)) VP_SET(VISP_HAVE_XML2 TRUE IF (BUILD_MODULE_visp_core AND USE_XML2)) VP_SET(VISP_HAVE_PCL TRUE IF (BUILD_MODULE_visp_core AND USE_PCL)) VP_SET(VISP_HAVE_TENSORRT TRUE IF (BUILD_MODULE_visp_core AND USE_TENSORRT)) -VP_SET(VISP_HAVE_NLOHMANN_JSON TRUE IF (BUILD_MODULE_visp_core AND USE_NLOHMANN_JSON)) +VP_SET(VISP_HAVE_NLOHMANN_JSON TRUE IF (BUILD_MODULE_visp_core AND USE_NLOHMANN_JSON)) +VP_SET(VISP_HAVE_NLOHMANN_JSON_FROM_VTK TRUE IF (BUILD_MODULE_visp_core AND VISP_HAVE_NLOHMANN_JSON_FROM_VTK)) VP_SET(VISP_HAVE_OGRE TRUE IF (BUILD_MODULE_visp_ar AND USE_OGRE)) VP_SET(VISP_HAVE_OIS TRUE IF (BUILD_MODULE_visp_ar AND USE_OIS)) @@ -1844,7 +1856,11 @@ status(" Misc: ") status(" Use Clipper (built-in):" WITH_CLIPPER THEN "yes (ver ${CLIPPER_VERSION})" ELSE "no") status(" Use pugixml (built-in):" WITH_PUGIXML THEN "yes (ver ${PUGIXML_VERSION})" ELSE "no") status(" Use libxml2:" USE_XML2 THEN "yes (ver ${XML2_VERSION_STRING})" ELSE "no") -status(" Use json (nlohmann):" USE_NLOHMANN_JSON THEN "yes (ver ${nlohmann_json_VERSION})" ELSE "no") +if(VISP_HAVE_NLOHMANN_JSON_FROM_VTK) +status(" Use json (nlohmann vtk):" USE_NLOHMANN_JSON THEN "yes (ver ${VTK_NLOHMANN_JSON_VERSION})" ELSE "no") +else() +status(" Use json (nlohmann system):" USE_NLOHMANN_JSON THEN "yes (ver ${nlohmann_json_VERSION})" ELSE "no") +endif() status("") status(" Optimization: ") status(" Use OpenMP:" USE_OPENMP THEN "yes" ELSE "no") diff --git a/cmake/PCLTools.cmake b/cmake/PCLTools.cmake index e0b67b9a30..2b04a427d9 100644 --- a/cmake/PCLTools.cmake +++ b/cmake/PCLTools.cmake @@ -257,6 +257,21 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries) endif() endforeach() + find_path(VTK_NLOHMANN_JSON_INCLUDE_DIR vtknlohmannjson/include/vtknlohmann/json.hpp + PATHS + ${PCL_VTK_IMPORTED_INCS} + ) + mark_as_advanced(VTK_NLOHMANN_JSON_INCLUDE_DIR) + if(VTK_NLOHMANN_JSON_INCLUDE_DIR) + vp_parse_header("${VTK_NLOHMANN_JSON_INCLUDE_DIR}/vtknlohmannjson/include/vtknlohmann/json.hpp" NLOHMANN_JSON_VERSION_LINES NLOHMANN_JSON_VERSION_MAJOR NLOHMANN_JSON_VERSION_MINOR NLOHMANN_JSON_VERSION_PATCH) + set(VTK_NLOHMANN_JSON_VERSION "${NLOHMANN_JSON_VERSION_MAJOR}.${NLOHMANN_JSON_VERSION_MINOR}.${NLOHMANN_JSON_VERSION_PATCH}") + list(APPEND ${pcl_deps_include_dirs} "${VTK_NLOHMANN_JSON_INCLUDE_DIR}/vtknlohmannjson/include") + set(VISP_HAVE_NLOHMANN_JSON_FROM_VTK TRUE) + else() + set(VISP_HAVE_NLOHMANN_JSON_FROM_VTK FALSE) + set(VTK_NLOHMANN_JSON_VERSION "n/a") + endif() + # On win10 + msvc 15 2017 with pcl 1.9.1 opengl32.lib needed by vtkRenderingOpenGL-8.1-gd.lib is not found # Here we explicitly add opengl if(OPENGL_LIBRARIES) diff --git a/cmake/VISPUtils.cmake b/cmake/VISPUtils.cmake index e3094740e1..3c5f06a62e 100644 --- a/cmake/VISPUtils.cmake +++ b/cmake/VISPUtils.cmake @@ -1248,6 +1248,14 @@ function(status text) endfunction() # read set of version defines from the header file +# This macro allows to get defines values from a header file. +# For example if the header.hpp file contains +# #define LIB_VERSION_MAJOR 1 +# #define LIB_VERSION_MINOR 2 +# #define LIB_VERSION_PATCH 3 +# to retrieve the values of these defines and compose a string version you may use +# vp_parse_header("header.hpp" LIB_VERSION_LINES LIB_VERSION_MAJOR LIB_VERSION_MINOR LIB_VERSION_PATCH) +# set(LIB_VERSION "${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}") macro(vp_parse_header FILENAME FILE_VAR) set(vars_regex "") set(__parent_scope OFF) @@ -1289,6 +1297,9 @@ macro(vp_parse_header FILENAME FILE_VAR) endmacro() # read single version define from the header file +# Example to detect the version in header.hpp file that contains: +# #define MyLIB_VERSION_STR "1.2.3" +# use vp_parse_header2(MyLIB "header.hpp" LIB_VERSION_STR) macro(vp_parse_header2 LIBNAME HDR_PATH VARNAME) vp_clear_vars(${LIBNAME}_VERSION_MAJOR ${LIBNAME}_VERSION_MAJOR @@ -1300,7 +1311,6 @@ macro(vp_parse_header2 LIBNAME HDR_PATH VARNAME) if(EXISTS "${HDR_PATH}") file(STRINGS "${HDR_PATH}" ${LIBNAME}_H REGEX "^#define[ \t]+${VARNAME}[ \t]+\"[^\"]*\".*$" LIMIT_COUNT 1) endif() - if(${LIBNAME}_H) string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MAJOR "${${LIBNAME}_H}") string(REGEX REPLACE "^.*[ \t]${VARNAME}[ \t]+\"[0-9]+\\.([0-9]+).*$" "\\1" ${LIBNAME}_VERSION_MINOR "${${LIBNAME}_H}") diff --git a/cmake/templates/vpConfig.h.in b/cmake/templates/vpConfig.h.in index 17d3be781c..1703725de2 100644 --- a/cmake/templates/vpConfig.h.in +++ b/cmake/templates/vpConfig.h.in @@ -1,6 +1,6 @@ /* * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -524,15 +524,19 @@ namespace vp = VISP_NAMESPACE_NAME; // Defined if we want to use openmp #cmakedefine VISP_HAVE_OPENMP -// Defined if nlohmann json parser is found +// Defined if nlohmann json parser is found (either system or coming from VTK) #cmakedefine VISP_HAVE_NLOHMANN_JSON -// Workaround for issue https://github.com/lagadic/visp/issues/1485 -#if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_PCL_VISUALIZATION) -#include -#if VTK_VERSION_NUMBER_QUICK >= VTK_VERSION_CHECK(9, 2, 0) -#include -#endif +// Defined if nlohmann json parser is found in PCL thanks to VTK 3rd party +#cmakedefine VISP_HAVE_NLOHMANN_JSON_FROM_VTK + +#ifdef VISP_HAVE_NLOHMANN_JSON +# if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_NLOHMANN_JSON_FROM_VTK) +# include +# define VISP_NLOHMANN_JSON(x) +# else +# define VISP_NLOHMANN_JSON(x) +# endif #endif // Define c++ standard values also available in __cplusplus when gcc is used diff --git a/doc/tutorial/misc/tutorial-json.dox b/doc/tutorial/misc/tutorial-json.dox index f909d78856..7a0f8200c7 100644 --- a/doc/tutorial/misc/tutorial-json.dox +++ b/doc/tutorial/misc/tutorial-json.dox @@ -29,7 +29,7 @@ Much of this section is a repeat of the library's documentation, available +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; // For convenience \endcode @@ -62,7 +62,7 @@ void to_json(json& j, const YourType& t); \endcode These functions must be defined in the same scope namespace as YourType and must be accessible everywhere YourType is used. It is thus common to define it in the header where YourType is defined. \code -#include +#include VISP_NLOHMANN_JSON(json.hpp) class YourType { public: diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index 6571aa581a..3b2063d25d 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -272,7 +272,7 @@ if(USE_OPENMP) endforeach() endif() -if(USE_NLOHMANN_JSON) +if(USE_NLOHMANN_JSON AND NOT VISP_HAVE_NLOHMANN_JSON_FROM_VTK) get_target_property(_inc_dirs "nlohmann_json::nlohmann_json" INTERFACE_INCLUDE_DIRECTORIES) list(APPEND opt_incs ${_inc_dirs}) endif() diff --git a/modules/core/include/visp3/core/vpArray2D.h b/modules/core/include/visp3/core/vpArray2D.h index f0ba0196e2..560e1effe2 100644 --- a/modules/core/include/visp3/core/vpArray2D.h +++ b/modules/core/include/visp3/core/vpArray2D.h @@ -47,7 +47,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif BEGIN_VISP_NAMESPACE diff --git a/modules/core/include/visp3/core/vpCameraParameters.h b/modules/core/include/visp3/core/vpCameraParameters.h index c20887f93f..1bf1c9d9eb 100644 --- a/modules/core/include/visp3/core/vpCameraParameters.h +++ b/modules/core/include/visp3/core/vpCameraParameters.h @@ -49,7 +49,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif BEGIN_VISP_NAMESPACE @@ -451,7 +451,7 @@ class VISP_EXPORT vpCameraParameters }; #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) NLOHMANN_JSON_SERIALIZE_ENUM(vpCameraParameters::vpCameraParametersProjType, { {vpCameraParameters::perspectiveProjWithoutDistortion, "perspectiveWithoutDistortion"}, {vpCameraParameters::perspectiveProjWithDistortion, "perspectiveWithDistortion"}, diff --git a/modules/core/include/visp3/core/vpCannyEdgeDetection.h b/modules/core/include/visp3/core/vpCannyEdgeDetection.h index e70360f40e..4ad676aead 100644 --- a/modules/core/include/visp3/core/vpCannyEdgeDetection.h +++ b/modules/core/include/visp3/core/vpCannyEdgeDetection.h @@ -42,7 +42,7 @@ // 3rd parties include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif BEGIN_VISP_NAMESPACE diff --git a/modules/core/include/visp3/core/vpColVector.h b/modules/core/include/visp3/core/vpColVector.h index 969db03ec7..56963be7e6 100644 --- a/modules/core/include/visp3/core/vpColVector.h +++ b/modules/core/include/visp3/core/vpColVector.h @@ -43,7 +43,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif BEGIN_VISP_NAMESPACE class vpMatrix; diff --git a/modules/core/include/visp3/core/vpHomogeneousMatrix.h b/modules/core/include/visp3/core/vpHomogeneousMatrix.h index 9d99ccbad3..3883dff892 100644 --- a/modules/core/include/visp3/core/vpHomogeneousMatrix.h +++ b/modules/core/include/visp3/core/vpHomogeneousMatrix.h @@ -63,7 +63,7 @@ END_VISP_NAMESPACE #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif BEGIN_VISP_NAMESPACE diff --git a/modules/core/include/visp3/core/vpJsonParsing.h b/modules/core/include/visp3/core/vpJsonParsing.h index 65086d5d79..62e7dfb533 100644 --- a/modules/core/include/visp3/core/vpJsonParsing.h +++ b/modules/core/include/visp3/core/vpJsonParsing.h @@ -37,7 +37,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) BEGIN_VISP_NAMESPACE /*! diff --git a/modules/core/include/visp3/core/vpPolygon3D.h b/modules/core/include/visp3/core/vpPolygon3D.h index 27472e2b32..54dc7a4fe9 100644 --- a/modules/core/include/visp3/core/vpPolygon3D.h +++ b/modules/core/include/visp3/core/vpPolygon3D.h @@ -219,7 +219,7 @@ class VISP_EXPORT vpPolygon3D END_VISP_NAMESPACE #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #include NLOHMANN_JSON_SERIALIZE_ENUM(VISP_NAMESPACE_ADDRESSING vpPolygon3D::vpPolygon3DClippingType, { {VISP_NAMESPACE_ADDRESSING vpPolygon3D::NO_CLIPPING, "none"}, diff --git a/modules/core/include/visp3/core/vpPoseVector.h b/modules/core/include/visp3/core/vpPoseVector.h index 0eb9d1ad2e..4863901810 100644 --- a/modules/core/include/visp3/core/vpPoseVector.h +++ b/modules/core/include/visp3/core/vpPoseVector.h @@ -331,7 +331,7 @@ class VISP_EXPORT vpPoseVector : public vpArray2D }; #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) inline void to_json(nlohmann::json &j, const vpPoseVector &r) { r.convert_to_json(j); diff --git a/modules/core/test/camera/catchJsonCamera.cpp b/modules/core/test/camera/catchJsonCamera.cpp index ae6c9b9ae3..63a06542b9 100644 --- a/modules/core/test/camera/catchJsonCamera.cpp +++ b/modules/core/test/camera/catchJsonCamera.cpp @@ -41,7 +41,7 @@ #include #if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_CATCH2) -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #include diff --git a/modules/core/test/math/catchJsonArrayConversion.cpp b/modules/core/test/math/catchJsonArrayConversion.cpp index be7060f49d..653d0e6d3e 100644 --- a/modules/core/test/math/catchJsonArrayConversion.cpp +++ b/modules/core/test/math/catchJsonArrayConversion.cpp @@ -45,7 +45,7 @@ #include #include -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #include diff --git a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h index 2da8aafe2d..9c0e0e362f 100644 --- a/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h +++ b/modules/detection/include/visp3/detection/vpDetectorDNNOpenCV.h @@ -54,7 +54,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif BEGIN_VISP_NAMESPACE diff --git a/modules/gui/src/pointcloud/vpPclViewer.cpp b/modules/gui/src/pointcloud/vpPclViewer.cpp index dd866f50e8..d1a8a67091 100644 --- a/modules/gui/src/pointcloud/vpPclViewer.cpp +++ b/modules/gui/src/pointcloud/vpPclViewer.cpp @@ -36,14 +36,14 @@ #include #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_IO) && defined(VISP_HAVE_THREADS) -// PCL -#include - // ViSP #include #include #include +// PCL +#include + BEGIN_VISP_NAMESPACE const std::vector gcolor = { vpColorBlindFriendlyPalette::Palette::Green, vpColorBlindFriendlyPalette::Palette::Vermillon,vpColorBlindFriendlyPalette::Palette::Blue, vpColorBlindFriendlyPalette::Palette::Black, vpColorBlindFriendlyPalette::Palette::Orange, vpColorBlindFriendlyPalette::Palette::Purple, diff --git a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h index 676b68125d..7448ea4722 100644 --- a/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h +++ b/modules/imgproc/include/visp3/imgproc/vpCircleHoughTransform.h @@ -44,7 +44,7 @@ // 3rd parties inclue #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17) diff --git a/modules/io/CMakeLists.txt b/modules/io/CMakeLists.txt index f9da76cb84..6683a93617 100644 --- a/modules/io/CMakeLists.txt +++ b/modules/io/CMakeLists.txt @@ -62,7 +62,7 @@ if(WITH_STBIMAGE) include_directories(${STBIMAGE_INCLUDE_DIRS}) endif() -if(USE_NLOHMANN_JSON) +if(USE_NLOHMANN_JSON AND NOT VISP_HAVE_NLOHMANN_JSON_FROM_VTK) get_target_property(_inc_dirs "nlohmann_json::nlohmann_json" INTERFACE_INCLUDE_DIRECTORIES) list(APPEND opt_incs ${_inc_dirs}) endif() diff --git a/modules/io/include/visp3/io/vpJsonArgumentParser.h b/modules/io/include/visp3/io/vpJsonArgumentParser.h index a95bfdf2a7..63fb30646f 100644 --- a/modules/io/include/visp3/io/vpJsonArgumentParser.h +++ b/modules/io/include/visp3/io/vpJsonArgumentParser.h @@ -37,7 +37,7 @@ #include #if defined(VISP_HAVE_NLOHMANN_JSON) -#include +#include VISP_NLOHMANN_JSON(json.hpp) #include #include diff --git a/modules/io/test/catchJsonArgumentParser.cpp b/modules/io/test/catchJsonArgumentParser.cpp index b9d6089fe2..cd37fa37a2 100644 --- a/modules/io/test/catchJsonArgumentParser.cpp +++ b/modules/io/test/catchJsonArgumentParser.cpp @@ -41,7 +41,7 @@ #include #if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_CATCH2) -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #include diff --git a/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h b/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h index d8f27c9b8a..fbfb9c1138 100644 --- a/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h +++ b/modules/tracker/dnn/include/visp3/dnn_tracker/vpMegaPose.h @@ -49,7 +49,7 @@ #include #include -#include +#include VISP_NLOHMANN_JSON(json.hpp) BEGIN_VISP_NAMESPACE /** diff --git a/modules/tracker/mbt/CMakeLists.txt b/modules/tracker/mbt/CMakeLists.txt index de17caab1a..c2ae6ad107 100644 --- a/modules/tracker/mbt/CMakeLists.txt +++ b/modules/tracker/mbt/CMakeLists.txt @@ -116,7 +116,7 @@ if(USE_PCL) list(APPEND opt_libs ${PCL_DEPS_LIBRARIES}) endif() -if(USE_NLOHMANN_JSON) +if(USE_NLOHMANN_JSON AND NOT VISP_HAVE_NLOHMANN_JSON_FROM_VTK) get_target_property(_inc_dirs "nlohmann_json::nlohmann_json" INTERFACE_INCLUDE_DIRECTORIES) list(APPEND opt_incs ${_inc_dirs}) endif() diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h index 02ce70db04..ba440d25ea 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h @@ -46,7 +46,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json_fwd.hpp) #include #endif diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h b/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h index dbe83e219b..c8fd9224b8 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbtFaceDepthNormal.h @@ -324,7 +324,7 @@ class VISP_EXPORT vpMbtFaceDepthNormal END_VISP_NAMESPACE #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #if defined(VISP_HAVE_PCL) && defined(VISP_HAVE_PCL_COMMON) && defined(VISP_HAVE_PCL_SEGMENTATION) && defined(VISP_HAVE_PCL_FILTERS) NLOHMANN_JSON_SERIALIZE_ENUM(VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::vpFeatureEstimationType, { {VISP_NAMESPACE_ADDRESSING vpMbtFaceDepthNormal::ROBUST_FEATURE_ESTIMATION, "robust"}, diff --git a/modules/tracker/mbt/src/vpMbGenericTracker.cpp b/modules/tracker/mbt/src/vpMbGenericTracker.cpp index ac28776a57..7f7726ef70 100644 --- a/modules/tracker/mbt/src/vpMbGenericTracker.cpp +++ b/modules/tracker/mbt/src/vpMbGenericTracker.cpp @@ -42,7 +42,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #endif diff --git a/modules/tracker/mbt/test/generic-with-dataset/catchMbtJsonSettings.cpp b/modules/tracker/mbt/test/generic-with-dataset/catchMbtJsonSettings.cpp index 36a20ceb43..2b960e13ec 100644 --- a/modules/tracker/mbt/test/generic-with-dataset/catchMbtJsonSettings.cpp +++ b/modules/tracker/mbt/test/generic-with-dataset/catchMbtJsonSettings.cpp @@ -41,7 +41,7 @@ #include #if defined(VISP_HAVE_NLOHMANN_JSON) && defined(VISP_HAVE_CATCH2) -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #include diff --git a/modules/tracker/me/include/visp3/me/vpMe.h b/modules/tracker/me/include/visp3/me/vpMe.h index d8fa3d0e7f..93b0d7f782 100644 --- a/modules/tracker/me/include/visp3/me/vpMe.h +++ b/modules/tracker/me/include/visp3/me/vpMe.h @@ -45,7 +45,7 @@ #include #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) #endif BEGIN_VISP_NAMESPACE diff --git a/modules/tracker/me/test/catchJsonMe.cpp b/modules/tracker/me/test/catchJsonMe.cpp index ab5d7f3b69..61630c3d6d 100644 --- a/modules/tracker/me/test/catchJsonMe.cpp +++ b/modules/tracker/me/test/catchJsonMe.cpp @@ -45,7 +45,7 @@ #include #include -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #include diff --git a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp index 4f8fe47c1b..cbe4ddecf3 100644 --- a/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp +++ b/tutorial/detection/dnn/tutorial-dnn-object-detection-live.cpp @@ -11,7 +11,7 @@ #endif #ifdef VISP_HAVE_NLOHMANN_JSON -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #endif diff --git a/tutorial/tracking/dnn/tutorial-megapose-live-single-object-tracking.cpp b/tutorial/tracking/dnn/tutorial-megapose-live-single-object-tracking.cpp index 6a34c93c36..44e766dfc6 100644 --- a/tutorial/tracking/dnn/tutorial-megapose-live-single-object-tracking.cpp +++ b/tutorial/tracking/dnn/tutorial-megapose-live-single-object-tracking.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include VISP_NLOHMANN_JSON(json.hpp) #include @@ -193,7 +193,7 @@ NLOHMANN_JSON_SERIALIZE_ENUM(DetectionMethod, { {UNKNOWN, nullptr}, // Default value if the json string is not in "current", "desired" or "mean" {CLICK, "click"}, {DNN, "dnn"} } -); + ); int main(int argc, const char *argv[]) diff --git a/tutorial/tracking/model-based/generic-rgbd/tutorial-mb-generic-tracker-rgbd-realsense-json.cpp b/tutorial/tracking/model-based/generic-rgbd/tutorial-mb-generic-tracker-rgbd-realsense-json.cpp index f52aff40a8..464c9f806c 100644 --- a/tutorial/tracking/model-based/generic-rgbd/tutorial-mb-generic-tracker-rgbd-realsense-json.cpp +++ b/tutorial/tracking/model-based/generic-rgbd/tutorial-mb-generic-tracker-rgbd-realsense-json.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut diff --git a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-json.cpp b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-json.cpp index 237f924134..3b45de14d4 100644 --- a/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-json.cpp +++ b/tutorial/visual-servo/ibvs/tutorial-ibvs-4pts-json.cpp @@ -8,7 +8,7 @@ #include -#include +#include VISP_NLOHMANN_JSON(json.hpp) using json = nlohmann::json; //! json namespace shortcut #if defined(ENABLE_VISP_NAMESPACE) From a5e7c7b5b7fe251954f1836ae6a24151375d9dc9 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Fri, 1 Nov 2024 11:10:49 +0100 Subject: [PATCH 09/15] Use latest uraimo/run-on-arch-action --- .github/workflows/other-arch-isolated.yml | 2 +- .github/workflows/other-arch.yml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/other-arch-isolated.yml b/.github/workflows/other-arch-isolated.yml index 9952242d71..e7e8485f58 100644 --- a/.github/workflows/other-arch-isolated.yml +++ b/.github/workflows/other-arch-isolated.yml @@ -53,7 +53,7 @@ jobs: uses: actions/checkout@v4 - name: Run on arch - uses: uraimo/run-on-arch-action@v2.7.2 + uses: uraimo/run-on-arch-action@v2 # See issue https://github.com/uraimo/run-on-arch-action/issues/155 for the explanation on the weird use of the arch and distro # that resulted in error # ERROR: failed to solve: ${arch}/ubuntu:latest: failed to resolve source metadata for docker.io/${arch}/ubuntu:latest: no match for platform in manifest: not found diff --git a/.github/workflows/other-arch.yml b/.github/workflows/other-arch.yml index 6a4d6ab9aa..27884f1036 100644 --- a/.github/workflows/other-arch.yml +++ b/.github/workflows/other-arch.yml @@ -48,7 +48,10 @@ jobs: uses: actions/checkout@v4 - name: Run on arch - uses: uraimo/run-on-arch-action@v2.7.2 + uses: uraimo/run-on-arch-action@v2 + # See issue https://github.com/uraimo/run-on-arch-action/issues/155 for the explanation on the weird use of the arch and distro + # that resulted in error + # ERROR: failed to solve: ${arch}/ubuntu:latest: failed to resolve source metadata for docker.io/${arch}/ubuntu:latest: no match for platform in manifest: not found with: githubToken: ${{ github.token }} arch: none From 0a33ed4078a5eb0076b1eb7dcb2d0bfb993cb512 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Fri, 1 Nov 2024 11:14:04 +0100 Subject: [PATCH 10/15] Attempt to force distro to ubuntu22.04 instead of ubuntu:latest on armv7 arch --- .github/workflows/other-arch-isolated.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/other-arch-isolated.yml b/.github/workflows/other-arch-isolated.yml index e7e8485f58..7bc1866478 100644 --- a/.github/workflows/other-arch-isolated.yml +++ b/.github/workflows/other-arch-isolated.yml @@ -29,7 +29,7 @@ jobs: # distro: bullseye # target: ARMV6 - arch: armv7 - distro: ubuntu:latest + distro: ubuntu22.04 target: ARMV7 endianness: (Little Endian) - arch: aarch64 From 5d62d6150bd4f7e0e2a8d44cccf7036ae8ff62f7 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Fri, 1 Nov 2024 17:02:28 +0100 Subject: [PATCH 11/15] Disable build on armv7 arch that produces the following issue while the changes introduced in previous commit make the other arch working Build container GitHub token provided, caching to ghcr.io/lagadic/visp/run-on-arch-lagadic-visp-other-architectures-isolated-none-none WARNING! Your password will be stored unencrypted in /home/runner/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded Error response from daemon: manifest unknown #0 building with "default" instance using docker driver #1 [internal] load build definition from Dockerfile.none.none #1 transferring dockerfile: 221B done #1 DONE 0.0s #2 [auth] library/ubuntu22.04:pull token for registry-1.docker.io #2 DONE 0.0s #3 [internal] load metadata for docker.io/library/ubuntu22.04:latest #3 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed ------ > [internal] load metadata for docker.io/library/ubuntu22.04:latest: ------ Dockerfile.none.none:1 -------------------- 1 | >>> FROM --platform=linux/armv7 ubuntu22.04 2 | COPY ./run-on-arch-install.sh /root/run-on-arch-install.sh 3 | RUN chmod +x /root/run-on-arch-install.sh && /root/run-on-arch-install.sh -------------------- ERROR: failed to solve: ubuntu22.04: failed to resolve source metadata for docker.io/library/ubuntu22.04:latest: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed Error: The process '/home/runner/work/_actions/uraimo/run-on-arch-action/v2/src/run-on-arch.sh' failed with exit code 1 --- .github/workflows/other-arch-isolated.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/other-arch-isolated.yml b/.github/workflows/other-arch-isolated.yml index 7bc1866478..6a485e2f02 100644 --- a/.github/workflows/other-arch-isolated.yml +++ b/.github/workflows/other-arch-isolated.yml @@ -28,10 +28,10 @@ jobs: # - arch: armv6 # distro: bullseye # target: ARMV6 - - arch: armv7 - distro: ubuntu22.04 - target: ARMV7 - endianness: (Little Endian) + #- arch: armv7 + # distro: ubuntu:latest + # target: ARMV7 + # endianness: (Little Endian) - arch: aarch64 distro: ubuntu:latest endianness: (Little Endian) From 24f3e3014d02592b735a19d4fe686cf23fdfc1f1 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Sat, 2 Nov 2024 10:44:48 +0100 Subject: [PATCH 12/15] Remove useless code --- .../tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h index ba440d25ea..6983bc0c33 100644 --- a/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h +++ b/modules/tracker/mbt/include/visp3/mbt/vpMbGenericTracker.h @@ -36,19 +36,15 @@ *\brief Generic model-based tracker */ -#ifndef _vpMbGenericTracker_h_ -#define _vpMbGenericTracker_h_ +#ifndef VP_MB_GENERIC_TRACKER_H +#define VP_MB_GENERIC_TRACKER_H #include #include #include #include #include - -#ifdef VISP_HAVE_NLOHMANN_JSON -#include VISP_NLOHMANN_JSON(json_fwd.hpp) #include -#endif BEGIN_VISP_NAMESPACE /*! From 9da181981b4c276dd51b531925deb7399251d086 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Sun, 3 Nov 2024 10:54:14 +0100 Subject: [PATCH 13/15] Fix vpArray::resize() when dsize = 0. Closes #1494. --- modules/core/include/visp3/core/vpArray2D.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/core/include/visp3/core/vpArray2D.h b/modules/core/include/visp3/core/vpArray2D.h index 560e1effe2..dc23719747 100644 --- a/modules/core/include/visp3/core/vpArray2D.h +++ b/modules/core/include/visp3/core/vpArray2D.h @@ -426,7 +426,10 @@ template class vpArray2D // Recopy of this->data array values or nullify if (flagNullify) { - memset(this->data, 0, static_cast(this->dsize) * sizeof(Type)); + // If dsize = 0 nothing to do + if ((nullptr != this->data) && (0 != this->dsize)) { + memset(this->data, 0, static_cast(this->dsize) * sizeof(Type)); + } } else if (recopyNeeded && (this->rowPtrs != nullptr)) { // Recopy... From ab30730ccd7b208f23e45f067a8cda7028e8ec29 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Sun, 3 Nov 2024 10:54:21 +0100 Subject: [PATCH 14/15] Update copyright header --- example/math/quadprog_eq.cpp | 9 ++++----- .../core/src/math/transformation/vpHomogeneousMatrix.cpp | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/example/math/quadprog_eq.cpp b/example/math/quadprog_eq.cpp index 85c3a00717..6c3cf66c51 100644 --- a/example/math/quadprog_eq.cpp +++ b/example/math/quadprog_eq.cpp @@ -1,7 +1,6 @@ -/**************************************************************************** - * +/* * ViSP, open source Visual Servoing Platform software. - * Copyright (C) 2005 - 2023 by Inria. All rights reserved. + * Copyright (C) 2005 - 2024 by Inria. All rights reserved. * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,8 +29,8 @@ * * Description: * Example of sequential calls to QP solver with constant equality constraint - * -*****************************************************************************/ + */ + /*! \file quadprog_eq.cpp diff --git a/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp b/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp index 0d364cd861..e0d071229a 100644 --- a/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp +++ b/modules/core/src/math/transformation/vpHomogeneousMatrix.cpp @@ -29,8 +29,7 @@ * * Description: * Homogeneous matrix. - * -*****************************************************************************/ + */ /*! \file vpHomogeneousMatrix.cpp From 520efed790eb51eaa586b54b834bd8b8b45aa684 Mon Sep 17 00:00:00 2001 From: Fabien Spindler Date: Sun, 3 Nov 2024 11:24:54 +0100 Subject: [PATCH 15/15] Update last fixed issues --- ChangeLog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 17d6b5fffe..758f9b1f53 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -87,6 +87,9 @@ ViSP 3.x.x (Version in development) . [#1341] SVD computation fails with Lapack when m < n . [#1370] encountered compilation errors while building the ViSP library . [#1424] Unable to detect Yarp 3.9.0 + . [#1485] Build issue around nlohmann_json usage with VTK 9.2.0 or more recent version used as an embedded + 3rdparty by PCL + . [#1494] Memory management issue in vpArray2D::resize() ---------------------------------------------- ViSP 3.6.0 (released September 22, 2023) - Contributors: