Sample Code and It's Compilation Process
  • 11 Jul 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

Sample Code and It's Compilation Process

  • Dark
    Light

Article Summary

For the EVA samples, please refer to github site: https://github.com/IST-EVA-Support/EVA-Sample and clone the source code:

git clone https://github.com/IST-EVA-Support/EVA-Sample.git
cd EVA-Sample

Change to new-samples branch to view all the samples provided:

git checkout new-samples

In Master branch are the samples developed around EVASDK 3.5.3 and before. Samples in new-samples branch are developed for the version after 3.5.3 with the purpose of more systematic illustrating each aimed function specifically instead of hybrid them too advanced.

Requirements

ADLINK device with EVASDK installed.

Build Process for C/C++

Step 1. Install require packages

  • gstreamer-1.0 >= 1.14.1
  • opencv >= 4.5.0 for windows and Linux x86_x64; opencv >= 4.1.1 for Linux ARM

Step 2. [Windows] Open Visual Studio Prompt

For windows compiler, open windows vs prompt. Take vs2019 as example:

Menu > Visual Studio 2019 > x64 Native Tools Command Prompt for VS 2019

In windows, use this tool to run the commands below.

Step 3. Install build tool

$ pip3 install meson ninja boto3

Step 4. Set environment variable

Run the script file described in Installation Guide in INSTALLING THE ADLINK EVA SDK - Set Environment Variables.

Linux version, assume installed default path to EVA SDK is /opt/adlink/eva, run:

$ source /opt/adlink/eva/scripts/setup_eva_envs.sh

For windows, assume installed default path to EVA SDK is C:\ADLINK\eva, run gstreamer and EVA bat file:

> C:\ADLINK\gstreamer\setupvars.bat
> C:\ADLINK\eva\scripts\setup_eva_envs.bat

Set gstreamer and opencv required path to system path, if you had installed EVA. Add those path to system variables, "Path":

C:\ADLINK\gstreamer\bin
C:\ADLINK\gstreamer\lib
C:\ADLINK\gstreamer\lib\gstreamer-1.0
PATH_TO_OPENCV\bin

If you don't want to set opencv path to system variables, remember copy the opencv dependencies besides the built binary.

Note: The samples used OpenCV GStreamer Wrapper, so it is required to use OpenCV which build with GStreamer.

Step 5. Go to sample folder

Assume you clone the EVA-Sample under EVA_Sample_ROOT:
For Linux:
Make sure you have the permission to samples folder first.

$ cd <EVA_Sample_ROOT>
$ sudo chmod +447 EVA-Sample/
$ cd EVA-Sample

For Windows:

> cd EVA_Sample_ROOT\EVA-Sample

Step 6. Build binary

For Linux, use meson to configure the source code and use ninja to build for linux.

$ meson build
$ ninja -C build

If opencv was installed at other directory location, assign target directory to opencv_dir option like below commands.

$ meson build -Dopencv_dir=PATH_TO_OPENCV
$ ninja -C build

Remind that the opencv_dir is depends on where user installed. If not provide -Dopencv_dir in command, the default path will used where it can be found set in meson_options.txt. Besides, check 2 parameters "libs_cv"(for libraries) and "inc_cv"(for include files) relative to opencv_dir used in meson.build for the opencv. Check join_paths to where your opencv relative files located is important both in Linux and windows.

If samples are built in windows, meson can set build backend to vs. Also set the opencv_dir option. One more path need to set is eva_root to EVA installed path. Here we assumed EVA is installed in C:\ADLINK\eva. Then build it using meson:

$ meson --buildtype=release --backend=vs build -Dopencv_dir=PATH_TO_OPENCV -Deva_root=C:\ADLINK\eva
$ meson compile -C build

The built *.so or binary for linux will generated in build/src folder which corresponding to the source code path. Same as Windows, the built *.dll or *.exe will generated in build/src folder which corresponding to the source code path.

Remind copy .so (for Linux)/.dll (for windows) to plugins folder under eva_root for convenient use it.

Python samples install process

Simply copy the python samples to EVA installed path. Here we assumed EVA is installed in /opt/adlink/eva/plugins/python for Linux and C:\ADLINK\eva\plugins\python for WIndows. After copy the python samples, re-run the EVA environment setting for scanning the python plugins.


Was this article helpful?