mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +08:00
Add const attribute to some functions (API change)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
253751c331
commit
63f4463028
@ -158,7 +158,7 @@ public:
|
||||
/**
|
||||
* Get value of named variable as a string, if it exists.
|
||||
*/
|
||||
bool GetVariableAsString(const char *name, std::string *val);
|
||||
bool GetVariableAsString(const char *name, std::string *val) const;
|
||||
|
||||
/**
|
||||
* Instances are now mostly thread-safe and totally independent,
|
||||
@ -530,7 +530,7 @@ public:
|
||||
*/
|
||||
char *GetUTF8Text();
|
||||
|
||||
size_t GetNumberOfTables();
|
||||
size_t GetNumberOfTables() const;
|
||||
|
||||
/// Return the i-th table bounding box coordinates
|
||||
///
|
||||
@ -699,9 +699,9 @@ public:
|
||||
* @warning temporary! This function will be removed from here and placed
|
||||
* in a separate API at some future time.
|
||||
*/
|
||||
int IsValidWord(const char *word);
|
||||
int IsValidWord(const char *word) const;
|
||||
// Returns true if utf8_character is defined in the UniCharset.
|
||||
bool IsValidCharacter(const char *utf8_character);
|
||||
bool IsValidCharacter(const char *utf8_character) const;
|
||||
|
||||
bool GetTextDirection(int *out_offset, float *out_slope);
|
||||
|
||||
@ -727,7 +727,7 @@ public:
|
||||
bool **vertical_writing);
|
||||
|
||||
/** This method returns the string form of the specified unichar. */
|
||||
const char *GetUnichar(int unichar_id);
|
||||
const char *GetUnichar(int unichar_id) const;
|
||||
|
||||
/** Return the pointer to the i-th dawg loaded into tesseract_ object. */
|
||||
const Dawg *GetDawg(int i) const;
|
||||
@ -779,7 +779,7 @@ protected:
|
||||
* and assuming a single character reject marker for each rejected character.
|
||||
* Also return the number of recognized blobs in blob_count.
|
||||
*/
|
||||
int TextLength(int *blob_count);
|
||||
int TextLength(int *blob_count) const;
|
||||
|
||||
//// paragraphs.cpp ////////////////////////////////////////////////////
|
||||
void DetectParagraphs(bool after_text_recognition);
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
ScriptDetector(const std::vector<int> *allowed_scripts, OSResults *osr,
|
||||
tesseract::Tesseract *tess);
|
||||
void detect_blob(BLOB_CHOICE_LIST *scores);
|
||||
bool must_stop(int orientation);
|
||||
bool must_stop(int orientation) const;
|
||||
|
||||
private:
|
||||
OSResults *osr_;
|
||||
|
@ -90,7 +90,7 @@ public:
|
||||
}
|
||||
|
||||
// Is everything fine? Otherwise something went wrong.
|
||||
bool happy() {
|
||||
bool happy() const {
|
||||
return happy_;
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ bool TessBaseAPI::GetDoubleVariable(const char *name, double *value) const {
|
||||
}
|
||||
|
||||
/** Get value of named variable as a string, if it exists. */
|
||||
bool TessBaseAPI::GetVariableAsString(const char *name, std::string *val) {
|
||||
bool TessBaseAPI::GetVariableAsString(const char *name, std::string *val) const {
|
||||
return ParamUtils::GetParamAsString(name, tesseract_->params(), val);
|
||||
}
|
||||
|
||||
@ -1349,7 +1349,7 @@ char *TessBaseAPI::GetUTF8Text() {
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t TessBaseAPI::GetNumberOfTables()
|
||||
size_t TessBaseAPI::GetNumberOfTables() const
|
||||
{
|
||||
return constUniqueInstance<std::vector<TessTable>>().size();
|
||||
}
|
||||
@ -1973,11 +1973,11 @@ void TessBaseAPI::ClearPersistentCache() {
|
||||
* Check whether a word is valid according to Tesseract's language model
|
||||
* returns 0 if the word is invalid, non-zero if valid
|
||||
*/
|
||||
int TessBaseAPI::IsValidWord(const char *word) {
|
||||
int TessBaseAPI::IsValidWord(const char *word) const {
|
||||
return tesseract_->getDict().valid_word(word);
|
||||
}
|
||||
// Returns true if utf8_character is defined in the UniCharset.
|
||||
bool TessBaseAPI::IsValidCharacter(const char *utf8_character) {
|
||||
bool TessBaseAPI::IsValidCharacter(const char *utf8_character) const {
|
||||
return tesseract_->unicharset.contains_unichar(utf8_character);
|
||||
}
|
||||
|
||||
@ -2225,7 +2225,7 @@ void TessBaseAPI::ClearResults() {
|
||||
* character.
|
||||
* Also return the number of recognized blobs in blob_count.
|
||||
*/
|
||||
int TessBaseAPI::TextLength(int *blob_count) {
|
||||
int TessBaseAPI::TextLength(int *blob_count) const {
|
||||
if (tesseract_ == nullptr || page_res_ == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
@ -2352,7 +2352,7 @@ void TessBaseAPI::DetectParagraphs(bool after_text_recognition) {
|
||||
}
|
||||
|
||||
/** This method returns the string form of the specified unichar. */
|
||||
const char *TessBaseAPI::GetUnichar(int unichar_id) {
|
||||
const char *TessBaseAPI::GetUnichar(int unichar_id) const {
|
||||
return tesseract_->unicharset.id_to_unichar(unichar_id);
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ void ScriptDetector::detect_blob(BLOB_CHOICE_LIST *scores) {
|
||||
} // iterate over each orientation
|
||||
}
|
||||
|
||||
bool ScriptDetector::must_stop(int orientation) {
|
||||
bool ScriptDetector::must_stop(int orientation) const {
|
||||
osr_->update_best_script(orientation);
|
||||
return osr_->best_result.sconfidence > 1;
|
||||
}
|
||||
|
@ -65,10 +65,10 @@ public:
|
||||
const char *GetName() const;
|
||||
const char *GetDescription() const;
|
||||
|
||||
int GetId() {
|
||||
int GetId() const {
|
||||
return my_id_;
|
||||
}
|
||||
bool HasChanged() {
|
||||
bool HasChanged() const {
|
||||
return changed_;
|
||||
}
|
||||
|
||||
|
@ -720,10 +720,8 @@ public:
|
||||
|
||||
void print_rows() { // debug info
|
||||
TO_ROW_IT row_it = &row_list;
|
||||
TO_ROW *row;
|
||||
|
||||
for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
|
||||
row = row_it.data();
|
||||
auto row = row_it.data();
|
||||
tprintf("Row range (%g,%g), para_c=%g, blobcount=%" PRId32 "\n", row->min_y(), row->max_y(),
|
||||
row->parallel_c(), row->blob_list()->length());
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void ROW::move( // reposition row
|
||||
|
||||
void ROW::print( // print
|
||||
FILE *fp // file to print on
|
||||
) {
|
||||
) const {
|
||||
tprintf("Kerning= %d\n", kerning);
|
||||
tprintf("Spacing= %d\n", spacing);
|
||||
bound_box.print();
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
const ICOORD vec); // by vector
|
||||
|
||||
void print( // print
|
||||
FILE *fp); // file to print on
|
||||
FILE *fp) const; // file to print on
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
void plot( // draw one
|
||||
|
@ -726,7 +726,7 @@ void WERD_RES::PrintBestChoices() const {
|
||||
|
||||
// Returns the sum of the widths of the blob between start_blob and last_blob
|
||||
// inclusive.
|
||||
int WERD_RES::GetBlobsWidth(int start_blob, int last_blob) {
|
||||
int WERD_RES::GetBlobsWidth(int start_blob, int last_blob) const {
|
||||
int result = 0;
|
||||
for (int b = start_blob; b <= last_blob; ++b) {
|
||||
result += blob_widths[b];
|
||||
@ -737,7 +737,7 @@ int WERD_RES::GetBlobsWidth(int start_blob, int last_blob) {
|
||||
return result;
|
||||
}
|
||||
// Returns the width of a gap between the specified blob and the next one.
|
||||
int WERD_RES::GetBlobsGap(int blob_index) {
|
||||
int WERD_RES::GetBlobsGap(int blob_index) const {
|
||||
if (blob_index < 0 || blob_index >= blob_gaps.size()) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -546,9 +546,9 @@ public:
|
||||
|
||||
// Returns the sum of the widths of the blob between start_blob and last_blob
|
||||
// inclusive.
|
||||
int GetBlobsWidth(int start_blob, int last_blob);
|
||||
int GetBlobsWidth(int start_blob, int last_blob) const;
|
||||
// Returns the width of a gap between the specified blob and the next one.
|
||||
int GetBlobsGap(int blob_index);
|
||||
int GetBlobsGap(int blob_index) const;
|
||||
|
||||
// Returns the BLOB_CHOICE corresponding to the given index in the
|
||||
// best choice word taken from the appropriate cell in the ratings MATRIX.
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
void forward();
|
||||
|
||||
/// test end
|
||||
bool cycled_rects() {
|
||||
bool cycled_rects() const {
|
||||
return left_it.cycled_list() && right_it.cycled_list();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
* File: quadlsq.h (Formerly qlsq.h)
|
||||
* Description: Code for least squares approximation of quadratics.
|
||||
* Author: Ray Smith
|
||||
* Created: Wed Oct 6 15:14:23 BST 1993
|
||||
*
|
||||
* (C) Copyright 1993, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -43,13 +42,13 @@ public:
|
||||
|
||||
void fit( // fit the given
|
||||
int degree); // return actual
|
||||
double get_a() { // get x squard
|
||||
double get_a() const { // get x squard
|
||||
return a;
|
||||
}
|
||||
double get_b() { // get x squard
|
||||
double get_b() const { // get x squard
|
||||
return b;
|
||||
}
|
||||
double get_c() { // get x squard
|
||||
double get_c() const { // get x squard
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ void WERD::copy_on(WERD *other) {
|
||||
* Display members
|
||||
*/
|
||||
|
||||
void WERD::print() {
|
||||
void WERD::print() const {
|
||||
tprintf("Blanks= %d\n", blanks);
|
||||
bounding_box().print();
|
||||
tprintf("Flags = %lu = 0%lo\n", flags.to_ulong(), flags.to_ulong());
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
void copy_on(WERD *other);
|
||||
|
||||
// tprintf word metadata (but not blob innards)
|
||||
void print();
|
||||
void print() const;
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
// plot word on window in a uniform colour
|
||||
|
@ -247,11 +247,11 @@ public:
|
||||
const char *c_str() const {
|
||||
return value_.c_str();
|
||||
}
|
||||
bool contains(char c) {
|
||||
bool contains(char c) const {
|
||||
return value_.find(c) != std::string::npos;
|
||||
}
|
||||
bool empty() {
|
||||
return value_.length() <= 0;
|
||||
bool empty() const {
|
||||
return value_.empty();
|
||||
}
|
||||
bool operator==(const std::string &other) {
|
||||
return value_ == other;
|
||||
|
@ -2,7 +2,6 @@
|
||||
// File: qrsequence.h
|
||||
// Description: Quasi-random sequence generator class.
|
||||
// Author: Ranjith Unnikrishnan
|
||||
// Created: Wed May 20 2009
|
||||
//
|
||||
// Class to generate a (deterministic) quasi-random Van der Corput sequence that
|
||||
// covers the interval [0,N) without repetition.
|
||||
|
Loading…
Reference in New Issue
Block a user