#include <imagedata.h>
Definition at line 208 of file imagedata.h.
◆ DocumentData()
tesseract::DocumentData::DocumentData |
( |
const STRING & |
name | ) |
|
|
explicit |
◆ ~DocumentData()
tesseract::DocumentData::~DocumentData |
( |
| ) |
|
Definition at line 380 of file imagedata.cpp.
381 std::lock_guard<std::mutex> lock_p(pages_mutex_);
382 std::lock_guard<std::mutex> lock_g(general_mutex_);
◆ AddPageToDocument()
void tesseract::DocumentData::AddPageToDocument |
( |
ImageData * |
page | ) |
|
Definition at line 424 of file imagedata.cpp.
425 std::lock_guard<std::mutex> lock(pages_mutex_);
426 pages_.push_back(page);
427 set_memory_used(
memory_used() + page->MemoryUsed());
◆ document_name()
const STRING& tesseract::DocumentData::document_name |
( |
| ) |
const |
|
inline |
Definition at line 228 of file imagedata.h.
229 std::lock_guard<std::mutex> lock(general_mutex_);
230 return document_name_;
◆ GetPage()
const ImageData * tesseract::DocumentData::GetPage |
( |
int |
index | ) |
|
Definition at line 445 of file imagedata.cpp.
446 ImageData* page =
nullptr;
450 bool needs_loading = pages_offset_ != index;
451 pages_mutex_.unlock();
455 std::this_thread::yield();
◆ IsCached()
bool tesseract::DocumentData::IsCached |
( |
| ) |
const |
|
inline |
◆ IsPageAvailable()
bool tesseract::DocumentData::IsPageAvailable |
( |
int |
index, |
|
|
ImageData ** |
page |
|
) |
| |
Definition at line 463 of file imagedata.cpp.
464 std::lock_guard<std::mutex> lock(pages_mutex_);
466 if (num_pages == 0 || index < 0) {
471 index =
Modulo(index, num_pages);
472 if (pages_offset_ <= index && index < pages_offset_ + pages_.size()) {
473 *page = pages_[index - pages_offset_];
◆ LoadDocument()
bool tesseract::DocumentData::LoadDocument |
( |
const char * |
filename, |
|
|
int |
start_page, |
|
|
int64_t |
max_memory, |
|
|
FileReader |
reader |
|
) |
| |
Definition at line 387 of file imagedata.cpp.
390 pages_offset_ = start_page;
391 return ReCachePages();
◆ LoadPageInBackground()
void tesseract::DocumentData::LoadPageInBackground |
( |
int |
index | ) |
|
Definition at line 432 of file imagedata.cpp.
433 ImageData* page =
nullptr;
435 std::lock_guard<std::mutex> lock(pages_mutex_);
436 if (pages_offset_ == index)
return;
437 pages_offset_ = index;
439 std::thread t(&tesseract::DocumentData::ReCachePages,
this);
◆ memory_used()
int64_t tesseract::DocumentData::memory_used |
( |
| ) |
const |
|
inline |
Definition at line 239 of file imagedata.h.
240 std::lock_guard<std::mutex> lock(general_mutex_);
◆ NumPages()
int tesseract::DocumentData::NumPages |
( |
| ) |
const |
|
inline |
Definition at line 232 of file imagedata.h.
233 std::lock_guard<std::mutex> lock(general_mutex_);
◆ PagesSize()
size_t tesseract::DocumentData::PagesSize |
( |
| ) |
const |
|
inline |
◆ SaveDocument()
bool tesseract::DocumentData::SaveDocument |
( |
const char * |
filename, |
|
|
FileWriter |
writer |
|
) |
| |
Definition at line 406 of file imagedata.cpp.
407 std::lock_guard<std::mutex> lock(pages_mutex_);
409 fp.OpenWrite(
nullptr);
410 if (!pages_.Serialize(&fp) || !fp.CloseWrite(filename, writer)) {
411 tprintf(
"Serialize failed: %s\n", filename);
◆ SaveToBuffer()
bool tesseract::DocumentData::SaveToBuffer |
( |
GenericVector< char > * |
buffer | ) |
|
Definition at line 416 of file imagedata.cpp.
417 std::lock_guard<std::mutex> lock(pages_mutex_);
419 fp.OpenWrite(buffer);
420 return pages_.Serialize(&fp);
◆ SetDocument()
void tesseract::DocumentData::SetDocument |
( |
const char * |
filename, |
|
|
int64_t |
max_memory, |
|
|
FileReader |
reader |
|
) |
| |
Definition at line 395 of file imagedata.cpp.
397 std::lock_guard<std::mutex> lock_p(pages_mutex_);
398 std::lock_guard<std::mutex> lock(general_mutex_);
399 document_name_ = filename;
401 max_memory_ = max_memory;
◆ Shuffle()
void tesseract::DocumentData::Shuffle |
( |
| ) |
|
Definition at line 495 of file imagedata.cpp.
499 random.set_seed(document_name_.
c_str());
500 int num_pages = pages_.size();
502 for (
int i = 0; i < num_pages; ++i) {
503 int src = random.IntRand() % num_pages;
504 int dest = random.IntRand() % num_pages;
505 std::swap(pages_[src], pages_[
dest]);
◆ TakePage()
ImageData* tesseract::DocumentData::TakePage |
( |
int |
index | ) |
|
|
inline |
Definition at line 263 of file imagedata.h.
264 std::lock_guard<std::mutex> lock(pages_mutex_);
265 ImageData* page = pages_[index];
266 pages_[index] =
nullptr;
◆ UnCache()
int64_t tesseract::DocumentData::UnCache |
( |
| ) |
|
Definition at line 482 of file imagedata.cpp.
483 std::lock_guard<std::mutex> lock(pages_mutex_);
489 tprintf(
"Unloaded document %s, saving %" PRId64
" memory\n",
490 document_name_.
c_str(), memory_saved);
◆ ReCachePagesFunc
void* ReCachePagesFunc |
( |
void * |
data | ) |
|
|
friend |
The documentation for this class was generated from the following files: