#include <imagedata.h>
Definition at line 245 of file imagedata.h.
tesseract::DocumentCache::DocumentCache |
( |
inT64 |
max_memory | ) |
|
|
explicit |
Definition at line 435 of file imagedata.cpp.
436 : total_pages_(0), memory_used_(0), max_memory_(max_memory) {}
tesseract::DocumentCache::~DocumentCache |
( |
| ) |
|
bool tesseract::DocumentCache::AddToCache |
( |
DocumentData * |
data | ) |
|
Definition at line 461 of file imagedata.cpp.
462 inT64 new_memory = data->memory_used();
463 memory_used_ += new_memory;
464 documents_.push_back(data);
465 total_pages_ += data->NumPages();
468 while (memory_used_ >= max_memory_ && max_memory_ > 0) {
469 tprintf(
"Memory used=%lld vs max=%lld, discarding doc of size %lld\n",
470 memory_used_ , max_memory_, documents_[0]->memory_used());
471 memory_used_ -= documents_[0]->memory_used();
472 total_pages_ -= documents_[0]->NumPages();
473 documents_.remove(0);
DocumentData * tesseract::DocumentCache::FindDocument |
( |
const STRING & |
document_name | ) |
const |
Definition at line 479 of file imagedata.cpp.
480 for (
int i = 0; i < documents_.size(); ++i) {
481 if (documents_[i]->document_name() == document_name)
482 return documents_[i];
const ImageData * tesseract::DocumentCache::GetPageBySerial |
( |
int |
serial | ) |
|
Definition at line 489 of file imagedata.cpp.
490 int document_index = serial % documents_.size();
491 return documents_[document_index]->GetPage(serial / documents_.size());
Definition at line 441 of file imagedata.cpp.
443 inT64 fair_share_memory = max_memory_ / filenames.
size();
444 for (
int arg = 0; arg < filenames.
size(); ++arg) {
446 DocumentData* document =
new DocumentData(filename);
447 if (document->LoadDocument(filename.
string(),
lang, 0,
448 fair_share_memory, reader)) {
455 tprintf(
"Loaded %d pages, total %gMB\n",
456 total_pages_, memory_used_ / 1048576.0);
457 return total_pages_ > 0;
bool AddToCache(DocumentData *data)
const char * string() const
int tesseract::DocumentCache::total_pages |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: