Leptonica  1.83.1
Image processing and image analysis suite
regutils.h File Reference

Go to the source code of this file.

Data Structures

struct  L_RegParams
 

Typedefs

typedef struct L_RegParams L_REGPARAMS
 

Enumerations

enum  { L_REG_GENERATE = 0 , L_REG_COMPARE = 1 , L_REG_DISPLAY = 2 }
 

Detailed Description

  Contains this regression test parameter packaging struct
      struct L_RegParams

  The regression test utility allows you to write regression tests
  that compare results with existing "golden files" and with
  compiled in data.

  Regression tests can be called in three ways.
  For example, for distance_reg:

      Case 1: distance_reg [compare]
          This runs the test against the set of golden files.  It
          appends to 'outfile.txt' either "SUCCESS" or "FAILURE",
          as well as the details of any parts of the test that failed.
          It writes to a temporary file stream (fp).
          Using 'compare' on the command line is optional.

      Case 2: distance_reg generate
          This generates golden files in /tmp for the reg test.

      Case 3: distance_reg display
          This runs the test but makes no comparison of the output
          against the set of golden files.  In addition, this displays
          images and plots that are specified in the test under
          control of the display variable.  Display is enabled only
          for this case.

  Regression tests follow the pattern given below.  Tests are
  automatically numbered sequentially, and it is convenient to
  comment each with a number to keep track (for comparison tests
  and for debugging).  In an actual case, comparisons of pix and
  of files can occur in any order.  We give a specific order here
  for clarity.

      L_REGPARAMS  *rp;  // holds data required by the test functions

      // Setup variables; optionally open stream
      if (regTestSetup(argc, argv, &rp))
          return 1;

      // Test pairs of generated pix for identity.  This compares
      // two pix; no golden file is generated.
      regTestComparePix(rp, pix1, pix2);  // 0

      // Test pairs of generated pix for similarity.  This compares
      // two pix; no golden file is generated.  The last arg determines
      // if stats are to be written to stderr.
      regTestCompareSimilarPix(rp, pix1, pix2, 15, 0.001, 0);  // 1

      // Generation of <newfile*> outputs and testing for identity
      // These files can be anything, of course.
      regTestCheckFile(rp, <newfile0>);  // 2
      regTestCheckFile(rp, <newfile1>);  // 3

      // Test pairs of output golden files for identity.  Here we
      // are comparing golden files 2 and 3.
      regTestCompareFiles(rp, 2, 3);  // 4

      // "Write and check".  This writes a pix using a canonical
      // formulation for the local filename and either:
      //     case 1: generates a golden file
      //     case 2: compares the local file with a golden file
      //     case 3: generates local files and displays
      // Here we write the pix compressed with png and jpeg, respectively;
      // Then check against the golden file.  The internal index
      // is incremented; it is embedded in the local filename and,
      // if generating, in the golden file as well.
      regTestWritePixAndCheck(rp, pix1, IFF_PNG);  // 5
      regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG);  // 6

      // Display if reg test was called in 'display' mode
      pixDisplayWithTitle(pix1, 100, 100, NULL, rp->display);

      // Clean up and output result
      regTestCleanup(rp);

Definition in file regutils.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Running modes for the test

Regtest Mode

Definition at line 133 of file regutils.h.