Skip to content

Commit

Permalink
Added two regtests to the automated set
Browse files Browse the repository at this point in the history
 * boxa1_reg
 * conversion_reg
  • Loading branch information
DanBloomberg committed Jun 11, 2017
1 parent d4a61eb commit a45de89
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 176 deletions.
16 changes: 7 additions & 9 deletions prog/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ AUTO_REG_PROGS = adaptmap_reg affine_reg alphaops_reg \
alphaxform_reg baseline_reg bilateral2_reg \
bilinear_reg binarize_reg blackwhite_reg \
blend1_reg blend2_reg blend3_reg blend4_reg \
ccthin1_reg ccthin2_reg cmapquant_reg \
colorcontent_reg coloring_reg \
colorize_reg colormask_reg \
colormorph_reg colorquant_reg \
colorseg_reg colorspace_reg compare_reg compfilter_reg \
conncomp_reg convolve_reg dewarp_reg distance_reg \
boxa1_reg ccthin1_reg ccthin2_reg cmapquant_reg \
colorcontent_reg coloring_reg colorize_reg \
colormask_reg colormorph_reg colorquant_reg \
colorseg_reg colorspace_reg compare_reg \
compfilter_reg conncomp_reg conversion_reg \
convolve_reg dewarp_reg distance_reg \
dither_reg dna_reg dwamorph1_reg edge_reg enhance_reg \
expand_reg findcorners_reg findpattern_reg \
fpix1_reg fpix2_reg genfonts_reg \
Expand Down Expand Up @@ -58,9 +58,7 @@ endif

