MCPcopy Create free account
hub / github.com/creatale/node-dv / Build

Method Build

deps/tesseract/ccstruct/imagedata.cpp:134–162  ·  view source on GitHub ↗

Builds and returns an ImageData from the basic data. Note that imagedata, truth_text, and box_text are all the actual file data, NOT filenames.

Source from the content-addressed store, hash-verified

132// Builds and returns an ImageData from the basic data. Note that imagedata,
133// truth_text, and box_text are all the actual file data, NOT filenames.
134ImageData* ImageData::Build(const char* name, int page_number, const char* lang,
135 const char* imagedata, int imagedatasize,
136 const char* truth_text, const char* box_text) {
137 ImageData* image_data = new ImageData();
138 image_data->imagefilename_ = name;
139 image_data->page_number_ = page_number;
140 image_data->language_ = lang;
141 // Save the imagedata.
142 image_data->image_data_.resize_no_init(imagedatasize);
143 memcpy(&image_data->image_data_[0], imagedata, imagedatasize);
144 if (!image_data->AddBoxes(box_text)) {
145 if (truth_text == NULL || truth_text[0] == '\0') {
146 tprintf("Error: No text corresponding to page %d from image %s!\n",
147 page_number, name);
148 delete image_data;
149 return NULL;
150 }
151 image_data->transcription_ = truth_text;
152 // If we have no boxes, the transcription is in the 0th box_texts_.
153 image_data->box_texts_.push_back(truth_text);
154 // We will create a box for the whole image on PreScale, to save unpacking
155 // the image now.
156 } else if (truth_text != NULL && truth_text[0] != '\0' &&
157 image_data->transcription_ != truth_text) {
158 // Save the truth text as it is present and disagrees with the box text.
159 image_data->transcription_ = truth_text;
160 }
161 return image_data;
162}
163
164// Writes to the given file. Returns false in case of error.
165bool ImageData::Serialize(TFile* fp) const {

Callers

nothing calls this directly

Calls 3

resize_no_initMethod · 0.80
AddBoxesMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected