#include <imagedata.h>
Definition at line 103 of file imagedata.h.
◆ ImageData() [1/2]
tesseract::ImageData::ImageData |
( |
| ) |
|
Definition at line 122 of file imagedata.cpp.
122 : page_number_(-1), vertical_text_(
false) {
◆ ImageData() [2/2]
tesseract::ImageData::ImageData |
( |
bool |
vertical, |
|
|
Pix * |
pix |
|
) |
| |
Definition at line 125 of file imagedata.cpp.
126 : 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];
const GenericVector< TBOX > & boxes() const
◆ 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 134 of file imagedata.cpp.
143 memcpy(&
image_data->image_data_[0], imagedata, imagedatasize);
145 if (truth_text == NULL || truth_text[0] ==
'\0') {
146 tprintf(
"Error: No text corresponding to page %d from image %s!\n",
156 }
else if (truth_text != NULL && truth_text[0] !=
'\0' &&
void resize_no_init(int size)
const GenericVector< char > & image_data() const
const STRING & box_text(int index) const
◆ DeSerialize()
bool tesseract::ImageData::DeSerialize |
( |
bool |
swap, |
|
|
TFile * |
fp |
|
) |
| |
Definition at line 180 of file imagedata.cpp.
181 if (!imagefilename_.
DeSerialize(swap, fp))
return false;
182 if (fp->FRead(&page_number_,
sizeof(page_number_), 1) != 1)
return false;
183 if (swap)
ReverseN(&page_number_,
sizeof(page_number_));
184 if (!image_data_.
DeSerialize(swap, fp))
return false;
185 if (!transcription_.
DeSerialize(swap, fp))
return false;
190 if (fp->FRead(&vertical,
sizeof(vertical), 1) != 1)
return false;
191 vertical_text_ = vertical != 0;
bool DeSerializeClasses(bool swap, FILE *fp)
bool DeSerialize(bool swap, FILE *fp)
void ReverseN(void *ptr, int num_bytes)
bool DeSerialize(bool swap, FILE *fp)
◆ 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 == NULL)
return;
279 int width = pixGetWidth(pix);
280 int height = pixGetHeight(pix);
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;
294 if (!boxes_.
empty()) {
295 for (
int b = 0; b < boxes_.
size(); ++b) {
297 win->
Text(boxes_[b].left(), height + kTextSize, box_texts_[b].
string());
302 win->
Text(0, height + kTextSize * 2, transcription_.
string());
void Image(struct Pix *image, int x_pos, int y_pos)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
void Text(int x, int y, const char *mystring)
const char * string() const
char window_wait(ScrollView *win)
◆ 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 =
MIN(input_height, max_height);
236 float im_factor =
static_cast<float>(target_height) / input_height;
237 if (scaled_width != NULL)
239 if (scaled_height != NULL)
240 *scaled_height = target_height;
242 Pix* pix = pixScale(src_pix, im_factor, im_factor);
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 != NULL) *scaled_width = pixGetWidth(pix);
248 if (scaled_height != NULL) *scaled_height = pixGetHeight(pix);
249 pixDestroy(&src_pix);
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 != NULL) *scale_factor = im_factor;
void scale(const float f)
int IntCastRounded(double x)
const GenericVector< TBOX > & boxes() const
◆ Serialize()
bool tesseract::ImageData::Serialize |
( |
TFile * |
fp | ) |
const |
Definition at line 165 of file imagedata.cpp.
166 if (!imagefilename_.
Serialize(fp))
return false;
167 if (fp->FWrite(&page_number_,
sizeof(page_number_), 1) != 1)
return false;
168 if (!image_data_.
Serialize(fp))
return false;
169 if (!transcription_.
Serialize(fp))
return false;
173 inT8 vertical = vertical_text_;
174 if (fp->FWrite(&vertical,
sizeof(vertical), 1) != 1)
return false;
bool Serialize(FILE *fp) const
bool Serialize(FILE *fp) const
bool SerializeClasses(FILE *fp) const
◆ 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()
Definition at line 196 of file imagedata.cpp.
205 return fp->
FRead(&vertical,
sizeof(vertical), 1) == 1;
static bool SkipDeSerialize(bool swap, tesseract::TFile *fp)
int FRead(void *buffer, int size, int count)
◆ 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: