Skip to content

Commit

Permalink
fix: use latest opencv on ubuntu (#2437)
Browse files Browse the repository at this point in the history
* fix: use latest opencv on ubuntu

* feat: add using opencv dockerfile

* trigger event

* remove test trigger

* use builded container

* rebuild image

* update build image

* debug

* swithc to root

* fix install dep

* fix source

* fix dependency

* fix dependency

* fix: dependency

* build new image version

* fix source

* fix: build errors

* fix: install dep

* fix: dependency

* fix: dependency

* fix dependency

* fix: remove sudo command

* fix dependency in doc

* fix: update opencv version

* fix: update opencv

* fix: decrease repetition

* try to use action

* use fixed version

* fix version format
  • Loading branch information
stepanLav authored Feb 19, 2025
1 parent ee365fd commit 815e593
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 84 deletions.
20 changes: 20 additions & 0 deletions .github/actions/install-android-dep/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Install Android Dependencies'
description: 'Sets up JDK and Android SDK/NDK'

runs:
using: "composite"
steps:
- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 12266719

- name: Install NDK
shell: bash
run: echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/16.0/bin/sdkmanager --install "ndk;24.0.8215888" --sdk_root=${ANDROID_SDK_ROOT}
31 changes: 11 additions & 20 deletions .github/workflows/android-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
build:
name: Build
runs-on: ubuntu-22.04
container:
image: ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
steps:

- name: Checkout Sources
Expand All @@ -26,7 +28,7 @@ jobs:
- name: Install System Dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install -y clang libclang-dev libopencv-dev
sudo apt-get install -y clang libclang-dev
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
Expand All @@ -40,15 +42,9 @@ jobs:

- name: Install additional rust targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android

- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17

- name: Install NDK
run: echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;24.0.8215888" --sdk_root=${ANDROID_SDK_ROOT}

- name: Install Android Dependencies
uses: ./.github/actions/install-android-dep

# - name: Rust Cache
# uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844 # v2.7.7
Expand All @@ -72,6 +68,8 @@ jobs:
makeapk:
name: Build unsigned APKs
runs-on: ubuntu-22.04
container:
image: ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
# if: github.ref == ' refs/head/main'
steps:

Expand All @@ -82,10 +80,9 @@ jobs:
submodules: 'recursive'

- name: Install System Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y clang libclang-dev libopencv-dev
sudo apt-get install -y clang libclang-dev
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
Expand All @@ -100,14 +97,8 @@ jobs:
- name: Install additional rust targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android

- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17

- name: Install NDK
run: echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;24.0.8215888" --sdk_root=${ANDROID_SDK_ROOT}
- name: Install Android Dependencies
uses: ./.github/actions/install-android-dep

# - name: Rust Cache
# uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844 # v2.7.7
Expand Down
28 changes: 10 additions & 18 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
build:
name: Build android unit test
runs-on: ubuntu-22.04
container:
image: ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
steps:

- name: Checkout Sources
Expand All @@ -22,7 +24,7 @@ jobs:
- name: Install System Dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install -y clang libclang-dev libopencv-dev
sudo apt-get install -y clang libclang-dev
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
Expand All @@ -37,14 +39,8 @@ jobs:
- name: Install additional rust targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android

- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17

- name: Install NDK
run: echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;24.0.8215888" --sdk_root=${ANDROID_SDK_ROOT}
- name: Install Android Dependencies
uses: ./.github/actions/install-android-dep

# - name: Rust Cache
# uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844 # v2.7.7
Expand All @@ -68,6 +64,8 @@ jobs:
make:
name: Build signed APKs
runs-on: ubuntu-22.04
container:
image: ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
# if: github.ref == ' refs/head/main'
steps:

Expand All @@ -80,7 +78,7 @@ jobs:
- name: Install System Dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install -y clang libclang-dev libopencv-dev
sudo apt-get install -y clang libclang-dev
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
Expand All @@ -95,14 +93,8 @@ jobs:
- name: Install additional rust targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android

- name: Set up JDK environment
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 17

- name: Install NDK
run: echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;24.0.8215888" --sdk_root=${ANDROID_SDK_ROOT}
- name: Install Android Dependencies
uses: ./.github/actions/install-android-dep

# - name: Rust Cache
# uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844 # v2.7.7
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ on:
jobs:
rustdocs_user_docs:
name: Build rustdocs, user-docs and check links
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container:
image: ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
steps:

- name: Checkout sources
Expand All @@ -26,7 +28,10 @@ jobs:
- name: Install rustdocs dependencies
run: |
sudo apt update
sudo apt install -y clang libclang-dev libopencv-dev
sudo apt install -y clang libclang-dev
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable

# - name: Rust Cache
# uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844 # v2.7.7
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/opencv-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build OpenCV Docker Image

on:
workflow_dispatch:
push:
paths:
- 'docker/opencv.Dockerfile'
branches:
- master

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/opencv.Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}/opencv-builder:latest
ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
6 changes: 4 additions & 2 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ on:
jobs:
linter:
name: Cargo clippy
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container:
image: ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
steps:

- name: Checkout sources
Expand All @@ -25,7 +27,7 @@ jobs:
- name: Install system dependancies
run: |
sudo apt update
sudo apt install -y clang libclang-dev libopencv-dev
sudo apt install -y clang libclang-dev
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/rust-test-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ on:
jobs:
check:
name: Cargo test on Ubuntu
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
container:
image: ghcr.io/${{ github.repository }}/opencv-builder:4.11.0
steps:

- name: Checkout sources
Expand All @@ -25,7 +27,7 @@ jobs:
- name: Install system dependancies
run: |
sudo apt update
sudo apt install -y clang libclang-dev libopencv-dev
sudo apt install -y clang libclang-dev
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
44 changes: 44 additions & 0 deletions docker/opencv.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM ghcr.io/catthehacker/ubuntu:rust-22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
libjpeg-dev \
libtiff-dev \
libpng-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libgtk-3-dev \
libatlas-base-dev \
gfortran \
python3-dev \
unzip \
wget \
cmake \
g++

WORKDIR /tmp

RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/4.11.0.zip && \
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.11.0.zip && \
unzip opencv.zip && \
unzip opencv_contrib.zip && \
cd opencv-4.11.0 && \
mkdir build && cd build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.11.0/modules \
-D BUILD_EXAMPLES=OFF .. && \
make -j2 && \
make install && \
ldconfig && \
cd /tmp && \
rm -rf opencv* && \
apt-get clean

WORKDIR /build
Loading

0 comments on commit 815e593

Please sign in to comment.