tesseract  5.0.0
tesseract::ImagedataTest Class Reference
Inheritance diagram for tesseract::ImagedataTest:

Protected Member Functions

void SetUp () override
 
 ImagedataTest ()=default
 
std::string MakeFakeDoc (int num_pages, unsigned doc_id, std::vector< std::string > *page_texts)
 

Detailed Description

Definition at line 23 of file imagedata_test.cc.

Constructor & Destructor Documentation

◆ ImagedataTest()

tesseract::ImagedataTest::ImagedataTest ( )
protecteddefault

Member Function Documentation

◆ MakeFakeDoc()

std::string tesseract::ImagedataTest::MakeFakeDoc ( int  num_pages,
unsigned  doc_id,
std::vector< std::string > *  page_texts 
)
inlineprotected

Definition at line 33 of file imagedata_test.cc.

33  {
34  // The size of the fake images that we will use.
35  const int kImageSize = 1048576;
36  // Not using a real image here - just an array of zeros! We are just testing
37  // that the truth text matches.
38  std::vector<char> fake_image(kImageSize, 0);
39  DocumentData write_doc("My document");
40  for (int p = 0; p < num_pages; ++p) {
41  // Make some fake text that is different for each page and save it.
42  char text[80];
43  snprintf(text, sizeof(text), "Page %d of %d in doc %u", p, num_pages, doc_id);
44  page_texts->push_back(text);
45  // Make an imagedata and put it in the document.
46  ImageData *imagedata = ImageData::Build("noname", p, "eng", fake_image.data(),
47  fake_image.size(), (*page_texts)[p].c_str(), nullptr);
48  EXPECT_EQ(kImageSize, imagedata->MemoryUsed());
49  write_doc.AddPageToDocument(imagedata);
50  }
51  // Write it to a file.
52  std::string filename =
53  file::JoinPath(FLAGS_test_tmpdir, "documentdata");
54  filename += std::to_string(doc_id) + ".lstmf";
55  EXPECT_TRUE(write_doc.SaveDocument(filename.c_str(), nullptr));
56  return filename;
57  }
static ImageData * Build(const char *name, int page_number, const char *lang, const char *imagedata, int imagedatasize, const char *truth_text, const char *box_text)
Definition: imagedata.cpp:58
static std::string JoinPath(const std::string &s1, const std::string &s2)
Definition: include_gunit.h:65

◆ SetUp()

void tesseract::ImagedataTest::SetUp ( )
inlineoverrideprotected

Definition at line 25 of file imagedata_test.cc.

25  {
26  std::locale::global(std::locale(""));
28  }
static void MakeTmpdir()
Definition: include_gunit.h:38

The documentation for this class was generated from the following file: