#include <imagedata.h>
Definition at line 88 of file imagedata.h.
tesseract::ImageData::ImageData |
( |
| ) |
|
Definition at line 108 of file imagedata.cpp.
108 : page_number_(-1), vertical_text_(
false) {
tesseract::ImageData::ImageData |
( |
bool |
vertical, |
|
|
Pix * |
pix |
|
) |
| |
Definition at line 111 of file imagedata.cpp.
112 : page_number_(0), vertical_text_(vertical) {
tesseract::ImageData::~ImageData |
( |
| ) |
|
Definition at line 285 of file imagedata.cpp.
289 for (
int i = 0; i < box_pages.
size(); ++i) {
290 if (page_number_ >= 0 && box_pages[i] != page_number_)
continue;
291 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 120 of file imagedata.cpp.
124 image_data->imagefilename_ =
name;
126 image_data->language_ =
lang;
128 image_data->image_data_.init_to_size(imagedatasize, 0);
129 memcpy(&image_data->image_data_[0], imagedata, imagedatasize);
130 if (!image_data->AddBoxes(
box_text)) {
131 if (truth_text ==
NULL || truth_text[0] ==
'\0') {
132 tprintf(
"Error: No text corresponding to page %d from image %s!\n",
137 image_data->transcription_ = truth_text;
139 image_data->box_texts_.push_back(truth_text);
142 }
else if (truth_text !=
NULL && truth_text[0] !=
'\0' &&
143 image_data->transcription_ != truth_text) {
145 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 166 of file imagedata.cpp.
167 if (!imagefilename_.
DeSerialize(swap, fp))
return false;
168 if (fp->FRead(&page_number_,
sizeof(page_number_), 1) != 1)
return false;
169 if (swap)
ReverseN(&page_number_,
sizeof(page_number_));
170 if (!image_data_.
DeSerialize(swap, fp))
return false;
171 if (!transcription_.
DeSerialize(swap, fp))
return false;
176 if (fp->FRead(&vertical,
sizeof(vertical), 1) != 1)
return false;
177 vertical_text_ = vertical != 0;
bool DeSerialize(bool swap, FILE *fp)
bool DeSerializeClasses(bool swap, FILE *fp)
bool DeSerialize(bool swap, FILE *fp)
void ReverseN(void *ptr, int num_bytes)
void tesseract::ImageData::Display |
( |
| ) |
const |
Definition at line 248 of file imagedata.cpp.
249 #ifndef GRAPHICS_DISABLED
250 const int kTextSize = 64;
253 if (pix ==
NULL)
return;
254 int width = pixGetWidth(pix);
255 int height = pixGetHeight(pix);
257 2 * (width + 2 * kTextSize),
258 2 * (height + 4 * kTextSize),
259 width + 10, height + 3 * kTextSize,
true);
260 win->
Image(pix, 0, height - 1);
266 for (
int b = 0; b < boxes_.
size(); ++b) {
268 win->
Text(boxes_[b].left(), height + kTextSize, box_texts_[b].
string());
269 TBOX scaled(boxes_[b]);
270 scaled.scale(256.0 / height);
275 win->
Text(0, height + kTextSize * 2, transcription_.
string());
void Text(int x, int y, const char *mystring)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
void Image(struct Pix *image, int x_pos, int y_pos)
char window_wait(ScrollView *win)
const char * string() const
Pix * tesseract::ImageData::GetPix |
( |
| ) |
const |
Definition at line 187 of file imagedata.cpp.
188 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 196 of file imagedata.cpp.
200 int input_height = 0;
203 input_width = pixGetWidth(src_pix);
204 input_height = pixGetHeight(src_pix);
205 if (target_height == 0)
206 target_height = input_height;
207 float im_factor =
static_cast<float>(target_height) / input_height;
208 if (scaled_width !=
NULL)
210 if (scaled_height !=
NULL)
211 *scaled_height = target_height;
215 *pix = pixScale(src_pix, im_factor, im_factor);
217 tprintf(
"Scaling pix of size %d, %d by factor %g made null pix!!\n",
218 input_width, input_height, im_factor);
220 if (scaled_width !=
NULL)
221 *scaled_width = pixGetWidth(*pix);
222 if (scaled_height !=
NULL)
223 *scaled_height = pixGetHeight(*pix);
225 pixDestroy(&src_pix);
229 for (
int b = 0; b < boxes_.
size(); ++b) {
230 TBOX box = boxes_[b];
231 box.
scale(im_factor);
234 if (boxes->
empty()) {
236 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 151 of file imagedata.cpp.
152 if (!imagefilename_.
Serialize(fp))
return false;
153 if (fp->FWrite(&page_number_,
sizeof(page_number_), 1) != 1)
return false;
154 if (!image_data_.
Serialize(fp))
return false;
155 if (!transcription_.
Serialize(fp))
return false;
159 inT8 vertical = vertical_text_;
160 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 182 of file imagedata.cpp.
183 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: