Birds Eye View - Birds Eye View Building and Installation Guide

From RidgeRun Developer Wiki



⇦ Getting the Code/Evaluation Home Getting_Started ⇨






Dependencies

The Birds Eye View has the following dependencies:

  • meson
  • ninja
  • pkg-config
  • jsoncpp
  • CUDA (optional, for GPU acceleration)
  • NPP (optional, for GPU acceleration)
  • CppUTest (optional, for testing)
  • wget (optional, for downloading the samples)
  • unzip (optional, for downloading the samples)
  • Doxygen (optional, for documentation)
  • Graphviz (optional, for documentation)
  • OpenCV (optional, for image loading and displaying)
  • GStreamer (optional, for image loading)
  • Qt5 (optional, for image loading and displaying)

On Debian based systems you can run:

apt update
apt install -y git meson ninja-build pkg-config libjsoncpp-dev libopencv-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad qtbase5-dev qtmultimedia5-dev libqt5multimedia5-plugins libcpputest-dev doxygen graphviz wget unzip


3. Obtain source code from Github

git clone https://github.com/opencv/opencv.git
cd opencv/
git checkout 4.1.0
cd ..
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib/
git checkout 4.1.0
cd ..



4. Configure with required flags

cd opencv/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python2=OFF \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D WITH_GSTREAMER=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_GENERATE_PKGCONFIG=YES \
-D BUILD_EXAMPLES=ON ..

5. Check configuration log

✔ Verify if it has Python 3: section and all interpreter and path are right. (If they aren’t there, check the NumPy package)

✔ Check the GStreamer section. (If it does not indicate YES, go check the GStreamer lib package)

6. Building

It will last some time. Please be patient.

sudo make -j4

7. Install the package

sudo make install
sudo ldconfig

Building OpenCV with GStreamer and CUDA support

If you are using a NVIDIA Jetson device, you can follow the instructions on the next wiki:

to properly configure, compile, and install OpenCV, natively; it is worth mentioning that this is not a cross-compilation.

Build library and examples

git clone https://gitlab.com/RidgeRun/rnd/bird-eye-view.git
cd bird-eye-view
mkdir build
cd build
meson ..
ninja


The library also supports several meson options to:

1. Build the library with OpenCV CUDA support. This boosts library performance by using CUDA to compute heavy transformation methods on GPU.

meson -Dopencv-cuda=enabled ..

2. Build the library with profiling support. Please refer to Birds_Eye_View/Performance/Profiling to install dependencies

meson -Dprofiling=enabled ..

3. Build the library with documentation

meson -Ddoc=enabled ..

4. Build only the documentation

meson -Ddocs-only=enabled ..

Now you will find the example files:

Troubleshooting

Meson version

On Ubuntu 18.04.1 LTS, the Meson install usually has a 0.45.1 version, however, the project requires at least 0.50. A newer version of Meson can be installed using Pip in the following way:

sudo -H pip3 install meson

This usually installs the latest version of Meson available for your system. However, this is just accessible from the Python environment. In order to make it system-wide do:

sudo touch /usr/local/bin/meson
sudo chmod +x /usr/local/bin/meson


and add the following to it:

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from mesonbuild.mesonmain import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

With this, you can follow the steps to build without further issues.

Patch to support 4 USB cameras

When using more than 2 USB cameras it may be necessary to jump over the bandwidth restriction imposed by the generic USB driver, which is not capable of requesting the correct image size, therefore, requests the max size. It is necessary to recompile the driver after applying the required patch.


1. Download the kernel source

sudo apt-get source linux-image-unsigned-$(uname -r)
cd $(uname -r)/drivers/media/usb/uvc/
mkdir patches
cd patches

If you get this error:

E: You must put some 'source' URIs in your sources.list

Run the following commands:

sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update

If you have problems trying to download the kernel sources via APT, you can download them as follows:

  • Find the release of L4T you are currently working with:
head -n 1 /etc/nv_tegra_release
dpkg -l | grep ‘nvidia-l4t-core
  • Go to the Linux Tegra Archive page and click on the L4T version button according to the output you've got in the previous step.
  • Go to the Driver Details chart and click on L4T Driver Package (BSP) Sources to download the whole driver package. It will start the public_sources.tbz2 package downloading.
  • You will find a file named as kernel_src.tbz2 inside the public_sources.tbz2 package located in the /Linux_for_Tegra/source/public/ folder.
  • Extract the kernel_src.tbz2 from the public_sources.tbz2 package and then, extract the content of the kernel_src.tbz2 tarball.
  • You should have access to the UVC sources:
cd kernel/kernel-4.9/drivers/media/usb/uvc/
mkdir patches
cd patches

2. Create the patch file

vim 001-uvc-add-compressed-video-bandwidth-parameter.patch
Index: ./uvc_video.c
===================================================================
--- ./uvc_video.c
+++ ./uvc_video.c
@@ -161,6 +161,11 @@ static void uvc_fixup_video_ctrl(struct
 
                ctrl->dwMaxPayloadTransferSize = bandwidth;
        }
+
+       if (format->flags & UVC_FMT_FLAG_COMPRESSED) {
+         ctrl->dwMaxPayloadTransferSize = 0x300;
+       }
+
 }
 
 static int uvc_get_video_ctrl(struct uvc_streaming *stream,



3. Setup the series file:

echo 001-uvc-add-compressed-video-bandwidth-parameter.patch > series
cd ..

4. Apply the patch:

quilt push

5. Compile and reload the kernel module:

sudo make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
sudo rmmod uvcvideo
sudo insmod uvcvideo.ko



⇦ Getting the Code/Evaluation Home Getting_Started ⇨