93 #include <config_auto.h>
97 #include "allheaders.h"
102 #define SPLIT_WITH_DID 1
105 static const l_int32 LeftRightPadding = 32;
108 static const l_float32 MinFillFactor = 0.10;
109 static const l_int32 DefaultMinHeight = 15;
110 static const l_int32 MinOverlap1 = 6;
111 static const l_int32 MinOverlap2 = 6;
112 static const l_int32 MinHeightPass1 = 5;
116 NUMA *namoment1, l_int32 area2,
117 l_int32 ycent2, l_int32 maxyshift,
118 l_int32 *tab8, l_int32 *pdelx,
119 l_int32 *pdely, l_float32 *pscore,
121 static L_RCH *
rchCreate(l_int32 index, l_float32 score,
char *text,
122 l_int32 sample, l_int32 xloc, l_int32 yloc,
127 l_float32 minaf, l_int32 debug);
129 l_float32 minaf, l_int32 *premove,
177 if (pboxa) *pboxa = NULL;
178 if (ppixa) *ppixa = NULL;
179 if (ppixdb) *ppixdb = NULL;
181 return ERROR_INT(
"recog not defined", __func__, 2);
183 return ERROR_INT(
"training not finished", __func__, 2);
185 return ERROR_INT(
"pixs not defined", __func__, 2);
188 if (pixGetDepth(pixs) > 1)
200 L_WARNING(
"nothing found\n", __func__);
257 static l_int32 ind = 0;
259 l_int32 i, xoff, yoff, empty, maxw, bw, ncomp, scaling;
261 BOXA *boxa1, *boxa2, *boxa3, *boxa4, *boxad;
263 PIX *pix, *pix1, *pix2, *pix3;
268 if (pboxa) *pboxa = NULL;
269 if (ppixa) *ppixa = NULL;
270 if (!pboxa || !ppixa)
271 return ERROR_INT(
"&boxa and &pixa not defined", __func__, 1);
273 return ERROR_INT(
"recog not defined", __func__, 1);
275 return ERROR_INT(
"training not finished", __func__, 1);
276 if (!pixs || pixGetDepth(pixs) != 1)
277 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
278 if (minh <= 0) minh = DefaultMinHeight;
296 L_WARNING(
"all components removed\n", __func__);
303 scaling = (recog->
scalew > 0 || recog->
scaleh > 0) ? TRUE : FALSE;
305 for (i = 0; i < ncomp; i++) {
310 if (bw <= maxw || scaling || skipsplit) {
333 L_ERROR(
"boxa3 not found for component %d\n", __func__, i);
345 snprintf(buf,
sizeof(buf),
"/tmp/lept/recog/decode-%d.png", ind++);
346 pixWrite(buf, pix3, IFF_PNG);
356 baa =
boxaSort2d(boxa2, NULL, MinOverlap1, MinOverlap2, MinHeightPass1);
411 l_int32 index, remove, w, h, bx, bw, bxc, bwc, w1, w2, w3;
413 BOX *box, *boxc, *boxtrans, *boxl, *boxr, *boxlt, *boxrt;
415 NUMA *nascoret, *naindext, *nasort;
416 PIX *pixb, *pixc, *pixl, *pixr, *pixdb, *pixd;
417 PIXA *pixar, *pixadb;
422 if (pnascore) *pnascore = NULL;
423 if (pnaindex) *pnaindex = NULL;
424 if (psachar) *psachar = NULL;
426 return ERROR_INT(
"&boxa not defined", __func__, 1);
429 return ERROR_INT(
"recog not defined", __func__, 1);
430 if (!pixs || pixGetDepth(pixs) != 1)
431 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
432 if (pixGetWidth(pixs) < recog->
minwidth_u - 4)
433 return ERROR_INT(
"pixs too narrow", __func__, 1);
435 return ERROR_INT(
"training not finished", __func__, 1);
459 for (iter = 0; iter < 11; iter++) {
463 L_WARNING(
"more than 10 chars; ending search\n", __func__);
474 lept_stderr(
"iter = %d, removed = %d\n", iter, remove);
484 &index, &charstr, &pixdb);
488 &index, &charstr, NULL);
506 lept_stderr(
" w1 = %d, w2 = %d, w3 = %d\n", w1, w2, w3);
507 if (w1 < recog->minwidth_u - 4) {
508 if (debug) L_INFO(
"discarding width %d on left\n", __func__, w1);
517 if (w3 < recog->minwidth_u - 4) {
518 if (debug) L_INFO(
"discarding width %d on right\n", __func__, w3);
520 boxr =
boxCreate(bx + bw - 1, 0, w3 + 1, h);
551 pixDisplay(pixd, 400, 400);
590 l_int32 i, n, w1, h1, w2, area2, ycent2, delx, dely;
591 l_int32 bestdelx, bestdely, bestindex;
592 l_float32 score, bestscore;
595 NUMA *nasum, *namoment;
598 if (pindex) *pindex = 0;
599 if (pcharstr) *pcharstr = NULL;
600 if (ppixdb) *ppixdb = NULL;
601 if (pbox) *pbox = NULL;
602 if (pscore) *pscore = 0.0;
603 if (!pbox || !pscore)
604 return ERROR_INT(
"&box and &score not both defined", __func__, 1);
606 return ERROR_INT(
"recog not defined", __func__, 1);
607 if (!pixs || pixGetDepth(pixs) != 1)
608 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
610 return ERROR_INT(
"training not finished", __func__, 1);
626 bestindex = bestdelx = bestdely = 0;
627 for (i = 0; i < n; i++) {
629 w2 = pixGetWidth(pix2);
640 "Best match template %d: (x,y) = (%d,%d), score = %5.3f\n",
641 i, delx, dely, score);
644 box =
boxCreate(delx - LeftRightPadding, 0, w2, h1);
645 if (score > bestscore) {
647 bestdelx = delx - LeftRightPadding;
654 lept_stderr(
"Component too thin: w1 = %d, w2 = %d\n", w1, w2);
662 if (pindex) *pindex = bestindex;
667 L_INFO(
"Best match: class %d; shifts (%d, %d)\n",
668 __func__, bestindex, bestdelx, bestdely);
735 l_int32 w1, w2, h1, h2, i, j, nx, shifty, delx, dely;
736 l_int32 sum, moment, count;
737 l_int32 *tab, *area1, *arraysum, *arraymoment;
738 l_float32 maxscore, score;
741 PIX *pixt, *pixt1, *pixt2;
743 if (pdelx) *pdelx = 0;
744 if (pdely) *pdely = 0;
745 if (pscore) *pscore = 0.0;
746 if (!pix1 || pixGetDepth(pix1) != 1)
747 return ERROR_INT(
"pix1 not defined or not 1 bpp", __func__, 1);
748 if (!pix2 || pixGetDepth(pix2) != 1)
749 return ERROR_INT(
"pix2 not defined or not 1 bpp", __func__, 1);
750 if (!nasum1 || !namoment1)
751 return ERROR_INT(
"nasum1 and namoment1 not both defined", __func__, 1);
752 if (area2 <= 0 || ycent2 <= 0)
753 return ERROR_INT(
"area2 and ycent2 must be > 0", __func__, 1);
762 L_INFO(
"skipping match with w1 = %d and w2 = %d\n",
778 area1 = (l_int32 *)LEPT_CALLOC(nx,
sizeof(l_int32));
779 ycent1 = (l_float32 *)LEPT_CALLOC(nx,
sizeof(l_int32));
782 for (i = 0, sum = 0, moment = 0; i < w2; i++) {
784 moment += arraymoment[i];
786 for (i = 0; i < nx - 1; i++) {
788 ycent1[i] = (sum == 0) ? ycent2 : (l_float32)moment / (l_float32)sum;
789 sum += arraysum[w2 + i] - arraysum[i];
790 moment += arraymoment[w2 + i] - arraymoment[i];
793 ycent1[nx - 1] = (sum == 0) ? ycent2 : (l_float32)moment / (l_float32)sum;
806 for (i = 0; i < nx; i++) {
807 shifty = (l_int32)(ycent1[i] - ycent2 + 0.5);
808 for (j = -maxyshift; j <= maxyshift; j++) {
813 score = (l_float32)count * (l_float32)count /
814 ((l_float32)area1[i] * (l_float32)area2);
815 if (score > maxscore) {
831 snprintf(buf,
sizeof(buf),
"/tmp/lept/recog/junkbs_%d.png", debugflag);
832 pixWrite(buf, pixt2, IFF_PNG);
838 if (pdelx) *pdelx = delx;
839 if (pdely) *pdely = dely;
840 if (pscore) *pscore = maxscore;
841 if (!tab8) LEPT_FREE(tab);
845 LEPT_FREE(arraymoment);
878 l_int32 i, n, fail, index, depth;
880 PIX *pix1, *pix2, *pix3;
884 if (ppixdb) *ppixdb = NULL;
886 return ERROR_INT(
"recog not defined", __func__, 1);
888 return ERROR_INT(
"pixa not defined", __func__, 1);
897 for (i = 0; i < n; i++) {
907 if ((rch = recog->
rch) == NULL) {
908 L_ERROR(
"rch not found for char %d\n", __func__, i);
913 rchExtract(rch, NULL, NULL, &text, NULL, NULL, NULL, NULL);
917 rchExtract(rch, &index, &score, NULL, NULL, NULL, NULL, NULL);
919 if (i == 0) depth = pixGetDepth(pix3);
969 l_int32 i, j, n, bestindex, bestsample, area1, area2, ret;
970 l_int32 shiftx, shifty, bestdelx, bestdely, bestwidth, maxyshift;
971 l_float32 x1, y1, x2, y2, delx, dely, score, maxscore;
973 PIX *pix0, *pix1, *pix2;
977 if (ppixdb) *ppixdb = NULL;
979 return ERROR_INT(
"recog not defined", __func__, 1);
980 if (!pixs || pixGetDepth(pixs) != 1)
981 return ERROR_INT(
"pixs not defined or not 1 bpp", __func__, 1);
987 return ERROR_INT(
"averaging failed", __func__, 1);
992 return ERROR_INT(
"no fg pixels in pix0", __func__, 1);
998 return ERROR_INT(
"no fg pixels in pix1", __func__, 1);
1004 bestindex = bestsample = bestdelx = bestdely = bestwidth = 0;
1008 for (i = 0; i < recog->
setsize; i++) {
1010 if (area2 == 0)
continue;
1015 for (shifty = -maxyshift; shifty <= maxyshift; shifty++) {
1016 for (shiftx = -maxyshift; shiftx <= maxyshift; shiftx++) {
1017 pixCorrelationScoreSimple(pix1, pix2, area1, area2,
1018 delx + shiftx, dely + shifty,
1019 5, 5, recog->
sumtab, &score);
1020 if (score > maxscore) {
1022 bestdelx = delx + shiftx;
1023 bestdely = dely + shifty;
1031 for (i = 0; i < recog->
setsize; i++) {
1040 for (j = 0; j < n; j++) {
1046 for (shifty = -maxyshift; shifty <= maxyshift; shifty++) {
1047 for (shiftx = -maxyshift; shiftx <= maxyshift; shiftx++) {
1048 pixCorrelationScoreSimple(pix1, pix2, area1, area2,
1049 delx + shiftx, dely + shifty,
1050 5, 5, recog->
sumtab, &score);
1051 if (score > maxscore) {
1054 bestdelx = delx + shiftx;
1055 bestdely = dely + shifty;
1057 bestwidth = pixGetWidth(pix2);
1072 recog->
rch =
rchCreate(bestindex, maxscore, text, bestsample,
1073 bestdelx, bestdely, bestwidth);
1077 L_INFO(
"Best match: str %s; class %d; sh (%d, %d); score %5.3f\n",
1078 __func__, text, bestindex, bestdelx, bestdely, maxscore);
1081 L_INFO(
"Best match: str %s; sample %d in class %d; score %5.3f\n",
1082 __func__, text, bestsample, bestindex, maxscore);
1083 if (maxyshift > 0 && (L_ABS(bestdelx) > 0 || L_ABS(bestdely) > 0)) {
1084 L_INFO(
" Best shift: (%d, %d)\n",
1085 __func__, bestdelx, bestdely);
1114 return ERROR_INT(
"recog not defined", __func__, 1);
1161 if (prcha == NULL) {
1162 L_WARNING(
"&rcha is null!\n", __func__);
1165 if ((rcha = *prcha) == NULL)
1210 rch = (
L_RCH *)LEPT_CALLOC(1,
sizeof(
L_RCH));
1233 L_WARNING(
"&rch is null!\n", __func__);
1236 if ((rch = *prch) == NULL)
1238 LEPT_FREE(rch->
text);
1273 if (pnaindex) *pnaindex = NULL;
1274 if (pnascore) *pnascore = NULL;
1275 if (psatext) *psatext = NULL;
1276 if (pnasample) *pnasample = NULL;
1277 if (pnaxloc) *pnaxloc = NULL;
1278 if (pnayloc) *pnayloc = NULL;
1279 if (pnawidth) *pnawidth = NULL;
1281 return ERROR_INT(
"rcha not defined", __func__, 1);
1317 if (pindex) *pindex = 0;
1318 if (pscore) *pscore = 0.0;
1319 if (ptext) *ptext = NULL;
1320 if (psample) *psample = 0;
1321 if (pxloc) *pxloc = 0;
1322 if (pyloc) *pyloc = 0;
1323 if (pwidth) *pwidth = 0;
1325 return ERROR_INT(
"rch not defined", __func__, 1);
1327 if (pindex) *pindex = rch->
index;
1328 if (pscore) *pscore = rch->
score;
1330 if (psample) *psample = rch->
sample;
1331 if (pxloc) *pxloc = rch->
xloc;
1332 if (pyloc) *pyloc = rch->
yloc;
1333 if (pwidth) *pwidth = rch->
width;
1357 return ERROR_INT(
"rch not defined", __func__, 1);
1359 return ERROR_INT(
"rcha not defined", __func__, 1);
1397 PIX *pix1, *pix2, *pixd;
1400 return (
PIX *)ERROR_PTR(
"recog not defined", __func__, NULL);
1402 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1404 if (pixGetDepth(pixs) != 1)
1415 return (
PIX *)ERROR_PTR(
"no foreground pixels", __func__, NULL);
1440 l_int32 scaling, minsplitw, maxsplith, maxasp;
1442 NUMA *naw, *nah, *na1, *na1c, *na2, *na3, *na4, *na5, *na6, *na7;
1447 return (
PIX *)ERROR_PTR(
"recog not defined", __func__, NULL);
1449 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1453 scaling = (recog->
scalew > 0 || recog->
scaleh > 0) ? TRUE : FALSE;
1454 minsplitw = (scaling) ? 1 : recog->
min_splitw - 3;
1455 maxsplith = (scaling) ? 150 : recog->
max_splith;
1517 l_float32 aspratio, fract;
1520 return ERROR_INT(
"&remove not defined", __func__, 1);
1523 return ERROR_INT(
"recog not defined", __func__, 1);
1525 return ERROR_INT(
"pixs not defined", __func__, 1);
1526 if (minh <= 0) minh = DefaultMinHeight;
1533 if (w < recog->min_splitw) {
1534 if (debug) L_INFO(
"w = %d < %d\n", __func__, w, recog->
min_splitw);
1539 if (debug) L_INFO(
"h = %d < %d\n", __func__, h, minh);
1543 aspratio = (l_float32)w / (l_float32)h;
1545 if (debug) L_INFO(
"w/h = %5.3f too large\n", __func__, aspratio);
1550 if (fract < minaf) {
1551 if (debug) L_INFO(
"area fill fract %5.3f < %5.3f\n",
1552 __func__, fract, minaf);
1601 l_float32 scorethresh,
1602 l_int32 spacethresh,
1607 l_int32 i, n, x1, x2, h_ovl, v_ovl, h_sep, v_sep;
1614 SARRAY *satext, *sa, *saout;
1616 if (pbaa) *pbaa = NULL;
1617 if (pnaa) *pnaa = NULL;
1618 if (!recog || !recog->
rcha)
1619 return (
SARRAY *)ERROR_PTR(
"recog and rcha not both defined",
1622 return (
SARRAY *)ERROR_PTR(
"boxas not defined", __func__, NULL);
1624 if (spacethresh < 0)
1626 rchaExtract(recog->
rcha, NULL, &nascore, &satext, NULL, NULL, NULL, NULL);
1627 if (!nascore || !satext) {
1630 return (
SARRAY *)ERROR_PTR(
"nascore and satext not both returned",
1639 for (i = 0; i < n; i++) {
1642 if (prebox == NULL) {
1643 if (score < scorethresh) {
1662 if (x1 < x2 && h_sep <= spacethresh &&
1663 v_sep < 0 && score >= scorethresh) {
1675 if (score >= scorethresh) {
1698 L_INFO(
"saout has no identified text\n", __func__);
1739 char *textstr, *scorestr;
1740 l_int32 i, j, n, nchar, len;
1746 PIX *pix1, *pix2, *pix3, *pix4;
1749 if (ppixdb) *ppixdb = NULL;
1751 return (
PIXA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1753 return (
PIXA *)ERROR_PTR(
"sa not defined", __func__, NULL);
1755 return (
PIXA *)ERROR_PTR(
"baa not defined", __func__, NULL);
1757 return (
PIXA *)ERROR_PTR(
"naa not defined", __func__, NULL);
1763 for (i = 0; i < n; i++) {
1771 len = strlen(textstr) + 1;
1777 for (j = 0; j < nchar; j++) {
1779 snprintf(buf,
sizeof(buf),
"%d", (l_int32)(100 * score));
1783 snprintf(buf,
sizeof(buf),
"%s: %s\n", textstr, scorestr);
1793 LEPT_FREE(scorestr);
1827 lept_stderr(
"================================================\n");
1829 for (i = 0; i < n; i++)
1832 for (i = 0; i < n; i++)
1835 for (i = 0; i < n; i++)
1838 for (i = 0; i < n; i++)
1841 for (i = 0; i < n; i++)
1843 lept_stderr(
"\n------------------------------------------------");
1845 for (i = 0; i < n; i++)
1847 lept_stderr(
"\n================================================\n");
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()
l_ok boxGetGeometry(const BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
void boxDestroy(BOX **pbox)
boxDestroy()
BOXAA * boxaaCreate(l_int32 n)
boxaaCreate()
l_ok boxaaAddBoxa(BOXAA *baa, BOXA *ba, l_int32 copyflag)
boxaaAddBoxa()
l_ok boxaAddBox(BOXA *boxa, BOX *box, l_int32 copyflag)
boxaAddBox()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_int32 boxaGetCount(const BOXA *boxa)
boxaGetCount()
BOXA * boxaaGetBoxa(BOXAA *baa, l_int32 index, l_int32 accessflag)
boxaaGetBoxa()
BOX * boxaGetBox(BOXA *boxa, l_int32 index, l_int32 accessflag)
boxaGetBox()
void boxaaDestroy(BOXAA **pbaa)
boxaaDestroy()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
BOXA * boxaCreate(l_int32 n)
boxaCreate()
l_ok boxaJoin(BOXA *boxad, BOXA *boxas, l_int32 istart, l_int32 iend)
boxaJoin()
l_ok boxOverlapDistance(BOX *box1, BOX *box2, l_int32 *ph_ovl, l_int32 *pv_ovl)
boxOverlapDistance()
BOXA * boxaHandleOverlaps(BOXA *boxas, l_int32 op, l_int32 range, l_float32 min_overlap, l_float32 max_ratio, NUMA **pnamap)
boxaHandleOverlaps()
BOX * boxAdjustSides(BOX *boxd, BOX *boxs, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot)
boxAdjustSides()
BOX * boxTransform(BOX *box, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
boxTransform()
BOXA * boxaTransform(BOXA *boxas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
boxaTransform()
BOXA * boxaaFlattenToBoxa(BOXAA *baa, NUMA **pnaindex, l_int32 copyflag)
boxaaFlattenToBoxa()
BOXA * boxaSort(BOXA *boxas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex)
boxaSort()
BOXAA * boxaSort2d(BOXA *boxas, NUMAA **pnaad, l_int32 delta1, l_int32 delta2, l_int32 minh1)
boxaSort2d()
l_ok boxaGetExtent(BOXA *boxa, l_int32 *pw, l_int32 *ph, BOX **pbox)
boxaGetExtent()
BOXA * pixConnComp(PIX *pixs, PIXA **ppixa, l_int32 connectivity)
pixConnComp()
l_ok fpixSetPixel(FPIX *fpix, l_int32 x, l_int32 y, l_float32 val)
fpixSetPixel()
void fpixDestroy(FPIX **pfpix)
fpixDestroy()
FPIX * fpixCreate(l_int32 width, l_int32 height)
fpixCreate()
PIX * fpixDisplayMaxDynamicRange(FPIX *fpixs)
fpixDisplayMaxDynamicRange()
l_ok pixRenderBoxArb(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxArb()
l_ok pixRenderBoxaArb(PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxaArb()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
l_ok pixCentroid(PIX *pix, l_int32 *centtab, l_int32 *sumtab, l_float32 *pxave, l_float32 *pyave)
pixCentroid()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
NUMA * numaCreate(l_int32 n)
numaCreate()
NUMA * numaaGetNuma(NUMAA *naa, l_int32 index, l_int32 accessflag)
numaaGetNuma()
NUMA * numaClone(NUMA *na)
numaClone()
void numaDestroy(NUMA **pna)
numaDestroy()
NUMAA * numaaCreate(l_int32 n)
numaaCreate()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok numaaAddNuma(NUMAA *naa, NUMA *na, l_int32 copyflag)
numaaAddNuma()
NUMA * numaCopy(NUMA *na)
numaCopy()
l_int32 * numaGetIArray(NUMA *na)
numaGetIArray()
void numaaDestroy(NUMAA **pnaa)
numaaDestroy()
NUMA * numaMakeThresholdIndicator(NUMA *nas, l_float32 thresh, l_int32 type)
numaMakeThresholdIndicator()
NUMA * numaLogicalOp(NUMA *nad, NUMA *na1, NUMA *na2, l_int32 op)
numaLogicalOp()
NUMA * numaSortByIndex(NUMA *nas, NUMA *naindex)
numaSortByIndex()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
l_ok pixSetText(PIX *pix, const char *textstring)
pixSetText()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
l_ok pixClearAll(PIX *pix)
pixClearAll()
PIX * pixAddBorderGeneral(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
pixAddBorderGeneral()
PIX * pixAddBlackOrWhiteBorder(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_int32 op)
pixAddBlackOrWhiteBorder()
l_ok pixZero(PIX *pix, l_int32 *pempty)
pixZero()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
NUMA * pixCountPixelsByColumn(PIX *pix)
pixCountPixelsByColumn()
NUMA * pixGetMomentByColumn(PIX *pix, l_int32 order)
pixGetMomentByColumn()
l_int32 * makePixelSumTab8(void)
makePixelSumTab8()
NUMA * pixaFindAreaFraction(PIXA *pixa)
pixaFindAreaFraction()
l_ok pixFindAreaFraction(PIX *pixs, l_int32 *tab, l_float32 *pfract)
pixFindAreaFraction()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
l_ok pixTestClipToForeground(PIX *pixs, l_int32 *pcanclip)
pixTestClipToForeground()
NUMA * pixaFindWidthHeightRatio(PIXA *pixa)
pixaFindWidthHeightRatio()
l_ok pixClipToForeground(PIX *pixs, PIX **ppixd, BOX **pbox)
pixClipToForeground()
l_ok pixaFindDimensions(PIXA *pixa, NUMA **pnaw, NUMA **pnah)
pixaFindDimensions()
PIXA * pixClipRectangles(PIX *pixs, BOXA *boxa)
pixClipRectangles()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_ok pixaRemovePixAndSave(PIXA *pixa, l_int32 index, PIX **ppix, BOX **pbox)
pixaRemovePixAndSave()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
l_ok pixaAddBox(PIXA *pixa, BOX *box, l_int32 copyflag)
pixaAddBox()
PIX * pixaaGetPix(PIXAA *paa, l_int32 index, l_int32 ipix, l_int32 accessflag)
pixaaGetPix()
PIXA * pixaaGetPixa(PIXAA *paa, l_int32 index, l_int32 accesstype)
pixaaGetPixa()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
l_ok pixRemoveWithIndicator(PIX *pixs, PIXA *pixa, NUMA *na)
pixRemoveWithIndicator()
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
PIX * pixaDisplayTiledInColumns(PIXA *pixas, l_int32 nx, l_float32 scalefactor, l_int32 spacing, l_int32 border)
pixaDisplayTiledInColumns()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
PTA * ptaaGetPta(PTAA *ptaa, l_int32 index, l_int32 accessflag)
ptaaGetPta()
l_ok ptaGetIPt(PTA *pta, l_int32 index, l_int32 *px, l_int32 *py)
ptaGetIPt()
l_ok ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
void ptaDestroy(PTA **ppta)
ptaDestroy()
@ L_USE_AVERAGE_TEMPLATES
l_int32 recogGetClassString(L_RECOG *recog, l_int32 index, char **pcharstr)
recogGetClassString()
BOXA * recogDecode(L_RECOG *recog, PIX *pixs, l_int32 nlevels, PIX **ppixdb)
recogDecode()
PIXA * showExtractNumbers(PIX *pixs, SARRAY *sa, BOXAA *baa, NUMAA *naa, PIX **ppixdb)
showExtractNumbers()
SARRAY * recogExtractNumbers(L_RECOG *recog, BOXA *boxas, l_float32 scorethresh, l_int32 spacethresh, BOXAA **pbaa, NUMAA **pnaa)
recogExtractNumbers()
l_ok recogCorrelationBestChar(L_RECOG *recog, PIX *pixs, BOX **pbox, l_float32 *pscore, l_int32 *pindex, char **pcharstr, PIX **ppixdb)
recogCorrelationBestChar()
void rchaDestroy(L_RCHA **prcha)
rchaDestroy()
l_ok rchExtract(L_RCH *rch, l_int32 *pindex, l_float32 *pscore, char **ptext, l_int32 *psample, l_int32 *pxloc, l_int32 *pyloc, l_int32 *pwidth)
rchExtract()
static l_int32 recogSplittingFilter(L_RECOG *recog, PIX *pixs, l_int32 min, l_float32 minaf, l_int32 *premove, l_int32 debug)
recogSplittingFilter()
static void l_showIndicatorSplitValues(NUMA *na1, NUMA *na2, NUMA *na3, NUMA *na4, NUMA *na5, NUMA *na6)
l_showIndicatorSplitValues()
static l_int32 transferRchToRcha(L_RCH *rch, L_RCHA *rcha)
transferRchToRcha()
static l_int32 pixCorrelationBestShift(PIX *pix1, PIX *pix2, NUMA *nasum1, NUMA *namoment1, l_int32 area2, l_int32 ycent2, l_int32 maxyshift, l_int32 *tab8, l_int32 *pdelx, l_int32 *pdely, l_float32 *pscore, l_int32 debugflag)
pixCorrelationBestShift()
void rchDestroy(L_RCH **prch)
rchDestroy()
l_ok recogIdentifyPixa(L_RECOG *recog, PIXA *pixa, PIX **ppixdb)
recogIdentifyPixa()
l_ok recogIdentifyPix(L_RECOG *recog, PIX *pixs, PIX **ppixdb)
recogIdentifyPix()
static L_RCHA * rchaCreate()
rchaCreate()
l_ok recogCorrelationBestRow(L_RECOG *recog, PIX *pixs, BOXA **pboxa, NUMA **pnascore, NUMA **pnaindex, SARRAY **psachar, l_int32 debug)
recogCorrelationBestRow()
l_ok recogSkipIdentify(L_RECOG *recog)
recogSkipIdentify()
l_ok recogIdentifyMultiple(L_RECOG *recog, PIX *pixs, l_int32 minh, l_int32 skipsplit, BOXA **pboxa, PIXA **ppixa, PIX **ppixdb, l_int32 debugsplit)
recogIdentifyMultiple()
static PIX * recogPreSplittingFilter(L_RECOG *recog, PIX *pixs, l_int32 minh, l_float32 minaf, l_int32 debug)
recogPreSplittingFilter()
l_ok recogSplitIntoCharacters(L_RECOG *recog, PIX *pixs, l_int32 minh, l_int32 skipsplit, BOXA **pboxa, PIXA **ppixa, l_int32 debug)
recogSplitIntoCharacters()
l_ok rchaExtract(L_RCHA *rcha, NUMA **pnaindex, NUMA **pnascore, SARRAY **psatext, NUMA **pnasample, NUMA **pnaxloc, NUMA **pnayloc, NUMA **pnawidth)
rchaExtract()
static L_RCH * rchCreate(l_int32 index, l_float32 score, char *text, l_int32 sample, l_int32 xloc, l_int32 yloc, l_int32 width)
rchCreate()
PIX * recogProcessToIdentify(L_RECOG *recog, PIX *pixs, l_int32 pad)
recogProcessToIdentify()
PIX * recogShowMatch(L_RECOG *recog, PIX *pix1, PIX *pix2, BOX *box, l_int32 index, l_float32 score)
recogShowMatch()
PIX * recogModifyTemplate(L_RECOG *recog, PIX *pixs)
recogModifyTemplate()
l_int32 recogAverageSamples(L_RECOG *recog, l_int32 debug)
recogAverageSamples()
l_ok pixRasterop(PIX *pixd, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, PIX *pixs, l_int32 sx, l_int32 sy)
pixRasterop()
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
SARRAY * sarrayClone(SARRAY *sa)
sarrayClone()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
l_ok sarrayAddString(SARRAY *sa, const char *string, l_int32 copyflag)
sarrayAddString()
char * sarrayToString(SARRAY *sa, l_int32 addnlflag)
sarrayToString()
SARRAY * sarraySortByIndex(SARRAY *sain, NUMA *naindex)
sarraySortByIndex()
PIX * pixExpandReplicate(PIX *pixs, l_int32 factor)
pixExpandReplicate()
struct Pixa * pixadb_split
PIX * pixAddTextlines(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location)
pixAddTextlines()
void lept_stderr(const char *fmt,...)
lept_stderr()
char * stringNew(const char *src)
stringNew()
l_ok stringJoinIP(char **psrc1, const char *src2)
stringJoinIP()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()