Copyright (C) 2021, Axis Communications AB, Lund, Sweden. All Rights Reserved.
This example demonstrates how to create a simple Python application using the ACAP Computer Vision SDK and run it on an edge device.
Going from zero to a Python application running on an AXIS device is quite easy. First, the application script is written, as in the hello-world script in app/simply_hello.py. Next, the Dockerfile which build the application image is constructed. This needs to pull in packages from the ACAP Computer Vision SDK, as is done using the COPY
commands. Finally, the application needs to be built and uploaded, as is specified below.
Following are the list of files and a brief description of each file in the example
hello-world
├── app
├── |- simply_hello.py
├── Dockerfile
└── README.md
- simply_hello.py - A Python script that prints "Hello World"
- Dockerfile - Build instructions for the application image that is run on the camera
To ensure compatibility with the examples, the following requirements shall be met:
- Camera: ARTPEC-{7-8} DLPU devices (e.g., Q1615 MkIII)
- docker-compose version 1.29 or higher
- Docker version 20.10.8 or higher
- Firmware: 10.9
- Docker ACAP installed and started, using TLS and SD card as storage
Export the ARCH variable depending on the architecture of your camera
# For arm32
export ARCH=armv7hf
# For arm64
export ARCH=aarch64
# Set camera IP
export AXIS_TARGET_IP=<actual camera IP address>
export DOCKER_PORT=2376
# Define APP name
export APP_NAME=hello-world
# Clean docker memory
docker --tlsverify -H tcp://$AXIS_TARGET_IP:$DOCKER_PORT system prune -af
With the environment setup, the hello-world
image can be built. The environment variables are supplied as build arguments such that they are made available to docker during the build process:
docker build . -t $APP_NAME --build-arg ARCH
Next, the built image needs to be uploaded to the device. This can be done through a registry or directly. In this case, the direct transfer is used by piping the compressed application directly to the device's docker client:
docker save $APP_NAME | docker --tlsverify -H tcp://$AXIS_TARGET_IP:$DOCKER_PORT load
With the application image on the device, it can be started. As this example does not use e.g., OpenCV, no special mounts are needed, making the run command very simple:
docker --tlsverify -H tcp://$AXIS_TARGET_IP:$DOCKER_PORT run -it $APP_NAME
The expected output from the application is simply:
Hello World!