Report errors with original DEM indexing#186
Merged
Merged
Conversation
…culation Fix Simplex cost_from_errors to use provided errors and const-qualify mask/cost helpers
…o fix the test failure caused by the previous fix to the cost from errors function in simplex
…into codex/add-index-translation-vectors-for-dem-errors
…rs-for-dem-errors Add index translation vectors for DEM errors
LalehB
approved these changes
Feb 16, 2026
| #include <cassert> | ||
| #include <functional> // For std::hash (though not strictly necessary here, but good practice) | ||
| #include <iostream> | ||
| #include <numeric> |
Collaborator
There was a problem hiding this comment.
super nit: for a more robust build you can also include since you this file and simplex.cc are using numeric_limits but that relies on transitive incude
Contributor
Author
There was a problem hiding this comment.
Ah got it, I'll #include <limits> as well, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A big flaw in Tesseract's API is that error indices are always in terms of the internal
errorsvector, which does not correspond directly to the errors in the (flattened) input DEM given by the user. This causes a variety of problems. One such problem is that if we generate a DEM with--dem-out(or e.g. similar manual processing steps in python) it may bear little resemblance to the input DEM. For example all the targets will be stripped of separators etc. This makes it annoying to use tesseract-calibrated error models for downstream tasks like matching-based decoding.Here we adopt the principle that the user interface to Tesseract/Simplex decoders should always be in terms of the error indices from the original flattened DEM as provided by the user. This is now true across C++, CLI, and Python APIs.
error_index_mapmaps original error index to new preprocessed indexerror_index_mapmaps removed / redundant errors to std::numeric_limits<size_t>::max()D0 ^ D0 D1) when writing estimated DEM output.