Replies: 2 comments 2 replies
-
This automatically generated reply acts as a friendly reminder. Answers to your questions will most often come from the community, from developers like yourself. You will, from time to time, find that Axis employees answers some of the questions, but this is not a guarantee. Think of the discussion forum as a complement to other support channels, not a replacement to any of them. If your question remains unanswered for a period of time, please revisit it to see whether it can be improved by following the guidelines listed in Axis support guidelines. |
Beta Was this translation helpful? Give feedback.
-
Hi @Cacsjep , DockerfileARG ARCH=armv7hf
ARG VERSION=12.2.0
ARG UBUNTU_VERSION=24.04
ARG REPO=axisecp
ARG SDK=acap-native-sdk
FROM ${REPO}/${SDK}:${VERSION}-${ARCH}-ubuntu${UBUNTU_VERSION}
# Set general arguments
ARG ARCH
ARG SDK_LIB_PATH_BASE=/opt/axis/acapsdk/sysroots/${ARCH}/usr
ARG BUILD_DIR=/opt/build
#-------------------------------------------------------------------------------
# Prepare build environment
#-------------------------------------------------------------------------------
# Install build dependencies for cross-compilation
RUN apt-get update && \
apt-get install -y --no-install-recommends \
cmake \
autoconf \
automake \
libtool \
ninja-build \
curl && \
apt-get clean && rm -rf /var/lib/apt/lists/*
#-------------------------------------------------------------------------------
# Build libjpeg-turbo with ARM NEON SIMD enabled
#-------------------------------------------------------------------------------
ARG JPEGTURBO_VERSION=3.0.3
ARG JPEGTURBO_GIT_REPO=https://github.com/libjpeg-turbo/libjpeg-turbo
ARG JPEGTURBO_VERSION_DIR=libjpeg-turbo-${JPEGTURBO_VERSION}
ARG JPEGTURBO_DIR=${BUILD_DIR}/libjpeg-turbo
ARG JPEGTURBO_SRC_DIR=${JPEGTURBO_DIR}/${JPEGTURBO_VERSION_DIR}
ARG JPEGTURBO_BUILD_DIR=${JPEGTURBO_DIR}/build
WORKDIR ${JPEGTURBO_DIR}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -fsSL ${JPEGTURBO_GIT_REPO}/releases/download/${JPEGTURBO_VERSION}/${JPEGTURBO_VERSION_DIR}.tar.gz | tar -xz
WORKDIR ${JPEGTURBO_BUILD_DIR}
# Use correct SIMD optimizations based on target architecture
RUN . /opt/axis/acapsdk/environment-setup* && \
cmake -G Ninja \
-DCMAKE_INSTALL_PREFIX=${SDK_LIB_PATH_BASE} \
-DCMAKE_INSTALL_LIBDIR=${SDK_LIB_PATH_BASE}/lib \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_SIMD=1 \
-DWITH_NEON=1 \
-DWITH_TURBOJPEG=1 \
${JPEGTURBO_SRC_DIR} && \
ninja && \
ninja install
# Ensure libjpeg-turbo is installed
RUN ls -lah ${SDK_LIB_PATH_BASE}/lib && \
test -f ${SDK_LIB_PATH_BASE}/lib/libjpeg.so || { echo "Error: libjpeg-turbo.so not found"; exit 1; }
#-------------------------------------------------------------------------------
# Create symlink so acap-build finds the .so files
#-------------------------------------------------------------------------------
RUN mkdir -p /opt/build/libjpeg-turbo/build/lib && \
ln -s ${SDK_LIB_PATH_BASE}/lib/libjpeg*.so* /opt/build/libjpeg-turbo/build/lib/
#-------------------------------------------------------------------------------
# Get models and labels
#-------------------------------------------------------------------------------
WORKDIR /opt/app/model
ARG CHIP=
RUN case "$CHIP" in \
artpec8|artpec9|cpu) \
curl -L -o converted_model.tflite \
https://github.com/google-coral/test_data/raw/master/ssd_mobilenet_v2_coco_quant_postprocess.tflite || exit 1 ;; \
edgetpu) \
curl -L -o converted_model.tflite \
https://github.com/google-coral/test_data/raw/master/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite || exit 1 ;; \
*) \
echo "Error: Invalid CHIP value ($CHIP)" >&2; exit 1 ;; \
esac
WORKDIR /opt/app/label
RUN curl -L -o labels.txt https://github.com/google-coral/test_data/raw/master/coco_labels.txt || exit 1
#-------------------------------------------------------------------------------
# Build ACAP application
#-------------------------------------------------------------------------------
WORKDIR /opt/app
COPY ./app .
# Verify and copy manifest
RUN test -f /opt/app/manifest.json.${CHIP} || { echo "Error: Manifest file missing for CHIP: ${CHIP}"; exit 1; }
RUN cp /opt/app/manifest.json.${CHIP} /opt/app/manifest.json
# Build the application with required dependencies
RUN . /opt/axis/acapsdk/environment-setup* && \
acap-build . \
-a 'label/labels.txt' \
-a 'model/converted_model.tflite'
Uploading the example for your reference:Output(docker build --build-arg ARCH=armv7hf --build-arg CHIP=edgetpu --tag obj_detect:1.0 .) (AXIS Q1715 Block Camera: AXIS OS version 12.2.62):Another useful example:You can also explore using-opencv example which talks about Other noteworthy options are the ones related to NEON and VFPV3, which are optimizations available for the platform that can greatly speed up CPU operations. This is only necessary for armv7hf, in aarch64 these options are implicitly present. I hope this will be helpful for you 😉 |
Beta Was this translation helpful? Give feedback.
-
Does anyone have a docker file to compile libjpeg with SIMD, because docker files from native sdk repo don't use nasm for compiling, so SIMD would not be enabled.
Would need it for aarch64, Artpec8 and Artpec9
Thx
Br
Beta Was this translation helpful? Give feedback.
All reactions