Custom apps#
Our cameras are shipped with a minimal operating system which only contains basic tools, libraries and no package management. For custom applications, docker is installed on the device, which allows users to develop, build and run their own software containers.
To give full access to the underlying hardware, the NVIDIA® Container Toolkit is installed on the host system and will be used as default runtime. This allows you to use several L4T container images provided by NVIDIA®.
Libraries#
For camera access, we provide the C++ library vl which is described in detail in section api.
You can download different version from our package registry. At the moment we also provide bindings for Python and C#. The respective Wheel- or Nuget-packages can also be found in the package registry.
Samples#
For getting started, we offer some example code, make files and accompanying docker environments. You can find the samples here.
Let's have a look in detail, how the C++ streaming sample is built. First a base image is created which contains some build dependencies (e.g. a Ninja, CMake) and the vl library:
# Dockerfile *vl-samples/cpp/base-image/Dockerfile*
# build a dev image that contains dev dependencies (based on ubuntu 20.04)
FROM ubuntu:20.04 as dev
# define the vl version
ARG VL_VERSION=v2.3.0-rc1
WORKDIR /app
# install some dependencies
RUN apt-get update \
&& apt-get -y install --no-install-recommends build-essential ninja-build ca-certificates wget \
&& apt-get clean
# install a recent CMake version and add it to the PATH variable
ARG CMAKE_VERSION=3.26.4
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz \
&& tar -xvf cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz \
&& mv cmake-${CMAKE_VERSION}-linux-$(uname -m) /opt/cmake \
&& rm cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz
ENV PATH=/opt/cmake/bin:$PATH
# install the vl library
RUN wget https://git.3dvisionlabs.com/api/v4/projects/274/packages/generic/vl/${VL_VERSION}/vl-${VL_VERSION}.tar.gz \
&& mkdir -p /opt/vl \
&& tar -C /opt/vl --strip-components=1 -xvf vl-${VL_VERSION}.tar.gz \
&& rm vl-${VL_VERSION}.tar.gz
# build a runtime image that only contains runtime dependencies (based on ubuntu 20.04)
FROM ubuntu:20.04 as runtime
RUN apt-get update \
&& apt-get -y install --no-install-recommends libegl1 libgles2 \
&& apt-get clean
COPY --from=dev /opt/vl/lib /opt/vl/lib
A build script is used to generate the development and the runtime image:
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ROOT_DIR=$SCRIPT_DIR/../..
. $ROOT_DIR/scripts/setup-env
docker build --target dev -t 3dvl/vl-dev:latest -f $SCRIPT_DIR/Dockerfile $SCRIPT_DIR
docker build --target runtime -t 3dvl/vl-runtime:latest -f $SCRIPT_DIR/Dockerfile $SCRIPT_DIR
The development image contains all build dependencies and will be used to build our application. The runtime image contains only runtime dependencies and is much smaller in size. In the streaming example, both images are used to build the application container. First the development image is used to compile the application using CMake, later the binraries are copied into the runtime image:
FROM 3dvl/vl-dev:latest as builder
ENV PATH=/opt/cmake/bin:$PATH
WORKDIR /app
COPY . src/
RUN mkdir build \
&& cd build \
&& cmake -Dvl_DIR=/opt/vl/lib/cmake/vl -DCMAKE_BUILD_TYPE=Release -GNinja ../src \
&& cmake --build .
FROM 3dvl/vl-runtime:latest
WORKDIR /app
COPY --from=builder /app/build/vl_sample_streaming ./
ENTRYPOINT [ "./vl_sample_streaming" ]
To build and run the container, the following commands can be used:
IMAGE_NAME=vl-sample-cpp-streaming
# build the image
docker build -t ${IMAGE_NAME} .
# run the image
docker run --gpus all --security-opt systempaths=unconfined -it ${IMAGE_NAME}
The parameter --gpus all is used for allowing the container to use the GPU. --security-opt systempaths=unconfined is necessary because the vl needs access to the device tree.