1

I'm trying to implentment openpilot on Jetson Xavier nx. So I'm following https://github.com/eFiniLan/xnxpilot instruction to install dependence. But when I'm installing opencv4, I get the following errors in ".../opencv/build/CMakeFiles/CMakeError.log"

 CMakeFiles/cmTC_ee78d.dir/CheckIncludeFile.c.o -c /home/tshu/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/tshu/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: sys/videoio.h: No such file or directory
#include <sys/videoio.h>
^~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/cmTC_ee78d.dir/build.make:65: recipe for target ‘CMakeFiles/cmTC_ee78d.dir/CheckIncludeFile.c.o’ failed
make[1]: * [CMakeFiles/cmTC_ee78d.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory ‘/home/tshu/opencv/build/CMakeFiles/CMakeTmp’
Makefile:126: recipe for target ‘cmTC_ee78d/fast’ failed
make: * [cmTC_ee78d/fast] Error 2

The build command I used is

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D WITH_CUDA=ON \
    -D CUDA_ARCH_PTX="" \
    -D CUDA_ARCH_BIN="7.2" \
  -D WITH_CUDNN=ON \
  -D CUDNN_VERSION="8.0" \
    -D BUILD_opencv_python3=ON \
    -D BUILD_opencv_python2=OFF \
    -D BUILD_opencv_java=OFF \
    -D WITH_GSTREAMER=ON \
    -D WITH_GTK=OFF \
    -D BUILD_TESTS=OFF \
    -D BUILD_PERF_TESTS=OFF \
    -D BUILD_EXAMPLES=OFF \
    -D BUILD_FFMPEG=ON \
    -D OPENCV_DNN_CUDA=ON \
    -D ENABLE_FAST_MATH=ON \
    -D CUDA_FAST_MATH=ON \
    -D WITH_QT=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D BUILD_TESTS=OFF \
  -D INSTALL_PYTHON_EXAMPLES=OFF \
  -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_ENABLE_NONFREE=ON \
  -D OPENCV_GENERATE_PKGCONFIG=ON \
  -D PYTHON_EXECUTABLE=/home/`whoami`/.pyenv/versions/3.8.5/bin/python \
  -D PYTHON_DEFAULT_EXECUTABLE=/home/`whoami`/.pyenv/versions/3.8.5/bin/python \
  -D PYTHON_PACKAGES_PATH=/home/`whoami`/.pyenv/versions/3.8.5/lib/python3.8/site-packages/ \
    -D OPENCV_EXTRA_MODULES_PATH=/home/`whoami`/opencv_contrib/modules ..

The version of opencv I tried to install is opencv-4.5.2

Can someone give me some advices? Thank you.

Tshu Shi
  • 11
  • 1

2 Answers2

0

Jetpack comes with opencv preinstalled. JetPack 4.4 includes OpenCV 4.1.1. JetPack 4.6 includes OpenCV 4.1.1. Let me look at the link you sent and I get back to you. You may need to install and compile OpenCV 4.5.2 from source. I wrote some instructions a while a go.

Tarik007
  • 474
  • 1
  • 4
  • 14
  • Looks like the github repo link you sent uses Jetpack 4.5. I will try to look at it this weekend. Interesting project – Tarik007 Aug 20 '21 at 22:33
  • Thanks for helping. I'm trying copy sys/videoio.h from /usr/include/opencv4/opencv2 to /usr/include/sys `cp /usr/include/opencv4/opencv2/videoio.h /usr/include/sys`. Then I get another error, still lack of file. But some file can be found in /usr/include/opencv4/opencv2. So maybe I need to change some file path? – Tshu Shi Aug 24 '21 at 00:48
0

What Jetpack version are you using? OPENCV 4.4, is CUDA GPU accelerated. Using version 4.4 or higher to fully use the Super Resolution function provided by OpenCV. If you are using Jetpack 4.4, you will need to delete the OpenCV 4.1.1 version of JetPack 4.4 and install 4.4 newly. Try this script file:

#!/bin/bash
#
# Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#

if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <Install Folder>"
    exit
fi
folder="$1"
user="nvidia"
passwd="nvidia"

echo "** Remove OpenCV4.1 first"
sudo apt-get purge *libopencv*

echo "** Install requirement"
sudo apt-get update
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y python2.7-dev python3.6-dev python-dev python-numpy python3-numpy
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp
sudo apt-get install -y curl
sudo apt-get update

echo "** Download opencv-4.5.1"
cd $folder
curl -L https://github.com/opencv/opencv/archive/4.5.1.zip -o opencv-4.5.1.zip
curl -L https://github.com/opencv/opencv_contrib/archive/4.5.1.zip -o opencv_contrib-4.5.1.zip
unzip opencv-4.5.1.zip 
unzip opencv_contrib-4.5.1.zip 
cd opencv-4.5.1/

echo "** Building..."
mkdir release
cd release/
cmake -D WITH_CUDA=ON -D ENABLE_PRECOMPILED_HEADERS=OFF  -D CUDA_ARCH_BIN="7.2" -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.4.0/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j6
sudo make install

echo "** Install opencv-4.5.1 successfully"
echo "** Bye :)"

If you are using NX -D CUDA_ARCH_BIN="7.2"

Run following script with on path:

$./opencv4.5_xavier_nx.sh /home/TH-Dev/src/
Tarik007
  • 474
  • 1
  • 4
  • 14
  • I'm using Jetpack4.5.1. I try to use the script to install opencv first and build openpilot enviorment later. It's success to install opencv, I will buy a webcam and try using webcam with nx later.I'll update situation after I test it, thanks for helping. – Tshu Shi Aug 28 '21 at 12:25