How to develop(Container AdamApp)

 

Table of contents


 

Overview


This tutorial explains how to develop a container app using the iPRO Camera SDK, using a sample app. In this tutorial, the installation directory of the SDK is indicated as ${SDK_DIR}.

Container AdamApp is for cameras with SoC ambaCV5X and firmware version 3.30 or later, and can be developed with SDK version 2.10 or later. Please check here for camera SoC.

 

How to build


Use of Developer License

You should already have applied for and obtained a developer license (development.key), so place it in the SDK/conf folder.

image-20240913-103323.png

 

Building the sample app

Here we will go through the steps to build a sample app as an example.

Move to ${SDK_DIR}.

cd ${SDK_DIR}

Add new options specific to ContainerAdamApp in setup_env.sh.

source setup_env.sh ambaCV5XCEX

During the first build, the necessary Docker images will be downloaded from the Internet. Please make sure you are connected to the Internet.

After that, the ext file is built with the following shell script:

./ext_docker_build.sh [sample app directory]

For example, to build the C version of skeleton_sample_app, do the following. (The Python version is similar, so I will omit the details.)

If the build is successful, the following two files will be generated in the sample app directory.

  • [app name]_[version name].ext

  • [app name]_[version name].zip

The app name and version name are taken from the first image value found at the top of docker_compose.yaml. For example, if image: “skeleton_sample_app:0.0.6” is written, the file name will be skeleton_sample_app_0.0.6.ext (zip).

 

Operation check

Install it on your camera (for example, you can install it from the green frame in the image below). Select the .ext file you created and install it. Open the app screen (red frame button in the image below).

Image-20240913-104240.jpg

If the text is displayed as in the image below, the operation was successful.

 

Build procedure using external libraries


Building a sample app with external libraries

If you want to develop an app that uses external libraries, you can use them by including them in the Dockerfile.

In addition, OpenSSL (Ver 3) and curl/libcurl (Ver 7.81.0) are included in the base Docker image, so you can use them as is.

Here we will go through the steps to build jpeg_app_for_CV5X as an example.

The C version builds libjpeg, and the Python version builds Numpy and OpenCV. The build may take several hours, so please allow yourself plenty of time to complete. Also, please make sure you have enough free space.
*The specific time and free space required will depend on the external library.

Move to ${SDK_DIR}.

Add new options specific to ContainerAdamApp in setup_env.sh.

After that, the ext file is built with the following shell script. (Python version is the same, so it is omitted.)

If the build is successful, the following two files will be generated in the sample app directory.

  • [app name]_[version name].ext

  • [app name]_[version name].zip

 

Operation check

Install it on your camera (for example, you can install it from the green frame in the image below). Select the .ext file you created and install it. Open the app screen (red frame button in the image below).

If the image captured by the camera is displayed when you start the app, as shown below, then the app was successful.

 

Adding other external libraries

If you want to use any external libraries, edit the Dockerfile.

For documentation on Dockerfile, see:

Dockerfile reference | Docker Docs

The following describes the content for i-PRO cameras.

 

The following explanation will be based on the following files included in skeleton_sample_app.

${SDK_DIR}\src\adamapp\skeleton_sample_app\Dockerfile.ext

 

  • Lines 1 to 12. Build the app.

  • Line 3. The image specified in FROM is the development environment image provided by i-PRO. It contains libraries for building apps that run on the camera, so please do not change it.

  • Line 6. All files in the skeleton_sample_app folder (except for files listed in .dockerignore) are copied into the build image.

  • Lines 9 to 12. This sets up the environment using setup_env.sh and builds the app. Do not change these lines.

  • Lines 4 to 5. If you want to include your own OSS required for the build, add it between lines 4 and 5. The following is an example for installing libjpeg.

     

  • You can also add OSS if you want to build it from source code. Below is an example of building the Eclipse Paho C Client Library for the MQTT Protocol from source code.

  • Lines 18 to 27. These are the steps to build the image included in the ext that actually runs on the camera. The basic flow is to copy the binary built in lines 1-12.

  • Line 16. The image specified in FROM is the base image for the application provided by i-PRO. It contains the minimum files required to run on the camera, so do not change it.

  • Line 17. This creates a user to run in the camera. The i-PRO camera prohibits running containers with root privileges.

  • Lines 19 to 23. Copy the already built binaries and necessary files to the image.

  • Line 25. The execution user is set to the “moduleuser” created in line 17.

  • Line 27. This specifies the default command for this image when it starts. This overrides the docker-compose.yaml file so that the app you built starts first.

  • Line 17. From line 17 onwards, add code to copy any libraries you wish to use. Below is an example of code to copy libjpeg.

  • To find out which files you need to copy, use the ldd command on the binary you built, or the dpkg -L command if you installed it with apt-get.