|
tesseract 3.04.01
|
#include <imagedata.h>
Public Member Functions | |
| DocumentCache (inT64 max_memory) | |
| ~DocumentCache () | |
| bool | LoadDocuments (const GenericVector< STRING > &filenames, const char *lang, FileReader reader) |
| bool | AddToCache (DocumentData *data) |
| DocumentData * | FindDocument (const STRING &document_name) const |
| const ImageData * | GetPageBySerial (int serial) |
| const PointerVector < DocumentData > & | documents () const |
| int | total_pages () const |
Definition at line 245 of file imagedata.h.
| tesseract::DocumentCache::DocumentCache | ( | inT64 | max_memory | ) | [explicit] |
Definition at line 440 of file imagedata.cpp.
: total_pages_(0), memory_used_(0), max_memory_(max_memory) {}
DocumentCache::~DocumentCache() {}
| tesseract::DocumentCache::~DocumentCache | ( | ) |
Definition at line 442 of file imagedata.cpp.
| bool tesseract::DocumentCache::AddToCache | ( | DocumentData * | data | ) |
Definition at line 466 of file imagedata.cpp.
{
tprintf("Memory used=%lld vs max=%lld, discarding doc of size %lld\n",
memory_used_ , max_memory_, documents_[0]->memory_used());
memory_used_ -= documents_[0]->memory_used();
total_pages_ -= documents_[0]->NumPages();
documents_.remove(0);
}
return true;
}
| const PointerVector<DocumentData>& tesseract::DocumentCache::documents | ( | ) | const [inline] |
Definition at line 265 of file imagedata.h.
{
return documents_;
}
| DocumentData * tesseract::DocumentCache::FindDocument | ( | const STRING & | document_name | ) | const |
Definition at line 484 of file imagedata.cpp.
{
if (documents_[i]->document_name() == document_name)
return documents_[i];
}
return NULL;
}
| const ImageData * tesseract::DocumentCache::GetPageBySerial | ( | int | serial | ) |
Definition at line 494 of file imagedata.cpp.
| bool tesseract::DocumentCache::LoadDocuments | ( | const GenericVector< STRING > & | filenames, |
| const char * | lang, | ||
| FileReader | reader | ||
| ) |
Definition at line 446 of file imagedata.cpp.
{
inT64 fair_share_memory = max_memory_ / filenames.size();
for (int arg = 0; arg < filenames.size(); ++arg) {
STRING filename = filenames[arg];
DocumentData* document = new DocumentData(filename);
if (document->LoadDocument(filename.string(), lang, 0,
fair_share_memory, reader)) {
AddToCache(document);
} else {
tprintf("Failed to load image %s!\n", filename.string());
delete document;
}
}
tprintf("Loaded %d pages, total %gMB\n",
total_pages_, memory_used_ / 1048576.0);
return total_pages_ > 0;
}
| int tesseract::DocumentCache::total_pages | ( | ) | const [inline] |
Definition at line 268 of file imagedata.h.
{
return total_pages_;
}