| 204 | } |
| 205 | |
| 206 | Box *CubeSearchObject::CharBox(int start_pt, int end_pt) { |
| 207 | if (!init_ && !Init()) |
| 208 | return NULL; |
| 209 | if (!IsValidSegmentRange(start_pt, end_pt)) { |
| 210 | fprintf(stderr, "Cube ERROR (CubeSearchObject::CharBox): invalid " |
| 211 | "segment range (%d, %d)\n", start_pt, end_pt); |
| 212 | return NULL; |
| 213 | } |
| 214 | |
| 215 | // create a char samp object from the specified range of segments, |
| 216 | // extract its dimensions into a leptonica box, and delete it |
| 217 | bool left_most; |
| 218 | bool right_most; |
| 219 | CharSamp *samp = CharSamp::FromConComps(segments_, start_pt + 1, |
| 220 | end_pt - start_pt, NULL, |
| 221 | &left_most, &right_most, hgt_); |
| 222 | if (!samp) |
| 223 | return NULL; |
| 224 | if (kUseCroppedChars) { |
| 225 | CharSamp *cropped_samp = samp->Crop(); |
| 226 | delete samp; |
| 227 | if (!cropped_samp) { |
| 228 | return NULL; |
| 229 | } |
| 230 | samp = cropped_samp; |
| 231 | } |
| 232 | Box *box = boxCreate(samp->Left(), samp->Top(), |
| 233 | samp->Width(), samp->Height()); |
| 234 | delete samp; |
| 235 | return box; |
| 236 | } |
| 237 | |
| 238 | // call from Beam Search to return the alt list corresponding to |
| 239 | // recognizing the bitmap between two segmentation pts |