#include <imagedata.h>
Definition at line 205 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 427 of file imagedata.cpp.
429 pages_.push_back(page);
430 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 225 of file imagedata.h.
227 return document_name_;
◆ GetPage()
const ImageData * tesseract::DocumentData::GetPage |
( |
int |
index | ) |
|
Definition at line 447 of file imagedata.cpp.
448 ImageData* page =
nullptr;
452 bool needs_loading = pages_offset_ != index;
457 #if defined(__MINGW32__) 460 std::this_thread::sleep_for(std::chrono::seconds(1));
void Unlock()
Unlocks on a mutex.
void Lock()
Locks on a mutex.
void LoadPageInBackground(int index)
bool IsPageAvailable(int index, ImageData **page)
◆ IsCached()
bool tesseract::DocumentData::IsCached |
( |
| ) |
const |
|
inline |
◆ IsPageAvailable()
bool tesseract::DocumentData::IsPageAvailable |
( |
int |
index, |
|
|
ImageData ** |
page |
|
) |
| |
Definition at line 469 of file imagedata.cpp.
472 if (num_pages == 0 || index < 0) {
477 index =
Modulo(index, num_pages);
478 if (pages_offset_ <= index && index < pages_offset_ + pages_.size()) {
479 *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 390 of file imagedata.cpp.
393 pages_offset_ = start_page;
394 return ReCachePages();
void SetDocument(const char *filename, int64_t max_memory, FileReader reader)
◆ LoadPageInBackground()
void tesseract::DocumentData::LoadPageInBackground |
( |
int |
index | ) |
|
Definition at line 435 of file imagedata.cpp.
436 ImageData* page =
nullptr;
439 if (pages_offset_ == index)
return;
440 pages_offset_ = index;
friend void * ReCachePagesFunc(void *data)
static void StartThread(void *(*func)(void *), void *arg)
Create new thread.
bool IsPageAvailable(int index, ImageData **page)
◆ memory_used()
int64_t tesseract::DocumentData::memory_used |
( |
| ) |
const |
|
inline |
◆ NumPages()
int tesseract::DocumentData::NumPages |
( |
| ) |
const |
|
inline |
◆ SaveDocument()
bool tesseract::DocumentData::SaveDocument |
( |
const char * |
filename, |
|
|
FileWriter |
writer |
|
) |
| |
Definition at line 409 of file imagedata.cpp.
412 fp.OpenWrite(
nullptr);
413 if (!pages_.Serialize(&fp) || !fp.CloseWrite(filename, writer)) {
414 tprintf(
"Serialize failed: %s\n", filename);
DLLSYM void tprintf(const char *format,...)
◆ SaveToBuffer()
bool tesseract::DocumentData::SaveToBuffer |
( |
GenericVector< char > * |
buffer | ) |
|
Definition at line 419 of file imagedata.cpp.
422 fp.OpenWrite(buffer);
423 return pages_.Serialize(&fp);
◆ SetDocument()
void tesseract::DocumentData::SetDocument |
( |
const char * |
filename, |
|
|
int64_t |
max_memory, |
|
|
FileReader |
reader |
|
) |
| |
Definition at line 398 of file imagedata.cpp.
402 document_name_ = filename;
404 max_memory_ = max_memory;
◆ Shuffle()
void tesseract::DocumentData::Shuffle |
( |
| ) |
|
Definition at line 501 of file imagedata.cpp.
505 random.set_seed(document_name_.
string());
506 int num_pages = pages_.size();
508 for (
int i = 0; i < num_pages; ++i) {
509 int src = random.IntRand() % num_pages;
510 int dest = random.IntRand() % num_pages;
511 std::swap(pages_[src], pages_[dest]);
const char * string() const
◆ TakePage()
ImageData* tesseract::DocumentData::TakePage |
( |
int |
index | ) |
|
|
inline |
Definition at line 257 of file imagedata.h.
259 ImageData* page = pages_[index];
260 pages_[index] =
nullptr;
◆ UnCache()
int64_t tesseract::DocumentData::UnCache |
( |
| ) |
|
Definition at line 488 of file imagedata.cpp.
495 tprintf(
"Unloaded document %s, saving %" PRId64
" memory\n",
496 document_name_.
string(), memory_saved);
const char * string() const
int64_t memory_used() const
DLLSYM void tprintf(const char *format,...)
◆ ReCachePagesFunc
void* ReCachePagesFunc |
( |
void * |
data | ) |
|
|
friend |
Definition at line 369 of file imagedata.cpp.
371 document_data->ReCachePages();
DocumentData(const STRING &name)
The documentation for this class was generated from the following files: