tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
21 #include "config_auto.h"
40 #ifndef GRAPHICS_DISABLED
41 #define ASC_HEIGHT (2 * kBlnBaselineOffset + kBlnXHeight)
42 #define X_HEIGHT (kBlnBaselineOffset + kBlnXHeight)
43 #define BL_HEIGHT kBlnBaselineOffset
101 static bool stillRunning =
false;
107 static bool recog_done =
false;
111 static BITS16 word_display_mode;
113 static bool display_image =
false;
114 static bool display_blocks =
false;
115 static bool display_baselines =
false;
117 static PAGE_RES *current_page_res =
nullptr;
120 "Editor image window name");
123 static INT_VAR(editor_image_menuheight, 50,
"Add to image height for menu bar");
125 "Word bounding box colour");
127 "Blob bounding box colour");
129 "Correct text colour");
132 "Editor debug window name");
151 static void show_point(
PAGE_RES* page_res,
float x,
float y) {
155 const int kBufsize = 512;
159 msg_ptr += sprintf(msg_ptr,
"Pt:(%0.3f, %0.3f) ", x, y);
161 for (
WERD_RES* word = pr_it.
word(); word !=
nullptr; word = pr_it.forward()) {
162 if (pr_it.row() != pr_it.prev_row() &&
163 pr_it.row()->row->bounding_box().contains(pt)) {
164 msg_ptr += sprintf(msg_ptr,
"BL(x)=%0.3f ",
165 pr_it.row()->row->base_line(x));
167 if (word->word->bounding_box().contains(pt)) {
168 TBOX box = word->word->bounding_box();
169 msg_ptr += sprintf(msg_ptr,
"Wd(%d, %d)/(%d, %d) ",
172 C_BLOB_IT cblob_it(word->word->cblob_list());
173 for (cblob_it.mark_cycle_pt();
174 !cblob_it.cycled_list();
175 cblob_it.forward()) {
176 C_BLOB* cblob = cblob_it.data();
179 msg_ptr += sprintf(msg_ptr,
180 "CBlb(%d, %d)/(%d, %d) ",
196 static void pgeditor_msg(
205 bln_word_window =
nullptr;
207 show_point(current_page_res, sv_event->
x, sv_event->
y);
218 if (bln_word_window ==
nullptr) {
219 pgeditor_msg(
"Creating BLN word window...");
225 pgeditor_msg(
"Creating BLN word window...Done");
227 return bln_word_window;
237 static void build_image_window(
int width,
int height) {
242 height + editor_image_menuheight + 1,
255 float scale_factor,
float y_offset,
256 float minx,
float maxx) {
261 maxx, y_offset + scale_factor *
BL_HEIGHT);
263 maxx, y_offset + scale_factor *
X_HEIGHT);
283 if (strcmp(event->
parameter,
"true") == 0) { myval =
'T'; }
284 else if (strcmp(event->
parameter,
"false") == 0) { myval =
'F'; }
313 parent_menu = root_menu_item->
AddChild(
"DISPLAY");
332 parent_menu = root_menu_item->
AddChild(
"OTHER");
341 return root_menu_item;
355 image_win->
Image(pix_binary_, 0, 0);
361 (this->*word_painter)(&pr_it);
362 if (display_baselines && pr_it.
row() != pr_it.
prev_row())
379 current_page_res = page_res;
386 build_image_window(width, height);
389 #ifndef GRAPHICS_DISABLED
458 mode =static_cast<CMD_EVENTS>(cmd_event);
463 word_config_ = parameter;
467 if (new_value[0] ==
'T')
474 if (new_value[0] ==
'T')
482 if (new_value[0] ==
'T')
489 if (new_value[0] ==
'T')
496 if (new_value[0] ==
'T')
503 if (new_value[0] ==
'T')
513 display_image =(new_value[0] ==
'T');
517 display_blocks =(new_value[0] ==
'T');
521 display_baselines =(new_value[0] ==
'T');
569 snprintf(msg,
sizeof(msg),
"Unrecognised event %" PRId32
"(%s)",
570 cmd_event, new_value);
603 show_point(current_page_res, event.
x, event.
y);
609 selection_box =
TBOX(down, up);
635 #ifndef DISABLED_LEGACY_ENGINE
636 image_win->
AddMessage(
"Recogging selected words");
640 #endif // ndef DISABLED_LEGACY_ENGINE
643 image_win->
AddMessage(
"Recogging selected blobs");
651 sprintf(msg,
"Mode %d not yet implemented", mode);
666 #ifndef DISABLED_LEGACY_ENGINE
693 #endif // GRAPHICS_DISABLED
695 #ifndef GRAPHICS_DISABLED
719 bln_word_window_handle()->
Clear();
721 1.0, 0.0f, -1000.0f, 1000.0f);
724 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
726 bln_word_window_handle());
729 bln_word_window_handle()->
Update();
745 bool displayed_something =
false;
749 #ifndef DISABLED_LEGACY_ENGINE
752 int length = box_word->
length();
753 if (word_res->
fontinfo ==
nullptr)
return false;
755 for (
int i = 0; i < length; ++i) {
757 switch (color_mode) {
795 image_win->
Pen(color);
802 #endif // ndef DISABLED_LEGACY_ENGINE
811 static_cast<ScrollView::Color>((int32_t)
813 static_cast<ScrollView::Color>((int32_t)
820 for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward())
821 c_it.data()->bounding_box().plot(image_win);
822 displayed_something =
true;
827 word->
plot(image_win);
828 displayed_something =
true;
835 tword->
plot(image_win);
837 displayed_something =
true;
851 if (blamer_bundle ==
nullptr) {
859 best_choice_str =
"NULL";
863 text += best_choice_str;
874 word_height = word_bb.
height();
875 int text_height = 0.50 * word_height;
876 if (text_height > 20) text_height = 20;
877 image_win->
TextAttributes(
"Arial", text_height,
false,
false,
false);
878 shift = (word_height < word_bb.
width()) ? 0.25 * word_height : 0.0f;
879 image_win->
Text(word_bb.
left() + shift,
880 word_bb.
bottom() + 0.25 * word_height, text.
c_str());
882 image_win->
Text(word_bb.
left() + shift,
883 word_bb.
bottom() + 0.25 * word_height - text_height,
887 displayed_something =
true;
890 if (!displayed_something)
893 static_cast<ScrollView::Color>((int32_t)
897 #endif // GRAPHICS_DISABLED
916 tprintf(
"Current blamer debug: %s\n",
922 #ifndef GRAPHICS_DISABLED
944 const TBOX& selection_box) {
945 #ifndef DISABLED_LEGACY_ENGINE
962 &cn_features, &fx_info,
nullptr);
966 for (
int f = 0; f < bl_features.
size(); ++f)
972 for (
int f = 0; f < cn_features.
size(); ++f)
979 #endif // ndef DISABLED_LEGACY_ENGINE
983 #endif // GRAPHICS_DISABLED
#define INT_VAR(name, val, comment)
void set_x(int16_t xin)
rewrite function
bool poly_allow_detailed_fx
void Notify(const SVEvent *sv_event) override
STRING TruthString() const
TBOX bounding_box() const
tesseract::BoxWord * box_word
void recog_pseudo_word(PAGE_RES *page_res, TBOX &selection_box)
void turn_on_bit(uint8_t bit_num)
void AddMessage(const char *format,...)
bool bit(uint8_t bit_num) const
int editor_image_blob_bb_color
bool textord_use_cjk_fp_model
void SetVisible(bool visible)
static ScrollView::Color NextColor(ScrollView::Color colour)
void Notify(const SVEvent *sve) override
TBOX bounding_box() const
SVMenuNode * AddChild(const char *txt)
bool display_flag(uint8_t flag) const
void debug_word(PAGE_RES *page_res, const TBOX &selection_box)
void plot(ScrollView *window, ScrollView::Color colour)
BLOCK_RES * block() const
bool contains(const FCOORD pt) const
bool recog_interactive(PAGE_RES_IT *pr_it)
static void ExtractFeatures(const TBLOB &blob, bool nonlinear_norm, GenericVector< INT_FEATURE_STRUCT > *bl_features, GenericVector< INT_FEATURE_STRUCT > *cn_features, INT_FX_RESULT_STRUCT *results, GenericVector< int > *outline_cn_counts)
const FontInfo * fontinfo
#define STRING_VAR(name, val, comment)
void Image(struct Pix *image, int x_pos, int y_pos)
ROW_RES * prev_row() const
void set_display_flag(uint8_t flag, bool value)
tesseract::ScriptPos BlobPosition(int index) const
void set_y(int16_t yin)
rewrite function
BLOCK_RES_LIST block_res_list
void pgeditor_main(int width, int height, PAGE_RES *page_res)
C_BLOB_LIST * cblob_list()
BlamerBundle * blamer_bundle
void Notify(const SVEvent *sve) override
static const char * IncorrectReasonName(IncorrectResultReason irr)
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
SVMenuNode * build_menu_new()
void print(FILE *fp, bool dump)
dump whole table
PDBLK pdblk
Page Description Block.
bool word_bln_display(PAGE_RES_IT *pr_it)
const TBOX & BlobBox(int index) const
WERD_CHOICE * best_choice
bool SetupForRecognition(const UNICHARSET &unicharset_in, tesseract::Tesseract *tesseract, Pix *pix, int norm_mode, const TBOX *norm_box, bool numeric_mode, bool use_body_size, bool allow_detailed_fx, ROW *row, const BLOCK *block)
const char * c_str() const
void plot_baseline(ScrollView *window, ScrollView::Color colour)
void turn_off_bit(uint8_t bit_num)
bool classify_nonlinear_norm
BLOCK_RES * prev_block() const
GenericVector< TBLOB * > blobs
static TWERD * PolygonalCopy(bool allow_detailed_fx, WERD *src)
void do_re_display(bool(tesseract::Tesseract::*word_painter)(PAGE_RES_IT *pr_it))
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
bool process_cmd_win_event(int32_t cmd_event, char *new_value)
bool is_fixed_pitch() const
void process_selected_words(PAGE_RES *page_res, TBOX &selection_box, bool(tesseract::Tesseract::*word_processor)(PAGE_RES_IT *pr_it))
void plot(ScrollView *fd) const
bool word_display(PAGE_RES_IT *pr_it)
void blob_feature_display(PAGE_RES *page_res, const TBOX &selection_box)
void BuildMenu(ScrollView *sv, bool menu_bar=true)
SVEvent * AwaitEvent(SVEventType type)
bool wordrec_debug_blamer
void process_image_event(const SVEvent &event)
int editor_image_text_color
int editor_image_word_bb_color
const STRING & debug() const
const char * text() const
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
void Line(int x1, int y1, int x2, int y2)
DLLSYM void tprintf(const char *format,...)
void plot(ScrollView *window, int32_t serial, ScrollView::Color colour)
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
void plot(ScrollView *window)
IncorrectResultReason incorrect_result_reason() const
void Text(int x, int y, const char *mystring)
bool word_blank_and_set_display(PAGE_RES_IT *pr_its)
bool word_set_display(PAGE_RES_IT *pr_it)
void ResetAdaptiveClassifier()
bool classify_bln_numeric_mode
char * ShowInputDialog(const char *msg)
void Rectangle(int x1, int y1, int x2, int y2)
bool word_dumper(PAGE_RES_IT *pr_it)
int tessedit_ocr_engine_mode
void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView *window)
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
char * editor_image_win_name