21 #pragma warning(disable:4244) // Conversion warnings
26 #include "config_auto.h"
45 #ifndef GRAPHICS_DISABLED
46 #define ASC_HEIGHT (2 * kBlnBaselineOffset + kBlnXHeight)
47 #define X_HEIGHT (kBlnBaselineOffset + kBlnXHeight)
48 #define BL_HEIGHT kBlnBaselineOffset
50 #define MAXSPACING 128
112 FILE *debug_window =
NULL;
131 "Editor image window name");
136 "Word bounding box colour");
138 "Blob bounding box colour");
140 "Correct text colour");
143 "Editor debug window name");
161 bln_word_window =
NULL;
174 if (bln_word_window ==
NULL) {
218 maxx, y_offset + scale_factor * DESC_HEIGHT);
220 maxx, y_offset + scale_factor * BL_HEIGHT);
222 maxx, y_offset + scale_factor * X_HEIGHT);
224 maxx, y_offset + scale_factor * ASC_HEIGHT);
242 if (strcmp(event->
parameter,
"true") == 0) { myval =
'T'; }
243 else if (strcmp(event->
parameter,
"false") == 0) { myval =
'F'; }
272 parent_menu = root_menu_item->
AddChild(
"DISPLAY");
291 parent_menu = root_menu_item->
AddChild(
"OTHER");
300 return root_menu_item;
314 image_win->
Image(pix_binary_, 0, 0);
320 (this->*word_painter)(&pr_it);
338 current_page_res = page_res;
348 #ifndef GRAPHICS_DISABLED
386 image_win->
AddMessage(
"Pointing at(%d, %d)", event->
x, event->
y);
445 if (new_value[0] ==
'T')
452 if (new_value[0] ==
'T')
460 if (new_value[0] ==
'T')
467 if (new_value[0] ==
'T')
474 if (new_value[0] ==
'T')
481 if (new_value[0] ==
'T')
547 sprintf(msg,
"Unrecognised event " INT32FORMAT "(%s)",
548 cmd_event, new_value);
587 selection_box =
TBOX(down, up);
613 image_win->
AddMessage(
"Recogging selected words");
619 image_win->
AddMessage(
"Recogging selected blobs");
627 sprintf(msg,
"Mode %d not yet implemented",
mode);
659 const int kBufsize = 512;
663 msg_ptr += sprintf(msg_ptr,
"Pt:(%0.3f, %0.3f) ", x, y);
668 msg_ptr += sprintf(msg_ptr,
"BL(x)=%0.3f ",
671 if (word->word->bounding_box().contains(pt)) {
672 TBOX box = word->word->bounding_box();
673 msg_ptr += sprintf(msg_ptr,
"Wd(%d, %d)/(%d, %d) ",
676 C_BLOB_IT cblob_it(word->word->cblob_list());
677 for (cblob_it.mark_cycle_pt();
678 !cblob_it.cycled_list();
679 cblob_it.forward()) {
680 C_BLOB* cblob = cblob_it.data();
683 msg_ptr += sprintf(msg_ptr,
684 "CBlb(%d, %d)/(%d, %d) ",
714 #endif // GRAPHICS_DISABLED
716 #ifndef GRAPHICS_DISABLED
742 1.0, 0.0f, -1000.0f, 1000.0f);
745 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
773 int length = box_word->
length();
776 for (
int i = 0; i < length; ++i) {
778 switch (color_mode) {
816 image_win->
Pen(color);
832 editor_image_word_bb_color));
838 for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward())
839 c_it.data()->bounding_box().plot(image_win);
840 displayed_something =
TRUE;
845 word->
plot(image_win);
846 displayed_something =
TRUE;
853 tword->
plot(image_win);
855 displayed_something =
TRUE;
869 if (blamer_bundle ==
NULL) {
877 best_choice_str =
"NULL";
881 text += best_choice_str;
892 word_height = word_bb.
height();
893 int text_height = 0.50 * word_height;
894 if (text_height > 20) text_height = 20;
895 image_win->
TextAttributes(
"Arial", text_height,
false,
false,
false);
896 shift = (word_height < word_bb.
width()) ? 0.25 * word_height : 0.0f;
897 image_win->
Text(word_bb.
left() + shift,
900 image_win->
Text(word_bb.
left() + shift,
901 word_bb.
bottom() + 0.25 * word_height - text_height,
905 displayed_something =
TRUE;
908 if (!displayed_something)
912 editor_image_word_bb_color));
915 #endif // GRAPHICS_DISABLED
934 tprintf(
"Current blamer debug: %s\n",
940 #ifndef GRAPHICS_DISABLED
961 const TBOX& selection_box) {
978 &cn_features, &fx_info,
NULL);
982 for (
int f = 0; f < bl_features.
size(); ++f)
988 for (
int f = 0; f < cn_features.
size(); ++f)
998 #endif // GRAPHICS_DISABLED
tesseract::ScriptPos BlobPosition(int index) const
void set_x(inT16 xin)
rewrite function
tesseract::BoxWord * box_word
BOOL8 word_dumper(PAGE_RES_IT *pr_it)
bool classify_bln_numeric_mode
BOOL8 recog_interactive(PAGE_RES_IT *pr_it)
BLOCK_RES_LIST block_res_list
void Notify(const SVEvent *sv_event)
void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView *window)
void turn_on_bit(uinT8 bit_num)
PAGE_RES * current_page_res
WERD_CHOICE * best_choice
void plot(ScrollView *window, inT32 serial, ScrollView::Color colour)
const ERRCODE EMPTYBLOCKLIST
void debug_word(PAGE_RES *page_res, const TBOX &selection_box)
BOOL8 bit(uinT8 bit_num) const
void Text(int x, int y, const char *mystring)
const TBOX & BlobBox(int index) const
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
void BuildMenu(ScrollView *sv, bool menu_bar=true)
BOOL8 word_display(PAGE_RES_IT *pr_it)
void ResetAdaptiveClassifier()
void plot_baseline(ScrollView *window, ScrollView::Color colour)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
int editor_image_text_color
BLOCK_RES * prev_block() const
TBOX bounding_box() const
const FontInfo * fontinfo
void AddMessage(const char *format,...)
void Image(struct Pix *image, int x_pos, int y_pos)
void set_display_flag(uinT8 flag, BOOL8 value)
IncorrectResultReason incorrect_result_reason() const
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
void print(FILE *fp, BOOL8 dump)
dump whole table
int editor_image_menuheight
ScrollView * bln_word_window
static TWERD * PolygonalCopy(bool allow_detailed_fx, WERD *src)
float base_line(float xpos) const
char * editor_debug_config_file
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
bool wordrec_debug_blamer
void process_selected_words(PAGE_RES *page_res, TBOX &selection_box, BOOL8(tesseract::Tesseract::*word_processor)(PAGE_RES_IT *pr_it))
BLOCK_RES * block() const
ScrollView * bln_word_window_handle()
void plot(ScrollView *window)
bool classify_nonlinear_norm
void Notify(const SVEvent *sve)
void display_bln_lines(ScrollView *window, ScrollView::Color colour, float scale_factor, float y_offset, float minx, float maxx)
void pgeditor_msg(const char *msg)
STRING TruthString() const
#define STRING_VAR(name, val, comment)
BOOL8 word_set_display(PAGE_RES_IT *pr_it)
void process_image_event(const SVEvent &event)
BOOL8 display_flag(uinT8 flag) const
BOOL8 word_blank_and_set_display(PAGE_RES_IT *pr_its)
bool is_fixed_pitch() const
int tessedit_ocr_engine_mode
bool poly_allow_detailed_fx
static const char * IncorrectReasonName(IncorrectResultReason irr)
SVEvent * AwaitEvent(SVEventType type)
BOOL8 process_cmd_win_event(inT32 cmd_event, char *new_value)
TBOX bounding_box() const
char * editor_image_win_name
void pgeditor_main(int width, int height, PAGE_RES *page_res)
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
BOOL8 word_bln_display(PAGE_RES_IT *pr_it)
static ScrollView::Color NextColor(ScrollView::Color colour)
#define INT_VAR(name, val, comment)
char * ShowInputDialog(const char *msg)
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
const char * text() const
void Notify(const SVEvent *sve)
int editor_image_word_bb_color
void recog_pseudo_word(PAGE_RES *page_res, TBOX &selection_box)
void blob_feature_display(PAGE_RES *page_res, const TBOX &selection_box)
GenericVector< TBLOB * > blobs
void set_y(inT16 yin)
rewrite function
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)
void plot(ScrollView *window, ScrollView::Color colour)
void do_re_display(BOOL8(tesseract::Tesseract::*word_painter)(PAGE_RES_IT *pr_it))
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)
void Rectangle(int x1, int y1, int x2, int y2)
void show_point(PAGE_RES *page_res, float x, float y)
int editor_image_blob_bb_color
bool contains(const FCOORD pt) const
TBOX bounding_box() const
void pgeditor_show_point(SVEvent *event)
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
void turn_off_bit(uinT8 bit_num)
SVMenuNode * AddChild(const char *txt)
const char * string() const
void build_image_window(int width, int height)
SVMenuNode * build_menu_new()
ROW_RES * prev_row() const
void Line(int x1, int y1, int x2, int y2)
bool textord_use_cjk_fp_model
BlamerBundle * blamer_bundle
void SetVisible(bool visible)
C_BLOB_LIST * cblob_list()
const STRING & debug() const
void plot(ScrollView *fd) const