Skip to content

Test and harden long-image OCR slicing#369

Merged
ModerRAS merged 1 commit into
masterfrom
test/long-image-ocr-slicing-regressions
Jul 26, 2026
Merged

Test and harden long-image OCR slicing#369
ModerRAS merged 1 commit into
masterfrom
test/long-image-ocr-slicing-regressions

Conversation

@ModerRAS

@ModerRAS ModerRAS commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • carry slice overlap metadata into OCR result merging and deduplicate only real overlap boundaries
  • judge safe cut points with the same seven-row density window used for cut selection
  • add regressions for one-row false blanks, safe-cut repeated tokens, and overlap deduplication
  • replace pixel-by-pixel test setup with Skia drawing to keep the expanded suite fast

Accuracy evidence

A local ChineseV3 A/B probe used a generated 1000x7000 image with 116 labeled Chinese/English lines:

Scenario Whole image Sliced Avg. confidence
Safe blank cuts 76.70% 99.95% 70.51% -> 94.11%
Forced 96px overlap 64.84% 99.97% 70.89% -> 93.84%

The real-engine probe is not part of CI because the current Paddle inference runtime is Windows-specific and OCR output depends on native runtime/font rendering. The deterministic boundary behavior is covered by unit and service-level tests instead.

Validation

  • dotnet test TelegramSearchBot.Test/TelegramSearchBot.Test.csproj --filter "FullyQualifiedName~LongImageOcrSlicerTests" --configuration Debug --no-restore: 12/12 passed
  • dotnet build TelegramSearchBot.sln --configuration Release: succeeded with 0 errors (434 existing warnings)

Summary by CodeRabbit

  • Bug Fixes
    • Improved OCR processing for long images by selecting safer slice boundaries based on surrounding image density.
    • Prevented duplicated text at overlapping slice boundaries while preserving repeated text when slices do not overlap.
    • Continued ignoring blank OCR results when combining output.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ModerRAS, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ddd5a1f8-eace-4142-8b2d-79e9b3a76700

📥 Commits

Reviewing files that changed from the base of the PR and between dc5d5c4 and 286c60f.

📒 Files selected for processing (3)
  • TelegramSearchBot.Test/Service/AI/OCR/LongImageOcrSlicerTests.cs
  • TelegramSearchBot/Service/AI/OCR/LongImageOcrSlicer.cs
  • TelegramSearchBot/Service/AI/OCR/PaddleOCRService.cs
📝 Walkthrough

Walkthrough

Long-image OCR slicing now averages row density around candidate cuts and passes slice metadata into result merging. Overlapping slices deduplicate repeated boundary tokens, while non-overlapping safe cuts preserve them. Tests cover both behaviors and use canvas-based image fixtures.

Changes

OCR overlap handling

Layer / File(s) Summary
Density-based cut selection
TelegramSearchBot/Service/AI/OCR/LongImageOcrSlicer.cs
Adds CutDensityRadius and uses averaged row density for safe-cut checks and best-cut scoring.
Overlap-aware result merging
TelegramSearchBot/Service/AI/OCR/LongImageOcrSlicer.cs, TelegramSearchBot/Service/AI/OCR/PaddleOCRService.cs
Aggregates slice/text pairs and removes repeated boundary tokens only when slices overlap.
Overlap behavior tests
TelegramSearchBot.Test/Service/AI/OCR/LongImageOcrSlicerTests.cs
Covers safe-cut preservation, overlapping-boundary deduplication, and canvas-based OCR image fixtures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PaddleOCRService
  participant LongImageOcrSlicer
  participant ExecuteSliceAsync
  PaddleOCRService->>LongImageOcrSlicer: plan OCR slices
  LongImageOcrSlicer-->>PaddleOCRService: OcrImageSlice list
  loop each slice
    PaddleOCRService->>ExecuteSliceAsync: process slice
    ExecuteSliceAsync-->>PaddleOCRService: OCR text
  end
  PaddleOCRService->>LongImageOcrSlicer: merge slice and text pairs
  LongImageOcrSlicer-->>PaddleOCRService: merged OCR text
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: testing and strengthening long-image OCR slicing behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/long-image-ocr-slicing-regressions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ModerRAS

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

PR Check Report

Summary

Test Results

Platform Status Details
Ubuntu Passed Tests passed, artifacts uploaded
Windows Passed Tests passed, artifacts uploaded

Code Quality

  • Code formatting check
  • Security vulnerability scan
  • Dependency analysis
  • Code coverage collection

Test Artifacts

  • Test results artifacts count: 2
  • Code coverage uploaded to Codecov

Links


This report is auto-generated by GitHub Actions

@ModerRAS
ModerRAS force-pushed the test/long-image-ocr-slicing-regressions branch from dc5d5c4 to 286c60f Compare July 26, 2026 01:51
@ModerRAS
ModerRAS merged commit fb2e098 into master Jul 26, 2026
5 checks passed
@ModerRAS
ModerRAS deleted the test/long-image-ocr-slicing-regressions branch July 26, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant