From c71b55b63e85346c6952f9885b6891d83cfcb8bb Mon Sep 17 00:00:00 2001 From: Gines Hidalgo Date: Sat, 4 Apr 2020 14:53:50 -0400 Subject: [PATCH] Proper fix for #1439 and cleaned accepted PRs --- doc/installation_jetson_tx2_jetpack3.3.md | 12 ++++++++---- examples/tests/resizeTest.cpp | 2 +- include/openpose/utilities/openCv.hpp | 5 +++++ scripts/ubuntu/install_cuda.sh | 12 ++++++++---- src/openpose/utilities/openCv.cpp | 13 +++++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/doc/installation_jetson_tx2_jetpack3.3.md b/doc/installation_jetson_tx2_jetpack3.3.md index aac59cee..33973515 100644 --- a/doc/installation_jetson_tx2_jetpack3.3.md +++ b/doc/installation_jetson_tx2_jetpack3.3.md @@ -29,15 +29,17 @@ Notes: ## Installation -1. Use the following script for installation of both caffe and OpenPose: +Use the following script for installation of both caffe and OpenPose: ``` bash ./scripts/ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.3.sh ``` -2. If you do not want to build the Python libraries, the installation is finished. Otherwise, edit the BUILD_PYTHON flag on CMakeLists.txt: + +Optional: If you want to build the Python libraries, then: +1. Edit the `BUILD_PYTHON` flag on `CMakeLists.txt`: ```option(BUILD_PYTHON "Build OpenPose python." ON)``` -and, in both places where this appears, set the flag to ON: +2. In both places where this appears, set the flag to ON: ``` -DBUILD_python=ON -DBUILD_python_layer=ON @@ -48,12 +50,14 @@ and, in both places where this appears, set the flag to ON: ```cmake -DBUILD_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python2.7 -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/libpython2.7.so ..``` 4. Now run `make`. You should see a file called "pyopenpose.so" if Python was set to 2.7, in -/home/nvidia/openpose/build/python/openpose. Otherwise, it will be "pyopenpose.cpython-35m-aarch64-linux-gnu" +`/home/nvidia/openpose/build/python/openpose`. Otherwise, it will be `pyopenpose.cpython-35m-aarch64-linux-gnu`. 5. Finally, run `sudo make install` inside build to copy the files to /usr/local/python and set PYTHONPATH accordingly on .bashrc: ```export PYTHONPATH="${PYTHONPATH}:/usr/local/python``` + + ## Usage It is for now recommended to use an external camera with the demo. To get to decent FPS you need to lower the net resolution: ``` diff --git a/examples/tests/resizeTest.cpp b/examples/tests/resizeTest.cpp index d6fc76b8..06652e47 100644 --- a/examples/tests/resizeTest.cpp +++ b/examples/tests/resizeTest.cpp @@ -79,7 +79,7 @@ try { // logging_level - op::Matrix opImg = op::loadImage(FLAGS_image_path, CV_LOAD_IMAGE_GRAYSCALE); + op::Matrix opImg = op::loadImage(FLAGS_image_path, getCvLoadImageGrayScale()); cv::Mat img = OP_OP2CVMAT(opImg); if(img.empty()) op::error("Could not open or find the image: " + FLAGS_image_path, __LINE__, __FUNCTION__, __FILE__); diff --git a/include/openpose/utilities/openCv.hpp b/include/openpose/utilities/openCv.hpp index b926929d..9c70364e 100644 --- a/include/openpose/utilities/openCv.hpp +++ b/include/openpose/utilities/openCv.hpp @@ -60,6 +60,11 @@ namespace op * Wrapper of CV_LOAD_IMAGE_ANYDEPTH to avoid leaving OpenCV dependencies on headers. */ OP_API int getCvLoadImageAnydepth(); + + /** + * Wrapper of CV_LOAD_IMAGE_GRAYSCALE to avoid leaving OpenCV dependencies on headers. + */ + OP_API int getCvLoadImageGrayScale(); } #endif // OPENPOSE_UTILITIES_OPEN_CV_HPP diff --git a/scripts/ubuntu/install_cuda.sh b/scripts/ubuntu/install_cuda.sh index e1ad5f0b..e12b0b64 100755 --- a/scripts/ubuntu/install_cuda.sh +++ b/scripts/ubuntu/install_cuda.sh @@ -1,6 +1,7 @@ #!/bin/bash -echo "NOTE: This script assumes Ubuntu 16 or 14 and Nvidia Graphics card up to 10XX. Otherwise, install it by yourself or it will fail." +echo "NOTE: This script assumes Ubuntu 18 (Nvidia Graphics card >= 10XX), 16 (card up to 10XX), or 14 (card up to 10XX)." +echo "Otherwise, install it by yourself or it might fail." # Install CUDA 8.0 ubuntu_version="$(lsb_release -r)" @@ -8,11 +9,16 @@ sudo apt-get update && sudo apt-get install wget -y --no-install-recommends if [[ $ubuntu_version == *"14."* ]]; then wget -c "https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb" sudo dpkg --install cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb + sudo apt-get update + sudo apt-get install cuda-8-0 elif [[ $ubuntu_version == *"16."* ]]; then wget -c "https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb" sudo dpkg --install cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb + sudo apt-get update + sudo apt-get install cuda-8-0 +# Install CUDA 10.0 elif [[ $ubuntu_version == *"18."* ]]; then - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin + wget -c "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin" sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb @@ -20,6 +26,4 @@ elif [[ $ubuntu_version == *"18."* ]]; then sudo apt-get update sudo apt-get -y install cuda fi -sudo apt-get update -sudo apt-get install cuda-8-0 # sudo apt-get install cuda diff --git a/src/openpose/utilities/openCv.cpp b/src/openpose/utilities/openCv.cpp index b6fe86c6..bd1141e7 100644 --- a/src/openpose/utilities/openCv.cpp +++ b/src/openpose/utilities/openCv.cpp @@ -372,4 +372,17 @@ namespace op return -1; } } + + int getCvLoadImageGrayScale() + { + try + { + return CV_LOAD_IMAGE_GRAYSCALE; + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + return -1; + } + } } -- GitLab