MANUAL_REG_PROGS = alltests_reg adaptnorm_reg bilateral1_reg \
binmorph1_reg binmorph2_reg binmorph3_reg \
binmorph4_reg binmorph5_reg \
boxa1_reg boxa2_reg \
colorize_reg conversion_reg \
binmorph4_reg binmorph5_reg boxa2_reg \
dwamorph2_reg equal_reg extrema_reg \
fhmtauto_reg files_reg flipdetect_reg fmorphauto_reg \
grayfill_reg heap_reg locminmax_reg \
Expand Down
2 changes: 2 additions & 0 deletions prog/alltests_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static const char *tests[] = {
"blend2_reg",
"blend3_reg",
"blend4_reg",
"boxa1_reg",
"ccthin1_reg",
"ccthin2_reg",
"cmapquant_reg",
Expand All @@ -73,6 +74,7 @@ static const char *tests[] = {
"compare_reg",
"compfilter_reg",
"conncomp_reg",
"conversion_reg",
"convolve_reg",
"dewarp_reg",
"distance_reg",
Expand Down
63 changes: 33 additions & 30 deletions prog/boxa1_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ BOXA *boxa1, *boxa2, *boxa3;
BOXAA *baa1, *baa2, *baa3;
PIX *pix1, *pixdb;
PIXA *pixa1, *pixa2;
static char mainName[] = "boxa1_reg";
L_REGPARAMS *rp;

if (argc != 1)
return ERROR_INT(" Syntax: boxa1_reg", mainName, 1);
if (regTestSetup(argc, argv, &rp))
return 1;

lept_mkdir("lept/boxa");

Expand All @@ -69,30 +69,35 @@ static char mainName[] = "boxa1_reg";
box = boxCreate(117, 206, 26, 74);
boxaAddBox(boxa1, box, L_INSERT);
pix1 = DisplayBoxa(boxa1);
pixDisplay(pix1, 100, 100);
regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 0 */
pixDisplayWithTitle(pix1, 0, 0, NULL, rp->display);
pixDestroy(&pix1);

boxaCompareRegions(boxa1, boxa1, 100, &same, &diffarea, &diffxor, NULL);
fprintf(stderr, "same = %d, diffarea = %5.3f, diffxor = %5.3f\n",
same, diffarea, diffxor);
regTestCompareValues(rp, 1, same, 0.0); /* 1 */
regTestCompareValues(rp, 0.0, diffarea, 0.0); /* 2 */
regTestCompareValues(rp, 0.0, diffxor, 0.0); /* 3 */

boxa2 = boxaTransform(boxa1, -13, -13, 1.0, 1.0);
boxaCompareRegions(boxa1, boxa2, 10, &same, &diffarea, &diffxor, NULL);
fprintf(stderr, "same = %d, diffarea = %5.3f, diffxor = %5.3f\n",
same, diffarea, diffxor);
regTestCompareValues(rp, 1, same, 0.0); /* 4 */
regTestCompareValues(rp, 0.0, diffarea, 0.0); /* 5 */
regTestCompareValues(rp, 0.0, diffxor, 0.0); /* 6 */
boxaDestroy(&boxa2);

boxa2 = boxaReconcileEvenOddHeight(boxa1, L_ADJUST_TOP_AND_BOT, 6,
L_ADJUST_CHOOSE_MIN, 1.0, 0);
pix1 = DisplayBoxa(boxa2);
pixDisplay(pix1, 100, 500);
regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 7 */
pixDisplayWithTitle(pix1, 200, 0, NULL, rp->display);
pixDestroy(&pix1);

boxaCompareRegions(boxa1, boxa2, 10, &same, &diffarea, &diffxor, &pixdb);
fprintf(stderr, "same = %d, diffarea = %5.3f, diffxor = %5.3f\n",
same, diffarea, diffxor);
pixDisplay(pixdb, 700, 100);

regTestCompareValues(rp, 1, same, 0.0); /* 8 */
regTestCompareValues(rp, 0.053, diffarea, 0.002); /* 9 */
regTestCompareValues(rp, 0.240, diffxor, 0.002); /* 10 */
regTestWritePixAndCheck(rp, pixdb, IFF_PNG); /* 11 */
pixDisplayWithTitle(pixdb, 400, 0, NULL, rp->display);
pixDestroy(&pixdb);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
Expand All @@ -106,8 +111,8 @@ static char mainName[] = "boxa1_reg";
scalefact = (l_float32)width / (l_float32)w;
boxa3 = boxaTransform(boxa2, 0, 0, scalefact, scalefact);
pix1 = boxaDisplayTiled(boxa3, NULL, 1500, 2, 1.0, 0, 3, 2);
pixDisplay(pix1, 0, 100);
pixWrite("/tmp/lept/boxa/pix1.png", pix1, IFF_PNG);
regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 12 */
pixDisplayWithTitle(pix1, 600, 0, NULL, rp->display);
pixDestroy(&pix1);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
Expand All @@ -122,8 +127,8 @@ static char mainName[] = "boxa1_reg";
scalefact = (l_float32)width / (l_float32)w;
boxa3 = boxaTransform(boxa2, 0, 0, scalefact, scalefact);
pix1 = boxaDisplayTiled(boxa3, NULL, 1500, 2, 1.0, 0, 3, 2);
pixDisplay(pix1, 500, 100);
pixWrite("/tmp/lept/boxa/pix2.png", pix1, IFF_PNG);
regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 13 */
pixDisplayWithTitle(pix1, 800, 0, NULL, rp->display);
pixDestroy(&pix1);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
Expand All @@ -138,8 +143,8 @@ static char mainName[] = "boxa1_reg";
scalefact = (l_float32)width / (l_float32)w;
boxa3 = boxaTransform(boxa2, 0, 0, scalefact, scalefact);
pix1 = boxaDisplayTiled(boxa3, NULL, 1500, 2, 1.0, 0, 3, 2);
pixDisplay(pix1, 1000, 100);
pixWrite("/tmp/lept/boxa/pix3.png", pix1, IFF_PNG);
regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 14 */
pixDisplayWithTitle(pix1, 1000, 0, NULL, rp->display);
pixDestroy(&pix1);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
Expand All @@ -154,16 +159,13 @@ static char mainName[] = "boxa1_reg";
boxaWrite("/tmp/lept/boxa/boxa2.ba", boxa2);
filesAreIdentical("/tmp/lept/boxa/boxa1.ba", "/tmp/lept/boxa/boxa2.ba",
&same);
if (same)
fprintf(stderr, "Good: boxes files are identical\n");
else
fprintf(stderr, "Bad: boxes files differ\n");
regTestCompareValues(rp, 1, same, 0.0); /* 15 */
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
lept_free(data1);
lept_free(data2);

/* Test pixaDisplayBoxaa() */
/* ----------- Test pixaDisplayBoxaa() ------------ */
pixa1 = pixaReadBoth("showboxes.pac");
baa1 = boxaaRead("showboxes1.baa");
baa2 = boxaaTranspose(baa1);
Expand All @@ -178,23 +180,24 @@ static char mainName[] = "boxa1_reg";
boxaDestroy(&boxa2);
if (!same) success = FALSE;
}
if (success)
fprintf(stderr, "Good: transpose is reversible\n");
else
fprintf(stderr, "Bad: transpose failed\n");
/* Check that the transpose is reversible */
regTestCompareValues(rp, 1, success, 0.0); /* 16 */
pixa2 = pixaDisplayBoxaa(pixa1, baa2, L_DRAW_RGB, 2);
pix1 = pixaDisplayTiledInRows(pixa2, 32, 1400, 1.0, 0, 10, 0);
pixDisplay(pix1, 0, 600);
regTestWritePixAndCheck(rp, pix1, IFF_PNG); /* 17 */
pixDisplayWithTitle(pix1, 0, 600, NULL, rp->display);
fprintf(stderr, "Writing to: /tmp/lept/boxa/show.pdf\n");
l_pdfSetDateAndVersion(FALSE);
pixaConvertToPdf(pixa2, 75, 1.0, 0, 0, NULL, "/tmp/lept/boxa/show.pdf");
regTestCheckFile(rp, "/tmp/lept/boxa/show.pdf"); /* 18 */
pixDestroy(&pix1);
pixaDestroy(&pixa1);
pixaDestroy(&pixa2);
boxaaDestroy(&baa1);
boxaaDestroy(&baa2);
boxaaDestroy(&baa3);

return 0;
return regTestCleanup(rp);
}


Expand Down
Loading

0 comments on commit a45de89

Please sign in to comment.