Merge branch 'tesseract-ocr:main' into 3871-disappearing-word

This commit is contained in:
rmast 2022-10-23 08:55:42 +02:00 committed by GitHub
commit cef102fdb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 34 additions and 23 deletions

View File

@ -14,11 +14,11 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
config: config:
- { name: macos-12-clang-13-autotools, os: macos-12, cxx: clang++ } - { name: macos-12-clang-14-autotools, os: macos-12, cxx: clang++ }
- { name: macos-12-gcc-11-autotools, os: macos-12, cxx: g++-11 } #- { name: macos-12-gcc-11-autotools, os: macos-12, cxx: g++-11 }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
@ -115,10 +115,10 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
config: config:
- { name: macos-10.15-clang-12-autotools, os: macos-10.15, cxx: clang++ } - { name: macos-12-clang-14-autotools, os: macos-12, cxx: clang++ }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -17,7 +17,7 @@ jobs:
- { name: 22.04-openmp, os: ubuntu-22.04 } - { name: 22.04-openmp, os: ubuntu-22.04 }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -24,7 +24,7 @@ jobs:
- { name: ubuntu-20.04-gcc-10-autotools, os: ubuntu-20.04, cxx: g++-10 } #installed - { name: ubuntu-20.04-gcc-10-autotools, os: ubuntu-20.04, cxx: g++-10 } #installed
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -26,7 +26,7 @@ jobs:
fuzz-seconds: 600 fuzz-seconds: 600
dry-run: false dry-run: false
- name: Upload Crash - name: Upload Crash
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success' if: failure() && steps.build.outcome == 'success'
with: with:
name: artifacts name: artifacts

View File

@ -151,7 +151,7 @@ jobs:
tesseract test/testing/phototest.tif - tesseract test/testing/phototest.tif -
- name: Upload Build Results - name: Upload Build Results
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: tesseract-${{ steps.get_version.outputs.VERSION }}-VS2019_win64 name: tesseract-${{ steps.get_version.outputs.VERSION }}-VS2019_win64
path: ${{env.ILOC}} path: ${{env.ILOC}}

View File

@ -61,7 +61,7 @@ jobs:
if: runner.os == 'macOS' if: runner.os == 'macOS'
- name: Checkout Source - name: Checkout Source
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -55,7 +55,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Install dependencies - name: Install dependencies
run: | run: |

View File

@ -19,7 +19,7 @@ jobs:
run: run:
shell: msys2 {0} shell: msys2 {0}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- uses: msys2/setup-msys2@v2 - uses: msys2/setup-msys2@v2

View File

@ -28,7 +28,7 @@ jobs:
os: [windows-2022, windows-2019, ubuntu-22.04, ubuntu-20.04, macos-12] os: [windows-2022, windows-2019, ubuntu-22.04, ubuntu-20.04, macos-12]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- uses: egorpugin/sw-action@master - uses: egorpugin/sw-action@master
@ -71,7 +71,7 @@ jobs:
- name: Upload Unit Test Results - name: Upload Unit Test Results
if: always() && matrix.os != 'windows-2022' && matrix.os != 'windows-2019' if: always() && matrix.os != 'windows-2022' && matrix.os != 'windows-2019'
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: Test Results (${{ matrix.os }}) name: Test Results (${{ matrix.os }})
path: .sw/test/results.xml path: .sw/test/results.xml

View File

@ -17,7 +17,7 @@ jobs:
os: [ ubuntu-20.04 ] os: [ ubuntu-20.04 ]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -17,7 +17,7 @@ jobs:
- { name: macos-12-gcc-unittest, os: macos-12, cxx: g++ } - { name: macos-12-gcc-unittest, os: macos-12, cxx: g++ }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -17,7 +17,7 @@ jobs:
- { name: ubuntu-20.04-gcc-unittest, os: ubuntu-20.04, cxx: g++ } - { name: ubuntu-20.04-gcc-unittest, os: ubuntu-20.04, cxx: g++ }
- { name: ubuntu-22.04-clang-unittest, os: ubuntu-22.04, cxx: clang++ } - { name: ubuntu-22.04-clang-unittest, os: ubuntu-22.04, cxx: clang++ }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -17,7 +17,7 @@ jobs:
steps: steps:
- name: Checkout Tesseract Source (for test images) - name: Checkout Tesseract Source (for test images)
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -16,7 +16,7 @@ jobs:
steps: steps:
- name: Checkout Tesseract Source (--head from main branch) - name: Checkout Tesseract Source (--head from main branch)
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive

View File

@ -287,15 +287,26 @@ bool ImageThresholder::ThresholdToPix(Image *pix) {
tprintf("Image too large: (%d, %d)\n", image_width_, image_height_); tprintf("Image too large: (%d, %d)\n", image_width_, image_height_);
return false; return false;
} }
Image original = GetPixRect();
if (pix_channels_ == 0) { if (pix_channels_ == 0) {
// We have a binary image, but it still has to be copied, as this API // We have a binary image, but it still has to be copied, as this API
// allows the caller to modify the output. // allows the caller to modify the output.
Image original = GetPixRect();
*pix = original.copy(); *pix = original.copy();
original.destroy();
} else { } else {
OtsuThresholdRectToPix(pix_, pix); if (pixGetColormap(original)) {
Image without_cmap =
pixRemoveColormap(original, REMOVE_CMAP_BASED_ON_SRC);
int depth = pixGetDepth(without_cmap);
if (depth > 1 && depth < 8) {
original = pixConvertTo8(without_cmap, false);
} else {
original = without_cmap.copy();
} }
without_cmap.destroy();
}
OtsuThresholdRectToPix(original, pix);
}
original.destroy();
return true; return true;
} }
@ -353,7 +364,7 @@ Image ImageThresholder::GetPixRect() {
Image ImageThresholder::GetPixRectGrey() { Image ImageThresholder::GetPixRectGrey() {
auto pix = GetPixRect(); // May have to be reduced to grey. auto pix = GetPixRect(); // May have to be reduced to grey.
int depth = pixGetDepth(pix); int depth = pixGetDepth(pix);
if (depth != 8) { if (depth != 8 || pixGetColormap(pix)) {
if (depth == 24) { if (depth == 24) {
auto tmp = pixConvert24To32(pix); auto tmp = pixConvert24To32(pix);
pix.destroy(); pix.destroy();