Skip to content

Commit ddad4cc

Browse files
Corallopataxis
authored andcommitted
Refactor CV-SDK
Refactor examples to use the new Computer Vision solution This change refactors the examples to use the new Computer Vision solution instead of the old one (CV SDK). It also includes various other updates and improvements, such as: - Update the README files with relevant information - Update the acap-runtime version to 2.0.0 (container based) - Add QEMU to the GitHub workflow for building
1 parent ec2c59b commit ddad4cc

30 files changed

+227
-223
lines changed

.github/workflows/example-checks.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ jobs:
1515
run: |
1616
# Find directories that do not start with dot
1717
acap_list="$(find . -maxdepth 1 -type d -printf '%f\n' |grep -v '^[.]' | sort)"
18-
# Find lines starting with '* ['
19-
# The grep removes anything but '[*]', then remove entries with space
20-
# or capital letter and finally removes the brackets.
21-
endline="$(sed -n '/## Docker Hub images/=' README.md)"
22-
readme_examples="$(sed -n "1,${endline}!d ; /* \[/p" README.md | grep -oe '\[.*\]' | grep -v '[A-Z ]' | grep -oe '[0-9a-z-]*')"
18+
19+
# Find example application links in README.md
20+
# The regular expression '^\* \[[0-9a-z-]*\]' matches lines starting with '* ['
21+
# followed by alphanumeric characters and hyphens, and a closing ']'
22+
example_links="$(grep -o '^\* \[[0-9a-z-]*\]' README.md)"
23+
24+
# Remove '* [' prefix and trailing ']' from example links
25+
# The sed command uses two substitutions:
26+
# 1. 's/^\* \[//' removes the '* [' prefix from the start of the line
27+
# 2. 's/\]$//' removes the trailing ']' from the end of the line
28+
readme_examples="$(echo "$example_links" | sed 's/^\* \[//;s/\]$//')"
2329
2430
# Control that all examples have an entry in README
2531
common=$(printf "${acap_list}\n${readme_examples}" | sort | uniq -d)

.github/workflows/hello-world-python.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ jobs:
2525
imagetag: ${{ env.EXREPO }}_${{ env.EXNAME }}:1.0
2626
run: |
2727
cd $EXNAME
28+
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
2829
docker build --no-cache --tag $imagetag .

.github/workflows/object-detector-python.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ jobs:
3131
modeltag: ${{ env.EXREPO }}_${{ env.EXNAME }}-${{ matrix.chip }}-model:1.0
3232
run: |
3333
cd $EXNAME
34+
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
3435
docker build --no-cache --build-arg CHIP=${{ matrix.chip }} --tag $imagetag .
3536
docker build --file Dockerfile.model --tag $modeltag .

.github/workflows/opencv-qr-decoder-python.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ jobs:
2525
imagetag: ${{ env.EXREPO }}_${{ env.EXNAME }}:1.0
2626
run: |
2727
cd $EXNAME
28+
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
2829
docker build --no-cache --tag $imagetag .

.github/workflows/parameter-api-python.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ jobs:
2525
imagetag: ${{ env.EXREPO }}_${{ env.EXNAME }}:1.0
2626
run: |
2727
cd $EXNAME
28+
docker run --rm --privileged multiarch/qemu-user-static --credential yes --persistent yes
2829
docker build --no-cache --tag $imagetag .

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,22 @@ developers analytics experience. All examples are using Docker framework and has
3232
README file in its directory which shows overview, example directory structure and
3333
step-by-step instructions on how to run applications on the camera.
3434

35-
### Requirements
35+
## Requirements
3636

3737
### Supported architectures
3838

3939
The examples support the following architectures:
4040

4141
* aarch64
4242

43-
### Example applications for video analytics
43+
### Required components
44+
45+
The example applications make use of two special components:
46+
47+
* [Docker ACAP](https://github.com/AxisCommunications/docker-acap) needs to be installed and running on the Axis device. It's required to deploy and run the example application.
48+
* [ACAP runtime](https://github.com/AxisCommunications/acap-runtime) is used in a few examples to get access to [APIs](https://axiscommunications.github.io/acap-documentation/docs/api/computer-vision-sdk-apis.html). ACAP Runtime is a container image and the example applications will pull it from Docker Hub when starting.
49+
50+
## Example applications
4451

4552
Below is a list of examples available in the repository:
4653

@@ -60,12 +67,6 @@ Below is a list of examples available in the repository:
6067
* [web-server](./web-server/)
6168
* A C++ example which runs a Monkey web server on the camera.
6269

63-
### Docker Hub images
64-
65-
The examples are based on the [ACAP Computer Vision SDK](https://github.com/AxisCommunications/acap-computer-vision-sdk).
66-
This SDK is an image which contains APIs and tooling to build computer vision apps for running on camera, with support for Python.
67-
Additionally, there is the [ACAP Native SDK](https://github.com/AxisCommunications/acap-native-sdk), which is more geared towards building ACAPs that uses AXIS-developed APIs directly, and primarily does so using C/C++.
68-
6970
## How to work with Github repository
7071

7172
You can help to make this repo a better one using the following commands.

hello-world-python/Dockerfile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG REPO=axisecp
4-
ARG SDK_VERSION=1.15
53
ARG UBUNTU_VERSION=22.04
64

7-
8-
FROM ${REPO}/acap-computer-vision-sdk:${SDK_VERSION}-aarch64 AS cv-sdk
9-
105
FROM arm64v8/ubuntu:${UBUNTU_VERSION}
116

12-
# Get the Python package from the CV SDK
13-
COPY --from=cv-sdk /axis/python /
7+
RUN DEBIAN_FRONTEND=noninteractive \
8+
apt-get update && apt-get install -y --no-install-recommends \
9+
python3 \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
WORKDIR /opt/app
1413

15-
WORKDIR /app
16-
COPY app/* /app
14+
COPY app/* .
1715
CMD ["python3", "simply_hello.py"]

hello-world-python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# A minimal Python application
44

5-
This example demonstrates how to create a simple Python application using the ACAP Computer Vision SDK and run it on an edge device.
5+
This example demonstrates how to create a simple containerized Python application and run it on an edge device.
66

7-
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](app/simply_hello.py). Next, the [Dockerfile](Dockerfile) which builds 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.
7+
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](app/simply_hello.py). Next, the [Dockerfile](Dockerfile) which builds the application image is constructed. The application needs to be built and uploaded, as is specified below.
88

99
## Example structure
1010

minimal-ml-inference/Dockerfile

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
# syntax=docker/dockerfile:1
22

3+
ARG RUNTIME_VERSION=2.0.0
34
ARG REPO=axisecp
4-
ARG SDK_VERSION=1.15
5+
ARG IMAGE=acap-runtime
56
ARG UBUNTU_VERSION=22.04
67

7-
# Specify which ACAP Computer Vision SDK to use
8-
FROM ${REPO}/acap-computer-vision-sdk:${SDK_VERSION}-aarch64 AS cv-sdk
8+
FROM ${REPO}/${IMAGE}:${RUNTIME_VERSION}-protofiles AS proto-image
9+
FROM arm64v8/ubuntu:${UBUNTU_VERSION} AS runtime-image
910

10-
# Define the runtime image
11-
FROM arm64v8/ubuntu:${UBUNTU_VERSION}
11+
RUN DEBIAN_FRONTEND=noninteractive \
12+
apt-get update && apt-get install -y --no-install-recommends \
13+
python3 \
14+
python3-pip \
15+
ffmpeg \
16+
libsm6 \
17+
libxext6 \
18+
&& rm -rf /var/lib/apt/lists/*
1219

13-
# Get packages from the CV SDK
14-
COPY --from=cv-sdk /axis/python /
15-
COPY --from=cv-sdk /axis/python-tfserving /
16-
COPY --from=cv-sdk /axis/python-vdoproto /
17-
COPY --from=cv-sdk /axis/python-numpy /
18-
COPY --from=cv-sdk /axis/opencv /
19-
COPY --from=cv-sdk /axis/openblas /
20+
# Copy list of grpc dependencies
21+
COPY --from=proto-image /build/requirements.txt .
22+
23+
RUN pip install --no-cache-dir -r requirements.txt \
24+
numpy \
25+
opencv-python
26+
27+
WORKDIR /opt/app
28+
29+
# Install prebuilt TensorFlow and VDO proto files
30+
COPY --from=proto-image /build/tf/proto_utils .
31+
COPY --from=proto-image /build/vdo/proto_utils .
2032

2133
# Copy the application script to the container
22-
WORKDIR /app
23-
COPY simple_inference.py .
34+
COPY app/* .
35+
2436
CMD ["python3", "simple_inference.py"]

minimal-ml-inference/Dockerfile.model

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ ARG UBUNTU_VERSION=22.04
44

55
FROM arm64v8/alpine as model-image
66

7-
87
# Get SSD Mobilenet V2
98
ADD https://github.com/google-coral/edgetpu/raw/master/test_data/ssd_mobilenet_v2_coco_quant_postprocess.tflite models/
109
ADD https://github.com/google-coral/edgetpu/raw/master/test_data/coco_labels.txt models/

0 commit comments

Comments
 (0)