+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+LEPT_DLL extern HBITMAP pixGetWindowsHBITMAP( PIX *pixs );
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* LEPTONICA_LEPTWIN_H */
+#endif /* _WIN32 */
diff --git a/third_party/leptonica/windows/include/leptonica/list.h b/third_party/leptonica/windows/include/leptonica/list.h
new file mode 100644
index 00000000..d207e79f
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/list.h
@@ -0,0 +1,90 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+
+#ifndef LEPTONICA_LIST_H
+#define LEPTONICA_LIST_H
+
+/*!
+ * \file list.h
+ *
+ *
+ * Cell for double-linked lists
+ *
+ * This allows composition of a list of cells with
+ * prev, next and data pointers. Generic data
+ * structures hang on the list cell data pointers.
+ *
+ * The list is not circular because that would add much
+ * complexity in traversing the list under general
+ * conditions where list cells can be added and removed.
+ * The only disadvantage of not having the head point to
+ * the last cell is that the list must be traversed to
+ * find its tail. However, this traversal is fast, and
+ * the listRemoveFromTail() function updates the tail
+ * so there is no searching overhead with repeated use.
+ *
+ * The list macros are used to run through a list, and their
+ * use is encouraged. They are invoked, e.g., as
+ *
+ * DLLIST *head, *elem;
+ * ...
+ * L_BEGIN_LIST_FORWARD(head, elem)
+ * data >
+ * L_END_LIST
+ *
+ */
+
+struct DoubleLinkedList
+{
+ struct DoubleLinkedList *prev;
+ struct DoubleLinkedList *next;
+ void *data;
+};
+typedef struct DoubleLinkedList DLLIST;
+
+
+ /*! Simple list traverse macro - forward */
+#define L_BEGIN_LIST_FORWARD(head, element) \
+ { \
+ DLLIST *_leptvar_nextelem_; \
+ for ((element) = (head); (element); (element) = _leptvar_nextelem_) { \
+ _leptvar_nextelem_ = (element)->next;
+
+
+ /*! Simple list traverse macro - reverse */
+#define L_BEGIN_LIST_REVERSE(tail, element) \
+ { \
+ DLLIST *_leptvar_prevelem_; \
+ for ((element) = (tail); (element); (element) = _leptvar_prevelem_) { \
+ _leptvar_prevelem_ = (element)->prev;
+
+
+ /*! Simple list traverse macro - end of a list traverse */
+#define L_END_LIST }}
+
+
+#endif /* LEPTONICA_LIST_H */
diff --git a/third_party/leptonica/windows/include/leptonica/morph.h b/third_party/leptonica/windows/include/leptonica/morph.h
new file mode 100644
index 00000000..34f665fc
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/morph.h
@@ -0,0 +1,225 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_MORPH_H
+#define LEPTONICA_MORPH_H
+
+/*!
+ * \file morph.h
+ *
+ *
+ * Contains the following structs:
+ * struct Sel
+ * struct Sela
+ * struct Kernel
+ *
+ * Contains definitions for:
+ * morphological b.c. flags
+ * structuring element types
+ * runlength flags for granulometry
+ * direction flags for grayscale morphology
+ * morphological operation flags
+ * standard border size
+ * grayscale intensity scaling flags
+ * morphological tophat flags
+ * arithmetic and logical operator flags
+ * grayscale morphology selection flags
+ * distance function b.c. flags
+ * image comparison flags
+ *
+ */
+
+/*-------------------------------------------------------------------------*
+ * Sel and Sel array *
+ *-------------------------------------------------------------------------*/
+#define SEL_VERSION_NUMBER 1
+
+/*! Selection */
+struct Sel
+{
+ l_int32 sy; /*!< sel height */
+ l_int32 sx; /*!< sel width */
+ l_int32 cy; /*!< y location of sel origin */
+ l_int32 cx; /*!< x location of sel origin */
+ l_int32 **data; /*!< {0,1,2}; data[i][j] in [row][col] order */
+ char *name; /*!< used to find sel by name */
+};
+typedef struct Sel SEL;
+
+/*! Array of Sel */
+struct Sela
+{
+ l_int32 n; /*!< number of sel actually stored */
+ l_int32 nalloc; /*!< size of allocated ptr array */
+ struct Sel **sel; /*!< sel ptr array */
+};
+typedef struct Sela SELA;
+
+
+/*-------------------------------------------------------------------------*
+ * Kernel *
+ *-------------------------------------------------------------------------*/
+#define KERNEL_VERSION_NUMBER 2
+
+/*! Kernel */
+struct L_Kernel
+{
+ l_int32 sy; /*!< kernel height */
+ l_int32 sx; /*!< kernel width */
+ l_int32 cy; /*!< y location of kernel origin */
+ l_int32 cx; /*!< x location of kernel origin */
+ l_float32 **data; /*!< data[i][j] in [row][col] order */
+};
+typedef struct L_Kernel L_KERNEL;
+
+
+/*-------------------------------------------------------------------------*
+ * Morphological boundary condition flags *
+ * *
+ * Two types of boundary condition for erosion. *
+ * The global variable MORPH_BC takes on one of these two values. *
+ * See notes in morph.c for usage. *
+ *-------------------------------------------------------------------------*/
+/*! Morph Boundary */
+enum {
+ SYMMETRIC_MORPH_BC = 0,
+ ASYMMETRIC_MORPH_BC = 1
+};
+
+/*-------------------------------------------------------------------------*
+ * Structuring element vals *
+ *-------------------------------------------------------------------------*/
+/*! SEL Vals */
+enum {
+ SEL_DONT_CARE = 0,
+ SEL_HIT = 1,
+ SEL_MISS = 2
+};
+
+/*-------------------------------------------------------------------------*
+ * Runlength flags for granulometry *
+ *-------------------------------------------------------------------------*/
+/*! Runlength Polarity */
+enum {
+ L_RUN_OFF = 0,
+ L_RUN_ON = 1
+};
+
+/*-------------------------------------------------------------------------*
+ * Direction flags for grayscale morphology, granulometry, *
+ * composable Sels, convolution, etc. *
+ *-------------------------------------------------------------------------*/
+/*! Direction Flags */
+enum {
+ L_HORIZ = 1,
+ L_VERT = 2,
+ L_BOTH_DIRECTIONS = 3
+};
+
+/*-------------------------------------------------------------------------*
+ * Morphological operation flags *
+ *-------------------------------------------------------------------------*/
+/*! Morph Operator */
+enum {
+ L_MORPH_DILATE = 1,
+ L_MORPH_ERODE = 2,
+ L_MORPH_OPEN = 3,
+ L_MORPH_CLOSE = 4,
+ L_MORPH_HMT = 5
+};
+
+/*-------------------------------------------------------------------------*
+ * Grayscale intensity scaling flags *
+ *-------------------------------------------------------------------------*/
+/*! Pixel Value Scaling */
+enum {
+ L_LINEAR_SCALE = 1,
+ L_LOG_SCALE = 2
+};
+
+/*-------------------------------------------------------------------------*
+ * Morphological tophat flags *
+ *-------------------------------------------------------------------------*/
+/*! Morph Tophat */
+enum {
+ L_TOPHAT_WHITE = 0,
+ L_TOPHAT_BLACK = 1
+};
+
+/*-------------------------------------------------------------------------*
+ * Arithmetic and logical operator flags *
+ * (use on grayscale images and Numas) *
+ *-------------------------------------------------------------------------*/
+/*! ArithLogical Ops */
+enum {
+ L_ARITH_ADD = 1,
+ L_ARITH_SUBTRACT = 2,
+ L_ARITH_MULTIPLY = 3, /* on numas only */
+ L_ARITH_DIVIDE = 4, /* on numas only */
+ L_UNION = 5, /* on numas only */
+ L_INTERSECTION = 6, /* on numas only */
+ L_SUBTRACTION = 7, /* on numas only */
+ L_EXCLUSIVE_OR = 8 /* on numas only */
+};
+
+/*-------------------------------------------------------------------------*
+ * Min/max selection flags *
+ *-------------------------------------------------------------------------*/
+/*! MinMax Selection */
+enum {
+ L_CHOOSE_MIN = 1, /* useful in a downscaling "erosion" */
+ L_CHOOSE_MAX = 2, /* useful in a downscaling "dilation" */
+ L_CHOOSE_MAXDIFF = 3, /* useful in a downscaling contrast */
+ L_CHOOSE_MIN_BOOST = 4, /* use a modification of the min value */
+ L_CHOOSE_MAX_BOOST = 5 /* use a modification of the max value */
+};
+
+/*-------------------------------------------------------------------------*
+ * Exterior value b.c. for distance function flags *
+ *-------------------------------------------------------------------------*/
+/*! Exterior Value */
+enum {
+ L_BOUNDARY_BG = 1, /* assume bg outside image */
+ L_BOUNDARY_FG = 2 /* assume fg outside image */
+};
+
+/*-------------------------------------------------------------------------*
+ * Image comparison flags *
+ *-------------------------------------------------------------------------*/
+/*! Image Comparison */
+enum {
+ L_COMPARE_XOR = 1,
+ L_COMPARE_SUBTRACT = 2,
+ L_COMPARE_ABS_DIFF = 3
+};
+
+/*-------------------------------------------------------------------------*
+ * Standard size of border added around images for special processing *
+ *-------------------------------------------------------------------------*/
+static const l_int32 ADDED_BORDER = 32; /*!< pixels, not bits */
+
+
+#endif /* LEPTONICA_MORPH_H */
diff --git a/third_party/leptonica/windows/include/leptonica/pix.h b/third_party/leptonica/windows/include/leptonica/pix.h
new file mode 100644
index 00000000..a2fe8e1a
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/pix.h
@@ -0,0 +1,1094 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_PIX_H
+#define LEPTONICA_PIX_H
+
+/*!
+ * \file pix.h
+ *
+ *
+ * Valid image types in leptonica:
+ * Pix: 1 bpp, with and without colormap
+ * Pix: 2 bpp, with and without colormap
+ * Pix: 4 bpp, with and without colormap
+ * Pix: 8 bpp, with and without colormap
+ * Pix: 16 bpp (1 spp)
+ * Pix: 32 bpp (rgb, 3 spp)
+ * Pix: 32 bpp (rgba, 4 spp)
+ * FPix: 32 bpp float
+ * DPix: 64 bpp double
+ * Notes:
+ * (1) The only valid Pix image type with alpha is rgba.
+ * In particular, the alpha component is not used in
+ * cmapped images.
+ * (2) PixComp can hold any Pix with IFF_PNG encoding.
+ *
+ * Contents:
+ *
+ * (1) This file has typedefs for most of the image-related structs
+ * used in leptonica:
+ * struct Pix
+ * struct PixColormap
+ * struct RGBA_Quad
+ * struct Pixa
+ * struct Pixaa
+ * struct Box
+ * struct Boxa
+ * struct Boxaa
+ * struct Pta
+ * struct Ptaa
+ * struct Pixacc
+ * struct PixTiling
+ * struct FPix
+ * struct FPixa
+ * struct DPix
+ * struct PixComp
+ * struct PixaComp
+ *
+ * (2) This file has definitions for:
+ * Colors for RGBA
+ * Colors for drawing boxes
+ * Perceptual color weights
+ * Colormap conversion flags
+ * Rasterop bit flags
+ * Structure access flags (for insert, copy, clone, copy-clone)
+ * Sorting flags (by type and direction)
+ * Blending flags
+ * Graphics pixel setting flags
+ * Size and location filter flags
+ * Color component selection flags
+ * Color content flags
+ * 16-bit conversion flags
+ * Rotation and shear flags
+ * Affine transform order flags
+ * Grayscale filling flags
+ * Flags for setting to white or black
+ * Flags for getting white or black pixel value
+ * Flags for 8 and 16 bit pixel sums
+ * Dithering flags
+ * Distance flags
+ * Value flags
+ * Statistical measures
+ * Set selection flags
+ * Text orientation flags
+ * Edge orientation flags
+ * Line orientation flags
+ * Image orientation flags
+ * Scan direction flags
+ * Box size adjustment flags
+ * Flags for modifying box boundaries using a second box
+ * Handling overlapping bounding boxes in boxa
+ * Selecting or making a box from two (intersecting) boxes
+ * Flags for replacing invalid boxes
+ * Flags for box corners and center
+ * Horizontal warp
+ * Pixel selection for resampling
+ * Thinning flags
+ * Runlength flags
+ * Edge filter flags
+ * Subpixel color component ordering in LCD display
+ * HSV histogram flags
+ * Region flags (inclusion, exclusion)
+ * Flags for adding text to a pix
+ * Flags for plotting on a pix
+ * Flags for making simple masks
+ * Flags for selecting display program
+ * Flags in the 'special' pix field for non-default operations
+ * Handling negative values in conversion to unsigned int
+ * Relative to zero flags
+ * Flags for adding or removing trailing slash from string
+ *
+ * (3) This file has typedefs for the pix allocator and deallocator functions
+ * alloc_fn()
+ * dealloc_fn().
+ *
+ * -------------------------------------------------------------------
+ * Notes on the pixels in the raster image. This information can also
+ * be found in pix_internal.h.
+ *
+ * (1) The image data is stored in a single contiguous
+ * array of l_uint32, into which the pixels are packed.
+ * By "packed" we mean that there are no unused bits
+ * between pixels, except for end-of-line padding to
+ * satisfy item (2) below.
+ *
+ * (2) Every image raster line begins on a 32-bit word
+ * boundary within this array.
+ *
+ * (3) Pix image data is stored in 32-bit units, with the
+ * pixels ordered from left to right in the image being
+ * stored in order from the MSB to LSB within the word,
+ * for both big-endian and little-endian machines.
+ * This is the natural ordering for big-endian machines,
+ * as successive bytes are stored and fetched progressively
+ * to the right. However, for little-endians, when storing
+ * we re-order the bytes from this byte stream order, and
+ * reshuffle again for byte access on 32-bit entities.
+ * So if the bytes come in sequence from left to right, we
+ * store them on little-endians in byte order:
+ * 3 2 1 0 7 6 5 4 ...
+ * This MSB to LSB ordering allows left and right shift
+ * operations on 32 bit words to move the pixels properly.
+ *
+ * (4) We use 32 bit pixels for both RGB and RGBA color images.
+ * The A (alpha) byte is ignored in most leptonica functions
+ * operating on color images. Within each 4 byte pixel, the
+ * color samples are ordered from MSB to LSB, as follows:
+ *
+ * | MSB | 2nd MSB | 3rd MSB | LSB |
+ * red green blue alpha
+ * 0 1 2 3 (big-endian)
+ * 3 2 1 0 (little-endian)
+ *
+ * Because we use MSB to LSB ordering within the 32-bit word,
+ * the individual 8-bit samples can be accessed with
+ * GET_DATA_BYTE and SET_DATA_BYTE macros, using the
+ * (implicitly big-ending) ordering
+ * red: byte 0 (MSB)
+ * green: byte 1 (2nd MSB)
+ * blue: byte 2 (3rd MSB)
+ * alpha: byte 3 (LSB)
+ *
+ * The specific color assignment is made in this file,
+ * through the definitions of COLOR_RED, etc. Then the R, G
+ * B and A sample values can be retrieved using
+ * redval = GET_DATA_BYTE(&pixel, COLOR_RED);
+ * greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN);
+ * blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE);
+ * alphaval = GET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL);
+ * and they can be set with
+ * SET_DATA_BYTE(&pixel, COLOR_RED, redval);
+ * SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval);
+ * SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval);
+ * SET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL, alphaval);
+ *
+ * More efficiently, these components can be extracted directly
+ * by shifting and masking, explicitly using the values in
+ * L_RED_SHIFT, etc.:
+ * (pixel32 >> L_RED_SHIFT) & 0xff; (red)
+ * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
+ * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
+ * (pixel32 >> L_ALPHA_SHIFT) & 0xff; (alpha)
+ * The functions extractRGBValues() and extractRGBAValues() are
+ * provided to do this. Likewise, the pixels can be set
+ * directly by shifting, using composeRGBPixel() and
+ * composeRGBAPixel().
+ *
+ * All these operations work properly on both big- and little-endians.
+ *
+ * (5) A reference count is held within each pix, giving the
+ * number of ptrs to the pix. When a pixClone() call
+ * is made, the ref count is increased by 1, and
+ * when a pixDestroy() call is made, the reference count
+ * of the pix is decremented. The pix is only destroyed
+ * when the reference count goes to zero.
+ *
+ * (6) Version numbers are used in the serialization of image-related
+ * data structures. They are placed in the files, and rarely
+ * (if ever) change.
+ *
+ * (7) The serialization dependencies are as follows:
+ * pixaa : pixa : boxa
+ * boxaa : boxa
+ * So, for example, pixaa and boxaa can be changed without
+ * forcing a change in pixa or boxa. However, if pixa is
+ * changed, it forces a change in pixaa, and if boxa is
+ * changed, if forces a change in the other three.
+ *
+ */
+
+/*-------------------------------------------------------------------------*
+ * Basic Pix *
+ *-------------------------------------------------------------------------*/
+/*! Basic Pix */
+typedef struct Pix PIX;
+
+/*! Colormap of a Pix */
+typedef struct PixColormap PIXCMAP;
+
+ /*! Colormap table entry (after the BMP version).
+ * Note that the BMP format stores the colormap table exactly
+ * as it appears here, with color samples being stored sequentially,
+ * in the order (b,g,r,a). */
+typedef struct RGBA_Quad RGBA_QUAD;
+
+/*-------------------------------------------------------------------------*
+ * Pix arrays *
+ *-------------------------------------------------------------------------*/
+/*! Array of pix */
+typedef struct Pixa PIXA;
+
+/*! Array of arrays of pix */
+typedef struct Pixaa PIXAA;
+
+/*-------------------------------------------------------------------------*
+ * Basic rectangle and rectangle arrays *
+ *-------------------------------------------------------------------------*/
+/*! Basic rectangle */
+typedef struct Box BOX;
+
+/*! Array of Box */
+typedef struct Boxa BOXA;
+
+/*! Array of Boxa */
+typedef struct Boxaa BOXAA;
+
+/*-------------------------------------------------------------------------*
+ * Arrays of points *
+ *-------------------------------------------------------------------------*/
+/*! Array of points */
+typedef struct Pta PTA;
+
+/*! Array of Pta */
+typedef struct Ptaa PTAA;
+
+/*-------------------------------------------------------------------------*
+ * Pix accumulator container *
+ *-------------------------------------------------------------------------*/
+/*! Pix accumulator container */
+typedef struct Pixacc PIXACC;
+
+/*-------------------------------------------------------------------------*
+ * Pix tiling *
+ *-------------------------------------------------------------------------*/
+/*! Pix tiling */
+typedef struct PixTiling PIXTILING;
+
+/*-------------------------------------------------------------------------*
+ * FPix: pix with float array *
+ *-------------------------------------------------------------------------*/
+/*! Pix with float array */
+typedef struct FPix FPIX;
+
+/*! Array of FPix */
+typedef struct FPixa FPIXA;
+
+/*-------------------------------------------------------------------------*
+ * DPix: pix with double array *
+ *-------------------------------------------------------------------------*/
+/*! Pix with double array */
+typedef struct DPix DPIX;
+
+/*-------------------------------------------------------------------------*
+ * Compressed pix and arrays *
+ *-------------------------------------------------------------------------*/
+/*! Compressed Pix */
+typedef struct PixComp PIXC;
+
+/*! Array of compressed pix */
+typedef struct PixaComp PIXAC;
+
+
+
+/*-------------------------------------------------------------------------*
+ * Colors for 32 RGBA *
+ *-------------------------------------------------------------------------*/
+/*
+ * Notes:
+ * (1) These are the byte indices for colors in 32 bpp images.
+ * They are used through the GET/SET_DATA_BYTE accessors.
+ * The 4th byte, typically known as the "alpha channel" and used
+ * for blending, is used to a small extent in leptonica.
+ * (2) Do not change these values! If you redefine them, functions
+ * that have the shifts hardcoded for efficiency and conciseness
+ * (instead of using the constants below) will break. These
+ * functions are labelled with "***" next to their names at
+ * the top of the files in which they are defined.
+ * (3) The shifts to extract the red, green, blue and alpha components
+ * from a 32 bit pixel are defined here.
+ *
+ */
+
+/*! RGBA Color */
+enum {
+ COLOR_RED = 0, /*!< red color index in RGBA_QUAD */
+ COLOR_GREEN = 1, /*!< green color index in RGBA_QUAD */
+ COLOR_BLUE = 2, /*!< blue color index in RGBA_QUAD */
+ L_ALPHA_CHANNEL = 3 /*!< alpha value index in RGBA_QUAD */
+};
+
+static const l_int32 L_RED_SHIFT =
+ 8 * (sizeof(l_uint32) - 1 - COLOR_RED); /* 24 */
+static const l_int32 L_GREEN_SHIFT =
+ 8 * (sizeof(l_uint32) - 1 - COLOR_GREEN); /* 16 */
+static const l_int32 L_BLUE_SHIFT =
+ 8 * (sizeof(l_uint32) - 1 - COLOR_BLUE); /* 8 */
+static const l_int32 L_ALPHA_SHIFT =
+ 8 * (sizeof(l_uint32) - 1 - L_ALPHA_CHANNEL); /* 0 */
+
+
+/*-------------------------------------------------------------------------*
+ * Colors for drawing boxes *
+ *-------------------------------------------------------------------------*/
+/*! Box Color */
+enum {
+ L_DRAW_RED = 0, /*!< draw in red */
+ L_DRAW_GREEN = 1, /*!< draw in green */
+ L_DRAW_BLUE = 2, /*!< draw in blue */
+ L_DRAW_SPECIFIED = 3, /*!< draw specified color */
+ L_DRAW_RGB = 4, /*!< draw as sequence of r,g,b */
+ L_DRAW_RANDOM = 5 /*!< draw randomly chosen colors */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Perceptual color weights *
+ *-------------------------------------------------------------------------*/
+/*
+ * Notes:
+ * (1) These perceptual weighting factors are ad-hoc, but they do
+ * add up to 1. Unlike, for example, the weighting factors for
+ * converting RGB to luminance, or more specifically to Y in the
+ * YUV colorspace. Those numbers come from the
+ * International Telecommunications Union, via ITU-R.
+ *
+ */
+static const l_float32 L_RED_WEIGHT = 0.3f; /*!< Percept. weight for red */
+static const l_float32 L_GREEN_WEIGHT = 0.5f; /*!< Percept. weight for green */
+static const l_float32 L_BLUE_WEIGHT = 0.2f; /*!< Percept. weight for blue */
+
+
+/*-------------------------------------------------------------------------*
+ * Flags for colormap conversion *
+ *-------------------------------------------------------------------------*/
+/*! Cmap Conversion */
+enum {
+ REMOVE_CMAP_TO_BINARY = 0, /*!< remove colormap for conv to 1 bpp */
+ REMOVE_CMAP_TO_GRAYSCALE = 1, /*!< remove colormap for conv to 8 bpp */
+ REMOVE_CMAP_TO_FULL_COLOR = 2, /*!< remove colormap for conv to 32 bpp */
+ REMOVE_CMAP_WITH_ALPHA = 3, /*!< remove colormap and alpha */
+ REMOVE_CMAP_BASED_ON_SRC = 4 /*!< remove depending on src format */
+};
+
+
+/*------------------------------------------------------------------------*
+ *!
+ *
+ * The following operation bit flags have been modified from Sun's
+ * original "bitblt" (bit block transfer) operations (from the 1980s).
+ *
+ * The 'op' in 'rasterop' is represented by an integer
+ * composed with Boolean functions using the set of five integers
+ * given below. The integers, and the op codes resulting from
+ * boolean expressions on them, need only be in the range from 0 to 15.
+ * The function is applied on a per-pixel basis.
+ *
+ * Examples: the op code representing ORing the src and dest
+ * is computed using the bit OR, as PIX_SRC | PIX_DST; the op
+ * code representing XORing src and dest is found from
+ * PIX_SRC ^ PIX_DST; the op code representing ANDing src and dest
+ * is found from PIX_SRC & PIX_DST. Note that
+ * PIX_NOT(PIX_CLR) = PIX_SET, and v.v., as they must be.
+ *
+ * We use the following set of definitions:
+ *
+ * #define PIX_SRC 0xc
+ * #define PIX_DST 0xa
+ * #define PIX_NOT(op) (op) ^ 0xf
+ * #define PIX_CLR 0x0
+ * #define PIX_SET 0xf
+ *
+ * [These definitions differ from Sun's, in that Sun left-shifted
+ * each value by 1 pixel, and used the least significant bit as a
+ * flag for the "pseudo-operation" of clipping. We don't need
+ * this bit, because it is both efficient and safe ALWAYS to clip
+ * the rectangles to the src and dest images, which is what we do.
+ * See the notes in rop.h on the general choice of these bit flags.]
+ *
+ * Here are the 16 unique op flags:
+ *
+ * PIX_CLR 0000 0x0
+ * PIX_SET 1111 0xf
+ * PIX_SRC 1100 0xc
+ * PIX_DST 1010 0xa
+ * PIX_NOT(PIX_SRC) 0011 0x3
+ * PIX_NOT(PIX_DST) 0101 0x5
+ * PIX_SRC | PIX_DST 1110 0xe
+ * PIX_SRC & PIX_DST 1000 0x8
+ * PIX_SRC ^ PIX_DST 0110 0x6
+ * PIX_NOT(PIX_SRC) | PIX_DST 1011 0xb
+ * PIX_NOT(PIX_SRC) & PIX_DST 0010 0x2
+ * PIX_SRC | PIX_NOT(PIX_DST) 1101 0xd
+ * PIX_SRC & PIX_NOT(PIX_DST) 0100 0x4
+ * PIX_NOT(PIX_SRC | PIX_DST) 0001 0x1
+ * PIX_NOT(PIX_SRC & PIX_DST) 0111 0x7
+ * PIX_NOT(PIX_SRC ^ PIX_DST) 1001 0x9
+ *
+ *
+ *-------------------------------------------------------------------------*/
+
+#define PIX_SRC (0xc) /*!< use source pixels */
+#define PIX_DST (0xa) /*!< use destination pixels */
+#define PIX_NOT(op) ((op) ^ 0x0f) /*!< invert operation %op */
+#define PIX_CLR (0x0) /*!< clear pixels */
+#define PIX_SET (0xf) /*!< set pixels */
+
+#define PIX_PAINT (PIX_SRC | PIX_DST) /*!< paint = src | dst */
+#define PIX_MASK (PIX_SRC & PIX_DST) /*!< mask = src & dst */
+#define PIX_SUBTRACT (PIX_DST & PIX_NOT(PIX_SRC)) /*!< subtract = */
+ /*!< src & !dst */
+#define PIX_XOR (PIX_SRC ^ PIX_DST) /*!< xor = src ^ dst */
+
+
+/*-------------------------------------------------------------------------*
+ * Access and storage flags *
+ *-------------------------------------------------------------------------*/
+/*
+ *
+ * For Pix, Box, Pta and Numa, there are 3 standard methods for handling
+ * the retrieval or insertion of a struct:
+ * (1) direct insertion (Don't do this if there is another handle
+ * somewhere to this same struct!)
+ * (2) copy (Always safe, sets up a refcount of 1 on the new object.
+ * Can be undesirable if very large, such as an image or
+ * an array of images.)
+ * (3) clone (Makes another handle to the same struct, and bumps the
+ * refcount up by 1. OK to use except in two situations:
+ * (a) You change data through one of the handles but don't
+ * want those changes to be seen by the other handle.
+ * (b) The application is multi-threaded. Because the clone
+ * operation is not atomic (e.g., locked with a mutex),
+ * it is possible to end up with an incorrect ref count,
+ * causing either a memory leak or a crash.
+ *
+ * For Pixa and Boxa, which are structs that hold an array of clonable
+ * structs, there is an additional method:
+ * (4) copy-clone (Makes a new higher-level struct with a refcount
+ * of 1, but clones all the structs in the array.)
+ *
+ * Unlike the other structs, when retrieving a string from an Sarray,
+ * you are allowed to get a handle without a copy or clone (i.e., the
+ * string is not owned by the handle). You must not either free the string
+ * or insert it in some other struct that would own it. Specifically,
+ * for an Sarray, the copyflag for retrieval is either:
+ * L_COPY or L_NOCOPY
+ * and for insertion, the copyflag is either:
+ * L_COPY or one of {L_INSERT , L_NOCOPY} (the latter are equivalent
+ * for insertion))
+ * Typical patterns are:
+ * (1) Reference a string in an Sarray with L_NOCOPY and insert a copy
+ * of it in another Sarray with L_COPY.
+ * (2) Copy a string from an Sarray with L_COPY and insert it in
+ * another Sarray with L_INSERT (or L_NOCOPY).
+ * In both cases, a copy is made and both Sarrays own their instance
+ * of that string.
+ *
+ */
+/*! Object Access */
+enum {
+ L_NOCOPY = 0, /*!< do not copy the object; do not delete the ptr */
+ L_INSERT = L_NOCOPY, /*!< stuff it in; do not copy or clone */
+ L_COPY = 1, /*!< make/use a copy of the object */
+ L_CLONE = 2, /*!< make/use clone (ref count) of the object */
+ L_COPY_CLONE = 3 /*!< make a new array object (e.g., pixa) and fill */
+ /*!< the array with clones (e.g., pix) */
+};
+
+/*----------------------------------------------------------------------------*
+ * Sort flags *
+ *----------------------------------------------------------------------------*/
+/*! Sort Mode */
+enum {
+ L_SHELL_SORT = 1, /*!< use shell sort */
+ L_BIN_SORT = 2 /*!< use bin sort */
+};
+
+/*! Sort Order */
+enum {
+ L_SORT_INCREASING = 1, /*!< sort in increasing order */
+ L_SORT_DECREASING = 2 /*!< sort in decreasing order */
+};
+
+/*! Sort Type */
+enum {
+ L_SORT_BY_X = 1, /*!< sort box or c.c. by left edge location */
+ L_SORT_BY_Y = 2, /*!< sort box or c.c. by top edge location */
+ L_SORT_BY_RIGHT = 3, /*!< sort box or c.c. by right edge location */
+ L_SORT_BY_BOT = 4, /*!< sort box or c.c. by bot edge location */
+ L_SORT_BY_WIDTH = 5, /*!< sort box or c.c. by width */
+ L_SORT_BY_HEIGHT = 6, /*!< sort box or c.c. by height */
+ L_SORT_BY_MIN_DIMENSION = 7, /*!< sort box or c.c. by min dimension */
+ L_SORT_BY_MAX_DIMENSION = 8, /*!< sort box or c.c. by max dimension */
+ L_SORT_BY_PERIMETER = 9, /*!< sort box or c.c. by perimeter */
+ L_SORT_BY_AREA = 10, /*!< sort box or c.c. by area */
+ L_SORT_BY_ASPECT_RATIO = 11 /*!< sort box or c.c. by width/height ratio */
+};
+
+/*---------------------------------------------------------------------------*
+ * Blend flags *
+ *---------------------------------------------------------------------------*/
+/*! Blend Types */
+enum {
+ L_BLEND_WITH_INVERSE = 1, /*!< add some of src inverse to itself */
+ L_BLEND_TO_WHITE = 2, /*!< shift src colors towards white */
+ L_BLEND_TO_BLACK = 3, /*!< shift src colors towards black */
+ L_BLEND_GRAY = 4, /*!< blend src directly with blender */
+ L_BLEND_GRAY_WITH_INVERSE = 5 /*!< add amount of src inverse to itself, */
+ /*!< based on blender pix value */
+};
+
+/*! Paint Selection */
+enum {
+ L_PAINT_LIGHT = 1, /*!< colorize non-black pixels */
+ L_PAINT_DARK = 2 /*!< colorize non-white pixels */
+};
+
+/*-------------------------------------------------------------------------*
+ * Graphics pixel setting *
+ *-------------------------------------------------------------------------*/
+/*! Pixel Setting */
+enum {
+ L_SET_PIXELS = 1, /*!< set all bits in each pixel to 1 */
+ L_CLEAR_PIXELS = 2, /*!< set all bits in each pixel to 0 */
+ L_FLIP_PIXELS = 3 /*!< flip all bits in each pixel */
+};
+
+/*-------------------------------------------------------------------------*
+ * Size and location filter flags *
+ *-------------------------------------------------------------------------*/
+/*! Size Comparison */
+enum {
+ L_SELECT_IF_LT = 1, /*!< save if value is less than threshold */
+ L_SELECT_IF_GT = 2, /*!< save if value is more than threshold */
+ L_SELECT_IF_LTE = 3, /*!< save if value is <= to the threshold */
+ L_SELECT_IF_GTE = 4 /*!< save if value is >= to the threshold */
+};
+
+/*! Size Selection */
+enum {
+ L_SELECT_BY_WIDTH = 1, /*!< select by width; 1 bpp */
+ L_SELECT_BY_HEIGHT = 2, /*!< select by height; 1 bpp */
+ L_SELECT_BY_MAX_DIMENSION = 3, /*!< select by max of width and */
+ /*!< height; 1 bpp */
+ L_SELECT_BY_AREA = 4, /*!< select by foreground area; 1 bpp */
+ L_SELECT_BY_PERIMETER = 5 /*!< select by perimeter; 1 bpp */
+};
+
+/*! Location Filter */
+enum {
+ L_SELECT_WIDTH = 1, /*!< width must satisfy constraint */
+ L_SELECT_HEIGHT = 2, /*!< height must satisfy constraint */
+ L_SELECT_XVAL = 3, /*!< x value must satisfy constraint */
+ L_SELECT_YVAL = 4, /*!< y value must satisfy constraint */
+ L_SELECT_IF_EITHER = 5, /*!< either width or height (or xval */
+ /*!< or yval) can satisfy constraint */
+ L_SELECT_IF_BOTH = 6 /*!< both width and height (or xval */
+ /*!< and yval must satisfy constraint */
+};
+
+/*! Boxa Check */
+enum {
+ L_CHECK_WIDTH = 1, /*!< check and possibly modify width */
+ L_CHECK_HEIGHT = 2, /*!< check and possibly modify height */
+ L_CHECK_BOTH = 3 /*!< check and possibly modify both */
+};
+
+/*-------------------------------------------------------------------------*
+ * Color component selection flags *
+ *-------------------------------------------------------------------------*/
+/*! Color Selection */
+enum {
+ L_SELECT_RED = 1, /*!< use red component */
+ L_SELECT_GREEN = 2, /*!< use green component */
+ L_SELECT_BLUE = 3, /*!< use blue component */
+ L_SELECT_MIN = 4, /*!< use min color component */
+ L_SELECT_MAX = 5, /*!< use max color component */
+ L_SELECT_AVERAGE = 6, /*!< use average of color components */
+ L_SELECT_HUE = 7, /*!< use hue value (in HSV color space) */
+ L_SELECT_SATURATION = 8, /*!< use saturation value (in HSV space) */
+ L_SELECT_WEIGHTED = 9 /*!< use weighted average of color comps */
+};
+
+/*-------------------------------------------------------------------------*
+ * Color content flags *
+ *-------------------------------------------------------------------------*/
+/*! Color Content */
+enum {
+ L_INTERMED_DIFF = 1, /*!< intermediate of diff component values */
+ L_AVE_MAX_DIFF_2 = 2, /*!< diff average closest comps to third */
+ L_MAX_DIFF = 3 /*!< maximum diff of component values */
+};
+
+/*-------------------------------------------------------------------------*
+ * 16-bit conversion flags *
+ *-------------------------------------------------------------------------*/
+/*! 16-bit Conversion */
+enum {
+ L_LS_BYTE = 1, /*!< use LSB */
+ L_MS_BYTE = 2, /*!< use MSB */
+ L_AUTO_BYTE = 3, /*!< use LSB if max(val) < 256; else MSB */
+ L_CLIP_TO_FF = 4, /*!< use max(val, 255) */
+ L_LS_TWO_BYTES = 5, /*!< use two LSB */
+ L_MS_TWO_BYTES = 6, /*!< use two MSB */
+ L_CLIP_TO_FFFF = 7 /*!< use max(val, 65535) */
+};
+
+/*-------------------------------------------------------------------------*
+ * Rotate and shear flags *
+ *-------------------------------------------------------------------------*/
+/*! Rotation Type */
+enum {
+ L_ROTATE_AREA_MAP = 1, /*!< use area map rotation, if possible */
+ L_ROTATE_SHEAR = 2, /*!< use shear rotation */
+ L_ROTATE_SAMPLING = 3 /*!< use sampling */
+};
+
+/*! Background Color */
+enum {
+ L_BRING_IN_WHITE = 1, /*!< bring in white pixels from the outside */
+ L_BRING_IN_BLACK = 2 /*!< bring in black pixels from the outside */
+};
+
+/*! Shear Point */
+enum {
+ L_SHEAR_ABOUT_CORNER = 1, /*!< shear image about UL corner */
+ L_SHEAR_ABOUT_CENTER = 2 /*!< shear image about center */
+};
+
+/*-------------------------------------------------------------------------*
+ * Affine transform order flags *
+ *-------------------------------------------------------------------------*/
+/*! Affine Transform Order */
+enum {
+ L_TR_SC_RO = 1, /*!< translate, scale, rotate */
+ L_SC_RO_TR = 2, /*!< scale, rotate, translate */
+ L_RO_TR_SC = 3, /*!< rotate, translate, scale */
+ L_TR_RO_SC = 4, /*!< translate, rotate, scale */
+ L_RO_SC_TR = 5, /*!< rotate, scale, translate */
+ L_SC_TR_RO = 6 /*!< scale, translate, rotate */
+};
+
+/*-------------------------------------------------------------------------*
+ * Grayscale filling flags *
+ *-------------------------------------------------------------------------*/
+/*! Grayscale Fill */
+enum {
+ L_FILL_WHITE = 1, /*!< fill white pixels (e.g, in fg map) */
+ L_FILL_BLACK = 2 /*!< fill black pixels (e.g., in bg map) */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for setting to white or black *
+ *-------------------------------------------------------------------------*/
+/*! BlackWhite Set */
+enum {
+ L_SET_WHITE = 1, /*!< set pixels to white */
+ L_SET_BLACK = 2 /*!< set pixels to black */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for getting white or black value *
+ *-------------------------------------------------------------------------*/
+/*! BlackWhite Get */
+enum {
+ L_GET_WHITE_VAL = 1, /*!< get white pixel value */
+ L_GET_BLACK_VAL = 2 /*!< get black pixel value */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for 8 bit and 16 bit pixel sums *
+ *-------------------------------------------------------------------------*/
+/*! BlackWhite Sum */
+enum {
+ L_WHITE_IS_MAX = 1, /*!< white pixels are 0xff or 0xffff; black are 0 */
+ L_BLACK_IS_MAX = 2 /*!< black pixels are 0xff or 0xffff; white are 0 */
+};
+
+/*-------------------------------------------------------------------------*
+ * Dither parameters *
+ * If within this grayscale distance from black or white, *
+ * do not propagate excess or deficit to neighboring pixels. *
+ *-------------------------------------------------------------------------*/
+/*! Dither Distance */
+enum {
+ DEFAULT_CLIP_LOWER_1 = 10, /*!< dist to black with no prop; 1 bpp */
+ DEFAULT_CLIP_UPPER_1 = 10, /*!< dist to black with no prop; 1 bpp */
+ DEFAULT_CLIP_LOWER_2 = 5, /*!< dist to black with no prop; 2 bpp */
+ DEFAULT_CLIP_UPPER_2 = 5 /*!< dist to black with no prop; 2 bpp */
+};
+
+/*-------------------------------------------------------------------------*
+ * Distance type flags *
+ *-------------------------------------------------------------------------*/
+/*! Distance Type */
+enum {
+ L_MANHATTAN_DISTANCE = 1, /*!< L1 distance (e.g., in color space) */
+ L_EUCLIDEAN_DISTANCE = 2 /*!< L2 distance */
+};
+
+/*-------------------------------------------------------------------------*
+ * Distance Value flags *
+ *-------------------------------------------------------------------------*/
+/*! Distance Value */
+enum {
+ L_NEGATIVE = 1, /*!< values < 0 */
+ L_NON_NEGATIVE = 2, /*!< values >= 0 */
+ L_POSITIVE = 3, /*!< values > 0 */
+ L_NON_POSITIVE = 4, /*!< values <= 0 */
+ L_ZERO = 5, /*!< values = 0 */
+ L_ALL = 6 /*!< all values */
+};
+
+/*-------------------------------------------------------------------------*
+ * Statistical measures *
+ *-------------------------------------------------------------------------*/
+/*! Stats Type */
+enum {
+ L_MEAN_ABSVAL = 1, /*!< average of abs values */
+ L_MEDIAN_VAL = 2, /*!< median value of set */
+ L_MODE_VAL = 3, /*!< mode value of set */
+ L_MODE_COUNT = 4, /*!< mode count of set */
+ L_ROOT_MEAN_SQUARE = 5, /*!< rms of values */
+ L_STANDARD_DEVIATION = 6, /*!< standard deviation from mean */
+ L_VARIANCE = 7 /*!< variance of values */
+};
+
+/*-------------------------------------------------------------------------*
+ * Set index selection flags *
+ *-------------------------------------------------------------------------*/
+/*! Index Selection */
+enum {
+ L_CHOOSE_CONSECUTIVE = 1, /*!< select 'n' consecutive */
+ L_CHOOSE_SKIP_BY = 2 /*!< select at intervals of 'n' */
+};
+
+/*-------------------------------------------------------------------------*
+ * Text orientation flags *
+ *-------------------------------------------------------------------------*/
+/*! Text Orientation */
+enum {
+ L_TEXT_ORIENT_UNKNOWN = 0, /*!< low confidence on text orientation */
+ L_TEXT_ORIENT_UP = 1, /*!< portrait, text rightside-up */
+ L_TEXT_ORIENT_LEFT = 2, /*!< landscape, text up to left */
+ L_TEXT_ORIENT_DOWN = 3, /*!< portrait, text upside-down */
+ L_TEXT_ORIENT_RIGHT = 4 /*!< landscape, text up to right */
+};
+
+/*-------------------------------------------------------------------------*
+ * Edge orientation flags *
+ *-------------------------------------------------------------------------*/
+/*! Edge Orientation */
+enum {
+ L_HORIZONTAL_EDGES = 0, /*!< filters for horizontal edges */
+ L_VERTICAL_EDGES = 1, /*!< filters for vertical edges */
+ L_ALL_EDGES = 2 /*!< filters for all edges */
+};
+
+/*-------------------------------------------------------------------------*
+ * Line orientation flags *
+ *-------------------------------------------------------------------------*/
+/*! Line Orientation */
+enum {
+ L_HORIZONTAL_LINE = 0, /*!< horizontal line */
+ L_POS_SLOPE_LINE = 1, /*!< 45 degree line with positive slope */
+ L_VERTICAL_LINE = 2, /*!< vertical line */
+ L_NEG_SLOPE_LINE = 3, /*!< 45 degree line with negative slope */
+ L_OBLIQUE_LINE = 4 /*!< neither horizontal nor vertical */
+};
+
+/*-------------------------------------------------------------------------*
+ * Image orientation flags *
+ *-------------------------------------------------------------------------*/
+/*! Image Orientation */
+enum {
+ L_PORTRAIT_MODE = 0, /*!< typical: page is viewed with height > width */
+ L_LANDSCAPE_MODE = 1 /*!< page is viewed at 90 deg to portrait mode */
+};
+
+/*-------------------------------------------------------------------------*
+ * Scan direction flags *
+ *-------------------------------------------------------------------------*/
+/*! Scan Direction */
+enum {
+ L_FROM_LEFT = 0, /*!< scan from left */
+ L_FROM_RIGHT = 1, /*!< scan from right */
+ L_FROM_TOP = 2, /*!< scan from top */
+ L_FROM_BOT = 3, /*!< scan from bottom */
+ L_SCAN_NEGATIVE = 4, /*!< scan in negative direction */
+ L_SCAN_POSITIVE = 5, /*!< scan in positive direction */
+ L_SCAN_BOTH = 6, /*!< scan in both directions */
+ L_SCAN_HORIZONTAL = 7, /*!< horizontal scan (direction unimportant) */
+ L_SCAN_VERTICAL = 8 /*!< vertical scan (direction unimportant) */
+};
+
+/*-------------------------------------------------------------------------*
+ * Box size adjustment and location flags *
+ *-------------------------------------------------------------------------*/
+/*! Box Adjustment */
+enum {
+ L_ADJUST_SKIP = 0, /*!< do not adjust */
+ L_ADJUST_LEFT = 1, /*!< adjust left edge */
+ L_ADJUST_RIGHT = 2, /*!< adjust right edge */
+ L_ADJUST_LEFT_AND_RIGHT = 3, /*!< adjust both left and right edges */
+ L_ADJUST_TOP = 4, /*!< adjust top edge */
+ L_ADJUST_BOT = 5, /*!< adjust bottom edge */
+ L_ADJUST_TOP_AND_BOT = 6, /*!< adjust both top and bottom edges */
+ L_ADJUST_CHOOSE_MIN = 7, /*!< choose the min median value */
+ L_ADJUST_CHOOSE_MAX = 8, /*!< choose the max median value */
+ L_SET_LEFT = 9, /*!< set left side to a given value */
+ L_SET_RIGHT = 10, /*!< set right side to a given value */
+ L_SET_TOP = 11, /*!< set top side to a given value */
+ L_SET_BOT = 12, /*!< set bottom side to a given value */
+ L_GET_LEFT = 13, /*!< get left side location */
+ L_GET_RIGHT = 14, /*!< get right side location */
+ L_GET_TOP = 15, /*!< get top side location */
+ L_GET_BOT = 16 /*!< get bottom side location */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for modifying box boundaries using a second box *
+ *-------------------------------------------------------------------------*/
+/*! Box Boundary Mod */
+enum {
+ L_USE_MINSIZE = 1, /*!< use boundaries giving min size */
+ L_USE_MAXSIZE = 2, /*!< use boundaries giving max size */
+ L_SUB_ON_LOC_DIFF = 3, /*!< modify boundary if big location diff */
+ L_SUB_ON_SIZE_DIFF = 4, /*!< modify boundary if big size diff */
+ L_USE_CAPPED_MIN = 5, /*!< modify boundary with capped min */
+ L_USE_CAPPED_MAX = 6 /*!< modify boundary with capped max */
+};
+
+/*-------------------------------------------------------------------------*
+ * Handling overlapping bounding boxes in boxa *
+ *-------------------------------------------------------------------------*/
+/*! Box Overlap Mod */
+enum {
+ L_COMBINE = 1, /*!< resize to bounding region; remove smaller */
+ L_REMOVE_SMALL = 2 /*!< only remove smaller */
+};
+
+/*-------------------------------------------------------------------------*
+ * Selecting or making a box from two (intersecting) boxes *
+ *-------------------------------------------------------------------------*/
+/*! Box Combine or Select */
+enum {
+ L_GEOMETRIC_UNION = 1, /*!< use union of two boxes */
+ L_GEOMETRIC_INTERSECTION = 2, /*!< use intersection of two boxes */
+ L_LARGEST_AREA = 3, /*!< use box with largest area */
+ L_SMALLEST_AREA = 4 /*!< use box with smallest area */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for replacing invalid boxes *
+ *-------------------------------------------------------------------------*/
+/*! Box Replacement */
+enum {
+ L_USE_ALL_BOXES = 1, /*!< consider all boxes in the sequence */
+ L_USE_SAME_PARITY_BOXES = 2 /*!< consider boxes with the same parity */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for box corners and center *
+ *-------------------------------------------------------------------------*/
+/*! Box Corners and Center */
+enum {
+ L_UPPER_LEFT = 1, /*!< UL corner */
+ L_UPPER_RIGHT = 2, /*!< UR corner */
+ L_LOWER_LEFT = 3, /*!< LL corner */
+ L_LOWER_RIGHT = 4, /*!< LR corner */
+ L_BOX_CENTER = 5 /*!< center */
+};
+
+/*-------------------------------------------------------------------------*
+ * Horizontal warp *
+ *-------------------------------------------------------------------------*/
+/*! Horiz Warp Stretch */
+enum {
+ L_WARP_TO_LEFT = 1, /*!< increasing stretch or contraction to left */
+ L_WARP_TO_RIGHT = 2 /*!< increasing stretch or contraction to right */
+};
+
+/*! Horiz Warp Mode */
+enum {
+ L_LINEAR_WARP = 1, /*!< stretch or contraction grows linearly */
+ L_QUADRATIC_WARP = 2 /*!< stretch or contraction grows quadratically */
+};
+
+/*-------------------------------------------------------------------------*
+ * Pixel selection for resampling *
+ *-------------------------------------------------------------------------*/
+/*! Pixel Selection */
+enum {
+ L_INTERPOLATED = 1, /*!< linear interpolation from src pixels */
+ L_SAMPLED = 2 /*!< nearest src pixel sampling only */
+};
+
+/*-------------------------------------------------------------------------*
+ * Thinning flags *
+ *-------------------------------------------------------------------------*/
+/*! Thinning Polarity */
+enum {
+ L_THIN_FG = 1, /*!< thin foreground of 1 bpp image */
+ L_THIN_BG = 2 /*!< thin background of 1 bpp image */
+};
+
+/*-------------------------------------------------------------------------*
+ * Runlength flags *
+ *-------------------------------------------------------------------------*/
+/*! Runlength Direction */
+enum {
+ L_HORIZONTAL_RUNS = 0, /*!< determine runlengths of horizontal runs */
+ L_VERTICAL_RUNS = 1 /*!< determine runlengths of vertical runs */
+};
+
+/*-------------------------------------------------------------------------*
+ * Edge filter flags *
+ *-------------------------------------------------------------------------*/
+/*! Edge Filter */
+enum {
+ L_SOBEL_EDGE = 1, /*!< Sobel edge filter */
+ L_TWO_SIDED_EDGE = 2 /*!< Two-sided edge filter */
+};
+
+/*-------------------------------------------------------------------------*
+ * Subpixel color component ordering in LCD display *
+ *-------------------------------------------------------------------------*/
+/*! Subpixel Color Order */
+enum {
+ L_SUBPIXEL_ORDER_RGB = 1, /*!< sensor order left-to-right RGB */
+ L_SUBPIXEL_ORDER_BGR = 2, /*!< sensor order left-to-right BGR */
+ L_SUBPIXEL_ORDER_VRGB = 3, /*!< sensor order top-to-bottom RGB */
+ L_SUBPIXEL_ORDER_VBGR = 4 /*!< sensor order top-to-bottom BGR */
+};
+
+/*-------------------------------------------------------------------------*
+ * HSV histogram flags *
+ *-------------------------------------------------------------------------*/
+/*! HSV Histogram */
+enum {
+ L_HS_HISTO = 1, /*!< Use hue-saturation histogram */
+ L_HV_HISTO = 2, /*!< Use hue-value histogram */
+ L_SV_HISTO = 3 /*!< Use saturation-value histogram */
+};
+
+/*-------------------------------------------------------------------------*
+ * HSV Region flags (inclusion, exclusion) *
+ *-------------------------------------------------------------------------*/
+/*! HSV Region */
+enum {
+ L_INCLUDE_REGION = 1, /*!< Use pixels with specified HSV region */
+ L_EXCLUDE_REGION = 2 /*!< Use pixels outside HSV region */
+};
+
+/*-------------------------------------------------------------------------*
+ * Location flags for adding text to a pix *
+ *-------------------------------------------------------------------------*/
+/*! Add Text Location */
+enum {
+ L_ADD_ABOVE = 1, /*!< Add text above the image */
+ L_ADD_BELOW = 2, /*!< Add text below the image */
+ L_ADD_LEFT = 3, /*!< Add text to the left of the image */
+ L_ADD_RIGHT = 4, /*!< Add text to the right of the image */
+ L_ADD_AT_TOP = 5, /*!< Add text over the top of the image */
+ L_ADD_AT_BOT = 6, /*!< Add text over the bottom of the image */
+ L_ADD_AT_LEFT = 7, /*!< Add text over left side of the image */
+ L_ADD_AT_RIGHT = 8 /*!< Add text over right side of the image */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for plotting on a pix *
+ *-------------------------------------------------------------------------*/
+/*! Pix Plot */
+enum {
+ L_PLOT_AT_TOP = 1, /*!< Plot horizontally at top */
+ L_PLOT_AT_MID_HORIZ = 2, /*!< Plot horizontally at middle */
+ L_PLOT_AT_BOT = 3, /*!< Plot horizontally at bottom */
+ L_PLOT_AT_LEFT = 4, /*!< Plot vertically at left */
+ L_PLOT_AT_MID_VERT = 5, /*!< Plot vertically at middle */
+ L_PLOT_AT_RIGHT = 6 /*!< Plot vertically at right */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for making simple masks *
+ *-------------------------------------------------------------------------*/
+/*! Mask Generation */
+enum {
+ L_USE_INNER = 1, /*!< Select the interior part */
+ L_USE_OUTER = 2 /*!< Select the outer part (e.g., a frame) */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for selecting display program *
+ *-------------------------------------------------------------------------*/
+/*! Display Program */
+enum {
+ L_DISPLAY_WITH_XZGV = 1, /*!< Use xzgv with pixDisplay() */
+ L_DISPLAY_WITH_XLI = 2, /*!< Use xli with pixDisplay() */
+ L_DISPLAY_WITH_XV = 3, /*!< Use xv with pixDisplay() */
+ L_DISPLAY_WITH_IV = 4, /*!< Use irfvanview (win) with pixDisplay() */
+ L_DISPLAY_WITH_OPEN = 5 /*!< Use open (apple) with pixDisplay() */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flag(s) used in the 'special' pix field for non-default operations *
+ * - 0 is default for chroma sampling in jpeg *
+ * - 10-19 are used for zlib compression in png write *
+ * - 4 and 8 are used for specifying connectivity in labelling *
+ *-------------------------------------------------------------------------*/
+/*! Flags used in Pix::special */
+enum {
+ L_NO_CHROMA_SAMPLING_JPEG = 1 /*!< Write full resolution chroma */
+};
+
+/*-------------------------------------------------------------------------*
+ * Handling negative values in conversion to unsigned int *
+ *-------------------------------------------------------------------------*/
+/*! Negative Value */
+enum {
+ L_CLIP_TO_ZERO = 1, /*!< Clip negative values to 0 */
+ L_TAKE_ABSVAL = 2 /*!< Convert to positive using L_ABS() */
+};
+
+/*-------------------------------------------------------------------------*
+ * Relative to zero flags *
+ *-------------------------------------------------------------------------*/
+/*! Relative To Zero */
+enum {
+ L_LESS_THAN_ZERO = 1, /*!< Choose values less than zero */
+ L_EQUAL_TO_ZERO = 2, /*!< Choose values equal to zero */
+ L_GREATER_THAN_ZERO = 3 /*!< Choose values greater than zero */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for adding or removing trailing slash from string *
+ *-------------------------------------------------------------------------*/
+/*! Trailing Slash */
+enum {
+ L_ADD_TRAIL_SLASH = 1, /*!< Add trailing slash to string */
+ L_REMOVE_TRAIL_SLASH = 2 /*!< Remove trailing slash from string */
+};
+
+/*-------------------------------------------------------------------------*
+ * Pix allocator and deallocator function types *
+ *-------------------------------------------------------------------------*/
+/*! Allocator function type */
+typedef void *(*alloc_fn)(size_t);
+
+/*! Deallocator function type */
+typedef void (*dealloc_fn)(void *);
+
+#endif /* LEPTONICA_PIX_H */
diff --git a/third_party/leptonica/windows/include/leptonica/pix_internal.h b/third_party/leptonica/windows/include/leptonica/pix_internal.h
new file mode 100644
index 00000000..ca20032e
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/pix_internal.h
@@ -0,0 +1,426 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_PIX_INTERNAL_H
+#define LEPTONICA_PIX_INTERNAL_H
+
+/*!
+ * \file pix_internal.h
+ *
+ *
+ * Valid image types in leptonica:
+ * Pix: 1 bpp, with and without colormap
+ * Pix: 2 bpp, with and without colormap
+ * Pix: 4 bpp, with and without colormap
+ * Pix: 8 bpp, with and without colormap
+ * Pix: 16 bpp (1 spp)
+ * Pix: 32 bpp (rgb, 3 spp)
+ * Pix: 32 bpp (rgba, 4 spp)
+ * FPix: 32 bpp float
+ * DPix: 64 bpp double
+ * Notes:
+ * (1) The only valid Pix image type with alpha is rgba.
+ * In particular, the alpha component is not used in
+ * cmapped images.
+ * (2) PixComp can hold any Pix with IFF_PNG encoding.
+ *
+ * This file is internal: it is not part of the public interface.
+ * It contains the definitions of most of the image-related structs
+ * used in leptonica:
+ * struct Pix
+ * struct PixColormap
+ * struct RGBA_Quad
+ * struct Pixa
+ * struct Pixaa
+ * struct Box
+ * struct Boxa
+ * struct Boxaa
+ * struct Pta
+ * struct Ptaa
+ * struct Pixacc
+ * struct PixTiling
+ * struct FPix
+ * struct FPixa
+ * struct DPix
+ * struct PixComp
+ * struct PixaComp
+ *
+ * This file can be #included after allheaders.h in source files that
+ * require direct access to the internal data fields in these structs.
+ *
+ * Notes on the pixels in the raster image. Most of this information
+ * can also be found in pix.h.
+ *
+ * (1) The image data is stored in a single contiguous
+ * array of l_uint32, into which the pixels are packed.
+ * By "packed" we mean that there are no unused bits
+ * between pixels, except for end-of-line padding to
+ * satisfy item (2) below.
+ *
+ * (2) Every image raster line begins on a 32-bit word
+ * boundary within this array.
+ *
+ * (3) Pix image data is stored in 32-bit units, with the
+ * pixels ordered from left to right in the image being
+ * stored in order from the MSB to LSB within the word,
+ * for both big-endian and little-endian machines.
+ * This is the natural ordering for big-endian machines,
+ * as successive bytes are stored and fetched progressively
+ * to the right. However, for little-endians, when storing
+ * we re-order the bytes from this byte stream order, and
+ * reshuffle again for byte access on 32-bit entities.
+ * So if the bytes come in sequence from left to right, we
+ * store them on little-endians in byte order:
+ * 3 2 1 0 7 6 5 4 ...
+ * This MSB to LSB ordering allows left and right shift
+ * operations on 32 bit words to move the pixels properly.
+ *
+ * (4) We use 32 bit pixels for both RGB and RGBA color images.
+ * The A (alpha) byte is ignored in most leptonica functions
+ * operating on color images. Within each 4 byte pixel, the
+ * color samples are ordered from MSB to LSB, as follows:
+ *
+ * | MSB | 2nd MSB | 3rd MSB | LSB |
+ * red green blue alpha
+ * 0 1 2 3 (big-endian)
+ * 3 2 1 0 (little-endian)
+ *
+ * Because we use MSB to LSB ordering within the 32-bit word,
+ * the individual 8-bit samples can be accessed with
+ * GET_DATA_BYTE and SET_DATA_BYTE macros, using the
+ * (implicitly big-ending) ordering
+ * red: byte 0 (MSB)
+ * green: byte 1 (2nd MSB)
+ * blue: byte 2 (3rd MSB)
+ * alpha: byte 3 (LSB)
+ *
+ * The specific color assignment is made in this file,
+ * through the definitions of COLOR_RED, etc. Then the R, G
+ * B and A sample values can be retrieved using
+ * redval = GET_DATA_BYTE(&pixel, COLOR_RED);
+ * greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN);
+ * blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE);
+ * alphaval = GET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL);
+ * and they can be set with
+ * SET_DATA_BYTE(&pixel, COLOR_RED, redval);
+ * SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval);
+ * SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval);
+ * SET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL, alphaval);
+ *
+ * More efficiently, these components can be extracted directly
+ * by shifting and masking, explicitly using the values in
+ * L_RED_SHIFT, etc.:
+ * (pixel32 >> L_RED_SHIFT) & 0xff; (red)
+ * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
+ * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
+ * (pixel32 >> L_ALPHA_SHIFT) & 0xff; (alpha)
+ * The functions extractRGBValues() and extractRGBAValues() are
+ * provided to do this. Likewise, the pixels can be set
+ * directly by shifting, using composeRGBPixel() and
+ * composeRGBAPixel().
+ *
+ * All these operations work properly on both big- and little-endians.
+ *
+ * (5) A reference count is held within each pix, giving the
+ * number of ptrs to the pix. When a pixClone() call
+ * is made, the ref count is increased by 1, and
+ * when a pixDestroy() call is made, the reference count
+ * of the pix is decremented. The pix is only destroyed
+ * when the reference count goes to zero.
+ *
+ * (6) The version numbers (below) are used in the serialization
+ * of these data structures. They are placed in the files,
+ * and rarely (if ever) change.
+ *
+ * (7) The serialization dependencies are as follows:
+ * pixaa : pixa : boxa
+ * boxaa : boxa
+ * So, for example, pixaa and boxaa can be changed without
+ * forcing a change in pixa or boxa. However, if pixa is
+ * changed, it forces a change in pixaa, and if boxa is
+ * changed, if forces a change in the other three.
+ * We define four version numbers:
+ * PIXAA_VERSION_NUMBER
+ * PIXA_VERSION_NUMBER
+ * BOXAA_VERSION_NUMBER
+ * BOXA_VERSION_NUMBER
+ *
+ *-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*
+ * Basic Pix *
+ *-------------------------------------------------------------------------*/
+ /* The 'special' field is by default 0, but it can hold integers
+ * that direct non-default actions, e.g., in png and jpeg I/O. */
+
+/*! Basic Pix */
+struct Pix
+{
+ l_uint32 w; /*!< width in pixels */
+ l_uint32 h; /*!< height in pixels */
+ l_uint32 d; /*!< depth in bits (bpp) */
+ l_uint32 spp; /*!< number of samples per pixel */
+ l_uint32 wpl; /*!< 32-bit words/line */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+ l_int32 xres; /*!< image res (ppi) in x direction */
+ /*!< (use 0 if unknown) */
+ l_int32 yres; /*!< image res (ppi) in y direction */
+ /*!< (use 0 if unknown) */
+ l_int32 informat; /*!< input file format, IFF_* */
+ l_int32 special; /*!< special instructions for I/O, etc */
+ char *text; /*!< text string associated with pix */
+ struct PixColormap *colormap; /*!< colormap (may be null) */
+ l_uint32 *data; /*!< the image data */
+};
+
+/*! Colormap of a Pix */
+struct PixColormap
+{
+ void *array; /*!< colormap table (array of RGBA_QUAD) */
+ l_int32 depth; /*!< of pix (1, 2, 4 or 8 bpp) */
+ l_int32 nalloc; /*!< number of color entries allocated */
+ l_int32 n; /*!< number of color entries used */
+};
+
+
+ /*! Colormap table entry (after the BMP version).
+ * Note that the BMP format stores the colormap table exactly
+ * as it appears here, with color samples being stored sequentially,
+ * in the order (b,g,r,a). */
+struct RGBA_Quad
+{
+ l_uint8 blue; /*!< blue value */
+ l_uint8 green; /*!< green value */
+ l_uint8 red; /*!< red value */
+ l_uint8 alpha; /*!< alpha value */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Array of pix *
+ *-------------------------------------------------------------------------*/
+ /* Serialization for primary data structures */
+#define PIXAA_VERSION_NUMBER 2 /*!< Version for Pixaa serialization */
+#define PIXA_VERSION_NUMBER 2 /*!< Version for Pixa serialization */
+#define BOXA_VERSION_NUMBER 2 /*!< Version for Boxa serialization */
+#define BOXAA_VERSION_NUMBER 3 /*!< Version for Boxaa serialization */
+
+/*! Array of pix */
+struct Pixa
+{
+ l_int32 n; /*!< number of Pix in ptr array */
+ l_int32 nalloc; /*!< number of Pix ptrs allocated */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+ struct Pix **pix; /*!< the array of ptrs to pix */
+ struct Boxa *boxa; /*!< array of boxes */
+};
+
+/*! Array of arrays of pix */
+struct Pixaa
+{
+ l_int32 n; /*!< number of Pixa in ptr array */
+ l_int32 nalloc; /*!< number of Pixa ptrs allocated */
+ struct Pixa **pixa; /*!< array of ptrs to pixa */
+ struct Boxa *boxa; /*!< array of boxes */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Basic rectangle and rectangle arrays *
+ *-------------------------------------------------------------------------*/
+/*! Basic rectangle */
+struct Box
+{
+ l_int32 x; /*!< left coordinate */
+ l_int32 y; /*!< top coordinate */
+ l_int32 w; /*!< box width */
+ l_int32 h; /*!< box height */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+};
+
+/*! Array of Box */
+struct Boxa
+{
+ l_int32 n; /*!< number of box in ptr array */
+ l_int32 nalloc; /*!< number of box ptrs allocated */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+ struct Box **box; /*!< box ptr array */
+};
+
+/*! Array of Boxa */
+struct Boxaa
+{
+ l_int32 n; /*!< number of boxa in ptr array */
+ l_int32 nalloc; /*!< number of boxa ptrs allocated */
+ struct Boxa **boxa; /*!< boxa ptr array */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Array of points *
+ *-------------------------------------------------------------------------*/
+#define PTA_VERSION_NUMBER 1 /*!< Version for Pta serialization */
+
+/*! Array of points */
+struct Pta
+{
+ l_int32 n; /*!< actual number of pts */
+ l_int32 nalloc; /*!< size of allocated arrays */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+ l_float32 *x, *y; /*!< arrays of floats */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Array of Pta *
+ *-------------------------------------------------------------------------*/
+/*! Array of Pta */
+struct Ptaa
+{
+ l_int32 n; /*!< number of pta in ptr array */
+ l_int32 nalloc; /*!< number of pta ptrs allocated */
+ struct Pta **pta; /*!< pta ptr array */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Pix accumulator container *
+ *-------------------------------------------------------------------------*/
+/*! Pix accumulator container */
+struct Pixacc
+{
+ l_int32 w; /*!< array width */
+ l_int32 h; /*!< array height */
+ l_int32 offset; /*!< used to allow negative */
+ /*!< intermediate results */
+ struct Pix *pix; /*!< the 32 bit accumulator pix */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Pix tiling *
+ *-------------------------------------------------------------------------*/
+/*! Pix tiling */
+struct PixTiling
+{
+ struct Pix *pix; /*!< input pix (a clone) */
+ l_int32 nx; /*!< number of tiles horizontally */
+ l_int32 ny; /*!< number of tiles vertically */
+ l_int32 w; /*!< tile width */
+ l_int32 h; /*!< tile height */
+ l_int32 xoverlap; /*!< overlap on left and right */
+ l_int32 yoverlap; /*!< overlap on top and bottom */
+ l_int32 strip; /*!< strip for paint; default is TRUE */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * FPix: pix with float array *
+ *-------------------------------------------------------------------------*/
+#define FPIX_VERSION_NUMBER 2 /*!< Version for FPix serialization */
+
+/*! Pix with float array */
+struct FPix
+{
+ l_int32 w; /*!< width in pixels */
+ l_int32 h; /*!< height in pixels */
+ l_int32 wpl; /*!< 32-bit words/line */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+ l_int32 xres; /*!< image res (ppi) in x direction */
+ /*!< (use 0 if unknown) */
+ l_int32 yres; /*!< image res (ppi) in y direction */
+ /*!< (use 0 if unknown) */
+ l_float32 *data; /*!< the float image data */
+};
+
+/*! Array of FPix */
+struct FPixa
+{
+ l_int32 n; /*!< number of fpix in ptr array */
+ l_int32 nalloc; /*!< number of fpix ptrs allocated */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+ struct FPix **fpix; /*!< the array of ptrs to fpix */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * DPix: pix with double array *
+ *-------------------------------------------------------------------------*/
+#define DPIX_VERSION_NUMBER 2 /*!< Version for DPix serialization */
+
+/*! Pix with double array */
+struct DPix
+{
+ l_int32 w; /*!< width in pixels */
+ l_int32 h; /*!< height in pixels */
+ l_int32 wpl; /*!< 32-bit words/line */
+ l_atomic refcount; /*!< reference count (1 if no clones) */
+ l_int32 xres; /*!< image res (ppi) in x direction */
+ /*!< (use 0 if unknown) */
+ l_int32 yres; /*!< image res (ppi) in y direction */
+ /*!< (use 0 if unknown) */
+ l_float64 *data; /*!< the double image data */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * PixComp: compressed pix *
+ *-------------------------------------------------------------------------*/
+/*! Compressed Pix */
+struct PixComp
+{
+ l_int32 w; /*!< width in pixels */
+ l_int32 h; /*!< height in pixels */
+ l_int32 d; /*!< depth in bits */
+ l_int32 xres; /*!< image res (ppi) in x direction */
+ /*!< (use 0 if unknown) */
+ l_int32 yres; /*!< image res (ppi) in y direction */
+ /*!< (use 0 if unknown) */
+ l_int32 comptype; /*!< compressed format (IFF_TIFF_G4, */
+ /*!< IFF_PNG, IFF_JFIF_JPEG) */
+ char *text; /*!< text string associated with pix */
+ l_int32 cmapflag; /*!< flag (1 for cmap, 0 otherwise) */
+ l_uint8 *data; /*!< the compressed image data */
+ size_t size; /*!< size of the data array */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * PixaComp: array of compressed pix *
+ *-------------------------------------------------------------------------*/
+#define PIXACOMP_VERSION_NUMBER 2 /*!< Version for PixaComp serialization */
+
+/*! Array of compressed pix */
+struct PixaComp
+{
+ l_int32 n; /*!< number of PixComp in ptr array */
+ l_int32 nalloc; /*!< number of PixComp ptrs allocated */
+ l_int32 offset; /*!< indexing offset into ptr array */
+ struct PixComp **pixc; /*!< the array of ptrs to PixComp */
+ struct Boxa *boxa; /*!< array of boxes */
+};
+
+#endif /* LEPTONICA_PIX_INTERNAL_H */
diff --git a/third_party/leptonica/windows/include/leptonica/ptra.h b/third_party/leptonica/windows/include/leptonica/ptra.h
new file mode 100644
index 00000000..705d97af
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/ptra.h
@@ -0,0 +1,97 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_PTRA_H
+#define LEPTONICA_PTRA_H
+
+/*!
+ * \file ptra.h
+ *
+ *
+ * Contains the following structs:
+ * struct L_Ptra
+ * struct L_Ptraa
+ *
+ * Contains definitions for:
+ * L_Ptra compaction flags for removal
+ * L_Ptra shifting flags for insert
+ * L_Ptraa accessor flags
+ *
+ */
+
+ /* Bound on max initial ptra size */
+LEPT_DLL extern const l_uint32 MaxInitPtraSize;
+
+/*------------------------------------------------------------------------*
+ * Generic Ptr Array Structs *
+ *------------------------------------------------------------------------*/
+
+ /*! Generic pointer array */
+struct L_Ptra
+{
+ l_int32 nalloc; /*!< size of allocated ptr array */
+ l_int32 imax; /*!< greatest valid index */
+ l_int32 nactual; /*!< actual number of stored elements */
+ void **array; /*!< ptr array */
+};
+typedef struct L_Ptra L_PTRA;
+
+
+ /*! Array of generic pointer arrays */
+struct L_Ptraa
+{
+ l_int32 nalloc; /*!< size of allocated ptr array */
+ struct L_Ptra **ptra; /*!< array of ptra */
+};
+typedef struct L_Ptraa L_PTRAA;
+
+
+
+/*------------------------------------------------------------------------*
+ * Accessor and modifier flags for L_Ptra and L_Ptraa *
+ *------------------------------------------------------------------------*/
+
+/*! Ptra Removal */
+enum {
+ L_NO_COMPACTION = 1, /*!< null the pointer only */
+ L_COMPACTION = 2 /*!< compact the array */
+};
+
+/*! Ptra Insertion */
+enum {
+ L_AUTO_DOWNSHIFT = 0, /*!< choose based on number of holes */
+ L_MIN_DOWNSHIFT = 1, /*!< downshifts min # of ptrs below insert */
+ L_FULL_DOWNSHIFT = 2 /*!< downshifts all ptrs below insert */
+};
+
+/*! Ptraa Accessor */
+enum {
+ L_HANDLE_ONLY = 0, /*!< ptr to L_Ptra; caller can inspect only */
+ L_REMOVE = 1 /*!< caller owns; destroy or save in L_Ptraa */
+};
+
+
+#endif /* LEPTONICA_PTRA_H */
diff --git a/third_party/leptonica/windows/include/leptonica/queue.h b/third_party/leptonica/windows/include/leptonica/queue.h
new file mode 100644
index 00000000..fd380e83
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/queue.h
@@ -0,0 +1,77 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_QUEUE_H
+#define LEPTONICA_QUEUE_H
+
+/*!
+ * \file queue.h
+ *
+ *
+ * Expandable pointer queue for arbitrary void* data.
+ *
+ * The L_Queue is a fifo that implements a queue of void* pointers.
+ * It can be used to hold a queue of any type of struct.
+ *
+ * Internally, it maintains two counters:
+ * nhead: location of head (in ptrs) from the beginning
+ * of the array.
+ * nelem: number of ptr elements stored in the queue.
+ *
+ * The element at the head of the queue, which is the next to
+ * be removed, is array[nhead]. The location at the tail of the
+ * queue to which the next element will be added is
+ * array[nhead + nelem].
+ *
+ * As items are added to the queue, nelem increases.
+ * As items are removed, nhead increases and nelem decreases.
+ * Any time the tail reaches the end of the allocated array,
+ * all the pointers are shifted to the left, so that the head
+ * is at the beginning of the array.
+ * If the array becomes more than 3/4 full, it doubles in size.
+ *
+ * The auxiliary stack can be used in a wrapper for re-using
+ * items popped from the queue. It is not made by default.
+ *
+ * For further implementation details, see queue.c.
+ *
+ */
+
+/*! Expandable pointer queue for arbitrary void* data */
+struct L_Queue
+{
+ l_int32 nalloc; /*!< size of allocated ptr array */
+ l_int32 nhead; /*!< location of head (in ptrs) from the */
+ /*!< beginning of the array */
+ l_int32 nelem; /*!< number of elements stored in the queue */
+ void **array; /*!< ptr array */
+ struct L_Stack *stack; /*!< auxiliary stack */
+
+};
+typedef struct L_Queue L_QUEUE;
+
+
+#endif /* LEPTONICA_QUEUE_H */
diff --git a/third_party/leptonica/windows/include/leptonica/rbtree.h b/third_party/leptonica/windows/include/leptonica/rbtree.h
new file mode 100644
index 00000000..6977d336
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/rbtree.h
@@ -0,0 +1,91 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+/*
+ * Modified from the excellent code here:
+ * http://en.literateprograms.org/Red-black_tree_(C)?oldid=19567
+ * which has been placed in the public domain under the Creative Commons
+ * CC0 1.0 waiver (http://creativecommons.org/publicdomain/zero/1.0/).
+ *
+ * When the key is generated from a hash (e.g., string --> uint64),
+ * there is always the possibility of having collisions, but to make
+ * the collision probability very low requires using a large hash.
+ * For that reason, the key types are 64 bit quantities, which will result
+ * in a negligible probabililty of collisions for millions of hashed values.
+ * Using 8 byte keys instead of 4 byte keys requires a little more
+ * storage, but the simplification in being able to ignore collisions
+ * with the red-black trees for most applications is worth it.
+ */
+
+#ifndef LEPTONICA_RBTREE_H
+#define LEPTONICA_RBTREE_H
+
+ /*! The three valid key types for red-black trees, maps and sets. */
+/*! RBTree Key Type */
+enum {
+ L_INT_TYPE = 1,
+ L_UINT_TYPE = 2,
+ L_FLOAT_TYPE = 3
+};
+
+ /*!
+ * Storage for keys and values for red-black trees, maps and sets.
+ *
+ * Note:
+ * (1) Keys and values of the valid key types are all 64-bit
+ * (2) (void *) can be used for values but not for keys.
+ *
+ */
+union Rb_Type {
+ l_int64 itype;
+ l_uint64 utype;
+ l_float64 ftype;
+ void *ptype;
+};
+typedef union Rb_Type RB_TYPE;
+
+struct L_Rbtree {
+ struct L_Rbtree_Node *root;
+ l_int32 keytype;
+};
+typedef struct L_Rbtree L_RBTREE;
+typedef struct L_Rbtree L_AMAP; /* hide underlying implementation for map */
+typedef struct L_Rbtree L_ASET; /* hide underlying implementation for set */
+
+struct L_Rbtree_Node {
+ union Rb_Type key;
+ union Rb_Type value;
+ struct L_Rbtree_Node *left;
+ struct L_Rbtree_Node *right;
+ struct L_Rbtree_Node *parent;
+ l_int32 color;
+};
+typedef struct L_Rbtree_Node L_RBTREE_NODE;
+typedef struct L_Rbtree_Node L_AMAP_NODE; /* hide tree implementation */
+typedef struct L_Rbtree_Node L_ASET_NODE; /* hide tree implementation */
+
+
+#endif /* LEPTONICA_RBTREE_H */
diff --git a/third_party/leptonica/windows/include/leptonica/readbarcode.h b/third_party/leptonica/windows/include/leptonica/readbarcode.h
new file mode 100644
index 00000000..358ff4e5
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/readbarcode.h
@@ -0,0 +1,239 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_READBARCODE_H
+#define LEPTONICA_READBARCODE_H
+
+ /* ----------------------------------------------------------------- *
+ * Flags for method of extracting barcode widths *
+ * ----------------------------------------------------------------- */
+
+/*! Barcode Method */
+enum {
+ L_USE_WIDTHS = 1, /*!< use histogram of barcode widths */
+ L_USE_WINDOWS = 2 /*!< find best window for decoding transitions */
+};
+
+ /* ----------------------------------------------------------------- *
+ * Flags for barcode formats *
+ * These are used both to identify a barcode format and to identify *
+ * the decoding method to use on a barcode. *
+ * ----------------------------------------------------------------- */
+
+/*! Barcode Format */
+enum {
+ L_BF_UNKNOWN = 0, /*!< unknown format */
+ L_BF_ANY = 1, /*!< try decoding with all known formats */
+ L_BF_CODE128 = 2, /*!< decode with Code128 format */
+ L_BF_EAN8 = 3, /*!< decode with EAN8 format */
+ L_BF_EAN13 = 4, /*!< decode with EAN13 format */
+ L_BF_CODE2OF5 = 5, /*!< decode with Code 2 of 5 format */
+ L_BF_CODEI2OF5 = 6, /*!< decode with Interleaved 2 of 5 format */
+ L_BF_CODE39 = 7, /*!< decode with Code39 format */
+ L_BF_CODE93 = 8, /*!< decode with Code93 format */
+ L_BF_CODABAR = 9, /*!< decode with Code93 format */
+ L_BF_UPCA = 10 /*!< decode with UPC A format */
+};
+
+ /* ----------------------------------------------------------------- *
+ * Currently supported formats *
+ * Update these arrays as new formats are added. *
+ * ----------------------------------------------------------------- */
+
+/*! Currently supported formats */
+static const l_int32 SupportedBarcodeFormat[] = {
+ L_BF_CODE2OF5,
+ L_BF_CODEI2OF5,
+ L_BF_CODE93,
+ L_BF_CODE39,
+ L_BF_CODABAR,
+ L_BF_UPCA,
+ L_BF_EAN13
+};
+
+/*! Currently supported format names */
+static const char *SupportedBarcodeFormatName[] = {
+ "Code2of5",
+ "CodeI2of5",
+ "Code93",
+ "Code39",
+ "Codabar",
+ "Upca",
+ "Ean13"
+};
+static const l_int32 NumSupportedBarcodeFormats = 7; /*!< Number of formats */
+
+
+ /* ----------------------------------------------------------------- *
+ * Code 2 of 5 symbology *
+ * ----------------------------------------------------------------- */
+static const char *Code2of5[] = {
+ "111121211", "211111112", "112111112", "212111111", /* 0 - 3 */
+ "111121112", "211121111", "112121111", "111111212", /* 4 - 7 */
+ "211111211", "112111211", /* 8 - 9 */
+ "21211", "21112" /* Start, Stop */
+};
+
+static const l_int32 C25_START = 10;
+static const l_int32 C25_STOP = 11;
+
+
+ /* ----------------------------------------------------------------- *
+ * Code Interleaved 2 of 5 symbology *
+ * ----------------------------------------------------------------- */
+static const char *CodeI2of5[] = {
+ "11221", "21112", "12112", "22111", "11212", /* 0 - 4 */
+ "21211", "12211", "11122", "21121", "12121", /* 5 - 9 */
+ "1111", "211" /* start, stop */
+};
+
+static const l_int32 CI25_START = 10;
+static const l_int32 CI25_STOP = 11;
+
+
+ /* ----------------------------------------------------------------- *
+ * Code 93 symbology *
+ * ----------------------------------------------------------------- */
+static const char *Code93[] = {
+ "131112", "111213", "111312", "111411", "121113", /* 0: 0 - 4 */
+ "121212", "121311", "111114", "131211", "141111", /* 5: 5 - 9 */
+ "211113", "211212", "211311", "221112", "221211", /* 10: A - E */
+ "231111", "112113", "112212", "112311", "122112", /* 15: F - J */
+ "132111", "111123", "111222", "111321", "121122", /* 20: K - O */
+ "131121", "212112", "212211", "211122", "211221", /* 25: P - T */
+ "221121", "222111", "112122", "112221", "122121", /* 30: U - Y */
+ "123111", "121131", "311112", "311211", "321111", /* 35: Z,-,.,SP,$ */
+ "112131", "113121", "211131", "131221", "312111", /* 40: /,+,%,($),(%) */
+ "311121", "122211", "111141" /* 45: (/),(+), Start */
+};
+
+ /* Use "[]{}#" to represent special codes 43-47 */
+static const char Code93Val[] =
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%[]{}#";
+
+static const l_int32 C93_START = 47;
+static const l_int32 C93_STOP = 47;
+
+
+ /* ----------------------------------------------------------------- *
+ * Code 39 symbology *
+ * ----------------------------------------------------------------- */
+static const char *Code39[] = {
+ "111221211", "211211112", "112211112", "212211111", /* 0: 0 - 3 */
+ "111221112", "211221111", "112221111", "111211212", /* 4: 4 - 7 */
+ "211211211", "112211211", "211112112", "112112112", /* 8: 8 - B */
+ "212112111", "111122112", "211122111", "112122111", /* 12: C - F */
+ "111112212", "211112211", "112112211", "111122211", /* 16: G - J */
+ "211111122", "112111122", "212111121", "111121122", /* 20: K - N */
+ "211121121", "112121121", "111111222", "211111221", /* 24: O - R */
+ "112111221", "111121221", "221111112", "122111112", /* 28: S - V */
+ "222111111", "121121112", "221121111", "122121111", /* 32: W - Z */
+ "121111212", "221111211", "122111211", "121212111", /* 36: -,.,SP,$ */
+ "121211121", "121112121", "111212121", "121121211" /* 40: /,+,%,* */
+};
+
+ /* Use "*" to represent the Start and Stop codes (43) */
+static const char Code39Val[] =
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*";
+
+static const l_int32 C39_START = 43;
+static const l_int32 C39_STOP = 43;
+
+
+ /* ----------------------------------------------------------------- *
+ * Codabar symbology *
+ * ----------------------------------------------------------------- */
+static const char *Codabar[] = {
+ "1111122", "1111221", "1112112", "2211111", "1121121", /* 0: 0 - 4 */
+ "2111121", "1211112", "1211211", "1221111", "2112111", /* 5: 5 - 9 */
+ "1112211", "1122111", "2111212", "2121112", "2121211", /* 10: -,$,:,/,. */
+ "1121212", "1122121", "1212112", "1112122", "1112221" /* 15: +,A,B,C,D */
+};
+
+ /* Ascii representations for codes 16-19: (A or T), (B or N), (C or *),
+ * (D or E). These are used in pairs for the Start and Stop codes. */
+static const char CodabarVal[] = "0123456789-$:/.+ABCD";
+
+
+ /* ----------------------------------------------------------------- *
+ * UPC-A symbology *
+ * ----------------------------------------------------------------- */
+static const char *Upca[] = {
+ "3211", "2221", "2122", "1411", "1132", /* 0: 0 - 4 */
+ "1231", "1114", "1312", "1213", "3112", /* 5: 5 - 9 */
+ "111", "111", "11111" /* 10: Start, Stop, Mid */
+};
+
+static const l_int32 UPCA_START = 10;
+static const l_int32 UPCA_STOP = 11;
+static const l_int32 UPCA_MID = 12;
+
+
+ /* ----------------------------------------------------------------- *
+ * Code128 symbology *
+ * ----------------------------------------------------------------- */
+static const char *Code128[] = {
+ "212222", "222122", "222221", "121223", "121322", /* 0 - 4 */
+ "131222", "122213", "122312", "132212", "221213", /* 5 - 9 */
+ "221312", "231212", "112232", "122132", "122231", /* 10 - 14 */
+ "113222", "123122", "123221", "223211", "221132", /* 15 - 19 */
+ "221231", "213212", "223112", "312131", "311222", /* 20 - 24 */
+ "321122", "321221", "312212", "322112", "322211", /* 25 - 29 */
+ "212123", "212321", "232121", "111323", "131123", /* 30 - 34 */
+ "131321", "112313", "132113", "132311", "211313", /* 35 - 39 */
+ "231113", "231311", "112133", "112331", "132131", /* 40 - 44 */
+ "113123", "113321", "133121", "313121", "211331", /* 45 - 49 */
+ "231131", "213113", "213311", "213131", "311123", /* 50 - 54 */
+ "311321", "331121", "312113", "312311", "332111", /* 55 - 59 */
+ "314111", "221411", "431111", "111224", "111422", /* 60 - 64 */
+ "121124", "121421", "141122", "141221", "112214", /* 65 - 69 */
+ "112412", "122114", "122411", "142112", "142211", /* 70 - 74 */
+ "241211", "221114", "413111", "241112", "134111", /* 75 - 79 */
+ "111242", "121142", "121241", "114212", "124112", /* 80 - 84 */
+ "124211", "411212", "421112", "421211", "212141", /* 85 - 89 */
+ "214121", "412121", "111143", "111341", "131141", /* 90 - 94 */
+ "114113", "114311", "411113", "411311", "113141", /* 95 - 99 */
+ "114131", "311141", "411131", "211412", "211214", /* 100 - 104 */
+ "211232", "2331112" /* 105 - 106 */
+};
+
+static const l_int32 C128_FUN_3 = 96; /* in A or B only; in C it is 96 */
+static const l_int32 C128_FUNC_2 = 97; /* in A or B only; in C it is 97 */
+static const l_int32 C128_SHIFT = 98; /* in A or B only; in C it is 98 */
+static const l_int32 C128_GOTO_C = 99; /* in A or B only; in C it is 99 */
+static const l_int32 C128_GOTO_B = 100;
+static const l_int32 C128_GOTO_A = 101;
+static const l_int32 C128_FUNC_1 = 102;
+static const l_int32 C128_START_A = 103;
+static const l_int32 C128_START_B = 104;
+static const l_int32 C128_START_C = 105;
+static const l_int32 C128_STOP = 106;
+ /* code 128 symbols are 11 units */
+static const l_int32 C128_SYMBOL_WIDTH = 11;
+
+
+
+#endif /* LEPTONICA_READBARCODE_H */
diff --git a/third_party/leptonica/windows/include/leptonica/recog.h b/third_party/leptonica/windows/include/leptonica/recog.h
new file mode 100644
index 00000000..44e6aa18
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/recog.h
@@ -0,0 +1,264 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_RECOG_H
+#define LEPTONICA_RECOG_H
+
+/*!
+ * \file recog.h
+ *
+ *
+ * This is a simple utility for training and recognizing individual
+ * machine-printed text characters. It is designed to be adapted
+ * to a particular set of character images; e.g., from a book.
+ *
+ * There are two methods of training the recognizer. In the most
+ * simple, a set of bitmaps has been labeled by some means, such
+ * a generic OCR program. This is input either one template at a time
+ * or as a pixa of templates, to a function that creates a recog.
+ * If in a pixa, the text string label must be embedded in the
+ * text field of each pix.
+ *
+ * If labeled data is not available, we start with a bootstrap
+ * recognizer (BSR) that has labeled data from a variety of sources.
+ * These images are scaled, typically to a fixed height, and then
+ * fed similarly scaled unlabeled images from the source (e.g., book),
+ * and the BSR attempts to identify them. All images that have
+ * a high enough correlation score with one of the templates in the
+ * BSR are emitted in a pixa, which now holds unscaled and labeled
+ * templates from the source. This is the generator for a book adapted
+ * recognizer (BAR).
+ *
+ * The pixa should always be thought of as the primary structure.
+ * It is the generator for the recog, because a recog is built
+ * from a pixa of unscaled images.
+ *
+ * New image templates can be added to a recog as long as it is
+ * in training mode. Once training is finished, to add templates
+ * it is necessary to extract the generating pixa, add templates
+ * to that pixa, and make a new recog. Similarly, we do not
+ * join two recog; instead, we simply join their generating pixa,
+ * and make a recog from that.
+ *
+ * To remove outliers from a pixa of labeled pix, make a recog,
+ * determine the outliers, and generate a new pixa with the
+ * outliers removed. The outliers are determined by building
+ * special templates for each character set that are scaled averages
+ * of the individual templates. Then a correlation score is found
+ * between each template and the averaged templates. There are
+ * two implementations; outliers are determined as either:
+ * (1) a template having a correlation score with its class average
+ * that is below a threshold, or
+ * (2) a template having a correlation score with its class average
+ * that is smaller than the correlation score with the average
+ * of another class.
+ * Outliers are removed from the generating pixa. Scaled averaging
+ * is only performed for determining outliers and for splitting
+ * characters; it is never used in a trained recognizer for identifying
+ * unlabeled samples.
+ *
+ * Two methods using averaged templates are provided for splitting
+ * touching characters:
+ * (1) greedy matching
+ * (2) document image decoding (DID)
+ * The DID method is the default. It is about 5x faster and
+ * possibly more accurate.
+ *
+ * Once a BAR has been made, unlabeled sample images are identified
+ * by finding the individual template in the BAR with highest
+ * correlation. The input images and images in the BAR can be
+ * represented in two ways:
+ * (1) as scanned, binarized to 1 bpp
+ * (2) as a width-normalized outline formed by thinning to a
+ * skeleton and then dilating by a fixed amount.
+ *
+ * The recog can be serialized to file and read back. The serialized
+ * version holds the templates used for correlation (which may have
+ * been modified by scaling and turning into lines from the unscaled
+ * templates), plus, for arbitrary character sets, the UTF8
+ * representation and the lookup table mapping from the character
+ * representation to index.
+ *
+ * Why do we not use averaged templates for recognition?
+ * Letterforms can take on significantly different shapes (eg.,
+ * the letters 'a' and 'g'), and it makes no sense to average these.
+ * The previous version of this utility allowed multiple recognizers
+ * to exist, but this is an unnecessary complication if recognition
+ * is done on all samples instead of on averages.
+ *
+ */
+
+#define RECOG_VERSION_NUMBER 2
+
+struct L_Recog {
+ l_int32 scalew; /*!< scale all examples to this width; */
+ /*!< use 0 prevent horizontal scaling */
+ l_int32 scaleh; /*!< scale all examples to this height; */
+ /*!< use 0 prevent vertical scaling */
+ l_int32 linew; /*!< use a value > 0 to convert the bitmap */
+ /*!< to lines of fixed width; 0 to skip */
+ l_int32 templ_use; /*!< template use: use either the average */
+ /*!< or all temmplates (L_USE_AVERAGE or */
+ /*!< L_USE_ALL) */
+ l_int32 maxarraysize; /*!< initialize container arrays to this */
+ l_int32 setsize; /*!< size of character set */
+ l_int32 threshold; /*!< for binarizing if depth > 1 */
+ l_int32 maxyshift; /*!< vertical jiggle on nominal centroid */
+ /*!< alignment; typically 0 or 1 */
+ l_int32 charset_type; /*!< one of L_ARABIC_NUMERALS, etc. */
+ l_int32 charset_size; /*!< expected number of classes in charset */
+ l_int32 min_nopad; /*!< min number of samples without padding */
+ l_int32 num_samples; /*!< number of training samples */
+ l_int32 minwidth_u; /*!< min width averaged unscaled templates */
+ l_int32 maxwidth_u; /*!< max width averaged unscaled templates */
+ l_int32 minheight_u; /*!< min height averaged unscaled templates */
+ l_int32 maxheight_u; /*!< max height averaged unscaled templates */
+ l_int32 minwidth; /*!< min width averaged scaled templates */
+ l_int32 maxwidth; /*!< max width averaged scaled templates */
+ l_int32 ave_done; /*!< set to 1 when averaged bitmaps are made */
+ l_int32 train_done; /*!< set to 1 when training is complete or */
+ /*!< identification has started */
+ l_float32 max_wh_ratio; /*!< max width/height ratio to split */
+ l_float32 max_ht_ratio; /*!< max of max/min template height ratio */
+ l_int32 min_splitw; /*!< min component width kept in splitting */
+ l_int32 max_splith; /*!< max component height kept in splitting */
+ struct Sarray *sa_text; /*!< text array for arbitrary char set */
+ struct L_Dna *dna_tochar; /*!< index-to-char lut for arbitrary charset */
+ l_int32 *centtab; /*!< table for finding centroids */
+ l_int32 *sumtab; /*!< table for finding pixel sums */
+ struct Pixaa *pixaa_u; /*!< all unscaled templates for each class */
+ struct Ptaa *ptaa_u; /*!< centroids of all unscaled templates */
+ struct Numaa *naasum_u; /*!< area of all unscaled templates */
+ struct Pixaa *pixaa; /*!< all (scaled) templates for each class */
+ struct Ptaa *ptaa; /*!< centroids of all (scaledl) templates */
+ struct Numaa *naasum; /*!< area of all (scaled) templates */
+ struct Pixa *pixa_u; /*!< averaged unscaled templates per class */
+ struct Pta *pta_u; /*!< centroids of unscaled ave. templates */
+ struct Numa *nasum_u; /*!< area of unscaled averaged templates */
+ struct Pixa *pixa; /*!< averaged (scaled) templates per class */
+ struct Pta *pta; /*!< centroids of (scaled) ave. templates */
+ struct Numa *nasum; /*!< area of (scaled) averaged templates */
+ struct Pixa *pixa_tr; /*!< all input training images */
+ struct Pixa *pixadb_ave; /*!< unscaled and scaled averaged bitmaps */
+ struct Pixa *pixa_id; /*!< input images for identifying */
+ struct Pix *pixdb_ave; /*!< debug: best match of input against ave. */
+ struct Pix *pixdb_range; /*!< debug: best matches within range */
+ struct Pixa *pixadb_boot; /*!< debug: bootstrap training results */
+ struct Pixa *pixadb_split; /*!< debug: splitting results */
+ struct L_Bmf *bmf; /*!< bmf fonts */
+ l_int32 bmf_size; /*!< font size of bmf; default is 6 pt */
+ struct L_Rdid *did; /*!< temp data used for image decoding */
+ struct L_Rch *rch; /*!< temp data used for holding best char */
+ struct L_Rcha *rcha; /*!< temp data used for array of best chars */
+};
+typedef struct L_Recog L_RECOG;
+
+/*!
+ * Data returned from correlation matching on a single character
+ */
+struct L_Rch {
+ l_int32 index; /*!< index of best template */
+ l_float32 score; /*!< correlation score of best template */
+ char *text; /*!< character string of best template */
+ l_int32 sample; /*!< index of best sample (within the best */
+ /*!< template class, if all samples are used) */
+ l_int32 xloc; /*!< x-location of template (delx + shiftx) */
+ l_int32 yloc; /*!< y-location of template (dely + shifty) */
+ l_int32 width; /*!< width of best template */
+};
+typedef struct L_Rch L_RCH;
+
+/*!
+ * Data returned from correlation matching on an array of characters
+ */
+struct L_Rcha {
+ struct Numa *naindex; /*!< indices of best templates */
+ struct Numa *nascore; /*!< correlation scores of best templates */
+ struct Sarray *satext; /*!< character strings of best templates */
+ struct Numa *nasample; /*!< indices of best samples */
+ struct Numa *naxloc; /*!< x-locations of templates (delx + shiftx) */
+ struct Numa *nayloc; /*!< y-locations of templates (dely + shifty) */
+ struct Numa *nawidth; /*!< widths of best templates */
+};
+typedef struct L_Rcha L_RCHA;
+
+/*!
+ * Data used for decoding a line of characters.
+ */
+struct L_Rdid {
+ struct Pix *pixs; /*!< clone of pix to be decoded */
+ l_int32 **counta; /*!< count array for each averaged template */
+ l_int32 **delya; /*!< best y-shift array per average template */
+ l_int32 narray; /*!< number of averaged templates */
+ l_int32 size; /*!< size of count array (width of pixs) */
+ l_int32 *setwidth; /*!< setwidths for each template */
+ struct Numa *nasum; /*!< pixel count in pixs by column */
+ struct Numa *namoment; /*!< first moment of pixels in pixs by cols */
+ l_int32 fullarrays; /*!< 1 if full arrays are made; 0 otherwise */
+ l_float32 *beta; /*!< channel coeffs for template fg term */
+ l_float32 *gamma; /*!< channel coeffs for bit-and term */
+ l_float32 *trellisscore; /*!< score on trellis */
+ l_int32 *trellistempl; /*!< template on trellis (for backtrack) */
+ struct Numa *natempl; /*!< indices of best path templates */
+ struct Numa *naxloc; /*!< x locations of best path templates */
+ struct Numa *nadely; /*!< y locations of best path templates */
+ struct Numa *nawidth; /*!< widths of best path templates */
+ struct Boxa *boxa; /*!< Viterbi result for splitting input pixs */
+ struct Numa *nascore; /*!< correlation scores: best path templates */
+ struct Numa *natempl_r; /*!< indices of best rescored templates */
+ struct Numa *nasample_r; /*!< samples of best scored templates */
+ struct Numa *naxloc_r; /*!< x locations of best rescoredtemplates */
+ struct Numa *nadely_r; /*!< y locations of best rescoredtemplates */
+ struct Numa *nawidth_r; /*!< widths of best rescoredtemplates */
+ struct Numa *nascore_r; /*!< correlation scores: rescored templates */
+};
+typedef struct L_Rdid L_RDID;
+
+
+/*-------------------------------------------------------------------------*
+ * Flags for describing limited character sets *
+ *-------------------------------------------------------------------------*/
+/*! Character Set */
+enum {
+ L_UNKNOWN = 0, /*!< character set type is not specified */
+ L_ARABIC_NUMERALS = 1, /*!< 10 digits */
+ L_LC_ROMAN_NUMERALS = 2, /*!< 7 lower-case letters (i,v,x,l,c,d,m) */
+ L_UC_ROMAN_NUMERALS = 3, /*!< 7 upper-case letters (I,V,X,L,C,D,M) */
+ L_LC_ALPHA = 4, /*!< 26 lower-case letters */
+ L_UC_ALPHA = 5 /*!< 26 upper-case letters */
+};
+
+/*-------------------------------------------------------------------------*
+ * Flags for selecting between using average and all templates: *
+ * recog->templ_use *
+ *-------------------------------------------------------------------------*/
+/*! Template Select */
+enum {
+ L_USE_ALL_TEMPLATES = 0, /*!< use all templates; default */
+ L_USE_AVERAGE_TEMPLATES = 1 /*!< use average templates; special cases */
+};
+
+#endif /* LEPTONICA_RECOG_H */
diff --git a/third_party/leptonica/windows/include/leptonica/regutils.h b/third_party/leptonica/windows/include/leptonica/regutils.h
new file mode 100644
index 00000000..2f1d5e4a
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/regutils.h
@@ -0,0 +1,141 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_REGUTILS_H
+#define LEPTONICA_REGUTILS_H
+
+/*!
+ * \file regutils.h
+ *
+ *
+ * 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 outputs and testing for identity
+ * // These files can be anything, of course.
+ * regTestCheckFile(rp, ); // 2
+ * regTestCheckFile(rp, ); // 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);
+ *
+ */
+
+/*----------------------------------------------------------------------------*
+ * Regression test parameter packer *
+ *----------------------------------------------------------------------------*/
+
+/*! Regression test parameter packer */
+struct L_RegParams
+{
+ FILE *fp; /*!< stream to temporary output file for compare mode */
+ char *testname; /*!< name of test, without '_reg' */
+ char *tempfile; /*!< name of temp file for compare mode output */
+ l_int32 mode; /*!< generate, compare or display */
+ l_int32 index; /*!< index into saved files for this test; 0-based */
+ l_int32 success; /*!< overall result of the test */
+ l_int32 display; /*!< 1 if in display mode; 0 otherwise */
+ L_TIMER tstart; /*!< marks beginning of the reg test */
+};
+typedef struct L_RegParams L_REGPARAMS;
+
+
+ /*! Running modes for the test */
+/*! Regtest Mode */
+enum {
+ L_REG_GENERATE = 0,
+ L_REG_COMPARE = 1,
+ L_REG_DISPLAY = 2
+};
+
+
+#endif /* LEPTONICA_REGUTILS_H */
+
diff --git a/third_party/leptonica/windows/include/leptonica/stack.h b/third_party/leptonica/windows/include/leptonica/stack.h
new file mode 100644
index 00000000..4fa61141
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/stack.h
@@ -0,0 +1,70 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_STACK_H
+#define LEPTONICA_STACK_H
+
+/*!
+ * \file stack.h
+ *
+ *
+ * Expandable pointer stack for arbitrary void* data.
+ *
+ * The L_Stack is an array of void * ptrs, onto which arbitrary
+ * objects can be stored. At any time, the number of
+ * stored objects is stack->n. The object at the bottom
+ * of the stack is at array[0]; the object at the top of
+ * the stack is at array[n-1]. New objects are added
+ * to the top of the stack, at the first available location,
+ * which is array[n]. Objects are removed from the top of the
+ * stack. When an attempt is made to remove an object from an
+ * empty stack, the result is null. When the stack becomes
+ * filled, so that n = nalloc, the size is doubled.
+ *
+ * The auxiliary stack can be used to store and remove
+ * objects for re-use. It must be created by a separate
+ * call to pstackCreate(). [Just imagine the chaos if
+ * pstackCreate() created the auxiliary stack!]
+ * pstackDestroy() checks for the auxiliary stack and removes it.
+ *
+ */
+
+
+ /*! Expandable pointer stack for arbitrary void* data.
+ * Note that array[n] is the first null ptr in the array
+ */
+struct L_Stack
+{
+ l_int32 nalloc; /*!< size of ptr array */
+ l_int32 n; /*!< number of stored elements */
+ void **array; /*!< ptr array */
+ struct L_Stack *auxstack; /*!< auxiliary stack */
+};
+typedef struct L_Stack L_STACK;
+
+
+#endif /* LEPTONICA_STACK_H */
+
diff --git a/third_party/leptonica/windows/include/leptonica/stringcode.h b/third_party/leptonica/windows/include/leptonica/stringcode.h
new file mode 100644
index 00000000..4510bdb0
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/stringcode.h
@@ -0,0 +1,61 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_STRINGCODE_H
+#define LEPTONICA_STRINGCODE_H
+
+/*!
+ * \file stringcode.h
+ *
+ * Data structure to hold accumulating generated code for storing
+ * and extracting serializable leptonica objects (e.g., pixa, recog).
+ *
+ * Also a flag for selecting a string from the L_GenAssoc struct
+ * in stringcode.
+ */
+
+struct L_StrCode
+{
+ l_int32 fileno; /*!< index for function and output file names */
+ l_int32 ifunc; /*!< index into struct currently being stored */
+ SARRAY *function; /*!< store case code for extraction */
+ SARRAY *data; /*!< store base64 encoded data as strings */
+ SARRAY *descr; /*!< store line in description table */
+ l_int32 n; /*!< number of data strings */
+};
+typedef struct L_StrCode L_STRCODE;
+
+
+ /*! Select string in stringcode for a specific serializable data type */
+/*! Stringcode Select */
+enum {
+ L_STR_TYPE = 0, /*!< typedef for the data type */
+ L_STR_NAME = 1, /*!< name of the data type */
+ L_STR_READER = 2, /*!< reader to get the data type from file */
+ L_STR_MEMREADER = 3 /*!< reader to get the compressed string in memory */
+};
+
+#endif /* LEPTONICA_STRINGCODE_H */
diff --git a/third_party/leptonica/windows/include/leptonica/sudoku.h b/third_party/leptonica/windows/include/leptonica/sudoku.h
new file mode 100644
index 00000000..5abb7cbc
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/sudoku.h
@@ -0,0 +1,77 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef SUDOKU_H_INCLUDED
+#define SUDOKU_H_INCLUDED
+
+/*!
+ * \file sudoku.h
+ *
+ *
+ * The L_Sudoku holds all the information of the current state.
+ *
+ * The input to sudokuCreate() is a file with any number of lines
+ * starting with '#', followed by 9 lines consisting of 9 numbers
+ * in each line. These have the known values and use 0 for the unknowns.
+ * Blank lines are ignored.
+ *
+ * The %locs array holds the indices of the unknowns, numbered
+ * left-to-right and top-to-bottom from 0 to 80. The array size
+ * is initialized to %num. %current is the index into the %locs
+ * array of the current guess: locs[current].
+ *
+ * The %state array is used to determine the validity of each guess.
+ * It is of size 81, and is initialized by setting the unknowns to 0
+ * and the knowns to their input values.
+ *
+ */
+
+struct L_Sudoku
+{
+ l_int32 num; /*!< number of unknowns */
+ l_int32 *locs; /*!< location of unknowns */
+ l_int32 current; /*!< index into %locs of current location */
+ l_int32 *init; /*!< initial state, with 0 representing */
+ /*!< the unknowns */
+ l_int32 *state; /*!< present state, including inits and */
+ /*!< guesses of unknowns up to %current */
+ l_int32 nguess; /*!< shows current number of guesses */
+ l_int32 finished; /*!< set to 1 when solved */
+ l_int32 failure; /*!< set to 1 if no solution is possible */
+};
+typedef struct L_Sudoku L_SUDOKU;
+
+
+ /*! For printing out array data */
+/*! Sudoku Output */
+enum {
+ L_SUDOKU_INIT = 0,
+ L_SUDOKU_STATE = 1
+};
+
+#endif /* SUDOKU_H_INCLUDED */
+
+
diff --git a/third_party/leptonica/windows/include/leptonica/watershed.h b/third_party/leptonica/windows/include/leptonica/watershed.h
new file mode 100644
index 00000000..d6b20775
--- /dev/null
+++ b/third_party/leptonica/windows/include/leptonica/watershed.h
@@ -0,0 +1,64 @@
+/*====================================================================*
+ - Copyright (C) 2001 Leptonica. All rights reserved.
+ -
+ - Redistribution and use in source and binary forms, with or without
+ - modification, are permitted provided that the following conditions
+ - are met:
+ - 1. Redistributions of source code must retain the above copyright
+ - notice, this list of conditions and the following disclaimer.
+ - 2. Redistributions in binary form must reproduce the above
+ - copyright notice, this list of conditions and the following
+ - disclaimer in the documentation and/or other materials
+ - provided with the distribution.
+ -
+ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
+ - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *====================================================================*/
+
+#ifndef LEPTONICA_WATERSHED_H
+#define LEPTONICA_WATERSHED_H
+
+/*!
+ * \file watershed.h
+ *
+ * Simple data structure to hold watershed data.
+ * All data here is owned by the L_WShed and must be freed.
+ */
+
+/*! Simple data structure to hold watershed data. */
+struct L_WShed
+{
+ struct Pix *pixs; /*!< clone of input 8 bpp pixs */
+ struct Pix *pixm; /*!< clone of input 1 bpp seed (marker) pixm */
+ l_int32 mindepth; /*!< minimum depth allowed for a watershed */
+ struct Pix *pixlab; /*!< 16 bpp label pix */
+ struct Pix *pixt; /*!< scratch pix for computing wshed regions */
+ void **lines8; /*!< line ptrs for pixs */
+ void **linem1; /*!< line ptrs for pixm */
+ void **linelab32; /*!< line ptrs for pixlab */
+ void **linet1; /*!< line ptrs for pixt */
+ struct Pixa *pixad; /*!< result: 1 bpp pixa of watersheds */
+ struct Pta *ptas; /*!< pta of initial seed pixels */
+ struct Numa *nasi; /*!< numa of seed indicators; 0 if completed */
+ struct Numa *nash; /*!< numa of initial seed heights */
+ struct Numa *namh; /*!< numa of initial minima heights */
+ struct Numa *nalevels; /*!< result: numa of watershed levels */
+ l_int32 nseeds; /*!< number of seeds (markers) */
+ l_int32 nother; /*!< number of minima different from seeds */
+ l_int32 *lut; /*!< lut for pixel indices */
+ struct Numa **links; /*!< back-links into lut, for updates */
+ l_int32 arraysize; /*!< size of links array */
+ l_int32 debug; /*!< set to 1 for debug output */
+};
+typedef struct L_WShed L_WSHED;
+
+#endif /* LEPTONICA_WATERSHED_H */
diff --git a/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaConfig-version.cmake b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaConfig-version.cmake
new file mode 100644
index 00000000..60ed0465
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaConfig-version.cmake
@@ -0,0 +1,14 @@
+set(Leptonica_VERSION 1.83.0)
+set(PACKAGE_VERSION ${Leptonica_VERSION})
+
+set(PACKAGE_VERSION_EXACT False)
+set(PACKAGE_VERSION_COMPATIBLE False)
+
+if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT True)
+ set(PACKAGE_VERSION_COMPATIBLE True)
+endif()
+
+if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE True)
+endif()
diff --git a/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaConfig.cmake b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaConfig.cmake
new file mode 100644
index 00000000..4c69a978
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaConfig.cmake
@@ -0,0 +1,46 @@
+# ===================================================================================
+# The Leptonica CMake configuration file
+#
+# ** File generated automatically, do not modify **
+#
+# Usage from an external project:
+# In your CMakeLists.txt, add these lines:
+#
+# find_package(Leptonica REQUIRED)
+# include_directories(${Leptonica_INCLUDE_DIRS})
+# target_link_libraries(MY_TARGET_NAME ${Leptonica_LIBRARIES})
+#
+# This file will define the following variables:
+# - Leptonica_LIBRARIES : The list of all imported targets for OpenCV modules.
+# - Leptonica_INCLUDE_DIRS : The Leptonica include directories.
+# - Leptonica_VERSION : The version of this Leptonica build: "1.83.0"
+# - Leptonica_VERSION_MAJOR : Major version part of Leptonica_VERSION: "1"
+# - Leptonica_VERSION_MINOR : Minor version part of Leptonica_VERSION: "83"
+# - Leptonica_VERSION_PATCH : Patch version part of Leptonica_VERSION: "0"
+#
+# ===================================================================================
+
+include(${CMAKE_CURRENT_LIST_DIR}/LeptonicaTargets.cmake)
+
+# ======================================================
+# Version variables:
+# ======================================================
+
+SET(Leptonica_VERSION 1.83.0)
+SET(Leptonica_VERSION_MAJOR 1)
+SET(Leptonica_VERSION_MINOR 83)
+SET(Leptonica_VERSION_PATCH 0)
+SET(Leptonica_FOUND 1)
+
+# ======================================================
+# Include directories to add to the user project:
+# ======================================================
+
+# Provide the include directories to the caller
+set(Leptonica_INCLUDE_DIRS "D:/code_app/third_party/leptonica/windows/leptonica-master/build/release/include;D:/code_app/third_party/leptonica/windows/leptonica-master/build/release/include/leptonica")
+
+# ====================================================================
+# Link libraries:
+# ====================================================================
+
+set(Leptonica_LIBRARIES leptonica)
diff --git a/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaTargets-release.cmake b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaTargets-release.cmake
new file mode 100644
index 00000000..b5ea19fc
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaTargets-release.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "Release".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "leptonica" for configuration "Release"
+set_property(TARGET leptonica APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(leptonica PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
+ IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/leptonica-1.83.0.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS leptonica )
+list(APPEND _IMPORT_CHECK_FILES_FOR_leptonica "${_IMPORT_PREFIX}/lib/leptonica-1.83.0.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaTargets.cmake b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaTargets.cmake
new file mode 100644
index 00000000..58048a06
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x64/cmake/leptonica/LeptonicaTargets.cmake
@@ -0,0 +1,90 @@
+# Generated by CMake
+
+if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
+ message(FATAL_ERROR "CMake >= 2.6.0 required")
+endif()
+cmake_policy(PUSH)
+cmake_policy(VERSION 2.6...3.21)
+#----------------------------------------------------------------
+# Generated CMake target import file.
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Protect against multiple inclusion, which would fail when already imported targets are added once more.
+set(_targetsDefined)
+set(_targetsNotDefined)
+set(_expectedTargets)
+foreach(_expectedTarget leptonica)
+ list(APPEND _expectedTargets ${_expectedTarget})
+ if(NOT TARGET ${_expectedTarget})
+ list(APPEND _targetsNotDefined ${_expectedTarget})
+ endif()
+ if(TARGET ${_expectedTarget})
+ list(APPEND _targetsDefined ${_expectedTarget})
+ endif()
+endforeach()
+if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
+ unset(_targetsDefined)
+ unset(_targetsNotDefined)
+ unset(_expectedTargets)
+ set(CMAKE_IMPORT_FILE_VERSION)
+ cmake_policy(POP)
+ return()
+endif()
+if(NOT "${_targetsDefined}" STREQUAL "")
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
+endif()
+unset(_targetsDefined)
+unset(_targetsNotDefined)
+unset(_expectedTargets)
+
+
+# Compute the installation prefix relative to this file.
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+ set(_IMPORT_PREFIX "")
+endif()
+
+# Create imported target leptonica
+add_library(leptonica STATIC IMPORTED)
+
+# Load information for each installed configuration.
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+file(GLOB CONFIG_FILES "${_DIR}/LeptonicaTargets-*.cmake")
+foreach(f ${CONFIG_FILES})
+ include(${f})
+endforeach()
+
+# Cleanup temporary variables.
+set(_IMPORT_PREFIX)
+
+# Loop over all imported files and verify that they actually exist
+foreach(target ${_IMPORT_CHECK_TARGETS} )
+ foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
+ if(NOT EXISTS "${file}" )
+ message(FATAL_ERROR "The imported target \"${target}\" references the file
+ \"${file}\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \"${CMAKE_CURRENT_LIST_FILE}\"
+but not all the files it references.
+")
+ endif()
+ endforeach()
+ unset(_IMPORT_CHECK_FILES_FOR_${target})
+endforeach()
+unset(_IMPORT_CHECK_TARGETS)
+
+# This file does not depend on other imported targets which have
+# been exported from the same project but in a separate export set.
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
+cmake_policy(POP)
diff --git a/third_party/leptonica/windows/lib/x64/leptonica-1.83.0.lib b/third_party/leptonica/windows/lib/x64/leptonica-1.83.0.lib
new file mode 100644
index 00000000..105f9d2e
Binary files /dev/null and b/third_party/leptonica/windows/lib/x64/leptonica-1.83.0.lib differ
diff --git a/third_party/leptonica/windows/lib/x64/leptonica-1.83.0d.lib b/third_party/leptonica/windows/lib/x64/leptonica-1.83.0d.lib
new file mode 100644
index 00000000..9f476aa1
Binary files /dev/null and b/third_party/leptonica/windows/lib/x64/leptonica-1.83.0d.lib differ
diff --git a/third_party/leptonica/windows/lib/x64/pkgconfig/lept.pc b/third_party/leptonica/windows/lib/x64/pkgconfig/lept.pc
new file mode 100644
index 00000000..1e671000
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x64/pkgconfig/lept.pc
@@ -0,0 +1,11 @@
+prefix=D:/code_app/third_party/leptonica/windows/leptonica-master/build/release
+exec_prefix=${prefix}/bin
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: leptonica
+Description: An open source C library for efficient image processing and image analysis operations
+Version: 1.83.0
+Libs: -L${libdir} -lleptonica-1.83.0
+Libs.private: -lm
+Cflags: -I${includedir} -I${includedir}/leptonica
diff --git a/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaConfig-version.cmake b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaConfig-version.cmake
new file mode 100644
index 00000000..60ed0465
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaConfig-version.cmake
@@ -0,0 +1,14 @@
+set(Leptonica_VERSION 1.83.0)
+set(PACKAGE_VERSION ${Leptonica_VERSION})
+
+set(PACKAGE_VERSION_EXACT False)
+set(PACKAGE_VERSION_COMPATIBLE False)
+
+if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT True)
+ set(PACKAGE_VERSION_COMPATIBLE True)
+endif()
+
+if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE True)
+endif()
diff --git a/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaConfig.cmake b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaConfig.cmake
new file mode 100644
index 00000000..4c69a978
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaConfig.cmake
@@ -0,0 +1,46 @@
+# ===================================================================================
+# The Leptonica CMake configuration file
+#
+# ** File generated automatically, do not modify **
+#
+# Usage from an external project:
+# In your CMakeLists.txt, add these lines:
+#
+# find_package(Leptonica REQUIRED)
+# include_directories(${Leptonica_INCLUDE_DIRS})
+# target_link_libraries(MY_TARGET_NAME ${Leptonica_LIBRARIES})
+#
+# This file will define the following variables:
+# - Leptonica_LIBRARIES : The list of all imported targets for OpenCV modules.
+# - Leptonica_INCLUDE_DIRS : The Leptonica include directories.
+# - Leptonica_VERSION : The version of this Leptonica build: "1.83.0"
+# - Leptonica_VERSION_MAJOR : Major version part of Leptonica_VERSION: "1"
+# - Leptonica_VERSION_MINOR : Minor version part of Leptonica_VERSION: "83"
+# - Leptonica_VERSION_PATCH : Patch version part of Leptonica_VERSION: "0"
+#
+# ===================================================================================
+
+include(${CMAKE_CURRENT_LIST_DIR}/LeptonicaTargets.cmake)
+
+# ======================================================
+# Version variables:
+# ======================================================
+
+SET(Leptonica_VERSION 1.83.0)
+SET(Leptonica_VERSION_MAJOR 1)
+SET(Leptonica_VERSION_MINOR 83)
+SET(Leptonica_VERSION_PATCH 0)
+SET(Leptonica_FOUND 1)
+
+# ======================================================
+# Include directories to add to the user project:
+# ======================================================
+
+# Provide the include directories to the caller
+set(Leptonica_INCLUDE_DIRS "D:/code_app/third_party/leptonica/windows/leptonica-master/build/release/include;D:/code_app/third_party/leptonica/windows/leptonica-master/build/release/include/leptonica")
+
+# ====================================================================
+# Link libraries:
+# ====================================================================
+
+set(Leptonica_LIBRARIES leptonica)
diff --git a/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaTargets-release.cmake b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaTargets-release.cmake
new file mode 100644
index 00000000..b5ea19fc
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaTargets-release.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "Release".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "leptonica" for configuration "Release"
+set_property(TARGET leptonica APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(leptonica PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
+ IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/leptonica-1.83.0.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS leptonica )
+list(APPEND _IMPORT_CHECK_FILES_FOR_leptonica "${_IMPORT_PREFIX}/lib/leptonica-1.83.0.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaTargets.cmake b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaTargets.cmake
new file mode 100644
index 00000000..58048a06
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x86/cmake/leptonica/LeptonicaTargets.cmake
@@ -0,0 +1,90 @@
+# Generated by CMake
+
+if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
+ message(FATAL_ERROR "CMake >= 2.6.0 required")
+endif()
+cmake_policy(PUSH)
+cmake_policy(VERSION 2.6...3.21)
+#----------------------------------------------------------------
+# Generated CMake target import file.
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Protect against multiple inclusion, which would fail when already imported targets are added once more.
+set(_targetsDefined)
+set(_targetsNotDefined)
+set(_expectedTargets)
+foreach(_expectedTarget leptonica)
+ list(APPEND _expectedTargets ${_expectedTarget})
+ if(NOT TARGET ${_expectedTarget})
+ list(APPEND _targetsNotDefined ${_expectedTarget})
+ endif()
+ if(TARGET ${_expectedTarget})
+ list(APPEND _targetsDefined ${_expectedTarget})
+ endif()
+endforeach()
+if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
+ unset(_targetsDefined)
+ unset(_targetsNotDefined)
+ unset(_expectedTargets)
+ set(CMAKE_IMPORT_FILE_VERSION)
+ cmake_policy(POP)
+ return()
+endif()
+if(NOT "${_targetsDefined}" STREQUAL "")
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
+endif()
+unset(_targetsDefined)
+unset(_targetsNotDefined)
+unset(_expectedTargets)
+
+
+# Compute the installation prefix relative to this file.
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+ set(_IMPORT_PREFIX "")
+endif()
+
+# Create imported target leptonica
+add_library(leptonica STATIC IMPORTED)
+
+# Load information for each installed configuration.
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+file(GLOB CONFIG_FILES "${_DIR}/LeptonicaTargets-*.cmake")
+foreach(f ${CONFIG_FILES})
+ include(${f})
+endforeach()
+
+# Cleanup temporary variables.
+set(_IMPORT_PREFIX)
+
+# Loop over all imported files and verify that they actually exist
+foreach(target ${_IMPORT_CHECK_TARGETS} )
+ foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
+ if(NOT EXISTS "${file}" )
+ message(FATAL_ERROR "The imported target \"${target}\" references the file
+ \"${file}\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \"${CMAKE_CURRENT_LIST_FILE}\"
+but not all the files it references.
+")
+ endif()
+ endforeach()
+ unset(_IMPORT_CHECK_FILES_FOR_${target})
+endforeach()
+unset(_IMPORT_CHECK_TARGETS)
+
+# This file does not depend on other imported targets which have
+# been exported from the same project but in a separate export set.
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
+cmake_policy(POP)
diff --git a/third_party/leptonica/windows/lib/x86/leptonica-1.83.0.lib b/third_party/leptonica/windows/lib/x86/leptonica-1.83.0.lib
new file mode 100644
index 00000000..1e5969eb
Binary files /dev/null and b/third_party/leptonica/windows/lib/x86/leptonica-1.83.0.lib differ
diff --git a/third_party/leptonica/windows/lib/x86/leptonica-1.83.0d.lib b/third_party/leptonica/windows/lib/x86/leptonica-1.83.0d.lib
new file mode 100644
index 00000000..fde0f1fb
Binary files /dev/null and b/third_party/leptonica/windows/lib/x86/leptonica-1.83.0d.lib differ
diff --git a/third_party/leptonica/windows/lib/x86/pkgconfig/lept.pc b/third_party/leptonica/windows/lib/x86/pkgconfig/lept.pc
new file mode 100644
index 00000000..1e671000
--- /dev/null
+++ b/third_party/leptonica/windows/lib/x86/pkgconfig/lept.pc
@@ -0,0 +1,11 @@
+prefix=D:/code_app/third_party/leptonica/windows/leptonica-master/build/release
+exec_prefix=${prefix}/bin
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: leptonica
+Description: An open source C library for efficient image processing and image analysis operations
+Version: 1.83.0
+Libs: -L${libdir} -lleptonica-1.83.0
+Libs.private: -lm
+Cflags: -I${includedir} -I${includedir}/leptonica
diff --git a/third_party/ocr/tesseract-ocr/windows/include/tesseract/baseapi.h b/third_party/ocr/tesseract-ocr/windows/include/tesseract/baseapi.h
index 5e1e4830..dd9fe4a2 100644
--- a/third_party/ocr/tesseract-ocr/windows/include/tesseract/baseapi.h
+++ b/third_party/ocr/tesseract-ocr/windows/include/tesseract/baseapi.h
@@ -27,7 +27,7 @@
#include "resultiterator.h"
#include "unichar.h"
-#include "version.h"
+#include
#include
#include // for std::vector
diff --git a/third_party/ocr/tesseract-ocr/windows/include/tesseract/version.h b/third_party/ocr/tesseract-ocr/windows/include/tesseract/version.h
index 6bac5d66..ac263972 100644
--- a/third_party/ocr/tesseract-ocr/windows/include/tesseract/version.h
+++ b/third_party/ocr/tesseract-ocr/windows/include/tesseract/version.h
@@ -18,16 +18,16 @@
// clang-format off
-#define TESSERACT_MAJOR_VERSION @GENERIC_MAJOR_VERSION@
-#define TESSERACT_MINOR_VERSION @GENERIC_MINOR_VERSION@
-#define TESSERACT_MICRO_VERSION @GENERIC_MICRO_VERSION@
+#define TESSERACT_MAJOR_VERSION 5
+#define TESSERACT_MINOR_VERSION 2
+#define TESSERACT_MICRO_VERSION 0
#define TESSERACT_VERSION \
(TESSERACT_MAJOR_VERSION << 16 | \
TESSERACT_MINOR_VERSION << 8 | \
TESSERACT_MICRO_VERSION)
-#define TESSERACT_VERSION_STR "@PACKAGE_VERSION@"
+#define TESSERACT_VERSION_STR "5.2.0"
// clang-format on
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractConfig.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractConfig.cmake
new file mode 100644
index 00000000..8ec1ca3c
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractConfig.cmake
@@ -0,0 +1,63 @@
+# ===================================================================================
+# The Tesseract CMake configuration file
+#
+# ** File generated automatically, do not modify **
+#
+# Usage from an external project:
+# In your CMakeLists.txt, add these lines:
+#
+# find_package(Tesseract REQUIRED)
+# target_link_libraries(MY_TARGET_NAME Tesseract::libtesseract)
+#
+# This file will define the following variables:
+# - Tesseract_LIBRARIES : The list of all imported targets.
+# - Tesseract_INCLUDE_DIRS : The Tesseract include directories.
+# - Tesseract_LIBRARY_DIRS : The Tesseract library directories.
+# - Tesseract_VERSION : The version of this Tesseract build: "5.2.0"
+# - Tesseract_VERSION_MAJOR : Major version part of Tesseract_VERSION: "5"
+# - Tesseract_VERSION_MINOR : Minor version part of Tesseract_VERSION: "2"
+# - Tesseract_VERSION_PATCH : Patch version part of Tesseract_VERSION: "0"
+#
+# ===================================================================================
+
+include(CMakeFindDependencyMacro)
+find_dependency(Leptonica)
+
+include(${CMAKE_CURRENT_LIST_DIR}/TesseractTargets.cmake)
+
+
+####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
+####### Any changes to this file will be overwritten by the next CMake run ####
+####### The input file was TesseractConfig.cmake.in ########
+
+get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
+
+macro(set_and_check _var _file)
+ set(${_var} "${_file}")
+ if(NOT EXISTS "${_file}")
+ message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
+ endif()
+endmacro()
+
+macro(check_required_components _NAME)
+ foreach(comp ${${_NAME}_FIND_COMPONENTS})
+ if(NOT ${_NAME}_${comp}_FOUND)
+ if(${_NAME}_FIND_REQUIRED_${comp})
+ set(${_NAME}_FOUND FALSE)
+ endif()
+ endif()
+ endforeach()
+endmacro()
+
+####################################################################################
+
+SET(Tesseract_VERSION 5.2.0)
+SET(Tesseract_VERSION_MAJOR 5)
+SET(Tesseract_VERSION_MINOR 2)
+SET(Tesseract_VERSION_PATCH 0)
+
+set_and_check(Tesseract_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include")
+set_and_check(Tesseract_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")
+set(Tesseract_LIBRARIES tesseract52)
+
+check_required_components(Tesseract)
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractConfigVersion.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractConfigVersion.cmake
new file mode 100644
index 00000000..577f0733
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractConfigVersion.cmake
@@ -0,0 +1,70 @@
+# This is a basic version file for the Config-mode of find_package().
+# It is used by write_basic_package_version_file() as input file for configure_file()
+# to create a version-file which can be installed along a config.cmake file.
+#
+# The created file sets PACKAGE_VERSION_EXACT if the current version string and
+# the requested version string are exactly the same and it sets
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
+# but only if the requested major version is the same as the current one.
+# The variable CVF_VERSION must be set before calling configure_file().
+
+
+set(PACKAGE_VERSION "5.2.0")
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+
+ if("5.2.0" MATCHES "^([0-9]+)\\.")
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
+ endif()
+ else()
+ set(CVF_VERSION_MAJOR "5.2.0")
+ endif()
+
+ if(PACKAGE_FIND_VERSION_RANGE)
+ # both endpoints of the range must have the expected major version
+ math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
+ if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+ AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+ else()
+ if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+ endif()
+endif()
+
+
+# if the installed project requested no architecture check, don't perform the check
+if("FALSE")
+ return()
+endif()
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
+ return()
+endif()
+
+# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
+ math(EXPR installedBits "8 * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractTargets-release.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractTargets-release.cmake
new file mode 100644
index 00000000..8e620af9
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractTargets-release.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "Release".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "Tesseract::libtesseract" for configuration "Release"
+set_property(TARGET Tesseract::libtesseract APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Tesseract::libtesseract PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
+ IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/tesseract52.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS Tesseract::libtesseract )
+list(APPEND _IMPORT_CHECK_FILES_FOR_Tesseract::libtesseract "${_IMPORT_PREFIX}/lib/tesseract52.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractTargets.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractTargets.cmake
new file mode 100644
index 00000000..6a575bbe
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x64/cmake/tesseract/TesseractTargets.cmake
@@ -0,0 +1,98 @@
+# Generated by CMake
+
+if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
+ message(FATAL_ERROR "CMake >= 2.6.0 required")
+endif()
+cmake_policy(PUSH)
+cmake_policy(VERSION 2.6...3.21)
+#----------------------------------------------------------------
+# Generated CMake target import file.
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Protect against multiple inclusion, which would fail when already imported targets are added once more.
+set(_targetsDefined)
+set(_targetsNotDefined)
+set(_expectedTargets)
+foreach(_expectedTarget Tesseract::libtesseract)
+ list(APPEND _expectedTargets ${_expectedTarget})
+ if(NOT TARGET ${_expectedTarget})
+ list(APPEND _targetsNotDefined ${_expectedTarget})
+ endif()
+ if(TARGET ${_expectedTarget})
+ list(APPEND _targetsDefined ${_expectedTarget})
+ endif()
+endforeach()
+if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
+ unset(_targetsDefined)
+ unset(_targetsNotDefined)
+ unset(_expectedTargets)
+ set(CMAKE_IMPORT_FILE_VERSION)
+ cmake_policy(POP)
+ return()
+endif()
+if(NOT "${_targetsDefined}" STREQUAL "")
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
+endif()
+unset(_targetsDefined)
+unset(_targetsNotDefined)
+unset(_expectedTargets)
+
+
+# Compute the installation prefix relative to this file.
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+ set(_IMPORT_PREFIX "")
+endif()
+
+# Create imported target Tesseract::libtesseract
+add_library(Tesseract::libtesseract STATIC IMPORTED)
+
+set_target_properties(Tesseract::libtesseract PROPERTIES
+ INTERFACE_LINK_LIBRARIES "\$;leptonica"
+)
+
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
+endif()
+
+# Load information for each installed configuration.
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+file(GLOB CONFIG_FILES "${_DIR}/TesseractTargets-*.cmake")
+foreach(f ${CONFIG_FILES})
+ include(${f})
+endforeach()
+
+# Cleanup temporary variables.
+set(_IMPORT_PREFIX)
+
+# Loop over all imported files and verify that they actually exist
+foreach(target ${_IMPORT_CHECK_TARGETS} )
+ foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
+ if(NOT EXISTS "${file}" )
+ message(FATAL_ERROR "The imported target \"${target}\" references the file
+ \"${file}\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \"${CMAKE_CURRENT_LIST_FILE}\"
+but not all the files it references.
+")
+ endif()
+ endforeach()
+ unset(_IMPORT_CHECK_FILES_FOR_${target})
+endforeach()
+unset(_IMPORT_CHECK_TARGETS)
+
+# This file does not depend on other imported targets which have
+# been exported from the same project but in a separate export set.
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
+cmake_policy(POP)
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x64/pkgconfig/tesseract.pc b/third_party/ocr/tesseract-ocr/windows/lib/x64/pkgconfig/tesseract.pc
new file mode 100644
index 00000000..c37b6143
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x64/pkgconfig/tesseract.pc
@@ -0,0 +1,13 @@
+prefix=D:/code_app/third_party/ocr/tesseract-ocr/windows/tesseract-main/build/release
+exec_prefix=${prefix}/bin
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: libtesseract
+Description: An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.
+URL: https://github.com/tesseract-ocr/tesseract
+Version: 5.2.0
+Requires.private: lept
+Libs: -L${libdir} -ltesseract52
+Libs.private:
+Cflags: -I${includedir}
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x64/tesseract52.lib b/third_party/ocr/tesseract-ocr/windows/lib/x64/tesseract52.lib
new file mode 100644
index 00000000..d63ee756
Binary files /dev/null and b/third_party/ocr/tesseract-ocr/windows/lib/x64/tesseract52.lib differ
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x64/tesseract52d.lib b/third_party/ocr/tesseract-ocr/windows/lib/x64/tesseract52d.lib
new file mode 100644
index 00000000..f07d1c53
Binary files /dev/null and b/third_party/ocr/tesseract-ocr/windows/lib/x64/tesseract52d.lib differ
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractConfig.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractConfig.cmake
new file mode 100644
index 00000000..8ec1ca3c
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractConfig.cmake
@@ -0,0 +1,63 @@
+# ===================================================================================
+# The Tesseract CMake configuration file
+#
+# ** File generated automatically, do not modify **
+#
+# Usage from an external project:
+# In your CMakeLists.txt, add these lines:
+#
+# find_package(Tesseract REQUIRED)
+# target_link_libraries(MY_TARGET_NAME Tesseract::libtesseract)
+#
+# This file will define the following variables:
+# - Tesseract_LIBRARIES : The list of all imported targets.
+# - Tesseract_INCLUDE_DIRS : The Tesseract include directories.
+# - Tesseract_LIBRARY_DIRS : The Tesseract library directories.
+# - Tesseract_VERSION : The version of this Tesseract build: "5.2.0"
+# - Tesseract_VERSION_MAJOR : Major version part of Tesseract_VERSION: "5"
+# - Tesseract_VERSION_MINOR : Minor version part of Tesseract_VERSION: "2"
+# - Tesseract_VERSION_PATCH : Patch version part of Tesseract_VERSION: "0"
+#
+# ===================================================================================
+
+include(CMakeFindDependencyMacro)
+find_dependency(Leptonica)
+
+include(${CMAKE_CURRENT_LIST_DIR}/TesseractTargets.cmake)
+
+
+####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
+####### Any changes to this file will be overwritten by the next CMake run ####
+####### The input file was TesseractConfig.cmake.in ########
+
+get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
+
+macro(set_and_check _var _file)
+ set(${_var} "${_file}")
+ if(NOT EXISTS "${_file}")
+ message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
+ endif()
+endmacro()
+
+macro(check_required_components _NAME)
+ foreach(comp ${${_NAME}_FIND_COMPONENTS})
+ if(NOT ${_NAME}_${comp}_FOUND)
+ if(${_NAME}_FIND_REQUIRED_${comp})
+ set(${_NAME}_FOUND FALSE)
+ endif()
+ endif()
+ endforeach()
+endmacro()
+
+####################################################################################
+
+SET(Tesseract_VERSION 5.2.0)
+SET(Tesseract_VERSION_MAJOR 5)
+SET(Tesseract_VERSION_MINOR 2)
+SET(Tesseract_VERSION_PATCH 0)
+
+set_and_check(Tesseract_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include")
+set_and_check(Tesseract_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")
+set(Tesseract_LIBRARIES tesseract52)
+
+check_required_components(Tesseract)
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractConfigVersion.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractConfigVersion.cmake
new file mode 100644
index 00000000..92474a62
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractConfigVersion.cmake
@@ -0,0 +1,70 @@
+# This is a basic version file for the Config-mode of find_package().
+# It is used by write_basic_package_version_file() as input file for configure_file()
+# to create a version-file which can be installed along a config.cmake file.
+#
+# The created file sets PACKAGE_VERSION_EXACT if the current version string and
+# the requested version string are exactly the same and it sets
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
+# but only if the requested major version is the same as the current one.
+# The variable CVF_VERSION must be set before calling configure_file().
+
+
+set(PACKAGE_VERSION "5.2.0")
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+
+ if("5.2.0" MATCHES "^([0-9]+)\\.")
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
+ endif()
+ else()
+ set(CVF_VERSION_MAJOR "5.2.0")
+ endif()
+
+ if(PACKAGE_FIND_VERSION_RANGE)
+ # both endpoints of the range must have the expected major version
+ math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
+ if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
+ AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+ else()
+ if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+ endif()
+endif()
+
+
+# if the installed project requested no architecture check, don't perform the check
+if("FALSE")
+ return()
+endif()
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "4" STREQUAL "")
+ return()
+endif()
+
+# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "4")
+ math(EXPR installedBits "4 * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractTargets-release.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractTargets-release.cmake
new file mode 100644
index 00000000..8e620af9
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractTargets-release.cmake
@@ -0,0 +1,19 @@
+#----------------------------------------------------------------
+# Generated CMake target import file for configuration "Release".
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Import target "Tesseract::libtesseract" for configuration "Release"
+set_property(TARGET Tesseract::libtesseract APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Tesseract::libtesseract PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
+ IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/tesseract52.lib"
+ )
+
+list(APPEND _IMPORT_CHECK_TARGETS Tesseract::libtesseract )
+list(APPEND _IMPORT_CHECK_FILES_FOR_Tesseract::libtesseract "${_IMPORT_PREFIX}/lib/tesseract52.lib" )
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractTargets.cmake b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractTargets.cmake
new file mode 100644
index 00000000..6a575bbe
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x86/cmake/tesseract/TesseractTargets.cmake
@@ -0,0 +1,98 @@
+# Generated by CMake
+
+if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
+ message(FATAL_ERROR "CMake >= 2.6.0 required")
+endif()
+cmake_policy(PUSH)
+cmake_policy(VERSION 2.6...3.21)
+#----------------------------------------------------------------
+# Generated CMake target import file.
+#----------------------------------------------------------------
+
+# Commands may need to know the format version.
+set(CMAKE_IMPORT_FILE_VERSION 1)
+
+# Protect against multiple inclusion, which would fail when already imported targets are added once more.
+set(_targetsDefined)
+set(_targetsNotDefined)
+set(_expectedTargets)
+foreach(_expectedTarget Tesseract::libtesseract)
+ list(APPEND _expectedTargets ${_expectedTarget})
+ if(NOT TARGET ${_expectedTarget})
+ list(APPEND _targetsNotDefined ${_expectedTarget})
+ endif()
+ if(TARGET ${_expectedTarget})
+ list(APPEND _targetsDefined ${_expectedTarget})
+ endif()
+endforeach()
+if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
+ unset(_targetsDefined)
+ unset(_targetsNotDefined)
+ unset(_expectedTargets)
+ set(CMAKE_IMPORT_FILE_VERSION)
+ cmake_policy(POP)
+ return()
+endif()
+if(NOT "${_targetsDefined}" STREQUAL "")
+ message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
+endif()
+unset(_targetsDefined)
+unset(_targetsNotDefined)
+unset(_expectedTargets)
+
+
+# Compute the installation prefix relative to this file.
+get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+if(_IMPORT_PREFIX STREQUAL "/")
+ set(_IMPORT_PREFIX "")
+endif()
+
+# Create imported target Tesseract::libtesseract
+add_library(Tesseract::libtesseract STATIC IMPORTED)
+
+set_target_properties(Tesseract::libtesseract PROPERTIES
+ INTERFACE_LINK_LIBRARIES "\$;leptonica"
+)
+
+if(CMAKE_VERSION VERSION_LESS 2.8.12)
+ message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
+endif()
+
+# Load information for each installed configuration.
+get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+file(GLOB CONFIG_FILES "${_DIR}/TesseractTargets-*.cmake")
+foreach(f ${CONFIG_FILES})
+ include(${f})
+endforeach()
+
+# Cleanup temporary variables.
+set(_IMPORT_PREFIX)
+
+# Loop over all imported files and verify that they actually exist
+foreach(target ${_IMPORT_CHECK_TARGETS} )
+ foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
+ if(NOT EXISTS "${file}" )
+ message(FATAL_ERROR "The imported target \"${target}\" references the file
+ \"${file}\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \"${CMAKE_CURRENT_LIST_FILE}\"
+but not all the files it references.
+")
+ endif()
+ endforeach()
+ unset(_IMPORT_CHECK_FILES_FOR_${target})
+endforeach()
+unset(_IMPORT_CHECK_TARGETS)
+
+# This file does not depend on other imported targets which have
+# been exported from the same project but in a separate export set.
+
+# Commands beyond this point should not need to know the version.
+set(CMAKE_IMPORT_FILE_VERSION)
+cmake_policy(POP)
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x86/pkgconfig/tesseract.pc b/third_party/ocr/tesseract-ocr/windows/lib/x86/pkgconfig/tesseract.pc
new file mode 100644
index 00000000..c37b6143
--- /dev/null
+++ b/third_party/ocr/tesseract-ocr/windows/lib/x86/pkgconfig/tesseract.pc
@@ -0,0 +1,13 @@
+prefix=D:/code_app/third_party/ocr/tesseract-ocr/windows/tesseract-main/build/release
+exec_prefix=${prefix}/bin
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: libtesseract
+Description: An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.
+URL: https://github.com/tesseract-ocr/tesseract
+Version: 5.2.0
+Requires.private: lept
+Libs: -L${libdir} -ltesseract52
+Libs.private:
+Cflags: -I${includedir}
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x86/tesseract52.lib b/third_party/ocr/tesseract-ocr/windows/lib/x86/tesseract52.lib
new file mode 100644
index 00000000..583366db
Binary files /dev/null and b/third_party/ocr/tesseract-ocr/windows/lib/x86/tesseract52.lib differ
diff --git a/third_party/ocr/tesseract-ocr/windows/lib/x86/tesseract52d.lib b/third_party/ocr/tesseract-ocr/windows/lib/x86/tesseract52d.lib
new file mode 100644
index 00000000..89417e83
Binary files /dev/null and b/third_party/ocr/tesseract-ocr/windows/lib/x86/tesseract52d.lib differ