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 sprintf(msg,
"Unrecognised event %" PRId32
"(%s)", cmd_event, new_value);
564 void Tesseract::process_image_event(
586 selection_box =
TBOX(down, up);
590 process_selected_words(
596 process_selected_words(current_page_res,
601 process_selected_words(current_page_res,
606 debug_word(current_page_res, selection_box);
612 image_win->
AddMessage(
"Recogging selected words");
613 this->process_selected_words(current_page_res,
615 &Tesseract::recog_interactive);
618 image_win->
AddMessage(
"Recogging selected blobs");
619 recog_pseudo_word(current_page_res, selection_box);
622 blob_feature_display(current_page_res, selection_box);
626 sprintf(msg,
"Mode %d not yet implemented",
mode);
640 void Tesseract::debug_word(
PAGE_RES* page_res,
const TBOX &selection_box) {
641 ResetAdaptiveClassifier();
642 recog_all_words(page_res, NULL, &selection_box, word_config_.string(), 0);
658 const int kBufsize = 512;
662 msg_ptr += sprintf(msg_ptr,
"Pt:(%0.3f, %0.3f) ", x, y);
667 msg_ptr += sprintf(msg_ptr,
"BL(x)=%0.3f ",
670 if (word->word->bounding_box().contains(pt)) {
671 TBOX box = word->word->bounding_box();
672 msg_ptr += sprintf(msg_ptr,
"Wd(%d, %d)/(%d, %d) ",
675 C_BLOB_IT cblob_it(word->word->cblob_list());
676 for (cblob_it.mark_cycle_pt();
677 !cblob_it.cycled_list();
678 cblob_it.forward()) {
679 C_BLOB* cblob = cblob_it.data();
682 msg_ptr += sprintf(msg_ptr,
683 "CBlb(%d, %d)/(%d, %d) ",
713 #endif // GRAPHICS_DISABLED 715 #ifndef GRAPHICS_DISABLED 719 return word_set_display(pr_it);
733 tessedit_ocr_engine_mode, NULL,
734 classify_bln_numeric_mode,
735 textord_use_cjk_fp_model,
736 poly_allow_detailed_fx,
741 1.0, 0.0f, -1000.0f, 1000.0f);
744 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
772 int length = box_word->
length();
773 if (word_res->
fontinfo == NULL)
return false;
775 for (
int i = 0; i < length; ++i) {
777 switch (color_mode) {
815 image_win->
Pen(color);
831 editor_image_word_bb_color));
837 for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward())
838 c_it.data()->bounding_box().plot(image_win);
839 displayed_something =
TRUE;
844 word->
plot(image_win);
845 displayed_something =
TRUE;
852 tword->
plot(image_win);
854 displayed_something =
TRUE;
868 if (blamer_bundle == NULL) {
876 best_choice_str =
"NULL";
880 text += best_choice_str;
891 word_height = word_bb.
height();
892 int text_height = 0.50 * word_height;
893 if (text_height > 20) text_height = 20;
894 image_win->
TextAttributes(
"Arial", text_height,
false,
false,
false);
895 shift = (word_height < word_bb.
width()) ? 0.25 * word_height : 0.0f;
896 image_win->
Text(word_bb.
left() + shift,
899 image_win->
Text(word_bb.
left() + shift,
900 word_bb.
bottom() + 0.25 * word_height - text_height,
904 displayed_something =
TRUE;
907 if (!displayed_something)
911 editor_image_word_bb_color));
914 #endif // GRAPHICS_DISABLED 931 if (word_res->
blamer_bundle != NULL && wordrec_debug_blamer &&
933 tprintf(
"Current blamer debug: %s\n",
939 #ifndef GRAPHICS_DISABLED 954 return word_display(pr_it);
959 void Tesseract::blob_feature_display(
PAGE_RES* page_res,
960 const TBOX& selection_box) {
966 tessedit_ocr_engine_mode, NULL,
967 classify_bln_numeric_mode,
968 textord_use_cjk_fp_model,
969 poly_allow_detailed_fx,
976 Classify::ExtractFeatures(*bln_blob, classify_nonlinear_norm, &bl_features,
977 &cn_features, &fx_info, NULL);
981 for (
int f = 0; f < bl_features.
size(); ++f)
987 for (
int f = 0; f < cn_features.
size(); ++f)
997 #endif // GRAPHICS_DISABLED
static ScrollView::Color NextColor(ScrollView::Color colour)
BOOL8 display_flag(uinT8 flag) const
void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView *window)
void Line(int x1, int y1, int x2, int y2)
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
void plot(ScrollView *fd) const
void Notify(const SVEvent *sve)
const TBOX & BlobBox(int index) const
char * editor_debug_config_file
const ERRCODE EMPTYBLOCKLIST
void plot(ScrollView *window)
void set_display_flag(uinT8 flag, BOOL8 value)
WERD_CHOICE * best_choice
void display_bln_lines(ScrollView *window, ScrollView::Color colour, float scale_factor, float y_offset, float minx, float maxx)
ROW_RES * prev_row() const
BlamerBundle * blamer_bundle
void set_x(inT16 xin)
rewrite function
BLOCK_RES_LIST block_res_list
void build_image_window(int width, int height)
int editor_image_text_color
int editor_image_word_bb_color
const char * string() const
tesseract::ScriptPos BlobPosition(int index) const
void pgeditor_msg(const char *msg)
void turn_off_bit(uinT8 bit_num)
char * ShowInputDialog(const char *msg)
TBOX bounding_box() const
tesseract::BoxWord * box_word
ScrollView * bln_word_window_handle()
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
BOOL8 word_bln_display(PAGE_RES_IT *pr_it)
IncorrectResultReason incorrect_result_reason() const
ScrollView * bln_word_window
char * editor_image_win_name
BOOL8 word_blank_and_set_display(PAGE_RES_IT *pr_its)
void Notify(const SVEvent *sve)
const STRING & debug() const
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
void plot_baseline(ScrollView *window, ScrollView::Color colour)
BOOL8 word_set_display(PAGE_RES_IT *pr_it)
void Rectangle(int x1, int y1, int x2, int y2)
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
const FontInfo * fontinfo
#define INT_VAR(name, val, comment)
const char * text() const
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
bool contains(const FCOORD pt) const
TBOX bounding_box() const
void print(FILE *fp, BOOL8 dump)
dump whole table
int editor_image_menuheight
int editor_image_blob_bb_color
GenericVector< TBLOB * > blobs
TBOX bounding_box() const
C_BLOB_LIST * cblob_list()
void plot(ScrollView *window, inT32 serial, ScrollView::Color colour)
BOOL8 word_dumper(PAGE_RES_IT *pr_it)
void Notify(const SVEvent *sv_event)
void Text(int x, int y, const char *mystring)
void pgeditor_show_point(SVEvent *event)
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)
BOOL8 word_display(PAGE_RES_IT *pr_it)
#define STRING_VAR(name, val, comment)
SVMenuNode * AddChild(const char *txt)
void show_point(PAGE_RES *page_res, float x, float y)
BOOL8 bit(uinT8 bit_num) const
bool is_fixed_pitch() const
static const char * IncorrectReasonName(IncorrectResultReason irr)
BLOCK_RES * prev_block() const
PAGE_RES * current_page_res
float base_line(float xpos) const
void SetVisible(bool visible)
void turn_on_bit(uinT8 bit_num)
void AddMessage(const char *format,...)
void BuildMenu(ScrollView *sv, bool menu_bar=true)
static TWERD * PolygonalCopy(bool allow_detailed_fx, WERD *src)
STRING TruthString() const
void set_y(inT16 yin)
rewrite function
void plot(ScrollView *window, ScrollView::Color colour)
BLOCK_RES * block() const
SVEvent * AwaitEvent(SVEventType type)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)