diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ffac375 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,296 @@ +name: Build, test and optionally deploy + +on: [push] + +jobs: + build-windows: + name: build-windows + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + lfs: 'true' + fetch-depth: 0 + - name: Pre-install (Windows) + shell: pwsh + run: | + $thirdpartydir="$((Get-Item ..).FullName)\3rdparty" + mkdir $thirdpartydir + - name: Install realsense SDK + shell: pwsh + run: | + choco install -y realsense-sdk2 + Add-Content $env:GITHUB_PATH "C:\Program Files (x86)\Intel RealSense SDK 2.0\bin\x64" + + - name: Install opencv (Windows) + shell: pwsh + run: | + $thirdpartydir="$((Get-Item ..\3rdparty).FullName)" + $installer="$thirdpartydir\opencv-installer.exe" + (New-Object System.Net.WebClient).DownloadFile("https://github.com/opencv/opencv/releases/download/4.5.5/opencv-4.5.5-vc14_vc15.exe","$installer"); + Start-Process "$installer" -ArgumentList '-o"C:\" -y' -Wait + Add-Content $env:GITHUB_PATH "C:/opencv/build/bin" + + - name: Install libturbojpeg (Windows) + shell: pwsh + run: | + $thirdpartydir="$((Get-Item ..\3rdparty).FullName)" + $installer="$thirdpartydir\jpegturbo-installer.exe" + (New-Object System.Net.WebClient).DownloadFile("https://sourceforge.net/projects/libjpeg-turbo/files/2.1.3/libjpeg-turbo-2.1.3-vc64.exe","$installer"); + Start-Process "$installer" -ArgumentList "/S" -Wait + Add-Content $env:GITHUB_PATH "C:/libjpeg-turbo64/bin" + + - name: Install K4A (Windows) + shell: pwsh + run: | + $thirdpartydir="$((Get-Item ..\3rdparty).FullName)" + $installer="$thirdpartydir\k4a-installer.exe" + (New-Object System.Net.WebClient).DownloadFile("https://download.microsoft.com/download/3/d/6/3d6d9e99-a251-4cf3-8c6a-8e108e960b4b/Azure%20Kinect%20SDK%201.4.1.exe","$installer"); + Start-Process "$installer" -ArgumentList "/S" -Wait + Add-Content $env:GITHUB_PATH "C:/Program Files/Azure Kinect SDK v1.4.1/sdk/windows-desktop/amd64/release/bin" + + - name: Install K4ABT (Windows) + shell: pwsh + run: | + $thirdpartydir="$((Get-Item ..\3rdparty).FullName)" + $msifile="$thirdpartydir\k4abt-installer.msi" + (New-Object System.Net.WebClient).DownloadFile("https://download.microsoft.com/download/9/d/b/9dbe0fbe-c9c3-4228-a64c-1e0a08736ec1/Azure%20Kinect%20Body%20Tracking%20SDK%201.1.1.msi","$msifile"); + Start-Process "$msifile" -ArgumentList '/quiet /passive' -Wait + Add-Content $env:GITHUB_PATH "C:/Program Files/Azure Kinect Body Tracking SDK/tools" + - name: Install PCL (Windows) + shell: pwsh + run: | + $thirdpartydir="$((Get-Item ..\3rdparty).FullName)" + $installer="$thirdpartydir/pcl-installer.exe" + (New-Object System.Net.WebClient).DownloadFile("https://github.com/PointCloudLibrary/pcl/releases/download/pcl-1.11.1/PCL-1.11.1-AllInOne-msvc2019-win64.exe","$installer"); + & "$installer" /S + Start-Sleep -s 300 + Add-Content $env:GITHUB_PATH "C:/Program Files/PCL 1.11.1/bin" + Add-Content $env:GITHUB_PATH "C:/Program Files/PCL 1.11.1/3rdparty/VTK/bin" + Add-Content $env:GITHUB_PATH "C:/Program Files/OpenNI2/redist" + - name: Install OpenCV (Windows) + shell: pwsh + run: | + choco install opencv + Add-Content $env:GITHUB_PATH "C:/tools/opencv/build/x64/vc15/bin" + Add-Content $env:GITHUB_ENV "OPENCV_DIR=C:/tools/opencv/build" + - name: Install Python packages (Windows) + shell: bash + run: | + ./scripts/install-3rdparty-win1064.sh + pythonExecutable=`which python` + pythonRoot=`python -c "import sys ; print(sys.prefix)"` + pythonExecutable=`cygpath --windows "$pythonExecutable"` + echo "Python_ROOT_DIR=$pythonRoot" >> $GITHUB_ENV + echo "Python3_EXECUTABLE=$pythonExecutable" >> $GITHUB_ENV + - name: Build & Test + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{ github.workspace }}/build + configure-options: -Wno-dev -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/installed -DPython3_EXECUTABLE=${{ env.Python3_EXECUTABLE }} -DOpenCV_ROOT=${{ env.OPENCV_DIR }} + build-type: Release + run-test: true + install-build: true + - name: upload CTest output in case of failure + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: windows-ctest-output + path: build/Testing/Temporary/LastTest.log + - name: Capture build folder as artifact + if: ${{ failure() }} + shell: bash + run: tar cfz build.tgz build + - name: Upload build folder + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: windows-build-folder + path: build.tgz + - name: Capture installed folder as artifact + shell: bash + run: | + 7z a cwipc_win1064_${{ github.ref_name }}.zip installed/ + - name: Upload installed folder + uses: actions/upload-artifact@v3 + with: + name: cwipc_win1064_${{ github.ref_name }}.zip + path: cwipc_win1064_${{ github.ref_name }}.zip + - name: Check what was created and installed + if: always() + shell: bash + run: | + ls -l /c + ls -l /c/tools + ls -l "/c/Program Files" + ls -l "/c/Program Files (x86)" + ls -l + ls -l .. + + build-macos: + name: build-macos + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + lfs: 'true' + fetch-depth: 0 + - name: Install dependencies + shell: bash + run: ./scripts/install-3rdparty-osx1015.sh + - name: Build & Test + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{ github.workspace }}/build + configure-options: -Wno-dev + run-test: true + install-build: true + install-options: --prefix ${{ github.workspace }}/installed + - name: upload CTest output in case of failure + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: macos-ctest-output + path: build/Testing/Temporary/LastTest.log + - name: Capture build folder as artifact + if: ${{ failure() }} + shell: bash + run: tar cfz build.tgz build + - name: Upload build folder + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: macos-build-folder + path: build.tgz + - name: Capture installed folder as artifact + shell: bash + run: | + tar -c -v -f cwipc_osx1014_${{ github.ref_name }}.tgz -z -C installed . + ls -l + - name: Upload installed folder + uses: actions/upload-artifact@v3 + with: + name: cwipc_osx1014_${{ github.ref_name }}.tgz + path: cwipc_osx1014_${{ github.ref_name }}.tgz + + build-linux: + name: build-linux + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + lfs: 'true' + fetch-depth: 0 + - name: Install dependencies + shell: bash + run: ./scripts/install-3rdparty-ubuntu2004.sh + - name: Build & Test + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{ github.workspace }}/build + configure-options: -Wno-dev + run-test: true + install-build: true + install-options: --prefix ${{ github.workspace }}/installed + - name: upload CTest output in case of failure + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: linux-ctest-output + path: build/Testing/Temporary/LastTest.log + - name: Capture build folder as artifact + if: ${{ failure() }} + shell: bash + run: tar cfz build.tgz build + - name: Upload build folder + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: linux-build-folder + path: build.tgz + - name: Capture installed folder as artifact + shell: bash + run: | + tar -c -v -f cwipc_ubuntu2004_${{ github.ref_name }}.tgz -z -C installed . + ls -l + - name: Upload installed folder + uses: actions/upload-artifact@v3 + with: + name: cwipc_ubuntu2004_${{ github.ref_name }}.tgz + path: cwipc_ubuntu2004_${{ github.ref_name }}.tgz + + create-release: + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + name: create-release + runs-on: ubuntu-latest + needs: + - build-windows + - build-macos + - build-linux + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: 'recursive' + lfs: 'true' + - name: Download Windows installed folder + uses: actions/download-artifact@v3 + with: + name: cwipc_win1064_${{ github.ref_name }}.zip + path: ./ + - name: Download MacOS installed folder + uses: actions/download-artifact@v3 + with: + name: cwipc_osx1014_${{ github.ref_name }}.tgz + path: ./ + - name: Download Linux installed folder + uses: actions/download-artifact@v3 + with: + name: cwipc_ubuntu2004_${{ github.ref_name }}.tgz + path: ./ + - name: Check what is there + shell: bash + run: ls -l + - name: Create Release + uses: actions/create-release@v1 + id: create_release + env: + GITHUB_TOKEN: ${{ github.token }} + with: + draft: true + prerelease: false + release_name: ${{ github.ref }} + tag_name: ${{ github.ref }} + - name: Upload Windows installed folder + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: cwipc_win1064_${{ github.ref_name }}.zip + asset_name: cwipc_win1064_${{ github.ref_name }}.zip + asset_content_type: application/zip + - name: Upload MacOS installed folder + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: cwipc_osx1014_${{ github.ref_name }}.tgz + asset_name: cwipc_osx1014_${{ github.ref_name }}.tgz + asset_content_type: application/gzip + - name: Upload Linux installed folder + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: cwipc_ubuntu2004_${{ github.ref_name }}.tgz + asset_name: cwipc_ubuntu2004_${{ github.ref_name }}.tgz + asset_content_type: application/gzip diff --git a/.gitignore b/.gitignore index f02cf0e..0d895a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ installed -build* +build*/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 609847e..c13841e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: GIT_SUBMODULE_STRATEGY: recursive - GIT_STRATEGY: clone # Only enable this line to fix problems with multiple branches in submodules - + GIT_STRATEGY: clone + GIT_DEPTH: 999 stages: - build - test @@ -15,28 +15,33 @@ build_linux: - ubuntu2004 - vrtogether before_script: + - git fetch --tags + - git describe --match 'v*' - ./scripts/install-3rdparty-ubuntu2004.sh script: + - rm -rf installed - mkdir -p installed/lib - - export LD_LIBRARY_PATH="`pwd`/installed/lib:$LD_LIBRARY_PATH" - instdir=`cd installed ; pwd` + - export LD_LIBRARY_PATH="$instdir/lib:$LD_LIBRARY_PATH" - rm -rf build - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=$instdir - - make - - make test - - make install + - cmake --build . +# There is a problem with Python open3d on the flauwte CI/CD runner. + - ctest -E '(cwipc_tilecolor)|(cwipc_calibrate)' + - cmake --install . - cd .. - tar --directory installed -cvaf cwipc_ubuntu2004_$CI_COMMIT_TAG.tgz . - touch successful.tmp after_script: - - if [ ! -e successful.tmp ]; then cp build/Testing/Temporary/LastTest.log ctest_log_ubuntu2004.log; fi + - if [ ! -e successful.tmp ]; then tar cfz build_folder_ubuntu2004.tgz build; fi + - ./build/venv/bin/pip list artifacts: when: always paths: - cwipc_ubuntu2004_$CI_COMMIT_TAG.tgz - - ctest_log_ubuntu2004.log + - build_folder_ubuntu2004.tgz build_osx: stage: build @@ -46,6 +51,8 @@ build_osx: - osx1015 - vrtogether before_script: + - git fetch --tags + - git describe --match 'v*' - ./scripts/install-3rdparty-osx1015.sh script: - mkdir -p installed/lib @@ -63,6 +70,7 @@ build_osx: - touch successful.tmp after_script: - if [ ! -e successful.tmp ]; then cp build/Testing/Temporary/LastTest.log ctest_log_osx1015.log; fi + - ./build/venv/bin/pip list artifacts: when: always paths: @@ -79,6 +87,8 @@ build_win: variables: OPENGL_IS_BROKEN: "true" # See issue #19 before_script: + - git fetch --tags + - git describe --match 'v*' - ./scripts/install-3rdparty-win1064.sh script: - mkdir -p installed/bin diff --git a/CHANGELOG.md b/CHANGELOG.md index ecb1f88..30176b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- cwipc_get_version() added to API, CWIPC_API_VERSION updated. + ### Changed - (kinect) cameraconfig is now independent of whether we use map\_color\_to\_depth or not - (kinect) implemented function generate_point_cloud_v2 which uses a lookup table to compute the pointcloud. - (kinect) opencv is now used for filtering the depth map: Thresholds + erosion. much faster. - (macos) MacOS 10.15 is now the target platform: 10.14 is no longer easily supported in brew. +- Build process, CMakefiles and versioning have been streamlined. +- Github is now the primary hosting platform and Gitlab is considered a mirror. ### Removed diff --git a/CMakeFiles/GetGitVersion.cmake b/CMakeFiles/GetGitVersion.cmake new file mode 100644 index 0000000..806f9d9 --- /dev/null +++ b/CMakeFiles/GetGitVersion.cmake @@ -0,0 +1,32 @@ +macro(get_git_version) + set(options) + set(oneValueArgs VERSION_VAR) + set(multiValueArgs) + cmake_parse_arguments(MYARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # cwipc-specific: our release tags start with v + execute_process(COMMAND "git" "describe" "--match" "v*" RESULT_VARIABLE status OUTPUT_VARIABLE describe_output OUTPUT_STRIP_TRAILING_WHITESPACE) + if(status AND NOT status EQUAL 0) + message(WARNING "GetGitVersion: git describe failed: ${status}") + set(${MYARGS_VERSION_VAR} "unknown") + return() + endif() + # cwipc-specific: remove the "v" and any "_stable" + string(REPLACE "_stable" "" describe_output ${describe_output}) + string(REPLACE "v" "" describe_output ${describe_output}) + # Now we have either 1.2.3 or 1.2.3-123-sha. Get the version bit + string(REGEX MATCH "[0-9\\.]+" describe_version ${describe_output}) + string(REGEX REPLACE ".*-g([a-fA-F0-9]+)" "\\1" describe_sha ${describe_output}) + # Use unknown if no version tag found + if(NOT describe_version) + set(describe_version "unknown") + endif() + if(describe_sha) + # Append +sha to the version tag + string(CONCAT ${MYARGS_VERSION_VAR} "${describe_version}+${describe_sha}") + else() + # Return just the version tag + set(${MYARGS_VERSION_VAR} ${describe_version}) + endif() + +endmacro() diff --git a/CMakeFiles/SetupCwipcPythonVenv.cmake b/CMakeFiles/SetupCwipcPythonVenv.cmake index 4c4b6d1..aaa4463 100644 --- a/CMakeFiles/SetupCwipcPythonVenv.cmake +++ b/CMakeFiles/SetupCwipcPythonVenv.cmake @@ -6,10 +6,10 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter) if(NOT VENV_DIR) # # Create venv for testing, and re-set Python3_EXECUTABLE to that Python. - # But: enable use of system-installed packages, because otherwise CI/CD will take forever. + # We disable use of system-installed packages, because otherwise the testing of the scripts will fail. # get_filename_component(VENV_DIR "${CMAKE_BINARY_DIR}/venv" ABSOLUTE) - execute_process(COMMAND ${Python3_EXECUTABLE} -m venv --system-site-packages "${VENV_DIR}") + execute_process(COMMAND ${Python3_EXECUTABLE} -m venv "${VENV_DIR}") set(ENV{VIRTUAL_ENV} "${VENV_DIR}") if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(Python3_SYSTEM_EXECUTABLE ${Python3_EXECUTABLE}) @@ -20,7 +20,7 @@ if(NOT VENV_DIR) set(Python3_BINDIR "${VENV_DIR}/bin") set(Python3_EXECUTABLE "${Python3_BINDIR}/python") endif() - execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install build) + execute_process(COMMAND ${Python3_EXECUTABLE} -m pip --quiet install --upgrade pip setuptools build wheel) message(STATUS "Created Python venv in ${VENV_DIR}") endif() @@ -84,6 +84,6 @@ macro(cwipc_install_wheel) cmake_parse_arguments(MYARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) # The /.. in the DESTINATION is a trick to forestall double /python/python install(DIRECTORY ${MYARGS_WHEELDIR} DESTINATION ${CMAKE_PYWHEELS_INSTALL_DIRECTORY}/.. FILES_MATCHING PATTERN "${MYARGS_NAME}*.whl" ) - install(CODE "execute_process(COMMAND \"${Python3_SYSTEM_EXECUTABLE}\" -m pip uninstall --yes ${MYARGS_NAME} WORKING_DIRECTORY \"${MYARGS_WHEELDIR}\" )") - install(CODE "execute_process(COMMAND \"${Python3_SYSTEM_EXECUTABLE}\" -m pip install --find-links=. ${MYARGS_NAME} WORKING_DIRECTORY \"${MYARGS_WHEELDIR}\" )") + install(CODE "execute_process(COMMAND \"${Python3_SYSTEM_EXECUTABLE}\" -m pip --quiet uninstall --yes ${MYARGS_NAME} WORKING_DIRECTORY \"${MYARGS_WHEELDIR}\" )") + install(CODE "execute_process(COMMAND \"${Python3_SYSTEM_EXECUTABLE}\" -m pip --quiet install --find-links=. ${MYARGS_NAME} WORKING_DIRECTORY \"${MYARGS_WHEELDIR}\" )") endmacro() diff --git a/CMakeLists.txt b/CMakeLists.txt index 6442ada..01c104f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,24 +17,27 @@ set(CMAKE_MODULE_PATH ) # Ensure all executable, dll/so and link-library outputs end up in the same directories -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_PYWHEELS_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/share/cwipc/python) set(CMAKE_PYWHEELS_INSTALL_DIRECTORY ${CMAKE_INSTALL_DATADIR}/cwipc/python) set(CMAKE_TESTDATA_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/share/cwipc/tests) set(CMAKE_TESTDATA_INSTALL_DIRECTORY ${CMAKE_INSTALL_DATADIR}/cwipc/tests) - +set(CMAKE_SCRIPTS_INSTALL_DIRECTORY ${CMAKE_INSTALL_DATADIR}/cwipc) + +# Get version from git +include(GetGitVersion) +get_git_version(VERSION_VAR CWIPC_VERSION) +if(CWIPC_VERSION) + message(STATUS "CWIPC_VERSION=${CWIPC_VERSION}") + add_compile_definitions(CWIPC_VERSION=${CWIPC_VERSION}) + set(ENV{CWIPC_VERSION} ${CWIPC_VERSION}) +endif() # # Packages required by all submodules # -# see here: https://github.com/PointCloudLibrary/pcl/issues/3680 -# when this is fixed, we can remove the following 3 lines. -#if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS) -# set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings") -#endif() - find_package(libjpeg-turbo REQUIRED) find_package(PCL 1.10 REQUIRED COMPONENTS common io octree filters features) find_package(Python3 REQUIRED COMPONENTS Interpreter) @@ -53,3 +56,6 @@ endif() if(k4a_FOUND) add_subdirectory("cwipc_kinect") endif() + +# Install scripts to help installing prerequisites +install(DIRECTORY scripts DESTINATION ${CMAKE_SCRIPTS_INSTALL_DIRECTORY}) \ No newline at end of file diff --git a/cwipc_codec b/cwipc_codec index 8edea09..91e95c8 160000 --- a/cwipc_codec +++ b/cwipc_codec @@ -1 +1 @@ -Subproject commit 8edea09dd7d66a016664c1a6e7d087b612ed761f +Subproject commit 91e95c8e5be295d0b80f8ed784378e6a5c7299ce diff --git a/cwipc_kinect b/cwipc_kinect index adbbdd3..ebdcd82 160000 --- a/cwipc_kinect +++ b/cwipc_kinect @@ -1 +1 @@ -Subproject commit adbbdd3a9a8f0df2f9994363412954b18f644551 +Subproject commit ebdcd82a7a424b46f1472fb1719f8c767ee32be8 diff --git a/cwipc_realsense2 b/cwipc_realsense2 index 113d909..1da5d23 160000 --- a/cwipc_realsense2 +++ b/cwipc_realsense2 @@ -1 +1 @@ -Subproject commit 113d9090e07eb8b4d8fc35471440cad73635ad5b +Subproject commit 1da5d23f2f64ebc56be575ebb6453ea4bd9698b0 diff --git a/cwipc_util b/cwipc_util index 4a84b7e..6f02c03 160000 --- a/cwipc_util +++ b/cwipc_util @@ -1 +1 @@ -Subproject commit 4a84b7e5ce8d011c946aa1a3fdfb30c8e20a187a +Subproject commit 6f02c0314eaaaec659bc12a7916917dcfcb63abc diff --git a/readme.md b/readme.md index ea9ff41..8f5b903 100644 --- a/readme.md +++ b/readme.md @@ -13,6 +13,72 @@ The suite also contains modules `cwipc_kinect` and `cwipc_realsense2` that which For now, refer to . +Documentation on the API can be created using _Doxygen_ in `cwipc_util/doc`, and will be made available here at some point in the future. + +## Installing third party requirements + +Building requires `cmake`, `python3`, `libpcl`, `glfw3`, `jpeg-turbo` and optionally (for Intel Realsense support) `librealsense` and/or (for Azure Kinect support) `Azure Kinect SDK`, `Azure Kinect Body Tracking SDK` and `OpenCV`. + +Running prebuilt binaries needs most of those requirements are well. + +### Linux + +There is a script `scripts/install-thirdparty-ubuntu2004.sh` that installs all requirements on Ubuntu 20.04. For other Linux variants please inspect this script and ensure the correct packages are installed. + +### MacOS + +There is a script `scripts/install-thirdparty-osx1015.sh` that installs all requirements on MacOS 10.15 or later. This script requires [HomeBrew](https://brew.sh) and the XCode Command Line Tools. Installing HomeBrew will help you install the command line tools. + +Building and installing natively on Apple Silicon (M1 machines) might work and might not work. A workaround is to install HomeBrew for Intel (which can be installed alongside HomeBrew for M1, because they use different locations) and ensure that `/usr/local/bin` is in your `$PATH` before `/opt/homebrew/bin`. Then everything is built for Intel and Rosetta. + +### Windows + +There are two things you always need to install (independent of whether you want to use a binary installer or build from source): + +- `git` and `bash`, from . +- Python, from . 3.9 is preferred, as of this writing (April 2022) python 3.10 does not work because some required packages are not available for 3.10 yet. + - Note: you should install Python *"For All Users"*. + - Note: You should install into a writeable directory, such as `C:/Python39` otherwise you will have to use _Run as Administrator_ for various build steps. + +If you want to build from source you first need to install some developer resources: + +- Visual Studio. Community Edition 2019 is known to work. +- CMake, from . + +Next, you need to install the third-party libraries and tools mentioned above. + +- Run the script `scripts/install-3rdparty-full-win1064.ps1` in a PowerShell **with Administrator rights**. Note the bold font. + +Finally, you need to ensure that all DLLs from the packages installed above or on the environment `%PATH%` variable: + +- Open the `install-3rdparty-full-win1064.ps1` script in a text editor, and inspect the comments that state what should be added to path. +- Open `Control Panel` -> `System Properties` -> `Environment Variables` -> `System Variables` -> `Path`. +- Check that each of the folders mentioned in the script exist (otherwise something went wrong during the installation step). +- Add each folder to the `Path`. +- Press `OK` to close the dialogs. +- Close all command prompt windows, bash windows and powershell windows and re-open them. + +If you don't follow these steps you will later get obscure errors. Windows will tell you that (for example) `"The cwipc_realsense2 DLL could not be found"`, and you see it right in front of you. The _actual_ problem is going to be with one of the dependency DLLs (but it would be far to helpful if Windows told you this:-), and the problem invariably is that something has not been added to `Path`. + +For the rest of the build instructions it is probably best to use `bash`, not `CMD` or powershell. + +## Installing a binary distribution + +Prebuilt binary releases are available at as zip or gzipped tar files. Download the correct one for you platform. On MacOS and Linux you can extract straight into `/usr/local` or any other location of your liking. On Windows you create an empty folder such as `C:/cwipc` and extract there. + +On Windows, add `c:/cwipc/bin` to your `%PATH%` environment variable (and restart your command prompt). + +Run `cwipc_pymodules_install.sh` to install the Python components. (On windows you can use this script when you are using bash, or you can run `cwipc_pymodules_install.bat` if you are using CMD). + +Check that everything is installed correctly by running + +``` +cwipc_view --synthetic +``` + +This should bring up a viewer window with a synthetic point cloud. Use left-mouse-drag, right-mouse-drag and scroll wheel to change your view position. + + ## Build instructions Check out the source repository from and ensure you also check out the submodules and the git-lfs files. Use either @@ -29,9 +95,7 @@ or git clone --recurse-submodules https://github.com/cwi-dis/cwipc.git ``` -Now you need to ensure that you have the required third party software installed (and, for Windows, that you have installed it in the expected location), see below. - -Finally you build by using one of the build scripts: +Now you build by using one of the build scripts: - Linux: @@ -58,32 +122,8 @@ Finally you build by using one of the build scripts: ``` This will build everything, do a limited self-test and install into `./installed`. -Both these scripts configures, builds, tests and installs each of the submodules individually (in `build` directories under the submodule directory). If you need to tweak the build procedure, for example by adding `cmake` flags, you can use `rm -rf cwipc_*/build` to do a complete clean build. - -The build scripts build the submodules in the correct order (`cwipc_util` first) and stop on error. - -## Required third party software - -On all platforms we require the standard development tools for the platform (XCode and the xcode command line tools on MacOS, Visual Studio 2019 on Windows, standard gcc tools on Linux). - -On Linux the preferred way to install the third party software is through _apt_ or whatever package manager your platform supports. Our build process should then automatically pick everything up. +Both these scripts configures, builds, tests and installs each of the submodules individually (in `build` directories under the submodule directory). If you need to tweak the build procedure, for example by adding `cmake` flags, you can use `rm -rf build` to do a complete clean build. -On MacOS the preferred way to install the third party software is through _Homebrew_ . Our build process should then automatically pick everything up. The Python dependency deserves special note on MacOS, due to the many variants of Python available. If you ensure the `python3` command refers to the brew-installed Python 3.8 everything should go well. When building on an M1 Mac you should use the (Rosetta-based) Intel version of _Homebrew_, the one that installs into `/usr/local`, not into `/opt/homebrew`. Both versions can co-exist, ensure you have the Intel one in your path first when you build. - -On Windows you have to install each package individually according to the instructions coming with the package. You need to ensure any "developer" option is installed. You also need to ensure that the folders with the DLLs and utilties for each package are on the `PATH` environment variable. For some packages you must install them in a specific place, or using specific settings. - -Packages required: - -- _cmake_. -- _python 3_. Python 3.9 is preferred (3.7 or later may work). - - On Windows you should install _"For All Users"_ and install into a writeable directory (such as `C:\Python37`). - - Some needed packages such as _Open3D_ can be slow to follow Python releases, if you experience problems try installing a previous Python release. - - On the Mac it is easy to install multiple Python versions with `brew`. Put the relevant `/usr/local/opt/python@3.9/bin` first in your `$PATH` and things should build fine. -- PCL . 1.12 is preferred, but 1.9 or later may work. For Linux apt the package is called `libpcl-dev`. For MacOS brew you need to `brew install pcl glfw3`. On Windows you need to ensure the DLL directories for PCL subpackages _OpenNI_ and _VTK_ are also on your `PATH`. -- _jpeg-turbo_ . On Mac you must force-link it if it conflicts with the normal `jpeg` brew package. -- _Intel Realsense SDK 2.0_ . 2.41 is known to work. 2.50 currently has issues on MacOS. -- _Azure Kinect SDK_ . 1.4.1 is known to work. Not available on Mac -- _Azure Kinect Body Tracking SDK_. 1.0.1 and 1.1.0 should work. Not available on Mac. ## Debugging @@ -113,12 +153,13 @@ When creating a new release, ensure the following have been done - `CWIPC_API_VERSION_OLD` incremented if there are API changes that are not backward compatible. - Both these need to be changed in `api.h` and `cwipc/util.py`. - `CHANGELOG.md` updated. -- Version numbers in `cwipc_*/python/setup.py` updated. -After making all these changes push to gitlab. Ensure the CI/CD build passes. +Version numbers for the release no longer need to be updated manually, they are generated from the git tag name. + +After making all these changes push to github. Ensure the CI/CD build passes. -After that tag all submodules and the main module with *v_X_._Y_._Z_\_stable*. +After that tag all submodules and the main module with *v_X_._Y_._Z_*. -Push the tag to gitlab, this will build the release. +Push the tag to github, this will build the release. After the release is built copy the relevant new section of `CHANGELOG.md` to the release notes. \ No newline at end of file diff --git a/sandbox/getgitversion.sh b/sandbox/getgitversion.sh new file mode 100755 index 0000000..ccaa9fb --- /dev/null +++ b/sandbox/getgitversion.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Get the current commit SHA +CURRENT_COMMIT=$(git rev-parse --short HEAD) +# Get the most recent tagged commit SHA +TAG_COMMIT=$(git rev-list --abbrev-commit --tags --max-count=1) +# Get the tag of that commit +TAG=$(git describe --abbrev=0 --tags $TAG_COMMIT) +# Remove a leading v and trailing _stable +TAG=${TAG/#v/} +TAG=${TAG/%_stable/} +# Construct version and version components +VERSION_COMMIT="" +VERSION_MAJOR=0 +VERSION_MINOR=0 +VERSION_MICRO=0 +# Start with constructing the version +if [[ "$TAG" == "" ]] ; then + # No tag found, use the current commit only + VERSION="0.0.0+${CURRENT_COMMIT}" + VERSION_COMMIT="+${CURRENT_COMMIT}" +else + if [[ "$TAG_COMMIT" == "CURRENT_COMMIT" ]] ; then + # Tag found, and we are exactly there + VERSION="${TAG}" + else + VERSION="${TAG}+${CURRENT_COMMIT}" + VERSION_COMMIT="+${CURRENT_COMMIT}" + fi +fi +if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)\. ]]; then + VERSION_MAJOR=${BASH_REMATCH[1]} + VERSION_MINOR=${BASH_REMATCH[2]} + VERSION_MICRO=${BASH_REMATCH[3]} +else + if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\. ]]; then + VERSION_MAJOR=${BASH_REMATCH[1]} + VERSION_MINOR=${BASH_REMATCH[2]} + fi +fi +echo VERSION=${VERSION} +echo VERSION_MAJOR=${VERSION_MAJOR} +echo VERSION_MINOR=${VERSION_MINOR} +echo VERSION_MICRO=${VERSION_MICRO} +echo VERSION_COMMIT=${VERSION_COMMIT} diff --git a/sandbox/touched b/sandbox/touched index e69de29..ce01362 100644 --- a/sandbox/touched +++ b/sandbox/touched @@ -0,0 +1 @@ +hello diff --git a/scripts/buildall-win.sh b/scripts/buildall-win.sh index e44c8b2..6cda80f 100755 --- a/scripts/buildall-win.sh +++ b/scripts/buildall-win.sh @@ -5,8 +5,9 @@ errorexit() { echo '** Error: your buildall-win did not succeed. Check error log above.' exit 1 } +# Alternative: config=RelWithDebInfo. # Alternative: config=Release. But having the .PDB files is good for debugging. -config=RelWithDebInfo +config=Release trap errorexit ERR dirname=`dirname $0` dirname=`cd $dirname/..; pwd` @@ -38,11 +39,10 @@ if nproc 2>&1 >/dev/null; then fi mkdir -p build -cd build -cmake .. -DCMAKE_INSTALL_PREFIX="$instdir" -DJPEG_Turbo_ROOT="C:/libjpeg-turbo64" -DOpenCV_ROOT="C:/OpenCV-4.5.5/build" -cmake --build . --config $config +cmake -S . -B build -DCMAKE_INSTALL_PREFIX="$instdir" +cmake --build build --config $config if [ "$notest" != "notest" ]; then - cmake --build . --config $config --target RUN_TESTS + ctest --test-dir build --build-config $config fi -cmake --build . --config $config --target INSTALL +cmake --install build --config $config diff --git a/scripts/install-3rdparty-full-win1064.ps1 b/scripts/install-3rdparty-full-win1064.ps1 new file mode 100644 index 0000000..bca3697 --- /dev/null +++ b/scripts/install-3rdparty-full-win1064.ps1 @@ -0,0 +1,37 @@ +# Install required third party packages. +# Probably incomplete. +# xxxjack Need to add entries to PATH environment +# +mkdir tmpinstall +cd tmpinstall + +# Install libjpeg-turbo +(New-Object System.Net.WebClient).DownloadFile("https://sourceforge.net/projects/libjpeg-turbo/files/2.1.3/libjpeg-turbo-2.1.3-vc64.exe","libjpeg-turbo-2.1.3-vc64.exe"); +Start-Process -FilePath '.\libjpeg-turbo-2.1.3-vc64.exe' -ArgumentList "/S" -Wait +# xxxjack add to path: C:\libjpeg-turbo64\bin + +# Install PCL 1.11. At the moment 1.12 has issues on some CI/CD machines. +(New-Object System.Net.WebClient).DownloadFile("https://github.com/PointCloudLibrary/pcl/releases/download/pcl-1.11.1/PCL-1.11.1-AllInOne-msvc2019-win64.exe","PCL-1.11.1-AllInOne-msvc2019-win64.exe"); +Start-Process -FilePath .\PCL-1.11.1-AllInOne-msvc2019-win64.exe -ArgumentList "/S" -Wait +# xxxjack add to path: C:\Program Files\PCL 1.11.1\bin +# xxxjack add to path: C:\Program Files\PCL 1.11.1\3rdParty\VTK\bin +# xxxjack add to path: C:\Program Files\OpenNI2\Redist + +# Install Realsense SDK. Cannot get the installer to run unattended, so use chocolatey. +choco install -y realsense-sdk2 + +# xxxjack add to path: C:\Program Files (x86)\Intel RealSense SDK 2.0\bin\x64 +# Install Kinect SDK +(New-Object System.Net.WebClient).DownloadFile("https://download.microsoft.com/download/3/d/6/3d6d9e99-a251-4cf3-8c6a-8e108e960b4b/Azure%20Kinect%20SDK%201.4.1.exe","Azure Kinect SDK 1.4.1.exe"); +Start-Process -FilePath '.\Azure Kinect SDK 1.4.1.exe' -ArgumentList "/S" -Wait +# xxxjack add to path: C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\bin + +# Install Kinect Body Tracking SDK +(New-Object System.Net.WebClient).DownloadFile("https://download.microsoft.com/download/9/d/b/9dbe0fbe-c9c3-4228-a64c-1e0a08736ec1/Azure%20Kinect%20Body%20Tracking%20SDK%201.1.1.msi","Azure Kinect Body Tracking SDK 1.1.1.msi"); +Start-Process '.\Azure Kinect Body Tracking SDK 1.1.1.msi' -ArgumentList '/quiet /passive' -Wait +# xxxjack add to path: C:\Program Files\Azure Kinect Body Tracking SDK\tools + +# Install OpenCV +(New-Object System.Net.WebClient).DownloadFile("https://github.com/opencv/opencv/releases/download/4.5.5/opencv-4.5.5-vc14_vc15.exe","opencv-4.5.5-vc14_vc15.exe"); +Start-Process '.\opencv-4.5.5-vc14_vc15.exe' -ArgumentList '-o"C:\" -y' -Wait +# xxxjack add to path: C:\opencv\build\bin diff --git a/scripts/install-3rdparty-osx1015.sh b/scripts/install-3rdparty-osx1015.sh index 41e82d9..1d75257 100755 --- a/scripts/install-3rdparty-osx1015.sh +++ b/scripts/install-3rdparty-osx1015.sh @@ -11,7 +11,7 @@ brew unlink jpeg brew link --force jpeg-turbo # Install Python delendencies -python3 -m pip install --upgrade pip setuptools build +python3 -m pip install --upgrade pip setuptools build wheel # Install Python dependencies for Depolyment scripts (unsure they are still needed) python3 -m pip install requests requests_toolbelt mechanize pillow numpy open3d diff --git a/scripts/install-3rdparty-ubuntu2004.sh b/scripts/install-3rdparty-ubuntu2004.sh index bee085b..6060fcb 100755 --- a/scripts/install-3rdparty-ubuntu2004.sh +++ b/scripts/install-3rdparty-ubuntu2004.sh @@ -25,10 +25,7 @@ sudo apt-get install -y libsoundio1 # # Upgrade essential Python packages that are too old on Ubuntu 20.04 # -sudo pip install --upgrade pip -sudo pip install --upgrade setuptools -sudo pip install --upgrade build -sudo pip install --upgrade pillow +sudo pip install --upgrade pip setuptools build wheel pillow # # Install k4a SDK from their repository. # Bit of a hack, see https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/1263 diff --git a/scripts/install-3rdparty-win1064.sh b/scripts/install-3rdparty-win1064.sh index facf989..d3fb1e8 100644 --- a/scripts/install-3rdparty-win1064.sh +++ b/scripts/install-3rdparty-win1064.sh @@ -1,5 +1 @@ -pip install --upgrade pip -pip install --upgrade setuptools -pip install --upgrade build -pip install --upgrade pillow -pip install --upgrade open3d +pip install --upgrade pip setuptools build wheel