mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Fixed issue 1108
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1072 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
9fad0316f4
commit
0dd47a2fd5
@ -106,6 +106,21 @@ Pixa *CubeLineSegmenter::VerticalClosing(Pix *pix,
|
||||
return pixac;
|
||||
}
|
||||
|
||||
// Helper cleans up after CrackLine.
|
||||
static void CleanupCrackLine(int line_cnt, Pixa **lines_pixa,
|
||||
Boxa **line_con_comps,
|
||||
Pixa **line_con_comps_pix) {
|
||||
for (int line = 0; line < line_cnt; line++) {
|
||||
if (lines_pixa[line] != NULL) {
|
||||
pixaDestroy(&lines_pixa[line]);
|
||||
}
|
||||
}
|
||||
|
||||
delete []lines_pixa;
|
||||
boxaDestroy(line_con_comps);
|
||||
pixaDestroy(line_con_comps_pix);
|
||||
}
|
||||
|
||||
// do a desperate attempt at cracking lines
|
||||
Pixa *CubeLineSegmenter::CrackLine(Pix *cracked_line_pix,
|
||||
Box *cracked_line_box, int line_cnt) {
|
||||
@ -139,9 +154,8 @@ Pixa *CubeLineSegmenter::CrackLine(Pix *cracked_line_pix,
|
||||
if (lines_pixa[line_idx] == NULL) {
|
||||
lines_pixa[line_idx] = pixaCreate(line_con_comps->n);
|
||||
if (lines_pixa[line_idx] == NULL) {
|
||||
delete []lines_pixa;
|
||||
boxaDestroy(&line_con_comps);
|
||||
pixaDestroy(&line_con_comps_pix);
|
||||
CleanupCrackLine(line_cnt, lines_pixa, &line_con_comps,
|
||||
&line_con_comps_pix);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -149,9 +163,9 @@ Pixa *CubeLineSegmenter::CrackLine(Pix *cracked_line_pix,
|
||||
// add the concomp to the line
|
||||
if (pixaAddPix(lines_pixa[line_idx], con_pix, L_CLONE) != 0 ||
|
||||
pixaAddBox(lines_pixa[line_idx], con_box, L_CLONE)) {
|
||||
delete []lines_pixa;
|
||||
boxaDestroy(&line_con_comps);
|
||||
pixaDestroy(&line_con_comps_pix);
|
||||
CleanupCrackLine(line_cnt, lines_pixa, &line_con_comps,
|
||||
&line_con_comps_pix);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,15 +206,8 @@ Pixa *CubeLineSegmenter::CrackLine(Pix *cracked_line_pix,
|
||||
}
|
||||
|
||||
// cleanup
|
||||
for (int line = 0; line < line_cnt; line++) {
|
||||
if (lines_pixa[line] != NULL) {
|
||||
pixaDestroy(&lines_pixa[line]);
|
||||
}
|
||||
}
|
||||
|
||||
delete []lines_pixa;
|
||||
boxaDestroy(&line_con_comps);
|
||||
pixaDestroy(&line_con_comps_pix);
|
||||
CleanupCrackLine(line_cnt, lines_pixa, &line_con_comps,
|
||||
&line_con_comps_pix);
|
||||
|
||||
if (success == false) {
|
||||
pixaDestroy(&lines);
|
||||
|
Loading…
Reference in New Issue
Block a user