Catch nullptr in PageIterator::Orientation to improve robustness

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2022-02-03 08:31:31 +01:00
parent 31a968432d
commit 443933a75a

View File

@ -566,7 +566,15 @@ void PageIterator::Orientation(tesseract::Orientation *orientation,
tesseract::WritingDirection *writing_direction,
tesseract::TextlineOrder *textline_order,
float *deskew_angle) const {
BLOCK *block = it_->block()->block;
auto *block_res = it_->block();
if (block_res == nullptr) {
// Nothing can be done, so return default values.
*orientation = ORIENTATION_PAGE_UP;
*writing_direction = WRITING_DIRECTION_LEFT_TO_RIGHT;
*textline_order = TEXTLINE_ORDER_TOP_TO_BOTTOM;
return;
}
auto *block = block_res->block;
// Orientation
FCOORD up_in_image(0.0, 1.0);