To get the most out of this book

To be able to compile and run the examples included in this book, you will need to configure a particular development environment. All code examples have been tested with the Arch and Ubuntu 18.04 Linux distributions. The following list outlines the packages you'll need to install on the Ubuntu platform:

  • build-essential
  • unzip
  • git
  • cmake
  • cmake-curses-gui
  • python
  • python-pip
  • libblas-dev
  • libopenblas-dev
  • libatlas-base-dev
  • liblapack-dev
  • libboost-all-dev
  • libopencv-core3.2
  • libopencv-imgproc3.2
  • libopencv-dev
  • libopencv-highgui3.2
  • libopencv-highgui-dev
  • protobuf-compiler
  • libprotobuf-dev
  • libhdf5-dev
  • libjson-c-dev
  • libx11-dev
  • openjdk-8-jdk
  • wget
  • ninja-build

Also, you need to install the following additional packages for Python:

  • pyyaml
  • typing

Besides the development environment, you'll have to check out requisite third-party libraries' source code samples and build them. Most of these libraries are actively developed and don't have strict releases, so it's easier to check out a particular commit from the development tree and build it than downloading the latest official release. The following table shows you the libraries you have to check out, their repository URLs, and the hash number of the commit to check out:

Library repository

Branch name

Commit

https://github.com/shogun-toolbox/shogun

master

f7255cf2cc6b5116e50840816d70d21e7cc039bb

https://github.com/Shark-ML/Shark

master

221c1f2e8abfffadbf3c5ef7cf324bc6dc9b4315

https://gitlab.com/conradsnicta/armadillo-code

9.500.x

442d52ba052115b32035a6e7dc6587bb6a462dec

https://github.com/davisking/dlib

v19.15

929c630b381d444bbf5d7aa622e3decc7785ddb2

https://github.com/eigenteam/eigen-git-mirror

3.3.7

cf794d3b741a6278df169e58461f8529f43bce5d

https://github.com/mlpack/mlpack

master

e2f696cfd5b7ccda2d3af1c7c728483ea6591718

https://github.com/Kolkir/plotcpp

master

c86bd4f5d9029986f0d5f368450d79f0dd32c7e4

https://github.com/pytorch/pytorch

v1.2.0

8554416a199c4cec01c60c7015d8301d2bb39b64

https://github.com/xtensor-stack/xtensor

master

02d8039a58828db1ffdd2c60fb9b378131c295a2

https://github.com/xtensor-stack/xtensor-blas

master

89d9df93ff7306c32997e8bb8b1ff02534d7df2e

https://github.com/xtensor-stack/xtl

master

03a6827c9e402736506f3ded754e890b3ea28a98

https://github.com/opencv/opencv_contrib/releases/tag/3.3.0

3.3.0

https://github.com/ben-strasser/fast-cpp-csv-parser

master

3b439a664090681931c6ace78dcedac6d3a3907e

https://github.com/Tencent/rapidjson

master

73063f5002612c6bf64fe24f851cd5cc0d83eef9

 

Also, for the last chapter, you'll have to install the Android Studio IDE. You can download it from the official site at https://developer.android.com/studio. Besides the IDE, you'll also need to install and configure the Android SDK. The respective example in this book was developed and tested with this SDK, which can be downloaded from https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip. To configure this SDK, you have to unzip it and install particular packages. The following script shows how to do it:

mkdir /android 
cd /android

wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip

yes | ./tools/bin/sdkmanager --licenses
yes | ./tools/bin/sdkmanager "platform-tools"
yes | ./tools/bin/sdkmanager "platforms;android-25"
yes | ./tools/bin/sdkmanager "build-tools;25.0.2"
yes | ./tools/bin/sdkmanager "system-images;android-25;google_apis;armeabi-v7a"
yes | ./tools/bin/sdkmanager --install "ndk;20.0.5594570"

export ANDROID_NDK=/android/ndk/20.0.5594570
export ANDROID_ABI='armeabi-v7a'

Another way to configure the development environment is through the use of Docker. Docker allows you to configure a lightweight virtual machine with particular components. You can install Docker from the official Ubuntu package repository. Then, use the scripts provided with this book to automatically configure the environment. You will find the docker folder in the examples package. The following steps show how to use Docker configuration scripts:

  1. Run the following commands to create the image, run it, and configure the environment:
cd docker 
docker build -t buildenv:1.0 .
docker run -it buildenv:1.0 bash
cd /development
./install_env.sh
./install_android.sh
exit
  1. Use the following command to save our Docker container with the configured libraries and packages into a new Docker image:
docker commit [container id]
  1. Use the following command to rename the updated Docker image:
docker tag [image id] [new name] 
  1. Use the following command to start a new Docker container and share the book examples sources to it:
docker run -it -v [host_examples_path]:[container_examples_path] [tag name] bash

After running the preceding command, you will be in the command-line environment with the necessary configured packages, compiled third-party libraries, and with access to the programming examples package. You can use this environment to compile and run the code examples in this book. Each programming example is configured to use the CMake build system so you will be able to build them all in the same way. The following script shows a possible scenario of building a code example:

cd [example folder name]
mkdir build
cd build
cmake ..
cmake --build . --target all

Also, you can configure your local machine environment to share X Server with a Docker container to be able to run graphical UI applications from this container. It will allow you to use, for example, the Android Studio IDE or a C++ IDE (such as Qt Creator) from the Docker container, without local installation. The following script shows how to do this:

xhost +local:root 
docker run --net=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -it -v [host_examples_path]:[container_examples_path] [tag name] bash

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the following section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

To be more comfortable with understanding and building the code examples, we recommend you carefully read the documentation for each third-party library, and take some time to learn the basics of the Docker system and of development for the Android platform. Also, we assume that you have sufficient working knowledge of the C++ language and compilers, and that you are familiar with the CMake build system.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.69.163