Skip to content

Commit

Permalink
feat: change split image with filter behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
4o3F committed Oct 5, 2024
1 parent 95de78a commit 48e7e64
Show file tree
Hide file tree
Showing 5 changed files with 353 additions and 275 deletions.
109 changes: 60 additions & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,71 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Builds for linux
# ubuntu-build:
# # The type of runner that the job will run on
# runs-on: ubuntu-latest
ubuntu-build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# # Steps represent a sequence of tasks that will be executed as part of the job
# steps:
# # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# - uses: actions/checkout@v3
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# # Install rust
# - name: Install rust
# run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# # Install opencv
# #- name: Install opencv
# # run: sudo apt install libopencv-dev clang libclang-dev
# Install rust
- name: Install rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# # Pull opencv source, unzip, configure cmake, build, and install
# # Disable image formats like jpeg, png, tiff, as we use rust image crate instead. See https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html
# # Inspired from https://github.com/twistedfall/opencv-rust/issues/364
# - name: Install OpenCV static lib
# run: |
# wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/4.8.1.zip
# wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.zip
# unzip opencv.zip && rm opencv.zip
# unzip opencv_contrib.zip && rm opencv_contrib.zip
# mkdir -p build && cd build
# cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=NO -DCMAKE_INSTALL_PREFIX=/opt/opencv -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_PNG=OFF -DWITH_JPEG=OFF -DWITH_TIFF=OFF -DWITH_WEBP=OFF -DWITH_OPENJPEG=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DWITH_V4L=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.8.1/modules ../opencv-4.8.1
# cmake --build . --target install --config Release --parallel 8
# cmake --install . --prefix /opt/opencv
# cd ..
# Install opencv
#- name: Install opencv
# run: sudo apt install libopencv-dev clang libclang-dev
- name: Cache OpenCV build
uses: actions/cache@v4
with:
path: |
/opt/opencv
key: ${{ runner.os }}-opencv-${{ hashFiles('**/CMakeLists.txt') }} # 使用 CMakeLists.txt 的哈希作为缓存键
restore-keys: |
${{ runner.os }}-opencv-
# Pull opencv source, unzip, configure cmake, build, and install
# Disable image formats like jpeg, png, tiff, as we use rust image crate instead. See https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html
# Inspired from https://github.com/twistedfall/opencv-rust/issues/364
- name: Install OpenCV static lib
run: |
wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/4.8.1.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.1.zip
unzip opencv.zip && rm opencv.zip
unzip opencv_contrib.zip && rm opencv_contrib.zip
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=NO -DCMAKE_INSTALL_PREFIX=/opt/opencv -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_WEBP=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DWITH_V4L=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.8.1/modules ../opencv-4.8.1
cmake --build . --target install --config Release --parallel 8
cmake --install . --prefix /opt/opencv
cd ..
# # Note: OPENCV_LINK_LIBS ordering matters for linux. Put lower level deps after higher level. See https://answers.opencv.org/question/186124/undefined-reference-to-cvsoftdoubleoperator/
# # libclang files are in /usr/lib/llvm-##/lib. We symlink it to one of the opencv_link_paths
# # OpenCV-rust looks for "opencv2/core/version.hpp" for the OpenCV version: https://github.com/twistedfall/opencv-rust/issues/368
# # which is under /<install-prefix>/include/opencv4 for linux
# # Build
# - name: Build
# run: |
# export OPENCV_LINK_LIBS="opencv_videoio,opencv_imgcodecs,opencv_imgproc,opencv_core,libippiw,libittnotify,libippicv,z"
# export OPENCV_LINK_PATHS=/opt/opencv/lib,/opt/opencv/lib/opencv4/3rdparty,/usr/lib/x86_64-linux-gnu
# export OPENCV_INCLUDE_PATHS=/opt/opencv/include,/opt/opencv/include/opencv4
# sudo ln -s /usr/lib/llvm-15/lib/libclang.so.1 /usr/lib/x86_64-linux-gnu/libclang.so
# ls -R /opt/opencv
# ls -R /usr/lib
# cargo build --release
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

# Note: OPENCV_LINK_LIBS ordering matters for linux. Put lower level deps after higher level. See https://answers.opencv.org/question/186124/undefined-reference-to-cvsoftdoubleoperator/
# libclang files are in /usr/lib/llvm-##/lib. We symlink it to one of the opencv_link_paths
# OpenCV-rust looks for "opencv2/core/version.hpp" for the OpenCV version: https://github.com/twistedfall/opencv-rust/issues/368
# which is under /<install-prefix>/include/opencv4 for linux
# Build
- name: Build
run: |
export OPENCV_LINK_LIBS="opencv_videoio,opencv_imgcodecs,opencv_imgproc,opencv_core,libippiw,libittnotify,libippicv,libippicvmt,zlib,IlmImf,libjpeg-turbo,libopenjp2,libpng,libtiff,libwebp"
export OPENCV_LINK_PATHS=/opt/opencv/lib,/opt/opencv/lib/opencv4/3rdparty,/usr/lib/x86_64-linux-gnu
export OPENCV_INCLUDE_PATHS=/opt/opencv/include,/opt/opencv/include/opencv4
sudo ln -s /usr/lib/llvm-15/lib/libclang.so.1 /usr/lib/x86_64-linux-gnu/libclang.so
ls -R /opt/opencv
ls -R /usr/lib
cargo build --release --target x86_64-unknown-linux-musl
# # Upload artifact: https://github.com/actions/upload-artifact
# - name: Upload Artifacts
# uses: actions/upload-artifact@v3
# with:
# name: imagetools
# path: target/release/imagetools
# retention-days: 14
# Upload artifact: https://github.com/actions/upload-artifact
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: imagetools
path: target/release/imagetools
retention-days: 14

windows-build:
# The type of runner that the job will run on
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ opencv = { version = "0.89.0", default-features = false, features = [
"imgproc",
"imgcodecs",
] }
# gdal = "0.17.0"
# gdal = "0.17"
itertools = "0.12.1"
clap = { version = "4.5.9", features = ["derive"] }
tracing-subscriber = "0.3.18"
Expand Down
Loading

0 comments on commit 48e7e64

Please sign in to comment.