22 #include "config_auto.h" 41 #ifndef GRAPHICS_DISABLED 42 #define ASC_HEIGHT (2 * kBlnBaselineOffset + kBlnXHeight) 43 #define X_HEIGHT (kBlnBaselineOffset + kBlnXHeight) 44 #define BL_HEIGHT kBlnBaselineOffset 46 #define MAXSPACING 128 105 static bool stillRunning =
false;
111 static bool recog_done =
false;
124 "Editor image window name");
129 "Word bounding box colour");
131 "Blob bounding box colour");
133 "Correct text colour");
136 "Editor debug window name");
154 bln_word_window =
nullptr;
167 if (bln_word_window ==
nullptr) {
176 return bln_word_window;
204 float scale_factor,
float y_offset,
205 float minx,
float maxx) {
210 maxx, y_offset + scale_factor *
BL_HEIGHT);
212 maxx, y_offset + scale_factor *
X_HEIGHT);
232 if (strcmp(event->
parameter,
"true") == 0) { myval =
'T'; }
233 else if (strcmp(event->
parameter,
"false") == 0) { myval =
'F'; }
262 parent_menu = root_menu_item->
AddChild(
"DISPLAY");
281 parent_menu = root_menu_item->
AddChild(
"OTHER");
290 return root_menu_item;
304 image_win->
Image(pix_binary_, 0, 0);
310 (this->*word_painter)(&pr_it);
338 #ifndef GRAPHICS_DISABLED 376 image_win->
AddMessage(
"Pointing at(%d, %d)", event->
x, event->
y);
435 word_config_ = parameter;
439 if (new_value[0] ==
'T')
446 if (new_value[0] ==
'T')
454 if (new_value[0] ==
'T')
461 if (new_value[0] ==
'T')
468 if (new_value[0] ==
'T')
475 if (new_value[0] ==
'T')
541 snprintf(msg,
sizeof(msg),
"Unrecognised event %" PRId32
"(%s)",
542 cmd_event, new_value);
581 selection_box =
TBOX(down, up);
607 #ifndef DISABLED_LEGACY_ENGINE 608 image_win->
AddMessage(
"Recogging selected words");
612 #endif // ndef DISABLED_LEGACY_ENGINE 615 image_win->
AddMessage(
"Recogging selected blobs");
623 sprintf(msg,
"Mode %d not yet implemented", mode);
638 #ifndef DISABLED_LEGACY_ENGINE 657 const int kBufsize = 512;
661 msg_ptr += sprintf(msg_ptr,
"Pt:(%0.3f, %0.3f) ", x, y);
666 msg_ptr += sprintf(msg_ptr,
"BL(x)=%0.3f ",
669 if (word->word->bounding_box().contains(pt)) {
670 TBOX box = word->word->bounding_box();
671 msg_ptr += sprintf(msg_ptr,
"Wd(%d, %d)/(%d, %d) ",
674 C_BLOB_IT cblob_it(word->word->cblob_list());
675 for (cblob_it.mark_cycle_pt();
676 !cblob_it.cycled_list();
677 cblob_it.forward()) {
678 C_BLOB* cblob = cblob_it.data();
681 msg_ptr += sprintf(msg_ptr,
682 "CBlb(%d, %d)/(%d, %d) ",
712 #endif // GRAPHICS_DISABLED 714 #ifndef GRAPHICS_DISABLED 740 1.0, 0.0f, -1000.0f, 1000.0f);
743 for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
764 bool displayed_something =
false;
770 int length = box_word->
length();
771 if (word_res->
fontinfo ==
nullptr)
return false;
773 for (
int i = 0; i < length; ++i) {
775 switch (color_mode) {
813 image_win->
Pen(color);
836 for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward())
837 c_it.data()->bounding_box().plot(image_win);
838 displayed_something =
true;
843 word->
plot(image_win);
844 displayed_something =
true;
851 tword->
plot(image_win);
853 displayed_something =
true;
867 if (blamer_bundle ==
nullptr) {
875 best_choice_str =
"NULL";
879 text += best_choice_str;
890 word_height = word_bb.
height();
891 int text_height = 0.50 * word_height;
892 if (text_height > 20) text_height = 20;
893 image_win->
TextAttributes(
"Arial", text_height,
false,
false,
false);
894 shift = (word_height < word_bb.
width()) ? 0.25 * word_height : 0.0f;
895 image_win->
Text(word_bb.
left() + shift,
898 image_win->
Text(word_bb.
left() + shift,
899 word_bb.
bottom() + 0.25 * word_height - text_height,
903 displayed_something =
true;
906 if (!displayed_something)
913 #endif // GRAPHICS_DISABLED 932 tprintf(
"Current blamer debug: %s\n",
938 #ifndef GRAPHICS_DISABLED 960 const TBOX& selection_box) {
961 #ifndef DISABLED_LEGACY_ENGINE 978 &cn_features, &fx_info,
nullptr);
982 for (
int f = 0; f < bl_features.
size(); ++f)
988 for (
int f = 0; f < cn_features.
size(); ++f)
995 #endif // ndef DISABLED_LEGACY_ENGINE 999 #endif // GRAPHICS_DISABLED
BLOCK_RES * block() const
int editor_image_blob_bb_color
const STRING & debug() const
const ERRCODE EMPTYBLOCKLIST
void plot_baseline(ScrollView *window, ScrollView::Color colour)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
void ClearFeatureSpaceWindow(NORM_METHOD norm_method, ScrollView *window)
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)
#define STRING_VAR(name, val, comment)
void SetVisible(bool visible)
PAGE_RES * current_page_res
bool word_display(PAGE_RES_IT *pr_it)
void set_x(int16_t xin)
rewrite function
int editor_image_text_color
int tessedit_ocr_engine_mode
const char * string() const
TBOX bounding_box() const
static ScrollView::Color NextColor(ScrollView::Color colour)
float base_line(float xpos) const
bool classify_bln_numeric_mode
void plot(ScrollView *window, ScrollView::Color colour)
void do_re_display(bool(tesseract::Tesseract::*word_painter)(PAGE_RES_IT *pr_it))
const FontInfo * fontinfo
void blob_feature_display(PAGE_RES *page_res, const TBOX &selection_box)
void turn_off_bit(uint8_t bit_num)
void build_image_window(int width, int height)
void process_image_event(const SVEvent &event)
BLOCK_RES_LIST block_res_list
static const char * IncorrectReasonName(IncorrectResultReason irr)
void pgeditor_show_point(SVEvent *event)
const TBOX & BlobBox(int index) const
void plot(ScrollView *window, int32_t serial, ScrollView::Color colour)
bool classify_nonlinear_norm
bool bit(uint8_t bit_num) const
int editor_image_menuheight
char * editor_debug_config_file
void Notify(const SVEvent *sve)
void plot(ScrollView *fd) const
void turn_on_bit(uint8_t bit_num)
void print(FILE *fp, bool dump)
dump whole table
ROW_RES * prev_row() const
ScrollView * bln_word_window_handle()
SVEvent * AwaitEvent(SVEventType type)
const char * text() const
char * ShowInputDialog(const char *msg)
void ResetAdaptiveClassifier()
bool word_blank_and_set_display(PAGE_RES_IT *pr_its)
bool textord_use_cjk_fp_model
void pgeditor_main(int width, int height, PAGE_RES *page_res)
void Text(int x, int y, const char *mystring)
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
SVMenuNode * build_menu_new()
SVMenuNode * AddChild(const char *txt)
IncorrectResultReason incorrect_result_reason() const
bool process_cmd_win_event(int32_t cmd_event, char *new_value)
bool word_bln_display(PAGE_RES_IT *pr_it)
void show_point(PAGE_RES *page_res, float x, float y)
void AddEventHandler(SVEventHandler *listener)
Add an Event Listener to this ScrollView Window.
STRING TruthString() const
bool word_set_display(PAGE_RES_IT *pr_it)
void plot(ScrollView *window)
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 RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
bool display_flag(uint8_t flag) const
TBOX bounding_box() const
void Image(struct Pix *image, int x_pos, int y_pos)
DLLSYM void tprintf(const char *format,...)
C_BLOB_LIST * cblob_list()
BLOCK_RES * prev_block() const
void Notify(const SVEvent *sv_event)
GenericVector< TBLOB * > blobs
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
void recog_pseudo_word(PAGE_RES *page_res, TBOX &selection_box)
bool word_dumper(PAGE_RES_IT *pr_it)
TBOX bounding_box() const
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
bool contains(const FCOORD pt) const
BlamerBundle * blamer_bundle
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
tesseract::ScriptPos BlobPosition(int index) const
void process_selected_words(PAGE_RES *page_res, TBOX &selection_box, bool(tesseract::Tesseract::*word_processor)(PAGE_RES_IT *pr_it))
void Rectangle(int x1, int y1, int x2, int y2)
void BuildMenu(ScrollView *sv, bool menu_bar=true)
bool is_fixed_pitch() const
void pgeditor_msg(const char *msg)
bool wordrec_debug_blamer
static TWERD * PolygonalCopy(bool allow_detailed_fx, WERD *src)
char * editor_image_win_name
bool recog_interactive(PAGE_RES_IT *pr_it)
void set_y(int16_t yin)
rewrite function
void Notify(const SVEvent *sve)
WERD_CHOICE * best_choice
tesseract::BoxWord * box_word
void set_display_flag(uint8_t flag, bool value)
#define INT_VAR(name, val, comment)
void Line(int x1, int y1, int x2, int y2)
bool poly_allow_detailed_fx
int editor_image_word_bb_color
void AddMessage(const char *format,...)
void debug_word(PAGE_RES *page_res, const TBOX &selection_box)