#include <imagedata.h>
Definition at line 105 of file imagedata.h.
◆ ImageData() [1/2]
tesseract::ImageData::ImageData |
( |
| ) |
|
Definition at line 123 of file imagedata.cpp.
123 : page_number_(-1), vertical_text_(
false) {
◆ ImageData() [2/2]
tesseract::ImageData::ImageData |
( |
bool |
vertical, |
|
|
Pix * |
pix |
|
) |
| |
Definition at line 126 of file imagedata.cpp.
127 : page_number_(0), vertical_text_(vertical) {
◆ ~ImageData()
tesseract::ImageData::~ImageData |
( |
| ) |
|
◆ AddBoxes()
Definition at line 313 of file imagedata.cpp.
317 for (
int i = 0; i < box_pages.
size(); ++i) {
318 if (page_number_ >= 0 && box_pages[i] != page_number_)
continue;
319 transcription_ += texts[i];
const GenericVector< TBOX > & boxes() const
◆ box_text()
const STRING& tesseract::ImageData::box_text |
( |
int |
index | ) |
const |
|
inline |
Definition at line 156 of file imagedata.h.
157 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 135 of file imagedata.cpp.
144 memcpy(&
image_data->image_data_[0], imagedata, imagedatasize);
146 if (truth_text ==
nullptr || truth_text[0] ==
'\0') {
147 tprintf(
"Error: No text corresponding to page %d from image %s!\n",
157 }
else if (truth_text !=
nullptr && truth_text[0] !=
'\0' &&
void resize_no_init(int size)
const GenericVector< char > & image_data() const
DLLSYM void tprintf(const char *format,...)
const STRING & box_text(int index) const
◆ DeSerialize()
bool tesseract::ImageData::DeSerialize |
( |
TFile * |
fp | ) |
|
Definition at line 181 of file imagedata.cpp.
183 if (!fp->DeSerialize(&page_number_))
return false;
191 if (!fp->DeSerialize(&vertical))
return false;
192 vertical_text_ = vertical != 0;
bool DeSerialize(bool swap, FILE *fp)
bool DeSerialize(bool swap, FILE *fp)
bool DeSerializeClasses(bool swap, FILE *fp)
◆ Display()
void tesseract::ImageData::Display |
( |
| ) |
const |
Definition at line 275 of file imagedata.cpp.
276 #ifndef GRAPHICS_DISABLED 277 const int kTextSize = 64;
280 if (pix ==
nullptr)
return;
281 int width = pixGetWidth(pix);
282 int height = pixGetHeight(pix);
284 2 * (width + 2 * kTextSize),
285 2 * (height + 4 * kTextSize),
286 width + 10, height + 3 * kTextSize,
true);
287 win->
Image(pix, 0, height - 1);
292 int text_size = kTextSize;
293 if (!boxes_.
empty() && boxes_[0].height() * 2 < text_size)
294 text_size = boxes_[0].height() * 2;
296 if (!boxes_.
empty()) {
297 for (
int b = 0; b < boxes_.
size(); ++b) {
299 win->
Text(boxes_[b].left(), height + kTextSize, box_texts_[b].
string());
304 win->
Text(0, height + kTextSize * 2, transcription_.
string());
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
const char * string() const
void Text(int x, int y, const char *mystring)
void Image(struct Pix *image, int x_pos, int y_pos)
char window_wait(ScrollView *win)
◆ GetPix()
Pix * tesseract::ImageData::GetPix |
( |
| ) |
const |
Definition at line 216 of file imagedata.cpp.
217 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 126 of file imagedata.h.
127 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 226 of file imagedata.cpp.
230 int input_height = 0;
233 input_width = pixGetWidth(src_pix);
234 input_height = pixGetHeight(src_pix);
235 if (target_height == 0) {
236 target_height = std::min(input_height, max_height);
238 float im_factor =
static_cast<float>(target_height) / input_height;
239 if (scaled_width !=
nullptr)
241 if (scaled_height !=
nullptr)
242 *scaled_height = target_height;
244 Pix* pix = pixScale(src_pix, im_factor, im_factor);
245 if (pix ==
nullptr) {
246 tprintf(
"Scaling pix of size %d, %d by factor %g made null pix!!\n",
247 input_width, input_height, im_factor);
249 if (scaled_width !=
nullptr) *scaled_width = pixGetWidth(pix);
250 if (scaled_height !=
nullptr) *scaled_height = pixGetHeight(pix);
251 pixDestroy(&src_pix);
252 if (
boxes !=
nullptr) {
255 for (
int b = 0; b < boxes_.
size(); ++b) {
256 TBOX box = boxes_[b];
257 box.
scale(im_factor);
262 TBOX box(0, 0, im_factor * input_width, target_height);
266 if (scale_factor !=
nullptr) *scale_factor = im_factor;
const GenericVector< TBOX > & boxes() const
void scale(const float f)
int IntCastRounded(double x)
DLLSYM void tprintf(const char *format,...)
◆ Serialize()
bool tesseract::ImageData::Serialize |
( |
TFile * |
fp | ) |
const |
Definition at line 166 of file imagedata.cpp.
167 if (!imagefilename_.
Serialize(fp))
return false;
168 if (!fp->Serialize(&page_number_))
return false;
169 if (!image_data_.
Serialize(fp))
return false;
170 if (!language_.
Serialize(fp))
return false;
171 if (!transcription_.
Serialize(fp))
return false;
175 int8_t vertical = vertical_text_;
176 return fp->Serialize(&vertical);
bool Serialize(FILE *fp) const
bool SerializeClasses(FILE *fp) const
bool Serialize(FILE *fp) const
◆ set_imagefilename()
void tesseract::ImageData::set_imagefilename |
( |
const STRING & |
name | ) |
|
|
inline |
Definition at line 129 of file imagedata.h.
130 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 211 of file imagedata.cpp.
212 SetPixInternal(pix, &image_data_);
◆ SkipDeSerialize()
bool tesseract::ImageData::SkipDeSerialize |
( |
TFile * |
fp | ) |
|
|
static |
Definition at line 197 of file imagedata.cpp.
207 return fp->DeSerialize(&vertical);
static bool SkipDeSerialize(tesseract::TFile *fp)
◆ transcription()
const STRING& tesseract::ImageData::transcription |
( |
| ) |
const |
|
inline |
Definition at line 147 of file imagedata.h.
148 return transcription_;
The documentation for this class was generated from the following files: