162 #include "allheaders.h" 166 l_float32 minfract, l_int32 *pok);
171 l_int32 maxclass, l_float32 maxscore);
177 static const l_int32 DEFAULT_MIN_SET_SIZE = 1;
179 static const l_float32 DEFAULT_MIN_SET_FRACT = 0.4;
183 static const l_float32 DEFAULT_MIN_SCORE = 0.75;
184 static const l_int32 DEFAULT_MIN_TARGET = 3;
185 static const l_float32 LOWER_SCORE_THRESHOLD = 0.5;
221 PROCNAME(
"recogTrainLabeled");
224 return ERROR_INT(
"recog not defined", procName, 1);
226 return ERROR_INT(
"pixs not defined", procName, 1);
233 L_WARNING(
"failure to get sample '%s' for training\n", procName,
268 l_int32 textinpix, textin, nsets;
270 PIX *pix1, *pix2, *pix3, *pix4;
272 PROCNAME(
"recogProcessLabeled");
275 return ERROR_INT(
"&pix not defined", procName, 1);
278 return ERROR_INT(
"recog not defined", procName, 1);
280 return ERROR_INT(
"pixs not defined", procName, 1);
283 textin = text && (text[0] !=
'\0');
285 if (!textin && !textinpix) {
286 L_ERROR(
"no text: %d\n", procName, recog->
num_samples);
289 textdata = (textin) ? text :
pixs->
text;
296 if (pixGetDepth(pix1) > 1)
312 return ERROR_INT(
"pix4 is empty", procName, 1);
320 L_WARNING(
"found %d sets of horiz separated c.c.; skipping\n",
357 l_int32 npa, charint, index;
361 PROCNAME(
"recogAddSample");
364 return ERROR_INT(
"recog not defined", procName, 1);
365 if (!pix || pixGetDepth(pix) != 1)
366 return ERROR_INT(
"pix not defined or not 1 bpp\n", procName, 1);
368 return ERROR_INT(
"not added: training has been completed", procName, 1);
374 L_ERROR(
"invalid text: %s\n", procName, text);
384 L_ERROR(
"oops: bad index %d > npa %d!!\n", procName, index, npa);
388 L_INFO(
"Adding new class and pixa: index = %d, text = %s\n",
389 procName, index, text);
395 L_INFO(
"Identified text label: %s\n", procName, text);
396 L_INFO(
"Identified: charint = %d, index = %d\n",
397 procName, charint, index);
423 PROCNAME(
"recogModifyTemplate");
426 return (
PIX *)ERROR_PTR(
"recog not defined", procName, NULL);
428 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
439 return (
PIX *)ERROR_PTR(
"pix1 not made", procName, NULL);
442 if (recog->
linew <= 0) {
449 return (
PIX *)ERROR_PTR(
"pix2 not made", procName, NULL);
455 return (
PIX *)ERROR_PTR(
"modified template has no pixels",
489 l_int32 i, nsamp,
size, area, bx, by, badclass;
490 l_float32 x, y, hratio;
493 PIX *pix1, *pix2, *pix3;
497 PROCNAME(
"recogAverageSamples");
500 return ERROR_INT(
"&recog not defined", procName, 1);
501 if ((recog = *precog) == NULL)
502 return ERROR_INT(
"recog not defined", procName, 1);
535 for (i = 0; i <
size; i++) {
539 nsamp = L_MIN(nsamp, 256);
541 L_ERROR(
"no samples in class %d\n", procName, i);
552 L_ERROR(
"no fg pixels in average for uclass %d\n", procName, i);
577 return ERROR_INT(
"at least 1 bad class; destroying recog", procName, 1);
586 L_ERROR(
"ratio of max/min height of average templates = %4.1f;" 587 " destroying recog\n", procName, hratio);
593 for (i = 0; i <
size; i++) {
597 nsamp = L_MIN(nsamp, 256);
603 L_ERROR(
"no fg pixels in average for sclass %d\n", procName, i);
626 return ERROR_INT(
"at least 1 bad class; destroying recog", procName, 1);
670 l_int32 i, n, maxw, maxh, xdiff, ydiff;
671 l_int32 *centtab, *sumtab;
672 l_float32 xc, yc, xave, yave;
673 PIX *pix1, *pix2, *pixsum;
676 PROCNAME(
"pixaAccumulateSamples");
681 return ERROR_INT(
"&pixd not defined", procName, 1);
684 return ERROR_INT(
"pixa not defined", procName, 1);
688 return ERROR_INT(
"pta count differs from pixa count", procName, 1);
691 return ERROR_INT(
"pixa array empty", procName, 1);
700 for (i = 0; i < n; i++) {
711 for (i = 0; i < n; i++) {
716 xave = xave / (l_float32)n;
717 yave = yave / (l_float32)n;
728 for (i = 0; i < n; i++) {
731 xdiff = (l_int32)(xave - xc);
732 ydiff = (l_int32)(yave - yc);
788 l_int32 ok, i, j,
size, nc, ns, area;
789 l_float32 xave, yave;
797 PROCNAME(
"recogTrainingFinished");
800 return ERROR_INT(
"&recog not defined", procName, 1);
801 if ((recog = *precog) == NULL)
802 return ERROR_INT(
"recog not defined", procName, 1);
809 return ERROR_INT(
"bad templates", procName, 1);
843 for (i = 0; i < nc; i++) {
846 for (j = 0; j < ns; j++) {
867 L_ERROR(
"failed: modified template for class %d, sample %d\n",
913 l_int32 i, n, validsets, nt;
917 PROCNAME(
"recogTemplatesAreOK");
920 return ERROR_INT(
"&ok not defined", procName, 1);
923 return ERROR_INT(
"recog not defined", procName, 1);
925 minsize = (minsize < 0) ? DEFAULT_MIN_SET_SIZE : minsize;
926 minfract = (minfract < 0) ? DEFAULT_MIN_SET_FRACT : minfract;
929 for (i = 0, validsets = 0; i < n; i++) {
935 ratio = (l_float32)validsets / (l_float32)recog->
charset_size;
936 *pok = (ratio >= minfract) ? 1 : 0;
973 l_float32 max_ht_ratio,
976 l_int32 i, j, h90, hj, j1, j2, j90, n, nc;
979 PIXA *pixa1, *pixa2, *pixa3, *pixa4, *pixa5;
982 PROCNAME(
"recogFilterPixaBySize");
984 if (pna) *pna = NULL;
986 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
989 return (
PIXA *)ERROR_PTR(
"paa not made", procName, NULL);
994 for (i = 0; i < nc; i++) {
1002 j90 = (l_int32)(0.9 * n);
1005 for (j = 0; j < n; j++) {
1007 ratio = (l_float32)h90 / (l_float32)hj;
1008 if (ratio <= max_ht_ratio)
1015 j1 = (n - maxkeep) / 2;
1016 j2 = j1 + maxkeep - 1;
1047 PROCNAME(
"recogSortPixaByClass");
1050 return (
PIXAA *)ERROR_PTR(
"pixa not defined", procName, NULL);
1053 return (
PIXAA *)ERROR_PTR(
"recog not made", procName, NULL);
1088 PIXA *pixa1, *pixa2;
1091 PROCNAME(
"recogRemoveOutliers1");
1094 return ERROR_INT(
"&recog not defined", procName, 1);
1095 if (*precog == NULL)
1096 return ERROR_INT(
"recog not defined", procName, 1);
1106 return ERROR_INT(
"failure to remove outliers", procName, 1);
1111 return ERROR_INT(
"failure to make recog from pixa sans outliers",
1166 l_int32 i, j, debug, n, area1, area2;
1167 l_float32 x1, y1, x2, y2, minfract, score, rankscore, threshscore;
1170 PIXA *pixa, *pixarem, *pixad;
1174 PROCNAME(
"pixaRemoveOutliers1");
1176 if (ppixsave) *ppixsave = NULL;
1177 if (ppixrem) *ppixrem = NULL;
1179 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1180 minscore = L_MIN(minscore, 1.0);
1181 if (minscore <= 0.0)
1182 minscore = DEFAULT_MIN_SCORE;
1183 mintarget = L_MIN(mintarget, 3);
1185 mintarget = DEFAULT_MIN_TARGET;
1187 minsize = DEFAULT_MIN_SET_SIZE;
1190 debug = (ppixsave || ppixrem) ? 1 : 0;
1193 return (
PIXA *)ERROR_PTR(
"bad pixas; recog not made", procName, NULL);
1196 return (
PIXA *)ERROR_PTR(
"bad templates", procName, NULL);
1203 for (i = 0; i < recog->
setsize; i++) {
1216 for (j = 0; j < n; j++) {
1220 pixCorrelationScoreSimple(pix1, pix2, area1, area2,
1221 x1 - x2, y1 - y2, 5, 5,
1224 if (debug && score == 0.0)
1225 fprintf(stderr,
"Got 0 score for i = %d, j = %d\n", i, j);
1235 minfract = (l_float32)mintarget / (l_float32)n;
1237 threshscore = L_MAX(LOWER_SCORE_THRESHOLD,
1238 L_MIN(minscore, rankscore));
1240 L_INFO(
"minscore = %4.2f, rankscore = %4.2f, threshscore = %4.2f\n",
1241 procName, minscore, rankscore, threshscore);
1246 for (j = 0; j < n; j++) {
1249 if (score >= threshscore && n >= minsize) {
1305 PIXA *pixa1, *pixa2;
1308 PROCNAME(
"recogRemoveOutliers2");
1311 return ERROR_INT(
"&recog not defined", procName, 1);
1312 if (*precog == NULL)
1313 return ERROR_INT(
"recog not defined", procName, 1);
1322 return ERROR_INT(
"failure to remove outliers", procName, 1);
1327 return ERROR_INT(
"failure to make recog from pixa sans outliers",
1369 l_int32 i, j, k, n, area1, area2, maxk, debug;
1370 l_float32 x1, y1, x2, y2, score, maxscore;
1372 PIX *pix1, *pix2, *pix3;
1373 PIXA *pixarem, *pixad;
1376 PROCNAME(
"pixaRemoveOutliers2");
1378 if (ppixsave) *ppixsave = NULL;
1379 if (ppixrem) *ppixrem = NULL;
1381 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1382 minscore = L_MIN(minscore, 1.0);
1383 if (minscore <= 0.0)
1384 minscore = DEFAULT_MIN_SCORE;
1386 minsize = DEFAULT_MIN_SET_SIZE;
1389 debug = (ppixsave || ppixrem) ? 1 : 0;
1392 return (
PIXA *)ERROR_PTR(
"bad pixas; recog not made", procName, NULL);
1395 return (
PIXA *)ERROR_PTR(
"bad templates", procName, NULL);
1402 for (i = 0; i < recog->
setsize; i++) {
1406 for (j = 0; j < n; j++) {
1411 for (k = 0; k < recog->
setsize; k++) {
1415 pixCorrelationScoreSimple(pix1, pix2, area1, area2,
1416 x1 - x2, y1 - y2, 5, 5,
1426 if (maxk == i && maxscore >= minscore && n >= minsize) {
1431 }
else if (ppixrem) {
1495 l_int32 i, n, same, maxd, scaleh, linew;
1497 PIX *pix1, *pix2, *pixdb;
1498 PIXA *pixa1, *pixa2, *pixa3, *pixad;
1500 PROCNAME(
"recogTrainFromBoot");
1503 return (
PIXA *)ERROR_PTR(
"recogboot not defined", procName, NULL);
1505 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1509 return (
PIXA *)ERROR_PTR(
"no pix in pixa", procName, NULL);
1515 for (i = 0; i < n; i++) {
1524 scaleh = recogboot->
scaleh;
1525 linew = recogboot->
linew;
1527 for (i = 0; i < n; i++) {
1545 for (i = 0; i < n; i++) {
1554 rchExtract(recogboot->
rch, NULL, &score, &text, NULL, NULL, NULL, NULL);
1555 if (score >= minscore) {
1600 PROCNAME(
"recogPadDigitTrainingSet");
1603 return ERROR_INT(
"&recog not defined", procName, 1);
1613 return ERROR_INT(
"pixa not made", procName, 1);
1617 L_WARNING(
"templates must be scaled to fixed height; using %d\n",
1654 l_int32 i, nt, min_nopad, nclass, allclasses;
1659 PROCNAME(
"recogIsPaddingNeeded");
1662 return ERROR_INT(
"&sa not defined", procName, 1);
1665 return ERROR_INT(
"recog not defined", procName, 1);
1674 if (allclasses && (minval >= min_nopad)) {
1684 for (i = 0; i < nclass; i++) {
1686 if (nt < min_nopad) {
1713 l_int32 i, nclass, index, ival;
1717 PROCNAME(
"recogAddMissingClassStrings");
1720 return (
SARRAY *)ERROR_PTR(
"recog not defined", procName, NULL);
1732 for (i = 0; i < nclass; i++) {
1734 index = text[0] -
'0';
1739 for (i = 0; i < nclass; i++) {
1772 l_int32 i, j, n, nt;
1774 PIXA *pixa1, *pixa2;
1776 PROCNAME(
"recogAddDigitPadTemplates");
1779 return (
PIXA *)ERROR_PTR(
"recog not defined", procName, NULL);
1781 return (
PIXA *)ERROR_PTR(
"sa not defined", procName, NULL);
1783 return (
PIXA *)ERROR_PTR(
"boot charset not available", procName, NULL);
1794 for (i = 0; i < n; i++) {
1797 for (j = 0; j < nt; j++) {
1799 if (!strcmp(text, str)) {
1823 PROCNAME(
"recogCharsetAvailable");
1834 L_INFO(
"charset type %d not available\n", procName, type);
1838 L_INFO(
"charset type %d is unknown\n", procName, type);
1921 PIX *pix1, *pix2, *pix3;
1922 PIXA *pixa1, *pixa2, *pixa3;
1929 pixDisplay(pix1, 0, 0);
1938 pixa3 = l_bootnum_gen3();
1943 pixDisplay(pix1, 0, 0);
1944 pixDisplay(pix2, 600, 0);
1945 pixDisplay(pix3, 1200, 0);
1987 l_int32 i, val, count;
1991 PROCNAME(
"recogShowContent");
1994 return ERROR_INT(
"stream not defined", procName, 1);
1996 return ERROR_INT(
"recog not defined", procName, 1);
1998 fprintf(fp,
"Debug print of recog contents\n");
1999 fprintf(fp,
" Setsize: %d\n", recog->
setsize);
2000 fprintf(fp,
" Binarization threshold: %d\n", recog->
threshold);
2001 fprintf(fp,
" Maximum matching y-jiggle: %d\n", recog->
maxyshift);
2002 if (recog->
linew <= 0)
2003 fprintf(fp,
" Using image templates for matching\n");
2005 fprintf(fp,
" Using templates with fixed line width for matching\n");
2007 fprintf(fp,
" No width scaling of templates\n");
2009 fprintf(fp,
" Template width scaled to %d\n", recog->
scalew);
2011 fprintf(fp,
" No height scaling of templates\n");
2013 fprintf(fp,
" Template height scaled to %d\n", recog->
scaleh);
2014 fprintf(fp,
" Number of samples in each class:\n");
2016 for (i = 0; i < recog->
setsize; i++) {
2020 fprintf(fp,
" class %d, char %c: %d\n", i, val, count);
2022 fprintf(fp,
" class %d, val %d: %d\n", i, val, count);
2029 snprintf(buf,
sizeof(buf),
"/tmp/lept/recog/templates_u.%d.png", index);
2030 pixWriteDebug(buf, pix, IFF_PNG);
2031 pixDisplay(pix, 0, 200 * index);
2035 snprintf(buf,
sizeof(buf),
2036 "/tmp/lept/recog/templates.%d.png", index);
2037 pixWriteDebug(buf, pix, IFF_PNG);
2038 pixDisplay(pix, 800, 200 * index);
2067 l_int32 i, j, n, np, index;
2069 PIX *pix1, *pix2, *pix3;
2074 PROCNAME(
"recogDebugAverages");
2077 return ERROR_INT(
"&recog not defined", procName, 1);
2078 if ((recog = *precog) == NULL)
2079 return ERROR_INT(
"recog not defined", procName, 1);
2085 return ERROR_INT(
"averaging failed; recog destroyed", procName, 1);
2088 paa1 = recog->
pixaa;
2097 for (i = 0; i < n; i++) {
2101 for (j = 0; j < np; j++) {
2107 fprintf(stderr,
"index = %d, score = %7.3f\n", index, score);
2119 pixWriteDebug(
"/tmp/lept/recog/templ_match.png", recog->
pixdb_ave,
2146 PIX *pix1, *pix2, *pixr;
2147 PIXA *pixat, *pixadb;
2149 PROCNAME(
"recogShowAverageTemplates");
2152 return ERROR_INT(
"recog not defined", procName, 1);
2154 fprintf(stderr,
"min/max width_u = (%d,%d); min/max height_u = (%d,%d)\n",
2157 fprintf(stderr,
"min splitw = %d, max splith = %d\n",
2169 for (i = 0; i <
size; i++) {
2174 pixRasterop(pix2, (l_int32)(x - 0.5), (l_int32)(y - 0.5), 3, 3,
2181 pixDisplay(pix1, 100, 100);
2186 for (i = 0; i <
size; i++) {
2191 pixRasterop(pix2, (l_int32)(x - 0.5), (l_int32)(y - 0.5), 3, 3,
2198 pixDisplay(pix1, 100, 100);
2230 PROCNAME(
"pixDisplayOutliers");
2233 return (
PIX *)ERROR_PTR(
"pixas not defined", procName, NULL);
2235 return (
PIX *)ERROR_PTR(
"nas not defined", procName, NULL);
2238 return (
PIX *)ERROR_PTR(
"pixas and nas sizes differ", procName, NULL);
2241 for (i = 0; i < n; i++) {
2246 snprintf(buf,
sizeof(buf),
"'%s': %5.2f", text, fval);
2283 PIX *pix1, *pix2, *pix3, *pix4, *pix5;
2286 PROCNAME(
"recogDisplayOutlier");
2289 return (
PIX *)ERROR_PTR(
"recog not defined", procName, NULL);
2299 snprintf(buf,
sizeof(buf),
"C=%d, BAC=%d, S=%4.2f", iclass, maxclass,
2337 l_int32 i, n, index, depth;
2341 PIXA *pixa1, *pixa2;
2343 PROCNAME(
"recogShowMatchesInRange");
2346 return ERROR_INT(
"recog not defined", procName, 1);
2348 return ERROR_INT(
"pixa not defined", procName, 1);
2355 for (i = 0; i < n; i++) {
2358 rchExtract(recog->
rch, &index, &score, NULL, NULL, NULL, NULL, NULL);
2368 for (i = 0; i < n; i++) {
2370 if (score < minscore || score > maxscore)
continue;
2374 if (i == 0) depth = pixGetDepth(pix2);
2387 L_INFO(
"no character matches in the range of scores\n", procName);
2435 PIX *pix3, *pix4, *pix5, *pixd;
2438 PROCNAME(
"recogShowMatch");
2441 return (
PIX *)ERROR_PTR(
"recog not defined", procName, NULL);
2443 return (
PIX *)ERROR_PTR(
"pix1 not defined", procName, NULL);
2445 bmf = (recog->
bmf && index >= 0) ? recog->
bmf : NULL;
2446 if (!pix2 && !box && !bmf)
2467 snprintf(buf,
sizeof(buf),
"C=%s, S=%4.3f, I=%d", text, score, index);
l_ok recogRemoveOutliers1(L_RECOG **precog, l_float32 minscore, l_int32 mintarget, l_int32 minsize, PIX **ppixsave, PIX **ppixrem)
recogRemoveOutliers1()
void pixaaDestroy(PIXAA **ppaa)
pixaaDestroy()
struct Pixa * pixadb_boot
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
PIXAA * pixaaCreate(l_int32 n)
pixaaCreate()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
l_ok recogDebugAverages(L_RECOG **precog, l_int32 debug)
recogDebugAverages()
l_ok ptaaGetPt(PTAA *ptaa, l_int32 ipta, l_int32 jpt, l_float32 *px, l_float32 *py)
ptaaGetPt()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
l_ok pixCentroid(PIX *pix, l_int32 *centtab, l_int32 *sumtab, l_float32 *pxave, l_float32 *pyave)
pixCentroid()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
l_int32 * makePixelCentroidTab8(void)
makePixelCentroidTab8()
l_ok recogTrainLabeled(L_RECOG *recog, PIX *pixs, BOX *box, char *text, l_int32 debug)
recogTrainLabeled()
l_ok ptaaAddPt(PTAA *ptaa, l_int32 ipta, l_float32 x, l_float32 y)
ptaaAddPt()
l_ok pixaVerifyDepth(PIXA *pixa, l_int32 *psame, l_int32 *pmaxd)
pixaVerifyDepth()
PIXA * pixaRemoveOutliers2(PIXA *pixas, l_float32 minscore, l_int32 minsize, PIX **ppixsave, PIX **ppixrem)
pixaRemoveOutliers2()
l_ok ptaAddPt(PTA *pta, l_float32 x, l_float32 y)
ptaAddPt()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
PIXA * recogFilterPixaBySize(PIXA *pixas, l_int32 setsize, l_int32 maxkeep, l_float32 max_ht_ratio, NUMA **pna)
recogFilterPixaBySize()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_ok recogAddSample(L_RECOG *recog, PIX *pix, l_int32 debug)
recogAddSample()
l_ok pixaJoin(PIXA *pixad, PIXA *pixas, l_int32 istart, l_int32 iend)
pixaJoin()
L_RECOG * recogCreateFromPixa(PIXA *pixa, l_int32 scalew, l_int32 scaleh, l_int32 linew, l_int32 threshold, l_int32 maxyshift)
recogCreateFromPixa()
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()
PTA * ptaCreate(l_int32 n)
ptaCreate()
PIXA * pixaaGetPixa(PIXAA *paa, l_int32 index, l_int32 accesstype)
pixaaGetPixa()
l_int32 recogGetClassString(L_RECOG *recog, l_int32 index, char **pcharstr)
recogGetClassString()
PIXA * l_bootnum_gen1(void)
l_bootnum_gen1()
l_int32 pixaaGetCount(PIXAA *paa, NUMA **pna)
pixaaGetCount()
PIXA * l_bootnum_gen2(void)
l_bootnum_gen2()
l_ok l_dnaGetIValue(L_DNA *da, l_int32 index, l_int32 *pival)
l_dnaGetIValue()
PIXA * pixaaFlattenToPixa(PIXAA *paa, NUMA **pnaindex, l_int32 copyflag)
pixaaFlattenToPixa()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
l_ok ptaaTruncate(PTAA *ptaa)
ptaaTruncate()
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
l_ok numaCountNonzeroRuns(NUMA *na, l_int32 *pcount)
numaCountNonzeroRuns()
PIX * pixInvert(PIX *pixd, PIX *pixs)
pixInvert()
NUMA * numaCreate(l_int32 n)
numaCreate()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
PIX * pixAddBlackOrWhiteBorder(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_int32 op)
pixAddBlackOrWhiteBorder()
static l_int32 recogCharsetAvailable(l_int32 type)
recogCharsetAvailable()
l_int32 recogIsPaddingNeeded(L_RECOG *recog, SARRAY **psa)
recogIsPaddingNeeded()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
l_ok numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
void numaaDestroy(NUMAA **pnaa)
numaaDestroy()
PIX * pixaaGetPix(PIXAA *paa, l_int32 index, l_int32 ipix, l_int32 accessflag)
pixaaGetPix()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
l_ok pixSetText(PIX *pix, const char *textstring)
pixSetText()
l_ok recogTrainingFinished(L_RECOG **precog, l_int32 modifyflag, l_int32 minsize, l_float32 minfract)
recogTrainingFinished()
l_ok pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
l_ok pixClipToForeground(PIX *pixs, PIX **ppixd, BOX **pbox)
pixClipToForeground()
PIXA * pixaCopy(PIXA *pixa, l_int32 copyflag)
pixaCopy()
NUMA * numaaGetNuma(NUMAA *naa, l_int32 index, l_int32 accessflag)
numaaGetNuma()
PTA * ptaaGetPta(PTAA *ptaa, l_int32 index, l_int32 accessflag)
ptaaGetPta()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
l_ok recogIdentifyPix(L_RECOG *recog, PIX *pixs, PIX **ppixdb)
recogIdentifyPix()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_ok sarrayAddString(SARRAY *sa, const char *string, l_int32 copyflag)
sarrayAddString()
PIXA * pixaSetStrokeWidth(PIXA *pixas, l_int32 width, l_int32 thinfirst, l_int32 connectivity)
pixaSetStrokeWidth()
l_ok pixClearAll(PIX *pix)
pixClearAll()
PTA * ptaClone(PTA *pta)
ptaClone()
l_ok l_convertCharstrToInt(const char *str, l_int32 *pval)
l_convertCharstrToInt()
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
PIX * pixInitAccumulate(l_int32 w, l_int32 h, l_uint32 offset)
pixInitAccumulate()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
l_ok pixAccumulate(PIX *pixd, PIX *pixs, l_int32 op)
pixAccumulate()
void ptaaDestroy(PTAA **pptaa)
ptaaDestroy()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
l_ok ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
l_int32 * makePixelSumTab8(void)
makePixelSumTab8()
PIX * pixSetStrokeWidth(PIX *pixs, l_int32 width, l_int32 thinfirst, l_int32 connectivity)
pixSetStrokeWidth()
l_int32 recogShowAverageTemplates(L_RECOG *recog)
recogShowAverageTemplates()
l_int32 recogGetClassIndex(L_RECOG *recog, l_int32 val, char *text, l_int32 *pindex)
recogGetClassIndex()
l_ok pixaaTruncate(PIXAA *paa)
pixaaTruncate()
static l_int32 recogTemplatesAreOK(L_RECOG *recog, l_int32 minsize, l_float32 minfract, l_int32 *pok)
recogTemplatesAreOK()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
l_ok ptaaInitFull(PTAA *ptaa, PTA *pta)
ptaaInitFull()
static SARRAY * recogAddMissingClassStrings(L_RECOG *recog)
recogAddMissingClassStrings()
l_ok recogProcessLabeled(L_RECOG *recog, PIX *pixs, BOX *box, char *text, PIX **ppix)
recogProcessLabeled()
PIX * pixClone(PIX *pixs)
pixClone()
l_int32 pixaAccumulateSamples(PIXA *pixa, PTA *pta, PIX **ppixd, l_float32 *px, l_float32 *py)
pixaAccumulateSamples()
PIX * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
PIX * pixFinalAccumulate(PIX *pixs, l_uint32 offset, l_int32 depth)
pixFinalAccumulate()
l_ok numaaTruncate(NUMAA *naa)
numaaTruncate()
struct L_Dna * dna_tochar
void pixDestroy(PIX **ppix)
pixDestroy()
PIXA * recogAddDigitPadTemplates(L_RECOG *recog, SARRAY *sa)
recogAddDigitPadTemplates()
PIXA * pixaSort(PIXA *pixas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex, l_int32 copyflag)
pixaSort()
l_ok numaaAddNumber(NUMAA *naa, l_int32 index, l_float32 val)
numaaAddNumber()
l_int32 recogAverageSamples(L_RECOG **precog, l_int32 debug)
recogAverageSamples()
l_ok recogShowContent(FILE *fp, L_RECOG *recog, l_int32 index, l_int32 display)
recogShowContent()
PIX * pixaaDisplayByPixa(PIXAA *paa, l_int32 xspace, l_int32 yspace, l_int32 maxw)
pixaaDisplayByPixa()
void numaDestroy(NUMA **pna)
numaDestroy()
PIX * pixSeedfillBinary(PIX *pixd, PIX *pixs, PIX *pixm, l_int32 connectivity)
pixSeedfillBinary()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * recogShowMatch(L_RECOG *recog, PIX *pix1, PIX *pix2, BOX *box, l_int32 index, l_float32 score)
recogShowMatch()
l_ok numaGetMin(NUMA *na, l_float32 *pminval, l_int32 *piminloc)
numaGetMin()
l_ok numaaGetValue(NUMAA *naa, l_int32 i, l_int32 j, l_float32 *pfval, l_int32 *pival)
numaaGetValue()
PIXA * recogTrainFromBoot(L_RECOG *recogboot, PIXA *pixas, l_float32 minscore, l_int32 threshold, l_int32 debug)
recogTrainFromBoot()
NUMA * pixCountByColumn(PIX *pix, BOX *box)
pixCountByColumn()
l_ok pixaSizeRange(PIXA *pixa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh)
pixaSizeRange()
PIXA * l_bootnum_gen4(l_int32 nsamp)
l_bootnum_gen4()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
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()
char * pixGetText(PIX *pix)
pixGetText()
static PIX * recogDisplayOutlier(L_RECOG *recog, l_int32 iclass, l_int32 jsamp, l_int32 maxclass, l_float32 maxscore)
recogDisplayOutlier()
PIXA * recogMakeBootDigitTemplates(l_int32 nsamp, l_int32 debug)
recogMakeBootDigitTemplates()
L_RECOG * recogMakeBootDigitRecog(l_int32 nsamp, l_int32 scaleh, l_int32 linew, l_int32 maxyshift, l_int32 debug)
recogMakeBootDigitRecog()
PIXA * recogExtractPixa(L_RECOG *recog)
recogExtractPixa()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
l_ok pixRenderBoxArb(PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
pixRenderBoxArb()
l_ok pixaaInitFull(PIXAA *paa, PIXA *pixa)
pixaaInitFull()
l_ok pixaaAddPixa(PIXAA *paa, PIXA *pixa, l_int32 copyflag)
pixaaAddPixa()
PIXAA * recogSortPixaByClass(PIXA *pixa, l_int32 setsize)
recogSortPixaByClass()
L_RECOG * recogCreateFromPixaNoFinish(PIXA *pixa, l_int32 scalew, l_int32 scaleh, l_int32 linew, l_int32 threshold, l_int32 maxyshift)
recogCreateFromPixaNoFinish()
void ptaDestroy(PTA **ppta)
ptaDestroy()
l_ok pixZero(PIX *pix, l_int32 *pempty)
pixZero()
l_ok recogPadDigitTrainingSet(L_RECOG **precog, l_int32 scaleh, l_int32 linew)
recogPadDigitTrainingSet()
l_ok pixaGetPixDimensions(PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixaGetPixDimensions()
PIX * pixCopy(PIX *pixd, PIX *pixs)
pixCopy()
PIX * recogModifyTemplate(L_RECOG *recog, PIX *pixs)
recogModifyTemplate()
void boxDestroy(BOX **pbox)
boxDestroy()
PIXA * pixaRemoveOutliers1(PIXA *pixas, l_float32 minscore, l_int32 mintarget, l_int32 minsize, PIX **ppixsave, PIX **ppixrem)
pixaRemoveOutliers1()
NUMAA * numaaCreateFull(l_int32 nptr, l_int32 n)
numaaCreateFull()
l_ok recogShowMatchesInRange(L_RECOG *recog, PIXA *pixa, l_float32 minscore, l_float32 maxscore, l_int32 display)
recogShowMatchesInRange()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
PIXA * pixaSelectRange(PIXA *pixas, l_int32 first, l_int32 last, l_int32 copyflag)
pixaSelectRange()
PIX * pixaDisplayTiledWithText(PIXA *pixa, l_int32 maxwidth, l_float32 scalefactor, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledWithText()
l_ok boxGetGeometry(BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
static PIX * pixDisplayOutliers(PIXA *pixas, NUMA *nas)
pixDisplayOutliers()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIX * pixAddSingleTextblock(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location, l_int32 *poverflow)
pixAddSingleTextblock()
l_ok recogRemoveOutliers2(L_RECOG **precog, l_float32 minscore, l_int32 minsize, PIX **ppixsave, PIX **ppixrem)
recogRemoveOutliers2()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
l_ok numaGetRankValue(NUMA *na, l_float32 fract, NUMA *nasort, l_int32 usebins, l_float32 *pval)
numaGetRankValue()
PTAA * ptaaCreate(l_int32 n)
ptaaCreate()
void recogDestroy(L_RECOG **precog)
recogDestroy()
PIX * pixAddBorderGeneral(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
pixAddBorderGeneral()
l_ok pixaaAddPix(PIXAA *paa, l_int32 index, PIX *pix, BOX *box, l_int32 copyflag)
pixaaAddPix()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
PIXA * pixaExtendByScaling(PIXA *pixas, NUMA *nasc, l_int32 type, l_int32 include)
pixaExtendByScaling()