#include <imagedata.h>
Definition at line 209 of file imagedata.h.
◆ DocumentData()
tesseract::DocumentData::DocumentData |
( |
const STRING & |
name | ) |
|
|
explicit |
◆ ~DocumentData()
tesseract::DocumentData::~DocumentData |
( |
| ) |
|
◆ AddPageToDocument()
void tesseract::DocumentData::AddPageToDocument |
( |
ImageData * |
page | ) |
|
Definition at line 435 of file imagedata.cpp.
437 pages_.push_back(page);
438 set_memory_used(
memory_used() + page->MemoryUsed());
int64_t memory_used() const
◆ document_name()
const STRING& tesseract::DocumentData::document_name |
( |
| ) |
const |
|
inline |
Definition at line 229 of file imagedata.h.
231 return document_name_;
◆ GetPage()
const ImageData * tesseract::DocumentData::GetPage |
( |
int |
index | ) |
|
Definition at line 455 of file imagedata.cpp.
456 ImageData* page =
nullptr;
460 bool needs_loading = pages_offset_ != index;
465 #if defined(__MINGW32__)
468 std::this_thread::sleep_for(std::chrono::seconds(1));
bool IsPageAvailable(int index, ImageData **page)
void LoadPageInBackground(int index)
void Unlock()
Unlocks on a mutex.
void Lock()
Locks on a mutex.
◆ IsCached()
bool tesseract::DocumentData::IsCached |
( |
| ) |
const |
|
inline |
◆ IsPageAvailable()
bool tesseract::DocumentData::IsPageAvailable |
( |
int |
index, |
|
|
ImageData ** |
page |
|
) |
| |
Definition at line 477 of file imagedata.cpp.
480 if (num_pages == 0 || index < 0) {
485 index =
Modulo(index, num_pages);
486 if (pages_offset_ <= index && index < pages_offset_ + pages_.size()) {
487 *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 398 of file imagedata.cpp.
401 pages_offset_ = start_page;
402 return ReCachePages();
void SetDocument(const char *filename, int64_t max_memory, FileReader reader)
◆ LoadPageInBackground()
void tesseract::DocumentData::LoadPageInBackground |
( |
int |
index | ) |
|
Definition at line 443 of file imagedata.cpp.
444 ImageData* page =
nullptr;
447 if (pages_offset_ == index)
return;
448 pages_offset_ = index;
friend void * ReCachePagesFunc(void *data)
static void StartThread(void *(*func)(void *), void *arg)
Create new thread.
◆ memory_used()
int64_t tesseract::DocumentData::memory_used |
( |
| ) |
const |
|
inline |
◆ NumPages()
int tesseract::DocumentData::NumPages |
( |
| ) |
const |
|
inline |
◆ PagesSize()
size_t tesseract::DocumentData::PagesSize |
( |
| ) |
const |
|
inline |
◆ SaveDocument()
bool tesseract::DocumentData::SaveDocument |
( |
const char * |
filename, |
|
|
FileWriter |
writer |
|
) |
| |
Definition at line 417 of file imagedata.cpp.
420 fp.OpenWrite(
nullptr);
421 if (!pages_.Serialize(&fp) || !fp.CloseWrite(filename, writer)) {
422 tprintf(
"Serialize failed: %s\n", filename);
DLLSYM void tprintf(const char *format,...)
◆ SaveToBuffer()
bool tesseract::DocumentData::SaveToBuffer |
( |
GenericVector< char > * |
buffer | ) |
|
Definition at line 427 of file imagedata.cpp.
430 fp.OpenWrite(buffer);
431 return pages_.Serialize(&fp);
◆ SetDocument()
void tesseract::DocumentData::SetDocument |
( |
const char * |
filename, |
|
|
int64_t |
max_memory, |
|
|
FileReader |
reader |
|
) |
| |
Definition at line 406 of file imagedata.cpp.
410 document_name_ = filename;
412 max_memory_ = max_memory;
◆ Shuffle()
void tesseract::DocumentData::Shuffle |
( |
| ) |
|
Definition at line 509 of file imagedata.cpp.
513 random.set_seed(document_name_.
string());
514 int num_pages = pages_.size();
516 for (
int i = 0; i < num_pages; ++i) {
517 int src = random.IntRand() % num_pages;
518 int dest = random.IntRand() % num_pages;
519 std::swap(pages_[src], pages_[
dest]);
const char * string() const
◆ TakePage()
ImageData* tesseract::DocumentData::TakePage |
( |
int |
index | ) |
|
|
inline |
Definition at line 264 of file imagedata.h.
266 ImageData* page = pages_[index];
267 pages_[index] =
nullptr;
◆ UnCache()
int64_t tesseract::DocumentData::UnCache |
( |
| ) |
|
Definition at line 496 of file imagedata.cpp.
503 tprintf(
"Unloaded document %s, saving %" PRId64
" memory\n",
504 document_name_.
string(), memory_saved);
◆ ReCachePagesFunc
void* ReCachePagesFunc |
( |
void * |
data | ) |
|
|
friend |
Definition at line 377 of file imagedata.cpp.
379 document_data->ReCachePages();
DocumentData(const STRING &name)
The documentation for this class was generated from the following files: