diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..554ad74 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,100 @@ +name: android +on: + push: + tags: + - "*" + pull_request: + branches: ["main"] +env: + ANDROID_PLATFORM: android-24 + FFMPEG_ROOT: /tmp/ffmpeg + +jobs: + android: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + abi: [armeabi-v7a, arm64-v8a, x86_64] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ + -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ + -DANDROID_PLATFORM=$ANDROID_PLATFORM \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DANDROID_STL=c++_static \ + -DANDROID_ABI=${{ matrix.abi }} \ + -DANDROID_ARM_NEON=ON \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + -DWITH_ANDROID_MEDIANDK=ON \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> "$GITHUB_ENV" + - name: setup ffmpeg + run: | + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/android/ffmpeg-6.1-android-lite.tar.xz + mkdir -p tmp + tar xf ffmpeg.tar.xz -C tmp --strip-components=1 + + mkdir -p $FFMPEG_ROOT + cp -rf tmp/include $FFMPEG_ROOT + cp -rf tmp/lib/${{ matrix.abi }} $FFMPEG_ROOT/lib + cp -rf tmp/bin/${{ matrix.abi }} $FFMPEG_ROOT/bin + cp -rf tmp/COPYING.LGPLv2.1 $FFMPEG_ROOT + cp -rf tmp/RELEASE_NOTES $FFMPEG_ROOT + + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ + + rm -rf tmp + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DFFMPEG_ARCH="${{ matrix.abi }}" + cmake --build . -j $(nproc) + cmake --build . --target install + + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DANDROID_ABI="${{ matrix.abi }}" \ + -DANDROID_ARM_NEON=ON \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/sdk/native/jni \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml new file mode 100644 index 0000000..a45550a --- /dev/null +++ b/.github/workflows/apple.yml @@ -0,0 +1,252 @@ +name: apple +# on: pull_request +on: + push: + tags: + - "*" + pull_request: + branches: ["main"] + +env: + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + IOS_DEPLOYMENT_TARGET: "11.0" + MAC_DEPLOYMENT_TARGET: "10.15" + ENABLE_BITCODE: OFF + ENABLE_ARC: OFF + ENABLE_VISIBILITY: OFF + FFMPEG_ROOT: /tmp/ffmpeg + +jobs: + ios: + runs-on: macos-14 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DBUILD_TIFF=OFF \ + -DBUILD_OPENJPEG=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_OPENCL_SVM=OFF \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-ios-arm64" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" + - name: setup ffmpeg + run: | + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz + mkdir -p $FFMPEG_ROOT + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=OS64 \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" + cmake --build . -j 4 + cmake --build . --target install + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=OS64 \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} + cmake --build . -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz + + ios-simulator: + runs-on: macos-14 + strategy: + matrix: + opencv-version: [4.10.0] + platform: + - { arch: x64, name: SIMULATOR64 } + - { arch: arm64, name: SIMULATORARM64 } + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DBUILD_TIFF=OFF \ + -DBUILD_OPENJPEG=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_OPENCL_SVM=OFF \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-iossimulator-${{ matrix.platform.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" + - name: setup ffmpeg + run: | + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz + mkdir -p $FFMPEG_ROOT + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=${{ matrix.platform.name }} \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON + cmake --build . -j 4 + cmake --build . --target install + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=${{ matrix.platform.name }} \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} + cmake --build . -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz + + macos: + strategy: + matrix: + opencv-version: [4.10.0] + osname: + - { os: macos-13, arch: x64, platform: MAC } + - { os: macos-14, arch: arm64, platform: MAC_ARM64 } + runs-on: ${{ matrix.osname.os }} + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=OFF \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-macos-${{ matrix.osname.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" + - name: setup ffmpeg + run: | + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-lite.tar.xz + mkdir -p $FFMPEG_ROOT + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=${{ matrix.osname.platform }} \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" + cmake --build . -j 4 + cmake --build . --target install + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} \ + .. + cmake --build . -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz diff --git a/.github/workflows/build_test_release.yaml b/.github/workflows/build_test_release.yaml deleted file mode 100644 index 4a3c22a..0000000 --- a/.github/workflows/build_test_release.yaml +++ /dev/null @@ -1,243 +0,0 @@ -name: build release - -on: - push: - tags: - - "*.*.*" - # branches: - # - main - pull_request: - branches: ["main"] - -env: - ANDROID_NDK_VERSION: r26c - -jobs: - build-android: - name: build-android - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - sudo apt-get update - - sudo apt-get install -y build-essential libgtk-3-dev ffmpeg libavcodec-dev \ - cmake ninja-build libavformat-dev libavutil-dev libswscale-dev \ - libgflags-dev python3 unzip tree python3-pip - - python3 -m pip install conan - conan profile detect -f - - cd ${{github.workspace}} - mkdir -p build/android - - wget -q -O build/android-ndk-$ANDROID_NDK_VERSION-linux.zip \ - https://dl.google.com/android/repository/android-ndk-$ANDROID_NDK_VERSION-linux.zip - unzip -q -o build/android-ndk-$ANDROID_NDK_VERSION-linux.zip -d build/ - - name: build-android - run: | - conan build . -b missing -pr:h profiles/android-x86_64 \ - -c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION" - conan build . -b missing -pr:h profiles/android-armv8 \ - -c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION" - conan build . -b missing -pr:h profiles/android-armv7 \ - -c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION" - - uses: actions/upload-artifact@v4 - name: upload-android-x86_64 - with: - path: build/publish/libopencv-android-x86_64.tar.gz - name: libopencv-android-x86_64.tar.gz - - - uses: actions/upload-artifact@v4 - name: upload-android-arm64-v8a - with: - path: build/publish/libopencv-android-arm64-v8a.tar.gz - name: libopencv-android-arm64-v8a.tar.gz - - - uses: actions/upload-artifact@v4 - name: upload-android-armeabi-v7a - with: - path: build/publish/libopencv-android-armeabi-v7a.tar.gz - name: libopencv-android-armeabi-v7a.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-android-arm64-v8a.tar.gz - build/publish/libopencv-android-armeabi-v7a.tar.gz - build/publish/libopencv-android-x86_64.tar.gz - - build-ubuntu: - name: build-ubuntu - runs-on: ubuntu-22.04 - - steps: - - name: setup - run: | - sudo apt-get update - sudo apt-get install -y curl git wget python3 unzip build-essential \ - libgtk-3-dev ffmpeg libavcodec-dev \ - cmake ninja-build libavformat-dev libavutil-dev \ - libswscale-dev libgflags-dev \ - libjpeg-dev libpng-dev libtiff-dev python3-pip - - python3 -m pip install conan - conan profile detect -f - - - uses: actions/checkout@v4 - with: - submodules: true - - name: build - run: | - conan build . -b missing -c tools.cmake.cmaketoolchain:generator=Ninja - - uses: actions/upload-artifact@v4 - name: upload-linux-x64 - with: - path: build/publish/libopencv-linux-x64.tar.gz - name: libopencv-linux-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-linux-x64.tar.gz - - build-windows: - name: build-windows - runs-on: windows-2019 - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - name: build - run: | - python3 -m pip install conan - conan profile detect -f - conan build . -b missing -s compiler.cppstd=20 - - uses: actions/upload-artifact@v4 - name: upload-windows-x64 - with: - path: build/publish/libopencv-windows-x64.tar.gz - name: libopencv-windows-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-windows-x64.tar.gz - build-macos: - name: build-macos - runs-on: macos-13 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - brew install --force --overwrite ninja ccache ffmpeg@6 nasm python@3.12 - brew link --overwrite ffmpeg@6 - brew link --overwrite python@3.12 - brew install --force --overwrite conan - conan profile detect -f - cd ${{github.workspace}} - - name: build - run: | - conan build . -b missing -c tools.cmake.cmaketoolchain:generator=Ninja - - - uses: actions/upload-artifact@v4 - name: upload-macos-x64 - with: - path: build/publish/libopencv-macos-x64.tar.gz - name: libopencv-macos-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-macos-x64.tar.gz - build-macos-arm64: - name: build-macos-arm64 - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - brew install --force --overwrite ninja ccache ffmpeg@6 conan - brew link --overwrite ffmpeg@6 - conan profile detect -f - cd ${{github.workspace}} - - name: build - run: | - conan build . -b missing -c tools.cmake.cmaketoolchain:generator=Ninja - ls -alh build/Macos - - - uses: actions/upload-artifact@v4 - name: upload-macos-arm64 - with: - path: build/publish/libopencv-macos-arm64.tar.gz - name: libopencv-macos-arm64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-macos-arm64.tar.gz - build-ios: - name: build-ios - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - brew install --force --overwrite ninja ccache ffmpeg@6 conan - conan profile detect -f - cd ${{github.workspace}} - - name: build - run: | - echo "tools.cmake.cmaketoolchain:user_toolchain=[\"`pwd`/profiles/ios.toolchain.cmake\"]" >> profiles/ios-armv8 - conan build . -b missing -pr:h profiles/ios-armv8 - - echo "tools.cmake.cmaketoolchain:user_toolchain=[\"`pwd`/profiles/ios.toolchain.cmake\"]" >> profiles/ios-x86_64 - conan build . -b missing -pr:h profiles/ios-x86_64 - - - uses: actions/upload-artifact@v4 - name: upload - with: - path: build/publish/libopencv-ios-arm64.tar.gz - name: libopencv-ios-arm64.tar.gz - - uses: actions/upload-artifact@v4 - name: upload x64 - with: - path: build/publish/libopencv-ios-x64.tar.gz - name: libopencv-ios-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-ios-arm64.tar.gz - build/publish/libopencv-ios-x64.tar.gz diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..b6d3a6a --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,160 @@ +name: linux +on: + push: + tags: + - "*" + pull_request: + branches: ["main"] + +env: + FFMPEG_ROOT: /tmp/ffmpeg + +jobs: + linux-x64: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + os: + - { arch: x64, ffmpeg_arch: amd64 } + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + steps: + - name: setup + run: | + sudo apt-get update + sudo apt-get install libgtk-3-dev + + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" + - name: setup ffmpeg + run: | + wget -q -O ffmpeg.tar.xz https://github.com/rainyl/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linux64-lgpl-shared-6.1.tar.xz + mkdir -p $FFMPEG_ROOT/cmake + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + ${{ env.TOOLCHAIN_FILE }} \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} \ + -DFFMPEG_DIR=$FFMPEG_ROOT/cmake .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz + + linux-arm64: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + os: + - { arch: arm64, ffmpeg_arch: arm64 } + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + steps: + - name: setup + run: | + sudo apt-get update + sudo apt-get install g++-aarch64-linux-gnu + + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" + - name: setup ffmpeg + run: | + wget -q -O ffmpeg.tar.xz https://github.com/rainyl/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linuxarm64-lgpl-shared-6.1.tar.xz + mkdir -p $FFMPEG_ROOT/cmake + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} \ + -DFFMPEG_DIR=$FFMPEG_ROOT/cmake .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 0000000..610bc28 --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,169 @@ +name: wasm +# on: pull_request +on: + push: + tags: + - '*' + # pull_request: + # branches: ["main"] + +env: + EMSCRIPTEN_VERSION: 3.1.28 + +permissions: + contents: read + +jobs: + webassembly: + runs-on: ubuntu-20.04 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - uses: actions/checkout@v4 + - name: emsdk + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install $EMSCRIPTEN_VERSION + ./emsdk activate $EMSCRIPTEN_VERSION + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-webassembly" >> $GITHUB_ENV + - name: build + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + # patch -p1 -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-simd + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + mkdir build-simd && cd build-simd + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-threads + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + # patch -p1 -R -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + mkdir build-threads && cd build-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-simd-threads + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + mkdir build-simd-threads && cd build-simd-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + rm -rf ${{ env.PACKAGE_NAME }} + mkdir -p ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install ${{ env.PACKAGE_NAME }}/basic + cp -rf ${{ env.SOURCE_DIR }}/build-simd/install ${{ env.PACKAGE_NAME }}/simd + cp -rf ${{ env.SOURCE_DIR }}/build-threads/install ${{ env.PACKAGE_NAME }}/threads + cp -rf ${{ env.SOURCE_DIR }}/build-simd-threads/install ${{ env.PACKAGE_NAME }}/simd-threads + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/basic/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-simd + run: | + cd test + mkdir build-simd && cd build-simd + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-threads + run: | + cd test + mkdir build-threads && cd build-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/threads/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-simd-threads + run: | + cd test + mkdir build-simd-threads && cd build-simd-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd-threads/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + release: + permissions: + contents: write # for softprops/action-gh-release to create a release + needs: [webassembly] + runs-on: ubuntu-latest + steps: + - name: download + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: create-release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + token: ${{ secrets.GITHUB_TOKEN }} + files: artifacts/*/*.zip diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..4002830 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,174 @@ +name: windows +on: + push: + tags: + - "*" + pull_request: + branches: ["main"] + +env: + FFMPEG_ROOT: ${{ github.workspace }}/ffmpeg + +jobs: + windows: + strategy: + matrix: + opencv-version: [4.10.0] + os: + - { arch: x64, toolset-version: v142 } + runs-on: windows-2019 + env: + UseMultiToolTask: true + COMMON_CMAKE_OPTIONS: | + $(type ${{ github.workspace }}/options.txt) ` + -T ${{ matrix.os.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" ` + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` + -A x64 ` + -DCMAKE_SYSTEM_NAME=Windows ` + -DFFMPEG_ARCH=${{ matrix.os.arch }} ` + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + - name: download ffmpeg + uses: robinraju/release-downloader@v1.10 + with: + repository: "rainyl/FFmpeg-Builds" + latest: true + fileName: "ffmpeg-n6.1-latest-win64-lgpl-shared-6.1.zip" + out-file-path: 'ffmpeg_tmp' + extract: true + - name: setup ffmpeg + run: | + ls ffmpeg_tmp + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + mkdir -Force $env:FFMPEG_ROOT/cmake + Move-Item -Force ffmpeg_tmp\*\* $env:FFMPEG_ROOT + cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build + cd ${{ env.SOURCE_DIR }}/build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" + cmake --build . --config Release --target install -j 4 + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build\install\*" -Destination "${{ env.PACKAGE_NAME }}" + cp -Force $env:FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build; cd build + cmake -T ${{ matrix.os.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -A x64 ` + -DOpenCV_DIR="${{ github.workspace }}\${{ env.PACKAGE_NAME }}" ` + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` + -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz + + windows-arm64: + strategy: + matrix: + opencv-version: [4.10.0] + os: + - { arch: arm64, toolset-version: v142 } + runs-on: windows-2019 + env: + UseMultiToolTask: true + COMMON_CMAKE_OPTIONS: | + $(type ${{ github.workspace }}/options.txt) ` + -T ${{ matrix.os.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" ` + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` + -A ARM64 ` + -DCMAKE_SYSTEM_NAME=Windows ` + -DCMAKE_SYSTEM_PROCESSOR=ARM64 ` + -DFFMPEG_ARCH=${{ matrix.os.arch }} ` + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + - name: download ffmpeg + uses: robinraju/release-downloader@v1.10 + with: + repository: "rainyl/FFmpeg-Builds" + latest: true + fileName: "ffmpeg-n6.1-latest-winarm64-lgpl-shared-6.1.zip" + out-file-path: 'ffmpeg_tmp' + extract: true + - name: setup ffmpeg + run: | + ls ffmpeg_tmp + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + mkdir -Force $env:FFMPEG_ROOT/cmake + Move-Item -Force ffmpeg_tmp\*\* $env:FFMPEG_ROOT + cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build + cd ${{ env.SOURCE_DIR }}/build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` + -DWITH_IPP=OFF ` + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" + cd ${{ env.SOURCE_DIR }}/build + cmake --build . --config Release --target install -j 4 + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build\install\*" -Destination "${{ env.PACKAGE_NAME }}" + cp -Force $env:FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build; cd build + cmake -T ${{ matrix.os.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -A ARM64 ` + -DOpenCV_DIR="${{ github.workspace }}\${{ env.PACKAGE_NAME }}" ` + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` + -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz diff --git a/.gitignore b/.gitignore index 31f95aa..4161c9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ build*/ test/ +ffmpeg* +opencv/ +opencv_contrib/ # Prerequisites *.d .vscode diff --git a/README.md b/README.md index 6b68f9a..8d3c5a6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # opencv.full Prebuilt opencv static library for opencv_dart to speedup compile + +## Acknowledgement + +- prbuilt ffmpeg for android macos ios are from avbuild (https://github.com/wang-bin/avbuild) +- prebuilt ffmpeg for linux and windows are from https://github.com/BtbN/FFmpeg-Builds +- https://github.com/obsproject/obs-studio/blob/master/cmake/finders/FindFFmpeg.cmake +- https://github.com/Kitware/VTK/blob/master/CMake/FindFFMPEG.cmake diff --git a/cmake/aarch64-linux-gnu.toolchain.cmake b/cmake/aarch64-linux-gnu.toolchain.cmake new file mode 100644 index 0000000..b9b9f6c --- /dev/null +++ b/cmake/aarch64-linux-gnu.toolchain.cmake @@ -0,0 +1,16 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc") +set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv8-a") +set(CMAKE_CXX_FLAGS "-march=armv8-a") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") diff --git a/cmake/arm-linux-gnueabi.toolchain.cmake b/cmake/arm-linux-gnueabi.toolchain.cmake new file mode 100644 index 0000000..b9e1881 --- /dev/null +++ b/cmake/arm-linux-gnueabi.toolchain.cmake @@ -0,0 +1,16 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(CMAKE_C_COMPILER "arm-linux-gnueabi-gcc") +set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4") +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") diff --git a/cmake/arm-linux-gnueabihf.toolchain.cmake b/cmake/arm-linux-gnueabihf.toolchain.cmake new file mode 100644 index 0000000..74ed5bf --- /dev/null +++ b/cmake/arm-linux-gnueabihf.toolchain.cmake @@ -0,0 +1,16 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc") +set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon") +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake new file mode 100644 index 0000000..70e4868 --- /dev/null +++ b/cmake/ffmpeg-config.cmake @@ -0,0 +1,475 @@ +#[=======================================================================[.rst +FindFFMPEG +---------- + +FindModule for FFMPEG and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Components +^^^^^^^^^^ + +.. versionadded:: 1.0 + +This module contains provides several components: + +``avcodec`` +``avdevice`` +``avfilter`` +``avformat`` +``avutil`` +``postproc`` +``swscale`` +``swresample`` + +Import targets exist for each component. + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` targets: + +``FFMPEG::avcodec`` + AVcodec component + +``FFMPEG::avdevice`` + AVdevice component + +``FFMPEG::avfilter`` + AVfilter component + +``FFMPEG::avformat`` + AVformat component + +``FFMPEG::avutil`` + AVutil component + +``FFMPEG::postproc`` + postproc component + +``FFMPEG::swscale`` + SWscale component + +``FFMPEG::swresample`` + SWresample component + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``FFMPEG_FOUND`` + True, if all required components and the core library were found. +``FFMPEG_VERSION`` + Detected version of found FFMPEG libraries. +``FFMPEG_INCLUDE_DIRS`` + Include directories needed for FFMPEG. +``FFMPEG_LIBRARIES`` + Libraries needed to link to FFMPEG. +``FFMPEG_DEFINITIONS`` + Compiler flags required for FFMPEG. + +``FFMPEG__VERSION`` + Detected version of found FFMPEG component library. +``FFMPEG__INCLUDE_DIRS`` + Include directories needed for FFMPEG component. +``FFMPEG__LIBRARIES`` + Libraries needed to link to FFMPEG component. +``FFMPEG__DEFINITIONS`` + Compiler flags required for FFMPEG component. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``FFMPEG__LIBRARY`` + Path to the library component of FFMPEG. +``FFMPEG__INCLUDE_DIR`` + Directory containing ``.h``. + +#]=======================================================================] + +option(FFMPEG_USE_STATIC_LIBS "Use static libs (only for windows now)" ON) + +include(FindPackageHandleStandardArgs) + +if(NOT DEFINED FFMPEG_ROOT) + get_filename_component(FFMPEG_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +endif() + +# some builds have multiple architectures like `lib/arm64` +if(NOT DEFINED FFMPEG_ARCH) + message(STATUS "FFMPEG_ARCH not defined, set to: ${CMAKE_SYSTEM_PROCESSOR}") + string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} FFMPEG_ARCH) +endif() + +message(STATUS "FFMPEG_ROOT: ${FFMPEG_ROOT}") +message(STATUS "FFMPEG_ARCH: ${FFMPEG_ARCH}") + +# https://stackoverflow.com/a/46057018/18539998 +if(ANDROID) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) +endif() + +set( + _DEFAULT_COMPONENTS + avcodec + avdevice + avformat + avfilter + avresample + avutil + postproc + swscale + swresample +) + +# set(FFMPEG_FIND_COMPONENTS +# avcodec +# avformat +# avutil +# swscale +# ) + +set(component_avcodec libavcodec avcodec avcodec.h) +set(component_avdevice libavdevice avdevice avdevice.h) +set(component_avformat libavformat avformat avformat.h) +set(component_avfilter libavfilter avfilter avfilter.h) +set(component_avresample libavresample avresample avresample.h) +set(component_avutil libavutil avutil avutil.h) +set(component_postproc libpostproc postproc postprocess.h) +set(component_swscale libswscale swscale swscale.h) +set(component_swresample libswresample swresample swresample.h) + +if(NOT FFMPEG_FIND_COMPONENTS) + set(FFMPEG_FIND_COMPONENTS ${_DEFAULT_COMPONENTS}) +endif() + +# ffmpeg_find_component: Find and set up requested FFMPEG component +macro(ffmpeg_find_component component) + list(GET component_${component} 0 component_libname) + list(GET component_${component} 1 component_name) + list(GET component_${component} 2 component_header) + + if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + find_package(PkgConfig) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${FFMPEG_ROOT}/lib/pkgconfig") + + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_FFMPEG_${component} QUIET ${component_libname}) + endif() + endif() + + find_path( + FFMPEG_${component}_INCLUDE_DIR + NAMES ${component_libname}/${component_header} ${component_libname}/version.h + HINTS ${PC_FFMPEG_${component}_INCLUDE_DIRS} + PATHS + "${FFMPEG_ROOT}/include" + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include # Fink + /opt/local/include # DarwinPorts + /opt/csw/include # Blastwave + /opt/include + /usr/freeware/include + DOC "FFMPEG component ${component_name} include directory" + ) + + ffmpeg_check_version() + + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + find_library( + FFMPEG_${component}_IMPLIB + NAMES ${component_libname} ${component_name} + HINTS ${FFMPEG_ROOT}/lib + PATHS + ${FFMPEG_ROOT}/lib/${FFMPEG_ARCH} + DOC "FFMPEG component ${component_name} import library location" + ) + + if(FFMPEG_USE_STATIC_LIBS) + set(FFMPEG_${component}_LIBRARY "${FFMPEG_${component}_IMPLIB}") + else() + ffmpeg_find_dll() + endif() + + else() + find_library( + FFMPEG_${component}_LIBRARY + NAMES ${component_libname} ${component_name} + HINTS ${PC_FFMPEG_${component}_LIBRARY_DIRS} + PATHS + "${FFMPEG_ROOT}/lib" + "${FFMPEG_ROOT}/lib/${FFMPEG_ARCH}" + ~/Library/Frameworks + /Library/Frameworks + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib64 + "${FFMPEG_ROOT}/bin" + "${FFMPEG_ROOT}/bin/${FFMPEG_ARCH}" + DOC "FFMPEG component ${component_name} location" + ) + endif() + + if(FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) + set(FFMPEG_${component}_FOUND TRUE) + set(FFMPEG_${component}_LIBRARIES ${${_library_var}}) + set(FFMPEG_${component}_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR}) + set(FFMPEG_${component}_DEFINITIONS ${PC_FFMPEG_${component}_CFLAGS_OTHER}) + mark_as_advanced(FFMPEG_${component}_LIBRARY FFMPEG_${component}_INCLUDE_DIR FFMPEG_${component}_IMPLIB) + endif() + + message(DEBUG "[FindFFMPEG]: ${component_name}:") + message(DEBUG "[FindFFMPEG]: LIBRARY: ${FFMPEG_${component}_LIBRARY}") + message(DEBUG "[FindFFMPEG]: IMPLIB: ${FFMPEG_${component}_IMPLIB}") + message(DEBUG "[FindFFMPEG]: INCLUDE: ${FFMPEG_${component}_INCLUDE_DIR}") + message(DEBUG "[FindFFMPEG]: DEFINITIONS: ${FFMPEG_${component}_DEFINITIONS}") + message(DEBUG "[FindFFMPEG]: FFMPEG_${component}_VERSION: ${FFMPEG_${component}_VERSION}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_VERSION: ${PC_FFMPEG_${component}_VERSION}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_INCLUDE_DIRS: ${PC_FFMPEG_${component}_INCLUDE_DIRS}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_LIBRARY_DIRS: ${PC_FFMPEG_${component}_LIBRARY_DIRS}") +endmacro() + +# ffmpeg_find_dll: Macro to find DLL for corresponding import library +macro(ffmpeg_find_dll) + cmake_path(GET FFMPEG_${component}_IMPLIB PARENT_PATH _implib_path) + cmake_path(SET _bin_path NORMALIZE "${FFMPEG_ROOT}/bin") + + string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" _dll_version "${FFMPEG_${component}_VERSION}") + + find_program( + FFMPEG_${component}_LIBRARY + NAMES ${component_name}-${_dll_version}.dll + HINTS ${_implib_path} ${_bin_path} + DOC "FFMPEG component ${component_name} DLL location" + ) + + if(NOT FFMPEG_${component}_LIBRARY) + set(FFMPEG_${component}_LIBRARY "${FFMPEG_${component}_IMPLIB}") + endif() + + unset(_implib_path) + unset(_bin_path) + unset(_dll_version) +endmacro() + +# ffmpeg_check_version: Macro to help extract version number from FFMPEG headers +macro(ffmpeg_check_version) + if(PC_FFMPEG_${component}_VERSION) + set(FFMPEG_${component_libname}_VERSION ${PC_FFMPEG_${component}_VERSION}) + elseif(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/${component_libname}/version.h") + # get major version from version_major if version_major.h exists + if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + else() + # otherwise get major version from version.h + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + endif() + + # get major version + file( + STRINGS + ${_major_version_file} + _version_string + REGEX "^.*VERSION_MAJOR[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") + + # get minor and micro version + file( + STRINGS + "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h" + _version_string + REGEX "^.*VERSION_(MINOR|MICRO)[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") + string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") + + if(NOT _version_major STREQUAL "" AND NOT _version_minor STREQUAL "" AND NOT _version_micro STREQUAL "") + set(FFMPEG_${component}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + set(FFMPEG_${component_libname}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + message(DEBUG "[FindFFMPEG]: found ${component}: ${_version_major}.${_version_minor}.${_version_micro}") + else() + message(AUTHOR_WARNING "Failed to find ${component_name} version.") + endif() + + unset(_version_major) + unset(_version_minor) + unset(_version_micro) + unset(_version_string) + unset(_major_version_file) + else() + if(NOT FFMPEG_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find ${component_name} version.") + endif() + + # set(FFMPEG_${component_libname}_VERSION 0.0.0) + endif() +endmacro() + +# ffmpeg_set_soname: Set SONAME property on imported library targets +macro(ffmpeg_set_soname) + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") + execute_process( + COMMAND sh -c "otool -D '${FFMPEG_${component}_LIBRARY}' | grep -v '${FFMPEG_${component}_LIBRARY}'" + OUTPUT_VARIABLE _output + RESULT_VARIABLE _result + ) + + if(_result EQUAL 0 AND _output MATCHES "^@rpath/") + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_output}") + endif() + elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD") + execute_process( + COMMAND sh -c "objdump -p '${FFMPEG_${component}_LIBRARY}' | grep SONAME" + OUTPUT_VARIABLE _output + RESULT_VARIABLE _result + ) + + if(_result EQUAL 0) + string(REGEX REPLACE "[ \t]+SONAME[ \t]+([^ \t]+)" "\\1" _soname "${_output}") + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_soname}") + unset(_soname) + endif() + endif() + + unset(_output) + unset(_result) +endmacro() + +macro(ffmpeg_create_target component) + if(FFMPEG_${component}_FOUND AND NOT TARGET FFMPEG::${component}) + if(IS_ABSOLUTE "${FFMPEG_${component}_LIBRARY}") + if(DEFINED FFMPEG_${component}_IMPLIB) + if(FFMPEG_${component}_IMPLIB STREQUAL FFMPEG_${component}_LIBRARY) + add_library(FFMPEG::${component} STATIC IMPORTED) + else() + add_library(FFMPEG::${component} SHARED IMPORTED) + set_target_properties( + FFMPEG::${component} + PROPERTIES + IMPORTED_IMPLIB "${FFMPEG_${component}_IMPLIB}" + ) + endif() + else() + add_library(FFMPEG::${component} UNKNOWN IMPORTED) + ffmpeg_set_soname() + endif() + + set_target_properties( + FFMPEG::${component} + PROPERTIES + IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}" + ) + else() + add_library(FFMPEG::${component} INTERFACE IMPORTED) + set_target_properties( + FFMPEG::${component} + PROPERTIES + IMPORTED_LIBNAME "${FFMPEG_${component}_LIBRARY}" + ) + endif() + + set_target_properties( + FFMPEG::${component} + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_FFMPEG_${component}_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" + VERSION ${FFMPEG_${component_libname}_VERSION} + ) + + # get_target_property(_ffmpeg_interface_libraries FFMPEG::FFMPEG INTERFACE_LINK_LIBRARIES) + + # if(NOT FFMPEG::${component} IN_LIST _ffmpeg_interface_libraries) + # set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) + # endif() + endif() +endmacro() + +foreach(component IN LISTS FFMPEG_FIND_COMPONENTS) + if(NOT component IN_LIST _DEFAULT_COMPONENTS) + message(FATAL_ERROR "Unknown FFMPEG component specified: ${component}.") + endif() + + if(NOT FFMPEG_${component}_FOUND) + ffmpeg_find_component(${component}) + endif() + + if(FFMPEG_${component}_FOUND) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_${component}_LIBRARY}) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${FFMPEG_${component}_DEFINITIONS}) + set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} ${FFMPEG_${component}_INCLUDE_DIR}) + endif() +endforeach() + +if(NOT FFMPEG_avutil_FOUND) + ffmpeg_find_component(avutil) +endif() + +if(EXISTS "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h") + file( + STRINGS + "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h" + _version_string + REGEX "FFMPEG_VERSION" + ) + string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_version_string}") +endif() + +unset(_version_string) + +message(STATUS "FFMPEG_VERSION: ${FFMPEG_VERSION}") + +list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) +list(REMOVE_DUPLICATES FFMPEG_LIBRARIES) +list(REMOVE_DUPLICATES FFMPEG_DEFINITIONS) + +if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin|Windows") + set(FFMPEG_ERROR_REASON "Ensure that obs-deps is provided as part of CMAKE_PREFIX_PATH.") +elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD") + set(FFMPEG_ERROR_REASON "Ensure that required FFMPEG libraries are installed on the system.") +endif() + +find_package_handle_standard_args( + FFMPEG + REQUIRED_VARS FFMPEG_ROOT FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS + VERSION_VAR FFMPEG_VERSION + HANDLE_COMPONENTS + REASON_FAILURE_MESSAGE "${FFMPEG_ERROR_REASON}" +) + +if(FFMPEG_FOUND AND NOT TARGET FFMPEG::FFMPEG) + add_library(FFMPEG::FFMPEG INTERFACE IMPORTED) + + foreach(component IN LISTS FFMPEG_FIND_COMPONENTS) + ffmpeg_create_target(${component}) + + if(FFMPEG_${component}_FOUND) + set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) + endif() + endforeach() +endif() + +include(FeatureSummary) +set_package_properties( + FFMPEG + PROPERTIES + URL "https://www.ffmpeg.org" + DESCRIPTION "A complete, cross-platform solution to record, convert and stream audio and video." +) diff --git a/profiles/ios.toolchain.cmake b/cmake/ios.toolchain.cmake similarity index 100% rename from profiles/ios.toolchain.cmake rename to cmake/ios.toolchain.cmake diff --git a/cmake/riscv64-unknown-linux-musl.toolchain.cmake b/cmake/riscv64-unknown-linux-musl.toolchain.cmake new file mode 100644 index 0000000..27ab640 --- /dev/null +++ b/cmake/riscv64-unknown-linux-musl.toolchain.cmake @@ -0,0 +1,34 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR riscv64) +set(C906 True) + +if(DEFINED ENV{RISCV_ROOT_PATH}) + file(TO_CMAKE_PATH $ENV{RISCV_ROOT_PATH} RISCV_ROOT_PATH) +else() + message(FATAL_ERROR "RISCV_ROOT_PATH env must be defined") +endif() + +set(RISCV_ROOT_PATH ${RISCV_ROOT_PATH} CACHE STRING "root path to riscv toolchain") + +set(CMAKE_C_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-gcc") +set(CMAKE_CXX_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-g++") + +set(CMAKE_FIND_ROOT_PATH "${RISCV_ROOT_PATH}/riscv64-unknown-linux-musl") + +set(CMAKE_SYSROOT "${RISCV_ROOT_PATH}/sysroot") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +set(CMAKE_C_FLAGS "-march=rv64gcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c906") +set(CMAKE_CXX_FLAGS "-march=rv64gcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c906") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") + +# export RISCV_ROOT_PATH=/home/nihui/osd/host-tools/gcc/riscv64-linux-musl-x86_64 + +# cmake -DCMAKE_TOOLCHAIN_FILE=../../toolchains/riscv64-unknown-linux-musl.toolchain.cmake -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release `cat ../../opencv4_cmake_options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index ab5eb65..0000000 --- a/conanfile.py +++ /dev/null @@ -1,467 +0,0 @@ -import os -from conan import ConanFile -from conan.api.output import ConanOutput, Color -from conan.errors import ConanInvalidConfiguration, ConanException -from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain, CMakeDeps -from conan.tools.files import chdir, mkdir, copy -from conan.tools.scm import Git -from conan.tools.microsoft import is_msvc, is_msvc_static_runtime -import tarfile -from pathlib import Path - -OPENCV_VERSION = "4.10.0" - -# for compatibility -arch_map = { - "windows": { - "x86_64": "x64", - }, - "linux": { - "x86_64": "x64", - }, - "android": { - "x86_64": "x86_64", - "armv8": "arm64-v8a", - "armv7": "armeabi-v7a", - }, - "macos": { - "x86_64": "x64", - "armv8": "arm64", - }, - "ios": { - "x86_64": "x64", - "armv8": "arm64", - }, -} - -# (name, enabled) -OCV_MODULES = { - "calib3d": True, - "dnn": True, - "features2d": True, - "flann": True, - "gapi": True, # not implemented - "highgui": True, - "imgcodecs": True, - "imgproc": True, - "ml": True, # not implemented - "objdetect": True, - "photo": True, - "stitching": True, - "video": True, - "videoio": True, - # contrib - "aruco": True, - "img_hash": True, - # not implemented - "wechat_qrcode": True, - "bgsegm": True, - "bioinspired": False, - "ccalib": True, - "dnn_objdetect": True, - "dnn_superres": True, - "dpm": False, - "face": True, - "fuzzy": False, - "hfs": False, - "intensity_transform": False, - "line_descriptor": False, - "mcc": False, - "optflow": False, - "phase_unwrapping": False, - "plot": False, - "rapid": False, - "reg": False, - "rgbd": False, - "saliency": False, - "shape": False, - "signal": False, - "stereo": False, - "structured_light": False, - "superres": True, - "surface_matching": False, - "tracking": False, - "videostab": False, - "xfeatures2d": True, - "ximgproc": True, - "xobjdetect": True, - "xphoto": True, - "alphamat": False, - "cannops": False, - "cudaarithm": False, - "cudabgsegm": False, - "cudacodec": False, - "cudafeatures2d": False, - "cudafilters": False, - "cudaimgproc": False, - "cudalegacy": False, - "cudaobjdetect": False, - "cudaoptflow": False, - "cudastereo": False, - "cudawarping": False, - "cudev": False, - "cvv": False, - "freetype": False, - "hdf": False, - "java": False, - "julia": False, - "matlab": False, - "ovis": False, - "python2": False, - "python3": False, - "sfm": False, - "ts": False, - "viz": False, - "quality":True, -} - - -class OcvDartDesktop(ConanFile): - name = "opencv" - settings = "os", "compiler", "build_type", "arch" - # generators = "CMakeToolchain", "CMakeDeps" - options = { - "build_opencv": [True, False], - "shared": [True, False], - "with_cuda": [True, False], - "with_cublas": [True, False], - "with_cufft": [True, False], - "with_cudnn": [True, False], - "with_eigen": [True, False], - "with_opencl": [True, False], - "with_openvino": [True, False], - "with_obsensor": [True, False], - "with_ipp": [False, "intel-ipp", "opencv-icv"], - "with_protobuf": [True, False], - "with_vulkan": [True, False], - # imgcodecs module options - "with_avif": [True, False], - "with_jpeg": [False, "libjpeg", "libjpeg-turbo", "mozjpeg"], - "with_png": [True, False], - "with_tiff": [True, False], - "with_jpeg2000": [False, "jasper", "openjpeg"], - "with_openexr": [True, False], - "with_webp": [True, False], - "with_gdal": [True, False], - "with_gdcm": [True, False], - "with_imgcodec_hdr": [True, False], - "with_imgcodec_pfm": [True, False], - "with_imgcodec_pxm": [True, False], - "with_imgcodec_sunraster": [True, False], - "with_msmf": [True, False], - "with_msmf_dxva": [True, False], - # objdetect module options - "with_quirc": [True, False], - # videoio module options - "with_ffmpeg": [True, False], - "with_openni2": [True, False], - "with_v4l": [True, False], - # text module options - "with_tesseract": [True, False], - "with_gtk": [True, False], - "nonfree": [True, False], - } - options.update({k: [True, False] for k in OCV_MODULES}) - default_build_options = { - "ffmpeg/*:with_vaapi": False, - "ffmpeg/*:with_vdpau": False, - "ffmpeg/*:with_xcb": False, - "pulseaudio/*:with_x11": False, - } - default_options = { - "ffmpeg/*:with_vaapi": False, - "ffmpeg/*:with_vdpau": False, - "ffmpeg/*:with_xcb": False, - "build_opencv": True, - "shared": False, - "with_cuda": False, - "with_cublas": False, - "with_cufft": False, - "with_cudnn": False, - "with_eigen": False, - "with_opencl": True, - "with_openvino": False, - "with_obsensor": False, - "with_ipp": "opencv-icv", - "with_protobuf": True, - "with_vulkan": True, - # imgcodecs module options - "with_avif": False, - "with_jpeg": "libjpeg-turbo", - "with_png": True, - "with_tiff": True, - "with_jpeg2000": "openjpeg", - "with_openexr": True, - "with_webp": True, - "with_gdal": False, - "with_gdcm": False, - "with_imgcodec_hdr": True, - "with_imgcodec_pfm": True, - "with_imgcodec_pxm": True, - "with_imgcodec_sunraster": True, - "with_msmf": True, - "with_msmf_dxva": True, - # objdetect module options - "with_quirc": True, - # videoio module options - "with_ffmpeg": True, - "with_openni2": False, - "with_v4l": True, - # text module options - "with_tesseract": False, - "with_gtk": True, - "nonfree": False, - } - default_options.update(OCV_MODULES) - - opencv_repo: str - opencv_contrib_repo: str - - def __init__(self, display_name=""): - super().__init__(display_name) - - self.version = OPENCV_VERSION - - def generate(self): - tc: CMakeToolchain = CMakeToolchain(self) - if self.settings.os == "iOS": - platform_map = { - "armv8": "OS64", - "x86_64": "SIMULATOR64", - # TODO: maybe need a conf var to support "SIMULATORARM64" and more - } - platform = platform_map[str(self.settings.arch)] - block = tc.blocks["user_toolchain"] - block.template = ( - f"set(PLATFORM {platform})\n" - "set(ENABLE_ARC FALSE)\n" - "set(ENABLE_BITCODE FALSE)\n" - f"{block.template}" - ) - # tc.variables["CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM"] = "rainyl" - # tc.variables["CODE_SIGNING_ALLOWED"] = "NO" - tc.variables["BUILD_CUDA_STUBS"] = False - tc.variables["BUILD_DOCS"] = False - tc.variables["BUILD_EXAMPLES"] = False - tc.variables["BUILD_FAT_JAVA_LIB"] = False - tc.variables["BUILD_IPP_IW"] = self.options.with_ipp == "opencv-icv" - tc.variables["BUILD_ITT"] = False - tc.variables["BUILD_JASPER"] = False - tc.variables["BUILD_JAVA"] = False - tc.variables["BUILD_JPEG"] = True - tc.variables["BUILD_OPENEXR"] = True - tc.variables["BUILD_OPENJPEG"] = True - tc.variables["BUILD_TESTS"] = False - tc.variables["BUILD_PROTOBUF"] = True - tc.variables["BUILD_PERF_TESTS"] = False - tc.variables["BUILD_USE_SYMLINKS"] = False - tc.variables["BUILD_opencv_apps"] = False - tc.variables["BUILD_opencv_java"] = False - tc.variables["BUILD_opencv_java_bindings_gen"] = False - tc.variables["BUILD_opencv_js"] = False - tc.variables["BUILD_ZLIB"] = True - tc.variables["BUILD_PNG"] = True - tc.variables["BUILD_TIFF"] = True - tc.variables["BUILD_WEBP"] = True - tc.variables["BUILD_TBB"] = False - tc.variables["OPENCV_FORCE_3RDPARTY_BUILD"] = False - tc.variables["OPENCV_PYTHON_SKIP_DETECTION"] = True - tc.variables["BUILD_opencv_python2"] = False - tc.variables["BUILD_opencv_python3"] = False - tc.variables["BUILD_opencv_python_bindings_g"] = False - tc.variables["BUILD_opencv_python_tests"] = False - tc.variables["BUILD_opencv_ts"] = False - - tc.variables["WITH_1394"] = True - tc.variables["WITH_ARAVIS"] = False - tc.variables["WITH_CLP"] = False - tc.variables["WITH_NVCUVID"] = False - - tc.variables["WITH_FFMPEG"] = self.get_bool("with_ffmpeg", False) - tc.variables["WITH_GSTREAMER"] = False - tc.variables["WITH_HALIDE"] = False - tc.variables["WITH_HPX"] = False - tc.variables["WITH_IMGCODEC_HDR"] = self.get_bool("with_imgcodec_hdr", False) - tc.variables["WITH_IMGCODEC_PFM"] = self.get_bool("with_imgcodec_pfm", False) - tc.variables["WITH_IMGCODEC_PXM"] = self.get_bool("with_imgcodec_pxm", False) - tc.variables["WITH_IMGCODEC_SUNRASTER"] = self.get_bool( - "with_imgcodec_sunraster", False - ) - tc.variables["WITH_IPP"] = bool(self.options.get_safe("with_ipp", False)) - tc.variables["WITH_ITT"] = False - tc.variables["WITH_LIBREALSENSE"] = False - tc.variables["WITH_MFX"] = False - # opencl fails on ios - tc.variables["WITH_OPENCL"] = ( - False if self.settings.os == "iOS" else self.get_bool("with_opencl", False) - ) - tc.variables["WITH_OPENCLAMDBLAS"] = False - tc.variables["WITH_OPENCLAMDFFT"] = False - tc.variables["WITH_OPENCL_SVM"] = False - tc.variables["WITH_OPENGL"] = False - tc.variables["WITH_OPENNI"] = False - tc.variables["WITH_OPENNI2"] = self.get_bool("with_openni2", False) - tc.variables["WITH_OPENVX"] = False - tc.variables["WITH_CAROTENE"] = False - tc.variables["WITH_PLAIDML"] = False - tc.variables["WITH_PVAPI"] = False - tc.variables["WITH_QT"] = self.get_bool("with_qt", False) - tc.variables["WITH_QUIRC"] = self.get_bool("with_quirc", False) - tc.variables["WITH_V4L"] = self.get_bool("with_v4l", False) - tc.variables["WITH_VA"] = False - tc.variables["WITH_VA_INTEL"] = False - tc.variables["WITH_VTK"] = self.get_bool("viz", False) - tc.variables["WITH_VULKAN"] = self.get_bool("with_vulkan", False) - tc.variables["WITH_XIMEA"] = False - tc.variables["WITH_XINE"] = False - tc.variables["WITH_LAPACK"] = False - - tc.variables["WITH_GTK"] = self.get_bool("with_gtk", False) - tc.variables["WITH_WEBP"] = self.get_bool("with_webp", False) - tc.variables["WITH_JPEG"] = bool(self.options.get_safe("with_jpeg", False)) - tc.variables["WITH_PNG"] = self.get_bool("with_png", False) - tc.variables["WITH_TIFF"] = self.get_bool("with_tiff", False) - tc.variables["WITH_JASPER"] = self.options.get_safe("with_jpeg2000") == "jasper" - tc.variables["WITH_OPENJPEG"] = ( - self.options.get_safe("with_jpeg2000") == "openjpeg" - ) - tc.variables["WITH_OPENEXR"] = self.get_bool("with_openexr", False) - tc.variables["WITH_GDAL"] = self.get_bool("with_gdal", False) - tc.variables["WITH_GDCM"] = self.get_bool("with_gdcm", False) - tc.variables["WITH_EIGEN"] = self.get_bool("with_eigen") - tc.variables["WITH_DSHOW"] = is_msvc(self) - tc.variables["WITH_MSMF"] = self.get_bool("with_msmf", False) - tc.variables["WITH_MSMF_DXVA"] = self.get_bool("with_msmf_dxva", False) - tc.variables["OPENCV_ENABLE_NONFREE"] = self.get_bool("nonfree", False) - tc.variables["ENABLE_NEON"] = self.get_bool("neon", False) - tc.variables["OPENCV_DNN_CUDA"] = self.get_bool("dnn_cuda", False) - tc.variables["WITH_OPENVINO"] = False - tc.variables["WITH_OBSENSOR"] = self.get_bool("with_obsensor", False) - tc.variables["WITH_AVIF"] = self.get_bool("with_avif", False) - tc.variables["BUILD_opencv_world"] = self.get_bool("world", False) - tc.variables["BUILD_opencv_core"] = True - for module in OCV_MODULES: - tc.variables[f"BUILD_opencv_{module}"] = self.get_bool(module, False) - tc.variables["WITH_PROTOBUF"] = self.get_bool("with_protobuf", False) - tc.variables["WITH_ADE"] = self.get_bool("gapi", False) - tc.variables["BUILD_opencv_julia"] = False - tc.variables["BUILD_opencv_matlab"] = False - tc.variables["WITH_TESSERACT"] = self.get_bool("with_tesseract", False) - tc.variables["WITH_CUDA"] = self.get_bool("with_cuda", False) - tc.variables["WITH_CUBLAS"] = self.get_bool("with_cublas", False) - tc.variables["WITH_CUFFT"] = self.get_bool("with_cufft", False) - tc.variables["WITH_CUDNN"] = self.get_bool("with_cudnn", False) - tc.variables["BUILD_WITH_STATIC_CRT"] = is_msvc_static_runtime(self) - if is_msvc(self): - tc.variables["BUILD_WITH_STATIC_CRT"] = is_msvc_static_runtime(self) - - if self.settings.os == "Android": - tc.variables["BUILD_ANDROID_EXAMPLES"] = False - - tc.variables["OPENCV_EXTRA_MODULES_PATH"] = os.path.join( - self.opencv_contrib_repo, "modules" - ).replace("\\", "/") - tc.generate() - - CMakeDeps(self).generate() - - def requirements(self): - root = os.path.abspath(".") - self.opencv_repo = os.path.join(root, "build", "opencv") - self.opencv_contrib_repo = os.path.join(root, "build", "opencv_contrib") - git = Git(self) - if not os.path.exists(self.opencv_repo): - git.clone("https://github.com/opencv/opencv.git", self.opencv_repo, [f"-b {OPENCV_VERSION}"]) - if not os.path.exists(self.opencv_contrib_repo): - git.clone( - "https://github.com/opencv/opencv_contrib.git", - self.opencv_contrib_repo, - [f"-b {OPENCV_VERSION}"] - ) - - def build_requirements(self): - self.tool_requires("cmake/3.28.1") - # self.tool_requires("nasm/2.16.01") - # self.tool_requires("ccache/4.9.1") - - # build ffmpeg only for linux, on macos, install with brew, - # on windows use prebuilt dll - # android and ios are unsupported - # if self.settings.os == "Linux": - # self.tool_requires("ffmpeg/6.1") - if self.settings.os != "Windows": - self.tool_requires("ninja/1.11.1") - - def layout(self): - base = Path("build") / str(self.settings.os) / str(self.settings.arch) - self.folders.generators = str((base / "generators").absolute()) - self.folders.build = str((base / "opencv").absolute()) - self.folders.source = "build/opencv" - - def layout_dart(self): - # self.build_folder: build/{os}/{arch}/opencv - base = Path(self.build_folder).parent # build/{os}/{arch} - self.folders.generators = str((base / "generators").absolute()) - self.folders.build = str(base.absolute()) - self.folders.source = "." - - def build(self): - cmake = CMake(self) - - if self.get_bool("build_opencv", True): - # build opencv - cmake.configure( - variables={ - "CMAKE_INSTALL_PREFIX": self.install_folder, - } - ) - cmake.build(target="install") - else: - ConanOutput().writeln("Skipping opencv build...", fg=Color.YELLOW) - ocv_install_dir = self.opencv_dir(self.install_folder) - - self.post_build() - - def post_build(self): - # archive - install_dir = Path(self.install_folder) - os = str(self.settings.os).lower() - arch = arch_map[os][str(self.settings.arch)] - new_name = f"lib{self.name}-{os}-{arch}.tar.gz" - fname = self.publish_folder / new_name - print(fname) - if not fname.parent.exists(): - fname.parent.mkdir(parents=True) - with tarfile.open(fname, mode="w:gz") as tar: - for file in install_dir.glob("*"): - print(f"Adding {file}...") - tar.add(file, arcname=file.name) - print(f"published: {fname}") - - @property - def install_folder(self) -> Path: - return Path(f"{os.path.join(self.build_folder, 'install')}") - - @property - def publish_folder(self) -> Path: - p = Path(self.install_folder).absolute().parent.parent.parent.parent - return p / "publish" - - def opencv_dir(self, dir: Path) -> str: - if self.settings.os == "Windows": - return str(dir) - elif self.settings.os in ["Linux", "Macos", "iOS"]: - return str(dir / "lib" / "cmake" / "opencv4") - elif self.settings.os == "Android": - return str(dir / "sdk" / "native" / "jni") - else: - raise ConanInvalidConfiguration - - def get_bool(self, name: str, default=False): - value = str(self.options.get_safe(name, default)) - if isinstance(value, str): - return value == "True" - elif isinstance(value, bool): - return value - else: - raise ValueError(f"value: {value=} of {name=} error") diff --git a/options.txt b/options.txt new file mode 100644 index 0000000..e4bba0f --- /dev/null +++ b/options.txt @@ -0,0 +1,140 @@ +-DBUILD_ZLIB=ON +-DBUILD_TIFF=ON +-DBUILD_OPENJPEG=ON +-DBUILD_JASPER=OFF +-DBUILD_JPEG=ON +-DBUILD_PNG=ON +-DBUILD_OPENEXR=ON +-DBUILD_WEBP=ON +-DBUILD_TBB=OFF +-DBUILD_ITT=OFF +-DWITH_ADE=ON +-DWITH_FFMPEG=ON +-DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON +-DWITH_CPUFEATURES=OFF +-DWITH_EIGEN=ON +-DWITH_HALIDE=OFF +-DWITH_VULKAN=ON +-DWITH_INF_ENGINE=OFF +-DWITH_NGRAPH=OFF +-DWITH_JASPER=OFF +-DWITH_OPENJPEG=ON +-DWITH_JPEG=ON +-DWITH_WEBP=ON +-DWITH_OPENEXR=ON +-DWITH_PNG=ON +-DWITH_TIFF=ON +-DWITH_OPENVX=OFF +-DWITH_GDCM=OFF +-DWITH_TBB=OFF +-DWITH_HPX=OFF +-DWITH_OPENMP=ON +-DWITH_PTHREADS_PF=OFF +-DWITH_CLP=OFF +-DWITH_OPENCL=ON +-DWITH_OPENCL_SVM=OFF +-DWITH_VA=OFF +-DWITH_VA_INTEL=OFF +-DWITH_ITT=OFF +-DWITH_PROTOBUF=ON +-DWITH_IMGCODEC_HDR=ON +-DWITH_IMGCODEC_SUNRASTER=ON +-DWITH_IMGCODEC_PXM=ON +-DWITH_IMGCODEC_PFM=ON +-DWITH_QUIRC=ON +-DWITH_OBSENSOR=OFF +-DWITH_CANN=OFF +-DWITH_FLATBUFFERS=OFF +-DBUILD_SHARED_LIBS=OFF +-DBUILD_opencv_apps=OFF +-DBUILD_ANDROID_PROJECTS=OFF +-DBUILD_ANDROID_EXAMPLES=OFF +-DBUILD_DOCS=OFF +-DBUILD_EXAMPLES=OFF +-DBUILD_PACKAGE=OFF +-DBUILD_PERF_TESTS=OFF +-DBUILD_TESTS=OFF +-DBUILD_FAT_JAVA_LIB=OFF +-DBUILD_JAVA=OFF +-DBUILD_OBJC=OFF +-DBUILD_KOTLIN_EXTENSIONS=OFF +-DENABLE_PRECOMPILED_HEADERS=OFF +-DENABLE_FAST_MATH=ON +-DBUILD_opencv_world=OFF +-DBUILD_opencv_calib3d=ON +-DBUILD_opencv_dnn=ON +-DBUILD_opencv_features2d=ON +-DBUILD_opencv_flann=ON +-DBUILD_opencv_gapi=ON +-DBUILD_opencv_highgui=ON +-DBUILD_opencv_imgcodecs=ON +-DBUILD_opencv_imgproc=ON +-DBUILD_opencv_ml=ON +-DBUILD_opencv_objdetect=ON +-DBUILD_opencv_photo=ON +-DBUILD_opencv_stitching=ON +-DBUILD_opencv_video=ON +-DBUILD_opencv_videoio=ON +-DBUILD_opencv_aruco=ON +-DBUILD_opencv_img_hash=ON +-DBUILD_opencv_wechat_qrcode=ON +-DBUILD_opencv_bgsegm=ON +-DBUILD_opencv_bioinspired=ON +-DBUILD_opencv_ccalib=ON +-DBUILD_opencv_dnn_objdetect=ON +-DBUILD_opencv_dnn_superres=ON +-DBUILD_opencv_dpm=ON +-DBUILD_opencv_face=ON +-DBUILD_opencv_fuzzy=ON +-DBUILD_opencv_hfs=ON +-DBUILD_opencv_intensity_transform=ON +-DBUILD_opencv_line_descriptor=ON +-DBUILD_opencv_mcc=ON +-DBUILD_opencv_optflow=ON +-DBUILD_opencv_phase_unwrapping=ON +-DBUILD_opencv_plot=ON +-DBUILD_opencv_quality=ON +-DBUILD_opencv_rapid=ON +-DBUILD_opencv_reg=ON +-DBUILD_opencv_rgbd=ON +-DBUILD_opencv_saliency=ON +-DBUILD_opencv_shape=ON +-DBUILD_opencv_signal=ON +-DBUILD_opencv_stereo=ON +-DBUILD_opencv_structured_light=ON +-DBUILD_opencv_superres=ON +-DBUILD_opencv_surface_matching=ON +-DBUILD_opencv_tracking=ON +-DBUILD_opencv_videostab=ON +-DBUILD_opencv_xfeatures2d=ON +-DBUILD_opencv_ximgproc=ON +-DBUILD_opencv_xobjdetect=ON +-DBUILD_opencv_xphoto=ON +-DBUILD_opencv_alphamat=ON +-DBUILD_opencv_cannops=OFF +-DBUILD_opencv_cudaarithm=OFF +-DBUILD_opencv_cudabgsegm=OFF +-DBUILD_opencv_cudacodec=OFF +-DBUILD_opencv_cudafeatures2d=OFF +-DBUILD_opencv_cudafilters=OFF +-DBUILD_opencv_cudaimgproc=OFF +-DBUILD_opencv_cudalegacy=OFF +-DBUILD_opencv_cudaobjdetect=OFF +-DBUILD_opencv_cudaoptflow=OFF +-DBUILD_opencv_cudastereo=OFF +-DBUILD_opencv_cudawarping=OFF +-DBUILD_opencv_cudev=OFF +-DBUILD_opencv_cvv=OFF +-DBUILD_opencv_freetype=OFF +-DBUILD_opencv_hdf=OFF +-DBUILD_opencv_java=OFF +-DBUILD_opencv_objc=OFF +-DBUILD_opencv_js=OFF +-DBUILD_opencv_ts=OFF +-DBUILD_opencv_python2=OFF +-DBUILD_opencv_python3=OFF +-DBUILD_opencv_julia=OFF +-DBUILD_opencv_matlab=OFF +-DBUILD_opencv_ovis=OFF +-DBUILD_opencv_sfm=OFF +-DBUILD_opencv_viz=OFF diff --git a/patches/opencv-4.10.0-unsafe-xadd.patch b/patches/opencv-4.10.0-unsafe-xadd.patch new file mode 100644 index 0000000..c99a84c --- /dev/null +++ b/patches/opencv-4.10.0-unsafe-xadd.patch @@ -0,0 +1,38 @@ +diff -Nuarp opencv-4.10.0.orig/modules/core/include/opencv2/core/cvdef.h opencv-4.10.0/modules/core/include/opencv2/core/cvdef.h +--- opencv-4.10.0.orig/modules/core/include/opencv2/core/cvdef.h 2024-06-02 04:41:06.000000000 +0800 ++++ opencv-4.10.0/modules/core/include/opencv2/core/cvdef.h 2024-06-04 20:55:30.670342400 +0800 +@@ -693,33 +693,7 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumTy + * exchange-add operation for atomic operations on reference counters * + \****************************************************************************************/ + +-#ifdef CV_XADD +- // allow to use user-defined macro +-#elif defined __GNUC__ || defined __clang__ +-# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER +-# ifdef __ATOMIC_ACQ_REL +-# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL) +-# else +-# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4) +-# endif +-# else +-# if defined __ATOMIC_ACQ_REL && !defined __clang__ +- // version for gcc >= 4.7 +-# define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL) +-# else +-# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta)) +-# endif +-# endif +-#elif defined _MSC_VER && !defined RC_INVOKED +-# include +-# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta) +-#else +- #ifdef OPENCV_FORCE_UNSAFE_XADD +- CV_INLINE int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; } +- #else +- #error "OpenCV: can't define safe CV_XADD macro for current platform (unsupported). Define CV_XADD macro through custom port header (see OPENCV_INCLUDE_PORT_FILE)" +- #endif +-#endif ++CV_INLINE int CV_XADD(void* addr, int delta) { int tmp = *(int*)addr; *(int*)addr += delta; return tmp; } + + + /****************************************************************************************\ diff --git a/profiles/android-armv7 b/profiles/android-armv7 deleted file mode 100644 index 2521f96..0000000 --- a/profiles/android-armv7 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=Android -os.api_level=24 -arch=armv7 -compiler=clang -compiler.version=12 -compiler.libcxx=c++_static -compiler.cppstd=14 - -[conf] -tools.cmake.cmaketoolchain:generator=Ninja diff --git a/profiles/android-armv8 b/profiles/android-armv8 deleted file mode 100644 index 50bdc9a..0000000 --- a/profiles/android-armv8 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=Android -os.api_level=24 -arch=armv8 -compiler=clang -compiler.version=12 -compiler.libcxx=c++_static -compiler.cppstd=14 - -[conf] -tools.cmake.cmaketoolchain:generator=Ninja diff --git a/profiles/android-x86_64 b/profiles/android-x86_64 deleted file mode 100644 index 5dd70ad..0000000 --- a/profiles/android-x86_64 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=Android -os.api_level=24 -arch=x86_64 -compiler=clang -compiler.version=12 -compiler.libcxx=c++_static -compiler.cppstd=14 - -[conf] -tools.cmake.cmaketoolchain:generator=Ninja diff --git a/profiles/arm-toolchain/test_package/CMakeUserPresets.json b/profiles/arm-toolchain/test_package/CMakeUserPresets.json deleted file mode 100644 index e6e4188..0000000 --- a/profiles/arm-toolchain/test_package/CMakeUserPresets.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "version": 4, - "vendor": { - "conan": {} - }, - "include": [ - "build/gcc-13-armv8-gnu17-release/generators/CMakePresets.json" - ] -} \ No newline at end of file diff --git a/profiles/ios-armv8 b/profiles/ios-armv8 deleted file mode 100644 index c241eb6..0000000 --- a/profiles/ios-armv8 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=iOS -os.version=11.0 -os.sdk=iphoneos -arch=armv8 -build_type=Release - -[conf] -tools.apple:enable_arc=False -tools.apple:enable_visibility=False -tools.cmake.cmaketoolchain:generator=Xcode diff --git a/profiles/ios-x86_64 b/profiles/ios-x86_64 deleted file mode 100644 index 1ed383c..0000000 --- a/profiles/ios-x86_64 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=iOS -os.version=11.0 -os.sdk=iphonesimulator -arch=x86_64 -build_type=Release - -[conf] -tools.apple:enable_arc=False -tools.apple:enable_visibility=False -tools.cmake.cmaketoolchain:generator=Xcode diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..0908ced --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,21 @@ +project(opencv-mobile-test) +cmake_minimum_required(VERSION 3.5) + +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/MT) +endif() + +# opencv4 requires c++11 +set(CMAKE_CXX_STANDARD 11) + +if(LINUX OR APPLE) + find_package(Iconv REQUIRED) +endif() + +find_package(OpenCV REQUIRED) +find_package(FFMPEG REQUIRED) + +add_executable(opencv-mobile-test main.cpp) +target_include_directories(opencv-mobile-test PRIVATE ${OpenCV_INCLUDE_DIRS} ${FFMPEG_INCLUDE_DIRS}) + +target_link_libraries(opencv-mobile-test opencv_highgui opencv_core opencv_imgproc ${FFMPEG_LIBRARIES}) diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 0000000..f8d2873 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + +int main() +{ + cv::Mat bgr = cv::imread("in.jpg", 1); + + cv::resize(bgr, bgr, cv::Size(200, 200)); + + cv::imwrite("out.jpg", bgr); + + return 0; +}