diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index 2dd399b..7426a8a 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -2,9 +2,6 @@ name: Builder on: workflow_dispatch: - push: - tags: - - '*' jobs: ubuntu1804: diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..4014646 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,145 @@ +name: linux + +on: + workflow_dispatch: + push: + tags: + - '*' + +jobs: + linux: + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + arch_type: + [ + aarch64-linux-musl, + mips64el-linux-musl, + mipsel-linux-musl, + mipsel-linux-musln32, + mipsel-linux-musln32sf, + mipsel-linux-muslsf, + riscv32-linux-musl, + riscv64-linux-musl, + sh2-linux-musl, + x86_64-linux-musl, + x86_64-linux-muslx32, + ] + + name: ${{ matrix.arch_type }} + + env: + TOOLCHAIN_VERSION: 20231224 + ONNX_VERSION: 1.15.1 + ONNX_PKG_NAME: onnxruntime-1.15.1-${{ matrix.arch_type }}-static + CV_VERSION: 4.8.1 + CV_PKG_NAME: opencv-4.8.1-${{ matrix.arch_type }} + BIN_PKG_NAME: linux-bin-${{ matrix.arch_type }} + JNI_PKG_NAME: linux-jni-${{ matrix.arch_type }} + CLIB_PKG_NAME: linux-clib-${{ matrix.arch_type }} + + steps: + # 检出代码 + - uses: actions/checkout@v3 + + # 部署musl + - name: deploy musl + run: | + wget https://github.com/benjaminwan/musl-cross-builder/releases/download/${{ env.TOOLCHAIN_VERSION }}/${{ matrix.arch_type }}.7z -O ${{ matrix.arch_type }}.7z + 7z x ${{ matrix.arch_type }}.7z -aoa + mv ${{ matrix.arch_type }}/ /opt/${{ matrix.arch_type }}/ + + # 下载onnxruntime-static + - name: download onnxruntime-static + run: | + cd onnxruntime-static + wget https://github.com/RapidAI/OnnxruntimeBuilder/releases/download/${{ env.ONNX_VERSION }}/${{ env.ONNX_PKG_NAME }}.7z -O ${{ env.ONNX_PKG_NAME }}.7z + 7z x ${{ env.ONNX_PKG_NAME }}.7z -aoa + + # 下载opencv-static + - name: download opencv-static + run: | + cd opencv-static + wget https://github.com/RapidAI/OpenCVBuilder/releases/download/${{ env.CV_VERSION }}/${{ env.CV_PKG_NAME }}.7z -O ${{ env.CV_PKG_NAME }}.7z + 7z x ${{ env.CV_PKG_NAME }}.7z -aoa + + # 编译 + - name: build + run: | + wget https://github.com/benjaminwan/musl-cross-builder/raw/main/musl-cross.toolchain.cmake -O musl-cross.toolchain.cmake + chmod a+x build-default.sh + ./build-default.sh "${{ matrix.arch_type }}" "/opt/${{ matrix.arch_type }}" + + # install文件夹改名linux,并使用7z压缩 + - name: 7zip + run: | + mkdir ${{ env.BIN_PKG_NAME }} + cp run-benchmark.sh ${{ env.BIN_PKG_NAME }}/run-benchmark.sh + cp run-test.sh ${{ env.BIN_PKG_NAME }}/run-test.sh + cp -r images ${{ env.BIN_PKG_NAME }}/images + mv Linux-BIN-CPU/install/bin ${{ env.BIN_PKG_NAME }}/Linux-BIN-CPU + cp others/README-bin.txt ${{ env.BIN_PKG_NAME }}/README.txt + 7z a ${{ env.BIN_PKG_NAME }}.7z ${{ env.BIN_PKG_NAME }} + mkdir ${{ env.JNI_PKG_NAME }} + mv Linux-JNI-CPU/install ${{ env.JNI_PKG_NAME }}/Linux-JNI-CPU + cp others/README-jni.txt ${{ env.JNI_PKG_NAME }}/README.txt + 7z a ${{ env.JNI_PKG_NAME }}.7z ${{ env.JNI_PKG_NAME }} + mkdir ${{ env.CLIB_PKG_NAME }} + mv Linux-CLIB-CPU/install ${{ env.CLIB_PKG_NAME }}/Linux-CLIB-CPU + cp others/README-clib.txt ${{ env.CLIB_PKG_NAME }}/README.txt + 7z a ${{ env.CLIB_PKG_NAME }}.7z ${{ env.CLIB_PKG_NAME }} + + # 上传artifact + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BIN_PKG_NAME }} + path: ${{ env.BIN_PKG_NAME }}.7z + + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.JNI_PKG_NAME }} + path: ${{ env.JNI_PKG_NAME }}.7z + + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.CLIB_PKG_NAME }} + path: ${{ env.CLIB_PKG_NAME }}.7z + + # 获取所有的git log和tag + - name: Unshallow + run: git fetch --prune --unshallow + + # 获取git log 从 previousTag 到 lastTag + - name: Get git log + id: git-log + run: | + previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) + lastTag=$(git describe --abbrev=0 --tags) + echo "previousTag:$previousTag ~ lastTag:$lastTag" + log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') + echo "$log" + echo "log_state="$log"" >> $GITHUB_ENV + + # 创建Changelog文件 triggered by git tag push + - name: Generate Changelog + if: startsWith(github.ref, 'refs/tags/') + run: | + echo -e '${{ env.log_state }}' > release.md + + # 创建release 上传release + # https://github.com/marketplace/actions/create-release + - name: Create release and upload-archive + uses: ncipollo/release-action@v1 + with: + prerelease: true + name: RapidOcrOnnx ${{ github.ref }} + bodyFile: release.md + artifacts: linux-*.7z + allowUpdates: true + artifactContentType: application/x-7z-compressed + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..69624b1 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,116 @@ +name: macos + +on: + workflow_dispatch: + push: + tags: + - '*' + +jobs: + macos: + runs-on: macos-latest + + env: + ONNX_VERSION: 1.15.1 + ONNX_PKG_NAME: onnxruntime-1.15.1-macos-static + CV_VERSION: 4.8.1 + CV_PKG_NAME: opencv-4.8.1-macos + BIN_PKG_NAME: macos-bin + JNI_PKG_NAME: macos-jni + CLIB_PKG_NAME: macos-clib + + + steps: + # 检出代码 + - uses: actions/checkout@v3 + + # 下载onnxruntime-static + - name: download onnxruntime-static + run: | + cd onnxruntime-static + wget https://github.com/RapidAI/OnnxruntimeBuilder/releases/download/${{ env.ONNX_VERSION }}/${{ env.ONNX_PKG_NAME }}.7z -O ${{ env.ONNX_PKG_NAME }}.7z + 7z x ${{ env.ONNX_PKG_NAME }}.7z -aoa + + # 下载opencv-static + - name: download opencv-static + run: | + cd opencv-static + wget https://github.com/RapidAI/OpenCVBuilder/releases/download/${{ env.CV_VERSION }}/${{ env.CV_PKG_NAME }}.7z -O ${{ env.CV_PKG_NAME }}.7z + 7z x ${{ env.CV_PKG_NAME }}.7z -aoa + + # 编译 + - name: build + run: | + chmod a+x build-default.sh &&./build-default.sh + + # 压缩 + - name: 7z + run: | + mkdir ${{ env.BIN_PKG_NAME }} + cp run-benchmark.sh ${{ env.BIN_PKG_NAME }}/run-benchmark.sh + cp run-test.sh ${{ env.BIN_PKG_NAME }}/run-test.sh + cp -r images ${{ env.BIN_PKG_NAME }}/images + mv Darwin-BIN-CPU/install/bin ${{ env.BIN_PKG_NAME }}/Darwin-BIN-CPU + cp others/README-bin.txt ${{ env.BIN_PKG_NAME }}/README.txt + 7z a ${{ env.BIN_PKG_NAME }}.7z ${{ env.BIN_PKG_NAME }} + mkdir ${{ env.JNI_PKG_NAME }} + mv Darwin-JNI-CPU/install ${{ env.JNI_PKG_NAME }}/Darwin-JNI-CPU + cp others/README-jni.txt ${{ env.JNI_PKG_NAME }}/README.txt + 7z a ${{ env.JNI_PKG_NAME }}.7z ${{ env.JNI_PKG_NAME }} + mkdir ${{ env.CLIB_PKG_NAME }} + mv Darwin-CLIB-CPU/install ${{ env.CLIB_PKG_NAME }}/Darwin-CLIB-CPU + cp others/README-clib.txt ${{ env.CLIB_PKG_NAME }}/README.txt + 7z a ${{ env.CLIB_PKG_NAME }}.7z ${{ env.CLIB_PKG_NAME }} + + # 上传artifact + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BIN_PKG_NAME }} + path: ${{ env.BIN_PKG_NAME }}.7z + + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.JNI_PKG_NAME }} + path: ${{ env.JNI_PKG_NAME }}.7z + + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.CLIB_PKG_NAME }} + path: ${{ env.CLIB_PKG_NAME }}.7z + + # 获取所有的git log和tag + - name: Unshallow + run: git fetch --prune --unshallow + + # 获取git log 从 previousTag 到 lastTag + - name: Get git log + id: git-log + run: | + previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) + lastTag=$(git describe --abbrev=0 --tags) + echo "previousTag:$previousTag ~ lastTag:$lastTag" + log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') + echo "$log" + echo "log_state="$log"" >> $GITHUB_ENV + + # 创建Changelog文件 triggered by git tag push + - name: Generate Changelog + if: startsWith(github.ref, 'refs/tags/') + run: | + echo -e '${{ env.log_state }}' > release.md + + # 创建release 上传release + # https://github.com/marketplace/actions/create-release + - name: Create release and upload-archive + uses: ncipollo/release-action@v1 + with: + prerelease: true + name: RapidOcrOnnx ${{ github.ref }} + bodyFile: release.md + artifacts: macos-*.7z + allowUpdates: true + artifactContentType: application/x-7z-compressed + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..345d682 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,147 @@ +name: windows + +on: + workflow_dispatch: + push: + tags: + - '*' + +jobs: + windows: + strategy: + fail-fast: false + matrix: + list: + - { win_ver: 2019, vs_name: vs2019, vs_ver: v142 } + - { win_ver: 2022, vs_name: vs2022, vs_ver: v143 } + + runs-on: windows-${{ matrix.list.win_ver }} + + name: windows-${{ matrix.list.vs_name }} + + env: + ONNX_VERSION: 1.15.1 + ONNX_PKG_NAME: onnxruntime-1.15.1-windows-${{ matrix.list.vs_name }}-static-mt + CV_VERSION: 4.8.1 + CV_PKG_NAME: opencv-4.8.1-windows-${{ matrix.list.vs_name }}-mt + BIN_PKG_NAME: windows-bin-${{ matrix.list.vs_name }}-mt + JNI_PKG_NAME: windows-jni-${{ matrix.list.vs_name }}-mt + CLIB_PKG_NAME: windows-clib-${{ matrix.list.vs_name }}-mt + + steps: + # 检出代码 + - uses: actions/checkout@v3 + + # 下载onnxruntime-static + - name: download onnxruntime-static + run: | + cd onnxruntime-static + Invoke-WebRequest -Uri https://github.com/RapidAI/OnnxruntimeBuilder/releases/download/${{ env.ONNX_VERSION }}/${{ env.ONNX_PKG_NAME }}.7z -OutFile ${{ env.ONNX_PKG_NAME }}.7z + 7z x ${{ env.ONNX_PKG_NAME }}.7z -aoa + + # 下载opencv-static + - name: download opencv-static + run: | + cd opencv-static + Invoke-WebRequest -Uri https://github.com/RapidAI/OpenCVBuilder/releases/download/${{ env.CV_VERSION }}/${{ env.CV_PKG_NAME }}.7z -OutFile ${{ env.CV_PKG_NAME }}.7z + 7z x ${{ env.CV_PKG_NAME }}.7z -aoa + + # 编译 + - name: build + run: | + ./build-default.bat ${{ matrix.list.vs_ver }} + + # 压缩 + - name: 7zip + run: | + mkdir ${{ env.BIN_PKG_NAME }} + cp run-benchmark.bat ${{ env.BIN_PKG_NAME }}/run-benchmark.bat + cp run-test.bat ${{ env.BIN_PKG_NAME }}/run-test.bat + cp -r images ${{ env.BIN_PKG_NAME }}/images + mv win-BIN-CPU-x64/install/bin ${{ env.BIN_PKG_NAME }}/win-BIN-CPU-x64 + mv win-BIN-CPU-Win32/install/bin ${{ env.BIN_PKG_NAME }}/win-BIN-CPU-Win32 + cp others/README-bin.txt ${{ env.BIN_PKG_NAME }}/README.txt + 7z a ${{ env.BIN_PKG_NAME }}.7z ${{ env.BIN_PKG_NAME }} + mkdir ${{ env.JNI_PKG_NAME }} + mv win-JNI-CPU-x64/install ${{ env.JNI_PKG_NAME }}/win-JNI-CPU-x64 + mv win-JNI-CPU-Win32/install ${{ env.JNI_PKG_NAME }}/win-JNI-CPU-Win32 + cp others/README-jni.txt ${{ env.JNI_PKG_NAME }}/README.txt + 7z a ${{ env.JNI_PKG_NAME }}.7z ${{ env.JNI_PKG_NAME }} + mkdir ${{ env.CLIB_PKG_NAME }} + mv win-CLIB-CPU-x64/install ${{ env.CLIB_PKG_NAME }}/win-CLIB-CPU-x64 + mv win-CLIB-CPU-Win32/install ${{ env.CLIB_PKG_NAME }}/win-CLIB-CPU-Win32 + cp others/README-clib.txt ${{ env.CLIB_PKG_NAME }}/README.txt + 7z a ${{ env.CLIB_PKG_NAME }}.7z ${{ env.CLIB_PKG_NAME }} + + # 上传artifact + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BIN_PKG_NAME }} + path: ${{ env.BIN_PKG_NAME }}.7z + + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.JNI_PKG_NAME }} + path: ${{ env.JNI_PKG_NAME }}.7z + + - name: upload + uses: actions/upload-artifact@v3 + with: + name: ${{ env.CLIB_PKG_NAME }} + path: ${{ env.CLIB_PKG_NAME }}.7z + + release: + needs: [ windows ] + + runs-on: ubuntu-latest + + steps: + # 检出代码 + - uses: actions/checkout@v3 + + # 获取所有的git log和tag + - name: Unshallow + run: git fetch --prune --unshallow + + # 获取git log 从 previousTag 到 lastTag + - name: Get git log + id: git-log + run: | + previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) + lastTag=$(git describe --abbrev=0 --tags) + echo "previousTag:$previousTag ~ lastTag:$lastTag" + log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') + echo "$log" + echo "log_state="$log"" >> $GITHUB_ENV + + # 创建Changelog文件 triggered by git tag push + - name: Generate Changelog + if: startsWith(github.ref, 'refs/tags/') + run: | + echo -e '${{ env.log_state }}' > release.md + + # 下载artifact + - name: download + uses: actions/download-artifact@v3 + with: + path: artifacts + + # 查看artifact + - name: list artifact + run: | + tree artifacts + + # 创建release 上传release + # https://github.com/marketplace/actions/create-release + - name: upload-windows + uses: ncipollo/release-action@v1 + with: + prerelease: true + name: RapidOcrOnnx ${{ github.ref }} + bodyFile: release.md + artifacts: artifacts/*/*.7z + allowUpdates: true + artifactContentType: application/x-7z-compressed + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 367fdd9..e0a348e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if (NOT DEFINED OCR_ONNX) endif () #set(OCR_OUTPUT "GPU") -set(CMAKE_CXX_STANDARD 11) +#set(CMAKE_CXX_STANDARD 11) add_definitions(-DUNICODE -D_UNICODE) if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions("-Wall -g -O0") diff --git a/README.md b/README.md index f111997..beb8003 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ ### 联系方式 -- QQ群号:1群:~887298230~ 已满,2群:~755960114~ 已满,3群:450338158 +- QQ1群:~887298230~ 已满, +- QQ2群:~755960114~ 已满, +- QQ3群:450338158 +- QQ4群:419196348 ### Project下载 @@ -62,6 +65,11 @@ * 适配onnxruntime 1.14.0 +#### 2024-01-07 update v1.2.3 + +* onnxruntime 1.15.1 +* opencv 4.8.1 + ### 模型下载 整合好的范例工程自带了模型,在models文件夹中 @@ -87,6 +95,14 @@ RapidOcrOnnx/models ### FAQ +#### windows10下bat执行错误 + +- 在win、linux、mac系统下,文本文件使用不同的换行符格式,win是CRLF,linux是LF,mac是CR +- github的"Download ZIP"按钮下载的整个仓库代码,默认格式是UNIX换行符,此时bat脚本在windows平台执行会出错 +- 解决方法1:从Release中下载完整工程压缩包 +- 解决方法2:使用git clone命令同步仓库代码,git可以自动转换文件格式 +- 解决方法3:使用UltraEdit等文本编辑器,把bat文件的换行符转成win格式 + #### windows静态链接msvc - 作用:静态链接CRT(mt)可以让编译出来的包,部署时不需要安装c++运行时,但会增大包体积; diff --git a/build-default.bat b/build-default.bat index f6cdfe4..8d05f06 100644 --- a/build-default.bat +++ b/build-default.bat @@ -3,9 +3,18 @@ chcp 65001 cls @SETLOCAL +IF "%1"=="" ( + echo input VS_VER none, use v142 + set VS_VER="v142" +)^ +ELSE ( + echo input VS_VER:%1 + set VS_VER="%1" +) + mkdir win-BIN-CPU-x64 pushd win-BIN-CPU-x64 -cmake -T "v142,host=x64" -A "x64" ^ +cmake -T "%VS_VER%,host=x64" -A "x64" ^ -DCMAKE_INSTALL_PREFIX=install ^ -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="BIN" ^ -DOCR_BUILD_CRT="True" -DOCR_ONNX="CPU" .. @@ -15,7 +24,7 @@ popd mkdir win-BIN-CPU-Win32 pushd win-BIN-CPU-Win32 -cmake -T "v142,host=x64" -A "Win32" ^ +cmake -T "%VS_VER%,host=x64" -A "Win32" ^ -DCMAKE_INSTALL_PREFIX=install ^ -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="BIN" ^ -DOCR_BUILD_CRT="True" -DOCR_ONNX="CPU" .. @@ -25,7 +34,7 @@ popd mkdir win-JNI-CPU-x64 pushd win-JNI-CPU-x64 -cmake -T "v142,host=x64" -A "x64" ^ +cmake -T "%VS_VER%,host=x64" -A "x64" ^ -DCMAKE_INSTALL_PREFIX=install ^ -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="JNI" ^ -DOCR_BUILD_CRT="True" -DOCR_ONNX="CPU" .. @@ -35,7 +44,7 @@ popd mkdir win-JNI-CPU-Win32 pushd win-JNI-CPU-Win32 -cmake -T "v142,host=x64" -A "Win32" ^ +cmake -T "%VS_VER%,host=x64" -A "Win32" ^ -DCMAKE_INSTALL_PREFIX=install ^ -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="JNI" ^ -DOCR_BUILD_CRT="True" -DOCR_ONNX="CPU" .. @@ -45,7 +54,7 @@ popd mkdir win-CLIB-CPU-x64 pushd win-CLIB-CPU-x64 -cmake -T "v142,host=x64" -A "x64" ^ +cmake -T "%VS_VER%,host=x64" -A "x64" ^ -DCMAKE_INSTALL_PREFIX=install ^ -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="CLIB" ^ -DOCR_BUILD_CRT="True" -DOCR_ONNX="CPU" .. @@ -55,7 +64,7 @@ popd mkdir win-CLIB-CPU-Win32 pushd win-CLIB-CPU-Win32 -cmake -T "v142,host=x64" -A "Win32" ^ +cmake -T "%VS_VER%,host=x64" -A "Win32" ^ -DCMAKE_INSTALL_PREFIX=install ^ -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="CLIB" ^ -DOCR_BUILD_CRT="True" -DOCR_ONNX="CPU" .. diff --git a/build-default.sh b/build-default.sh index 57f33ec..a6d78cd 100755 --- a/build-default.sh +++ b/build-default.sh @@ -1,34 +1,74 @@ #!/usr/bin/env bash +function cmakeBuild() { + mkdir -p ${sysOS}-BIN-CPU + pushd ${sysOS}-BIN-CPU + cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="BIN" -DOCR_ONNX="CPU" .. + cmake --build . --config Release -j $NUM_THREADS + cmake --build . --config Release --target install + popd + + mkdir -p ${sysOS}-JNI-CPU + pushd ${sysOS}-JNI-CPU + cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="JNI" -DOCR_ONNX="CPU" .. + cmake --build . --config Release -j $NUM_THREADS + cmake --build . --config Release --target install + popd + + mkdir -p ${sysOS}-CLIB-CPU + pushd ${sysOS}-CLIB-CPU + cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="CLIB" -DOCR_ONNX="CPU" .. + cmake --build . --config Release -j $NUM_THREADS + cmake --build . --config Release --target install + popd +} + +function cmakeCrossBuild() { + mkdir -p ${sysOS}-BIN-CPU + pushd ${sysOS}-BIN-CPU + cmake -DCMAKE_TOOLCHAIN_FILE=../musl-cross.toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="BIN" -DOCR_ONNX="CPU" .. + cmake --build . --config Release -j $NUM_THREADS + cmake --build . --config Release --target install + popd + + mkdir -p ${sysOS}-JNI-CPU + pushd ${sysOS}-JNI-CPU + cmake -DCMAKE_TOOLCHAIN_FILE=../musl-cross.toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="JNI" -DOCR_ONNX="CPU" .. + cmake --build . --config Release -j $NUM_THREADS + cmake --build . --config Release --target install + popd + + mkdir -p ${sysOS}-CLIB-CPU + pushd ${sysOS}-CLIB-CPU + cmake -DCMAKE_TOOLCHAIN_FILE=../musl-cross.toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="CLIB" -DOCR_ONNX="CPU" .. + cmake --build . --config Release -j $NUM_THREADS + cmake --build . --config Release --target install + popd +} + sysOS=$(uname -s) NUM_THREADS=1 if [ $sysOS == "Darwin" ]; then #echo "I'm MacOS" - NUM_THREADS=$(sysctl -n hw.nCPU) + NUM_THREADS=$(sysctl -n hw.ncpu) elif [ $sysOS == "Linux" ]; then #echo "I'm Linux" NUM_THREADS=$(grep ^processor /proc/cpuinfo | wc -l) + if [ "$1" ] && [ "$2" ]; then + echo "TOOLCHAIN_NAME=$1" + echo "TOOLCHAIN_PATH=$2" + export TOOLCHAIN_NAME="$1" + export TOOLCHAIN_PATH="$2" + echo "cross build" + cmakeCrossBuild "Release" + else + echo "native build" + cmakeBuild "Release" + fi else echo "Other OS: $sysOS" fi -mkdir -p ${sysOS}-BIN-CPU -pushd ${sysOS}-BIN-CPU -cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="BIN" -DOCR_ONNX="CPU" .. -cmake --build . --config Release -j $NUM_THREADS -cmake --build . --config Release --target install -popd - -mkdir -p ${sysOS}-JNI-CPU -pushd ${sysOS}-JNI-CPU -cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="JNI" -DOCR_ONNX="CPU" .. -cmake --build . --config Release -j $NUM_THREADS -cmake --build . --config Release --target install -popd - -mkdir -p ${sysOS}-CLIB-CPU -pushd ${sysOS}-CLIB-CPU -cmake -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOCR_OUTPUT="CLIB" -DOCR_ONNX="CPU" .. -cmake --build . --config Release -j $NUM_THREADS -cmake --build . --config Release --target install -popd \ No newline at end of file diff --git a/build.bat b/build.bat index 9cce477..c42a5fd 100644 --- a/build.bat +++ b/build.bat @@ -41,7 +41,7 @@ else if %flag% == 2 (set ONNX_TYPE="CUDA")^ else (echo 输入错误!Input Error!) echo. -echo "VS版本: 1)vs2019-x64, 2)vs2019-x86" +echo "VS版本: 1)vs2019-x64, 2)vs2019-x86, 3)vs2022-x64, 4)vs2022-x86" set BUILD_CMAKE_T="v142" set BUILD_CMAKE_A="x64" set /p flag= @@ -53,6 +53,14 @@ else if %flag% == 2 ( set BUILD_CMAKE_T="v142" set BUILD_CMAKE_A="Win32" )^ +else if %flag% == 3 ( + set BUILD_CMAKE_T="v143" + set BUILD_CMAKE_A="x64" +)^ +else if %flag% == 4 ( + set BUILD_CMAKE_T="v143" + set BUILD_CMAKE_A="Win32" +)^ else (echo 输入错误!Input Error!) echo. diff --git a/include/version.h b/include/version.h index 5e37f15..88cc83d 100644 --- a/include/version.h +++ b/include/version.h @@ -1,6 +1,6 @@ #ifndef __OCR_VERSION_H__ #define __OCR_VERSION_H__ -#define VERSION "1.2.2" +#define VERSION "1.2.3" #endif //__OCR_VERSION_H__ diff --git a/others/README-bin.txt b/others/README-bin.txt new file mode 100644 index 0000000..a3e4625 --- /dev/null +++ b/others/README-bin.txt @@ -0,0 +1,34 @@ +### 测试说明 + +1. 根据系统下载对应的程序包并解压. +2. 终端运行run-test.sh或命令行运行run-test.bat,查看识别结果. +3. 终端运行run-benchmark.sh或命令行运行run-benchmark.bat,查看识别过程平均耗时. + +### Windows7执行错误|中文乱码 + +1. cmd窗口左上角-属性 +2. 字体选项卡-选择除了“点阵字体”以外的TrueType字体,例如:Lucida Console、宋体 +3. 重新执行bat + +### 输入参数说明 + +* 请参考main.h中的命令行参数说明。 +* 每个参数有一个短参数名和一个长参数名,用短的或长的均可。 + +1. ```-d或--models```:模型所在文件夹路径,可以相对路径也可以绝对路径。 +2. ```-1或--det```:det模型文件名(含扩展名) +3. ```-2或--cls```:cls模型文件名(含扩展名) +4. ```-3或--rec```:rec模型文件名(含扩展名) +5. ```-4或--keys```:keys.txt文件名(含扩展名) +6. ```-i或--image```:目标图片路径,可以相对路径也可以绝对路径。 +7. ```-t或--numThread```:线程数量。 +8. ```-p或--padding```:图像预处理,在图片外周添加白边,用于提升识别率,文字框没有正确框住所有文字时,增加此值。 +9. ```-s或--maxSideLen``` + :按图片最长边的长度,此值为0代表不缩放,例:1024,如果图片长边大于1024则把图像整体缩小到1024再进行图像分割计算,如果图片长边小于1024则不缩放,如果图片长边小于32,则缩放到32。 +10. ```-b或--boxScoreThresh```:文字框置信度门限,文字框没有正确框住所有文字时,减小此值。 +11. ```-o或--boxThresh```:请自行试验。 +12. ```-u或--unClipRatio```:单个文字框大小倍率,越大时单个文字框越大。此项与图片的大小相关,越大的图片此值应该越大。 +13. ```-a或--doAngle```:启用(1)/禁用(0) 文字方向检测,只有图片倒置的情况下(旋转90~270度的图片),才需要启用文字方向检测。 +14. ```-A或--mostAngle```:启用(1)/禁用(0) 角度投票(整张图片以最大可能文字方向来识别),当禁用文字方向检测时,此项也不起作用。 +15. ```-h或--help```:打印命令行帮助。 + diff --git a/others/README-clib.txt b/others/README-clib.txt new file mode 100644 index 0000000..36b4e2e --- /dev/null +++ b/others/README-clib.txt @@ -0,0 +1,4 @@ +### 说明 +请参考此仓库 +https://github.com/RapidAI/RapidOcrOnnxLibTest + diff --git a/others/README-jni.txt b/others/README-jni.txt new file mode 100644 index 0000000..3b973d3 --- /dev/null +++ b/others/README-jni.txt @@ -0,0 +1,3 @@ +### 说明 +请参考此仓库 +https://github.com/RapidAI/RapidOcrOnnxJvm \ No newline at end of file