Skip to content

Commit

Permalink
Replace STRING by std::string for function read_unlv_file
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jan 23, 2021
1 parent 139d127 commit 4b84a56
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
11 changes: 3 additions & 8 deletions src/ccmain/osdetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,9 @@ static void remove_nontext_regions(tesseract::Tesseract *tess,
int orientation_and_script_detection(const char* filename,
OSResults* osr,
tesseract::Tesseract* tess) {
STRING name = filename; //truncated name
const char *lastdot; //of name
TBOX page_box;
std::string name = filename; //truncated name

lastdot = strrchr(name.c_str(), '.');
const char* lastdot = strrchr(name.c_str(), '.');
if (lastdot != nullptr)
name[lastdot-name.c_str()] = '\0';

Expand All @@ -218,10 +216,7 @@ int orientation_and_script_detection(const char* filename,
tess->mutable_textord()->find_components(tess->pix_binary(),
&blocks, &port_blocks);
} else {
page_box.set_left(0);
page_box.set_bottom(0);
page_box.set_right(width);
page_box.set_top(height);
TBOX page_box(0, 0, width, height);
// Filter_blobs sets up the TO_BLOCKs the same as find_components does.
tess->mutable_textord()->filter_blobs(page_box.topright(),
&port_blocks, true);
Expand Down
2 changes: 1 addition & 1 deletion src/ccmain/pagesegmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int Tesseract::SegmentPage(const char* input_file, BLOCK_LIST* blocks,
// If a UNLV zone file can be found, use that instead of segmentation.
if (!PSM_COL_FIND_ENABLED(pageseg_mode) &&
input_file != nullptr && input_file[0] != '\0') {
STRING name = input_file;
std::string name = input_file;
const char* lastdot = strrchr(name.c_str(), '.');
if (lastdot != nullptr)
name[lastdot - name.c_str()] = '\0';
Expand Down
8 changes: 4 additions & 4 deletions src/ccstruct/blread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace tesseract {
**********************************************************************/

bool read_unlv_file( //print list of sides
STRING name, //basename of file
int32_t xsize, //image size
int32_t ysize, //image size
BLOCK_LIST *blocks //output list
std::string& name, //basename of file
int32_t xsize, //image size
int32_t ysize, //image size
BLOCK_LIST* blocks //output list
) {
FILE *pdfp; //file pointer
BLOCK *block; //current block
Expand Down
15 changes: 7 additions & 8 deletions src/ccstruct/blread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* File: blread.h (Formerly pdread.h)
* Description: Friend function of BLOCK to read the uscan pd file.
* Author: Ray Smith
* Created: Mon Mar 18 14:39:00 GMT 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,21 +19,21 @@
#ifndef BLREAD_H
#define BLREAD_H

#include "strngs.h" // for STRING

#include <cstdint> // for int32_t
#include <string> // for std::string

namespace tesseract {

class BLOCK_LIST;

bool read_unlv_file( //print list of sides
STRING name, //basename of file
int32_t xsize, //image size
int32_t ysize, //image size
BLOCK_LIST *blocks //output list
std::string& name, //basename of file
int32_t xsize, //image size
int32_t ysize, //image size
BLOCK_LIST* blocks //output list
);
void FullPageBlock(int width, int height, BLOCK_LIST *blocks);

void FullPageBlock(int width, int height, BLOCK_LIST* blocks);

} // namespace tesseract

Expand Down

0 comments on commit 4b84a56

Please sign in to comment.