⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 training.h

📁 Ocr source code. provides an Ocr engine that works in C++ language.
💻 H
字号:
/* training.h : setup for training vars and window * Author: Maxie D. Schmidt (created 5/20/2006)      */#ifndef _TRAINING_H_#define _TRAINING_H_#include <stdlib.h>#include <string.h>#include <gtkmm/drawingarea.h>#include <gtkmm/scrolledwindow.h>#include <gtkmm/textview.h>#include <gtkmm/textbuffer.h>#include <gtkmm/box.h>#include <gtkmm/button.h>#include <gtkmm/buttonbox.h>#include <gtkmm/paned.h>#include <gtkmm/dialog.h>#include <gtkmm/messagedialog.h>#include <gtkmm/checkbutton.h>#include <gtkmm/entry.h>#include <gtkmm/label.h>#include <gtkmm/separator.h>#include <gtkmm/comboboxtext.h>#include <string>#include <vector>using namespace std;#include "types.h"#include "classnotes.h"#include "runutils.h"#include "parseutils.h"#include "drawingarea.h"#include "dialogs.h"#define TR_SWIN_X_SIZE          450#define TR_SWIN_Y_SIZE          300#define TR_TEXT_X_SIZE          450 #define TR_TEXT_Y_SIZE          125#define TR_MAIN_WIN_X_SIZE      500#define TR_MAIN_WIN_Y_SIZE      500#define TR_DA_SELECTED_LINE_THICKNESS   4/////// related functions:void init_training(bool train_with_scan);void cleanup_training();bool parse_training(string img_text, vector<int> lines);bool remap_characters(parse_list *plist, string text);bool tr_train_with_scan_replace_text();/////// GUI training window + components:class tr_drawing_area : public drawing_area {     public:          tr_drawing_area(int size_x, int size_y);                    void refresh();          void add_line(int line);          void delete_line(); // deletes the most recently added line          vector<int> get_lines();          bool add_spint_line(int line);          bool delete_spint_line();          vector<int> get_spint_lines();          void select_lines();          void clear_select_lines();          void set_swin_vis_props(int x, int y, int width, int height);          void set_tools_vars(vector<plist_parsed_char> *sel_chars,                               vector<int> *split_chars_divider_pos,                              bool *join_letters, bool *rm_spots,                              bool *split_chars, bool *search_alternate);               protected:          // These are used to figure out what part of the drawing area          // is visible within the scrolled window; these are necessary          // for dragging a line since dragging a line is quite          // sluggish when there is a large image to refresh:          int swin_vis_x, swin_vis_y, swin_vis_width, swin_vis_height;          bool need_valid_vis;                    int selected_line_index;          int selected_spint_line_index;          int split_chars_line_index;          bool dragging;          vector<int> lines;          vector<int> spint_lines;          int selected_line_index0, selected_line_index1; // -1 for off          bool selecting_lines;          // tools:          vector<plist_parsed_char> *selected_chars;          vector<int> *tool_split_chars_divider_pos;          bool *tool_join_letters, *tool_rm_spots, *tool_split_chars,                *tools_search_alternate;          // (X event) signal handlers:          bool on_button_press_event(GdkEventButton *event);          bool on_button_release_event(GdkEventButton *event);          bool on_motion_notify_event(GdkEventMotion *event);          bool on_expose_event(GdkEventExpose *event);          // refresh signal after image parsing:          void on_signal_tr_refresh();          void on_signal_tr_clear_int_lines();                    void draw_image();          void draw_selected_chars();          void draw_lines();          void draw_spint_lines();          void draw_split_chars_lines();          bool click_on_line(int line_index, int y);          int click_on_line(int y); // returns index or -1          bool click_on_spint_line(int line_index, int x, int y);          int click_on_spint_line(int x, int y);          int split_chars_click_on_line(int x, int y); // index or -1};class tr_image_display : public Gtk::ScrolledWindow {     public:          tr_image_display();          void da_add_line(int line);          void da_delete_line();          vector<int> da_get_lines();          bool da_add_spint_line(int line);          bool da_delete_spint_line();          vector<int> da_get_spint_lines();          void da_select_lines();          void da_clear_select_lines();          void da_set_tools_vars(vector<plist_parsed_char> *sel_chars,                                  vector<int> *split_chars_divider_pos,                                 bool *join_letters, bool *rm_spots,                                  bool *split_chars, bool *search_alternate);     protected:          tr_drawing_area da;          void on_scrollbar_adjust();          };class training_text : public Gtk::ScrolledWindow {     public:          training_text();          void set_text(string text);          string get_text();     protected:          void setup_buffer();          Gtk::TextView text_view;          Glib::RefPtr<Gtk::TextBuffer> buffer_ref;};class training_window : public Gtk::Dialog { //Gtk::Window {     public:          training_window(string input_text = string(""));          ~training_window();               protected:          bool draw_interval_lines, train_with_scan;          // tools:          vector<plist_parsed_char> *selected_chars;          vector<int> *tool_split_chars_divider_pos;           bool *tool_join_letters, *tool_rm_spots, *tool_split_chars,                *tools_search_alternate;                    Gtk::VPaned divider;          // top of win:          tr_image_display img_display;          // bottom of win:          Gtk::Button plus_line_button, minus_line_button,                       plus_spint_line_button, minus_spint_line_button,                      select_lines_button, clear_select_lines_button,                      parse_button, add_to_config_button,                      add_to_profile_button, view_cfg_button,                       view_gridding_cfg_button, clear_button,                      view_profile_stats_button, view_logs_button, close_button,                       tools_start_button, tools_action_button,                       tools_clear_selected_button;          Gtk::HButtonBox tools_buttonbox, line_buttonbox, middle_buttonbox,                          bottom_buttonbox;          Gtk::Label tools_label;          Gtk::ComboBoxText tools_combobox;          Gtk::CheckButton tools_search_alternate_checkbutton;          Gtk::HBox tools_hbox;          Gtk::VBox win_bottom_vbox, bottom_buttonbox_vbox;          training_text image_text;                    // signal handlers:          void on_plus_line_click();          void on_minus_line_click();          void on_plus_spint_line_click();          void on_minus_spint_line_click();          void on_select_lines_click();          void on_clear_select_lines_click();          void on_parse_button_click();          void on_add_to_config_click();          void on_add_to_profile_click();          void on_clear_button_click();          void on_view_tr_cfg_click();          void on_view_gridding_cfg_click();          void on_view_profile_stats_click();          void on_view_logs_click();          void on_close_button_click();          void on_tools_start_button_click();          void on_tools_action_button_click();          void on_tools_clear_selected_click();          void on_tools_search_alternate_click();          };/////// training-related popups (dialogs):// grid configuration:#define GRID_CFG_ENTRY_SIZE       5class grid_cfg_da : public grid_char_da {     public:          grid_cfg_da();};class grid_config_display : public Gtk::ScrolledWindow {     public:          grid_config_display();                    void set_size(int size_x, int size_y);          grid_cfg_da da;};class grid_config_dialog : public Gtk::Dialog {     public:          grid_config_dialog();     protected:          // non-widget vars (gs=>grid size, gc=>grid cell):          box_t cur_char_box;          parsed_line *cur_pl;          parsed_char *cur_pc;          int gs_x, gs_y, gc_x, gc_y;          // grid display:          grid_config_display display;                    // upper/ctrl buttons:          Gtk::HBox ctrl_hbox;          Gtk::HButtonBox ctrl_buttonbox;          Gtk::Button plus_char_button, minus_char_button, add_to_config_button;          Gtk::Label grid_fill_label;          Gtk::CheckButton grid_fill_check;          // grid size, grid cell sections:          Gtk::HBox grid_sections_hbox;          Gtk::VBox gs_vbox, gc_vbox;          Gtk::Label gs_x_label, gs_y_label, gc_x_label, gc_y_label;          Gtk::Entry gs_x_entry, gs_y_entry, gc_x_entry, gc_y_entry;          Gtk::HBox gs_x_hbox, gs_y_hbox, gc_x_hbox, gc_y_hbox;          Gtk::HButtonBox gs_update_buttonbox, gc_update_buttonbox;          Gtk::Button gs_update_button, gc_update_button;          Gtk::HSeparator line;          Gtk::Button close_button;          Gtk::HButtonBox close_buttonbox;                    // signal handlers:          void on_plus_char_click();          void on_minus_char_click();          void on_add_to_config_click();          void on_grid_fill_toggle();          void on_gs_update();          void on_gc_update();          void on_close_button_click();};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -