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

Method CopyFromNormalized

deps/tesseract/ccstruct/boxword.cpp:59–90  ·  view source on GitHub ↗

Factory to build a BoxWord from a TWERD using the DENORMs on each blob to switch back to original image coordinates.

Source from the content-addressed store, hash-verified

57// Factory to build a BoxWord from a TWERD using the DENORMs on each blob to
58// switch back to original image coordinates.
59BoxWord* BoxWord::CopyFromNormalized(TWERD* tessword) {
60 BoxWord* boxword = new BoxWord();
61 // Count the blobs.
62 boxword->length_ = tessword->NumBlobs();
63 // Allocate memory.
64 boxword->boxes_.reserve(boxword->length_);
65
66 for (int b = 0; b < boxword->length_; ++b) {
67 TBLOB* tblob = tessword->blobs[b];
68 TBOX blob_box;
69 for (TESSLINE* outline = tblob->outlines; outline != NULL;
70 outline = outline->next) {
71 EDGEPT* edgept = outline->loop;
72 // Iterate over the edges.
73 do {
74 if (!edgept->IsHidden() || !edgept->prev->IsHidden()) {
75 ICOORD pos(edgept->pos.x, edgept->pos.y);
76 TPOINT denormed;
77 tblob->denorm().DenormTransform(NULL, edgept->pos, &denormed);
78 pos.set_x(denormed.x);
79 pos.set_y(denormed.y);
80 TBOX pt_box(pos, pos);
81 blob_box += pt_box;
82 }
83 edgept = edgept->next;
84 } while (edgept != outline->loop);
85 }
86 boxword->boxes_.push_back(blob_box);
87 }
88 boxword->ComputeBoundingBox();
89 return boxword;
90}
91
92// Clean up the bounding boxes from the polygonal approximation by
93// expanding slightly, then clipping to the blobs from the original_word

Callers

nothing calls this directly

Calls 9

NumBlobsMethod · 0.80
IsHiddenMethod · 0.80
DenormTransformMethod · 0.80
denormMethod · 0.80
set_xMethod · 0.80
set_yMethod · 0.80
reserveMethod · 0.45
push_backMethod · 0.45
ComputeBoundingBoxMethod · 0.45

Tested by

no test coverage detected