CMU-Perceptual-Computing-Lab / openpose

OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation
https://cmu-perceptual-computing-lab.github.io/openpose
Other
30.99k stars 7.84k forks source link

Jetson install error during openpose compile #1124

Closed dreinsdo closed 5 years ago

dreinsdo commented 5 years ago

Issue Summary

I am on a Jetson TX1. I know this is not officially supported, however I am hoping someone can provide some insight. I am getting an error "'.build_release/examples/tests/clTest.bin' failed make".

I am on system config and what I've done:

I encounter this error when building openpose, cafffe builds without issues. Output:

OpenPose Output

CXX/LD -o .build_release/examples/tests/resizeTest.bin /usr/bin/ld: warning: libopencv_core.so.2.4, needed by 3rdparty/caffe/distribute/lib/libcaffe.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libopencv_highgui.so.2.4, needed by 3rdparty/caffe/distribute/lib/libcaffe.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libopencv_imgproc.so.2.4, needed by 3rdparty/caffe/distribute/lib/libcaffe.so, not found (try using -rpath or -rpath-link) .build_release/lib/libopenpose.so: undefined reference to cv::write(cv::FileStorage&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&)' .build_release/lib/libopenpose.so: undefined reference tocv::imshow(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&)' .buildrelease/lib/libopenpose.so: undefined reference to `cv::circle(cv::Mat&, cv::Point, int, cv::Scalar_ const&, int, int, int)' .build_release/lib/libopenpose.so: undefined reference to cv::FileStorage::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' .build_release/lib/libopenpose.so: undefined reference tocv::_OutputArray::_OutputArray(cv::Mat&)' .build_release/lib/libopenpose.so: undefined reference to cv::VideoWriter::VideoWriter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double, cv::Size_<int>, bool)' .build_release/lib/libopenpose.so: undefined reference tocv::drawChessboardCorners(cv::OutputArray const&, cv::Size, cv::_InputArray const&, bool)' .build_release/lib/libopenpose.so: undefined reference to cv::Exception::Exception(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' .build_release/lib/libopenpose.so: undefined reference tocv::FileStorage::FileStorage(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)' .build_release/lib/libopenpose.so: undefined reference tocv::operator<<(cv::FileStorage&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::_InputArray::_InputArray(cv::Mat const&)' .build_release/lib/libopenpose.so: undefined reference tocv::VideoCapture::VideoCapture(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::VideoCapture::get(int)' .build_release/lib/libopenpose.so: undefined reference tocv::CascadeClassifier::load(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::cornerSubPix(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, cv::Size_<int>, cv::TermCriteria)' .build_release/lib/libopenpose.so: undefined reference tovtable for cv::_OutputArray' 3rdparty/caffe/distribute/lib/libcaffe.so: undefined reference to `cv::imencode(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator >&, std::vector<int, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::_InputArray::_InputArray(double const&)' .build_release/lib/libopenpose.so: undefined reference tovtable for cv::_InputArray' .build_release/lib/libopenpose.so: undefined reference to cv::resizeWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int)' .build_release/lib/libopenpose.so: undefined reference tocv::Ptr::delete_obj()' .build_release/lib/libopenpose.so: undefined reference to cv::_InputArray::_InputArray(std::vector<cv::Mat, std::allocator<cv::Mat> > const&)' .build_release/lib/libopenpose.so: undefined reference tocv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::Rect, std::allocator<cv::Rect > >&, double, int, int, cv::Size, cv::Size)' .build_release/lib/libopenpose.so: undefined reference to cv::putText(cv::Mat&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)' .build_release/lib/libopenpose.so: undefined reference tocv::calcOpticalFlowPyrLK(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::OutputArray const&, cv::Size, int, cv::TermCriteria, int, double)' .build_release/lib/libopenpose.so: undefined reference to cv::Ptr<CvVideoWriter>::delete_obj()' .build_release/lib/libopenpose.so: undefined reference tocv::_OutputArray::_OutputArray(std::vector<cv::Mat, std::allocator >&)' .buildrelease/lib/libopenpose.so: undefined reference to `cv::line(cv::Mat&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' .build_release/lib/libopenpose.so: undefined reference to cv::getTextSize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double, int, int*)' .build_release/lib/libopenpose.so: undefined reference tocv::setWindowProperty(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, double)' .build_release/lib/libopenpose.so: undefined reference to cv::Formatter::get(char const*)' .build_release/lib/libopenpose.so: undefined reference tocv::namedWindow(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)' .build_release/lib/libopenpose.so: undefined reference to cv::calibrateCamera(cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::TermCriteria)' .build_release/lib/libopenpose.so: undefined reference tocv::imread(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)' collect2: error: ld returned 1 exit status Makefile:492: recipe for target '.build_release/examples/tests/resizeTest.bin' failed make: [.build_release/examples/tests/resizeTest.bin] Error 1 make: Waiting for unfinished jobs.... /usr/bin/ld: warning: libopencv_core.so.2.4, needed by 3rdparty/caffe/distribute/lib/libcaffe.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libopencv_highgui.so.2.4, needed by 3rdparty/caffe/distribute/lib/libcaffe.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libopencv_imgproc.so.2.4, needed by 3rdparty/caffe/distribute/lib/libcaffe.so, not found (try using -rpath or -rpath-link) .build_release/lib/libopenpose.so: undefined reference to `cv::write(cv::FileStorage&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::Mat const&)' .build_release/lib/libopenpose.so: undefined reference to cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)' .build_release/lib/libopenpose.so: undefined reference tocv::circle(cv::Mat&, cv::Point, int, cv::Scalar const&, int, int, int)' .build_release/lib/libopenpose.so: undefined reference to cv::FileStorage::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' .build_release/lib/libopenpose.so: undefined reference tocv::_OutputArray::_OutputArray(cv::Mat&)' .build_release/lib/libopenpose.so: undefined reference to cv::VideoWriter::VideoWriter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double, cv::Size_<int>, bool)' .build_release/lib/libopenpose.so: undefined reference tocv::drawChessboardCorners(cv::OutputArray const&, cv::Size, cv::_InputArray const&, bool)' .build_release/lib/libopenpose.so: undefined reference to cv::Exception::Exception(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' .build_release/lib/libopenpose.so: undefined reference tocv::FileStorage::FileStorage(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)' .build_release/lib/libopenpose.so: undefined reference tocv::operator<<(cv::FileStorage&, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::_InputArray::_InputArray(cv::Mat const&)' .build_release/lib/libopenpose.so: undefined reference tocv::VideoCapture::VideoCapture(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::VideoCapture::get(int)' .build_release/lib/libopenpose.so: undefined reference tocv::CascadeClassifier::load(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&)' .build_release/lib/libopenpose.so: undefined reference to cv::cornerSubPix(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, cv::Size_<int>, cv::TermCriteria)' .build_release/lib/libopenpose.so: undefined reference tovtable for cv::_OutputArray' 3rdparty/caffe/distribute/lib/libcaffe.so: undefined reference to cv::imencode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)' .build_release/lib/libopenpose.so: undefined reference tocv::_InputArray::_InputArray(double const&)' .build_release/lib/libopenpose.so: undefined reference to vtable for cv::_InputArray' .build_release/lib/libopenpose.so: undefined reference tocv::resizeWindow(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, int)' .build_release/lib/libopenpose.so: undefined reference to cv::Ptr<CvCapture>::delete_obj()' .build_release/lib/libopenpose.so: undefined reference tocv::_InputArray::_InputArray(std::vector<cv::Mat, std::allocator > const&)' .buildrelease/lib/libopenpose.so: undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::Rect, std::allocator<cv::Rect > >&, double, int, int, cv::Size, cv::Size_)' .build_release/lib/libopenpose.so: undefined reference to cv::putText(cv::Mat&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)' .build_release/lib/libopenpose.so: undefined reference tocv::calcOpticalFlowPyrLK(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::OutputArray const&, cv::Size, int, cv::TermCriteria, int, double)' .build_release/lib/libopenpose.so: undefined reference to cv::Ptr<CvVideoWriter>::delete_obj()' .build_release/lib/libopenpose.so: undefined reference tocv::_OutputArray::_OutputArray(std::vector<cv::Mat, std::allocator >&)' .buildrelease/lib/libopenpose.so: undefined reference to `cv::line(cv::Mat&, cv::Point, cv::Point, cv::Scalar const&, int, int, int)' .build_release/lib/libopenpose.so: undefined reference to cv::getTextSize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double, int, int*)' .build_release/lib/libopenpose.so: undefined reference tocv::setWindowProperty(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int, double)' .build_release/lib/libopenpose.so: undefined reference to cv::Formatter::get(char const*)' .build_release/lib/libopenpose.so: undefined reference tocv::namedWindow(std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)' .build_release/lib/libopenpose.so: undefined reference to cv::calibrateCamera(cv::_InputArray const&, cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::TermCriteria)' .build_release/lib/libopenpose.so: undefined reference tocv::imread(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)' collect2: error: ld returned 1 exit status Makefile:492: recipe for target '.build_release/examples/tests/clTest.bin' failed make: *** [.build_release/examples/tests/clTest.bin] Error 1


