mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-08-06 13:56:47 +08:00
Fixed excessive stack use
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@241 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
af1a2dd994
commit
2186613963
@ -396,7 +396,7 @@ LIST AdaptiveClassifier(TBLOB *Blob, TBLOB *DotBlob, TEXTROW *Row) {
|
||||
** History: Mon Mar 11 10:00:58 1991, DSJ, Created.
|
||||
*/
|
||||
LIST Choices;
|
||||
ADAPT_RESULTS Results;
|
||||
ADAPT_RESULTS* Results = new ADAPT_RESULTS;
|
||||
LINE_STATS LineStats;
|
||||
|
||||
if (FailedAdaptionsBeforeReset >= 0 &&
|
||||
@ -408,27 +408,27 @@ LIST AdaptiveClassifier(TBLOB *Blob, TBLOB *DotBlob, TEXTROW *Row) {
|
||||
AdaptedTemplates = NewAdaptedTemplates ();
|
||||
EnterClassifyMode;
|
||||
|
||||
Results.BlobLength = MAX_INT32;
|
||||
Results.NumMatches = 0;
|
||||
Results.BestRating = WORST_POSSIBLE_RATING;
|
||||
Results.BestClass = NO_CLASS;
|
||||
Results.BestConfig = 0;
|
||||
Results->BlobLength = MAX_INT32;
|
||||
Results->NumMatches = 0;
|
||||
Results->BestRating = WORST_POSSIBLE_RATING;
|
||||
Results->BestClass = NO_CLASS;
|
||||
Results->BestConfig = 0;
|
||||
GetLineStatsFromRow(Row, &LineStats);
|
||||
InitMatcherRatings (Results.Ratings);
|
||||
InitMatcherRatings (Results->Ratings);
|
||||
|
||||
DoAdaptiveMatch(Blob, &LineStats, &Results);
|
||||
RemoveBadMatches(&Results);
|
||||
DoAdaptiveMatch(Blob, &LineStats, Results);
|
||||
RemoveBadMatches(Results);
|
||||
|
||||
/* save ratings in a global so that CompareCurrentRatings() can see them */
|
||||
CurrentRatings = Results.Ratings;
|
||||
qsort ((void *) (Results.Classes), Results.NumMatches,
|
||||
CurrentRatings = Results->Ratings;
|
||||
qsort((void*) (Results->Classes), Results->NumMatches,
|
||||
sizeof (CLASS_ID), CompareCurrentRatings);
|
||||
RemoveExtraPuncs(&Results);
|
||||
Choices = ConvertMatchesToChoices (&Results);
|
||||
RemoveExtraPuncs(Results);
|
||||
Choices = ConvertMatchesToChoices(Results);
|
||||
|
||||
if (MatcherDebugLevel >= 1) {
|
||||
cprintf ("AD Matches = ");
|
||||
PrintAdaptiveMatchResults(stdout, &Results);
|
||||
PrintAdaptiveMatchResults(stdout, Results);
|
||||
}
|
||||
|
||||
if (LargeSpeckle (Blob, Row))
|
||||
@ -436,7 +436,7 @@ LIST AdaptiveClassifier(TBLOB *Blob, TBLOB *DotBlob, TEXTROW *Row) {
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
if (EnableAdaptiveDebugger)
|
||||
DebugAdaptiveClassifier(Blob, &LineStats, &Results);
|
||||
DebugAdaptiveClassifier(Blob, &LineStats, Results);
|
||||
#endif
|
||||
|
||||
NumClassesOutput += count (Choices);
|
||||
@ -447,8 +447,8 @@ LIST AdaptiveClassifier(TBLOB *Blob, TBLOB *DotBlob, TEXTROW *Row) {
|
||||
return (append_choice (NIL, "", empty_lengths, 50.0f, -20.0f, -1));
|
||||
}
|
||||
|
||||
return (Choices);
|
||||
|
||||
delete Results;
|
||||
return Choices;
|
||||
} /* AdaptiveClassifier */
|
||||
|
||||
|
||||
|
@ -57,15 +57,8 @@ DLLSYM void block_edges( //get edges in a block
|
||||
BLOCK_LINE_IT line_it = block; //line iterator
|
||||
IMAGELINE bwline; //thresholded line
|
||||
//lines in progress
|
||||
CRACKEDGE *ptrlinemem[MAXIMAGEWIDTH];
|
||||
CRACKEDGE **ptrline = ptrlinemem;
|
||||
|
||||
if (t_image->get_xsize()+1 > MAXIMAGEWIDTH) {
|
||||
ptrline = new CRACKEDGE*[t_image->get_xsize()+1];
|
||||
}
|
||||
|
||||
//block box
|
||||
block->bounding_box (bleft, tright);
|
||||
CRACKEDGE **ptrline = new CRACKEDGE*[t_image->get_xsize()+1];
|
||||
block->bounding_box (bleft, tright); // block box
|
||||
block_bleft = bleft;
|
||||
block_tright = tright;
|
||||
for (x = tright.x () - bleft.x (); x >= 0; x--)
|
||||
@ -93,9 +86,7 @@ DLLSYM void block_edges( //get edges in a block
|
||||
|
||||
free_crackedges(free_cracks); //really free them
|
||||
free_cracks = NULL;
|
||||
if (ptrline != ptrlinemem) {
|
||||
delete [] ptrline;
|
||||
}
|
||||
delete[] ptrline;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user