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

Static Protected Member Functions

static void SetUpTestCase ()
 
static void TearDownTestCase ()
 

Static Protected Attributes

static std::vector< Imagepix_
 
static std::vector< std::string > langs_
 
static std::vector< std::string > gt_text_
 
static int num_langs_
 

Detailed Description

Definition at line 64 of file baseapi_thread_test.cc.

Member Function Documentation

◆ SetUpTestCase()

static void tesseract::BaseapiThreadTest::SetUpTestCase ( )
inlinestaticprotected

Definition at line 66 of file baseapi_thread_test.cc.

66  {
67  CHECK(FLAGS_test_tesseract || FLAGS_test_cube)
68  << "Need to test at least one of Tesseract/Cube!";
69  // Form a list of langs/gt_text/image_files we will work with.
70  std::vector<std::string> image_files;
71  if (FLAGS_test_tesseract) {
72  int i = 0;
73  while (kTessLangs[i] && kTessTruthText[i] && kTessImages[i]) {
74  langs_.emplace_back(kTessLangs[i]);
75  gt_text_.emplace_back(kTessTruthText[i]);
76  image_files.emplace_back(kTessImages[i]);
77  ++i;
78  }
79  LOG(INFO) << "Testing Tesseract on " << i << " languages.";
80  }
81  if (FLAGS_test_cube) {
82  int i = 0;
83  while (kCubeLangs[i] && kCubeTruthText[i] && kCubeImages[i]) {
84  langs_.emplace_back(kCubeLangs[i]);
85  gt_text_.emplace_back(kCubeTruthText[i]);
86  image_files.emplace_back(kCubeImages[i]);
87  ++i;
88  }
89  LOG(INFO) << "Testing Cube on " << i << " languages.";
90  }
91  num_langs_ = langs_.size();
92 
93  // Pre-load the images into an array. We will be making multiple copies of
94  // an image here if FLAGS_reps > 1 and that is intentional. In this test, we
95  // wish to not make any assumptions about the thread-safety of Pix objects,
96  // and so entirely disallow concurrent access of a Pix instance.
97  const int n = num_langs_ * FLAGS_reps;
98  for (int i = 0; i < n; ++i) {
99  std::string path = TESTING_DIR "/" + image_files[i % num_langs_];
100  Image new_pix = pixRead(path.c_str());
101  QCHECK(new_pix != nullptr) << "Could not read " << path;
102  pix_.push_back(new_pix);
103  }
104 
105 #ifdef INCLUDE_TENSORFLOW
106  pool_size_ = (FLAGS_max_concurrent_instances < 1) ? num_langs_ * FLAGS_reps
107  : FLAGS_max_concurrent_instances;
108 #endif
109  }
@ LOG
#define CHECK(condition)
Definition: include_gunit.h:76
@ INFO
Definition: log.h:28
static std::vector< std::string > langs_
static std::vector< Image > pix_
static std::vector< std::string > gt_text_

◆ TearDownTestCase()

static void tesseract::BaseapiThreadTest::TearDownTestCase ( )
inlinestaticprotected

Definition at line 111 of file baseapi_thread_test.cc.

111  {
112  for (auto &pix : pix_) {
113  pix.destroy();
114  }
115  }

Member Data Documentation

◆ gt_text_

std::vector< std::string > tesseract::BaseapiThreadTest::gt_text_
staticprotected

Definition at line 132 of file baseapi_thread_test.cc.

◆ langs_

std::vector< std::string > tesseract::BaseapiThreadTest::langs_
staticprotected

Definition at line 131 of file baseapi_thread_test.cc.

◆ num_langs_

int tesseract::BaseapiThreadTest::num_langs_
staticprotected

Definition at line 133 of file baseapi_thread_test.cc.

◆ pix_

std::vector< Image > tesseract::BaseapiThreadTest::pix_
staticprotected

Definition at line 130 of file baseapi_thread_test.cc.


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