提交 1faba523 编写于 作者: T theraysmith

Misc fixes including safe init/end

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@151 d0cd1f9f-072b-0410-8dd7-cf729c803f20
上级 0e6f803e
......@@ -112,21 +112,26 @@ void init_metrics() {
chars_classified = 0;
permutation_count = 0;
end_metrics();
states_before_best = new_tally (min (100, num_seg_states));
best_certainties[0] = new_tally (CERTAINTY_BUCKETS);
best_certainties[1] = new_tally (CERTAINTY_BUCKETS);
reset_width_tally();
}
void end_metrics() {
memfree(states_before_best);
memfree(best_certainties[0]);
memfree(best_certainties[1]);
memfree(character_widths);
states_before_best = NULL;
best_certainties[0] = NULL;
best_certainties[1] = NULL;
character_widths = NULL;
if (states_before_best != NULL) {
memfree(states_before_best);
memfree(best_certainties[0]);
memfree(best_certainties[1]);
memfree(character_widths);
states_before_best = NULL;
best_certainties[0] = NULL;
best_certainties[1] = NULL;
character_widths = NULL;
}
}
......
......@@ -45,13 +45,13 @@
V a r i a b l e s
----------------------------------------------------------------------*/
#ifndef GRAPHICS_DISABLED
int handle_menu_3();
int handle_menu_4();
int handle_menu_5();
int handle_menu_6();
int handle_menu_7();
int handle_menu_8();
int handle_menu_9();
int handle_menu_3();
int handle_menu_4();
int handle_menu_5();
int handle_menu_6();
int handle_menu_7();
int handle_menu_8();
int handle_menu_9();
#endif
/*----------------------------------------------------------------------
......@@ -62,7 +62,7 @@ int handle_menu_9();
*
* Initialize the traps for handling the splitter debug stuff.
**********************************************************************/
void init_ms_debug() {
void init_ms_debug() {
static int first_time = 1;
if (first_time) {
......@@ -79,18 +79,18 @@ void init_ms_debug() {
AddSignalMenuItem (SIGINT, 9, "Joiner", handle_menu_9);
#endif
init_plotseg();
init_render_vars();
init_plotseg();
init_render_vars();
#endif
init_baseline();
init_bestfirst_vars();
init_splitter_vars();
init_associate_vars();
init_chop();
init_textord_vars();
init_permute();
init_baseline();
init_bestfirst_vars();
init_splitter_vars();
init_associate_vars();
init_chop();
init_textord_vars();
init_permute_vars();
}
}
......
......@@ -59,7 +59,7 @@ make_toggle_var (blob_pause, 0, make_blob_pause,
*
* Macro to display blob in a window.
**********************************************************************/
void display_blob(TBLOB *blob, C_COL color) {
void display_blob(TBLOB *blob, C_COL color) {
void *window;
TPOINT origin;
/* Size of drawable */
......@@ -68,16 +68,14 @@ void display_blob(TBLOB *blob, C_COL color) {
500, 128, -1000.0, 1000.0, 0.0, 256.0);
}
else {
c_clear_window(blob_window);
c_clear_window(blob_window);
}
window = blob_window;
/* Render blob */
blob_origin(blob, &origin);
blob_origin(blob, &origin);
render_blob(window, blob, origin, color);
/* Default zoom */
c_make_current(window);
render_blob(window, blob, origin, color);
}
......@@ -86,10 +84,10 @@ void display_blob(TBLOB *blob, C_COL color) {
*
* Initialize the render graphics menu items.
**********************************************************************/
void init_render_vars() {
make_disp_all_blobs();
make_disp_all_words();
make_blob_pause();
void init_render_vars() {
make_disp_all_blobs();
make_disp_all_words();
make_blob_pause();
}
......@@ -99,7 +97,7 @@ void init_render_vars() {
* Create a list of line segments that represent the expanded outline
* that was supplied as input.
**********************************************************************/
void render_blob(void *window, TBLOB *blob, TPOINT origin, C_COL color) {
void render_blob(void *window, TBLOB *blob, TPOINT origin, C_COL color) {
/* No outline */
if (!blob)
return;
......@@ -114,7 +112,7 @@ void render_blob(void *window, TBLOB *blob, TPOINT origin, C_COL color) {
* Create a list of line segments that represent the expanded outline
* that was supplied as input.
**********************************************************************/
void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
float x = edgept->pos.x;
float y = edgept->pos.y;
EDGEPT *this_edge = edgept;
......@@ -122,13 +120,13 @@ void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
if (!edgept)
return;
c_line_color_index(window, color);
c_move(window, x, y);
c_line_color_index(window, color);
c_move(window, x, y);
do {
this_edge = this_edge->next;
x = this_edge->pos.x;
y = this_edge->pos.y;
c_draw(window, x, y);
c_draw(window, x, y);
}
while (edgept != this_edge);
}
......
......@@ -90,6 +90,7 @@ void program_editup(const char *configfile) {
/* Initialize subsystems */
program_init();
mfeature_init();
init_permute();
setup_cp_maps();
}
......@@ -105,7 +106,6 @@ void program_editup2(const char *textbase) {
init_metrics();
pass2_ok_split = ok_split;
pass2_seg_states = num_seg_states;
reset_width_tally();
}
......@@ -189,7 +189,6 @@ void program_editdown(INT32 elasped_time) {
}
end_metrics();
end_permute();
end_permdawg();
free_variables();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册