#include <imagedata.h>
Definition at line 104 of file imagedata.h.
◆ ImageData() [1/2]
tesseract::ImageData::ImageData |
( |
| ) |
|
Definition at line 119 of file imagedata.cpp.
119 : page_number_(-1), vertical_text_(
false) {
◆ ImageData() [2/2]
tesseract::ImageData::ImageData |
( |
bool |
vertical, |
|
|
Pix * |
pix |
|
) |
| |
Definition at line 122 of file imagedata.cpp.
123 : page_number_(0), vertical_text_(vertical) {
◆ ~ImageData()
tesseract::ImageData::~ImageData |
( |
| ) |
|
◆ AddBoxes()
Definition at line 311 of file imagedata.cpp.
315 for (
int i = 0; i < box_pages.
size(); ++i) {
316 if (page_number_ >= 0 && box_pages[i] != page_number_)
continue;
317 transcription_ += texts[i];
◆ box_text()
const STRING& tesseract::ImageData::box_text |
( |
int |
index | ) |
const |
|
inline |
Definition at line 155 of file imagedata.h.
156 return box_texts_[index];
◆ box_texts()
◆ boxes()
◆ Build()
ImageData * tesseract::ImageData::Build |
( |
const char * |
name, |
|
|
int |
page_number, |
|
|
const char * |
lang, |
|
|
const char * |
imagedata, |
|
|
int |
imagedatasize, |
|
|
const char * |
truth_text, |
|
|
const char * |
box_text |
|
) |
| |
|
static |
Definition at line 131 of file imagedata.cpp.
140 memcpy(&
image_data->image_data_[0], imagedata, imagedatasize);
142 if (truth_text ==
nullptr || truth_text[0] ==
'\0') {
143 tprintf(
"Error: No text corresponding to page %d from image %s!\n",
153 }
else if (truth_text !=
nullptr && truth_text[0] !=
'\0' &&
◆ DeSerialize()
bool tesseract::ImageData::DeSerialize |
( |
TFile * |
fp | ) |
|
Definition at line 177 of file imagedata.cpp.
179 if (!fp->DeSerialize(&page_number_))
return false;
187 if (!fp->DeSerialize(&vertical))
return false;
188 vertical_text_ = vertical != 0;
◆ Display()
void tesseract::ImageData::Display |
( |
| ) |
const |
Definition at line 273 of file imagedata.cpp.
274 #ifndef GRAPHICS_DISABLED
275 const int kTextSize = 64;
278 if (pix ==
nullptr)
return;
279 int width = pixGetWidth(pix);
280 int height = pixGetHeight(pix);
281 auto* win =
new ScrollView(
"Imagedata", 100, 100,
282 2 * (width + 2 * kTextSize),
283 2 * (height + 4 * kTextSize),
284 width + 10, height + 3 * kTextSize,
true);
285 win->Image(pix, 0, height - 1);
290 int text_size = kTextSize;
291 if (!boxes_.
empty() && boxes_[0].height() * 2 < text_size)
292 text_size = boxes_[0].height() * 2;
293 win->TextAttributes(
"Arial", text_size,
false,
false,
false);
294 if (!boxes_.
empty()) {
295 for (
int b = 0; b < boxes_.
size(); ++b) {
297 win->Text(boxes_[b].left(), height + kTextSize, box_texts_[b].c_str());
302 win->Text(0, height + kTextSize * 2, transcription_.
c_str());
◆ GetPix()
Pix * tesseract::ImageData::GetPix |
( |
| ) |
const |
Definition at line 214 of file imagedata.cpp.
215 return GetPixInternal(image_data_);
◆ image_data()
const GenericVector<char>& tesseract::ImageData::image_data |
( |
| ) |
const |
|
inline |
◆ imagefilename()
const STRING& tesseract::ImageData::imagefilename |
( |
| ) |
const |
|
inline |
Definition at line 125 of file imagedata.h.
126 return imagefilename_;
◆ language()
const STRING& tesseract::ImageData::language |
( |
| ) |
const |
|
inline |
◆ MemoryUsed()
int tesseract::ImageData::MemoryUsed |
( |
| ) |
const |
◆ page_number()
int tesseract::ImageData::page_number |
( |
| ) |
const |
|
inline |
◆ PreScale()
Pix * tesseract::ImageData::PreScale |
( |
int |
target_height, |
|
|
int |
max_height, |
|
|
float * |
scale_factor, |
|
|
int * |
scaled_width, |
|
|
int * |
scaled_height, |
|
|
GenericVector< TBOX > * |
boxes |
|
) |
| const |
Definition at line 224 of file imagedata.cpp.
228 int input_height = 0;
231 input_width = pixGetWidth(src_pix);
232 input_height = pixGetHeight(src_pix);
233 if (target_height == 0) {
234 target_height = std::min(input_height, max_height);
236 float im_factor = static_cast<float>(target_height) / input_height;
237 if (scaled_width !=
nullptr)
239 if (scaled_height !=
nullptr)
240 *scaled_height = target_height;
242 Pix* pix = pixScale(src_pix, im_factor, im_factor);
243 if (pix ==
nullptr) {
244 tprintf(
"Scaling pix of size %d, %d by factor %g made null pix!!\n",
245 input_width, input_height, im_factor);
247 if (scaled_width !=
nullptr) *scaled_width = pixGetWidth(pix);
248 if (scaled_height !=
nullptr) *scaled_height = pixGetHeight(pix);
249 pixDestroy(&src_pix);
250 if (
boxes !=
nullptr) {
253 for (
int b = 0; b < boxes_.
size(); ++b) {
254 TBOX box = boxes_[b];
255 box.
scale(im_factor);
260 TBOX box(0, 0, im_factor * input_width, target_height);
264 if (scale_factor !=
nullptr) *scale_factor = im_factor;
◆ Serialize()
bool tesseract::ImageData::Serialize |
( |
TFile * |
fp | ) |
const |
Definition at line 162 of file imagedata.cpp.
163 if (!imagefilename_.
Serialize(fp))
return false;
164 if (!fp->Serialize(&page_number_))
return false;
165 if (!image_data_.
Serialize(fp))
return false;
166 if (!language_.
Serialize(fp))
return false;
167 if (!transcription_.
Serialize(fp))
return false;
171 int8_t vertical = vertical_text_;
172 return fp->Serialize(&vertical);
◆ set_imagefilename()
void tesseract::ImageData::set_imagefilename |
( |
const STRING & |
name | ) |
|
|
inline |
Definition at line 128 of file imagedata.h.
129 imagefilename_ = name;
◆ set_language()
void tesseract::ImageData::set_language |
( |
const STRING & |
lang | ) |
|
|
inline |
◆ set_page_number()
void tesseract::ImageData::set_page_number |
( |
int |
num | ) |
|
|
inline |
◆ SetPix()
void tesseract::ImageData::SetPix |
( |
Pix * |
pix | ) |
|
Definition at line 209 of file imagedata.cpp.
210 SetPixInternal(pix, &image_data_);
◆ SkipDeSerialize()
bool tesseract::ImageData::SkipDeSerialize |
( |
TFile * |
fp | ) |
|
|
static |
Definition at line 193 of file imagedata.cpp.
203 return fp->DeSerialize(&vertical);
◆ transcription()
const STRING& tesseract::ImageData::transcription |
( |
| ) |
const |
|
inline |
Definition at line 146 of file imagedata.h.
147 return transcription_;
The documentation for this class was generated from the following files: