Leptonica 1.54
Файл src/regutils.c
#include <string.h>
#include "allheaders.h"

Функции

static char * getRootNameFromArgv0 (const char *argv0)
l_int32 regTestSetup (l_int32 argc, char **argv, L_REGPARAMS **prp)
l_int32 regTestCleanup (L_REGPARAMS *rp)
l_int32 regTestComparePix (L_REGPARAMS *rp, PIX *pix1, PIX *pix2)
l_int32 regTestCompareSimilarPix (L_REGPARAMS *rp, PIX *pix1, PIX *pix2, l_int32 mindiff, l_float32 maxfract, l_int32 printstats)
l_int32 regTestCheckFile (L_REGPARAMS *rp, const char *localname)
l_int32 regTestCompareFiles (L_REGPARAMS *rp, l_int32 index1, l_int32 index2)
l_int32 regTestWritePixAndCheck (L_REGPARAMS *rp, PIX *pix, l_int32 format)

Переменные

l_int32 NumImageFileFormatExtensions
const char * ImageFileFormatExtensions []

Функции

static char * getRootNameFromArgv0 ( const char *  argv0) [static]

getRootNameFromArgv0()

Input: argv0 Return: root name (without the '_reg'), or null on error

Notes: (1) For example, from psioseg_reg, we want to extract just 'psioseg' as the root. (2) In unix with autotools, the executable is not X, but ./.libs/lt-X. So in addition to stripping out the last 4 characters of the tail, we have to check for the '-' and strip out the "lt-" prefix if we find it.

l_int32 regTestCheckFile ( L_REGPARAMS rp,
const char *  localname 
)

regTestCheckFile()

Input: rp (regtest parameters) localname (name of output file from reg test) Return: 0 if OK, 1 on error (a failure in comparison is not an error)

Notes: (1) This function does one of three things, depending on the mode: * "generate": makes a "golden" file as a copy . * "compare": compares contents with the golden file * "display": makes the file but does no comparison (2) The canonical format of the golden filenames is: /tmp/golden/<root of="" main="" name>="">_golden.<index>.<ext of="" localname>=""> e.g., /tmp/golden/maze_golden.0.png It is important to add an extension to the local name, because the extension is added to the name of the golden file.

l_int32 regTestCleanup ( L_REGPARAMS rp)

regTestCleanup()

Input: rp (regression test parameters) Return: 0 if OK, 1 on error

Notes: (1) This copies anything written to the temporary file to the output file /tmp/reg_results.txt.

l_int32 regTestCompareFiles ( L_REGPARAMS rp,
l_int32  index1,
l_int32  index2 
)

regTestCompareFiles()

Input: rp (regtest parameters) index1 (of one output file from reg test) index2 (of another output file from reg test) Return: 0 if OK, 1 on error (a failure in comparison is not an error)

Notes: (1) This only does something in "compare" mode. (2) The canonical format of the golden filenames is: /tmp/golden/<root of="" main="" name>="">_golden.<index>.<ext of="" localname>=""> e.g., /tmp/golden/maze_golden.0.png

l_int32 regTestComparePix ( L_REGPARAMS rp,
PIX pix1,
PIX pix2 
)

regTestComparePix()

Input: rp (regtest parameters) pix1, pix2 (to be tested for equality) Return: 0 if OK, 1 on error (a failure in comparison is not an error)

Notes: (1) This function compares two pix for equality. If not in compare mode, on failure it writes to stderr.

l_int32 regTestCompareSimilarPix ( L_REGPARAMS rp,
PIX pix1,
PIX pix2,
l_int32  mindiff,
l_float32  maxfract,
l_int32  printstats 
)

regTestCompareSimilarPix()

Input: rp (regtest parameters) pix1, pix2 (to be tested for equality) mindiff (minimum pixel difference to be counted; > 0) maxfract (maximum fraction of pixels allowed to have diff greater than or equal to mindiff) printstats (use 1 to print normalized histogram to stderr) Return: 0 if OK, 1 on error (a failure in similarity comparison is not an error)

Notes: (1) This function compares two pix for equality. If not in compare mode, on failure it writes to stderr. (2) To identify two images as 'similar', select to be the upper bound for what you expect. Typical values might be = 15 and = 0.01. (3) Normally, use = 0. In debugging mode, to see the relation between and the minimum value of for success, set this to 1.

l_int32 regTestSetup ( l_int32  argc,
char **  argv,
L_REGPARAMS **  prp 
)

regTestSetup()

Input: argc (from invocation; can be either 1 or 2) argv (to regtest: [1] is one of these: "generate", "compare", "display") &rp (<return> all regression params) Return: 0 if OK, 1 on error

Notes: (1) Call this function with the args to the reg test. There are three cases: Case 1: The second arg is "generate". This will cause generation of new golden files for the reg test. The results of the reg test are not recorded, and the display field is set to FALSE, preventing image display. Case 2: The second arg is "compare". This is the mode in which you run a regression test (or a set of them), looking for failures and logging the results to a file. The output, which includes logging of all reg test failures plus a SUCCESS or FAILURE summary for each test, is appended to the file "/tmp/reg_results.txt. For this case, as in Case 1, the display field in rp is set to FALSE. Case 3: There is either only arg, or the second arg is "display". The test will run and files will be written. Comparisons with golden files will not be carried out, so the only notion of success or failure is with tests that do not involve golden files. The display field in rp is TRUE, and this is used by pixDisplayWithTitle(). (2) See regutils.h for examples of usage.

l_int32 regTestWritePixAndCheck ( L_REGPARAMS rp,
PIX pix,
l_int32  format 
)

regTestWritePixAndCheck()

Input: rp (regtest parameters) pix (to be written) format (of output pix) Return: 0 if OK, 1 on error (a failure in comparison is not an error)

Notes: (1) This function makes it easy to write the pix in a numbered sequence of files, and either to: (a) write the golden file ("generate" arg to regression test) (b) make a local file and "compare" with the golden file (c) make a local file and "display" the results (3) The canonical format of the local filename is: /tmp/<root of="" main="" name>="">.<count>.<format extension="" string>=""> e.g., for scale_reg, /tmp/scale.0.png


Переменные