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

Function ptaConvertToBox

deps/leptonica/src/boxfunc4.c:904–927  ·  view source on GitHub ↗

! * \brief ptaConvertToBox() * * \param[in] pta * \return box minimum containing all points in the pta, or NULL on error * * * Notes: * (1) For 2 corners, the order of the 2 points is UL, LR. * For 4 corners, the order of points is UL, UR, LL, LR. * */

Source from the content-addressed store, hash-verified

902 * </pre>
903 */
904BOX *
905ptaConvertToBox(PTA *pta)
906{
907l_int32 n, x1, y1, x2, y2, x3, y3, x4, y4, x, y, xmax, ymax;
908
909 PROCNAME("ptaConvertToBox");
910
911 if (!pta)
912 return (BOX *)ERROR_PTR("pta not defined", procName, NULL);
913 n = ptaGetCount(pta);
914 ptaGetIPt(pta, 0, &x1, &y1);
915 ptaGetIPt(pta, 1, &x2, &y2);
916 if (n == 2)
917 return boxCreate(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
918
919 /* 4 corners */
920 ptaGetIPt(pta, 2, &x3, &y3);
921 ptaGetIPt(pta, 3, &x4, &y4);
922 x = L_MIN(x1, x3);
923 y = L_MIN(y1, y2);
924 xmax = L_MAX(x2, x4);
925 ymax = L_MAX(y3, y4);
926 return boxCreate(x, y, xmax - x + 1, ymax - y + 1);
927}
928
929
930/*---------------------------------------------------------------------*

Callers 1

boxaApplyDisparityFunction · 0.85

Calls 3

ptaGetCountFunction · 0.85
ptaGetIPtFunction · 0.85
boxCreateFunction · 0.85

Tested by

no test coverage detected