Skip to content

CMake build OCVWarp-ffmpeg with OpenCV 4.11 #1

CMake build OCVWarp-ffmpeg with OpenCV 4.11

CMake build OCVWarp-ffmpeg with OpenCV 4.11 #1

name: CMake build OCVWarp-ffmpeg with OpenCV 4.11
on: workflow_dispatch
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
# This yml is copied from https://github.com/hn-88/pan2fulldome/blob/main/.github/workflows/cmake.yml
# and modified.
BUILD_TYPE: Release
#PATH_TO_ARTIFACT: $GITHUB_WORKSPACE/build/pan2fulldome this does not seem to work
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: use the alternate CMakeLists.txt
# for building ocvwarp-ffmpeg.cpp
run: |
rm -v CMakeLists.txt
mv -vf CMakelists.txt.OCVWarp-ffmpeg CMakeLists.txt
- name: Install OpenCV dependencies
# We're using the latest release opencv build, currently 4.11.0
run: |
sudo apt-get update
# from https://medium.com/@redswitches/how-to-install-opencv-on-ubuntu-22-04-fe736d51c705
# https://github.com/orgs/community/discussions/113480
sudo apt-get remove libunwind-*
sudo apt-get install -y build-essential cmake git libgtk-3-dev pkg-config libavcodec-dev \
libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev openexr \
libatlas-base-dev libopenexr-dev libgstreamer-plugins-base1.0-dev \
libgstreamer1.0-dev python3-dev python3-numpy libtbb2 libtbb-dev \
libjpeg-dev libpng-dev libtiff-dev libdc1394-dev gfortran ffmpeg
# check if ffmpeg has nvenc support
ffmpeg -encoders | grep nvenc
- name: Cache OpenCV
id: cache-ocv
uses: actions/cache@v4
with:
path: opencv
key: ${{ runner.os }}-opencv-4.11.0
- name: Cache OpenCV-contrib
id: cache-ocv-contrib
uses: actions/cache@v4
with:
path: opencv_contrib
key: ${{ runner.os }}-opencv_contrib-4.11.0
- name: Build OpenCV if not cached
if: steps.cache-ocv.outputs.cache-hit != 'true'
run: |
git clone https://github.com/opencv/opencv.git --branch "4.11.0" --depth 1
git clone https://github.com/opencv/opencv_contrib.git --branch "4.11.0" --depth 1
# from https://github.com/Dovyski/setup-opencv-action/blob/master/index.js
cmake -S opencv -B opencv/build \
-D CMAKE_CXX_COMPILER="g++" \
-D CMAKE_INSTALL_PREFIX="/usr/local" \
-D WITH_FFMPEG=ON \
-D WITH_IPP=ON \
-D BUILD_NEW_PYTHON_SUPPORT=OFF \
-D WITH_V4L=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=./opencv_contrib/modules
make -j10 -C opencv/build
- name: Install OpenCV
run: |
sudo make -C opencv/build install
sudo ldconfig
- name: Configure CMake for OCVWarp
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Create appimage
working-directory: ${{github.workspace}}/build
# https://appimage-builder.readthedocs.io/en/latest/hosted-services/github-actions.html
# But instead using linuxdeployqt as in https://github.com/hn-88/OCVWarp/blob/master/.travis.yml
run: |
echo "create appimage"
sudo apt-get install -y libfuse2
mkdir -p appdir/usr/bin ; strip OCVWarp.bin ; cp OCVWarp.bin ./appdir/usr/bin/OCVWarp.bin
mkdir -p appdir/usr/share/applications ; cp ../appdir/OCVWarp.desktop ./appdir/usr/share/applications/
mkdir -p appdir/usr/share/icons/hicolor/256x256/apps ; cp ../appdir/OCVWarp.png ./appdir/usr/share/icons/hicolor/256x256/apps/
wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
export VERSION=$(git rev-parse --short HEAD) # linuxdeployqt uses this for naming the file
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -bundle-non-qt-libs
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -appimage
mv OCVWarp*.AppImage OCVWarp-5-testing.00-x86_64.AppImage -v
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: OCVWarp-appimage
# optional, default is artifact
# A file, directory or wildcard pattern that describes what to upload
path: build/OCVWarp*x86_64.AppImage