Errors detected. Exiting script. The software might have not been successfully installed.

dreinsdo commented 5 years ago

I was able to get openpose working on the TX1 with some changes to makefiles. A detailed writeup of my procedure, including how I prepped the TX1 is attached, along with the openpose files I edited. I would be happy to commit these to the repo. The procedure is also copied below.

Openpose TX1 install files.zip

OpenPose - Installation on Nvidia Jetson TX1

Purpose

This document describes the full procedure for installing openpose on the Jetson TX1. Other, and less involved, procedures may have been found successful by community members, and we encourage you to share your alternatives.

Preliminary remarks

This procedure details moving the Jetson file system to a larger drive, building a custom kernel, building OpenCV from source, and customizing Openpose Makefiles because TX1 eMMC is limited, the onboard camera did not work with Openpose, stock Jetpack 3.1 OpenCV build lacks Openpose dependencies, and Openpose makefiles are not compatible with TX1 CUDA arch, respectively. We used a PS3 Eye camera in place of the onboard camera, and a 120Gb SSD, but most USB webcams and SATA drives should work fine.

Contents

Prep the TX1

  1. Flash Jetson TX1 with JetPack 3.1 per Jetpack installation guide. Be sure to complete both OS flashing and CUDA / cuDNN installation parts before installation.
  2. Move file system to SATA drive. Follow steps of JetsonHacks article Install Samsung SSD on NVIDIA Jetson TX1.

