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

Function SegmentBBox

deps/tesseract/ccstruct/blobs.cpp:636–659  ·  view source on GitHub ↗

Adds any edges from a single segment of outline between pt1 and pt2 to the bbox such that it guarantees to contain anything produced by SegmentCoords.

Source from the content-addressed store, hash-verified

634// the bbox such that it guarantees to contain anything produced by
635// SegmentCoords.
636static void SegmentBBox(const FCOORD& pt1, const FCOORD& pt2, TBOX* bbox) {
637 FCOORD step(pt2);
638 step -= pt1;
639 int x1 = IntCastRounded(MIN(pt1.x(), pt2.x()));
640 int x2 = IntCastRounded(MAX(pt1.x(), pt2.x()));
641 if (x2 > x1) {
642 int y1 = IntCastRounded(pt1.y() + step.y() * (x1 + 0.5 - pt1.x()) /
643 step.x());
644 int y2 = IntCastRounded(pt1.y() + step.y() * (x2 - 0.5 - pt1.x()) /
645 step.x());
646 TBOX point(x1, MIN(y1, y2), x2, MAX(y1, y2));
647 *bbox += point;
648 }
649 int y1 = IntCastRounded(MIN(pt1.y(), pt2.y()));
650 int y2 = IntCastRounded(MAX(pt1.y(), pt2.y()));
651 if (y2 > y1) {
652 int x1 = IntCastRounded(pt1.x() + step.x() * (y1 + 0.5 - pt1.y()) /
653 step.y());
654 int x2 = IntCastRounded(pt1.x() + step.x() * (y2 - 0.5 - pt1.y()) /
655 step.y());
656 TBOX point(MIN(x1, x2), y1, MAX(x1, x2), y2);
657 *bbox += point;
658 }
659}
660
661// Collects edges into the given bounding box, LLSQ accumulator and/or x_coords,
662// y_coords vectors.

Callers 1

CollectEdgesOfRunFunction · 0.85

Calls 3

IntCastRoundedFunction · 0.85
xMethod · 0.45
yMethod · 0.45

Tested by

no test coverage detected