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'; }
244 tess_->process_cmd_win_event(event->
command_id, &myval);
247 tess_->process_image_event(*event);
272 parent_menu = root_menu_item->
AddChild(
"DISPLAY");
291 parent_menu = root_menu_item->
AddChild(
"OTHER");
300 return root_menu_item;
308 void Tesseract::do_re_display(
314 image_win->
Image(pix_binary_, 0, 0);
320 (this->*word_painter)(&pr_it);
337 void Tesseract::pgeditor_main(
int width,
int height,
PAGE_RES *page_res) {
338 current_page_res = page_res;
348 #ifndef GRAPHICS_DISABLED 386 image_win->
AddMessage(
"Pointing at(%d, %d)", event->
x, event->
y);
397 BOOL8 Tesseract::process_cmd_win_event(
419 recog_all_words(current_page_res, NULL, NULL, NULL, 0);
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 snprintf(msg,
sizeof(msg),
"Unrecognised event %" PRId32
"(%s)",
548 cmd_event, new_value);
565 void Tesseract::process_image_event(
587 selection_box =
TBOX(down, up);
591 process_selected_words(
597 process_selected_words(current_page_res,
602 process_selected_words(current_page_res,
607 debug_word(current_page_res, selection_box);
613 image_win->
AddMessage(
"Recogging selected words");
614 this->process_selected_words(current_page_res,
616 &Tesseract::recog_interactive);
619 image_win->
AddMessage(
"Recogging selected blobs");
620 recog_pseudo_word(current_page_res, selection_box);
623 blob_feature_display(current_page_res, selection_box);
627 sprintf(msg,
"Mode %d not yet implemented",
mode);
641 void Tesseract::debug_word(
PAGE_RES* page_res,
const TBOX &selection_box) {
642 ResetAdaptiveClassifier();
643 recog_all_words(page_res, NULL, &selection_box, word_config_.string(), 0);
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 720 return word_set_display(pr_it);
734 tessedit_ocr_engine_mode, NULL,
735 classify_bln_numeric_mode,
736 textord_use_cjk_fp_model,
737 poly_allow_detailed_fx,
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();
774 if (word_res->
fontinfo == NULL)
return false;
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 932 if (word_res->
blamer_bundle != NULL && wordrec_debug_blamer &&
934 tprintf(
"Current blamer debug: %s\n",
940 #ifndef GRAPHICS_DISABLED 955 return word_display(pr_it);
960 void Tesseract::blob_feature_display(
PAGE_RES* page_res,
961 const TBOX& selection_box) {
967 tessedit_ocr_engine_mode, NULL,
968 classify_bln_numeric_mode,
969 textord_use_cjk_fp_model,
970 poly_allow_detailed_fx,
977 Classify::ExtractFeatures(*bln_blob, classify_nonlinear_norm, &bl_features,
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 static const char * IncorrectReasonName(IncorrectResultReason irr)
BOOL8 word_display(PAGE_RES_IT *pr_it)
void plot(ScrollView *window, inT32 serial, ScrollView::Color colour)
ScrollView * bln_word_window_handle()
BOOL8 display_flag(uinT8 flag) const
void set_y(inT16 yin)
rewrite function
ScrollView * bln_word_window
const FontInfo * fontinfo
void print(FILE *fp, BOOL8 dump)
dump whole table
void show_point(PAGE_RES *page_res, float x, float y)
BOOL8 word_blank_and_set_display(PAGE_RES_IT *pr_its)
void Rectangle(int x1, int y1, int x2, int y2)
ROW_RES * prev_row() const
void Notify(const SVEvent *sve)
BlamerBundle * blamer_bundle
void set_x(inT16 xin)
rewrite function
C_BLOB_LIST * cblob_list()
const char * text() const
SVEvent * AwaitEvent(SVEventType type)
WERD_CHOICE * best_choice
char * ShowInputDialog(const char *msg)
void Line(int x1, int y1, int x2, int y2)
void plot(ScrollView *window, ScrollView::Color colour)
int editor_image_word_bb_color
void turn_off_bit(uinT8 bit_num)
void turn_on_bit(uinT8 bit_num)
void plot_baseline(ScrollView *window, ScrollView::Color colour)
BOOL8 word_set_display(PAGE_RES_IT *pr_it)
void pgeditor_msg(const char *msg)
void plot(ScrollView *fd) const
char * editor_image_win_name
const char * string() const
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
const TBOX & BlobBox(int index) const
#define INT_VAR(name, val, comment)
void Text(int x, int y, const char *mystring)
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
int editor_image_blob_bb_color
static ScrollView::Color NextColor(ScrollView::Color colour)
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
BOOL8 word_dumper(PAGE_RES_IT *pr_it)
const STRING & debug() const
const ERRCODE EMPTYBLOCKLIST
BLOCK_RES_LIST block_res_list
tesseract::ScriptPos BlobPosition(int index) const
bool contains(const FCOORD pt) const
void set_display_flag(uinT8 flag, BOOL8 value)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
#define STRING_VAR(name, val, comment)
void AddMessage(const char *format,...)
TBOX bounding_box() const
float base_line(float xpos) const
void build_image_window(int width, int height)
BLOCK_RES * prev_block() const
PAGE_RES * current_page_res
void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView *window)
void pgeditor_show_point(SVEvent *event)
int editor_image_text_color
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
void BuildMenu(ScrollView *sv, bool menu_bar=true)
tesseract::BoxWord * box_word
void SetVisible(bool visible)
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
IncorrectResultReason incorrect_result_reason() const
BLOCK_RES * block() const
void display_bln_lines(ScrollView *window, ScrollView::Color colour, float scale_factor, float y_offset, float minx, float maxx)
TBOX bounding_box() const
bool is_fixed_pitch() const
GenericVector< TBLOB * > blobs
BOOL8 word_bln_display(PAGE_RES_IT *pr_it)
SVMenuNode * AddChild(const char *txt)
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 Image(struct Pix *image, int x_pos, int y_pos)
TBOX bounding_box() const
int editor_image_menuheight
void Notify(const SVEvent *sv_event)
void Notify(const SVEvent *sve)
void plot(ScrollView *window)
static TWERD * PolygonalCopy(bool allow_detailed_fx, WERD *src)
char * editor_debug_config_file
BOOL8 bit(uinT8 bit_num) const
STRING TruthString() const