Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Current »

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.)

./ext_docker_build.sh src/adamapp/skeleton_sample_app

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.

Image-20240830-155501.jpg

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}.

cd ${SDK_DIR}

Add new options specific to ContainerAdamApp in setup_env.sh.

source setup_env.sh ambaCV5XCEX

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

./ext_docker_build.sh src/adamapp/jpeg_app_for_CV5X

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).

Image-20240913-104241.jpg

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

Adding external libraries

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

Building external libraries is not supported. Please refer to the information in this chapter to build external libraries. Please note that we cannot provide support even if you contact us.

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

ARG CADAMBUILDBASE_PATH
ARG CADAMAPPBASE_PATH
FROM ${CADAMBUILDBASE_PATH} AS build-env

WORKDIR /app
COPY . ./
WORKDIR /iprosdk
RUN chmod +x setup_env.sh
RUN /bin/bash -c "source setup_env.sh ambaCV5XCEXinternal && \
    cd /app && \
    make clean && \
    make"


# Application environment (arm64v8)
FROM ${CADAMAPPBASE_PATH} AS aplbase
RUN useradd -ms /bin/bash moduleuser
WORKDIR /app
COPY --chown=moduleuser:moduleuser --from=build-env /app/configuration.txt /app/
COPY --chown=moduleuser:moduleuser --from=build-env /app/data/ /app/data/
COPY --chown=moduleuser:moduleuser --from=build-env /app/setup/ /app/setup/
COPY --chown=moduleuser:moduleuser --from=build-env /app/bin/ /app/bin/
COPY --chown=moduleuser:moduleuser --from=build-env /app/conf/ /app/conf/

USER moduleuser

CMD ["bash"]
  • 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.

    #install libJpeg
    RUN apt update && \
        apt install -y libjpeg-dev && \
        apt-get clean && \
        rm -rf /var/lib/apt/lists/* 

     

  • 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.

    RUN apt-get update &&\
        apt-get install -y build-essential gcc make cmake cmake-gui cmake-curses-gui
    
    WORKDIR /paho
    RUN git clone https://github.com/eclipse/paho.mqtt.c.git && \
        mkdir /tmp/build.paho && \
        cd /tmp/build.paho && \
        cmake -DPAHO_WITH_SSL=TRUE /paho/paho.mqtt.c && \
        cmake --build .
  • 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.

    # copy libjpeg
    COPY --from=build-env /usr/lib/aarch64-linux-gnu/libjpeg.so.8.2.2 /usr/lib/aarch64-linux-gnu/
    RUN ln -sf /usr/lib/aarch64-linux-gnu/libjpeg.so.8.2.2  /usr/lib/aarch64-linux-gnu/libjpeg.so.8 && \
        ln -sf /usr/lib/aarch64-linux-gnu/libjpeg.so.8.2.2  /usr/lib/aarch64-linux-gnu/libjpeg.so
  • 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.

  • No labels