Build custom kernel

This step is required because we were not able to use Openpose with the onboard TX1 camera. The steps are a combination of two JetsonHacks articles Build Kernel and ttyACM Module – NVIDIA Jetson TX1 and Sony PlayStation Eye – NVIDIA Jetson TX1. If you are using a different webcam then include the driver for that webcam in place of the PS3 eye driver in step 3.

  1. Get the install scripts from JetsonHacks Github. This link is to the zip of the 'JetPack 3.1' release. If you $git clone$ from the master branch then you will get the most recent kernel build files, which are not compatible with JetPack 3.1.
  2. Unzip the downloaded files, enter the unzipped directory and run script to get kernel sources.
    $ cd buildJetsonTX1Kernel
    $ sudo ./getKernelSources.sh
  3. The script will open the editor for the kernel configuration. Find the driver for your webcam and select with a checkbox (not a dot). Save the configuration and quit the config window.
  4. Make the kernel.
    $ sudo ./makeKernel.sh
  5. Replace the current kernel the newly built kernel image.
    $ sudo cp /usr/src/kernel/kernel-4.4/arch/arm64/boot/Image ($PATH_TO_EMMC)/boot/Image

    Replace $PATH_TO_EMMC with the path to your eMMC. This is required because the Jetson initially boots to eMMC and loads the kernel from their, even with the SATA drive connected.

Build OpenCV from source

Follow JK Jung's steps from How to Install OpenCV (3.4.0) on Jetson TX2 verbatim, with the following exception: omit installation of Python3 dependencies, i.e. skip the following lines.

$ sudo apt-get install python3-dev python3-pip python3-tk
$ sudo pip3 install numpy
$ sudo pip3 install matplotlib

Install Openpose

The following steps detail the modification of three files to install Openpose. Modified versions of the files are attached and may alternatively be used. To use, be sure to rename both makefile configs to Makefile.config.Ubuntu16_cuda8_JetsonTX2.

  1. Clone from the master branch.

    $ git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose
    $ cd openpose
  2. Modify makefile config. For the installation procedure we will use the TX2 files for JetPack 3.1.

    $ gedit scripts/ubuntu/Makefile.config.Ubuntu16_cuda8_JetsonTX2

    Uncomment the opencv line

    OPENCV_VERSION := 3

    Replace all the 'CUDA_ARCH :=' lines with the following

    CUDA_ARCH := -gencode arch=compute_53,code=[sm_53,compute_53]

    Add CUDNN - not sure if this is necessary, have not retried the install without it.

    USE_CUDNN := 1
  3. Correct error in install script path.

    $ gedit scripts/ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.1.sh

    Replace

    executeShInItsFolder "install_openpose_JetsonTX2_JetPack3.1.sh" "./scripts/ubuntu/" "./"

    with

    executeShInItsFolder "./scripts/ubuntu/install_openpose_JetsonTX2_JetPack3.1.sh" "./" "./"
  4. Start the install process. When you initially call the install script the caffe repo will be cloned and associated files downloaded. As soon as Caffe starts compiling, halt the process and change the makefile config as in step 2.

    bash ./scripts/ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.1.sh

    Once caffe begins to compile CTRL+C.

    $ gedit 3rdparty/caffe/Makefile.config.Ubuntu16_cuda8_JetsonTX2

    Make the same changes as in step 2. The CUDNN switch should already be on.

  5. Restart the installation process.

    bash ./scripts/ubuntu/install_caffe_and_openpose_JetsonTX2_JetPack3.1.sh

Usage

To get to decent FPS you need to lower the net resolution:

./build/examples/openpose/openpose.bin -camera_resolution 640x480 -net_resolution 128x96

To activate hand or face resolution please complete this command with the following options (warning, both simultaneously will cause out of memory error):

--hand -hand_net_resolution 256x256
--face -face_net_resolution 256x256
gineshidalgo99 commented 5 years ago

Thanks a lot! I added it in the last commit!