#include <imagedata.h>
Definition at line 88 of file imagedata.h.
| tesseract::ImageData::ImageData |
( |
| ) |
|
Definition at line 112 of file imagedata.cpp.
112 : page_number_(-1), vertical_text_(
false) {
| tesseract::ImageData::ImageData |
( |
bool |
vertical, |
|
|
Pix * |
pix |
|
) |
| |
Definition at line 115 of file imagedata.cpp.
116 : page_number_(0), vertical_text_(vertical) {
| tesseract::ImageData::~ImageData |
( |
| ) |
|
Definition at line 289 of file imagedata.cpp.
293 for (
int i = 0; i < box_pages.
size(); ++i) {
294 if (page_number_ >= 0 && box_pages[i] != page_number_)
continue;
295 transcription_ += texts[i];
| const STRING& tesseract::ImageData::box_text |
( |
int |
index | ) |
const |
|
inline |
Definition at line 138 of file imagedata.h.
139 return box_texts_[index];
| 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 124 of file imagedata.cpp.
128 image_data->imagefilename_ =
name;
130 image_data->language_ =
lang;
132 image_data->image_data_.init_to_size(imagedatasize, 0);
133 memcpy(&image_data->image_data_[0], imagedata, imagedatasize);
134 if (!image_data->AddBoxes(
box_text)) {
135 if (truth_text == NULL || truth_text[0] ==
'\0') {
136 tprintf(
"Error: No text corresponding to page %d from image %s!\n",
141 image_data->transcription_ = truth_text;
143 image_data->box_texts_.
push_back(truth_text);
146 }
else if (truth_text != NULL && truth_text[0] !=
'\0' &&
147 image_data->transcription_ != truth_text) {
149 image_data->transcription_ = truth_text;
const GenericVector< char > & image_data() const
const STRING & box_text(int index) const
| bool tesseract::ImageData::DeSerialize |
( |
bool |
swap, |
|
|
TFile * |
fp |
|
) |
| |
Definition at line 170 of file imagedata.cpp.
171 if (!imagefilename_.
DeSerialize(swap, fp))
return false;
172 if (fp->FRead(&page_number_,
sizeof(page_number_), 1) != 1)
return false;
173 if (swap)
ReverseN(&page_number_,
sizeof(page_number_));
174 if (!image_data_.
DeSerialize(swap, fp))
return false;
175 if (!transcription_.
DeSerialize(swap, fp))
return false;
180 if (fp->FRead(&vertical,
sizeof(vertical), 1) != 1)
return false;
181 vertical_text_ = vertical != 0;
bool DeSerialize(bool swap, FILE *fp)
bool DeSerializeClasses(bool swap, FILE *fp)
void ReverseN(void *ptr, int num_bytes)
bool DeSerialize(bool swap, FILE *fp)
| void tesseract::ImageData::Display |
( |
| ) |
const |
Definition at line 252 of file imagedata.cpp.
253 #ifndef GRAPHICS_DISABLED
254 const int kTextSize = 64;
257 if (pix == NULL)
return;
258 int width = pixGetWidth(pix);
259 int height = pixGetHeight(pix);
261 2 * (width + 2 * kTextSize),
262 2 * (height + 4 * kTextSize),
263 width + 10, height + 3 * kTextSize,
true);
264 win->
Image(pix, 0, height - 1);
270 for (
int b = 0; b < boxes_.
size(); ++b) {
272 win->
Text(boxes_[b].left(), height + kTextSize, box_texts_[b].
string());
273 TBOX scaled(boxes_[b]);
274 scaled.scale(256.0 / height);
279 win->
Text(0, height + kTextSize * 2, transcription_.
string());
char window_wait(ScrollView *win)
void Image(struct Pix *image, int x_pos, int y_pos)
void Text(int x, int y, const char *mystring)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
const char * string() const
| Pix * tesseract::ImageData::GetPix |
( |
| ) |
const |
Definition at line 191 of file imagedata.cpp.
192 return GetPixInternal(image_data_);
| const GenericVector<char>& tesseract::ImageData::image_data |
( |
| ) |
const |
|
inline |
| const STRING& tesseract::ImageData::imagefilename |
( |
| ) |
const |
|
inline |
Definition at line 108 of file imagedata.h.
109 return imagefilename_;
| const STRING& tesseract::ImageData::language |
( |
| ) |
const |
|
inline |
| int tesseract::ImageData::MemoryUsed |
( |
| ) |
const |
| int tesseract::ImageData::page_number |
( |
| ) |
const |
|
inline |
| float tesseract::ImageData::PreScale |
( |
int |
target_height, |
|
|
Pix ** |
pix, |
|
|
int * |
scaled_width, |
|
|
int * |
scaled_height, |
|
|
GenericVector< TBOX > * |
boxes |
|
) |
| const |
Definition at line 200 of file imagedata.cpp.
204 int input_height = 0;
207 input_width = pixGetWidth(src_pix);
208 input_height = pixGetHeight(src_pix);
209 if (target_height == 0)
210 target_height = input_height;
211 float im_factor =
static_cast<float>(target_height) / input_height;
212 if (scaled_width != NULL)
214 if (scaled_height != NULL)
215 *scaled_height = target_height;
219 *pix = pixScale(src_pix, im_factor, im_factor);
221 tprintf(
"Scaling pix of size %d, %d by factor %g made null pix!!\n",
222 input_width, input_height, im_factor);
224 if (scaled_width != NULL)
225 *scaled_width = pixGetWidth(*pix);
226 if (scaled_height != NULL)
227 *scaled_height = pixGetHeight(*pix);
229 pixDestroy(&src_pix);
233 for (
int b = 0; b < boxes_.
size(); ++b) {
234 TBOX box = boxes_[b];
235 box.
scale(im_factor);
238 if (boxes->
empty()) {
240 TBOX box(0, 0, im_factor * input_width, target_height);
int IntCastRounded(double x)
void scale(const float f)
| bool tesseract::ImageData::Serialize |
( |
TFile * |
fp | ) |
const |
Definition at line 155 of file imagedata.cpp.
156 if (!imagefilename_.
Serialize(fp))
return false;
157 if (fp->FWrite(&page_number_,
sizeof(page_number_), 1) != 1)
return false;
158 if (!image_data_.
Serialize(fp))
return false;
159 if (!transcription_.
Serialize(fp))
return false;
163 inT8 vertical = vertical_text_;
164 if (fp->FWrite(&vertical,
sizeof(vertical), 1) != 1)
return false;
bool Serialize(FILE *fp) const
bool SerializeClasses(FILE *fp) const
bool Serialize(FILE *fp) const
| void tesseract::ImageData::set_imagefilename |
( |
const STRING & |
name | ) |
|
|
inline |
| void tesseract::ImageData::set_language |
( |
const STRING & |
lang | ) |
|
|
inline |
| void tesseract::ImageData::set_page_number |
( |
int |
num | ) |
|
|
inline |
| void tesseract::ImageData::SetPix |
( |
Pix * |
pix | ) |
|
Definition at line 186 of file imagedata.cpp.
187 SetPixInternal(pix, &image_data_);
| const STRING& tesseract::ImageData::transcription |
( |
| ) |
const |
|
inline |
Definition at line 129 of file imagedata.h.
130 return transcription_;
The documentation for this class was generated from the following files: