mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-23 18:49:08 +08:00
Multi-page TIFF buffering is broken - fix #233
This commit is contained in:
parent
092c7d5690
commit
245eebdf29
@ -1028,6 +1028,7 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data,
|
||||
OpenclDevice od;
|
||||
#endif // USE_OPENCL
|
||||
int page = (tessedit_page_number >= 0) ? tessedit_page_number : 0;
|
||||
size_t offset = 0;
|
||||
for (; ; ++page) {
|
||||
if (tessedit_page_number >= 0)
|
||||
page = tessedit_page_number;
|
||||
@ -1039,8 +1040,8 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data,
|
||||
} else {
|
||||
#endif // USE_OPENCL
|
||||
pix = (data) ?
|
||||
pixReadMemTiff(data, size, page) :
|
||||
pixReadTiff(filename, page);
|
||||
pixReadMemFromMultipageTiff(data, size, &offset) :
|
||||
pixReadFromMultipageTiff(filename, &offset);
|
||||
#ifdef USE_OPENCL
|
||||
}
|
||||
#endif // USE_OPENCL
|
||||
@ -1054,6 +1055,7 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data,
|
||||
pixDestroy(&pix);
|
||||
if (!r) return false;
|
||||
if (tessedit_page_number >= 0) break;
|
||||
if (!offset) break;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
|
@ -214,10 +214,14 @@ void MasterTrainer::AddSample(bool verification, const char* unichar,
|
||||
// Must be called after ReadTrainingSamples, as the current number of images
|
||||
// is used as an offset for page numbers in the samples.
|
||||
void MasterTrainer::LoadPageImages(const char* filename) {
|
||||
size_t offset = 0;
|
||||
int page;
|
||||
Pix* pix;
|
||||
for (page = 0; (pix = pixReadTiff(filename, page)) != NULL; ++page) {
|
||||
for (page = 0; ; page++) {
|
||||
pix = pixReadFromMultipageTiff(filename, &offset);
|
||||
if (!pix) break;
|
||||
page_images_.push_back(pix);
|
||||
if (!offset) break;
|
||||
}
|
||||
tprintf("Loaded %d page images from %s\n", page, filename);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user