#include <imagedata.h>
Definition at line 169 of file imagedata.h.
◆ DocumentData()
tesseract::DocumentData::DocumentData |
( |
const std::string & |
name | ) |
|
|
explicit |
◆ ~DocumentData()
tesseract::DocumentData::~DocumentData |
( |
| ) |
|
Definition at line 389 of file imagedata.cpp.
390 if (thread.joinable()) {
393 std::lock_guard<std::mutex> lock_p(pages_mutex_);
394 std::lock_guard<std::mutex> lock_g(general_mutex_);
395 for (
auto data : pages_) {
◆ AddPageToDocument()
void tesseract::DocumentData::AddPageToDocument |
( |
ImageData * |
page | ) |
|
Definition at line 433 of file imagedata.cpp.
434 std::lock_guard<std::mutex> lock(pages_mutex_);
435 pages_.push_back(page);
436 set_memory_used(
memory_used() + page->MemoryUsed());
int64_t memory_used() const
◆ document_name()
const std::string& tesseract::DocumentData::document_name |
( |
| ) |
const |
|
inline |
Definition at line 190 of file imagedata.h.
191 std::lock_guard<std::mutex> lock(general_mutex_);
192 return document_name_;
◆ GetPage()
const ImageData * tesseract::DocumentData::GetPage |
( |
int |
index | ) |
|
Definition at line 467 of file imagedata.cpp.
468 ImageData *page =
nullptr;
472 bool needs_loading = pages_offset_ != index;
473 pages_mutex_.unlock();
479 std::this_thread::yield();
bool IsPageAvailable(int index, ImageData **page)
void LoadPageInBackground(int index)
◆ IsCached()
bool tesseract::DocumentData::IsCached |
( |
| ) |
const |
|
inline |
◆ IsPageAvailable()
bool tesseract::DocumentData::IsPageAvailable |
( |
int |
index, |
|
|
ImageData ** |
page |
|
) |
| |
Definition at line 487 of file imagedata.cpp.
488 std::lock_guard<std::mutex> lock(pages_mutex_);
490 if (num_pages == 0 || index < 0) {
495 index =
Modulo(index, num_pages);
496 if (pages_offset_ <= index &&
497 static_cast<unsigned>(index) < pages_offset_ + pages_.size()) {
498 *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 402 of file imagedata.cpp.
405 pages_offset_ = start_page;
406 return ReCachePages();
void SetDocument(const char *filename, int64_t max_memory, FileReader reader)
◆ LoadPageInBackground()
void tesseract::DocumentData::LoadPageInBackground |
( |
int |
index | ) |
|
Definition at line 441 of file imagedata.cpp.
442 ImageData *page =
nullptr;
447 std::lock_guard<std::mutex> lock(pages_mutex_);
448 if (pages_offset_ == index) {
451 pages_offset_ = index;
452 for (
auto page : pages_) {
457 if (thread.joinable()) {
◆ memory_used()
int64_t tesseract::DocumentData::memory_used |
( |
| ) |
const |
|
inline |
Definition at line 201 of file imagedata.h.
202 std::lock_guard<std::mutex> lock(general_mutex_);
◆ NumPages()
int tesseract::DocumentData::NumPages |
( |
| ) |
const |
|
inline |
Definition at line 194 of file imagedata.h.
195 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 421 of file imagedata.cpp.
422 std::lock_guard<std::mutex> lock(pages_mutex_);
424 fp.OpenWrite(
nullptr);
425 if (!fp.Serialize(pages_) || !fp.CloseWrite(filename, writer)) {
426 tprintf(
"Serialize failed: %s\n", filename);
void tprintf(const char *format,...)
◆ SetDocument()
void tesseract::DocumentData::SetDocument |
( |
const char * |
filename, |
|
|
int64_t |
max_memory, |
|
|
FileReader |
reader |
|
) |
| |
Definition at line 410 of file imagedata.cpp.
412 std::lock_guard<std::mutex> lock_p(pages_mutex_);
413 std::lock_guard<std::mutex> lock(general_mutex_);
414 document_name_ = filename;
416 max_memory_ = max_memory;
◆ Shuffle()
void tesseract::DocumentData::Shuffle |
( |
| ) |
|
Definition at line 523 of file imagedata.cpp.
527 random.set_seed(document_name_.c_str());
528 int num_pages = pages_.size();
530 for (
int i = 0; i < num_pages; ++i) {
531 int src = random.IntRand() % num_pages;
532 int dest = random.IntRand() % num_pages;
533 std::swap(pages_[src], pages_[dest]);
◆ TakePage()
ImageData* tesseract::DocumentData::TakePage |
( |
int |
index | ) |
|
|
inline |
Definition at line 226 of file imagedata.h.
227 std::lock_guard<std::mutex> lock(pages_mutex_);
228 ImageData *page = pages_[index];
229 pages_[index] =
nullptr;
◆ UnCache()
int64_t tesseract::DocumentData::UnCache |
( |
| ) |
|
Definition at line 507 of file imagedata.cpp.
508 std::lock_guard<std::mutex> lock(pages_mutex_);
510 for (
auto page : pages_) {
517 tprintf(
"Unloaded document %s, saving %" PRId64
" memory\n",
518 document_name_.c_str(), memory_saved);
The documentation for this class was generated from the following files: