-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DepthAI PreV3 Support for Robothub based on docker image setup
- Loading branch information
Showing
10 changed files
with
303 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
set -Eeux | ||
|
||
# Check if the correct number of arguments is provided | ||
if [[ $# -ne 1 ]]; then | ||
echo "Usage: $0 <depthai-git-version>" | ||
exit 1 | ||
fi | ||
|
||
DEPTHAI_GIT_VERSION=$1 | ||
echo "Received DepthAI Git version: $DEPTHAI_GIT_VERSION" | ||
|
||
# Verify that the version starts with 'git+' | ||
if [[ $DEPTHAI_GIT_VERSION != git+* ]]; then | ||
echo "Error: DepthAI version must be a Git URL" | ||
exit 1 | ||
fi | ||
|
||
# Install necessary build tools and dependencies for compiling the DepthAI Python package from source | ||
apt-get update -qq && \ | ||
apt-get install -qq --no-install-recommends \ | ||
python3 python3-dev python3-pip \ | ||
ca-certificates \ | ||
git \ | ||
wget \ | ||
cmake \ | ||
make \ | ||
build-essential && \ | ||
pip3 install mypy && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Parse the Git URL and Branch from the version string | ||
GIT_URL=${DEPTHAI_GIT_VERSION/git+/} | ||
BRANCH=${GIT_URL##*@} | ||
GIT_URL=${GIT_URL%@*} | ||
echo "Cloning from Git URL: $GIT_URL, Branch: $BRANCH" | ||
|
||
|
||
# Clone the DepthAI Git repository | ||
echo "Cloning DepthAI from Git..." | ||
git clone --branch "$BRANCH" --recurse-submodules "$GIT_URL" depthai-python || { echo "Git clone failed"; exit 1; } | ||
|
||
# Navigate to the cloned directory | ||
echo "Navigating to cloned directory..." | ||
cd depthai-python || { echo "Failed to enter depthai-python directory"; exit 1; } | ||
|
||
# Build and install the package | ||
echo "Building and installing the DepthAI package..." | ||
pip3 install . --verbose || { echo "DepthAI installation failed"; exit 1; } | ||
|
||
echo "DepthAI installation from Git completed successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
ARG BASE_IMAGE | ||
|
||
FROM ${BASE_IMAGE} AS base | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
ENV PYTHONPATH=/lib \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Install python3 | ||
RUN apt-get update -qq && \ | ||
apt-get install -qq --no-install-recommends python3 python3-pip && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
FROM base AS build | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
ARG TARGETARCH | ||
ARG DEPTHAI_VERSION | ||
ARG ROBOTICS_VISION_CORE | ||
ARG DEPTHAI_VERSION | ||
ARG DEPTHAI_SDK_VERSION | ||
ARG ROBOTHUB_VERSION | ||
ARG VARIANT | ||
|
||
COPY install-depthai-from-git /tmp/ | ||
RUN /tmp/install-depthai-from-git ${DEPTHAI_VERSION} | ||
|
||
# Download patched libusb | ||
COPY download-patched-libusb /tmp/ | ||
RUN /tmp/download-patched-libusb ${TARGETARCH} | ||
|
||
# Install luxonis packages: depthai-sdk, robothub | ||
COPY install-luxonis-packages /tmp/ | ||
RUN /tmp/install-luxonis-packages ${ROBOTICS_VISION_CORE} ${ROBOTHUB_VERSION} ${DEPTHAI_SDK_VERSION} | ||
|
||
# Install python3 packages | ||
COPY requirements-${VARIANT}.txt /tmp/ | ||
RUN pip3 install --no-cache-dir --only-binary=:all: -r /tmp/requirements-${VARIANT}.txt | ||
|
||
FROM base | ||
|
||
ARG DEPTHAI_VERSION | ||
|
||
# Copy python3 packages | ||
COPY --from=build /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages | ||
|
||
# Install depthai | ||
COPY --from=build /lib/libusb-1.0.so /lib/libusb-1.0.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM ubuntu:22.04 AS base | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
ENV PYTHONPATH=/lib \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Install python3 | ||
RUN apt-get update -qq && \ | ||
apt-get install -qq --no-install-recommends python3 python3-pip && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
FROM base AS build | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
ARG TARGETARCH | ||
ARG DEPTHAI_VERSION | ||
|
||
# Install dependencies | ||
RUN apt-get update -qq && \ | ||
apt-get install -qq --no-install-recommends ca-certificates wget && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Download patched libusb | ||
COPY download-patched-libusb /tmp/ | ||
RUN /tmp/download-patched-libusb ${TARGETARCH} | ||
|
||
# Install depthai | ||
COPY install-depthai-from-git /usr/local/bin | ||
RUN install-depthai-from-git ${DEPTHAI_VERSION} | ||
|
||
# Install python3 packages | ||
COPY requirements-builtin-app.txt /tmp/ | ||
RUN pip3 install --no-cache-dir --only-binary=:all: -r /tmp/requirements-builtin-app.txt | ||
|
||
FROM base | ||
|
||
# Copy python3 packages | ||
COPY --from=build /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,105 @@ | ||
#!/bin/bash | ||
set -Eeux | ||
|
||
declare -a elems=( | ||
"rvc2 ubuntu:22.04 minimal" | ||
"rvc2 ubuntu:22.04 regular" | ||
"rvc2 ros:humble-ros-core minimal" | ||
"rvc2 ros:humble-ros-base regular" | ||
"rvc3 ubuntu:22.04 minimal" | ||
"rvc3 ubuntu:22.04 regular" | ||
"rvc3 ros:humble-ros-core minimal" | ||
"rvc3 ros:humble-ros-base regular" | ||
) | ||
declare -A versions | ||
CONFIG_FILE="scripts/versions.conf" | ||
if [ ! -f "${CONFIG_FILE}" ]; then | ||
echo "The file ${CONFIG_FILE} does not exist." | ||
exit 1 | ||
fi | ||
|
||
for elem in "${elems[@]}"; do | ||
# Define base parameters | ||
read -a strarr <<<"$elem" | ||
ROBOTICS_VISION_CORE=${strarr[0]} | ||
BASE_IMAGE=${strarr[1]} | ||
VARIANT=${strarr[2]} | ||
|
||
# Derive remaining parameters | ||
DEPTHAI_VERSION="" | ||
DEPTHAI_SDK_VERSION="" | ||
if [[ "${ROBOTICS_VISION_CORE}" == "rvc2" ]]; then | ||
DEPTHAI_VERSION="2.22.0.0.dev0+4f65e787340f0c83f8c03619d240bbb8af1260df" | ||
DEPTHAI_SDK_VERSION="1.12.1" | ||
elif [[ "${ROBOTICS_VISION_CORE}" == "rvc3" ]]; then | ||
DEPTHAI_VERSION="2.22.0.0.dev0+8b9eceb316ce60d57d9157ecec48534b548e8904" | ||
DEPTHAI_SDK_VERSION="d188eec84fded7ea10a3dc124db7da433a2a3578" | ||
else | ||
echo "Unknown ROBOTICS_VISION_CORE: ${ROBOTICS_VISION_CORE}" | ||
continue | ||
echo "Reading versions from ${CONFIG_FILE}..." | ||
while IFS='=' read -r key value; do | ||
versions[$key]=$value | ||
done < "${CONFIG_FILE}" | ||
|
||
# Define base parameters | ||
ROBOTHUB_VERSION="2.4.0" | ||
|
||
build_and_push_image() { | ||
local robotics_vision_core=$1 | ||
local base_image=$2 | ||
local variant=$3 | ||
local dockerfile=$4 | ||
|
||
IFS=',' read -r depthai_version depthai_sdk_version <<< "${versions[${robotics_vision_core}]}" | ||
if [ -z "${depthai_version}" ]; then | ||
echo "No version found for ${robotics_vision_core} in ${CONFIG_FILE}" | ||
return | ||
fi | ||
ROBOTHUB_VERSION="2.4.0" | ||
|
||
TAG="${BASE_TAG}-${ROBOTICS_VISION_CORE}-${VARIANT}" | ||
if [[ "${BASE_IMAGE}" == "ros:humble-ros-core" || "${BASE_IMAGE}" == "ros:humble-ros-base" ]]; then | ||
TAG="${TAG}-ros2humble" | ||
local tag="${BASE_TAG}-${robotics_vision_core}-${variant}" | ||
if [[ "${base_image}" == "ros:humble-ros-core" || "${base_image}" == "ros:humble-ros-base" ]]; then | ||
tag="${tag}-ros2humble" | ||
fi | ||
|
||
# Build | ||
echo "================================" | ||
echo "Building '${TAG}'..." | ||
echo "=> Depthai version: ${DEPTHAI_VERSION}" | ||
echo "=> Depthai SDK version: ${DEPTHAI_SDK_VERSION}" | ||
echo "Building '${tag}'..." | ||
echo "=> Depthai version: ${depthai_version}" | ||
echo "=> Depthai SDK version: ${depthai_sdk_version}" | ||
echo "=> RobotHub version: ${ROBOTHUB_VERSION}" | ||
echo "================================" | ||
|
||
LABELS=( | ||
"--label" "org.opencontainers.image.source=https://github.com/luxonis/robothub-images" | ||
"--label" "org.opencontainers.image.version=${tag}" | ||
"--label" "org.opencontainers.image.vendor=Luxonis" | ||
"--label" "org.opencontainers.image.ref.name=${IMAGE_REF_NAME}" | ||
"--label" "org.opencontainers.image.title=RobotHub App base image" | ||
"--label" "org.opencontainers.image.description=DepthAI version: ${depthai_version}" | ||
"--label" "com.luxonis.rh.depthai.version=${depthai_version}" | ||
"--label" "com.luxonis.rh.robothub.version=${ROBOTHUB_VERSION}" | ||
) | ||
|
||
BUILD_ARGS=( | ||
"--build-arg" "BASE_IMAGE=${base_image}" | ||
"--build-arg" "ROBOTICS_VISION_CORE=${robotics_vision_core}" | ||
"--build-arg" "DEPTHAI_SDK_VERSION=${depthai_sdk_version}" | ||
"--build-arg" "DEPTHAI_VERSION=${depthai_version}" | ||
"--build-arg" "ROBOTHUB_VERSION=${ROBOTHUB_VERSION}" | ||
"--build-arg" "VARIANT=${variant}" | ||
) | ||
|
||
# Check if the Robotics Vision Core version is not rvc2-depthaiV3 | ||
if [[ "${robotics_vision_core}" != "rvc2-depthaiV3" ]]; then | ||
LABELS+=("--label" "com.luxonis.rh.depthai-sdk.version=${depthai_sdk_version}") | ||
fi | ||
|
||
docker buildx build \ | ||
--build-arg "BASE_IMAGE=${BASE_IMAGE}" \ | ||
--build-arg "ROBOTICS_VISION_CORE=${ROBOTICS_VISION_CORE}" \ | ||
--build-arg "DEPTHAI_VERSION=${DEPTHAI_VERSION}" \ | ||
--build-arg "DEPTHAI_SDK_VERSION=${DEPTHAI_SDK_VERSION}" \ | ||
--build-arg "ROBOTHUB_VERSION=${ROBOTHUB_VERSION}" \ | ||
--build-arg "VARIANT=${VARIANT}" \ | ||
--label "org.opencontainers.image.source=https://github.com/luxonis/robothub-images" \ | ||
--label "org.opencontainers.image.version=${IMAGE_VERSION}" \ | ||
--label "org.opencontainers.image.vendor=Luxonis" \ | ||
--label "org.opencontainers.image.ref.name=${IMAGE_REF_NAME}" \ | ||
--label "org.opencontainers.image.title=RobotHub App base image" \ | ||
--label "org.opencontainers.image.description=DepthAI version: ${DEPTHAI_VERSION}" \ | ||
--label "com.luxonis.rh.depthai.version=${DEPTHAI_VERSION}" \ | ||
--label "com.luxonis.rh.depthai-sdk.version=${DEPTHAI_SDK_VERSION}" \ | ||
--label "com.luxonis.rh.robothub.version=${ROBOTHUB_VERSION}" \ | ||
--tag "${TAG}" \ | ||
--push \ | ||
--provenance=false \ | ||
--file dockerfiles/base.Dockerfile \ | ||
context/ | ||
"${BUILD_ARGS[@]}" \ | ||
"${LABELS[@]}" \ | ||
--tag "${tag}" \ | ||
--push \ | ||
--provenance=false \ | ||
--file "dockerfiles/${dockerfile}" \ | ||
context/ | ||
} | ||
|
||
# Define base parameters | ||
BASE_DOCKERFILE="base.Dockerfile" | ||
DEPTHAI_V3_DOCKERFILE_CONTEXT="depthai-v3-git" | ||
|
||
declare -a elems=( | ||
# RVC2 - DepthAI from registry: | ||
"rvc2 ubuntu:22.04 minimal ${BASE_DOCKERFILE}" | ||
"rvc2 ubuntu:22.04 regular ${BASE_DOCKERFILE}" | ||
"rvc2 ros:humble-ros-core minimal ${BASE_DOCKERFILE}" | ||
"rvc2 ros:humble-ros-base regular ${BASE_DOCKERFILE}" | ||
|
||
# RVC3 - DepthAI from registry: | ||
"rvc3 ubuntu:22.04 minimal ${BASE_DOCKERFILE}" | ||
"rvc3 ubuntu:22.04 regular ${BASE_DOCKERFILE}" | ||
"rvc3 ros:humble-ros-core minimal ${BASE_DOCKERFILE}" | ||
"rvc3 ros:humble-ros-base regular ${BASE_DOCKERFILE}" | ||
|
||
# RVC2 - DepthAI V3 - built from source: | ||
"rvc2-depthaiV3 ubuntu:22.04 minimal ${DEPTHAI_V3_DOCKERFILE_CONTEXT}/${BASE_DOCKERFILE}" | ||
"rvc2-depthaiV3 ubuntu:22.04 regular ${DEPTHAI_V3_DOCKERFILE_CONTEXT}/${BASE_DOCKERFILE}" | ||
"rvc2-depthaiV3 ros:humble-ros-core minimal ${DEPTHAI_V3_DOCKERFILE_CONTEXT}/${BASE_DOCKERFILE}" | ||
"rvc2-depthaiV3 ros:humble-ros-base regular ${DEPTHAI_V3_DOCKERFILE_CONTEXT}/${BASE_DOCKERFILE}" | ||
) | ||
|
||
for elem in "${elems[@]}"; do | ||
read -ra strarr <<<"$elem" | ||
build_and_push_image "${strarr[0]}" "${strarr[1]}" "${strarr[2]}" "${strarr[3]}" | ||
done |
Oops, something went wrong.