diff --git a/card.io/src/main/AndroidManifest.xml b/card.io/src/main/AndroidManifest.xml
index 43511802..dc63af79 100644
--- a/card.io/src/main/AndroidManifest.xml
+++ b/card.io/src/main/AndroidManifest.xml
@@ -6,6 +6,9 @@
+
+
+
diff --git a/card.io/src/main/assets/tessdata/co.traineddata b/card.io/src/main/assets/tessdata/co.traineddata
new file mode 100644
index 00000000..b8800848
Binary files /dev/null and b/card.io/src/main/assets/tessdata/co.traineddata differ
diff --git a/card.io/src/main/java/io/card/payment/CardIOActivity.java b/card.io/src/main/java/io/card/payment/CardIOActivity.java
index f314f31a..cf507211 100644
--- a/card.io/src/main/java/io/card/payment/CardIOActivity.java
+++ b/card.io/src/main/java/io/card/payment/CardIOActivity.java
@@ -4,10 +4,10 @@
* See the file "LICENSE.md" for the full license governing this code.
*/
-import android.Manifest;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
@@ -18,11 +18,15 @@
import android.graphics.Matrix;
import android.graphics.Rect;
import android.hardware.SensorManager;
+import android.Manifest;
import android.os.Build;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.os.Vibrator;
import android.util.Log;
+import android.view.animation.Animation;
+import android.view.animation.RotateAnimation;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.OrientationEventListener;
@@ -32,8 +36,6 @@
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
-import android.view.animation.Animation;
-import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -41,6 +43,11 @@
import android.widget.Toast;
import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.util.Date;
@@ -327,7 +334,7 @@ public final class CardIOActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate()");
-
+ tessSetup();
numActivityAllocations++;
// NOTE: java native asserts are disabled by default on Android.
if (numActivityAllocations != 1) {
@@ -1111,4 +1118,90 @@ public Rect getTorchRect() {
return mOverlay.getTorchRect();
}
+ /*************************** TESSERACT Entry Point **************************/
+
+
+ private String DATA_PATH = "";
+ private final String TESSDATA = "tessdata";
+ private final String TESSCONFIG = "tessconfigs";
+
+ /*
+ * Entry point for tessdata adapted from TessTwo
+ */
+ private void tessSetup() {
+ DATA_PATH = getExternalFilesDir(null) + "/Tesseract/";
+ Log.i(TAG, "Attempting to copy tessdata");
+ Log.i(TAG, "Accessing: "+ DATA_PATH);
+ prepareTesseract();
+ }
+
+ /**
+ * Prepare directory on external storage
+ *
+ * @param path
+ * @throws Exception
+ */
+ private void prepareDirectory(String path) {
+ File dir = new File(path);
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ Log.e(TAG, "ERROR: Creation of directory " + path + " failed, check does Android Manifest have permission to write to external storage?");
+ }
+ }
+ else {
+ Log.i(TAG, "Created directory " + path);
+ }
+ }
+
+ private void prepareTesseract() {
+ try {
+ prepareDirectory(DATA_PATH + TESSDATA);
+ prepareDirectory(DATA_PATH + TESSDATA + "/" + TESSCONFIG);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ copyTessDataFiles(TESSDATA);
+ }
+
+ /**
+ * Copy tessdata files (located on assets/tessdata) to destination directory
+ *
+ * @param path - name of directory with .traineddata files
+ */
+ private void copyTessDataFiles(String path) {
+ try {
+ String fileList[] = getAssets().list(path);
+
+ for (String fileName : fileList) {
+
+ // open file within the assets folder
+ // if it is not already there copy it
+ String pathToDataFile = DATA_PATH + path + "/" + fileName;
+ if (!(new File(pathToDataFile)).exists()) {
+
+ InputStream in = getAssets().open(path + "/" + fileName);
+
+ OutputStream out = new FileOutputStream(pathToDataFile);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+
+ Log.d(TAG, "Copied " + fileName + " to tessdata");
+ }
+ }
+ }
+ catch (IOException e) {
+ Log.e(TAG, "Unable to copy files to tessdata " + e.toString());
+ }
+ }
+
}
diff --git a/card.io/src/main/jni/Android.mk b/card.io/src/main/jni/Android.mk
index 32832245..d6717c1c 100644
--- a/card.io/src/main/jni/Android.mk
+++ b/card.io/src/main/jni/Android.mk
@@ -24,6 +24,30 @@ LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libopencv_imgproc.so
LOCAL_SHARED_LIBRARIES := opencv_core
include $(PREBUILT_SHARED_LIBRARY)
+
+# --- declare tesseract prebuilt static libs ---------------------------------
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := leptonica_core
+LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/liblept.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := jpg_lib
+LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libjpgt.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := png_lib
+LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libpngt.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := tesseract_core
+LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libtess.so
+LOCAL_SHARED_LIBRARIES := leptonica_core jpg_lib png_lib
+include $(PREBUILT_SHARED_LIBRARY)
+
endif
# --- libcardioRecognizer.so --------------------------------------------------------
@@ -36,7 +60,7 @@ ifneq (,$(filter $(TARGET_ARCH_ABI),armeabi-v7a x86 arm64-v8a x86_64))
LOCAL_MODULE := cardioRecognizer
LOCAL_LDLIBS := -llog -L$(SYSROOT)/usr/lib -lz -ljnigraphics
-LOCAL_SHARED_LIBRARIES := cpufeatures opencv_imgproc opencv_core
+LOCAL_SHARED_LIBRARIES := cpufeatures opencv_imgproc opencv_core tesseract_core
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LOCAL_DMZ_DIR) $(LOCAL_PATH)/$(LOCAL_DMZ_DIR)/cv
LOCAL_SRC_FILES := $(LOCAL_DMZ_DIR)/dmz_all.cpp nativeRecognizer.cpp
@@ -67,7 +91,7 @@ ifneq (,$(filter $(TARGET_ARCH_ABI),armeabi-v7a x86 arm64-v8a x86_64))
LOCAL_MODULE := cardioRecognizer_tegra2
LOCAL_LDLIBS := -llog -L$(SYSROOT)/usr/lib -lz -ljnigraphics
-LOCAL_SHARED_LIBRARIES := cpufeatures opencv_imgproc opencv_core
+LOCAL_SHARED_LIBRARIES := cpufeatures opencv_imgproc opencv_core tesseract_core
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LOCAL_DMZ_DIR) $(LOCAL_PATH)/$(LOCAL_DMZ_DIR)/cv
LOCAL_SRC_FILES := $(LOCAL_DMZ_DIR)/dmz_all.cpp nativeRecognizer.cpp
diff --git a/card.io/src/main/jni/leptonica/allheaders.h b/card.io/src/main/jni/leptonica/allheaders.h
new file mode 100644
index 00000000..16cc2411
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/allheaders.h
@@ -0,0 +1,2245 @@
+/*====================================================================*
+ - 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_ALLHEADERS_H
+#define LEPTONICA_ALLHEADERS_H
+
+
+#define LIBLEPT_MAJOR_VERSION 1
+#define LIBLEPT_MINOR_VERSION 69
+
+#include "alltypes.h"
+
+#ifndef NO_PROTOS
+/*
+ * These prototypes were autogen'd by xtractprotos, v. 1.5
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+LEPT_DLL extern PIX * pixBackgroundNormSimple ( PIX *pixs, PIX *pixim, PIX *pixg );
+LEPT_DLL extern PIX * pixBackgroundNorm ( PIX *pixs, PIX *pixim, PIX *pixg, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 bgval, l_int32 smoothx, l_int32 smoothy );
+LEPT_DLL extern PIX * pixBackgroundNormMorph ( PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, l_int32 bgval );
+LEPT_DLL extern l_int32 pixBackgroundNormGrayArray ( PIX *pixs, PIX *pixim, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 bgval, l_int32 smoothx, l_int32 smoothy, PIX **ppixd );
+LEPT_DLL extern l_int32 pixBackgroundNormRGBArrays ( PIX *pixs, PIX *pixim, PIX *pixg, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 bgval, l_int32 smoothx, l_int32 smoothy, PIX **ppixr, PIX **ppixg, PIX **ppixb );
+LEPT_DLL extern l_int32 pixBackgroundNormGrayArrayMorph ( PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, l_int32 bgval, PIX **ppixd );
+LEPT_DLL extern l_int32 pixBackgroundNormRGBArraysMorph ( PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, l_int32 bgval, PIX **ppixr, PIX **ppixg, PIX **ppixb );
+LEPT_DLL extern l_int32 pixGetBackgroundGrayMap ( PIX *pixs, PIX *pixim, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, PIX **ppixd );
+LEPT_DLL extern l_int32 pixGetBackgroundRGBMap ( PIX *pixs, PIX *pixim, PIX *pixg, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, PIX **ppixmr, PIX **ppixmg, PIX **ppixmb );
+LEPT_DLL extern l_int32 pixGetBackgroundGrayMapMorph ( PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, PIX **ppixm );
+LEPT_DLL extern l_int32 pixGetBackgroundRGBMapMorph ( PIX *pixs, PIX *pixim, l_int32 reduction, l_int32 size, PIX **ppixmr, PIX **ppixmg, PIX **ppixmb );
+LEPT_DLL extern l_int32 pixFillMapHoles ( PIX *pix, l_int32 nx, l_int32 ny, l_int32 filltype );
+LEPT_DLL extern PIX * pixExtendByReplication ( PIX *pixs, l_int32 addw, l_int32 addh );
+LEPT_DLL extern l_int32 pixSmoothConnectedRegions ( PIX *pixs, PIX *pixm, l_int32 factor );
+LEPT_DLL extern PIX * pixGetInvBackgroundMap ( PIX *pixs, l_int32 bgval, l_int32 smoothx, l_int32 smoothy );
+LEPT_DLL extern PIX * pixApplyInvBackgroundGrayMap ( PIX *pixs, PIX *pixm, l_int32 sx, l_int32 sy );
+LEPT_DLL extern PIX * pixApplyInvBackgroundRGBMap ( PIX *pixs, PIX *pixmr, PIX *pixmg, PIX *pixmb, l_int32 sx, l_int32 sy );
+LEPT_DLL extern PIX * pixApplyVariableGrayMap ( PIX *pixs, PIX *pixg, l_int32 target );
+LEPT_DLL extern PIX * pixGlobalNormRGB ( PIX *pixd, PIX *pixs, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 mapval );
+LEPT_DLL extern PIX * pixGlobalNormNoSatRGB ( PIX *pixd, PIX *pixs, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 factor, l_float32 rank );
+LEPT_DLL extern l_int32 pixThresholdSpreadNorm ( PIX *pixs, l_int32 filtertype, l_int32 edgethresh, l_int32 smoothx, l_int32 smoothy, l_float32 gamma, l_int32 minval, l_int32 maxval, l_int32 targetthresh, PIX **ppixth, PIX **ppixb, PIX **ppixd );
+LEPT_DLL extern PIX * pixBackgroundNormFlex ( PIX *pixs, l_int32 sx, l_int32 sy, l_int32 smoothx, l_int32 smoothy, l_int32 delta );
+LEPT_DLL extern PIX * pixContrastNorm ( PIX *pixd, PIX *pixs, l_int32 sx, l_int32 sy, l_int32 mindiff, l_int32 smoothx, l_int32 smoothy );
+LEPT_DLL extern l_int32 pixMinMaxTiles ( PIX *pixs, l_int32 sx, l_int32 sy, l_int32 mindiff, l_int32 smoothx, l_int32 smoothy, PIX **ppixmin, PIX **ppixmax );
+LEPT_DLL extern l_int32 pixSetLowContrast ( PIX *pixs1, PIX *pixs2, l_int32 mindiff );
+LEPT_DLL extern PIX * pixLinearTRCTiled ( PIX *pixd, PIX *pixs, l_int32 sx, l_int32 sy, PIX *pixmin, PIX *pixmax );
+LEPT_DLL extern PIX * pixAffineSampledPta ( PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor );
+LEPT_DLL extern PIX * pixAffineSampled ( PIX *pixs, l_float32 *vc, l_int32 incolor );
+LEPT_DLL extern PIX * pixAffinePta ( PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor );
+LEPT_DLL extern PIX * pixAffine ( PIX *pixs, l_float32 *vc, l_int32 incolor );
+LEPT_DLL extern PIX * pixAffinePtaColor ( PIX *pixs, PTA *ptad, PTA *ptas, l_uint32 colorval );
+LEPT_DLL extern PIX * pixAffineColor ( PIX *pixs, l_float32 *vc, l_uint32 colorval );
+LEPT_DLL extern PIX * pixAffinePtaGray ( PIX *pixs, PTA *ptad, PTA *ptas, l_uint8 grayval );
+LEPT_DLL extern PIX * pixAffineGray ( PIX *pixs, l_float32 *vc, l_uint8 grayval );
+LEPT_DLL extern PIX * pixAffinePtaWithAlpha ( PIX *pixs, PTA *ptad, PTA *ptas, PIX *pixg, l_float32 fract, l_int32 border );
+LEPT_DLL extern PIX * pixAffinePtaGammaXform ( PIX *pixs, l_float32 gamma, PTA *ptad, PTA *ptas, l_float32 fract, l_int32 border );
+LEPT_DLL extern l_int32 getAffineXformCoeffs ( PTA *ptas, PTA *ptad, l_float32 **pvc );
+LEPT_DLL extern l_int32 affineInvertXform ( l_float32 *vc, l_float32 **pvci );
+LEPT_DLL extern l_int32 affineXformSampledPt ( l_float32 *vc, l_int32 x, l_int32 y, l_int32 *pxp, l_int32 *pyp );
+LEPT_DLL extern l_int32 affineXformPt ( l_float32 *vc, l_int32 x, l_int32 y, l_float32 *pxp, l_float32 *pyp );
+LEPT_DLL extern l_int32 linearInterpolatePixelColor ( l_uint32 *datas, l_int32 wpls, l_int32 w, l_int32 h, l_float32 x, l_float32 y, l_uint32 colorval, l_uint32 *pval );
+LEPT_DLL extern l_int32 linearInterpolatePixelGray ( l_uint32 *datas, l_int32 wpls, l_int32 w, l_int32 h, l_float32 x, l_float32 y, l_int32 grayval, l_int32 *pval );
+LEPT_DLL extern l_int32 gaussjordan ( l_float32 **a, l_float32 *b, l_int32 n );
+LEPT_DLL extern PIX * pixAffineSequential ( PIX *pixs, PTA *ptad, PTA *ptas, l_int32 bw, l_int32 bh );
+LEPT_DLL extern l_float32 * createMatrix2dTranslate ( l_float32 transx, l_float32 transy );
+LEPT_DLL extern l_float32 * createMatrix2dScale ( l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern l_float32 * createMatrix2dRotate ( l_float32 xc, l_float32 yc, l_float32 angle );
+LEPT_DLL extern PTA * ptaTranslate ( PTA *ptas, l_float32 transx, l_float32 transy );
+LEPT_DLL extern PTA * ptaScale ( PTA *ptas, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PTA * ptaRotate ( PTA *ptas, l_float32 xc, l_float32 yc, l_float32 angle );
+LEPT_DLL extern BOXA * boxaTranslate ( BOXA *boxas, l_float32 transx, l_float32 transy );
+LEPT_DLL extern BOXA * boxaScale ( BOXA *boxas, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern BOXA * boxaRotate ( BOXA *boxas, l_float32 xc, l_float32 yc, l_float32 angle );
+LEPT_DLL extern PTA * ptaAffineTransform ( PTA *ptas, l_float32 *mat );
+LEPT_DLL extern BOXA * boxaAffineTransform ( BOXA *boxas, l_float32 *mat );
+LEPT_DLL extern l_int32 l_productMatVec ( l_float32 *mat, l_float32 *vecs, l_float32 *vecd, l_int32 size );
+LEPT_DLL extern l_int32 l_productMat2 ( l_float32 *mat1, l_float32 *mat2, l_float32 *matd, l_int32 size );
+LEPT_DLL extern l_int32 l_productMat3 ( l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *matd, l_int32 size );
+LEPT_DLL extern l_int32 l_productMat4 ( l_float32 *mat1, l_float32 *mat2, l_float32 *mat3, l_float32 *mat4, l_float32 *matd, l_int32 size );
+LEPT_DLL extern void addConstantGrayLow ( l_uint32 *data, l_int32 w, l_int32 h, l_int32 d, l_int32 wpl, l_int32 val );
+LEPT_DLL extern void multConstantGrayLow ( l_uint32 *data, l_int32 w, l_int32 h, l_int32 d, l_int32 wpl, l_float32 val );
+LEPT_DLL extern void addGrayLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 d, l_int32 wpld, l_uint32 *datas, l_int32 wpls );
+LEPT_DLL extern void subtractGrayLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 d, l_int32 wpld, l_uint32 *datas, l_int32 wpls );
+LEPT_DLL extern void thresholdToValueLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 d, l_int32 wpld, l_int32 threshval, l_int32 setval );
+LEPT_DLL extern void finalAccumulateLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 d, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 offset );
+LEPT_DLL extern void finalAccumulateThreshLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 offset, l_uint32 threshold );
+LEPT_DLL extern void accumulateLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 d, l_int32 wpls, l_int32 op );
+LEPT_DLL extern void multConstAccumulateLow ( l_uint32 *data, l_int32 w, l_int32 h, l_int32 wpl, l_float32 factor, l_uint32 offset );
+LEPT_DLL extern void absDifferenceLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas1, l_uint32 *datas2, l_int32 d, l_int32 wpls1, l_int32 wpls2 );
+LEPT_DLL extern l_int32 l_getDataBit ( void *line, l_int32 n );
+LEPT_DLL extern void l_setDataBit ( void *line, l_int32 n );
+LEPT_DLL extern void l_clearDataBit ( void *line, l_int32 n );
+LEPT_DLL extern void l_setDataBitVal ( void *line, l_int32 n, l_int32 val );
+LEPT_DLL extern l_int32 l_getDataDibit ( void *line, l_int32 n );
+LEPT_DLL extern void l_setDataDibit ( void *line, l_int32 n, l_int32 val );
+LEPT_DLL extern void l_clearDataDibit ( void *line, l_int32 n );
+LEPT_DLL extern l_int32 l_getDataQbit ( void *line, l_int32 n );
+LEPT_DLL extern void l_setDataQbit ( void *line, l_int32 n, l_int32 val );
+LEPT_DLL extern void l_clearDataQbit ( void *line, l_int32 n );
+LEPT_DLL extern l_int32 l_getDataByte ( void *line, l_int32 n );
+LEPT_DLL extern void l_setDataByte ( void *line, l_int32 n, l_int32 val );
+LEPT_DLL extern l_int32 l_getDataTwoBytes ( void *line, l_int32 n );
+LEPT_DLL extern void l_setDataTwoBytes ( void *line, l_int32 n, l_int32 val );
+LEPT_DLL extern l_int32 l_getDataFourBytes ( void *line, l_int32 n );
+LEPT_DLL extern void l_setDataFourBytes ( void *line, l_int32 n, l_int32 val );
+LEPT_DLL extern char * barcodeDispatchDecoder ( char *barstr, l_int32 format, l_int32 debugflag );
+LEPT_DLL extern l_int32 barcodeFormatIsSupported ( l_int32 format );
+LEPT_DLL extern NUMA * pixFindBaselines ( PIX *pixs, PTA **ppta, l_int32 debug );
+LEPT_DLL extern PIX * pixDeskewLocal ( PIX *pixs, l_int32 nslices, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta );
+LEPT_DLL extern l_int32 pixGetLocalSkewTransform ( PIX *pixs, l_int32 nslices, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta, PTA **pptas, PTA **pptad );
+LEPT_DLL extern NUMA * pixGetLocalSkewAngles ( PIX *pixs, l_int32 nslices, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta, l_float32 *pa, l_float32 *pb );
+LEPT_DLL extern BBUFFER * bbufferCreate ( l_uint8 *indata, l_int32 nalloc );
+LEPT_DLL extern void bbufferDestroy ( BBUFFER **pbb );
+LEPT_DLL extern l_uint8 * bbufferDestroyAndSaveData ( BBUFFER **pbb, size_t *pnbytes );
+LEPT_DLL extern l_int32 bbufferRead ( BBUFFER *bb, l_uint8 *src, l_int32 nbytes );
+LEPT_DLL extern l_int32 bbufferReadStream ( BBUFFER *bb, FILE *fp, l_int32 nbytes );
+LEPT_DLL extern l_int32 bbufferExtendArray ( BBUFFER *bb, l_int32 nbytes );
+LEPT_DLL extern l_int32 bbufferWrite ( BBUFFER *bb, l_uint8 *dest, size_t nbytes, size_t *pnout );
+LEPT_DLL extern l_int32 bbufferWriteStream ( BBUFFER *bb, FILE *fp, size_t nbytes, size_t *pnout );
+LEPT_DLL extern l_int32 bbufferBytesToWrite ( BBUFFER *bb, size_t *pnbytes );
+LEPT_DLL extern PIX * pixBilinearSampledPta ( PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor );
+LEPT_DLL extern PIX * pixBilinearSampled ( PIX *pixs, l_float32 *vc, l_int32 incolor );
+LEPT_DLL extern PIX * pixBilinearPta ( PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor );
+LEPT_DLL extern PIX * pixBilinear ( PIX *pixs, l_float32 *vc, l_int32 incolor );
+LEPT_DLL extern PIX * pixBilinearPtaColor ( PIX *pixs, PTA *ptad, PTA *ptas, l_uint32 colorval );
+LEPT_DLL extern PIX * pixBilinearColor ( PIX *pixs, l_float32 *vc, l_uint32 colorval );
+LEPT_DLL extern PIX * pixBilinearPtaGray ( PIX *pixs, PTA *ptad, PTA *ptas, l_uint8 grayval );
+LEPT_DLL extern PIX * pixBilinearGray ( PIX *pixs, l_float32 *vc, l_uint8 grayval );
+LEPT_DLL extern PIX * pixBilinearPtaWithAlpha ( PIX *pixs, PTA *ptad, PTA *ptas, PIX *pixg, l_float32 fract, l_int32 border );
+LEPT_DLL extern PIX * pixBilinearPtaGammaXform ( PIX *pixs, l_float32 gamma, PTA *ptad, PTA *ptas, l_float32 fract, l_int32 border );
+LEPT_DLL extern l_int32 getBilinearXformCoeffs ( PTA *ptas, PTA *ptad, l_float32 **pvc );
+LEPT_DLL extern l_int32 bilinearXformSampledPt ( l_float32 *vc, l_int32 x, l_int32 y, l_int32 *pxp, l_int32 *pyp );
+LEPT_DLL extern l_int32 bilinearXformPt ( l_float32 *vc, l_int32 x, l_int32 y, l_float32 *pxp, l_float32 *pyp );
+LEPT_DLL extern l_int32 pixOtsuAdaptiveThreshold ( PIX *pixs, l_int32 sx, l_int32 sy, l_int32 smoothx, l_int32 smoothy, l_float32 scorefract, PIX **ppixth, PIX **ppixd );
+LEPT_DLL extern PIX * pixOtsuThreshOnBackgroundNorm ( PIX *pixs, PIX *pixim, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 bgval, l_int32 smoothx, l_int32 smoothy, l_float32 scorefract, l_int32 *pthresh );
+LEPT_DLL extern PIX * pixMaskedThreshOnBackgroundNorm ( PIX *pixs, PIX *pixim, l_int32 sx, l_int32 sy, l_int32 thresh, l_int32 mincount, l_int32 smoothx, l_int32 smoothy, l_float32 scorefract, l_int32 *pthresh );
+LEPT_DLL extern l_int32 pixSauvolaBinarizeTiled ( PIX *pixs, l_int32 whsize, l_float32 factor, l_int32 nx, l_int32 ny, PIX **ppixth, PIX **ppixd );
+LEPT_DLL extern l_int32 pixSauvolaBinarize ( PIX *pixs, l_int32 whsize, l_float32 factor, l_int32 addborder, PIX **ppixm, PIX **ppixsd, PIX **ppixth, PIX **ppixd );
+LEPT_DLL extern PIX * pixSauvolaGetThreshold ( PIX *pixm, PIX *pixms, l_float32 factor, PIX **ppixsd );
+LEPT_DLL extern PIX * pixApplyLocalThreshold ( PIX *pixs, PIX *pixth, l_int32 redfactor );
+LEPT_DLL extern PIX * pixExpandBinaryReplicate ( PIX *pixs, l_int32 factor );
+LEPT_DLL extern PIX * pixExpandBinaryPower2 ( PIX *pixs, l_int32 factor );
+LEPT_DLL extern l_int32 expandBinaryPower2Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls, l_int32 factor );
+LEPT_DLL extern l_uint16 * makeExpandTab2x ( void );
+LEPT_DLL extern l_uint32 * makeExpandTab4x ( void );
+LEPT_DLL extern l_uint32 * makeExpandTab8x ( void );
+LEPT_DLL extern PIX * pixReduceBinary2 ( PIX *pixs, l_uint8 *intab );
+LEPT_DLL extern PIX * pixReduceRankBinaryCascade ( PIX *pixs, l_int32 level1, l_int32 level2, l_int32 level3, l_int32 level4 );
+LEPT_DLL extern PIX * pixReduceRankBinary2 ( PIX *pixs, l_int32 level, l_uint8 *intab );
+LEPT_DLL extern void reduceBinary2Low ( l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 hs, l_int32 wpls, l_uint8 *tab );
+LEPT_DLL extern void reduceRankBinary2Low ( l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 hs, l_int32 wpls, l_uint8 *tab, l_int32 level );
+LEPT_DLL extern l_uint8 * makeSubsampleTab2x ( void );
+LEPT_DLL extern PIX * pixBlend ( PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract );
+LEPT_DLL extern PIX * pixBlendMask ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract, l_int32 type );
+LEPT_DLL extern PIX * pixBlendGray ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract, l_int32 type, l_int32 transparent, l_uint32 transpix );
+LEPT_DLL extern PIX * pixBlendGrayInverse ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract );
+LEPT_DLL extern PIX * pixBlendColor ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract, l_int32 transparent, l_uint32 transpix );
+LEPT_DLL extern PIX * pixBlendColorByChannel ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 rfract, l_float32 gfract, l_float32 bfract, l_int32 transparent, l_uint32 transpix );
+LEPT_DLL extern PIX * pixBlendGrayAdapt ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract, l_int32 shift );
+LEPT_DLL extern PIX * pixFadeWithGray ( PIX *pixs, PIX *pixb, l_float32 factor, l_int32 type );
+LEPT_DLL extern PIX * pixBlendHardLight ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 x, l_int32 y, l_float32 fract );
+LEPT_DLL extern l_int32 pixBlendCmap ( PIX *pixs, PIX *pixb, l_int32 x, l_int32 y, l_int32 sindex );
+LEPT_DLL extern PIX * pixBlendWithGrayMask ( PIX *pixs1, PIX *pixs2, PIX *pixg, l_int32 x, l_int32 y );
+LEPT_DLL extern PIX * pixBlendBackgroundToColor ( PIX *pixd, PIX *pixs, BOX *box, l_uint32 color, l_float32 gamma, l_int32 minval, l_int32 maxval );
+LEPT_DLL extern PIX * pixMultiplyByColor ( PIX *pixd, PIX *pixs, BOX *box, l_uint32 color );
+LEPT_DLL extern PIX * pixAlphaBlendUniform ( PIX *pixs, l_uint32 color );
+LEPT_DLL extern PIX * pixSetAlphaOverWhite ( PIX *pixs );
+LEPT_DLL extern L_BMF * bmfCreate ( const char *dir, l_int32 size );
+LEPT_DLL extern void bmfDestroy ( L_BMF **pbmf );
+LEPT_DLL extern PIX * bmfGetPix ( L_BMF *bmf, char chr );
+LEPT_DLL extern l_int32 bmfGetWidth ( L_BMF *bmf, char chr, l_int32 *pw );
+LEPT_DLL extern l_int32 bmfGetBaseline ( L_BMF *bmf, char chr, l_int32 *pbaseline );
+LEPT_DLL extern PIXA * pixaGetFont ( const char *dir, l_int32 size, l_int32 *pbl0, l_int32 *pbl1, l_int32 *pbl2 );
+LEPT_DLL extern l_int32 pixaSaveFont ( const char *indir, const char *outdir, l_int32 size );
+LEPT_DLL extern PIXA * pixaGenerateFont ( const char *dir, l_int32 size, l_int32 *pbl0, l_int32 *pbl1, l_int32 *pbl2 );
+LEPT_DLL extern PIX * pixReadStreamBmp ( FILE *fp );
+LEPT_DLL extern l_int32 pixWriteStreamBmp ( FILE *fp, PIX *pix );
+LEPT_DLL extern PIX * pixReadMemBmp ( const l_uint8 *cdata, size_t size );
+LEPT_DLL extern l_int32 pixWriteMemBmp ( l_uint8 **pdata, size_t *psize, PIX *pix );
+LEPT_DLL extern BOX * boxCreate ( l_int32 x, l_int32 y, l_int32 w, l_int32 h );
+LEPT_DLL extern BOX * boxCreateValid ( l_int32 x, l_int32 y, l_int32 w, l_int32 h );
+LEPT_DLL extern BOX * boxCopy ( BOX *box );
+LEPT_DLL extern BOX * boxClone ( BOX *box );
+LEPT_DLL extern void boxDestroy ( BOX **pbox );
+LEPT_DLL extern l_int32 boxGetGeometry ( BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern l_int32 boxSetGeometry ( BOX *box, l_int32 x, l_int32 y, l_int32 w, l_int32 h );
+LEPT_DLL extern l_int32 boxGetRefcount ( BOX *box );
+LEPT_DLL extern l_int32 boxChangeRefcount ( BOX *box, l_int32 delta );
+LEPT_DLL extern l_int32 boxIsValid ( BOX *box, l_int32 *pvalid );
+LEPT_DLL extern BOXA * boxaCreate ( l_int32 n );
+LEPT_DLL extern BOXA * boxaCopy ( BOXA *boxa, l_int32 copyflag );
+LEPT_DLL extern void boxaDestroy ( BOXA **pboxa );
+LEPT_DLL extern l_int32 boxaAddBox ( BOXA *boxa, BOX *box, l_int32 copyflag );
+LEPT_DLL extern l_int32 boxaExtendArray ( BOXA *boxa );
+LEPT_DLL extern l_int32 boxaExtendArrayToSize ( BOXA *boxa, l_int32 size );
+LEPT_DLL extern l_int32 boxaGetCount ( BOXA *boxa );
+LEPT_DLL extern l_int32 boxaGetValidCount ( BOXA *boxa );
+LEPT_DLL extern BOX * boxaGetBox ( BOXA *boxa, l_int32 index, l_int32 accessflag );
+LEPT_DLL extern BOX * boxaGetValidBox ( BOXA *boxa, l_int32 index, l_int32 accessflag );
+LEPT_DLL extern l_int32 boxaGetBoxGeometry ( BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern l_int32 boxaReplaceBox ( BOXA *boxa, l_int32 index, BOX *box );
+LEPT_DLL extern l_int32 boxaInsertBox ( BOXA *boxa, l_int32 index, BOX *box );
+LEPT_DLL extern l_int32 boxaRemoveBox ( BOXA *boxa, l_int32 index );
+LEPT_DLL extern l_int32 boxaInitFull ( BOXA *boxa, BOX *box );
+LEPT_DLL extern l_int32 boxaClear ( BOXA *boxa );
+LEPT_DLL extern BOXAA * boxaaCreate ( l_int32 n );
+LEPT_DLL extern BOXAA * boxaaCopy ( BOXAA *baas, l_int32 copyflag );
+LEPT_DLL extern void boxaaDestroy ( BOXAA **pbaa );
+LEPT_DLL extern l_int32 boxaaAddBoxa ( BOXAA *baa, BOXA *ba, l_int32 copyflag );
+LEPT_DLL extern l_int32 boxaaExtendArray ( BOXAA *baa );
+LEPT_DLL extern l_int32 boxaaExtendArrayToSize ( BOXAA *baa, l_int32 size );
+LEPT_DLL extern l_int32 boxaaGetCount ( BOXAA *baa );
+LEPT_DLL extern l_int32 boxaaGetBoxCount ( BOXAA *baa );
+LEPT_DLL extern BOXA * boxaaGetBoxa ( BOXAA *baa, l_int32 index, l_int32 accessflag );
+LEPT_DLL extern BOX * boxaaGetBox ( BOXAA *baa, l_int32 iboxa, l_int32 ibox, l_int32 accessflag );
+LEPT_DLL extern l_int32 boxaaInitFull ( BOXAA *baa, BOXA *boxa );
+LEPT_DLL extern l_int32 boxaaExtendWithInit ( BOXAA *baa, l_int32 maxindex, BOXA *boxa );
+LEPT_DLL extern l_int32 boxaaReplaceBoxa ( BOXAA *baa, l_int32 index, BOXA *boxa );
+LEPT_DLL extern l_int32 boxaaInsertBoxa ( BOXAA *baa, l_int32 index, BOXA *boxa );
+LEPT_DLL extern l_int32 boxaaRemoveBoxa ( BOXAA *baa, l_int32 index );
+LEPT_DLL extern l_int32 boxaaAddBox ( BOXAA *baa, l_int32 index, BOX *box, l_int32 accessflag );
+LEPT_DLL extern BOXAA * boxaaRead ( const char *filename );
+LEPT_DLL extern BOXAA * boxaaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 boxaaWrite ( const char *filename, BOXAA *baa );
+LEPT_DLL extern l_int32 boxaaWriteStream ( FILE *fp, BOXAA *baa );
+LEPT_DLL extern BOXA * boxaRead ( const char *filename );
+LEPT_DLL extern BOXA * boxaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 boxaWrite ( const char *filename, BOXA *boxa );
+LEPT_DLL extern l_int32 boxaWriteStream ( FILE *fp, BOXA *boxa );
+LEPT_DLL extern l_int32 boxPrintStreamInfo ( FILE *fp, BOX *box );
+LEPT_DLL extern l_int32 boxContains ( BOX *box1, BOX *box2, l_int32 *presult );
+LEPT_DLL extern l_int32 boxIntersects ( BOX *box1, BOX *box2, l_int32 *presult );
+LEPT_DLL extern BOXA * boxaContainedInBox ( BOXA *boxas, BOX *box );
+LEPT_DLL extern BOXA * boxaIntersectsBox ( BOXA *boxas, BOX *box );
+LEPT_DLL extern BOXA * boxaClipToBox ( BOXA *boxas, BOX *box );
+LEPT_DLL extern BOXA * boxaCombineOverlaps ( BOXA *boxas );
+LEPT_DLL extern BOX * boxOverlapRegion ( BOX *box1, BOX *box2 );
+LEPT_DLL extern BOX * boxBoundingRegion ( BOX *box1, BOX *box2 );
+LEPT_DLL extern l_int32 boxOverlapFraction ( BOX *box1, BOX *box2, l_float32 *pfract );
+LEPT_DLL extern l_int32 boxContainsPt ( BOX *box, l_float32 x, l_float32 y, l_int32 *pcontains );
+LEPT_DLL extern BOX * boxaGetNearestToPt ( BOXA *boxa, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 boxGetCenter ( BOX *box, l_float32 *pcx, l_float32 *pcy );
+LEPT_DLL extern l_int32 boxIntersectByLine ( BOX *box, l_int32 x, l_int32 y, l_float32 slope, l_int32 *px1, l_int32 *py1, l_int32 *px2, l_int32 *py2, l_int32 *pn );
+LEPT_DLL extern BOX * boxClipToRectangle ( BOX *box, l_int32 wi, l_int32 hi );
+LEPT_DLL extern BOX * boxRelocateOneSide ( BOX *boxd, BOX *boxs, l_int32 loc, l_int32 sideflag );
+LEPT_DLL extern BOX * boxAdjustSides ( BOX *boxd, BOX *boxs, l_int32 delleft, l_int32 delright, l_int32 deltop, l_int32 delbot );
+LEPT_DLL extern l_int32 boxEqual ( BOX *box1, BOX *box2, l_int32 *psame );
+LEPT_DLL extern l_int32 boxaEqual ( BOXA *boxa1, BOXA *boxa2, l_int32 maxdist, NUMA **pnaindex, l_int32 *psame );
+LEPT_DLL extern l_int32 boxaJoin ( BOXA *boxad, BOXA *boxas, l_int32 istart, l_int32 iend );
+LEPT_DLL extern l_int32 boxaSplitEvenOdd ( BOXA *boxa, BOXA **pboxae, BOXA **pboxao );
+LEPT_DLL extern BOXA * boxaMergeEvenOdd ( BOXA *boxae, BOXA *boxao );
+LEPT_DLL extern BOXA * boxaTransform ( BOXA *boxas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern BOX * boxTransform ( BOX *box, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern BOXA * boxaTransformOrdered ( BOXA *boxas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 order );
+LEPT_DLL extern BOX * boxTransformOrdered ( BOX *boxs, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 order );
+LEPT_DLL extern BOXA * boxaRotateOrth ( BOXA *boxas, l_int32 w, l_int32 h, l_int32 rotation );
+LEPT_DLL extern BOX * boxRotateOrth ( BOX *box, l_int32 w, l_int32 h, l_int32 rotation );
+LEPT_DLL extern BOXA * boxaSort ( BOXA *boxas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex );
+LEPT_DLL extern BOXA * boxaBinSort ( BOXA *boxas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex );
+LEPT_DLL extern BOXA * boxaSortByIndex ( BOXA *boxas, NUMA *naindex );
+LEPT_DLL extern BOXAA * boxaSort2d ( BOXA *boxas, NUMAA **pnaad, l_int32 delta1, l_int32 delta2, l_int32 minh1 );
+LEPT_DLL extern BOXAA * boxaSort2dByIndex ( BOXA *boxas, NUMAA *naa );
+LEPT_DLL extern l_int32 boxaExtractAsNuma ( BOXA *boxa, NUMA **pnax, NUMA **pnay, NUMA **pnaw, NUMA **pnah, l_int32 keepinvalid );
+LEPT_DLL extern l_int32 boxaExtractAsPta ( BOXA *boxa, PTA **pptal, PTA **pptat, PTA **pptar, PTA **pptab, l_int32 keepinvalid );
+LEPT_DLL extern BOX * boxaGetRankSize ( BOXA *boxa, l_float32 fract );
+LEPT_DLL extern BOX * boxaGetMedian ( BOXA *boxa );
+LEPT_DLL extern l_int32 boxaaGetExtent ( BOXAA *boxaa, l_int32 *pw, l_int32 *ph, BOX **pbox );
+LEPT_DLL extern BOXA * boxaaFlattenToBoxa ( BOXAA *baa, NUMA **pnaindex, l_int32 copyflag );
+LEPT_DLL extern BOXA * boxaaFlattenAligned ( BOXAA *baa, l_int32 num, l_int32 copyflag );
+LEPT_DLL extern BOXAA * boxaEncapsulateAligned ( BOXA *boxa, l_int32 num, l_int32 copyflag );
+LEPT_DLL extern l_int32 boxaaAlignBox ( BOXAA *baa, BOX *box, l_int32 delta, l_int32 *pindex );
+LEPT_DLL extern PIX * pixMaskConnComp ( PIX *pixs, l_int32 connectivity, BOXA **pboxa );
+LEPT_DLL extern PIX * pixMaskBoxa ( PIX *pixd, PIX *pixs, BOXA *boxa, l_int32 op );
+LEPT_DLL extern PIX * pixPaintBoxa ( PIX *pixs, BOXA *boxa, l_uint32 val );
+LEPT_DLL extern PIX * pixSetBlackOrWhiteBoxa ( PIX *pixs, BOXA *boxa, l_int32 op );
+LEPT_DLL extern PIX * pixPaintBoxaRandom ( PIX *pixs, BOXA *boxa );
+LEPT_DLL extern PIX * pixBlendBoxaRandom ( PIX *pixs, BOXA *boxa, l_float32 fract );
+LEPT_DLL extern PIX * pixDrawBoxa ( PIX *pixs, BOXA *boxa, l_int32 width, l_uint32 val );
+LEPT_DLL extern PIX * pixDrawBoxaRandom ( PIX *pixs, BOXA *boxa, l_int32 width );
+LEPT_DLL extern PIX * boxaaDisplay ( BOXAA *boxaa, l_int32 linewba, l_int32 linewb, l_uint32 colorba, l_uint32 colorb, l_int32 w, l_int32 h );
+LEPT_DLL extern BOXA * pixSplitIntoBoxa ( PIX *pixs, l_int32 minsum, l_int32 skipdist, l_int32 delta, l_int32 maxbg, l_int32 maxcomps, l_int32 remainder );
+LEPT_DLL extern BOXA * pixSplitComponentIntoBoxa ( PIX *pix, BOX *box, l_int32 minsum, l_int32 skipdist, l_int32 delta, l_int32 maxbg, l_int32 maxcomps, l_int32 remainder );
+LEPT_DLL extern BOXA * boxaSelectBySize ( BOXA *boxas, l_int32 width, l_int32 height, l_int32 type, l_int32 relation, l_int32 *pchanged );
+LEPT_DLL extern NUMA * boxaMakeSizeIndicator ( BOXA *boxa, l_int32 width, l_int32 height, l_int32 type, l_int32 relation );
+LEPT_DLL extern BOXA * boxaSelectWithIndicator ( BOXA *boxas, NUMA *na, l_int32 *pchanged );
+LEPT_DLL extern BOXA * boxaPermutePseudorandom ( BOXA *boxas );
+LEPT_DLL extern BOXA * boxaPermuteRandom ( BOXA *boxad, BOXA *boxas );
+LEPT_DLL extern l_int32 boxaSwapBoxes ( BOXA *boxa, l_int32 i, l_int32 j );
+LEPT_DLL extern PTA * boxaConvertToPta ( BOXA *boxa, l_int32 ncorners );
+LEPT_DLL extern BOXA * ptaConvertToBoxa ( PTA *pta, l_int32 ncorners );
+LEPT_DLL extern BOXA * boxaSmoothSequence ( BOXA *boxas, l_float32 factor, l_int32 max_error, l_int32 debug );
+LEPT_DLL extern BOXA * boxaLinearFit ( BOXA *boxas, l_float32 factor, l_int32 max_error, l_int32 debug );
+LEPT_DLL extern BOXA * boxaConstrainSize ( BOXA *boxas, l_int32 width, l_int32 widthflag, l_int32 height, l_int32 heightflag );
+LEPT_DLL extern l_int32 boxaPlotSides ( BOXA *boxa, const char *plotname, NUMA **pnal, NUMA **pnat, NUMA **pnar, NUMA **pnab, l_int32 outformat );
+LEPT_DLL extern l_int32 boxaGetExtent ( BOXA *boxa, l_int32 *pw, l_int32 *ph, BOX **pbox );
+LEPT_DLL extern l_int32 boxaGetCoverage ( BOXA *boxa, l_int32 wc, l_int32 hc, l_int32 exactflag, l_float32 *pfract );
+LEPT_DLL extern l_int32 boxaSizeRange ( BOXA *boxa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh );
+LEPT_DLL extern l_int32 boxaLocationRange ( BOXA *boxa, l_int32 *pminx, l_int32 *pminy, l_int32 *pmaxx, l_int32 *pmaxy );
+LEPT_DLL extern L_BYTEA * l_byteaCreate ( size_t nbytes );
+LEPT_DLL extern L_BYTEA * l_byteaInitFromMem ( l_uint8 *data, size_t size );
+LEPT_DLL extern L_BYTEA * l_byteaInitFromFile ( const char *fname );
+LEPT_DLL extern L_BYTEA * l_byteaInitFromStream ( FILE *fp );
+LEPT_DLL extern L_BYTEA * l_byteaCopy ( L_BYTEA *bas, l_int32 copyflag );
+LEPT_DLL extern void l_byteaDestroy ( L_BYTEA **pba );
+LEPT_DLL extern size_t l_byteaGetSize ( L_BYTEA *ba );
+LEPT_DLL extern l_uint8 * l_byteaGetData ( L_BYTEA *ba, size_t *psize );
+LEPT_DLL extern l_uint8 * l_byteaCopyData ( L_BYTEA *ba, size_t *psize );
+LEPT_DLL extern l_int32 l_byteaAppendData ( L_BYTEA *ba, l_uint8 *newdata, size_t newbytes );
+LEPT_DLL extern l_int32 l_byteaAppendString ( L_BYTEA *ba, char *str );
+LEPT_DLL extern l_int32 l_byteaExtendArrayToSize ( L_BYTEA *ba, size_t size );
+LEPT_DLL extern l_int32 l_byteaJoin ( L_BYTEA *ba1, L_BYTEA **pba2 );
+LEPT_DLL extern l_int32 l_byteaSplit ( L_BYTEA *ba1, size_t splitloc, L_BYTEA **pba2 );
+LEPT_DLL extern l_int32 l_byteaFindEachSequence ( L_BYTEA *ba, l_uint8 *sequence, l_int32 seqlen, L_DNA **pda );
+LEPT_DLL extern l_int32 l_byteaWrite ( const char *fname, L_BYTEA *ba, size_t startloc, size_t endloc );
+LEPT_DLL extern l_int32 l_byteaWriteStream ( FILE *fp, L_BYTEA *ba, size_t startloc, size_t endloc );
+LEPT_DLL extern CCBORDA * ccbaCreate ( PIX *pixs, l_int32 n );
+LEPT_DLL extern void ccbaDestroy ( CCBORDA **pccba );
+LEPT_DLL extern CCBORD * ccbCreate ( PIX *pixs );
+LEPT_DLL extern void ccbDestroy ( CCBORD **pccb );
+LEPT_DLL extern l_int32 ccbaAddCcb ( CCBORDA *ccba, CCBORD *ccb );
+LEPT_DLL extern l_int32 ccbaExtendArray ( CCBORDA *ccba );
+LEPT_DLL extern l_int32 ccbaGetCount ( CCBORDA *ccba );
+LEPT_DLL extern CCBORD * ccbaGetCcb ( CCBORDA *ccba, l_int32 index );
+LEPT_DLL extern CCBORDA * pixGetAllCCBorders ( PIX *pixs );
+LEPT_DLL extern CCBORD * pixGetCCBorders ( PIX *pixs, BOX *box );
+LEPT_DLL extern PTAA * pixGetOuterBordersPtaa ( PIX *pixs );
+LEPT_DLL extern PTA * pixGetOuterBorderPta ( PIX *pixs, BOX *box );
+LEPT_DLL extern l_int32 pixGetOuterBorder ( CCBORD *ccb, PIX *pixs, BOX *box );
+LEPT_DLL extern l_int32 pixGetHoleBorder ( CCBORD *ccb, PIX *pixs, BOX *box, l_int32 xs, l_int32 ys );
+LEPT_DLL extern l_int32 findNextBorderPixel ( l_int32 w, l_int32 h, l_uint32 *data, l_int32 wpl, l_int32 px, l_int32 py, l_int32 *pqpos, l_int32 *pnpx, l_int32 *pnpy );
+LEPT_DLL extern void locateOutsideSeedPixel ( l_int32 fpx, l_int32 fpy, l_int32 spx, l_int32 spy, l_int32 *pxs, l_int32 *pys );
+LEPT_DLL extern l_int32 ccbaGenerateGlobalLocs ( CCBORDA *ccba );
+LEPT_DLL extern l_int32 ccbaGenerateStepChains ( CCBORDA *ccba );
+LEPT_DLL extern l_int32 ccbaStepChainsToPixCoords ( CCBORDA *ccba, l_int32 coordtype );
+LEPT_DLL extern l_int32 ccbaGenerateSPGlobalLocs ( CCBORDA *ccba, l_int32 ptsflag );
+LEPT_DLL extern l_int32 ccbaGenerateSinglePath ( CCBORDA *ccba );
+LEPT_DLL extern PTA * getCutPathForHole ( PIX *pix, PTA *pta, BOX *boxinner, l_int32 *pdir, l_int32 *plen );
+LEPT_DLL extern PIX * ccbaDisplayBorder ( CCBORDA *ccba );
+LEPT_DLL extern PIX * ccbaDisplaySPBorder ( CCBORDA *ccba );
+LEPT_DLL extern PIX * ccbaDisplayImage1 ( CCBORDA *ccba );
+LEPT_DLL extern PIX * ccbaDisplayImage2 ( CCBORDA *ccba );
+LEPT_DLL extern l_int32 ccbaWrite ( const char *filename, CCBORDA *ccba );
+LEPT_DLL extern l_int32 ccbaWriteStream ( FILE *fp, CCBORDA *ccba );
+LEPT_DLL extern CCBORDA * ccbaRead ( const char *filename );
+LEPT_DLL extern CCBORDA * ccbaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 ccbaWriteSVG ( const char *filename, CCBORDA *ccba );
+LEPT_DLL extern char * ccbaWriteSVGString ( const char *filename, CCBORDA *ccba );
+LEPT_DLL extern PIX * pixThin ( PIX *pixs, l_int32 type, l_int32 connectivity, l_int32 maxiters );
+LEPT_DLL extern PIX * pixThinGeneral ( PIX *pixs, l_int32 type, SELA *sela, l_int32 maxiters );
+LEPT_DLL extern PIX * pixThinExamples ( PIX *pixs, l_int32 type, l_int32 index, l_int32 maxiters, const char *selfile );
+LEPT_DLL extern l_int32 jbCorrelation ( const char *dirin, l_float32 thresh, l_float32 weight, l_int32 components, const char *rootname, l_int32 firstpage, l_int32 npages, l_int32 renderflag );
+LEPT_DLL extern l_int32 jbRankHaus ( const char *dirin, l_int32 size, l_float32 rank, l_int32 components, const char *rootname, l_int32 firstpage, l_int32 npages, l_int32 renderflag );
+LEPT_DLL extern JBCLASSER * jbWordsInTextlines ( const char *dirin, l_int32 reduction, l_int32 maxwidth, l_int32 maxheight, l_float32 thresh, l_float32 weight, NUMA **pnatl, l_int32 firstpage, l_int32 npages );
+LEPT_DLL extern l_int32 pixGetWordsInTextlines ( PIX *pixs, l_int32 reduction, l_int32 minwidth, l_int32 minheight, l_int32 maxwidth, l_int32 maxheight, BOXA **pboxad, PIXA **ppixad, NUMA **pnai );
+LEPT_DLL extern l_int32 pixGetWordBoxesInTextlines ( PIX *pixs, l_int32 reduction, l_int32 minwidth, l_int32 minheight, l_int32 maxwidth, l_int32 maxheight, BOXA **pboxad, NUMA **pnai );
+LEPT_DLL extern NUMAA * boxaExtractSortedPattern ( BOXA *boxa, NUMA *na );
+LEPT_DLL extern l_int32 numaaCompareImagesByBoxes ( NUMAA *naa1, NUMAA *naa2, l_int32 nperline, l_int32 nreq, l_int32 maxshiftx, l_int32 maxshifty, l_int32 delx, l_int32 dely, l_int32 *psame, l_int32 debugflag );
+LEPT_DLL extern l_int32 pixColorContent ( PIX *pixs, l_int32 rwhite, l_int32 gwhite, l_int32 bwhite, l_int32 mingray, PIX **ppixr, PIX **ppixg, PIX **ppixb );
+LEPT_DLL extern PIX * pixColorMagnitude ( PIX *pixs, l_int32 rwhite, l_int32 gwhite, l_int32 bwhite, l_int32 type );
+LEPT_DLL extern PIX * pixMaskOverColorPixels ( PIX *pixs, l_int32 threshdiff, l_int32 mindist );
+LEPT_DLL extern l_int32 pixColorFraction ( PIX *pixs, l_int32 darkthresh, l_int32 lightthresh, l_int32 diffthresh, l_int32 factor, l_float32 *ppixfract, l_float32 *pcolorfract );
+LEPT_DLL extern l_int32 pixNumSignificantGrayColors ( PIX *pixs, l_int32 darkthresh, l_int32 lightthresh, l_float32 minfract, l_int32 factor, l_int32 *pncolors );
+LEPT_DLL extern l_int32 pixColorsForQuantization ( PIX *pixs, l_int32 thresh, l_int32 *pncolors, l_int32 *piscolor, l_int32 debug );
+LEPT_DLL extern l_int32 pixNumColors ( PIX *pixs, l_int32 factor, l_int32 *pncolors );
+LEPT_DLL extern l_int32 pixColorGray ( PIX *pixs, BOX *box, l_int32 type, l_int32 thresh, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern PIX * pixSnapColor ( PIX *pixd, PIX *pixs, l_uint32 srcval, l_uint32 dstval, l_int32 diff );
+LEPT_DLL extern PIX * pixSnapColorCmap ( PIX *pixd, PIX *pixs, l_uint32 srcval, l_uint32 dstval, l_int32 diff );
+LEPT_DLL extern PIX * pixLinearMapToTargetColor ( PIX *pixd, PIX *pixs, l_uint32 srcval, l_uint32 dstval );
+LEPT_DLL extern l_int32 pixelLinearMapToTargetColor ( l_uint32 scolor, l_uint32 srcmap, l_uint32 dstmap, l_uint32 *pdcolor );
+LEPT_DLL extern PIX * pixShiftByComponent ( PIX *pixd, PIX *pixs, l_uint32 srcval, l_uint32 dstval );
+LEPT_DLL extern l_int32 pixelShiftByComponent ( l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 srcval, l_uint32 dstval, l_uint32 *ppixel );
+LEPT_DLL extern l_int32 pixelFractionalShift ( l_int32 rval, l_int32 gval, l_int32 bval, l_float32 fraction, l_uint32 *ppixel );
+LEPT_DLL extern PIXCMAP * pixcmapCreate ( l_int32 depth );
+LEPT_DLL extern PIXCMAP * pixcmapCreateRandom ( l_int32 depth, l_int32 hasblack, l_int32 haswhite );
+LEPT_DLL extern PIXCMAP * pixcmapCreateLinear ( l_int32 d, l_int32 nlevels );
+LEPT_DLL extern PIXCMAP * pixcmapCopy ( PIXCMAP *cmaps );
+LEPT_DLL extern void pixcmapDestroy ( PIXCMAP **pcmap );
+LEPT_DLL extern l_int32 pixcmapAddColor ( PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern l_int32 pixcmapAddNewColor ( PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex );
+LEPT_DLL extern l_int32 pixcmapAddNearestColor ( PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex );
+LEPT_DLL extern l_int32 pixcmapUsableColor ( PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pusable );
+LEPT_DLL extern l_int32 pixcmapAddBlackOrWhite ( PIXCMAP *cmap, l_int32 color, l_int32 *pindex );
+LEPT_DLL extern l_int32 pixcmapSetBlackAndWhite ( PIXCMAP *cmap, l_int32 setblack, l_int32 setwhite );
+LEPT_DLL extern l_int32 pixcmapGetCount ( PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixcmapGetFreeCount ( PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixcmapGetDepth ( PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixcmapGetMinDepth ( PIXCMAP *cmap, l_int32 *pmindepth );
+LEPT_DLL extern l_int32 pixcmapClear ( PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixcmapGetColor ( PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval );
+LEPT_DLL extern l_int32 pixcmapGetColor32 ( PIXCMAP *cmap, l_int32 index, l_uint32 *pval32 );
+LEPT_DLL extern l_int32 pixcmapResetColor ( PIXCMAP *cmap, l_int32 index, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern l_int32 pixcmapGetIndex ( PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex );
+LEPT_DLL extern l_int32 pixcmapHasColor ( PIXCMAP *cmap, l_int32 *pcolor );
+LEPT_DLL extern l_int32 pixcmapCountGrayColors ( PIXCMAP *cmap, l_int32 *pngray );
+LEPT_DLL extern l_int32 pixcmapGetRankIntensity ( PIXCMAP *cmap, l_float32 rankval, l_int32 *pindex );
+LEPT_DLL extern l_int32 pixcmapGetNearestIndex ( PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex );
+LEPT_DLL extern l_int32 pixcmapGetNearestGrayIndex ( PIXCMAP *cmap, l_int32 val, l_int32 *pindex );
+LEPT_DLL extern l_int32 pixcmapGetComponentRange ( PIXCMAP *cmap, l_int32 color, l_int32 *pminval, l_int32 *pmaxval );
+LEPT_DLL extern l_int32 pixcmapGetExtremeValue ( PIXCMAP *cmap, l_int32 type, l_int32 *prval, l_int32 *pgval, l_int32 *pbval );
+LEPT_DLL extern PIXCMAP * pixcmapGrayToColor ( l_uint32 color );
+LEPT_DLL extern PIXCMAP * pixcmapColorToGray ( PIXCMAP *cmaps, l_float32 rwt, l_float32 gwt, l_float32 bwt );
+LEPT_DLL extern PIXCMAP * pixcmapReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 pixcmapWriteStream ( FILE *fp, PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixcmapToArrays ( PIXCMAP *cmap, l_int32 **prmap, l_int32 **pgmap, l_int32 **pbmap );
+LEPT_DLL extern l_int32 pixcmapToRGBTable ( PIXCMAP *cmap, l_uint32 **ptab, l_int32 *pncolors );
+LEPT_DLL extern l_int32 pixcmapSerializeToMemory ( PIXCMAP *cmap, l_int32 cpc, l_int32 *pncolors, l_uint8 **pdata, l_int32 *pnbytes );
+LEPT_DLL extern PIXCMAP * pixcmapDeserializeFromMemory ( l_uint8 *data, l_int32 ncolors, l_int32 nbytes );
+LEPT_DLL extern char * pixcmapConvertToHex ( l_uint8 *data, l_int32 nbytes, l_int32 ncolors );
+LEPT_DLL extern l_int32 pixcmapGammaTRC ( PIXCMAP *cmap, l_float32 gamma, l_int32 minval, l_int32 maxval );
+LEPT_DLL extern l_int32 pixcmapContrastTRC ( PIXCMAP *cmap, l_float32 factor );
+LEPT_DLL extern l_int32 pixcmapShiftIntensity ( PIXCMAP *cmap, l_float32 fraction );
+LEPT_DLL extern l_int32 pixcmapShiftByComponent ( PIXCMAP *cmap, l_uint32 srcval, l_uint32 dstval );
+LEPT_DLL extern PIX * pixColorMorph ( PIX *pixs, l_int32 type, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOctreeColorQuant ( PIX *pixs, l_int32 colors, l_int32 ditherflag );
+LEPT_DLL extern PIX * pixOctreeColorQuantGeneral ( PIX *pixs, l_int32 colors, l_int32 ditherflag, l_float32 validthresh, l_float32 colorthresh );
+LEPT_DLL extern l_int32 makeRGBToIndexTables ( l_uint32 **prtab, l_uint32 **pgtab, l_uint32 **pbtab, l_int32 cqlevels );
+LEPT_DLL extern void getOctcubeIndexFromRGB ( l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *rtab, l_uint32 *gtab, l_uint32 *btab, l_uint32 *pindex );
+LEPT_DLL extern PIX * pixOctreeQuantByPopulation ( PIX *pixs, l_int32 level, l_int32 ditherflag );
+LEPT_DLL extern PIX * pixOctreeQuantNumColors ( PIX *pixs, l_int32 maxcolors, l_int32 subsample );
+LEPT_DLL extern PIX * pixOctcubeQuantMixedWithGray ( PIX *pixs, l_int32 depth, l_int32 graylevels, l_int32 delta );
+LEPT_DLL extern PIX * pixFixedOctcubeQuant256 ( PIX *pixs, l_int32 ditherflag );
+LEPT_DLL extern PIX * pixFewColorsOctcubeQuant1 ( PIX *pixs, l_int32 level );
+LEPT_DLL extern PIX * pixFewColorsOctcubeQuant2 ( PIX *pixs, l_int32 level, NUMA *na, l_int32 ncolors, l_int32 *pnerrors );
+LEPT_DLL extern PIX * pixFewColorsOctcubeQuantMixed ( PIX *pixs, l_int32 level, l_int32 darkthresh, l_int32 lightthresh, l_int32 diffthresh, l_float32 minfract, l_int32 maxspan );
+LEPT_DLL extern PIX * pixFixedOctcubeQuantGenRGB ( PIX *pixs, l_int32 level );
+LEPT_DLL extern PIX * pixQuantFromCmap ( PIX *pixs, PIXCMAP *cmap, l_int32 mindepth, l_int32 level, l_int32 metric );
+LEPT_DLL extern PIX * pixOctcubeQuantFromCmap ( PIX *pixs, PIXCMAP *cmap, l_int32 mindepth, l_int32 level, l_int32 metric );
+LEPT_DLL extern PIX * pixOctcubeQuantFromCmapLUT ( PIX *pixs, PIXCMAP *cmap, l_int32 mindepth, l_int32 *cmaptab, l_uint32 *rtab, l_uint32 *gtab, l_uint32 *btab );
+LEPT_DLL extern NUMA * pixOctcubeHistogram ( PIX *pixs, l_int32 level, l_int32 *pncolors );
+LEPT_DLL extern l_int32 * pixcmapToOctcubeLUT ( PIXCMAP *cmap, l_int32 level, l_int32 metric );
+LEPT_DLL extern l_int32 pixRemoveUnusedColors ( PIX *pixs );
+LEPT_DLL extern l_int32 pixNumberOccupiedOctcubes ( PIX *pix, l_int32 level, l_int32 mincount, l_float32 minfract, l_int32 *pncolors );
+LEPT_DLL extern PIX * pixMedianCutQuant ( PIX *pixs, l_int32 ditherflag );
+LEPT_DLL extern PIX * pixMedianCutQuantGeneral ( PIX *pixs, l_int32 ditherflag, l_int32 outdepth, l_int32 maxcolors, l_int32 sigbits, l_int32 maxsub, l_int32 checkbw );
+LEPT_DLL extern PIX * pixMedianCutQuantMixed ( PIX *pixs, l_int32 ncolor, l_int32 ngray, l_int32 darkthresh, l_int32 lightthresh, l_int32 diffthresh );
+LEPT_DLL extern PIX * pixFewColorsMedianCutQuantMixed ( PIX *pixs, l_int32 ncolor, l_int32 ngray, l_int32 maxncolors, l_int32 darkthresh, l_int32 lightthresh, l_int32 diffthresh );
+LEPT_DLL extern l_int32 * pixMedianCutHisto ( PIX *pixs, l_int32 sigbits, l_int32 subsample );
+LEPT_DLL extern PIX * pixColorSegment ( PIX *pixs, l_int32 maxdist, l_int32 maxcolors, l_int32 selsize, l_int32 finalcolors );
+LEPT_DLL extern PIX * pixColorSegmentCluster ( PIX *pixs, l_int32 maxdist, l_int32 maxcolors );
+LEPT_DLL extern l_int32 pixAssignToNearestColor ( PIX *pixd, PIX *pixs, PIX *pixm, l_int32 level, l_int32 *countarray );
+LEPT_DLL extern l_int32 pixColorSegmentClean ( PIX *pixs, l_int32 selsize, l_int32 *countarray );
+LEPT_DLL extern l_int32 pixColorSegmentRemoveColors ( PIX *pixd, PIX *pixs, l_int32 finalcolors );
+LEPT_DLL extern PIX * pixConvertRGBToHSV ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern PIX * pixConvertHSVToRGB ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern l_int32 convertRGBToHSV ( l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *phval, l_int32 *psval, l_int32 *pvval );
+LEPT_DLL extern l_int32 convertHSVToRGB ( l_int32 hval, l_int32 sval, l_int32 vval, l_int32 *prval, l_int32 *pgval, l_int32 *pbval );
+LEPT_DLL extern l_int32 pixcmapConvertRGBToHSV ( PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixcmapConvertHSVToRGB ( PIXCMAP *cmap );
+LEPT_DLL extern PIX * pixConvertRGBToHue ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertRGBToSaturation ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertRGBToValue ( PIX *pixs );
+LEPT_DLL extern PIX * pixMakeRangeMaskHS ( PIX *pixs, l_int32 huecenter, l_int32 huehw, l_int32 satcenter, l_int32 sathw, l_int32 regionflag );
+LEPT_DLL extern PIX * pixMakeRangeMaskHV ( PIX *pixs, l_int32 huecenter, l_int32 huehw, l_int32 valcenter, l_int32 valhw, l_int32 regionflag );
+LEPT_DLL extern PIX * pixMakeRangeMaskSV ( PIX *pixs, l_int32 satcenter, l_int32 sathw, l_int32 valcenter, l_int32 valhw, l_int32 regionflag );
+LEPT_DLL extern PIX * pixMakeHistoHS ( PIX *pixs, l_int32 factor, NUMA **pnahue, NUMA **pnasat );
+LEPT_DLL extern PIX * pixMakeHistoHV ( PIX *pixs, l_int32 factor, NUMA **pnahue, NUMA **pnaval );
+LEPT_DLL extern PIX * pixMakeHistoSV ( PIX *pixs, l_int32 factor, NUMA **pnasat, NUMA **pnaval );
+LEPT_DLL extern l_int32 pixFindHistoPeaksHSV ( PIX *pixs, l_int32 type, l_int32 width, l_int32 height, l_int32 npeaks, l_float32 erasefactor, PTA **ppta, NUMA **pnatot, PIXA **ppixa );
+LEPT_DLL extern PIX * displayHSVColorRange ( l_int32 hval, l_int32 sval, l_int32 vval, l_int32 huehw, l_int32 sathw, l_int32 nsamp, l_int32 factor );
+LEPT_DLL extern PIX * pixConvertRGBToYUV ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern PIX * pixConvertYUVToRGB ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern l_int32 convertRGBToYUV ( l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pyval, l_int32 *puval, l_int32 *pvval );
+LEPT_DLL extern l_int32 convertYUVToRGB ( l_int32 yval, l_int32 uval, l_int32 vval, l_int32 *prval, l_int32 *pgval, l_int32 *pbval );
+LEPT_DLL extern l_int32 pixcmapConvertRGBToYUV ( PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixcmapConvertYUVToRGB ( PIXCMAP *cmap );
+LEPT_DLL extern l_int32 pixEqual ( PIX *pix1, PIX *pix2, l_int32 *psame );
+LEPT_DLL extern l_int32 pixEqualWithCmap ( PIX *pix1, PIX *pix2, l_int32 *psame );
+LEPT_DLL extern l_int32 pixUsesCmapColor ( PIX *pixs, l_int32 *pcolor );
+LEPT_DLL extern l_int32 pixCorrelationBinary ( PIX *pix1, PIX *pix2, l_float32 *pval );
+LEPT_DLL extern PIX * pixDisplayDiffBinary ( PIX *pix1, PIX *pix2 );
+LEPT_DLL extern l_int32 pixCompareBinary ( PIX *pix1, PIX *pix2, l_int32 comptype, l_float32 *pfract, PIX **ppixdiff );
+LEPT_DLL extern l_int32 pixCompareGrayOrRGB ( PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff );
+LEPT_DLL extern l_int32 pixCompareGray ( PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff );
+LEPT_DLL extern l_int32 pixCompareRGB ( PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff );
+LEPT_DLL extern l_int32 pixCompareTiled ( PIX *pix1, PIX *pix2, l_int32 sx, l_int32 sy, l_int32 type, PIX **ppixdiff );
+LEPT_DLL extern NUMA * pixCompareRankDifference ( PIX *pix1, PIX *pix2, l_int32 factor );
+LEPT_DLL extern l_int32 pixTestForSimilarity ( PIX *pix1, PIX *pix2, l_int32 factor, l_int32 mindiff, l_float32 maxfract, l_float32 maxave, l_int32 *psimilar, l_int32 printstats );
+LEPT_DLL extern l_int32 pixGetDifferenceStats ( PIX *pix1, PIX *pix2, l_int32 factor, l_int32 mindiff, l_float32 *pfractdiff, l_float32 *pavediff, l_int32 printstats );
+LEPT_DLL extern NUMA * pixGetDifferenceHistogram ( PIX *pix1, PIX *pix2, l_int32 factor );
+LEPT_DLL extern l_int32 pixGetPSNR ( PIX *pix1, PIX *pix2, l_int32 factor, l_float32 *ppsnr );
+LEPT_DLL extern l_int32 pixCompareWithTranslation ( PIX *pix1, PIX *pix2, l_int32 thresh, l_int32 *pdelx, l_int32 *pdely, l_float32 *pscore, l_int32 debugflag );
+LEPT_DLL extern BOXA * pixConnComp ( PIX *pixs, PIXA **ppixa, l_int32 connectivity );
+LEPT_DLL extern BOXA * pixConnCompPixa ( PIX *pixs, PIXA **ppixa, l_int32 connectivity );
+LEPT_DLL extern BOXA * pixConnCompBB ( PIX *pixs, l_int32 connectivity );
+LEPT_DLL extern l_int32 pixCountConnComp ( PIX *pixs, l_int32 connectivity, l_int32 *pcount );
+LEPT_DLL extern l_int32 nextOnPixelInRaster ( PIX *pixs, l_int32 xstart, l_int32 ystart, l_int32 *px, l_int32 *py );
+LEPT_DLL extern l_int32 nextOnPixelInRasterLow ( l_uint32 *data, l_int32 w, l_int32 h, l_int32 wpl, l_int32 xstart, l_int32 ystart, l_int32 *px, l_int32 *py );
+LEPT_DLL extern BOX * pixSeedfillBB ( PIX *pixs, L_STACK *stack, l_int32 x, l_int32 y, l_int32 connectivity );
+LEPT_DLL extern BOX * pixSeedfill4BB ( PIX *pixs, L_STACK *stack, l_int32 x, l_int32 y );
+LEPT_DLL extern BOX * pixSeedfill8BB ( PIX *pixs, L_STACK *stack, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 pixSeedfill ( PIX *pixs, L_STACK *stack, l_int32 x, l_int32 y, l_int32 connectivity );
+LEPT_DLL extern l_int32 pixSeedfill4 ( PIX *pixs, L_STACK *stack, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 pixSeedfill8 ( PIX *pixs, L_STACK *stack, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 convertFilesTo1bpp ( const char *dirin, const char *substr, l_int32 upscaling, l_int32 thresh, l_int32 firstpage, l_int32 npages, const char *dirout, l_int32 outformat );
+LEPT_DLL extern PIX * pixBlockconv ( PIX *pix, l_int32 wc, l_int32 hc );
+LEPT_DLL extern PIX * pixBlockconvGray ( PIX *pixs, PIX *pixacc, l_int32 wc, l_int32 hc );
+LEPT_DLL extern PIX * pixBlockconvAccum ( PIX *pixs );
+LEPT_DLL extern PIX * pixBlockconvGrayUnnormalized ( PIX *pixs, l_int32 wc, l_int32 hc );
+LEPT_DLL extern PIX * pixBlockconvTiled ( PIX *pix, l_int32 wc, l_int32 hc, l_int32 nx, l_int32 ny );
+LEPT_DLL extern PIX * pixBlockconvGrayTile ( PIX *pixs, PIX *pixacc, l_int32 wc, l_int32 hc );
+LEPT_DLL extern l_int32 pixWindowedStats ( PIX *pixs, l_int32 wc, l_int32 hc, l_int32 hasborder, PIX **ppixm, PIX **ppixms, FPIX **pfpixv, FPIX **pfpixrv );
+LEPT_DLL extern PIX * pixWindowedMean ( PIX *pixs, l_int32 wc, l_int32 hc, l_int32 hasborder, l_int32 normflag );
+LEPT_DLL extern PIX * pixWindowedMeanSquare ( PIX *pixs, l_int32 wc, l_int32 hc, l_int32 hasborder );
+LEPT_DLL extern l_int32 pixWindowedVariance ( PIX *pixm, PIX *pixms, FPIX **pfpixv, FPIX **pfpixrv );
+LEPT_DLL extern DPIX * pixMeanSquareAccum ( PIX *pixs );
+LEPT_DLL extern PIX * pixBlockrank ( PIX *pixs, PIX *pixacc, l_int32 wc, l_int32 hc, l_float32 rank );
+LEPT_DLL extern PIX * pixBlocksum ( PIX *pixs, PIX *pixacc, l_int32 wc, l_int32 hc );
+LEPT_DLL extern PIX * pixCensusTransform ( PIX *pixs, l_int32 halfsize, PIX *pixacc );
+LEPT_DLL extern PIX * pixConvolve ( PIX *pixs, L_KERNEL *kel, l_int32 outdepth, l_int32 normflag );
+LEPT_DLL extern PIX * pixConvolveSep ( PIX *pixs, L_KERNEL *kelx, L_KERNEL *kely, l_int32 outdepth, l_int32 normflag );
+LEPT_DLL extern PIX * pixConvolveRGB ( PIX *pixs, L_KERNEL *kel );
+LEPT_DLL extern PIX * pixConvolveRGBSep ( PIX *pixs, L_KERNEL *kelx, L_KERNEL *kely );
+LEPT_DLL extern FPIX * fpixConvolve ( FPIX *fpixs, L_KERNEL *kel, l_int32 normflag );
+LEPT_DLL extern FPIX * fpixConvolveSep ( FPIX *fpixs, L_KERNEL *kelx, L_KERNEL *kely, l_int32 normflag );
+LEPT_DLL extern void l_setConvolveSampling ( l_int32 xfact, l_int32 yfact );
+LEPT_DLL extern void blockconvLow ( l_uint32 *data, l_int32 w, l_int32 h, l_int32 wpl, l_uint32 *dataa, l_int32 wpla, l_int32 wc, l_int32 hc );
+LEPT_DLL extern void blockconvAccumLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 d, l_int32 wpls );
+LEPT_DLL extern void blocksumLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpl, l_uint32 *dataa, l_int32 wpla, l_int32 wc, l_int32 hc );
+LEPT_DLL extern l_float32 pixCorrelationScore ( PIX *pix1, PIX *pix2, l_int32 area1, l_int32 area2, l_float32 delx, l_float32 dely, l_int32 maxdiffw, l_int32 maxdiffh, l_int32 *tab );
+LEPT_DLL extern l_int32 pixCorrelationScoreThresholded ( PIX *pix1, PIX *pix2, l_int32 area1, l_int32 area2, l_float32 delx, l_float32 dely, l_int32 maxdiffw, l_int32 maxdiffh, l_int32 *tab, l_int32 *downcount, l_float32 score_threshold );
+LEPT_DLL extern l_float32 pixCorrelationScoreSimple ( PIX *pix1, PIX *pix2, l_int32 area1, l_int32 area2, l_float32 delx, l_float32 dely, l_int32 maxdiffw, l_int32 maxdiffh, l_int32 *tab );
+LEPT_DLL extern l_float32 pixCorrelationScoreShifted ( PIX *pix1, PIX *pix2, l_int32 area1, l_int32 area2, l_int32 delx, l_int32 dely, l_int32 *tab );
+LEPT_DLL extern l_int32 pixBestCorrelation ( PIX *pix1, PIX *pix2, l_int32 area1, l_int32 area2, l_int32 etransx, l_int32 etransy, l_int32 maxshift, l_int32 *tab8, l_int32 *pdelx, l_int32 *pdely, l_float32 *pscore, l_int32 debugflag );
+LEPT_DLL extern L_DEWARP * dewarpCreate ( PIX *pixs, l_int32 pageno );
+LEPT_DLL extern L_DEWARP * dewarpCreateReference ( l_int32 pageno, l_int32 refpage );
+LEPT_DLL extern void dewarpDestroy ( L_DEWARP **pdew );
+LEPT_DLL extern L_DEWARPA * dewarpaCreate ( l_int32 nptrs, l_int32 sampling, l_int32 redfactor, l_int32 minlines, l_int32 maxdist );
+LEPT_DLL extern L_DEWARPA * dewarpaCreateFromPixacomp ( PIXAC *pixac, l_int32 sampling, l_int32 minlines, l_int32 maxdist );
+LEPT_DLL extern void dewarpaDestroy ( L_DEWARPA **pdewa );
+LEPT_DLL extern l_int32 dewarpaDestroyDewarp ( L_DEWARPA *dewa, l_int32 pageno );
+LEPT_DLL extern l_int32 dewarpaInsertDewarp ( L_DEWARPA *dewa, L_DEWARP *dew );
+LEPT_DLL extern l_int32 dewarpaExtendArrayToSize ( L_DEWARPA *dewa, l_int32 size );
+LEPT_DLL extern l_int32 dewarpBuildModel ( L_DEWARP *dew, const char *debugfile );
+LEPT_DLL extern l_int32 dewarpFindVertDisparity ( L_DEWARP *dew, PTAA *ptaa );
+LEPT_DLL extern l_int32 dewarpFindHorizDisparity ( L_DEWARP *dew, PTAA *ptaa );
+LEPT_DLL extern PTAA * dewarpGetTextlineCenters ( PIX *pixs, l_int32 debugflag );
+LEPT_DLL extern PTAA * dewarpRemoveShortLines ( PIX *pixs, PTAA *ptaas, l_float32 fract, l_int32 debugflag );
+LEPT_DLL extern l_int32 dewarpaApplyDisparity ( L_DEWARPA *dewa, l_int32 pageno, PIX *pixs, const char *debugfile );
+LEPT_DLL extern l_int32 dewarpMinimize ( L_DEWARP *dew );
+LEPT_DLL extern l_int32 dewarpPopulateFullRes ( L_DEWARP *dew, PIX *pix );
+LEPT_DLL extern L_DEWARP * dewarpaGetDewarp ( L_DEWARPA *dewa, l_int32 index );
+LEPT_DLL extern PIX * dewarpaGetResult ( L_DEWARPA *dewa, l_int32 index );
+LEPT_DLL extern PIX * dewarpGetResult ( L_DEWARP *dew );
+LEPT_DLL extern l_int32 dewarpaListPages ( L_DEWARPA *dewa );
+LEPT_DLL extern l_int32 dewarpaSetValidModels ( L_DEWARPA *dewa, l_int32 debug );
+LEPT_DLL extern l_int32 dewarpaInsertRefModels ( L_DEWARPA *dewa, l_int32 debug );
+LEPT_DLL extern l_int32 dewarpaStripRefModels ( L_DEWARPA *dewa );
+LEPT_DLL extern l_int32 dewarpaSetCurvatures ( L_DEWARPA *dewa, l_int32 min_medcurv, l_int32 max_medcurv, l_int32 max_leftcurv, l_int32 max_rightcurv );
+LEPT_DLL extern l_int32 dewarpaUseFullModel ( L_DEWARPA *dewa, l_int32 fullmodel );
+LEPT_DLL extern l_int32 dewarpaSetMaxDistance ( L_DEWARPA *dewa, l_int32 maxdist );
+LEPT_DLL extern L_DEWARP * dewarpRead ( const char *filename );
+LEPT_DLL extern L_DEWARP * dewarpReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 dewarpWrite ( const char *filename, L_DEWARP *dew );
+LEPT_DLL extern l_int32 dewarpWriteStream ( FILE *fp, L_DEWARP *dew );
+LEPT_DLL extern L_DEWARPA * dewarpaRead ( const char *filename );
+LEPT_DLL extern L_DEWARPA * dewarpaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 dewarpaWrite ( const char *filename, L_DEWARPA *dewa );
+LEPT_DLL extern l_int32 dewarpaWriteStream ( FILE *fp, L_DEWARPA *dewa );
+LEPT_DLL extern l_int32 dewarpaInfo ( FILE *fp, L_DEWARPA *dewa );
+LEPT_DLL extern l_int32 dewarpaModelStats ( L_DEWARPA *dewa, l_int32 *pnnone, l_int32 *pnactual, l_int32 *pnvalid, l_int32 *pnref );
+LEPT_DLL extern l_int32 dewarpaShowArrays ( L_DEWARPA *dewa, l_float32 scalefact, l_int32 first, l_int32 last );
+LEPT_DLL extern l_int32 dewarpDebug ( L_DEWARP *dew, const char *subdir, l_int32 index );
+LEPT_DLL extern l_int32 dewarpShowResults ( L_DEWARPA *dewa, SARRAY *sa, BOXA *boxa, l_int32 firstpage, l_int32 lastpage, const char *pdfout );
+LEPT_DLL extern L_DNA * l_dnaCreate ( l_int32 n );
+LEPT_DLL extern L_DNA * l_dnaCreateFromIArray ( l_int32 *iarray, l_int32 size );
+LEPT_DLL extern L_DNA * l_dnaCreateFromDArray ( l_float64 *darray, l_int32 size, l_int32 copyflag );
+LEPT_DLL extern L_DNA * l_dnaMakeSequence ( l_float64 startval, l_float64 increment, l_int32 size );
+LEPT_DLL extern void l_dnaDestroy ( L_DNA **pda );
+LEPT_DLL extern L_DNA * l_dnaCopy ( L_DNA *da );
+LEPT_DLL extern L_DNA * l_dnaClone ( L_DNA *da );
+LEPT_DLL extern l_int32 l_dnaEmpty ( L_DNA *da );
+LEPT_DLL extern l_int32 l_dnaAddNumber ( L_DNA *da, l_float64 val );
+LEPT_DLL extern l_int32 l_dnaExtendArray ( L_DNA *da );
+LEPT_DLL extern l_int32 l_dnaInsertNumber ( L_DNA *da, l_int32 index, l_float64 val );
+LEPT_DLL extern l_int32 l_dnaRemoveNumber ( L_DNA *da, l_int32 index );
+LEPT_DLL extern l_int32 l_dnaReplaceNumber ( L_DNA *da, l_int32 index, l_float64 val );
+LEPT_DLL extern l_int32 l_dnaGetCount ( L_DNA *da );
+LEPT_DLL extern l_int32 l_dnaSetCount ( L_DNA *da, l_int32 newcount );
+LEPT_DLL extern l_int32 l_dnaGetDValue ( L_DNA *da, l_int32 index, l_float64 *pval );
+LEPT_DLL extern l_int32 l_dnaGetIValue ( L_DNA *da, l_int32 index, l_int32 *pival );
+LEPT_DLL extern l_int32 l_dnaSetValue ( L_DNA *da, l_int32 index, l_float64 val );
+LEPT_DLL extern l_int32 l_dnaShiftValue ( L_DNA *da, l_int32 index, l_float64 diff );
+LEPT_DLL extern l_int32 * l_dnaGetIArray ( L_DNA *da );
+LEPT_DLL extern l_float64 * l_dnaGetDArray ( L_DNA *da, l_int32 copyflag );
+LEPT_DLL extern l_int32 l_dnaGetRefcount ( L_DNA *da );
+LEPT_DLL extern l_int32 l_dnaChangeRefcount ( L_DNA *da, l_int32 delta );
+LEPT_DLL extern l_int32 l_dnaGetXParameters ( L_DNA *da, l_float64 *pstartx, l_float64 *pdelx );
+LEPT_DLL extern l_int32 l_dnaSetXParameters ( L_DNA *da, l_float64 startx, l_float64 delx );
+LEPT_DLL extern l_int32 l_dnaCopyXParameters ( L_DNA *dad, L_DNA *das );
+LEPT_DLL extern L_DNA * l_dnaRead ( const char *filename );
+LEPT_DLL extern L_DNA * l_dnaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 l_dnaWrite ( const char *filename, L_DNA *da );
+LEPT_DLL extern l_int32 l_dnaWriteStream ( FILE *fp, L_DNA *da );
+LEPT_DLL extern L_DNAA * l_dnaaCreate ( l_int32 n );
+LEPT_DLL extern void l_dnaaDestroy ( L_DNAA **pdaa );
+LEPT_DLL extern l_int32 l_dnaaAddDna ( L_DNAA *daa, L_DNA *da, l_int32 copyflag );
+LEPT_DLL extern l_int32 l_dnaaExtendArray ( L_DNAA *daa );
+LEPT_DLL extern l_int32 l_dnaaGetCount ( L_DNAA *daa );
+LEPT_DLL extern l_int32 l_dnaaGetDnaCount ( L_DNAA *daa, l_int32 index );
+LEPT_DLL extern l_int32 l_dnaaGetNumberCount ( L_DNAA *daa );
+LEPT_DLL extern L_DNA * l_dnaaGetDna ( L_DNAA *daa, l_int32 index, l_int32 accessflag );
+LEPT_DLL extern l_int32 l_dnaaReplaceDna ( L_DNAA *daa, l_int32 index, L_DNA *da );
+LEPT_DLL extern l_int32 l_dnaaGetValue ( L_DNAA *daa, l_int32 i, l_int32 j, l_float64 *pval );
+LEPT_DLL extern l_int32 l_dnaaAddNumber ( L_DNAA *daa, l_int32 index, l_float64 val );
+LEPT_DLL extern L_DNAA * l_dnaaRead ( const char *filename );
+LEPT_DLL extern L_DNAA * l_dnaaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 l_dnaaWrite ( const char *filename, L_DNAA *daa );
+LEPT_DLL extern l_int32 l_dnaaWriteStream ( FILE *fp, L_DNAA *daa );
+LEPT_DLL extern L_DNA * l_dnaMakeDelta ( L_DNA *das );
+LEPT_DLL extern NUMA * l_dnaConvertToNuma ( L_DNA *da );
+LEPT_DLL extern L_DNA * numaConvertToDna ( NUMA *na );
+LEPT_DLL extern PIX * pixMorphDwa_2 ( PIX *pixd, PIX *pixs, l_int32 operation, char *selname );
+LEPT_DLL extern PIX * pixFMorphopGen_2 ( PIX *pixd, PIX *pixs, l_int32 operation, char *selname );
+LEPT_DLL extern l_int32 fmorphopgen_low_2 ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 index );
+LEPT_DLL extern PIX * pixSobelEdgeFilter ( PIX *pixs, l_int32 orientflag );
+LEPT_DLL extern PIX * pixTwoSidedEdgeFilter ( PIX *pixs, l_int32 orientflag );
+LEPT_DLL extern l_int32 pixMeasureEdgeSmoothness ( PIX *pixs, l_int32 side, l_int32 minjump, l_int32 minreversal, l_float32 *pjpl, l_float32 *pjspl, l_float32 *prpl, const char *debugfile );
+LEPT_DLL extern NUMA * pixGetEdgeProfile ( PIX *pixs, l_int32 side, const char *debugfile );
+LEPT_DLL extern l_int32 pixGetLastOffPixelInRun ( PIX *pixs, l_int32 x, l_int32 y, l_int32 direction, l_int32 *ploc );
+LEPT_DLL extern l_int32 pixGetLastOnPixelInRun ( PIX *pixs, l_int32 x, l_int32 y, l_int32 direction, l_int32 *ploc );
+LEPT_DLL extern PIX * pixGammaTRC ( PIX *pixd, PIX *pixs, l_float32 gamma, l_int32 minval, l_int32 maxval );
+LEPT_DLL extern PIX * pixGammaTRCMasked ( PIX *pixd, PIX *pixs, PIX *pixm, l_float32 gamma, l_int32 minval, l_int32 maxval );
+LEPT_DLL extern PIX * pixGammaTRCWithAlpha ( PIX *pixd, PIX *pixs, l_float32 gamma, l_int32 minval, l_int32 maxval );
+LEPT_DLL extern NUMA * numaGammaTRC ( l_float32 gamma, l_int32 minval, l_int32 maxval );
+LEPT_DLL extern PIX * pixContrastTRC ( PIX *pixd, PIX *pixs, l_float32 factor );
+LEPT_DLL extern PIX * pixContrastTRCMasked ( PIX *pixd, PIX *pixs, PIX *pixm, l_float32 factor );
+LEPT_DLL extern NUMA * numaContrastTRC ( l_float32 factor );
+LEPT_DLL extern PIX * pixEqualizeTRC ( PIX *pixd, PIX *pixs, l_float32 fract, l_int32 factor );
+LEPT_DLL extern NUMA * numaEqualizeTRC ( PIX *pix, l_float32 fract, l_int32 factor );
+LEPT_DLL extern l_int32 pixTRCMap ( PIX *pixs, PIX *pixm, NUMA *na );
+LEPT_DLL extern PIX * pixUnsharpMasking ( PIX *pixs, l_int32 halfwidth, l_float32 fract );
+LEPT_DLL extern PIX * pixUnsharpMaskingGray ( PIX *pixs, l_int32 halfwidth, l_float32 fract );
+LEPT_DLL extern PIX * pixUnsharpMaskingFast ( PIX *pixs, l_int32 halfwidth, l_float32 fract, l_int32 direction );
+LEPT_DLL extern PIX * pixUnsharpMaskingGrayFast ( PIX *pixs, l_int32 halfwidth, l_float32 fract, l_int32 direction );
+LEPT_DLL extern PIX * pixUnsharpMaskingGray1D ( PIX *pixs, l_int32 halfwidth, l_float32 fract, l_int32 direction );
+LEPT_DLL extern PIX * pixUnsharpMaskingGray2D ( PIX *pixs, l_int32 halfwidth, l_float32 fract );
+LEPT_DLL extern PIX * pixModifyHue ( PIX *pixd, PIX *pixs, l_float32 fract );
+LEPT_DLL extern PIX * pixModifySaturation ( PIX *pixd, PIX *pixs, l_float32 fract );
+LEPT_DLL extern l_int32 pixMeasureSaturation ( PIX *pixs, l_int32 factor, l_float32 *psat );
+LEPT_DLL extern PIX * pixMultConstantColor ( PIX *pixs, l_float32 rfact, l_float32 gfact, l_float32 bfact );
+LEPT_DLL extern PIX * pixMultMatrixColor ( PIX *pixs, L_KERNEL *kel );
+LEPT_DLL extern PIX * pixHalfEdgeByBandpass ( PIX *pixs, l_int32 sm1h, l_int32 sm1v, l_int32 sm2h, l_int32 sm2v );
+LEPT_DLL extern l_int32 fhmtautogen ( SELA *sela, l_int32 fileindex, const char *filename );
+LEPT_DLL extern l_int32 fhmtautogen1 ( SELA *sela, l_int32 fileindex, const char *filename );
+LEPT_DLL extern l_int32 fhmtautogen2 ( SELA *sela, l_int32 fileindex, const char *filename );
+LEPT_DLL extern PIX * pixHMTDwa_1 ( PIX *pixd, PIX *pixs, char *selname );
+LEPT_DLL extern PIX * pixFHMTGen_1 ( PIX *pixd, PIX *pixs, char *selname );
+LEPT_DLL extern l_int32 fhmtgen_low_1 ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 index );
+LEPT_DLL extern l_int32 pixItalicWords ( PIX *pixs, BOXA *boxaw, PIX *pixw, BOXA **pboxa, l_int32 debugflag );
+LEPT_DLL extern l_int32 pixOrientDetect ( PIX *pixs, l_float32 *pupconf, l_float32 *pleftconf, l_int32 mincount, l_int32 debug );
+LEPT_DLL extern l_int32 makeOrientDecision ( l_float32 upconf, l_float32 leftconf, l_float32 minupconf, l_float32 minratio, l_int32 *porient, l_int32 debug );
+LEPT_DLL extern l_int32 pixUpDownDetect ( PIX *pixs, l_float32 *pconf, l_int32 mincount, l_int32 debug );
+LEPT_DLL extern l_int32 pixUpDownDetectGeneral ( PIX *pixs, l_float32 *pconf, l_int32 mincount, l_int32 npixels, l_int32 debug );
+LEPT_DLL extern l_int32 pixOrientDetectDwa ( PIX *pixs, l_float32 *pupconf, l_float32 *pleftconf, l_int32 mincount, l_int32 debug );
+LEPT_DLL extern l_int32 pixUpDownDetectDwa ( PIX *pixs, l_float32 *pconf, l_int32 mincount, l_int32 debug );
+LEPT_DLL extern l_int32 pixUpDownDetectGeneralDwa ( PIX *pixs, l_float32 *pconf, l_int32 mincount, l_int32 npixels, l_int32 debug );
+LEPT_DLL extern l_int32 pixMirrorDetect ( PIX *pixs, l_float32 *pconf, l_int32 mincount, l_int32 debug );
+LEPT_DLL extern l_int32 pixMirrorDetectDwa ( PIX *pixs, l_float32 *pconf, l_int32 mincount, l_int32 debug );
+LEPT_DLL extern PIX * pixFlipFHMTGen ( PIX *pixd, PIX *pixs, char *selname );
+LEPT_DLL extern l_int32 fmorphautogen ( SELA *sela, l_int32 fileindex, const char *filename );
+LEPT_DLL extern l_int32 fmorphautogen1 ( SELA *sela, l_int32 fileindex, const char *filename );
+LEPT_DLL extern l_int32 fmorphautogen2 ( SELA *sela, l_int32 fileindex, const char *filename );
+LEPT_DLL extern PIX * pixMorphDwa_1 ( PIX *pixd, PIX *pixs, l_int32 operation, char *selname );
+LEPT_DLL extern PIX * pixFMorphopGen_1 ( PIX *pixd, PIX *pixs, l_int32 operation, char *selname );
+LEPT_DLL extern l_int32 fmorphopgen_low_1 ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 index );
+LEPT_DLL extern FPIX * fpixCreate ( l_int32 width, l_int32 height );
+LEPT_DLL extern FPIX * fpixCreateTemplate ( FPIX *fpixs );
+LEPT_DLL extern FPIX * fpixClone ( FPIX *fpix );
+LEPT_DLL extern FPIX * fpixCopy ( FPIX *fpixd, FPIX *fpixs );
+LEPT_DLL extern l_int32 fpixResizeImageData ( FPIX *fpixd, FPIX *fpixs );
+LEPT_DLL extern void fpixDestroy ( FPIX **pfpix );
+LEPT_DLL extern l_int32 fpixGetDimensions ( FPIX *fpix, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern l_int32 fpixSetDimensions ( FPIX *fpix, l_int32 w, l_int32 h );
+LEPT_DLL extern l_int32 fpixGetWpl ( FPIX *fpix );
+LEPT_DLL extern l_int32 fpixSetWpl ( FPIX *fpix, l_int32 wpl );
+LEPT_DLL extern l_int32 fpixGetRefcount ( FPIX *fpix );
+LEPT_DLL extern l_int32 fpixChangeRefcount ( FPIX *fpix, l_int32 delta );
+LEPT_DLL extern l_int32 fpixGetResolution ( FPIX *fpix, l_int32 *pxres, l_int32 *pyres );
+LEPT_DLL extern l_int32 fpixSetResolution ( FPIX *fpix, l_int32 xres, l_int32 yres );
+LEPT_DLL extern l_int32 fpixCopyResolution ( FPIX *fpixd, FPIX *fpixs );
+LEPT_DLL extern l_float32 * fpixGetData ( FPIX *fpix );
+LEPT_DLL extern l_int32 fpixSetData ( FPIX *fpix, l_float32 *data );
+LEPT_DLL extern l_int32 fpixGetPixel ( FPIX *fpix, l_int32 x, l_int32 y, l_float32 *pval );
+LEPT_DLL extern l_int32 fpixSetPixel ( FPIX *fpix, l_int32 x, l_int32 y, l_float32 val );
+LEPT_DLL extern FPIXA * fpixaCreate ( l_int32 n );
+LEPT_DLL extern FPIXA * fpixaCopy ( FPIXA *fpixa, l_int32 copyflag );
+LEPT_DLL extern void fpixaDestroy ( FPIXA **pfpixa );
+LEPT_DLL extern l_int32 fpixaAddFPix ( FPIXA *fpixa, FPIX *fpix, l_int32 copyflag );
+LEPT_DLL extern l_int32 fpixaExtendArray ( FPIXA *fpixa );
+LEPT_DLL extern l_int32 fpixaExtendArrayToSize ( FPIXA *fpixa, l_int32 size );
+LEPT_DLL extern l_int32 fpixaGetCount ( FPIXA *fpixa );
+LEPT_DLL extern l_int32 fpixaChangeRefcount ( FPIXA *fpixa, l_int32 delta );
+LEPT_DLL extern FPIX * fpixaGetFPix ( FPIXA *fpixa, l_int32 index, l_int32 accesstype );
+LEPT_DLL extern l_int32 fpixaGetFPixDimensions ( FPIXA *fpixa, l_int32 index, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern l_int32 fpixaGetPixel ( FPIXA *fpixa, l_int32 index, l_int32 x, l_int32 y, l_float32 *pval );
+LEPT_DLL extern l_int32 fpixaSetPixel ( FPIXA *fpixa, l_int32 index, l_int32 x, l_int32 y, l_float32 val );
+LEPT_DLL extern DPIX * dpixCreate ( l_int32 width, l_int32 height );
+LEPT_DLL extern DPIX * dpixCreateTemplate ( DPIX *dpixs );
+LEPT_DLL extern DPIX * dpixClone ( DPIX *dpix );
+LEPT_DLL extern DPIX * dpixCopy ( DPIX *dpixd, DPIX *dpixs );
+LEPT_DLL extern l_int32 dpixResizeImageData ( DPIX *dpixd, DPIX *dpixs );
+LEPT_DLL extern void dpixDestroy ( DPIX **pdpix );
+LEPT_DLL extern l_int32 dpixGetDimensions ( DPIX *dpix, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern l_int32 dpixSetDimensions ( DPIX *dpix, l_int32 w, l_int32 h );
+LEPT_DLL extern l_int32 dpixGetWpl ( DPIX *dpix );
+LEPT_DLL extern l_int32 dpixSetWpl ( DPIX *dpix, l_int32 wpl );
+LEPT_DLL extern l_int32 dpixGetRefcount ( DPIX *dpix );
+LEPT_DLL extern l_int32 dpixChangeRefcount ( DPIX *dpix, l_int32 delta );
+LEPT_DLL extern l_int32 dpixGetResolution ( DPIX *dpix, l_int32 *pxres, l_int32 *pyres );
+LEPT_DLL extern l_int32 dpixSetResolution ( DPIX *dpix, l_int32 xres, l_int32 yres );
+LEPT_DLL extern l_int32 dpixCopyResolution ( DPIX *dpixd, DPIX *dpixs );
+LEPT_DLL extern l_float64 * dpixGetData ( DPIX *dpix );
+LEPT_DLL extern l_int32 dpixSetData ( DPIX *dpix, l_float64 *data );
+LEPT_DLL extern l_int32 dpixGetPixel ( DPIX *dpix, l_int32 x, l_int32 y, l_float64 *pval );
+LEPT_DLL extern l_int32 dpixSetPixel ( DPIX *dpix, l_int32 x, l_int32 y, l_float64 val );
+LEPT_DLL extern FPIX * fpixRead ( const char *filename );
+LEPT_DLL extern FPIX * fpixReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 fpixWrite ( const char *filename, FPIX *fpix );
+LEPT_DLL extern l_int32 fpixWriteStream ( FILE *fp, FPIX *fpix );
+LEPT_DLL extern FPIX * fpixEndianByteSwap ( FPIX *fpixd, FPIX *fpixs );
+LEPT_DLL extern DPIX * dpixRead ( const char *filename );
+LEPT_DLL extern DPIX * dpixReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 dpixWrite ( const char *filename, DPIX *dpix );
+LEPT_DLL extern l_int32 dpixWriteStream ( FILE *fp, DPIX *dpix );
+LEPT_DLL extern DPIX * dpixEndianByteSwap ( DPIX *dpixd, DPIX *dpixs );
+LEPT_DLL extern l_int32 fpixPrintStream ( FILE *fp, FPIX *fpix, l_int32 factor );
+LEPT_DLL extern FPIX * pixConvertToFPix ( PIX *pixs, l_int32 ncomps );
+LEPT_DLL extern DPIX * pixConvertToDPix ( PIX *pixs, l_int32 ncomps );
+LEPT_DLL extern PIX * fpixConvertToPix ( FPIX *fpixs, l_int32 outdepth, l_int32 negvals, l_int32 errorflag );
+LEPT_DLL extern PIX * fpixDisplayMaxDynamicRange ( FPIX *fpixs );
+LEPT_DLL extern DPIX * fpixConvertToDPix ( FPIX *fpix );
+LEPT_DLL extern PIX * dpixConvertToPix ( DPIX *dpixs, l_int32 outdepth, l_int32 negvals, l_int32 errorflag );
+LEPT_DLL extern FPIX * dpixConvertToFPix ( DPIX *dpix );
+LEPT_DLL extern l_int32 fpixGetMin ( FPIX *fpix, l_float32 *pminval, l_int32 *pxminloc, l_int32 *pyminloc );
+LEPT_DLL extern l_int32 fpixGetMax ( FPIX *fpix, l_float32 *pmaxval, l_int32 *pxmaxloc, l_int32 *pymaxloc );
+LEPT_DLL extern l_int32 dpixGetMin ( DPIX *dpix, l_float64 *pminval, l_int32 *pxminloc, l_int32 *pyminloc );
+LEPT_DLL extern l_int32 dpixGetMax ( DPIX *dpix, l_float64 *pmaxval, l_int32 *pxmaxloc, l_int32 *pymaxloc );
+LEPT_DLL extern FPIX * fpixScaleByInteger ( FPIX *fpixs, l_int32 factor );
+LEPT_DLL extern DPIX * dpixScaleByInteger ( DPIX *dpixs, l_int32 factor );
+LEPT_DLL extern FPIX * fpixLinearCombination ( FPIX *fpixd, FPIX *fpixs1, FPIX *fpixs2, l_float32 a, l_float32 b );
+LEPT_DLL extern l_int32 fpixAddMultConstant ( FPIX *fpix, l_float32 addc, l_float32 multc );
+LEPT_DLL extern DPIX * dpixLinearCombination ( DPIX *dpixd, DPIX *dpixs1, DPIX *dpixs2, l_float32 a, l_float32 b );
+LEPT_DLL extern l_int32 dpixAddMultConstant ( DPIX *dpix, l_float64 addc, l_float64 multc );
+LEPT_DLL extern l_int32 fpixSetAllArbitrary ( FPIX *fpix, l_float32 inval );
+LEPT_DLL extern l_int32 dpixSetAllArbitrary ( DPIX *dpix, l_float64 inval );
+LEPT_DLL extern FPIX * fpixAddBorder ( FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern FPIX * fpixRemoveBorder ( FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern FPIX * fpixAddMirroredBorder ( FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern FPIX * fpixAddContinuedBorder ( FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern FPIX * fpixAddSlopeBorder ( FPIX *fpixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern l_int32 fpixRasterop ( FPIX *fpixd, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, FPIX *fpixs, l_int32 sx, l_int32 sy );
+LEPT_DLL extern FPIX * fpixAffinePta ( FPIX *fpixs, PTA *ptad, PTA *ptas, l_int32 border, l_float32 inval );
+LEPT_DLL extern FPIX * fpixAffine ( FPIX *fpixs, l_float32 *vc, l_float32 inval );
+LEPT_DLL extern FPIX * fpixProjectivePta ( FPIX *fpixs, PTA *ptad, PTA *ptas, l_int32 border, l_float32 inval );
+LEPT_DLL extern FPIX * fpixProjective ( FPIX *fpixs, l_float32 *vc, l_float32 inval );
+LEPT_DLL extern l_int32 linearInterpolatePixelFloat ( l_float32 *datas, l_int32 w, l_int32 h, l_float32 x, l_float32 y, l_float32 inval, l_float32 *pval );
+LEPT_DLL extern PIX * pixReadStreamGif ( FILE *fp );
+LEPT_DLL extern l_int32 pixWriteStreamGif ( FILE *fp, PIX *pix );
+LEPT_DLL extern PIX * pixReadMemGif ( const l_uint8 *cdata, size_t size );
+LEPT_DLL extern l_int32 pixWriteMemGif ( l_uint8 **pdata, size_t *psize, PIX *pix );
+LEPT_DLL extern GPLOT * gplotCreate ( const char *rootname, l_int32 outformat, const char *title, const char *xlabel, const char *ylabel );
+LEPT_DLL extern void gplotDestroy ( GPLOT **pgplot );
+LEPT_DLL extern l_int32 gplotAddPlot ( GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plottitle );
+LEPT_DLL extern l_int32 gplotSetScaling ( GPLOT *gplot, l_int32 scaling );
+LEPT_DLL extern l_int32 gplotMakeOutput ( GPLOT *gplot );
+LEPT_DLL extern l_int32 gplotGenCommandFile ( GPLOT *gplot );
+LEPT_DLL extern l_int32 gplotGenDataFiles ( GPLOT *gplot );
+LEPT_DLL extern l_int32 gplotSimple1 ( NUMA *na, l_int32 outformat, const char *outroot, const char *title );
+LEPT_DLL extern l_int32 gplotSimple2 ( NUMA *na1, NUMA *na2, l_int32 outformat, const char *outroot, const char *title );
+LEPT_DLL extern l_int32 gplotSimpleN ( NUMAA *naa, l_int32 outformat, const char *outroot, const char *title );
+LEPT_DLL extern GPLOT * gplotRead ( const char *filename );
+LEPT_DLL extern l_int32 gplotWrite ( const char *filename, GPLOT *gplot );
+LEPT_DLL extern PTA * generatePtaLine ( l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2 );
+LEPT_DLL extern PTA * generatePtaWideLine ( l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width );
+LEPT_DLL extern PTA * generatePtaBox ( BOX *box, l_int32 width );
+LEPT_DLL extern PTA * generatePtaHashBox ( BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline );
+LEPT_DLL extern PTA * generatePtaBoxa ( BOXA *boxa, l_int32 width, l_int32 removedups );
+LEPT_DLL extern PTAA * generatePtaaBoxa ( BOXA *boxa );
+LEPT_DLL extern PTAA * generatePtaaHashBoxa ( BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline );
+LEPT_DLL extern PTA * generatePtaPolyline ( PTA *ptas, l_int32 width, l_int32 closeflag, l_int32 removedups );
+LEPT_DLL extern PTA * generatePtaFilledCircle ( l_int32 radius );
+LEPT_DLL extern PTA * generatePtaLineFromPt ( l_int32 x, l_int32 y, l_float64 length, l_float64 radang );
+LEPT_DLL extern l_int32 locatePtRadially ( l_int32 xr, l_int32 yr, l_float64 dist, l_float64 radang, l_float64 *px, l_float64 *py );
+LEPT_DLL extern l_int32 pixRenderPta ( PIX *pix, PTA *pta, l_int32 op );
+LEPT_DLL extern l_int32 pixRenderPtaArb ( PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval );
+LEPT_DLL extern l_int32 pixRenderPtaBlend ( PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract );
+LEPT_DLL extern l_int32 pixRenderLine ( PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_int32 op );
+LEPT_DLL extern l_int32 pixRenderLineArb ( PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval );
+LEPT_DLL extern l_int32 pixRenderLineBlend ( PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract );
+LEPT_DLL extern l_int32 pixRenderBox ( PIX *pix, BOX *box, l_int32 width, l_int32 op );
+LEPT_DLL extern l_int32 pixRenderBoxArb ( PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval );
+LEPT_DLL extern l_int32 pixRenderBoxBlend ( PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract );
+LEPT_DLL extern l_int32 pixRenderHashBox ( PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 op );
+LEPT_DLL extern l_int32 pixRenderHashBoxArb ( PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern l_int32 pixRenderHashBoxBlend ( PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval, l_float32 fract );
+LEPT_DLL extern l_int32 pixRenderBoxa ( PIX *pix, BOXA *boxa, l_int32 width, l_int32 op );
+LEPT_DLL extern l_int32 pixRenderBoxaArb ( PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval );
+LEPT_DLL extern l_int32 pixRenderBoxaBlend ( PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract, l_int32 removedups );
+LEPT_DLL extern l_int32 pixRenderPolyline ( PIX *pix, PTA *ptas, l_int32 width, l_int32 op, l_int32 closeflag );
+LEPT_DLL extern l_int32 pixRenderPolylineArb ( PIX *pix, PTA *ptas, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_int32 closeflag );
+LEPT_DLL extern l_int32 pixRenderPolylineBlend ( PIX *pix, PTA *ptas, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract, l_int32 closeflag, l_int32 removedups );
+LEPT_DLL extern PIX * pixRenderRandomCmapPtaa ( PIX *pix, PTAA *ptaa, l_int32 polyflag, l_int32 width, l_int32 closeflag );
+LEPT_DLL extern PIX * pixRenderContours ( PIX *pixs, l_int32 startval, l_int32 incr, l_int32 outdepth );
+LEPT_DLL extern PIX * fpixAutoRenderContours ( FPIX *fpix, l_int32 ncontours );
+LEPT_DLL extern PIX * fpixRenderContours ( FPIX *fpixs, l_float32 incr, l_float32 proxim );
+LEPT_DLL extern PIX * pixErodeGray ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixDilateGray ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOpenGray ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseGray ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixErodeGray3 ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixDilateGray3 ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOpenGray3 ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseGray3 ( PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern void dilateGrayLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 size, l_int32 direction, l_uint8 *buffer, l_uint8 *maxarray );
+LEPT_DLL extern void erodeGrayLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 size, l_int32 direction, l_uint8 *buffer, l_uint8 *minarray );
+LEPT_DLL extern PIX * pixDitherToBinary ( PIX *pixs );
+LEPT_DLL extern PIX * pixDitherToBinarySpec ( PIX *pixs, l_int32 lowerclip, l_int32 upperclip );
+LEPT_DLL extern PIX * pixThresholdToBinary ( PIX *pixs, l_int32 thresh );
+LEPT_DLL extern PIX * pixVarThresholdToBinary ( PIX *pixs, PIX *pixg );
+LEPT_DLL extern PIX * pixDitherToBinaryLUT ( PIX *pixs, l_int32 lowerclip, l_int32 upperclip );
+LEPT_DLL extern PIX * pixGenerateMaskByValue ( PIX *pixs, l_int32 val, l_int32 usecmap );
+LEPT_DLL extern PIX * pixGenerateMaskByBand ( PIX *pixs, l_int32 lower, l_int32 upper, l_int32 inband, l_int32 usecmap );
+LEPT_DLL extern PIX * pixDitherTo2bpp ( PIX *pixs, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixDitherTo2bppSpec ( PIX *pixs, l_int32 lowerclip, l_int32 upperclip, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixThresholdTo2bpp ( PIX *pixs, l_int32 nlevels, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixThresholdTo4bpp ( PIX *pixs, l_int32 nlevels, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixThresholdOn8bpp ( PIX *pixs, l_int32 nlevels, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixThresholdGrayArb ( PIX *pixs, const char *edgevals, l_int32 outdepth, l_int32 use_average, l_int32 setblack, l_int32 setwhite );
+LEPT_DLL extern l_int32 * makeGrayQuantIndexTable ( l_int32 nlevels );
+LEPT_DLL extern l_int32 * makeGrayQuantTargetTable ( l_int32 nlevels, l_int32 depth );
+LEPT_DLL extern l_int32 makeGrayQuantTableArb ( NUMA *na, l_int32 outdepth, l_int32 **ptab, PIXCMAP **pcmap );
+LEPT_DLL extern l_int32 makeGrayQuantColormapArb ( PIX *pixs, l_int32 *tab, l_int32 outdepth, PIXCMAP **pcmap );
+LEPT_DLL extern PIX * pixGenerateMaskByBand32 ( PIX *pixs, l_uint32 refval, l_int32 delm, l_int32 delp );
+LEPT_DLL extern PIX * pixGenerateMaskByDiscr32 ( PIX *pixs, l_uint32 refval1, l_uint32 refval2, l_int32 distflag );
+LEPT_DLL extern PIX * pixGrayQuantFromHisto ( PIX *pixd, PIX *pixs, PIX *pixm, l_float32 minfract, l_int32 maxsize );
+LEPT_DLL extern PIX * pixGrayQuantFromCmap ( PIX *pixs, PIXCMAP *cmap, l_int32 mindepth );
+LEPT_DLL extern void ditherToBinaryLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 *bufs1, l_uint32 *bufs2, l_int32 lowerclip, l_int32 upperclip );
+LEPT_DLL extern void ditherToBinaryLineLow ( l_uint32 *lined, l_int32 w, l_uint32 *bufs1, l_uint32 *bufs2, l_int32 lowerclip, l_int32 upperclip, l_int32 lastlineflag );
+LEPT_DLL extern void thresholdToBinaryLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 d, l_int32 wpls, l_int32 thresh );
+LEPT_DLL extern void thresholdToBinaryLineLow ( l_uint32 *lined, l_int32 w, l_uint32 *lines, l_int32 d, l_int32 thresh );
+LEPT_DLL extern void ditherToBinaryLUTLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 *bufs1, l_uint32 *bufs2, l_int32 *tabval, l_int32 *tab38, l_int32 *tab14 );
+LEPT_DLL extern void ditherToBinaryLineLUTLow ( l_uint32 *lined, l_int32 w, l_uint32 *bufs1, l_uint32 *bufs2, l_int32 *tabval, l_int32 *tab38, l_int32 *tab14, l_int32 lastlineflag );
+LEPT_DLL extern l_int32 make8To1DitherTables ( l_int32 **ptabval, l_int32 **ptab38, l_int32 **ptab14, l_int32 lowerclip, l_int32 upperclip );
+LEPT_DLL extern void ditherTo2bppLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 *bufs1, l_uint32 *bufs2, l_int32 *tabval, l_int32 *tab38, l_int32 *tab14 );
+LEPT_DLL extern void ditherTo2bppLineLow ( l_uint32 *lined, l_int32 w, l_uint32 *bufs1, l_uint32 *bufs2, l_int32 *tabval, l_int32 *tab38, l_int32 *tab14, l_int32 lastlineflag );
+LEPT_DLL extern l_int32 make8To2DitherTables ( l_int32 **ptabval, l_int32 **ptab38, l_int32 **ptab14, l_int32 cliptoblack, l_int32 cliptowhite );
+LEPT_DLL extern void thresholdTo2bppLow ( l_uint32 *datad, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 *tab );
+LEPT_DLL extern void thresholdTo4bppLow ( l_uint32 *datad, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 *tab );
+LEPT_DLL extern L_HEAP * lheapCreate ( l_int32 nalloc, l_int32 direction );
+LEPT_DLL extern void lheapDestroy ( L_HEAP **plh, l_int32 freeflag );
+LEPT_DLL extern l_int32 lheapAdd ( L_HEAP *lh, void *item );
+LEPT_DLL extern l_int32 lheapExtendArray ( L_HEAP *lh );
+LEPT_DLL extern void * lheapRemove ( L_HEAP *lh );
+LEPT_DLL extern l_int32 lheapGetCount ( L_HEAP *lh );
+LEPT_DLL extern l_int32 lheapSwapUp ( L_HEAP *lh, l_int32 index );
+LEPT_DLL extern l_int32 lheapSwapDown ( L_HEAP *lh );
+LEPT_DLL extern l_int32 lheapSort ( L_HEAP *lh );
+LEPT_DLL extern l_int32 lheapSortStrictOrder ( L_HEAP *lh );
+LEPT_DLL extern l_int32 lheapPrint ( FILE *fp, L_HEAP *lh );
+LEPT_DLL extern JBCLASSER * jbRankHausInit ( l_int32 components, l_int32 maxwidth, l_int32 maxheight, l_int32 size, l_float32 rank );
+LEPT_DLL extern JBCLASSER * jbCorrelationInit ( l_int32 components, l_int32 maxwidth, l_int32 maxheight, l_float32 thresh, l_float32 weightfactor );
+LEPT_DLL extern JBCLASSER * jbCorrelationInitWithoutComponents ( l_int32 components, l_int32 maxwidth, l_int32 maxheight, l_float32 thresh, l_float32 weightfactor );
+LEPT_DLL extern l_int32 jbAddPages ( JBCLASSER *classer, SARRAY *safiles );
+LEPT_DLL extern l_int32 jbAddPage ( JBCLASSER *classer, PIX *pixs );
+LEPT_DLL extern l_int32 jbAddPageComponents ( JBCLASSER *classer, PIX *pixs, BOXA *boxas, PIXA *pixas );
+LEPT_DLL extern l_int32 jbClassifyRankHaus ( JBCLASSER *classer, BOXA *boxa, PIXA *pixas );
+LEPT_DLL extern l_int32 pixHaustest ( PIX *pix1, PIX *pix2, PIX *pix3, PIX *pix4, l_float32 delx, l_float32 dely, l_int32 maxdiffw, l_int32 maxdiffh );
+LEPT_DLL extern l_int32 pixRankHaustest ( PIX *pix1, PIX *pix2, PIX *pix3, PIX *pix4, l_float32 delx, l_float32 dely, l_int32 maxdiffw, l_int32 maxdiffh, l_int32 area1, l_int32 area3, l_float32 rank, l_int32 *tab8 );
+LEPT_DLL extern l_int32 jbClassifyCorrelation ( JBCLASSER *classer, BOXA *boxa, PIXA *pixas );
+LEPT_DLL extern l_int32 jbGetComponents ( PIX *pixs, l_int32 components, l_int32 maxwidth, l_int32 maxheight, BOXA **pboxad, PIXA **ppixad );
+LEPT_DLL extern PIX * pixWordMaskByDilation ( PIX *pixs, l_int32 maxsize, l_int32 *psize );
+LEPT_DLL extern PIXA * jbAccumulateComposites ( PIXAA *pixaa, NUMA **pna, PTA **pptat );
+LEPT_DLL extern PIXA * jbTemplatesFromComposites ( PIXA *pixac, NUMA *na );
+LEPT_DLL extern JBCLASSER * jbClasserCreate ( l_int32 method, l_int32 components );
+LEPT_DLL extern void jbClasserDestroy ( JBCLASSER **pclasser );
+LEPT_DLL extern JBDATA * jbDataSave ( JBCLASSER *classer );
+LEPT_DLL extern void jbDataDestroy ( JBDATA **pdata );
+LEPT_DLL extern l_int32 jbDataWrite ( const char *rootout, JBDATA *jbdata );
+LEPT_DLL extern JBDATA * jbDataRead ( const char *rootname );
+LEPT_DLL extern PIXA * jbDataRender ( JBDATA *data, l_int32 debugflag );
+LEPT_DLL extern l_int32 jbGetULCorners ( JBCLASSER *classer, PIX *pixs, BOXA *boxa );
+LEPT_DLL extern l_int32 jbGetLLCorners ( JBCLASSER *classer );
+LEPT_DLL extern PIX * pixReadJpeg ( const char *filename, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn );
+LEPT_DLL extern PIX * pixReadStreamJpeg ( FILE *fp, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint );
+LEPT_DLL extern l_int32 readHeaderJpeg ( const char *filename, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk );
+LEPT_DLL extern l_int32 freadHeaderJpeg ( FILE *fp, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk );
+LEPT_DLL extern l_int32 fgetJpegResolution ( FILE *fp, l_int32 *pxres, l_int32 *pyres );
+LEPT_DLL extern l_int32 pixWriteJpeg ( const char *filename, PIX *pix, l_int32 quality, l_int32 progressive );
+LEPT_DLL extern l_int32 pixWriteStreamJpeg ( FILE *fp, PIX *pix, l_int32 quality, l_int32 progressive );
+LEPT_DLL extern PIX * pixReadMemJpeg ( const l_uint8 *cdata, size_t size, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint );
+LEPT_DLL extern l_int32 readHeaderMemJpeg ( const l_uint8 *cdata, size_t size, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk );
+LEPT_DLL extern l_int32 pixWriteMemJpeg ( l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 quality, l_int32 progressive );
+LEPT_DLL extern void l_jpegSetNoChromaSampling ( l_int32 flag );
+LEPT_DLL extern l_int32 extractJpegDataFromFile ( const char *filein, l_uint8 **pdata, size_t *pnbytes, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp );
+LEPT_DLL extern l_int32 extractJpegDataFromArray ( const void *data, size_t nbytes, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp );
+LEPT_DLL extern L_KERNEL * kernelCreate ( l_int32 height, l_int32 width );
+LEPT_DLL extern void kernelDestroy ( L_KERNEL **pkel );
+LEPT_DLL extern L_KERNEL * kernelCopy ( L_KERNEL *kels );
+LEPT_DLL extern l_int32 kernelGetElement ( L_KERNEL *kel, l_int32 row, l_int32 col, l_float32 *pval );
+LEPT_DLL extern l_int32 kernelSetElement ( L_KERNEL *kel, l_int32 row, l_int32 col, l_float32 val );
+LEPT_DLL extern l_int32 kernelGetParameters ( L_KERNEL *kel, l_int32 *psy, l_int32 *psx, l_int32 *pcy, l_int32 *pcx );
+LEPT_DLL extern l_int32 kernelSetOrigin ( L_KERNEL *kel, l_int32 cy, l_int32 cx );
+LEPT_DLL extern l_int32 kernelGetSum ( L_KERNEL *kel, l_float32 *psum );
+LEPT_DLL extern l_int32 kernelGetMinMax ( L_KERNEL *kel, l_float32 *pmin, l_float32 *pmax );
+LEPT_DLL extern L_KERNEL * kernelNormalize ( L_KERNEL *kels, l_float32 normsum );
+LEPT_DLL extern L_KERNEL * kernelInvert ( L_KERNEL *kels );
+LEPT_DLL extern l_float32 ** create2dFloatArray ( l_int32 sy, l_int32 sx );
+LEPT_DLL extern L_KERNEL * kernelRead ( const char *fname );
+LEPT_DLL extern L_KERNEL * kernelReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 kernelWrite ( const char *fname, L_KERNEL *kel );
+LEPT_DLL extern l_int32 kernelWriteStream ( FILE *fp, L_KERNEL *kel );
+LEPT_DLL extern L_KERNEL * kernelCreateFromString ( l_int32 h, l_int32 w, l_int32 cy, l_int32 cx, const char *kdata );
+LEPT_DLL extern L_KERNEL * kernelCreateFromFile ( const char *filename );
+LEPT_DLL extern L_KERNEL * kernelCreateFromPix ( PIX *pix, l_int32 cy, l_int32 cx );
+LEPT_DLL extern PIX * kernelDisplayInPix ( L_KERNEL *kel, l_int32 size, l_int32 gthick );
+LEPT_DLL extern NUMA * parseStringForNumbers ( const char *str, const char *seps );
+LEPT_DLL extern L_KERNEL * makeFlatKernel ( l_int32 height, l_int32 width, l_int32 cy, l_int32 cx );
+LEPT_DLL extern L_KERNEL * makeGaussianKernel ( l_int32 halfheight, l_int32 halfwidth, l_float32 stdev, l_float32 max );
+LEPT_DLL extern l_int32 makeGaussianKernelSep ( l_int32 halfheight, l_int32 halfwidth, l_float32 stdev, l_float32 max, L_KERNEL **pkelx, L_KERNEL **pkely );
+LEPT_DLL extern L_KERNEL * makeDoGKernel ( l_int32 halfheight, l_int32 halfwidth, l_float32 stdev, l_float32 ratio );
+LEPT_DLL extern char * getImagelibVersions ( );
+LEPT_DLL extern void listDestroy ( DLLIST **phead );
+LEPT_DLL extern l_int32 listAddToHead ( DLLIST **phead, void *data );
+LEPT_DLL extern l_int32 listAddToTail ( DLLIST **phead, DLLIST **ptail, void *data );
+LEPT_DLL extern l_int32 listInsertBefore ( DLLIST **phead, DLLIST *elem, void *data );
+LEPT_DLL extern l_int32 listInsertAfter ( DLLIST **phead, DLLIST *elem, void *data );
+LEPT_DLL extern void * listRemoveElement ( DLLIST **phead, DLLIST *elem );
+LEPT_DLL extern void * listRemoveFromHead ( DLLIST **phead );
+LEPT_DLL extern void * listRemoveFromTail ( DLLIST **phead, DLLIST **ptail );
+LEPT_DLL extern DLLIST * listFindElement ( DLLIST *head, void *data );
+LEPT_DLL extern DLLIST * listFindTail ( DLLIST *head );
+LEPT_DLL extern l_int32 listGetCount ( DLLIST *head );
+LEPT_DLL extern l_int32 listReverse ( DLLIST **phead );
+LEPT_DLL extern l_int32 listJoin ( DLLIST **phead1, DLLIST **phead2 );
+LEPT_DLL extern PIX * generateBinaryMaze ( l_int32 w, l_int32 h, l_int32 xi, l_int32 yi, l_float32 wallps, l_float32 ranis );
+LEPT_DLL extern PTA * pixSearchBinaryMaze ( PIX *pixs, l_int32 xi, l_int32 yi, l_int32 xf, l_int32 yf, PIX **ppixd );
+LEPT_DLL extern PTA * pixSearchGrayMaze ( PIX *pixs, l_int32 xi, l_int32 yi, l_int32 xf, l_int32 yf, PIX **ppixd );
+LEPT_DLL extern l_int32 pixFindLargestRectangle ( PIX *pixs, l_int32 polarity, BOX **pbox, const char *debugfile );
+LEPT_DLL extern PIX * pixDilate ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixErode ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixHMT ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixOpen ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixClose ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixCloseSafe ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixOpenGeneralized ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixCloseGeneralized ( PIX *pixd, PIX *pixs, SEL *sel );
+LEPT_DLL extern PIX * pixDilateBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixErodeBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOpenBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseSafeBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern l_int32 selectComposableSels ( l_int32 size, l_int32 direction, SEL **psel1, SEL **psel2 );
+LEPT_DLL extern l_int32 selectComposableSizes ( l_int32 size, l_int32 *pfactor1, l_int32 *pfactor2 );
+LEPT_DLL extern PIX * pixDilateCompBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixErodeCompBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOpenCompBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseCompBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseSafeCompBrick ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern void resetMorphBoundaryCondition ( l_int32 bc );
+LEPT_DLL extern l_uint32 getMorphBorderPixelColor ( l_int32 type, l_int32 depth );
+LEPT_DLL extern PIX * pixExtractBoundary ( PIX *pixs, l_int32 type );
+LEPT_DLL extern PIX * pixMorphSequenceMasked ( PIX *pixs, PIX *pixm, const char *sequence, l_int32 dispsep );
+LEPT_DLL extern PIX * pixMorphSequenceByComponent ( PIX *pixs, const char *sequence, l_int32 connectivity, l_int32 minw, l_int32 minh, BOXA **pboxa );
+LEPT_DLL extern PIXA * pixaMorphSequenceByComponent ( PIXA *pixas, const char *sequence, l_int32 minw, l_int32 minh );
+LEPT_DLL extern PIX * pixMorphSequenceByRegion ( PIX *pixs, PIX *pixm, const char *sequence, l_int32 connectivity, l_int32 minw, l_int32 minh, BOXA **pboxa );
+LEPT_DLL extern PIXA * pixaMorphSequenceByRegion ( PIX *pixs, PIXA *pixam, const char *sequence, l_int32 minw, l_int32 minh );
+LEPT_DLL extern PIX * pixUnionOfMorphOps ( PIX *pixs, SELA *sela, l_int32 type );
+LEPT_DLL extern PIX * pixIntersectionOfMorphOps ( PIX *pixs, SELA *sela, l_int32 type );
+LEPT_DLL extern PIX * pixSelectiveConnCompFill ( PIX *pixs, l_int32 connectivity, l_int32 minw, l_int32 minh );
+LEPT_DLL extern l_int32 pixRemoveMatchedPattern ( PIX *pixs, PIX *pixp, PIX *pixe, l_int32 x0, l_int32 y0, l_int32 dsize );
+LEPT_DLL extern PIX * pixDisplayMatchedPattern ( PIX *pixs, PIX *pixp, PIX *pixe, l_int32 x0, l_int32 y0, l_uint32 color, l_float32 scale, l_int32 nlevels );
+LEPT_DLL extern PIX * pixSeedfillMorph ( PIX *pixs, PIX *pixm, l_int32 connectivity );
+LEPT_DLL extern NUMA * pixRunHistogramMorph ( PIX *pixs, l_int32 runtype, l_int32 direction, l_int32 maxsize );
+LEPT_DLL extern PIX * pixTophat ( PIX *pixs, l_int32 hsize, l_int32 vsize, l_int32 type );
+LEPT_DLL extern PIX * pixHDome ( PIX *pixs, l_int32 height, l_int32 connectivity );
+LEPT_DLL extern PIX * pixFastTophat ( PIX *pixs, l_int32 xsize, l_int32 ysize, l_int32 type );
+LEPT_DLL extern PIX * pixMorphGradient ( PIX *pixs, l_int32 hsize, l_int32 vsize, l_int32 smoothing );
+LEPT_DLL extern PTA * pixaCentroids ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixCentroid ( PIX *pix, l_int32 *centtab, l_int32 *sumtab, l_float32 *pxave, l_float32 *pyave );
+LEPT_DLL extern PIX * pixDilateBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixErodeBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOpenBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixDilateCompBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixErodeCompBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOpenCompBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseCompBrickDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixDilateCompBrickExtendDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixErodeCompBrickExtendDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixOpenCompBrickExtendDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern PIX * pixCloseCompBrickExtendDwa ( PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern l_int32 getExtendedCompositeParameters ( l_int32 size, l_int32 *pn, l_int32 *pextra, l_int32 *pactualsize );
+LEPT_DLL extern PIX * pixMorphSequence ( PIX *pixs, const char *sequence, l_int32 dispsep );
+LEPT_DLL extern PIX * pixMorphCompSequence ( PIX *pixs, const char *sequence, l_int32 dispsep );
+LEPT_DLL extern PIX * pixMorphSequenceDwa ( PIX *pixs, const char *sequence, l_int32 dispsep );
+LEPT_DLL extern PIX * pixMorphCompSequenceDwa ( PIX *pixs, const char *sequence, l_int32 dispsep );
+LEPT_DLL extern l_int32 morphSequenceVerify ( SARRAY *sa );
+LEPT_DLL extern PIX * pixGrayMorphSequence ( PIX *pixs, const char *sequence, l_int32 dispsep, l_int32 dispy );
+LEPT_DLL extern PIX * pixColorMorphSequence ( PIX *pixs, const char *sequence, l_int32 dispsep, l_int32 dispy );
+LEPT_DLL extern NUMA * numaCreate ( l_int32 n );
+LEPT_DLL extern NUMA * numaCreateFromIArray ( l_int32 *iarray, l_int32 size );
+LEPT_DLL extern NUMA * numaCreateFromFArray ( l_float32 *farray, l_int32 size, l_int32 copyflag );
+LEPT_DLL extern void numaDestroy ( NUMA **pna );
+LEPT_DLL extern NUMA * numaCopy ( NUMA *na );
+LEPT_DLL extern NUMA * numaClone ( NUMA *na );
+LEPT_DLL extern l_int32 numaEmpty ( NUMA *na );
+LEPT_DLL extern l_int32 numaAddNumber ( NUMA *na, l_float32 val );
+LEPT_DLL extern l_int32 numaExtendArray ( NUMA *na );
+LEPT_DLL extern l_int32 numaInsertNumber ( NUMA *na, l_int32 index, l_float32 val );
+LEPT_DLL extern l_int32 numaRemoveNumber ( NUMA *na, l_int32 index );
+LEPT_DLL extern l_int32 numaReplaceNumber ( NUMA *na, l_int32 index, l_float32 val );
+LEPT_DLL extern l_int32 numaGetCount ( NUMA *na );
+LEPT_DLL extern l_int32 numaSetCount ( NUMA *na, l_int32 newcount );
+LEPT_DLL extern l_int32 numaGetFValue ( NUMA *na, l_int32 index, l_float32 *pval );
+LEPT_DLL extern l_int32 numaGetIValue ( NUMA *na, l_int32 index, l_int32 *pival );
+LEPT_DLL extern l_int32 numaSetValue ( NUMA *na, l_int32 index, l_float32 val );
+LEPT_DLL extern l_int32 numaShiftValue ( NUMA *na, l_int32 index, l_float32 diff );
+LEPT_DLL extern l_int32 * numaGetIArray ( NUMA *na );
+LEPT_DLL extern l_float32 * numaGetFArray ( NUMA *na, l_int32 copyflag );
+LEPT_DLL extern l_int32 numaGetRefcount ( NUMA *na );
+LEPT_DLL extern l_int32 numaChangeRefcount ( NUMA *na, l_int32 delta );
+LEPT_DLL extern l_int32 numaGetXParameters ( NUMA *na, l_float32 *pstartx, l_float32 *pdelx );
+LEPT_DLL extern l_int32 numaSetXParameters ( NUMA *na, l_float32 startx, l_float32 delx );
+LEPT_DLL extern l_int32 numaCopyXParameters ( NUMA *nad, NUMA *nas );
+LEPT_DLL extern NUMA * numaRead ( const char *filename );
+LEPT_DLL extern NUMA * numaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 numaWrite ( const char *filename, NUMA *na );
+LEPT_DLL extern l_int32 numaWriteStream ( FILE *fp, NUMA *na );
+LEPT_DLL extern NUMAA * numaaCreate ( l_int32 n );
+LEPT_DLL extern void numaaDestroy ( NUMAA **pnaa );
+LEPT_DLL extern l_int32 numaaAddNuma ( NUMAA *naa, NUMA *na, l_int32 copyflag );
+LEPT_DLL extern l_int32 numaaExtendArray ( NUMAA *naa );
+LEPT_DLL extern l_int32 numaaGetCount ( NUMAA *naa );
+LEPT_DLL extern l_int32 numaaGetNumaCount ( NUMAA *naa, l_int32 index );
+LEPT_DLL extern l_int32 numaaGetNumberCount ( NUMAA *naa );
+LEPT_DLL extern NUMA ** numaaGetPtrArray ( NUMAA *naa );
+LEPT_DLL extern NUMA * numaaGetNuma ( NUMAA *naa, l_int32 index, l_int32 accessflag );
+LEPT_DLL extern l_int32 numaaReplaceNuma ( NUMAA *naa, l_int32 index, NUMA *na );
+LEPT_DLL extern l_int32 numaaGetValue ( NUMAA *naa, l_int32 i, l_int32 j, l_float32 *pval );
+LEPT_DLL extern l_int32 numaaAddNumber ( NUMAA *naa, l_int32 index, l_float32 val );
+LEPT_DLL extern NUMAA * numaaRead ( const char *filename );
+LEPT_DLL extern NUMAA * numaaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 numaaWrite ( const char *filename, NUMAA *naa );
+LEPT_DLL extern l_int32 numaaWriteStream ( FILE *fp, NUMAA *naa );
+LEPT_DLL extern NUMA2D * numa2dCreate ( l_int32 nrows, l_int32 ncols, l_int32 initsize );
+LEPT_DLL extern void numa2dDestroy ( NUMA2D **pna2d );
+LEPT_DLL extern l_int32 numa2dAddNumber ( NUMA2D *na2d, l_int32 row, l_int32 col, l_float32 val );
+LEPT_DLL extern l_int32 numa2dGetCount ( NUMA2D *na2d, l_int32 row, l_int32 col );
+LEPT_DLL extern NUMA * numa2dGetNuma ( NUMA2D *na2d, l_int32 row, l_int32 col );
+LEPT_DLL extern l_int32 numa2dGetFValue ( NUMA2D *na2d, l_int32 row, l_int32 col, l_int32 index, l_float32 *pval );
+LEPT_DLL extern l_int32 numa2dGetIValue ( NUMA2D *na2d, l_int32 row, l_int32 col, l_int32 index, l_int32 *pval );
+LEPT_DLL extern NUMAHASH * numaHashCreate ( l_int32 nbuckets, l_int32 initsize );
+LEPT_DLL extern void numaHashDestroy ( NUMAHASH **pnahash );
+LEPT_DLL extern NUMA * numaHashGetNuma ( NUMAHASH *nahash, l_uint32 key );
+LEPT_DLL extern l_int32 numaHashAdd ( NUMAHASH *nahash, l_uint32 key, l_float32 value );
+LEPT_DLL extern NUMA * numaArithOp ( NUMA *nad, NUMA *na1, NUMA *na2, l_int32 op );
+LEPT_DLL extern NUMA * numaLogicalOp ( NUMA *nad, NUMA *na1, NUMA *na2, l_int32 op );
+LEPT_DLL extern NUMA * numaInvert ( NUMA *nad, NUMA *nas );
+LEPT_DLL extern l_int32 numaGetMin ( NUMA *na, l_float32 *pminval, l_int32 *piminloc );
+LEPT_DLL extern l_int32 numaGetMax ( NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc );
+LEPT_DLL extern l_int32 numaGetSum ( NUMA *na, l_float32 *psum );
+LEPT_DLL extern NUMA * numaGetPartialSums ( NUMA *na );
+LEPT_DLL extern l_int32 numaGetSumOnInterval ( NUMA *na, l_int32 first, l_int32 last, l_float32 *psum );
+LEPT_DLL extern l_int32 numaHasOnlyIntegers ( NUMA *na, l_int32 maxsamples, l_int32 *pallints );
+LEPT_DLL extern NUMA * numaSubsample ( NUMA *nas, l_int32 subfactor );
+LEPT_DLL extern NUMA * numaMakeDelta ( NUMA *nas );
+LEPT_DLL extern NUMA * numaMakeSequence ( l_float32 startval, l_float32 increment, l_int32 size );
+LEPT_DLL extern NUMA * numaMakeConstant ( l_float32 val, l_int32 size );
+LEPT_DLL extern NUMA * numaMakeAbsValue ( NUMA *nad, NUMA *nas );
+LEPT_DLL extern NUMA * numaAddBorder ( NUMA *nas, l_int32 left, l_int32 right, l_float32 val );
+LEPT_DLL extern NUMA * numaAddSpecifiedBorder ( NUMA *nas, l_int32 left, l_int32 right, l_int32 type );
+LEPT_DLL extern NUMA * numaRemoveBorder ( NUMA *nas, l_int32 left, l_int32 right );
+LEPT_DLL extern l_int32 numaGetNonzeroRange ( NUMA *na, l_float32 eps, l_int32 *pfirst, l_int32 *plast );
+LEPT_DLL extern l_int32 numaGetCountRelativeToZero ( NUMA *na, l_int32 type, l_int32 *pcount );
+LEPT_DLL extern NUMA * numaClipToInterval ( NUMA *nas, l_int32 first, l_int32 last );
+LEPT_DLL extern NUMA * numaMakeThresholdIndicator ( NUMA *nas, l_float32 thresh, l_int32 type );
+LEPT_DLL extern NUMA * numaUniformSampling ( NUMA *nas, l_int32 nsamp );
+LEPT_DLL extern NUMA * numaLowPassIntervals ( NUMA *nas, l_float32 thresh, l_float32 maxn );
+LEPT_DLL extern NUMA * numaThresholdEdges ( NUMA *nas, l_float32 thresh1, l_float32 thresh2, l_float32 maxn );
+LEPT_DLL extern l_int32 numaGetSpanValues ( NUMA *na, l_int32 span, l_int32 *pstart, l_int32 *pend );
+LEPT_DLL extern l_int32 numaGetEdgeValues ( NUMA *na, l_int32 edge, l_int32 *pstart, l_int32 *pend, l_int32 *psign );
+LEPT_DLL extern l_int32 numaInterpolateEqxVal ( l_float32 startx, l_float32 deltax, NUMA *nay, l_int32 type, l_float32 xval, l_float32 *pyval );
+LEPT_DLL extern l_int32 numaInterpolateArbxVal ( NUMA *nax, NUMA *nay, l_int32 type, l_float32 xval, l_float32 *pyval );
+LEPT_DLL extern l_int32 numaInterpolateEqxInterval ( l_float32 startx, l_float32 deltax, NUMA *nasy, l_int32 type, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnax, NUMA **pnay );
+LEPT_DLL extern l_int32 numaInterpolateArbxInterval ( NUMA *nax, NUMA *nay, l_int32 type, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnadx, NUMA **pnady );
+LEPT_DLL extern l_int32 numaFitMax ( NUMA *na, l_float32 *pmaxval, NUMA *naloc, l_float32 *pmaxloc );
+LEPT_DLL extern l_int32 numaDifferentiateInterval ( NUMA *nax, NUMA *nay, l_float32 x0, l_float32 x1, l_int32 npts, NUMA **pnadx, NUMA **pnady );
+LEPT_DLL extern l_int32 numaIntegrateInterval ( NUMA *nax, NUMA *nay, l_float32 x0, l_float32 x1, l_int32 npts, l_float32 *psum );
+LEPT_DLL extern NUMA * numaSort ( NUMA *naout, NUMA *nain, l_int32 sortorder );
+LEPT_DLL extern NUMA * numaBinSort ( NUMA *nas, l_int32 sortorder );
+LEPT_DLL extern NUMA * numaGetSortIndex ( NUMA *na, l_int32 sortorder );
+LEPT_DLL extern NUMA * numaGetBinSortIndex ( NUMA *nas, l_int32 sortorder );
+LEPT_DLL extern NUMA * numaSortByIndex ( NUMA *nas, NUMA *naindex );
+LEPT_DLL extern l_int32 numaIsSorted ( NUMA *nas, l_int32 sortorder, l_int32 *psorted );
+LEPT_DLL extern l_int32 numaSortPair ( NUMA *nax, NUMA *nay, l_int32 sortorder, NUMA **pnasx, NUMA **pnasy );
+LEPT_DLL extern NUMA * numaPseudorandomSequence ( l_int32 size, l_int32 seed );
+LEPT_DLL extern NUMA * numaRandomPermutation ( NUMA *nas, l_int32 seed );
+LEPT_DLL extern l_int32 numaGetRankValue ( NUMA *na, l_float32 fract, NUMA *nasort, l_int32 usebins, l_float32 *pval );
+LEPT_DLL extern l_int32 numaGetMedian ( NUMA *na, l_float32 *pval );
+LEPT_DLL extern l_int32 numaGetBinnedMedian ( NUMA *na, l_int32 *pval );
+LEPT_DLL extern l_int32 numaGetMode ( NUMA *na, l_float32 *pval, l_int32 *pcount );
+LEPT_DLL extern l_int32 numaGetMedianVariation ( NUMA *na, l_float32 *pmedval, l_float32 *pmedvar );
+LEPT_DLL extern l_int32 numaJoin ( NUMA *nad, NUMA *nas, l_int32 istart, l_int32 iend );
+LEPT_DLL extern NUMA * numaaFlattenToNuma ( NUMAA *naa );
+LEPT_DLL extern NUMA * numaErode ( NUMA *nas, l_int32 size );
+LEPT_DLL extern NUMA * numaDilate ( NUMA *nas, l_int32 size );
+LEPT_DLL extern NUMA * numaOpen ( NUMA *nas, l_int32 size );
+LEPT_DLL extern NUMA * numaClose ( NUMA *nas, l_int32 size );
+LEPT_DLL extern NUMA * numaTransform ( NUMA *nas, l_float32 shift, l_float32 scale );
+LEPT_DLL extern l_int32 numaWindowedStats ( NUMA *nas, l_int32 wc, NUMA **pnam, NUMA **pnams, NUMA **pnav, NUMA **pnarv );
+LEPT_DLL extern NUMA * numaWindowedMean ( NUMA *nas, l_int32 wc );
+LEPT_DLL extern NUMA * numaWindowedMeanSquare ( NUMA *nas, l_int32 wc );
+LEPT_DLL extern l_int32 numaWindowedVariance ( NUMA *nam, NUMA *nams, NUMA **pnav, NUMA **pnarv );
+LEPT_DLL extern NUMA * numaConvertToInt ( NUMA *nas );
+LEPT_DLL extern NUMA * numaMakeHistogram ( NUMA *na, l_int32 maxbins, l_int32 *pbinsize, l_int32 *pbinstart );
+LEPT_DLL extern NUMA * numaMakeHistogramAuto ( NUMA *na, l_int32 maxbins );
+LEPT_DLL extern NUMA * numaMakeHistogramClipped ( NUMA *na, l_float32 binsize, l_float32 maxsize );
+LEPT_DLL extern NUMA * numaRebinHistogram ( NUMA *nas, l_int32 newsize );
+LEPT_DLL extern NUMA * numaNormalizeHistogram ( NUMA *nas, l_float32 area );
+LEPT_DLL extern l_int32 numaGetStatsUsingHistogram ( NUMA *na, l_int32 maxbins, l_float32 *pmin, l_float32 *pmax, l_float32 *pmean, l_float32 *pvariance, l_float32 *pmedian, l_float32 rank, l_float32 *prval, NUMA **phisto );
+LEPT_DLL extern l_int32 numaGetHistogramStats ( NUMA *nahisto, l_float32 startx, l_float32 deltax, l_float32 *pxmean, l_float32 *pxmedian, l_float32 *pxmode, l_float32 *pxvariance );
+LEPT_DLL extern l_int32 numaGetHistogramStatsOnInterval ( NUMA *nahisto, l_float32 startx, l_float32 deltax, l_int32 ifirst, l_int32 ilast, l_float32 *pxmean, l_float32 *pxmedian, l_float32 *pxmode, l_float32 *pxvariance );
+LEPT_DLL extern l_int32 numaMakeRankFromHistogram ( l_float32 startx, l_float32 deltax, NUMA *nasy, l_int32 npts, NUMA **pnax, NUMA **pnay );
+LEPT_DLL extern l_int32 numaHistogramGetRankFromVal ( NUMA *na, l_float32 rval, l_float32 *prank );
+LEPT_DLL extern l_int32 numaHistogramGetValFromRank ( NUMA *na, l_float32 rank, l_float32 *prval );
+LEPT_DLL extern l_int32 numaDiscretizeRankAndIntensity ( NUMA *na, l_int32 nbins, NUMA **pnarbin, NUMA **pnam, NUMA **pnar, NUMA **pnabb );
+LEPT_DLL extern l_int32 numaGetRankBinValues ( NUMA *na, l_int32 nbins, NUMA **pnarbin, NUMA **pnam );
+LEPT_DLL extern l_int32 numaSplitDistribution ( NUMA *na, l_float32 scorefract, l_int32 *psplitindex, l_float32 *pave1, l_float32 *pave2, l_float32 *pnum1, l_float32 *pnum2, NUMA **pnascore );
+LEPT_DLL extern NUMA * numaFindPeaks ( NUMA *nas, l_int32 nmax, l_float32 fract1, l_float32 fract2 );
+LEPT_DLL extern NUMA * numaFindExtrema ( NUMA *nas, l_float32 delta );
+LEPT_DLL extern l_int32 numaCountReversals ( NUMA *nas, l_float32 minreversal, l_int32 *pnr, l_float32 *pnrpl );
+LEPT_DLL extern l_int32 numaSelectCrossingThreshold ( NUMA *nax, NUMA *nay, l_float32 estthresh, l_float32 *pbestthresh );
+LEPT_DLL extern NUMA * numaCrossingsByThreshold ( NUMA *nax, NUMA *nay, l_float32 thresh );
+LEPT_DLL extern NUMA * numaCrossingsByPeaks ( NUMA *nax, NUMA *nay, l_float32 delta );
+LEPT_DLL extern l_int32 numaEvalBestHaarParameters ( NUMA *nas, l_float32 relweight, l_int32 nwidth, l_int32 nshift, l_float32 minwidth, l_float32 maxwidth, l_float32 *pbestwidth, l_float32 *pbestshift, l_float32 *pbestscore );
+LEPT_DLL extern l_int32 numaEvalHaarSum ( NUMA *nas, l_float32 width, l_float32 shift, l_float32 relweight, l_float32 *pscore );
+LEPT_DLL extern l_int32 pixGetRegionsBinary ( PIX *pixs, PIX **ppixhm, PIX **ppixtm, PIX **ppixtb, l_int32 debug );
+LEPT_DLL extern PIX * pixGenHalftoneMask ( PIX *pixs, PIX **ppixtext, l_int32 *phtfound, l_int32 debug );
+LEPT_DLL extern PIX * pixGenTextlineMask ( PIX *pixs, PIX **ppixvws, l_int32 *ptlfound, l_int32 debug );
+LEPT_DLL extern PIX * pixGenTextblockMask ( PIX *pixs, PIX *pixvws, l_int32 debug );
+LEPT_DLL extern l_int32 pixSetSelectCmap ( PIX *pixs, BOX *box, l_int32 sindex, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern l_int32 pixColorGrayCmap ( PIX *pixs, BOX *box, l_int32 type, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern l_int32 addColorizedGrayToCmap ( PIXCMAP *cmap, l_int32 type, l_int32 rval, l_int32 gval, l_int32 bval, NUMA **pna );
+LEPT_DLL extern l_int32 pixSetSelectMaskedCmap ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 sindex, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern l_int32 pixSetMaskedCmap ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern char * parseForProtos ( const char *filein, const char *prestring );
+LEPT_DLL extern BOXA * boxaGetWhiteblocks ( BOXA *boxas, BOX *box, l_int32 sortflag, l_int32 maxboxes, l_float32 maxoverlap, l_int32 maxperim, l_float32 fract, l_int32 maxpops );
+LEPT_DLL extern BOXA * boxaPruneSortedOnOverlap ( BOXA *boxas, l_float32 maxoverlap );
+LEPT_DLL extern l_int32 convertFilesToPdf ( const char *dirname, const char *substr, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout );
+LEPT_DLL extern l_int32 saConvertFilesToPdf ( SARRAY *sa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout );
+LEPT_DLL extern l_int32 saConvertFilesToPdfData ( SARRAY *sa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern l_int32 selectDefaultPdfEncoding ( PIX *pix, l_int32 *ptype );
+LEPT_DLL extern l_int32 pixaConvertToPdf ( PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout );
+LEPT_DLL extern l_int32 pixaConvertToPdfData ( PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern l_int32 convertToPdf ( const char *filein, l_int32 type, l_int32 quality, const char *fileout, l_int32 x, l_int32 y, l_int32 res, L_PDF_DATA **plpd, l_int32 position, const char *title );
+LEPT_DLL extern l_int32 convertImageDataToPdf ( l_uint8 *imdata, size_t size, l_int32 type, l_int32 quality, const char *fileout, l_int32 x, l_int32 y, l_int32 res, L_PDF_DATA **plpd, l_int32 position, const char *title );
+LEPT_DLL extern l_int32 convertToPdfData ( const char *filein, l_int32 type, l_int32 quality, l_uint8 **pdata, size_t *pnbytes, l_int32 x, l_int32 y, l_int32 res, L_PDF_DATA **plpd, l_int32 position, const char *title );
+LEPT_DLL extern l_int32 convertImageDataToPdfData ( l_uint8 *imdata, size_t size, l_int32 type, l_int32 quality, l_uint8 **pdata, size_t *pnbytes, l_int32 x, l_int32 y, l_int32 res, L_PDF_DATA **plpd, l_int32 position, const char *title );
+LEPT_DLL extern l_int32 pixConvertToPdf ( PIX *pix, l_int32 type, l_int32 quality, const char *fileout, l_int32 x, l_int32 y, l_int32 res, L_PDF_DATA **plpd, l_int32 position, const char *title );
+LEPT_DLL extern l_int32 pixConvertToPdfData ( PIX *pix, l_int32 type, l_int32 quality, l_uint8 **pdata, size_t *pnbytes, l_int32 x, l_int32 y, l_int32 res, L_PDF_DATA **plpd, l_int32 position, const char *title );
+LEPT_DLL extern l_int32 pixWriteStreamPdf ( FILE *fp, PIX *pix, l_int32 res, const char *title );
+LEPT_DLL extern l_int32 convertSegmentedFilesToPdf ( const char *dirname, const char *substr, l_int32 res, l_int32 type, l_int32 thresh, BOXAA *baa, l_int32 quality, l_float32 scalefactor, const char *title, const char *fileout );
+LEPT_DLL extern BOXAA * convertNumberedMasksToBoxaa ( const char *dirname, const char *substr, l_int32 numpre, l_int32 numpost );
+LEPT_DLL extern l_int32 convertToPdfSegmented ( const char *filein, l_int32 res, l_int32 type, l_int32 thresh, BOXA *boxa, l_int32 quality, l_float32 scalefactor, const char *fileout );
+LEPT_DLL extern l_int32 pixConvertToPdfSegmented ( PIX *pixs, l_int32 res, l_int32 type, l_int32 thresh, BOXA *boxa, l_int32 quality, l_float32 scalefactor, const char *fileout, const char *title );
+LEPT_DLL extern l_int32 convertToPdfDataSegmented ( const char *filein, l_int32 res, l_int32 type, l_int32 thresh, BOXA *boxa, l_int32 quality, l_float32 scalefactor, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern l_int32 pixConvertToPdfDataSegmented ( PIX *pixs, l_int32 res, l_int32 type, l_int32 thresh, BOXA *boxa, l_int32 quality, l_float32 scalefactor, l_uint8 **pdata, size_t *pnbytes, const char *title );
+LEPT_DLL extern l_int32 concatenatePdf ( const char *dirname, const char *substr, const char *fileout );
+LEPT_DLL extern l_int32 saConcatenatePdf ( SARRAY *sa, const char *fileout );
+LEPT_DLL extern l_int32 ptraConcatenatePdf ( L_PTRA *pa, const char *fileout );
+LEPT_DLL extern l_int32 concatenatePdfToData ( const char *dirname, const char *substr, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern l_int32 saConcatenatePdfToData ( SARRAY *sa, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern l_int32 ptraConcatenatePdfToData ( L_PTRA *pa_data, SARRAY *sa, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern void l_pdfSetG4ImageMask ( l_int32 flag );
+LEPT_DLL extern void l_pdfSetDateAndVersion ( l_int32 flag );
+LEPT_DLL extern void setPixMemoryManager ( void * ( allocator ( size_t ) ), void ( deallocator ( void * ) ) );
+LEPT_DLL extern PIX * pixCreate ( l_int32 width, l_int32 height, l_int32 depth );
+LEPT_DLL extern PIX * pixCreateNoInit ( l_int32 width, l_int32 height, l_int32 depth );
+LEPT_DLL extern PIX * pixCreateTemplate ( PIX *pixs );
+LEPT_DLL extern PIX * pixCreateTemplateNoInit ( PIX *pixs );
+LEPT_DLL extern PIX * pixCreateHeader ( l_int32 width, l_int32 height, l_int32 depth );
+LEPT_DLL extern PIX * pixClone ( PIX *pixs );
+LEPT_DLL extern void pixDestroy ( PIX **ppix );
+LEPT_DLL extern PIX * pixCopy ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern l_int32 pixResizeImageData ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern l_int32 pixCopyColormap ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern l_int32 pixSizesEqual ( PIX *pix1, PIX *pix2 );
+LEPT_DLL extern l_int32 pixTransferAllData ( PIX *pixd, PIX **ppixs, l_int32 copytext, l_int32 copyformat );
+LEPT_DLL extern l_int32 pixSwapAndDestroy ( PIX **ppixd, PIX **ppixs );
+LEPT_DLL extern l_int32 pixGetWidth ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetWidth ( PIX *pix, l_int32 width );
+LEPT_DLL extern l_int32 pixGetHeight ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetHeight ( PIX *pix, l_int32 height );
+LEPT_DLL extern l_int32 pixGetDepth ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetDepth ( PIX *pix, l_int32 depth );
+LEPT_DLL extern l_int32 pixGetDimensions ( PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd );
+LEPT_DLL extern l_int32 pixSetDimensions ( PIX *pix, l_int32 w, l_int32 h, l_int32 d );
+LEPT_DLL extern l_int32 pixCopyDimensions ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern l_int32 pixGetWpl ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetWpl ( PIX *pix, l_int32 wpl );
+LEPT_DLL extern l_int32 pixGetRefcount ( PIX *pix );
+LEPT_DLL extern l_int32 pixChangeRefcount ( PIX *pix, l_int32 delta );
+LEPT_DLL extern l_int32 pixGetXRes ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetXRes ( PIX *pix, l_int32 res );
+LEPT_DLL extern l_int32 pixGetYRes ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetYRes ( PIX *pix, l_int32 res );
+LEPT_DLL extern l_int32 pixGetResolution ( PIX *pix, l_int32 *pxres, l_int32 *pyres );
+LEPT_DLL extern l_int32 pixSetResolution ( PIX *pix, l_int32 xres, l_int32 yres );
+LEPT_DLL extern l_int32 pixCopyResolution ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern l_int32 pixScaleResolution ( PIX *pix, l_float32 xscale, l_float32 yscale );
+LEPT_DLL extern l_int32 pixGetInputFormat ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetInputFormat ( PIX *pix, l_int32 informat );
+LEPT_DLL extern l_int32 pixCopyInputFormat ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern char * pixGetText ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetText ( PIX *pix, const char *textstring );
+LEPT_DLL extern l_int32 pixAddText ( PIX *pix, const char *textstring );
+LEPT_DLL extern l_int32 pixCopyText ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern PIXCMAP * pixGetColormap ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetColormap ( PIX *pix, PIXCMAP *colormap );
+LEPT_DLL extern l_int32 pixDestroyColormap ( PIX *pix );
+LEPT_DLL extern l_uint32 * pixGetData ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetData ( PIX *pix, l_uint32 *data );
+LEPT_DLL extern l_uint32 * pixExtractData ( PIX *pixs );
+LEPT_DLL extern l_int32 pixFreeData ( PIX *pix );
+LEPT_DLL extern void ** pixGetLinePtrs ( PIX *pix, l_int32 *psize );
+LEPT_DLL extern l_int32 pixPrintStreamInfo ( FILE *fp, PIX *pix, const char *text );
+LEPT_DLL extern l_int32 pixGetPixel ( PIX *pix, l_int32 x, l_int32 y, l_uint32 *pval );
+LEPT_DLL extern l_int32 pixSetPixel ( PIX *pix, l_int32 x, l_int32 y, l_uint32 val );
+LEPT_DLL extern l_int32 pixGetRGBPixel ( PIX *pix, l_int32 x, l_int32 y, l_int32 *prval, l_int32 *pgval, l_int32 *pbval );
+LEPT_DLL extern l_int32 pixSetRGBPixel ( PIX *pix, l_int32 x, l_int32 y, l_int32 rval, l_int32 gval, l_int32 bval );
+LEPT_DLL extern l_int32 pixGetRandomPixel ( PIX *pix, l_uint32 *pval, l_int32 *px, l_int32 *py );
+LEPT_DLL extern l_int32 pixClearPixel ( PIX *pix, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 pixFlipPixel ( PIX *pix, l_int32 x, l_int32 y );
+LEPT_DLL extern void setPixelLow ( l_uint32 *line, l_int32 x, l_int32 depth, l_uint32 val );
+LEPT_DLL extern l_int32 pixClearAll ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetAll ( PIX *pix );
+LEPT_DLL extern l_int32 pixSetAllArbitrary ( PIX *pix, l_uint32 val );
+LEPT_DLL extern l_int32 pixSetBlackOrWhite ( PIX *pixs, l_int32 op );
+LEPT_DLL extern l_int32 pixClearInRect ( PIX *pix, BOX *box );
+LEPT_DLL extern l_int32 pixSetInRect ( PIX *pix, BOX *box );
+LEPT_DLL extern l_int32 pixSetInRectArbitrary ( PIX *pix, BOX *box, l_uint32 val );
+LEPT_DLL extern l_int32 pixBlendInRect ( PIX *pixs, BOX *box, l_uint32 val, l_float32 fract );
+LEPT_DLL extern l_int32 pixSetPadBits ( PIX *pix, l_int32 val );
+LEPT_DLL extern l_int32 pixSetPadBitsBand ( PIX *pix, l_int32 by, l_int32 bh, l_int32 val );
+LEPT_DLL extern l_int32 pixSetOrClearBorder ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_int32 op );
+LEPT_DLL extern l_int32 pixSetBorderVal ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val );
+LEPT_DLL extern l_int32 pixSetBorderRingVal ( PIX *pixs, l_int32 dist, l_uint32 val );
+LEPT_DLL extern l_int32 pixSetMirroredBorder ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern PIX * pixCopyBorder ( PIX *pixd, PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern PIX * pixAddBorder ( PIX *pixs, l_int32 npix, l_uint32 val );
+LEPT_DLL extern PIX * pixAddBlackBorder ( PIX *pixs, l_int32 npix );
+LEPT_DLL extern PIX * pixAddBorderGeneral ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val );
+LEPT_DLL extern PIX * pixRemoveBorder ( PIX *pixs, l_int32 npix );
+LEPT_DLL extern PIX * pixRemoveBorderGeneral ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern PIX * pixAddMirroredBorder ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern PIX * pixAddRepeatedBorder ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern PIX * pixAddMixedBorder ( PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot );
+LEPT_DLL extern PIX * pixCreateRGBImage ( PIX *pixr, PIX *pixg, PIX *pixb );
+LEPT_DLL extern PIX * pixGetRGBComponent ( PIX *pixs, l_int32 color );
+LEPT_DLL extern l_int32 pixSetRGBComponent ( PIX *pixd, PIX *pixs, l_int32 color );
+LEPT_DLL extern PIX * pixGetRGBComponentCmap ( PIX *pixs, l_int32 color );
+LEPT_DLL extern l_int32 composeRGBPixel ( l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 *ppixel );
+LEPT_DLL extern void extractRGBValues ( l_uint32 pixel, l_int32 *prval, l_int32 *pgval, l_int32 *pbval );
+LEPT_DLL extern l_int32 extractMinMaxComponent ( l_uint32 pixel, l_int32 type );
+LEPT_DLL extern l_int32 pixGetRGBLine ( PIX *pixs, l_int32 row, l_uint8 *bufr, l_uint8 *bufg, l_uint8 *bufb );
+LEPT_DLL extern PIX * pixEndianByteSwapNew ( PIX *pixs );
+LEPT_DLL extern l_int32 pixEndianByteSwap ( PIX *pixs );
+LEPT_DLL extern l_int32 lineEndianByteSwap ( l_uint32 *datad, l_uint32 *datas, l_int32 wpl );
+LEPT_DLL extern PIX * pixEndianTwoByteSwapNew ( PIX *pixs );
+LEPT_DLL extern l_int32 pixEndianTwoByteSwap ( PIX *pixs );
+LEPT_DLL extern l_int32 pixGetRasterData ( PIX *pixs, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern l_uint8 ** pixSetupByteProcessing ( PIX *pix, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern l_int32 pixCleanupByteProcessing ( PIX *pix, l_uint8 **lineptrs );
+LEPT_DLL extern void l_setAlphaMaskBorder ( l_float32 val1, l_float32 val2 );
+LEPT_DLL extern l_int32 pixSetMasked ( PIX *pixd, PIX *pixm, l_uint32 val );
+LEPT_DLL extern l_int32 pixSetMaskedGeneral ( PIX *pixd, PIX *pixm, l_uint32 val, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 pixCombineMasked ( PIX *pixd, PIX *pixs, PIX *pixm );
+LEPT_DLL extern l_int32 pixCombineMaskedGeneral ( PIX *pixd, PIX *pixs, PIX *pixm, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 pixPaintThroughMask ( PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_uint32 val );
+LEPT_DLL extern l_int32 pixPaintSelfThroughMask ( PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_int32 tilesize, l_int32 searchdir );
+LEPT_DLL extern PIX * pixMakeMaskFromLUT ( PIX *pixs, l_int32 *tab );
+LEPT_DLL extern PIX * pixSetUnderTransparency ( PIX *pixs, l_uint32 val, l_int32 debugflag );
+LEPT_DLL extern PIX * pixInvert ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern PIX * pixOr ( PIX *pixd, PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern PIX * pixAnd ( PIX *pixd, PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern PIX * pixXor ( PIX *pixd, PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern PIX * pixSubtract ( PIX *pixd, PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern l_int32 pixZero ( PIX *pix, l_int32 *pempty );
+LEPT_DLL extern l_int32 pixForegroundFraction ( PIX *pix, l_float32 *pfract );
+LEPT_DLL extern l_int32 pixCountPixels ( PIX *pix, l_int32 *pcount, l_int32 *tab8 );
+LEPT_DLL extern NUMA * pixaCountPixels ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixCountPixelsInRow ( PIX *pix, l_int32 row, l_int32 *pcount, l_int32 *tab8 );
+LEPT_DLL extern NUMA * pixCountPixelsByRow ( PIX *pix, l_int32 *tab8 );
+LEPT_DLL extern NUMA * pixCountPixelsByColumn ( PIX *pix );
+LEPT_DLL extern NUMA * pixSumPixelsByRow ( PIX *pix, l_int32 *tab8 );
+LEPT_DLL extern NUMA * pixSumPixelsByColumn ( PIX *pix );
+LEPT_DLL extern l_int32 pixThresholdPixelSum ( PIX *pix, l_int32 thresh, l_int32 *pabove, l_int32 *tab8 );
+LEPT_DLL extern l_int32 * makePixelSumTab8 ( void );
+LEPT_DLL extern l_int32 * makePixelCentroidTab8 ( void );
+LEPT_DLL extern l_int32 pixCountArbInRect ( PIX *pixs, BOX *box, l_int32 val, l_int32 factor, l_int32 *pcount );
+LEPT_DLL extern l_int32 pixSumPixelValues ( PIX *pix, BOX *box, l_float64 *psum );
+LEPT_DLL extern PIX * pixMirroredTiling ( PIX *pixs, l_int32 w, l_int32 h );
+LEPT_DLL extern NUMA * pixGetGrayHistogram ( PIX *pixs, l_int32 factor );
+LEPT_DLL extern NUMA * pixGetGrayHistogramMasked ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor );
+LEPT_DLL extern NUMA * pixGetGrayHistogramInRect ( PIX *pixs, BOX *box, l_int32 factor );
+LEPT_DLL extern l_int32 pixGetColorHistogram ( PIX *pixs, l_int32 factor, NUMA **pnar, NUMA **pnag, NUMA **pnab );
+LEPT_DLL extern l_int32 pixGetColorHistogramMasked ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, NUMA **pnar, NUMA **pnag, NUMA **pnab );
+LEPT_DLL extern NUMA * pixGetCmapHistogram ( PIX *pixs, l_int32 factor );
+LEPT_DLL extern NUMA * pixGetCmapHistogramMasked ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor );
+LEPT_DLL extern NUMA * pixGetCmapHistogramInRect ( PIX *pixs, BOX *box, l_int32 factor );
+LEPT_DLL extern l_int32 pixGetRankValue ( PIX *pixs, l_int32 factor, l_float32 rank, l_uint32 *pvalue );
+LEPT_DLL extern l_int32 pixGetRankValueMaskedRGB ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_float32 rank, l_float32 *prval, l_float32 *pgval, l_float32 *pbval );
+LEPT_DLL extern l_int32 pixGetRankValueMasked ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_float32 rank, l_float32 *pval, NUMA **pna );
+LEPT_DLL extern l_int32 pixGetAverageValue ( PIX *pixs, l_int32 factor, l_int32 type, l_uint32 *pvalue );
+LEPT_DLL extern l_int32 pixGetAverageMaskedRGB ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *prval, l_float32 *pgval, l_float32 *pbval );
+LEPT_DLL extern l_int32 pixGetAverageMasked ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_int32 factor, l_int32 type, l_float32 *pval );
+LEPT_DLL extern l_int32 pixGetAverageTiledRGB ( PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type, PIX **ppixr, PIX **ppixg, PIX **ppixb );
+LEPT_DLL extern PIX * pixGetAverageTiled ( PIX *pixs, l_int32 sx, l_int32 sy, l_int32 type );
+LEPT_DLL extern l_int32 pixRowStats ( PIX *pixs, NUMA **pnamean, NUMA **pnamedian, NUMA **pnamode, NUMA **pnamodecount, NUMA **pnavar, NUMA **pnarootvar );
+LEPT_DLL extern l_int32 pixColumnStats ( PIX *pixs, NUMA **pnamean, NUMA **pnamedian, NUMA **pnamode, NUMA **pnamodecount, NUMA **pnavar, NUMA **pnarootvar );
+LEPT_DLL extern l_int32 pixGetComponentRange ( PIX *pixs, l_int32 factor, l_int32 color, l_int32 *pminval, l_int32 *pmaxval );
+LEPT_DLL extern l_int32 pixGetExtremeValue ( PIX *pixs, l_int32 factor, l_int32 type, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *pgrayval );
+LEPT_DLL extern l_int32 pixGetMaxValueInRect ( PIX *pixs, BOX *box, l_uint32 *pmaxval, l_int32 *pxmax, l_int32 *pymax );
+LEPT_DLL extern l_int32 pixGetBinnedComponentRange ( PIX *pixs, l_int32 nbins, l_int32 factor, l_int32 color, l_int32 *pminval, l_int32 *pmaxval, l_uint32 **pcarray, l_int32 debugflag );
+LEPT_DLL extern l_int32 pixGetRankColorArray ( PIX *pixs, l_int32 nbins, l_int32 type, l_int32 factor, l_uint32 **pcarray, l_int32 debugflag );
+LEPT_DLL extern l_int32 pixGetBinnedColor ( PIX *pixs, PIX *pixg, l_int32 factor, l_int32 nbins, NUMA *nalut, l_uint32 **pcarray, l_int32 debugflag );
+LEPT_DLL extern PIX * pixDisplayColorArray ( l_uint32 *carray, l_int32 ncolors, l_int32 side, l_int32 ncols, l_int32 textflag );
+LEPT_DLL extern PIX * pixaGetAlignedStats ( PIXA *pixa, l_int32 type, l_int32 nbins, l_int32 thresh );
+LEPT_DLL extern l_int32 pixaExtractColumnFromEachPix ( PIXA *pixa, l_int32 col, PIX *pixd );
+LEPT_DLL extern l_int32 pixGetRowStats ( PIX *pixs, l_int32 type, l_int32 nbins, l_int32 thresh, l_float32 *colvect );
+LEPT_DLL extern l_int32 pixGetColumnStats ( PIX *pixs, l_int32 type, l_int32 nbins, l_int32 thresh, l_float32 *rowvect );
+LEPT_DLL extern l_int32 pixSetPixelColumn ( PIX *pix, l_int32 col, l_float32 *colvect );
+LEPT_DLL extern l_int32 pixThresholdForFgBg ( PIX *pixs, l_int32 factor, l_int32 thresh, l_int32 *pfgval, l_int32 *pbgval );
+LEPT_DLL extern l_int32 pixSplitDistributionFgBg ( PIX *pixs, l_float32 scorefract, l_int32 factor, l_int32 *pthresh, l_int32 *pfgval, l_int32 *pbgval, l_int32 debugflag );
+LEPT_DLL extern l_int32 pixaFindDimensions ( PIXA *pixa, NUMA **pnaw, NUMA **pnah );
+LEPT_DLL extern NUMA * pixaFindAreaPerimRatio ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixFindAreaPerimRatio ( PIX *pixs, l_int32 *tab, l_float32 *pfract );
+LEPT_DLL extern NUMA * pixaFindPerimSizeRatio ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixFindPerimSizeRatio ( PIX *pixs, l_int32 *tab, l_float32 *pratio );
+LEPT_DLL extern NUMA * pixaFindAreaFraction ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixFindAreaFraction ( PIX *pixs, l_int32 *tab, l_float32 *pfract );
+LEPT_DLL extern NUMA * pixaFindWidthHeightRatio ( PIXA *pixa );
+LEPT_DLL extern NUMA * pixaFindWidthHeightProduct ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixFindOverlapFraction ( PIX *pixs1, PIX *pixs2, l_int32 x2, l_int32 y2, l_int32 *tab, l_float32 *pratio, l_int32 *pnoverlap );
+LEPT_DLL extern BOXA * pixFindRectangleComps ( PIX *pixs, l_int32 dist, l_int32 minw, l_int32 minh );
+LEPT_DLL extern l_int32 pixConformsToRectangle ( PIX *pixs, BOX *box, l_int32 dist, l_int32 *pconforms );
+LEPT_DLL extern PIX * pixClipRectangle ( PIX *pixs, BOX *box, BOX **pboxc );
+LEPT_DLL extern PIX * pixClipMasked ( PIX *pixs, PIX *pixm, l_int32 x, l_int32 y, l_uint32 outval );
+LEPT_DLL extern PIX * pixResizeToMatch ( PIX *pixs, PIX *pixt, l_int32 w, l_int32 h );
+LEPT_DLL extern l_int32 pixClipToForeground ( PIX *pixs, PIX **ppixd, BOX **pbox );
+LEPT_DLL extern l_int32 pixClipBoxToForeground ( PIX *pixs, BOX *boxs, PIX **ppixd, BOX **pboxd );
+LEPT_DLL extern l_int32 pixScanForForeground ( PIX *pixs, BOX *box, l_int32 scanflag, l_int32 *ploc );
+LEPT_DLL extern l_int32 pixClipBoxToEdges ( PIX *pixs, BOX *boxs, l_int32 lowthresh, l_int32 highthresh, l_int32 maxwidth, l_int32 factor, PIX **ppixd, BOX **pboxd );
+LEPT_DLL extern l_int32 pixScanForEdge ( PIX *pixs, BOX *box, l_int32 lowthresh, l_int32 highthresh, l_int32 maxwidth, l_int32 factor, l_int32 scanflag, l_int32 *ploc );
+LEPT_DLL extern NUMA * pixExtractOnLine ( PIX *pixs, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 factor );
+LEPT_DLL extern l_float32 pixAverageOnLine ( PIX *pixs, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 factor );
+LEPT_DLL extern NUMA * pixAverageIntensityProfile ( PIX *pixs, l_float32 fract, l_int32 dir, l_int32 first, l_int32 last, l_int32 factor1, l_int32 factor2 );
+LEPT_DLL extern NUMA * pixReversalProfile ( PIX *pixs, l_float32 fract, l_int32 dir, l_int32 first, l_int32 last, l_int32 minreversal, l_int32 factor1, l_int32 factor2 );
+LEPT_DLL extern PIX * pixRankRowTransform ( PIX *pixs );
+LEPT_DLL extern PIX * pixRankColumnTransform ( PIX *pixs );
+LEPT_DLL extern PIXA * pixaCreate ( l_int32 n );
+LEPT_DLL extern PIXA * pixaCreateFromPix ( PIX *pixs, l_int32 n, l_int32 cellw, l_int32 cellh );
+LEPT_DLL extern PIXA * pixaCreateFromBoxa ( PIX *pixs, BOXA *boxa, l_int32 *pcropwarn );
+LEPT_DLL extern PIXA * pixaSplitPix ( PIX *pixs, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor );
+LEPT_DLL extern void pixaDestroy ( PIXA **ppixa );
+LEPT_DLL extern PIXA * pixaCopy ( PIXA *pixa, l_int32 copyflag );
+LEPT_DLL extern l_int32 pixaAddPix ( PIXA *pixa, PIX *pix, l_int32 copyflag );
+LEPT_DLL extern l_int32 pixaExtendArray ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixaExtendArrayToSize ( PIXA *pixa, l_int32 size );
+LEPT_DLL extern l_int32 pixaAddBox ( PIXA *pixa, BOX *box, l_int32 copyflag );
+LEPT_DLL extern l_int32 pixaGetCount ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixaChangeRefcount ( PIXA *pixa, l_int32 delta );
+LEPT_DLL extern PIX * pixaGetPix ( PIXA *pixa, l_int32 index, l_int32 accesstype );
+LEPT_DLL extern l_int32 pixaGetPixDimensions ( PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd );
+LEPT_DLL extern BOXA * pixaGetBoxa ( PIXA *pixa, l_int32 accesstype );
+LEPT_DLL extern l_int32 pixaGetBoxaCount ( PIXA *pixa );
+LEPT_DLL extern BOX * pixaGetBox ( PIXA *pixa, l_int32 index, l_int32 accesstype );
+LEPT_DLL extern l_int32 pixaGetBoxGeometry ( PIXA *pixa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern PIX ** pixaGetPixArray ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixaReplacePix ( PIXA *pixa, l_int32 index, PIX *pix, BOX *box );
+LEPT_DLL extern l_int32 pixaInsertPix ( PIXA *pixa, l_int32 index, PIX *pixs, BOX *box );
+LEPT_DLL extern l_int32 pixaRemovePix ( PIXA *pixa, l_int32 index );
+LEPT_DLL extern l_int32 pixaInitFull ( PIXA *pixa, PIX *pix, BOX *box );
+LEPT_DLL extern l_int32 pixaClear ( PIXA *pixa );
+LEPT_DLL extern l_int32 pixaJoin ( PIXA *pixad, PIXA *pixas, l_int32 istart, l_int32 iend );
+LEPT_DLL extern PIXAA * pixaaCreate ( l_int32 n );
+LEPT_DLL extern PIXAA * pixaaCreateFromPixa ( PIXA *pixa, l_int32 n, l_int32 type, l_int32 copyflag );
+LEPT_DLL extern void pixaaDestroy ( PIXAA **ppixaa );
+LEPT_DLL extern l_int32 pixaaAddPixa ( PIXAA *pixaa, PIXA *pixa, l_int32 copyflag );
+LEPT_DLL extern l_int32 pixaaExtendArray ( PIXAA *pixaa );
+LEPT_DLL extern l_int32 pixaaAddBox ( PIXAA *pixaa, BOX *box, l_int32 copyflag );
+LEPT_DLL extern l_int32 pixaaGetCount ( PIXAA *pixaa );
+LEPT_DLL extern PIXA * pixaaGetPixa ( PIXAA *pixaa, l_int32 index, l_int32 accesstype );
+LEPT_DLL extern BOXA * pixaaGetBoxa ( PIXAA *pixaa, l_int32 accesstype );
+LEPT_DLL extern PIX * pixaaGetPix ( PIXAA *paa, l_int32 ipixa, l_int32 ipix, l_int32 accessflag );
+LEPT_DLL extern PIXA * pixaRead ( const char *filename );
+LEPT_DLL extern PIXA * pixaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 pixaWrite ( const char *filename, PIXA *pixa );
+LEPT_DLL extern l_int32 pixaWriteStream ( FILE *fp, PIXA *pixa );
+LEPT_DLL extern PIXAA * pixaaRead ( const char *filename );
+LEPT_DLL extern PIXAA * pixaaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 pixaaWrite ( const char *filename, PIXAA *pixaa );
+LEPT_DLL extern l_int32 pixaaWriteStream ( FILE *fp, PIXAA *pixaa );
+LEPT_DLL extern PIXACC * pixaccCreate ( l_int32 w, l_int32 h, l_int32 negflag );
+LEPT_DLL extern PIXACC * pixaccCreateWithPix ( PIX *pix, l_int32 negflag );
+LEPT_DLL extern void pixaccDestroy ( PIXACC **ppixacc );
+LEPT_DLL extern PIX * pixaccFinal ( PIXACC *pixacc, l_int32 outdepth );
+LEPT_DLL extern PIX * pixaccGetPix ( PIXACC *pixacc );
+LEPT_DLL extern l_int32 pixaccGetOffset ( PIXACC *pixacc );
+LEPT_DLL extern l_int32 pixaccAdd ( PIXACC *pixacc, PIX *pix );
+LEPT_DLL extern l_int32 pixaccSubtract ( PIXACC *pixacc, PIX *pix );
+LEPT_DLL extern l_int32 pixaccMultConst ( PIXACC *pixacc, l_float32 factor );
+LEPT_DLL extern l_int32 pixaccMultConstAccumulate ( PIXACC *pixacc, PIX *pix, l_float32 factor );
+LEPT_DLL extern PIX * pixSelectBySize ( PIX *pixs, l_int32 width, l_int32 height, l_int32 connectivity, l_int32 type, l_int32 relation, l_int32 *pchanged );
+LEPT_DLL extern PIXA * pixaSelectBySize ( PIXA *pixas, l_int32 width, l_int32 height, l_int32 type, l_int32 relation, l_int32 *pchanged );
+LEPT_DLL extern PIX * pixSelectByAreaPerimRatio ( PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged );
+LEPT_DLL extern PIXA * pixaSelectByAreaPerimRatio ( PIXA *pixas, l_float32 thresh, l_int32 type, l_int32 *pchanged );
+LEPT_DLL extern PIX * pixSelectByAreaFraction ( PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged );
+LEPT_DLL extern PIXA * pixaSelectByAreaFraction ( PIXA *pixas, l_float32 thresh, l_int32 type, l_int32 *pchanged );
+LEPT_DLL extern PIX * pixSelectByWidthHeightRatio ( PIX *pixs, l_float32 thresh, l_int32 connectivity, l_int32 type, l_int32 *pchanged );
+LEPT_DLL extern PIXA * pixaSelectByWidthHeightRatio ( PIXA *pixas, l_float32 thresh, l_int32 type, l_int32 *pchanged );
+LEPT_DLL extern PIXA * pixaSelectWithIndicator ( PIXA *pixas, NUMA *na, l_int32 *pchanged );
+LEPT_DLL extern l_int32 pixRemoveWithIndicator ( PIX *pixs, PIXA *pixa, NUMA *na );
+LEPT_DLL extern l_int32 pixAddWithIndicator ( PIX *pixs, PIXA *pixa, NUMA *na );
+LEPT_DLL extern PIX * pixaRenderComponent ( PIX *pixs, PIXA *pixa, l_int32 index );
+LEPT_DLL extern PIXA * pixaSort ( PIXA *pixas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex, l_int32 copyflag );
+LEPT_DLL extern PIXA * pixaBinSort ( PIXA *pixas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex, l_int32 copyflag );
+LEPT_DLL extern PIXA * pixaSortByIndex ( PIXA *pixas, NUMA *naindex, l_int32 copyflag );
+LEPT_DLL extern PIXAA * pixaSort2dByIndex ( PIXA *pixas, NUMAA *naa, l_int32 copyflag );
+LEPT_DLL extern PIXA * pixaAddBorderGeneral ( PIXA *pixad, PIXA *pixas, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val );
+LEPT_DLL extern PIXA * pixaaFlattenToPixa ( PIXAA *pixaa, NUMA **pnaindex, l_int32 copyflag );
+LEPT_DLL extern l_int32 pixaSizeRange ( PIXA *pixa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh );
+LEPT_DLL extern PIXA * pixaClipToPix ( PIXA *pixas, PIX *pixs );
+LEPT_DLL extern l_int32 pixaAnyColormaps ( PIXA *pixa, l_int32 *phascmap );
+LEPT_DLL extern l_int32 pixaGetDepthInfo ( PIXA *pixa, l_int32 *pmaxdepth, l_int32 *psame );
+LEPT_DLL extern l_int32 pixaEqual ( PIXA *pixa1, PIXA *pixa2, l_int32 maxdist, NUMA **pnaindex, l_int32 *psame );
+LEPT_DLL extern PIX * pixaDisplay ( PIXA *pixa, l_int32 w, l_int32 h );
+LEPT_DLL extern PIX * pixaDisplayOnColor ( PIXA *pixa, l_int32 w, l_int32 h, l_uint32 bgcolor );
+LEPT_DLL extern PIX * pixaDisplayRandomCmap ( PIXA *pixa, l_int32 w, l_int32 h );
+LEPT_DLL extern PIX * pixaDisplayOnLattice ( PIXA *pixa, l_int32 xspace, l_int32 yspace );
+LEPT_DLL extern PIX * pixaDisplayUnsplit ( PIXA *pixa, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor );
+LEPT_DLL extern PIX * pixaDisplayTiled ( PIXA *pixa, l_int32 maxwidth, l_int32 background, l_int32 spacing );
+LEPT_DLL extern PIX * pixaDisplayTiledInRows ( PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border );
+LEPT_DLL extern PIX * pixaDisplayTiledAndScaled ( PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border );
+LEPT_DLL extern PIX * pixaaDisplay ( PIXAA *pixaa, l_int32 w, l_int32 h );
+LEPT_DLL extern PIX * pixaaDisplayByPixa ( PIXAA *pixaa, l_int32 xspace, l_int32 yspace, l_int32 maxw );
+LEPT_DLL extern PIXA * pixaaDisplayTiledAndScaled ( PIXAA *pixaa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border );
+LEPT_DLL extern l_int32 pmsCreate ( size_t minsize, size_t smallest, NUMA *numalloc, const char *logfile );
+LEPT_DLL extern void pmsDestroy ( );
+LEPT_DLL extern void * pmsCustomAlloc ( size_t nbytes );
+LEPT_DLL extern void pmsCustomDealloc ( void *data );
+LEPT_DLL extern void * pmsGetAlloc ( size_t nbytes );
+LEPT_DLL extern l_int32 pmsGetLevelForAlloc ( size_t nbytes, l_int32 *plevel );
+LEPT_DLL extern l_int32 pmsGetLevelForDealloc ( void *data, l_int32 *plevel );
+LEPT_DLL extern void pmsLogInfo ( );
+LEPT_DLL extern l_int32 pixAddConstantGray ( PIX *pixs, l_int32 val );
+LEPT_DLL extern l_int32 pixMultConstantGray ( PIX *pixs, l_float32 val );
+LEPT_DLL extern PIX * pixAddGray ( PIX *pixd, PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern PIX * pixSubtractGray ( PIX *pixd, PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern PIX * pixThresholdToValue ( PIX *pixd, PIX *pixs, l_int32 threshval, l_int32 setval );
+LEPT_DLL extern PIX * pixInitAccumulate ( l_int32 w, l_int32 h, l_uint32 offset );
+LEPT_DLL extern PIX * pixFinalAccumulate ( PIX *pixs, l_uint32 offset, l_int32 depth );
+LEPT_DLL extern PIX * pixFinalAccumulateThreshold ( PIX *pixs, l_uint32 offset, l_uint32 threshold );
+LEPT_DLL extern l_int32 pixAccumulate ( PIX *pixd, PIX *pixs, l_int32 op );
+LEPT_DLL extern l_int32 pixMultConstAccumulate ( PIX *pixs, l_float32 factor, l_uint32 offset );
+LEPT_DLL extern PIX * pixAbsDifference ( PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern PIX * pixMinOrMax ( PIX *pixd, PIX *pixs1, PIX *pixs2, l_int32 type );
+LEPT_DLL extern PIX * pixMaxDynamicRange ( PIX *pixs, l_int32 type );
+LEPT_DLL extern l_float32 * makeLogBase2Tab ( void );
+LEPT_DLL extern l_float32 getLogBase2 ( l_int32 val, l_float32 *logtab );
+LEPT_DLL extern PIXC * pixcompCreateFromPix ( PIX *pix, l_int32 comptype );
+LEPT_DLL extern PIXC * pixcompCreateFromString ( l_uint8 *data, size_t size, l_int32 copyflag );
+LEPT_DLL extern PIXC * pixcompCreateFromFile ( const char *filename, l_int32 comptype );
+LEPT_DLL extern void pixcompDestroy ( PIXC **ppixc );
+LEPT_DLL extern l_int32 pixcompGetDimensions ( PIXC *pixc, l_int32 *pw, l_int32 *ph, l_int32 *pd );
+LEPT_DLL extern l_int32 pixcompDetermineFormat ( l_int32 comptype, l_int32 d, l_int32 cmapflag, l_int32 *pformat );
+LEPT_DLL extern PIX * pixCreateFromPixcomp ( PIXC *pixc );
+LEPT_DLL extern PIXAC * pixacompCreate ( l_int32 n );
+LEPT_DLL extern PIXAC * pixacompCreateInitialized ( l_int32 n, l_int32 offset, PIX *pix, l_int32 comptype );
+LEPT_DLL extern PIXAC * pixacompCreateFromPixa ( PIXA *pixa, l_int32 comptype, l_int32 accesstype );
+LEPT_DLL extern PIXAC * pixacompCreateFromFiles ( const char *dirname, const char *substr, l_int32 comptype );
+LEPT_DLL extern PIXAC * pixacompCreateFromSA ( SARRAY *sa, l_int32 comptype );
+LEPT_DLL extern void pixacompDestroy ( PIXAC **ppixac );
+LEPT_DLL extern l_int32 pixacompAddPix ( PIXAC *pixac, PIX *pix, l_int32 comptype );
+LEPT_DLL extern l_int32 pixacompAddPixcomp ( PIXAC *pixac, PIXC *pixc );
+LEPT_DLL extern l_int32 pixacompExtendArray ( PIXAC *pixac );
+LEPT_DLL extern l_int32 pixacompReplacePix ( PIXAC *pixac, l_int32 index, PIX *pix, l_int32 comptype );
+LEPT_DLL extern l_int32 pixacompReplacePixcomp ( PIXAC *pixac, l_int32 index, PIXC *pixc );
+LEPT_DLL extern l_int32 pixacompAddBox ( PIXAC *pixac, BOX *box, l_int32 copyflag );
+LEPT_DLL extern l_int32 pixacompGetCount ( PIXAC *pixac );
+LEPT_DLL extern PIXC * pixacompGetPixcomp ( PIXAC *pixac, l_int32 index );
+LEPT_DLL extern PIX * pixacompGetPix ( PIXAC *pixac, l_int32 index );
+LEPT_DLL extern l_int32 pixacompGetPixDimensions ( PIXAC *pixac, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd );
+LEPT_DLL extern BOXA * pixacompGetBoxa ( PIXAC *pixac, l_int32 accesstype );
+LEPT_DLL extern l_int32 pixacompGetBoxaCount ( PIXAC *pixac );
+LEPT_DLL extern BOX * pixacompGetBox ( PIXAC *pixac, l_int32 index, l_int32 accesstype );
+LEPT_DLL extern l_int32 pixacompGetBoxGeometry ( PIXAC *pixac, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern l_int32 pixacompGetOffset ( PIXAC *pixac );
+LEPT_DLL extern l_int32 pixacompSetOffset ( PIXAC *pixac, l_int32 offset );
+LEPT_DLL extern PIXA * pixaCreateFromPixacomp ( PIXAC *pixac, l_int32 accesstype );
+LEPT_DLL extern PIXAC * pixacompRead ( const char *filename );
+LEPT_DLL extern PIXAC * pixacompReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 pixacompWrite ( const char *filename, PIXAC *pixac );
+LEPT_DLL extern l_int32 pixacompWriteStream ( FILE *fp, PIXAC *pixac );
+LEPT_DLL extern l_int32 pixacompConvertToPdf ( PIXAC *pixac, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout );
+LEPT_DLL extern l_int32 pixacompConvertToPdfData ( PIXAC *pixac, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, l_uint8 **pdata, size_t *pnbytes );
+LEPT_DLL extern l_int32 pixacompWriteStreamInfo ( FILE *fp, PIXAC *pixac, const char *text );
+LEPT_DLL extern l_int32 pixcompWriteStreamInfo ( FILE *fp, PIXC *pixc, const char *text );
+LEPT_DLL extern PIX * pixacompDisplayTiledAndScaled ( PIXAC *pixac, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border );
+LEPT_DLL extern PIX * pixThreshold8 ( PIX *pixs, l_int32 d, l_int32 nlevels, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixRemoveColormap ( PIX *pixs, l_int32 type );
+LEPT_DLL extern l_int32 pixAddGrayColormap8 ( PIX *pixs );
+LEPT_DLL extern PIX * pixAddMinimalGrayColormap8 ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertRGBToLuminance ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertRGBToGray ( PIX *pixs, l_float32 rwt, l_float32 gwt, l_float32 bwt );
+LEPT_DLL extern PIX * pixConvertRGBToGrayFast ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertRGBToGrayMinMax ( PIX *pixs, l_int32 type );
+LEPT_DLL extern PIX * pixConvertGrayToColormap ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertGrayToColormap8 ( PIX *pixs, l_int32 mindepth );
+LEPT_DLL extern PIX * pixColorizeGray ( PIX *pixs, l_uint32 color, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixConvertRGBToColormap ( PIX *pixs, l_int32 ditherflag );
+LEPT_DLL extern l_int32 pixQuantizeIfFewColors ( PIX *pixs, l_int32 maxcolors, l_int32 mingraycolors, l_int32 octlevel, PIX **ppixd );
+LEPT_DLL extern PIX * pixConvert16To8 ( PIX *pixs, l_int32 whichbyte );
+LEPT_DLL extern PIX * pixConvertGrayToFalseColor ( PIX *pixs, l_float32 gamma );
+LEPT_DLL extern PIX * pixUnpackBinary ( PIX *pixs, l_int32 depth, l_int32 invert );
+LEPT_DLL extern PIX * pixConvert1To16 ( PIX *pixd, PIX *pixs, l_uint16 val0, l_uint16 val1 );
+LEPT_DLL extern PIX * pixConvert1To32 ( PIX *pixd, PIX *pixs, l_uint32 val0, l_uint32 val1 );
+LEPT_DLL extern PIX * pixConvert1To2Cmap ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvert1To2 ( PIX *pixd, PIX *pixs, l_int32 val0, l_int32 val1 );
+LEPT_DLL extern PIX * pixConvert1To4Cmap ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvert1To4 ( PIX *pixd, PIX *pixs, l_int32 val0, l_int32 val1 );
+LEPT_DLL extern PIX * pixConvert1To8 ( PIX *pixd, PIX *pixs, l_uint8 val0, l_uint8 val1 );
+LEPT_DLL extern PIX * pixConvert2To8 ( PIX *pixs, l_uint8 val0, l_uint8 val1, l_uint8 val2, l_uint8 val3, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixConvert4To8 ( PIX *pixs, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixConvert8To16 ( PIX *pixs, l_int32 leftshift );
+LEPT_DLL extern PIX * pixConvertTo1 ( PIX *pixs, l_int32 threshold );
+LEPT_DLL extern PIX * pixConvertTo1BySampling ( PIX *pixs, l_int32 factor, l_int32 threshold );
+LEPT_DLL extern PIX * pixConvertTo8 ( PIX *pixs, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixConvertTo8BySampling ( PIX *pixs, l_int32 factor, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixConvertTo16 ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertTo32 ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertTo32BySampling ( PIX *pixs, l_int32 factor );
+LEPT_DLL extern PIX * pixConvert8To32 ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertTo8Or32 ( PIX *pixs, l_int32 copyflag, l_int32 warnflag );
+LEPT_DLL extern PIX * pixConvert24To32 ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvert32To24 ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertLossless ( PIX *pixs, l_int32 d );
+LEPT_DLL extern PIX * pixConvertForPSWrap ( PIX *pixs );
+LEPT_DLL extern PIX * pixConvertToSubpixelRGB ( PIX *pixs, l_float32 scalex, l_float32 scaley, l_int32 order );
+LEPT_DLL extern PIX * pixConvertGrayToSubpixelRGB ( PIX *pixs, l_float32 scalex, l_float32 scaley, l_int32 order );
+LEPT_DLL extern PIX * pixConvertColorToSubpixelRGB ( PIX *pixs, l_float32 scalex, l_float32 scaley, l_int32 order );
+LEPT_DLL extern PIXTILING * pixTilingCreate ( PIX *pixs, l_int32 nx, l_int32 ny, l_int32 w, l_int32 h, l_int32 xoverlap, l_int32 yoverlap );
+LEPT_DLL extern void pixTilingDestroy ( PIXTILING **ppt );
+LEPT_DLL extern l_int32 pixTilingGetCount ( PIXTILING *pt, l_int32 *pnx, l_int32 *pny );
+LEPT_DLL extern l_int32 pixTilingGetSize ( PIXTILING *pt, l_int32 *pw, l_int32 *ph );
+LEPT_DLL extern PIX * pixTilingGetTile ( PIXTILING *pt, l_int32 i, l_int32 j );
+LEPT_DLL extern l_int32 pixTilingNoStripOnPaint ( PIXTILING *pt );
+LEPT_DLL extern l_int32 pixTilingPaintTile ( PIX *pixd, l_int32 i, l_int32 j, PIX *pixs, PIXTILING *pt );
+LEPT_DLL extern PIX * pixReadStreamPng ( FILE *fp );
+LEPT_DLL extern l_int32 readHeaderPng ( const char *filename, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 freadHeaderPng ( FILE *fp, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 sreadHeaderPng ( const l_uint8 *data, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 fgetPngResolution ( FILE *fp, l_int32 *pxres, l_int32 *pyres );
+LEPT_DLL extern l_int32 pixWritePng ( const char *filename, PIX *pix, l_float32 gamma );
+LEPT_DLL extern l_int32 pixWriteStreamPng ( FILE *fp, PIX *pix, l_float32 gamma );
+LEPT_DLL extern PIX * pixReadRGBAPng ( const char *filename );
+LEPT_DLL extern l_int32 pixWriteRGBAPng ( const char *filename, PIX *pix );
+LEPT_DLL extern void l_pngSetStrip16To8 ( l_int32 flag );
+LEPT_DLL extern void l_pngSetStripAlpha ( l_int32 flag );
+LEPT_DLL extern void l_pngSetWriteAlpha ( l_int32 flag );
+LEPT_DLL extern void l_pngSetZlibCompression ( l_int32 val );
+LEPT_DLL extern PIX * pixReadMemPng ( const l_uint8 *cdata, size_t size );
+LEPT_DLL extern l_int32 pixWriteMemPng ( l_uint8 **pdata, size_t *psize, PIX *pix, l_float32 gamma );
+LEPT_DLL extern PIX * pixReadStreamPnm ( FILE *fp );
+LEPT_DLL extern l_int32 readHeaderPnm ( const char *filename, PIX **ppix, l_int32 *pwidth, l_int32 *pheight, l_int32 *pdepth, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp );
+LEPT_DLL extern l_int32 freadHeaderPnm ( FILE *fp, PIX **ppix, l_int32 *pwidth, l_int32 *pheight, l_int32 *pdepth, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp );
+LEPT_DLL extern l_int32 pixWriteStreamPnm ( FILE *fp, PIX *pix );
+LEPT_DLL extern l_int32 pixWriteStreamAsciiPnm ( FILE *fp, PIX *pix );
+LEPT_DLL extern PIX * pixReadMemPnm ( const l_uint8 *cdata, size_t size );
+LEPT_DLL extern l_int32 sreadHeaderPnm ( const l_uint8 *cdata, size_t size, l_int32 *pwidth, l_int32 *pheight, l_int32 *pdepth, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp );
+LEPT_DLL extern l_int32 pixWriteMemPnm ( l_uint8 **pdata, size_t *psize, PIX *pix );
+LEPT_DLL extern PIX * pixProjectiveSampledPta ( PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor );
+LEPT_DLL extern PIX * pixProjectiveSampled ( PIX *pixs, l_float32 *vc, l_int32 incolor );
+LEPT_DLL extern PIX * pixProjectivePta ( PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor );
+LEPT_DLL extern PIX * pixProjective ( PIX *pixs, l_float32 *vc, l_int32 incolor );
+LEPT_DLL extern PIX * pixProjectivePtaColor ( PIX *pixs, PTA *ptad, PTA *ptas, l_uint32 colorval );
+LEPT_DLL extern PIX * pixProjectiveColor ( PIX *pixs, l_float32 *vc, l_uint32 colorval );
+LEPT_DLL extern PIX * pixProjectivePtaGray ( PIX *pixs, PTA *ptad, PTA *ptas, l_uint8 grayval );
+LEPT_DLL extern PIX * pixProjectiveGray ( PIX *pixs, l_float32 *vc, l_uint8 grayval );
+LEPT_DLL extern PIX * pixProjectivePtaWithAlpha ( PIX *pixs, PTA *ptad, PTA *ptas, PIX *pixg, l_float32 fract, l_int32 border );
+LEPT_DLL extern PIX * pixProjectivePtaGammaXform ( PIX *pixs, l_float32 gamma, PTA *ptad, PTA *ptas, l_float32 fract, l_int32 border );
+LEPT_DLL extern l_int32 getProjectiveXformCoeffs ( PTA *ptas, PTA *ptad, l_float32 **pvc );
+LEPT_DLL extern l_int32 projectiveXformSampledPt ( l_float32 *vc, l_int32 x, l_int32 y, l_int32 *pxp, l_int32 *pyp );
+LEPT_DLL extern l_int32 projectiveXformPt ( l_float32 *vc, l_int32 x, l_int32 y, l_float32 *pxp, l_float32 *pyp );
+LEPT_DLL extern l_int32 convertFilesToPS ( const char *dirin, const char *substr, l_int32 res, const char *fileout );
+LEPT_DLL extern l_int32 sarrayConvertFilesToPS ( SARRAY *sa, l_int32 res, const char *fileout );
+LEPT_DLL extern l_int32 convertFilesFittedToPS ( const char *dirin, const char *substr, l_float32 xpts, l_float32 ypts, const char *fileout );
+LEPT_DLL extern l_int32 sarrayConvertFilesFittedToPS ( SARRAY *sa, l_float32 xpts, l_float32 ypts, const char *fileout );
+LEPT_DLL extern l_int32 writeImageCompressedToPSFile ( const char *filein, const char *fileout, l_int32 res, l_int32 *pfirstfile, l_int32 *pindex );
+LEPT_DLL extern l_int32 convertSegmentedPagesToPS ( const char *pagedir, const char *pagestr, const char *maskdir, const char *maskstr, l_int32 numpre, l_int32 numpost, l_int32 maxnum, l_float32 textscale, l_float32 imagescale, l_int32 threshold, const char *fileout );
+LEPT_DLL extern l_int32 pixWriteSegmentedPageToPS ( PIX *pixs, PIX *pixm, l_float32 textscale, l_float32 imagescale, l_int32 threshold, l_int32 pageno, const char *fileout );
+LEPT_DLL extern l_int32 pixWriteMixedToPS ( PIX *pixb, PIX *pixc, l_float32 scale, l_int32 pageno, const char *fileout );
+LEPT_DLL extern l_int32 convertToPSEmbed ( const char *filein, const char *fileout, l_int32 level );
+LEPT_DLL extern l_int32 pixaWriteCompressedToPS ( PIXA *pixa, const char *fileout, l_int32 res, l_int32 level );
+LEPT_DLL extern l_int32 pixWritePSEmbed ( const char *filein, const char *fileout );
+LEPT_DLL extern l_int32 pixWriteStreamPS ( FILE *fp, PIX *pix, BOX *box, l_int32 res, l_float32 scale );
+LEPT_DLL extern char * pixWriteStringPS ( PIX *pixs, BOX *box, l_int32 res, l_float32 scale );
+LEPT_DLL extern char * generateUncompressedPS ( char *hexdata, l_int32 w, l_int32 h, l_int32 d, l_int32 psbpl, l_int32 bps, l_float32 xpt, l_float32 ypt, l_float32 wpt, l_float32 hpt, l_int32 boxflag );
+LEPT_DLL extern void getScaledParametersPS ( BOX *box, l_int32 wpix, l_int32 hpix, l_int32 res, l_float32 scale, l_float32 *pxpt, l_float32 *pypt, l_float32 *pwpt, l_float32 *phpt );
+LEPT_DLL extern void convertByteToHexAscii ( l_uint8 byteval, char *pnib1, char *pnib2 );
+LEPT_DLL extern l_int32 convertJpegToPSEmbed ( const char *filein, const char *fileout );
+LEPT_DLL extern l_int32 convertJpegToPS ( const char *filein, const char *fileout, const char *operation, l_int32 x, l_int32 y, l_int32 res, l_float32 scale, l_int32 pageno, l_int32 endpage );
+LEPT_DLL extern l_int32 convertJpegToPSString ( const char *filein, char **poutstr, l_int32 *pnbytes, l_int32 x, l_int32 y, l_int32 res, l_float32 scale, l_int32 pageno, l_int32 endpage );
+LEPT_DLL extern char * generateJpegPS ( const char *filein, L_COMPRESSED_DATA *cid, l_float32 xpt, l_float32 ypt, l_float32 wpt, l_float32 hpt, l_int32 pageno, l_int32 endpage );
+LEPT_DLL extern L_COMPRESSED_DATA * pixGenerateJpegData ( PIX *pixs, l_int32 ascii85flag, l_int32 quality );
+LEPT_DLL extern L_COMPRESSED_DATA * l_generateJpegData ( const char *fname, l_int32 ascii85flag );
+LEPT_DLL extern void compressed_dataDestroy ( L_COMPRESSED_DATA **pcid );
+LEPT_DLL extern l_int32 convertG4ToPSEmbed ( const char *filein, const char *fileout );
+LEPT_DLL extern l_int32 convertG4ToPS ( const char *filein, const char *fileout, const char *operation, l_int32 x, l_int32 y, l_int32 res, l_float32 scale, l_int32 pageno, l_int32 maskflag, l_int32 endpage );
+LEPT_DLL extern l_int32 convertG4ToPSString ( const char *filein, char **poutstr, l_int32 *pnbytes, l_int32 x, l_int32 y, l_int32 res, l_float32 scale, l_int32 pageno, l_int32 maskflag, l_int32 endpage );
+LEPT_DLL extern char * generateG4PS ( const char *filein, L_COMPRESSED_DATA *cid, l_float32 xpt, l_float32 ypt, l_float32 wpt, l_float32 hpt, l_int32 maskflag, l_int32 pageno, l_int32 endpage );
+LEPT_DLL extern L_COMPRESSED_DATA * pixGenerateG4Data ( PIX *pixs, l_int32 ascii85flag );
+LEPT_DLL extern L_COMPRESSED_DATA * l_generateG4Data ( const char *fname, l_int32 ascii85flag );
+LEPT_DLL extern l_int32 convertTiffMultipageToPS ( const char *filein, const char *fileout, const char *tempfile, l_float32 fillfract );
+LEPT_DLL extern l_int32 convertFlateToPSEmbed ( const char *filein, const char *fileout );
+LEPT_DLL extern l_int32 convertFlateToPS ( const char *filein, const char *fileout, const char *operation, l_int32 x, l_int32 y, l_int32 res, l_float32 scale, l_int32 pageno, l_int32 endpage );
+LEPT_DLL extern l_int32 convertFlateToPSString ( const char *filein, char **poutstr, l_int32 *pnbytes, l_int32 x, l_int32 y, l_int32 res, l_float32 scale, l_int32 pageno, l_int32 endpage );
+LEPT_DLL extern char * generateFlatePS ( const char *filein, L_COMPRESSED_DATA *cid, l_float32 xpt, l_float32 ypt, l_float32 wpt, l_float32 hpt, l_int32 pageno, l_int32 endpage );
+LEPT_DLL extern L_COMPRESSED_DATA * l_generateFlateData ( const char *fname, l_int32 ascii85flag );
+LEPT_DLL extern L_COMPRESSED_DATA * pixGenerateFlateData ( PIX *pixs, l_int32 ascii85flag );
+LEPT_DLL extern l_int32 pixWriteMemPS ( l_uint8 **pdata, size_t *psize, PIX *pix, BOX *box, l_int32 res, l_float32 scale );
+LEPT_DLL extern l_int32 getResLetterPage ( l_int32 w, l_int32 h, l_float32 fillfract );
+LEPT_DLL extern l_int32 getResA4Page ( l_int32 w, l_int32 h, l_float32 fillfract );
+LEPT_DLL extern char * encodeAscii85 ( l_uint8 *inarray, l_int32 insize, l_int32 *poutsize );
+LEPT_DLL extern l_uint8 * decodeAscii85 ( char *ina, l_int32 insize, l_int32 *poutsize );
+LEPT_DLL extern void l_psWriteBoundingBox ( l_int32 flag );
+LEPT_DLL extern PTA * ptaCreate ( l_int32 n );
+LEPT_DLL extern PTA * ptaCreateFromNuma ( NUMA *nax, NUMA *nay );
+LEPT_DLL extern void ptaDestroy ( PTA **ppta );
+LEPT_DLL extern PTA * ptaCopy ( PTA *pta );
+LEPT_DLL extern PTA * ptaCopyRange ( PTA *ptas, l_int32 istart, l_int32 iend );
+LEPT_DLL extern PTA * ptaClone ( PTA *pta );
+LEPT_DLL extern l_int32 ptaEmpty ( PTA *pta );
+LEPT_DLL extern l_int32 ptaAddPt ( PTA *pta, l_float32 x, l_float32 y );
+LEPT_DLL extern l_int32 ptaExtendArrays ( PTA *pta );
+LEPT_DLL extern l_int32 ptaGetRefcount ( PTA *pta );
+LEPT_DLL extern l_int32 ptaChangeRefcount ( PTA *pta, l_int32 delta );
+LEPT_DLL extern l_int32 ptaGetCount ( PTA *pta );
+LEPT_DLL extern l_int32 ptaGetPt ( PTA *pta, l_int32 index, l_float32 *px, l_float32 *py );
+LEPT_DLL extern l_int32 ptaGetIPt ( PTA *pta, l_int32 index, l_int32 *px, l_int32 *py );
+LEPT_DLL extern l_int32 ptaSetPt ( PTA *pta, l_int32 index, l_float32 x, l_float32 y );
+LEPT_DLL extern l_int32 ptaGetArrays ( PTA *pta, NUMA **pnax, NUMA **pnay );
+LEPT_DLL extern PTA * ptaRead ( const char *filename );
+LEPT_DLL extern PTA * ptaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 ptaWrite ( const char *filename, PTA *pta, l_int32 type );
+LEPT_DLL extern l_int32 ptaWriteStream ( FILE *fp, PTA *pta, l_int32 type );
+LEPT_DLL extern PTAA * ptaaCreate ( l_int32 n );
+LEPT_DLL extern void ptaaDestroy ( PTAA **pptaa );
+LEPT_DLL extern l_int32 ptaaAddPta ( PTAA *ptaa, PTA *pta, l_int32 copyflag );
+LEPT_DLL extern l_int32 ptaaExtendArray ( PTAA *ptaa );
+LEPT_DLL extern l_int32 ptaaGetCount ( PTAA *ptaa );
+LEPT_DLL extern PTA * ptaaGetPta ( PTAA *ptaa, l_int32 index, l_int32 accessflag );
+LEPT_DLL extern l_int32 ptaaGetPt ( PTAA *ptaa, l_int32 ipta, l_int32 jpt, l_float32 *px, l_float32 *py );
+LEPT_DLL extern PTAA * ptaaRead ( const char *filename );
+LEPT_DLL extern PTAA * ptaaReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 ptaaWrite ( const char *filename, PTAA *ptaa, l_int32 type );
+LEPT_DLL extern l_int32 ptaaWriteStream ( FILE *fp, PTAA *ptaa, l_int32 type );
+LEPT_DLL extern PTA * ptaSubsample ( PTA *ptas, l_int32 subfactor );
+LEPT_DLL extern l_int32 ptaJoin ( PTA *ptad, PTA *ptas, l_int32 istart, l_int32 iend );
+LEPT_DLL extern PTA * ptaReverse ( PTA *ptas, l_int32 type );
+LEPT_DLL extern PTA * ptaTranspose ( PTA *ptas );
+LEPT_DLL extern PTA * ptaCyclicPerm ( PTA *ptas, l_int32 xs, l_int32 ys );
+LEPT_DLL extern PTA * ptaSort ( PTA *ptas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex );
+LEPT_DLL extern l_int32 ptaGetSortIndex ( PTA *ptas, l_int32 sorttype, l_int32 sortorder, NUMA **pnaindex );
+LEPT_DLL extern PTA * ptaSortByIndex ( PTA *ptas, NUMA *naindex );
+LEPT_DLL extern PTA * ptaRemoveDuplicates ( PTA *ptas, l_uint32 factor );
+LEPT_DLL extern PTAA * ptaaSortByIndex ( PTAA *ptaas, NUMA *naindex );
+LEPT_DLL extern BOX * ptaGetBoundingRegion ( PTA *pta );
+LEPT_DLL extern l_int32 ptaGetRange ( PTA *pta, l_float32 *pminx, l_float32 *pmaxx, l_float32 *pminy, l_float32 *pmaxy );
+LEPT_DLL extern PTA * ptaGetInsideBox ( PTA *ptas, BOX *box );
+LEPT_DLL extern PTA * pixFindCornerPixels ( PIX *pixs );
+LEPT_DLL extern l_int32 ptaContainsPt ( PTA *pta, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 ptaTestIntersection ( PTA *pta1, PTA *pta2 );
+LEPT_DLL extern PTA * ptaTransform ( PTA *ptas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern l_int32 ptaGetLinearLSF ( PTA *pta, l_float32 *pa, l_float32 *pb, NUMA **pnafit );
+LEPT_DLL extern l_int32 ptaGetQuadraticLSF ( PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, NUMA **pnafit );
+LEPT_DLL extern l_int32 ptaGetCubicLSF ( PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pd, NUMA **pnafit );
+LEPT_DLL extern l_int32 ptaGetQuarticLSF ( PTA *pta, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pd, l_float32 *pe, NUMA **pnafit );
+LEPT_DLL extern l_int32 ptaNoisyLinearLSF ( PTA *pta, l_float32 factor, PTA **pptad, l_float32 *pa, l_float32 *pb, l_float32 *pmederr, NUMA **pnafit );
+LEPT_DLL extern l_int32 ptaNoisyQuadraticLSF ( PTA *pta, l_float32 factor, PTA **pptad, l_float32 *pa, l_float32 *pb, l_float32 *pc, l_float32 *pmederr, NUMA **pnafit );
+LEPT_DLL extern l_int32 applyLinearFit ( l_float32 a, l_float32 b, l_float32 x, l_float32 *py );
+LEPT_DLL extern l_int32 applyQuadraticFit ( l_float32 a, l_float32 b, l_float32 c, l_float32 x, l_float32 *py );
+LEPT_DLL extern l_int32 applyCubicFit ( l_float32 a, l_float32 b, l_float32 c, l_float32 d, l_float32 x, l_float32 *py );
+LEPT_DLL extern l_int32 applyQuarticFit ( l_float32 a, l_float32 b, l_float32 c, l_float32 d, l_float32 e, l_float32 x, l_float32 *py );
+LEPT_DLL extern l_int32 pixPlotAlongPta ( PIX *pixs, PTA *pta, l_int32 outformat, const char *title );
+LEPT_DLL extern PTA * ptaGetPixelsFromPix ( PIX *pixs, BOX *box );
+LEPT_DLL extern PIX * pixGenerateFromPta ( PTA *pta, l_int32 w, l_int32 h );
+LEPT_DLL extern PTA * ptaGetBoundaryPixels ( PIX *pixs, l_int32 type );
+LEPT_DLL extern PTAA * ptaaGetBoundaryPixels ( PIX *pixs, l_int32 type, l_int32 connectivity, BOXA **pboxa, PIXA **ppixa );
+LEPT_DLL extern PIX * pixDisplayPta ( PIX *pixd, PIX *pixs, PTA *pta );
+LEPT_DLL extern PIX * pixDisplayPtaaPattern ( PIX *pixd, PIX *pixs, PTAA *ptaa, PIX *pixp, l_int32 cx, l_int32 cy );
+LEPT_DLL extern PIX * pixDisplayPtaPattern ( PIX *pixd, PIX *pixs, PTA *pta, PIX *pixp, l_int32 cx, l_int32 cy, l_uint32 color );
+LEPT_DLL extern PTA * ptaReplicatePattern ( PTA *ptas, PIX *pixp, l_int32 cx, l_int32 cy, l_int32 w, l_int32 h );
+LEPT_DLL extern PIX * pixDisplayPtaa ( PIX *pixs, PTAA *ptaa );
+LEPT_DLL extern L_PTRA * ptraCreate ( l_int32 n );
+LEPT_DLL extern void ptraDestroy ( L_PTRA **ppa, l_int32 freeflag, l_int32 warnflag );
+LEPT_DLL extern l_int32 ptraAdd ( L_PTRA *pa, void *item );
+LEPT_DLL extern l_int32 ptraExtendArray ( L_PTRA *pa );
+LEPT_DLL extern l_int32 ptraInsert ( L_PTRA *pa, l_int32 index, void *item, l_int32 shiftflag );
+LEPT_DLL extern void * ptraGetHandle ( L_PTRA *pa, l_int32 index );
+LEPT_DLL extern void * ptraRemove ( L_PTRA *pa, l_int32 index, l_int32 flag );
+LEPT_DLL extern void * ptraRemoveLast ( L_PTRA *pa );
+LEPT_DLL extern void * ptraReplace ( L_PTRA *pa, l_int32 index, void *item, l_int32 freeflag );
+LEPT_DLL extern l_int32 ptraSwap ( L_PTRA *pa, l_int32 index1, l_int32 index2 );
+LEPT_DLL extern l_int32 ptraCompactArray ( L_PTRA *pa );
+LEPT_DLL extern l_int32 ptraReverse ( L_PTRA *pa );
+LEPT_DLL extern l_int32 ptraJoin ( L_PTRA *pa1, L_PTRA *pa2 );
+LEPT_DLL extern l_int32 ptraGetMaxIndex ( L_PTRA *pa, l_int32 *pmaxindex );
+LEPT_DLL extern l_int32 ptraGetActualCount ( L_PTRA *pa, l_int32 *pcount );
+LEPT_DLL extern void * ptraGetPtrToItem ( L_PTRA *pa, l_int32 index );
+LEPT_DLL extern L_PTRAA * ptraaCreate ( l_int32 n );
+LEPT_DLL extern void ptraaDestroy ( L_PTRAA **ppaa, l_int32 freeflag, l_int32 warnflag );
+LEPT_DLL extern l_int32 ptraaGetSize ( L_PTRAA *paa, l_int32 *psize );
+LEPT_DLL extern l_int32 ptraaInsertPtra ( L_PTRAA *paa, l_int32 index, L_PTRA *pa );
+LEPT_DLL extern L_PTRA * ptraaGetPtra ( L_PTRAA *paa, l_int32 index, l_int32 accessflag );
+LEPT_DLL extern L_PTRA * ptraaFlattenToPtra ( L_PTRAA *paa );
+LEPT_DLL extern l_int32 pixQuadtreeMean ( PIX *pixs, l_int32 nlevels, PIX *pix_ma, FPIXA **pfpixa );
+LEPT_DLL extern l_int32 pixQuadtreeVariance ( PIX *pixs, l_int32 nlevels, PIX *pix_ma, DPIX *dpix_msa, FPIXA **pfpixa_v, FPIXA **pfpixa_rv );
+LEPT_DLL extern l_int32 pixMeanInRectangle ( PIX *pixs, BOX *box, PIX *pixma, l_float32 *pval );
+LEPT_DLL extern l_int32 pixVarianceInRectangle ( PIX *pixs, BOX *box, PIX *pix_ma, DPIX *dpix_msa, l_float32 *pvar, l_float32 *prvar );
+LEPT_DLL extern BOXAA * boxaaQuadtreeRegions ( l_int32 w, l_int32 h, l_int32 nlevels );
+LEPT_DLL extern l_int32 quadtreeGetParent ( FPIXA *fpixa, l_int32 level, l_int32 x, l_int32 y, l_float32 *pval );
+LEPT_DLL extern l_int32 quadtreeGetChildren ( FPIXA *fpixa, l_int32 level, l_int32 x, l_int32 y, l_float32 *pval00, l_float32 *pval10, l_float32 *pval01, l_float32 *pval11 );
+LEPT_DLL extern l_int32 quadtreeMaxLevels ( l_int32 w, l_int32 h );
+LEPT_DLL extern PIX * fpixaDisplayQuadtree ( FPIXA *fpixa, l_int32 factor );
+LEPT_DLL extern L_QUEUE * lqueueCreate ( l_int32 nalloc );
+LEPT_DLL extern void lqueueDestroy ( L_QUEUE **plq, l_int32 freeflag );
+LEPT_DLL extern l_int32 lqueueAdd ( L_QUEUE *lq, void *item );
+LEPT_DLL extern l_int32 lqueueExtendArray ( L_QUEUE *lq );
+LEPT_DLL extern void * lqueueRemove ( L_QUEUE *lq );
+LEPT_DLL extern l_int32 lqueueGetCount ( L_QUEUE *lq );
+LEPT_DLL extern l_int32 lqueuePrint ( FILE *fp, L_QUEUE *lq );
+LEPT_DLL extern PIX * pixRankFilter ( PIX *pixs, l_int32 wf, l_int32 hf, l_float32 rank );
+LEPT_DLL extern PIX * pixRankFilterRGB ( PIX *pixs, l_int32 wf, l_int32 hf, l_float32 rank );
+LEPT_DLL extern PIX * pixRankFilterGray ( PIX *pixs, l_int32 wf, l_int32 hf, l_float32 rank );
+LEPT_DLL extern PIX * pixMedianFilter ( PIX *pixs, l_int32 wf, l_int32 hf );
+LEPT_DLL extern PIX * pixRankFilterWithScaling ( PIX *pixs, l_int32 wf, l_int32 hf, l_float32 rank, l_float32 scalefactor );
+LEPT_DLL extern SARRAY * pixProcessBarcodes ( PIX *pixs, l_int32 format, l_int32 method, SARRAY **psaw, l_int32 debugflag );
+LEPT_DLL extern PIXA * pixExtractBarcodes ( PIX *pixs, l_int32 debugflag );
+LEPT_DLL extern SARRAY * pixReadBarcodes ( PIXA *pixa, l_int32 format, l_int32 method, SARRAY **psaw, l_int32 debugflag );
+LEPT_DLL extern NUMA * pixReadBarcodeWidths ( PIX *pixs, l_int32 method, l_int32 debugflag );
+LEPT_DLL extern BOXA * pixLocateBarcodes ( PIX *pixs, l_int32 thresh, PIX **ppixb, PIX **ppixm );
+LEPT_DLL extern PIX * pixDeskewBarcode ( PIX *pixs, PIX *pixb, BOX *box, l_int32 margin, l_int32 threshold, l_float32 *pangle, l_float32 *pconf );
+LEPT_DLL extern NUMA * pixExtractBarcodeWidths1 ( PIX *pixs, l_float32 thresh, l_float32 binfract, NUMA **pnaehist, NUMA **pnaohist, l_int32 debugflag );
+LEPT_DLL extern NUMA * pixExtractBarcodeWidths2 ( PIX *pixs, l_float32 thresh, l_float32 *pwidth, NUMA **pnac, l_int32 debugflag );
+LEPT_DLL extern NUMA * pixExtractBarcodeCrossings ( PIX *pixs, l_float32 thresh, l_int32 debugflag );
+LEPT_DLL extern NUMA * numaQuantizeCrossingsByWidth ( NUMA *nas, l_float32 binfract, NUMA **pnaehist, NUMA **pnaohist, l_int32 debugflag );
+LEPT_DLL extern NUMA * numaQuantizeCrossingsByWindow ( NUMA *nas, l_float32 ratio, l_float32 *pwidth, l_float32 *pfirstloc, NUMA **pnac, l_int32 debugflag );
+LEPT_DLL extern PIXA * pixaReadFiles ( const char *dirname, const char *substr );
+LEPT_DLL extern PIXA * pixaReadFilesSA ( SARRAY *sa );
+LEPT_DLL extern PIX * pixRead ( const char *filename );
+LEPT_DLL extern PIX * pixReadWithHint ( const char *filename, l_int32 hint );
+LEPT_DLL extern PIX * pixReadIndexed ( SARRAY *sa, l_int32 index );
+LEPT_DLL extern PIX * pixReadStream ( FILE *fp, l_int32 hint );
+LEPT_DLL extern l_int32 pixReadHeader ( const char *filename, l_int32 *pformat, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 findFileFormat ( const char *filename, l_int32 *pformat );
+LEPT_DLL extern l_int32 findFileFormatStream ( FILE *fp, l_int32 *pformat );
+LEPT_DLL extern l_int32 findFileFormatBuffer ( const l_uint8 *buf, l_int32 *pformat );
+LEPT_DLL extern l_int32 fileFormatIsTiff ( FILE *fp );
+LEPT_DLL extern PIX * pixReadMem ( const l_uint8 *data, size_t size );
+LEPT_DLL extern l_int32 pixReadHeaderMem ( const l_uint8 *data, size_t size, l_int32 *pformat, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 ioFormatTest ( const char *filename );
+LEPT_DLL extern l_int32 regTestSetup ( l_int32 argc, char **argv, L_REGPARAMS **prp );
+LEPT_DLL extern l_int32 regTestCleanup ( L_REGPARAMS *rp );
+LEPT_DLL extern l_int32 regTestCompareValues ( L_REGPARAMS *rp, l_float32 val1, l_float32 val2, l_float32 delta );
+LEPT_DLL extern l_int32 regTestComparePix ( L_REGPARAMS *rp, PIX *pix1, PIX *pix2 );
+LEPT_DLL extern l_int32 regTestCompareSimilarPix ( L_REGPARAMS *rp, PIX *pix1, PIX *pix2, l_int32 mindiff, l_float32 maxfract, l_int32 printstats );
+LEPT_DLL extern l_int32 regTestCheckFile ( L_REGPARAMS *rp, const char *localname );
+LEPT_DLL extern l_int32 regTestCompareFiles ( L_REGPARAMS *rp, l_int32 index1, l_int32 index2 );
+LEPT_DLL extern l_int32 regTestWritePixAndCheck ( L_REGPARAMS *rp, PIX *pix, l_int32 format );
+LEPT_DLL extern l_int32 pixRasterop ( PIX *pixd, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, PIX *pixs, l_int32 sx, l_int32 sy );
+LEPT_DLL extern l_int32 pixRasteropVip ( PIX *pixd, l_int32 bx, l_int32 bw, l_int32 vshift, l_int32 incolor );
+LEPT_DLL extern l_int32 pixRasteropHip ( PIX *pixd, l_int32 by, l_int32 bh, l_int32 hshift, l_int32 incolor );
+LEPT_DLL extern PIX * pixTranslate ( PIX *pixd, PIX *pixs, l_int32 hshift, l_int32 vshift, l_int32 incolor );
+LEPT_DLL extern l_int32 pixRasteropIP ( PIX *pixd, l_int32 hshift, l_int32 vshift, l_int32 incolor );
+LEPT_DLL extern l_int32 pixRasteropFullImage ( PIX *pixd, PIX *pixs, l_int32 op );
+LEPT_DLL extern void rasteropVipLow ( l_uint32 *data, l_int32 pixw, l_int32 pixh, l_int32 depth, l_int32 wpl, l_int32 x, l_int32 w, l_int32 shift );
+LEPT_DLL extern void rasteropHipLow ( l_uint32 *data, l_int32 pixh, l_int32 depth, l_int32 wpl, l_int32 y, l_int32 h, l_int32 shift );
+LEPT_DLL extern void shiftDataHorizontalLow ( l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 shift );
+LEPT_DLL extern void rasteropUniLow ( l_uint32 *datad, l_int32 dpixw, l_int32 dpixh, l_int32 depth, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op );
+LEPT_DLL extern void rasteropLow ( l_uint32 *datad, l_int32 dpixw, l_int32 dpixh, l_int32 depth, l_int32 dwpl, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, l_uint32 *datas, l_int32 spixw, l_int32 spixh, l_int32 swpl, l_int32 sx, l_int32 sy );
+LEPT_DLL extern PIX * pixRotate ( PIX *pixs, l_float32 angle, l_int32 type, l_int32 incolor, l_int32 width, l_int32 height );
+LEPT_DLL extern PIX * pixEmbedForRotation ( PIX *pixs, l_float32 angle, l_int32 incolor, l_int32 width, l_int32 height );
+LEPT_DLL extern PIX * pixRotateBySampling ( PIX *pixs, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRotateBinaryNice ( PIX *pixs, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRotateWithAlpha ( PIX *pixs, l_float32 angle, PIX *pixg, l_float32 fract );
+LEPT_DLL extern PIX * pixRotateGammaXform ( PIX *pixs, l_float32 gamma, l_float32 angle, l_float32 fract );
+LEPT_DLL extern PIX * pixRotateAM ( PIX *pixs, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRotateAMColor ( PIX *pixs, l_float32 angle, l_uint32 colorval );
+LEPT_DLL extern PIX * pixRotateAMGray ( PIX *pixs, l_float32 angle, l_uint8 grayval );
+LEPT_DLL extern PIX * pixRotateAMCorner ( PIX *pixs, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRotateAMColorCorner ( PIX *pixs, l_float32 angle, l_uint32 fillval );
+LEPT_DLL extern PIX * pixRotateAMGrayCorner ( PIX *pixs, l_float32 angle, l_uint8 grayval );
+LEPT_DLL extern PIX * pixRotateAMColorFast ( PIX *pixs, l_float32 angle, l_uint32 colorval );
+LEPT_DLL extern void rotateAMColorLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_float32 angle, l_uint32 colorval );
+LEPT_DLL extern void rotateAMGrayLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_float32 angle, l_uint8 grayval );
+LEPT_DLL extern void rotateAMColorCornerLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_float32 angle, l_uint32 colorval );
+LEPT_DLL extern void rotateAMGrayCornerLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_float32 angle, l_uint8 grayval );
+LEPT_DLL extern void rotateAMColorFastLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_float32 angle, l_uint32 colorval );
+LEPT_DLL extern PIX * pixRotateOrth ( PIX *pixs, l_int32 quads );
+LEPT_DLL extern PIX * pixRotate180 ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern PIX * pixRotate90 ( PIX *pixs, l_int32 direction );
+LEPT_DLL extern PIX * pixFlipLR ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern PIX * pixFlipTB ( PIX *pixd, PIX *pixs );
+LEPT_DLL extern void rotate90Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 d, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 direction );
+LEPT_DLL extern void flipLRLow ( l_uint32 *data, l_int32 w, l_int32 h, l_int32 d, l_int32 wpl, l_uint8 *tab, l_uint32 *buffer );
+LEPT_DLL extern void flipTBLow ( l_uint32 *data, l_int32 h, l_int32 wpl, l_uint32 *buffer );
+LEPT_DLL extern l_uint8 * makeReverseByteTab1 ( void );
+LEPT_DLL extern l_uint8 * makeReverseByteTab2 ( void );
+LEPT_DLL extern l_uint8 * makeReverseByteTab4 ( void );
+LEPT_DLL extern PIX * pixRotateShear ( PIX *pixs, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRotate2Shear ( PIX *pixs, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRotate3Shear ( PIX *pixs, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern l_int32 pixRotateShearIP ( PIX *pixs, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRotateShearCenter ( PIX *pixs, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern l_int32 pixRotateShearCenterIP ( PIX *pixs, l_float32 angle, l_int32 incolor );
+LEPT_DLL extern PIX * pixRunlengthTransform ( PIX *pixs, l_int32 color, l_int32 direction, l_int32 depth );
+LEPT_DLL extern l_int32 pixFindHorizontalRuns ( PIX *pix, l_int32 y, l_int32 *xstart, l_int32 *xend, l_int32 *pn );
+LEPT_DLL extern l_int32 pixFindVerticalRuns ( PIX *pix, l_int32 x, l_int32 *ystart, l_int32 *yend, l_int32 *pn );
+LEPT_DLL extern l_int32 runlengthMembershipOnLine ( l_int32 *buffer, l_int32 size, l_int32 depth, l_int32 *start, l_int32 *end, l_int32 n );
+LEPT_DLL extern l_int32 * makeMSBitLocTab ( l_int32 bitval );
+LEPT_DLL extern SARRAY * sarrayCreate ( l_int32 n );
+LEPT_DLL extern SARRAY * sarrayCreateInitialized ( l_int32 n, char *initstr );
+LEPT_DLL extern SARRAY * sarrayCreateWordsFromString ( const char *string );
+LEPT_DLL extern SARRAY * sarrayCreateLinesFromString ( char *string, l_int32 blankflag );
+LEPT_DLL extern void sarrayDestroy ( SARRAY **psa );
+LEPT_DLL extern SARRAY * sarrayCopy ( SARRAY *sa );
+LEPT_DLL extern SARRAY * sarrayClone ( SARRAY *sa );
+LEPT_DLL extern l_int32 sarrayAddString ( SARRAY *sa, char *string, l_int32 copyflag );
+LEPT_DLL extern l_int32 sarrayExtendArray ( SARRAY *sa );
+LEPT_DLL extern char * sarrayRemoveString ( SARRAY *sa, l_int32 index );
+LEPT_DLL extern l_int32 sarrayReplaceString ( SARRAY *sa, l_int32 index, char *newstr, l_int32 copyflag );
+LEPT_DLL extern l_int32 sarrayClear ( SARRAY *sa );
+LEPT_DLL extern l_int32 sarrayGetCount ( SARRAY *sa );
+LEPT_DLL extern char ** sarrayGetArray ( SARRAY *sa, l_int32 *pnalloc, l_int32 *pn );
+LEPT_DLL extern char * sarrayGetString ( SARRAY *sa, l_int32 index, l_int32 copyflag );
+LEPT_DLL extern l_int32 sarrayGetRefcount ( SARRAY *sa );
+LEPT_DLL extern l_int32 sarrayChangeRefcount ( SARRAY *sa, l_int32 delta );
+LEPT_DLL extern char * sarrayToString ( SARRAY *sa, l_int32 addnlflag );
+LEPT_DLL extern char * sarrayToStringRange ( SARRAY *sa, l_int32 first, l_int32 nstrings, l_int32 addnlflag );
+LEPT_DLL extern l_int32 sarrayConcatenate ( SARRAY *sa1, SARRAY *sa2 );
+LEPT_DLL extern l_int32 sarrayAppendRange ( SARRAY *sa1, SARRAY *sa2, l_int32 start, l_int32 end );
+LEPT_DLL extern l_int32 sarrayPadToSameSize ( SARRAY *sa1, SARRAY *sa2, char *padstring );
+LEPT_DLL extern SARRAY * sarrayConvertWordsToLines ( SARRAY *sa, l_int32 linesize );
+LEPT_DLL extern l_int32 sarraySplitString ( SARRAY *sa, const char *str, const char *separators );
+LEPT_DLL extern SARRAY * sarraySelectBySubstring ( SARRAY *sain, const char *substr );
+LEPT_DLL extern SARRAY * sarraySelectByRange ( SARRAY *sain, l_int32 first, l_int32 last );
+LEPT_DLL extern l_int32 sarrayParseRange ( SARRAY *sa, l_int32 start, l_int32 *pactualstart, l_int32 *pend, l_int32 *pnewstart, const char *substr, l_int32 loc );
+LEPT_DLL extern SARRAY * sarraySort ( SARRAY *saout, SARRAY *sain, l_int32 sortorder );
+LEPT_DLL extern l_int32 stringCompareLexical ( const char *str1, const char *str2 );
+LEPT_DLL extern SARRAY * sarrayRead ( const char *filename );
+LEPT_DLL extern SARRAY * sarrayReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 sarrayWrite ( const char *filename, SARRAY *sa );
+LEPT_DLL extern l_int32 sarrayWriteStream ( FILE *fp, SARRAY *sa );
+LEPT_DLL extern l_int32 sarrayAppend ( const char *filename, SARRAY *sa );
+LEPT_DLL extern SARRAY * getNumberedPathnamesInDirectory ( const char *dirname, const char *substr, l_int32 numpre, l_int32 numpost, l_int32 maxnum );
+LEPT_DLL extern SARRAY * getSortedPathnamesInDirectory ( const char *dirname, const char *substr, l_int32 firstpage, l_int32 npages );
+LEPT_DLL extern SARRAY * convertSortedToNumberedPathnames ( SARRAY *sa, l_int32 numpre, l_int32 numpost, l_int32 maxnum );
+LEPT_DLL extern SARRAY * getFilenamesInDirectory ( const char *dirname );
+LEPT_DLL extern PIX * pixScale ( PIX *pixs, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleToSize ( PIX *pixs, l_int32 wd, l_int32 hd );
+LEPT_DLL extern PIX * pixScaleGeneral ( PIX *pixs, l_float32 scalex, l_float32 scaley, l_float32 sharpfract, l_int32 sharpwidth );
+LEPT_DLL extern PIX * pixScaleLI ( PIX *pixs, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleColorLI ( PIX *pixs, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleColor2xLI ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleColor4xLI ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleGrayLI ( PIX *pixs, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleGray2xLI ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleGray4xLI ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleBySampling ( PIX *pixs, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleByIntSubsampling ( PIX *pixs, l_int32 factor );
+LEPT_DLL extern PIX * pixScaleRGBToGrayFast ( PIX *pixs, l_int32 factor, l_int32 color );
+LEPT_DLL extern PIX * pixScaleRGBToBinaryFast ( PIX *pixs, l_int32 factor, l_int32 thresh );
+LEPT_DLL extern PIX * pixScaleGrayToBinaryFast ( PIX *pixs, l_int32 factor, l_int32 thresh );
+LEPT_DLL extern PIX * pixScaleSmooth ( PIX *pix, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleRGBToGray2 ( PIX *pixs, l_float32 rwt, l_float32 gwt, l_float32 bwt );
+LEPT_DLL extern PIX * pixScaleAreaMap ( PIX *pix, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleAreaMap2 ( PIX *pix );
+LEPT_DLL extern PIX * pixScaleBinary ( PIX *pixs, l_float32 scalex, l_float32 scaley );
+LEPT_DLL extern PIX * pixScaleToGray ( PIX *pixs, l_float32 scalefactor );
+LEPT_DLL extern PIX * pixScaleToGrayFast ( PIX *pixs, l_float32 scalefactor );
+LEPT_DLL extern PIX * pixScaleToGray2 ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleToGray3 ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleToGray4 ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleToGray6 ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleToGray8 ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleToGray16 ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleToGrayMipmap ( PIX *pixs, l_float32 scalefactor );
+LEPT_DLL extern PIX * pixScaleMipmap ( PIX *pixs1, PIX *pixs2, l_float32 scale );
+LEPT_DLL extern PIX * pixExpandReplicate ( PIX *pixs, l_int32 factor );
+LEPT_DLL extern PIX * pixScaleGray2xLIThresh ( PIX *pixs, l_int32 thresh );
+LEPT_DLL extern PIX * pixScaleGray2xLIDither ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleGray4xLIThresh ( PIX *pixs, l_int32 thresh );
+LEPT_DLL extern PIX * pixScaleGray4xLIDither ( PIX *pixs );
+LEPT_DLL extern PIX * pixScaleGrayMinMax ( PIX *pixs, l_int32 xfact, l_int32 yfact, l_int32 type );
+LEPT_DLL extern PIX * pixScaleGrayMinMax2 ( PIX *pixs, l_int32 type );
+LEPT_DLL extern PIX * pixScaleGrayRankCascade ( PIX *pixs, l_int32 level1, l_int32 level2, l_int32 level3, l_int32 level4 );
+LEPT_DLL extern PIX * pixScaleGrayRank2 ( PIX *pixs, l_int32 rank );
+LEPT_DLL extern PIX * pixScaleWithAlpha ( PIX *pixs, l_float32 scalex, l_float32 scaley, PIX *pixg, l_float32 fract );
+LEPT_DLL extern PIX * pixScaleGammaXform ( PIX *pixs, l_float32 gamma, l_float32 scalex, l_float32 scaley, l_float32 fract );
+LEPT_DLL extern void scaleColorLILow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleGrayLILow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleColor2xLILow ( l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleColor2xLILineLow ( l_uint32 *lined, l_int32 wpld, l_uint32 *lines, l_int32 ws, l_int32 wpls, l_int32 lastlineflag );
+LEPT_DLL extern void scaleGray2xLILow ( l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleGray2xLILineLow ( l_uint32 *lined, l_int32 wpld, l_uint32 *lines, l_int32 ws, l_int32 wpls, l_int32 lastlineflag );
+LEPT_DLL extern void scaleGray4xLILow ( l_uint32 *datad, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleGray4xLILineLow ( l_uint32 *lined, l_int32 wpld, l_uint32 *lines, l_int32 ws, l_int32 wpls, l_int32 lastlineflag );
+LEPT_DLL extern l_int32 scaleBySamplingLow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 d, l_int32 wpls );
+LEPT_DLL extern l_int32 scaleSmoothLow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 d, l_int32 wpls, l_int32 size );
+LEPT_DLL extern void scaleRGBToGray2Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_float32 rwt, l_float32 gwt, l_float32 bwt );
+LEPT_DLL extern void scaleColorAreaMapLow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleGrayAreaMapLow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleAreaMapLow2 ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 d, l_int32 wpls );
+LEPT_DLL extern l_int32 scaleBinaryLow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 ws, l_int32 hs, l_int32 wpls );
+LEPT_DLL extern void scaleToGray2Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 *sumtab, l_uint8 *valtab );
+LEPT_DLL extern l_uint32 * makeSumTabSG2 ( void );
+LEPT_DLL extern l_uint8 * makeValTabSG2 ( void );
+LEPT_DLL extern void scaleToGray3Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 *sumtab, l_uint8 *valtab );
+LEPT_DLL extern l_uint32 * makeSumTabSG3 ( void );
+LEPT_DLL extern l_uint8 * makeValTabSG3 ( void );
+LEPT_DLL extern void scaleToGray4Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_uint32 *sumtab, l_uint8 *valtab );
+LEPT_DLL extern l_uint32 * makeSumTabSG4 ( void );
+LEPT_DLL extern l_uint8 * makeValTabSG4 ( void );
+LEPT_DLL extern void scaleToGray6Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 *tab8, l_uint8 *valtab );
+LEPT_DLL extern l_uint8 * makeValTabSG6 ( void );
+LEPT_DLL extern void scaleToGray8Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 *tab8, l_uint8 *valtab );
+LEPT_DLL extern l_uint8 * makeValTabSG8 ( void );
+LEPT_DLL extern void scaleToGray16Low ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas, l_int32 wpls, l_int32 *tab8 );
+LEPT_DLL extern l_int32 scaleMipmapLow ( l_uint32 *datad, l_int32 wd, l_int32 hd, l_int32 wpld, l_uint32 *datas1, l_int32 wpls1, l_uint32 *datas2, l_int32 wpls2, l_float32 red );
+LEPT_DLL extern PIX * pixSeedfillBinary ( PIX *pixd, PIX *pixs, PIX *pixm, l_int32 connectivity );
+LEPT_DLL extern PIX * pixSeedfillBinaryRestricted ( PIX *pixd, PIX *pixs, PIX *pixm, l_int32 connectivity, l_int32 xmax, l_int32 ymax );
+LEPT_DLL extern PIX * pixHolesByFilling ( PIX *pixs, l_int32 connectivity );
+LEPT_DLL extern PIX * pixFillClosedBorders ( PIX *pixs, l_int32 connectivity );
+LEPT_DLL extern PIX * pixExtractBorderConnComps ( PIX *pixs, l_int32 connectivity );
+LEPT_DLL extern PIX * pixRemoveBorderConnComps ( PIX *pixs, l_int32 connectivity );
+LEPT_DLL extern PIX * pixFillHolesToBoundingRect ( PIX *pixs, l_int32 minsize, l_float32 maxhfract, l_float32 minfgfract );
+LEPT_DLL extern l_int32 pixSeedfillGray ( PIX *pixs, PIX *pixm, l_int32 connectivity );
+LEPT_DLL extern l_int32 pixSeedfillGrayInv ( PIX *pixs, PIX *pixm, l_int32 connectivity );
+LEPT_DLL extern l_int32 pixSeedfillGraySimple ( PIX *pixs, PIX *pixm, l_int32 connectivity );
+LEPT_DLL extern l_int32 pixSeedfillGrayInvSimple ( PIX *pixs, PIX *pixm, l_int32 connectivity );
+LEPT_DLL extern PIX * pixSeedfillGrayBasin ( PIX *pixb, PIX *pixm, l_int32 delta, l_int32 connectivity );
+LEPT_DLL extern PIX * pixDistanceFunction ( PIX *pixs, l_int32 connectivity, l_int32 outdepth, l_int32 boundcond );
+LEPT_DLL extern PIX * pixSeedspread ( PIX *pixs, l_int32 connectivity );
+LEPT_DLL extern l_int32 pixLocalExtrema ( PIX *pixs, l_int32 maxmin, l_int32 minmax, PIX **ppixmin, PIX **ppixmax );
+LEPT_DLL extern l_int32 pixSelectedLocalExtrema ( PIX *pixs, l_int32 mindist, PIX **ppixmin, PIX **ppixmax );
+LEPT_DLL extern PIX * pixFindEqualValues ( PIX *pixs1, PIX *pixs2 );
+LEPT_DLL extern PTA * pixSelectMinInConnComp ( PIX *pixs, PIX *pixm, NUMA **pnav );
+LEPT_DLL extern PIX * pixRemoveSeededComponents ( PIX *pixd, PIX *pixs, PIX *pixm, l_int32 connectivity, l_int32 bordersize );
+LEPT_DLL extern void seedfillBinaryLow ( l_uint32 *datas, l_int32 hs, l_int32 wpls, l_uint32 *datam, l_int32 hm, l_int32 wplm, l_int32 connectivity );
+LEPT_DLL extern void seedfillGrayLow ( l_uint32 *datas, l_int32 w, l_int32 h, l_int32 wpls, l_uint32 *datam, l_int32 wplm, l_int32 connectivity );
+LEPT_DLL extern void seedfillGrayInvLow ( l_uint32 *datas, l_int32 w, l_int32 h, l_int32 wpls, l_uint32 *datam, l_int32 wplm, l_int32 connectivity );
+LEPT_DLL extern void seedfillGrayLowSimple ( l_uint32 *datas, l_int32 w, l_int32 h, l_int32 wpls, l_uint32 *datam, l_int32 wplm, l_int32 connectivity );
+LEPT_DLL extern void seedfillGrayInvLowSimple ( l_uint32 *datas, l_int32 w, l_int32 h, l_int32 wpls, l_uint32 *datam, l_int32 wplm, l_int32 connectivity );
+LEPT_DLL extern void distanceFunctionLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 d, l_int32 wpld, l_int32 connectivity );
+LEPT_DLL extern void seedspreadLow ( l_uint32 *datad, l_int32 w, l_int32 h, l_int32 wpld, l_uint32 *datat, l_int32 wplt, l_int32 connectivity );
+LEPT_DLL extern SELA * selaCreate ( l_int32 n );
+LEPT_DLL extern void selaDestroy ( SELA **psela );
+LEPT_DLL extern SEL * selCreate ( l_int32 height, l_int32 width, const char *name );
+LEPT_DLL extern void selDestroy ( SEL **psel );
+LEPT_DLL extern SEL * selCopy ( SEL *sel );
+LEPT_DLL extern SEL * selCreateBrick ( l_int32 h, l_int32 w, l_int32 cy, l_int32 cx, l_int32 type );
+LEPT_DLL extern SEL * selCreateComb ( l_int32 factor1, l_int32 factor2, l_int32 direction );
+LEPT_DLL extern l_int32 ** create2dIntArray ( l_int32 sy, l_int32 sx );
+LEPT_DLL extern l_int32 selaAddSel ( SELA *sela, SEL *sel, const char *selname, l_int32 copyflag );
+LEPT_DLL extern l_int32 selaExtendArray ( SELA *sela );
+LEPT_DLL extern l_int32 selaGetCount ( SELA *sela );
+LEPT_DLL extern SEL * selaGetSel ( SELA *sela, l_int32 i );
+LEPT_DLL extern char * selGetName ( SEL *sel );
+LEPT_DLL extern l_int32 selSetName ( SEL *sel, const char *name );
+LEPT_DLL extern l_int32 selaFindSelByName ( SELA *sela, const char *name, l_int32 *pindex, SEL **psel );
+LEPT_DLL extern l_int32 selGetElement ( SEL *sel, l_int32 row, l_int32 col, l_int32 *ptype );
+LEPT_DLL extern l_int32 selSetElement ( SEL *sel, l_int32 row, l_int32 col, l_int32 type );
+LEPT_DLL extern l_int32 selGetParameters ( SEL *sel, l_int32 *psy, l_int32 *psx, l_int32 *pcy, l_int32 *pcx );
+LEPT_DLL extern l_int32 selSetOrigin ( SEL *sel, l_int32 cy, l_int32 cx );
+LEPT_DLL extern l_int32 selGetTypeAtOrigin ( SEL *sel, l_int32 *ptype );
+LEPT_DLL extern char * selaGetBrickName ( SELA *sela, l_int32 hsize, l_int32 vsize );
+LEPT_DLL extern char * selaGetCombName ( SELA *sela, l_int32 size, l_int32 direction );
+LEPT_DLL extern l_int32 getCompositeParameters ( l_int32 size, l_int32 *psize1, l_int32 *psize2, char **pnameh1, char **pnameh2, char **pnamev1, char **pnamev2 );
+LEPT_DLL extern SARRAY * selaGetSelnames ( SELA *sela );
+LEPT_DLL extern l_int32 selFindMaxTranslations ( SEL *sel, l_int32 *pxp, l_int32 *pyp, l_int32 *pxn, l_int32 *pyn );
+LEPT_DLL extern SEL * selRotateOrth ( SEL *sel, l_int32 quads );
+LEPT_DLL extern SELA * selaRead ( const char *fname );
+LEPT_DLL extern SELA * selaReadStream ( FILE *fp );
+LEPT_DLL extern SEL * selRead ( const char *fname );
+LEPT_DLL extern SEL * selReadStream ( FILE *fp );
+LEPT_DLL extern l_int32 selaWrite ( const char *fname, SELA *sela );
+LEPT_DLL extern l_int32 selaWriteStream ( FILE *fp, SELA *sela );
+LEPT_DLL extern l_int32 selWrite ( const char *fname, SEL *sel );
+LEPT_DLL extern l_int32 selWriteStream ( FILE *fp, SEL *sel );
+LEPT_DLL extern SEL * selCreateFromString ( const char *text, l_int32 h, l_int32 w, const char *name );
+LEPT_DLL extern char * selPrintToString ( SEL *sel );
+LEPT_DLL extern SELA * selaCreateFromFile ( const char *filename );
+LEPT_DLL extern SEL * selCreateFromPta ( PTA *pta, l_int32 cy, l_int32 cx, const char *name );
+LEPT_DLL extern SEL * selCreateFromPix ( PIX *pix, l_int32 cy, l_int32 cx, const char *name );
+LEPT_DLL extern SEL * selReadFromColorImage ( const char *pathname );
+LEPT_DLL extern SEL * selCreateFromColorPix ( PIX *pixs, char *selname );
+LEPT_DLL extern PIX * selDisplayInPix ( SEL *sel, l_int32 size, l_int32 gthick );
+LEPT_DLL extern PIX * selaDisplayInPix ( SELA *sela, l_int32 size, l_int32 gthick, l_int32 spacing, l_int32 ncols );
+LEPT_DLL extern SELA * selaAddBasic ( SELA *sela );
+LEPT_DLL extern SELA * selaAddHitMiss ( SELA *sela );
+LEPT_DLL extern SELA * selaAddDwaLinear ( SELA *sela );
+LEPT_DLL extern SELA * selaAddDwaCombs ( SELA *sela );
+LEPT_DLL extern SELA * selaAddCrossJunctions ( SELA *sela, l_float32 hlsize, l_float32 mdist, l_int32 norient, l_int32 debugflag );
+LEPT_DLL extern SELA * selaAddTJunctions ( SELA *sela, l_float32 hlsize, l_float32 mdist, l_int32 norient, l_int32 debugflag );
+LEPT_DLL extern SEL * pixGenerateSelWithRuns ( PIX *pixs, l_int32 nhlines, l_int32 nvlines, l_int32 distance, l_int32 minlength, l_int32 toppix, l_int32 botpix, l_int32 leftpix, l_int32 rightpix, PIX **ppixe );
+LEPT_DLL extern SEL * pixGenerateSelRandom ( PIX *pixs, l_float32 hitfract, l_float32 missfract, l_int32 distance, l_int32 toppix, l_int32 botpix, l_int32 leftpix, l_int32 rightpix, PIX **ppixe );
+LEPT_DLL extern SEL * pixGenerateSelBoundary ( PIX *pixs, l_int32 hitdist, l_int32 missdist, l_int32 hitskip, l_int32 missskip, l_int32 topflag, l_int32 botflag, l_int32 leftflag, l_int32 rightflag, PIX **ppixe );
+LEPT_DLL extern NUMA * pixGetRunCentersOnLine ( PIX *pixs, l_int32 x, l_int32 y, l_int32 minlength );
+LEPT_DLL extern NUMA * pixGetRunsOnLine ( PIX *pixs, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2 );
+LEPT_DLL extern PTA * pixSubsampleBoundaryPixels ( PIX *pixs, l_int32 skip );
+LEPT_DLL extern l_int32 adjacentOnPixelInRaster ( PIX *pixs, l_int32 x, l_int32 y, l_int32 *pxa, l_int32 *pya );
+LEPT_DLL extern PIX * pixDisplayHitMissSel ( PIX *pixs, SEL *sel, l_int32 scalefactor, l_uint32 hitcolor, l_uint32 misscolor );
+LEPT_DLL extern PIX * pixHShear ( PIX *pixd, PIX *pixs, l_int32 liney, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixVShear ( PIX *pixd, PIX *pixs, l_int32 linex, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixHShearCorner ( PIX *pixd, PIX *pixs, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixVShearCorner ( PIX *pixd, PIX *pixs, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixHShearCenter ( PIX *pixd, PIX *pixs, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixVShearCenter ( PIX *pixd, PIX *pixs, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern l_int32 pixHShearIP ( PIX *pixs, l_int32 liney, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern l_int32 pixVShearIP ( PIX *pixs, l_int32 linex, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixHShearLI ( PIX *pixs, l_int32 liney, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixVShearLI ( PIX *pixs, l_int32 linex, l_float32 radang, l_int32 incolor );
+LEPT_DLL extern PIX * pixDeskew ( PIX *pixs, l_int32 redsearch );
+LEPT_DLL extern PIX * pixFindSkewAndDeskew ( PIX *pixs, l_int32 redsearch, l_float32 *pangle, l_float32 *pconf );
+LEPT_DLL extern PIX * pixDeskewGeneral ( PIX *pixs, l_int32 redsweep, l_float32 sweeprange, l_float32 sweepdelta, l_int32 redsearch, l_int32 thresh, l_float32 *pangle, l_float32 *pconf );
+LEPT_DLL extern l_int32 pixFindSkew ( PIX *pixs, l_float32 *pangle, l_float32 *pconf );
+LEPT_DLL extern l_int32 pixFindSkewSweep ( PIX *pixs, l_float32 *pangle, l_int32 reduction, l_float32 sweeprange, l_float32 sweepdelta );
+LEPT_DLL extern l_int32 pixFindSkewSweepAndSearch ( PIX *pixs, l_float32 *pangle, l_float32 *pconf, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta );
+LEPT_DLL extern l_int32 pixFindSkewSweepAndSearchScore ( PIX *pixs, l_float32 *pangle, l_float32 *pconf, l_float32 *pendscore, l_int32 redsweep, l_int32 redsearch, l_float32 sweepcenter, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta );
+LEPT_DLL extern l_int32 pixFindSkewSweepAndSearchScorePivot ( PIX *pixs, l_float32 *pangle, l_float32 *pconf, l_float32 *pendscore, l_int32 redsweep, l_int32 redsearch, l_float32 sweepcenter, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta, l_int32 pivot );
+LEPT_DLL extern l_int32 pixFindSkewOrthogonalRange ( PIX *pixs, l_float32 *pangle, l_float32 *pconf, l_int32 redsweep, l_int32 redsearch, l_float32 sweeprange, l_float32 sweepdelta, l_float32 minbsdelta, l_float32 confprior );
+LEPT_DLL extern l_int32 pixFindDifferentialSquareSum ( PIX *pixs, l_float32 *psum );
+LEPT_DLL extern l_int32 pixFindNormalizedSquareSum ( PIX *pixs, l_float32 *phratio, l_float32 *pvratio, l_float32 *pfract );
+LEPT_DLL extern PIX * pixReadStreamSpix ( FILE *fp );
+LEPT_DLL extern l_int32 readHeaderSpix ( const char *filename, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 freadHeaderSpix ( FILE *fp, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 sreadHeaderSpix ( const l_uint32 *data, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap );
+LEPT_DLL extern l_int32 pixWriteStreamSpix ( FILE *fp, PIX *pix );
+LEPT_DLL extern PIX * pixReadMemSpix ( const l_uint8 *data, size_t size );
+LEPT_DLL extern l_int32 pixWriteMemSpix ( l_uint8 **pdata, size_t *psize, PIX *pix );
+LEPT_DLL extern l_int32 pixSerializeToMemory ( PIX *pixs, l_uint32 **pdata, size_t *pnbytes );
+LEPT_DLL extern PIX * pixDeserializeFromMemory ( const l_uint32 *data, size_t nbytes );
+LEPT_DLL extern L_STACK * lstackCreate ( l_int32 nalloc );
+LEPT_DLL extern void lstackDestroy ( L_STACK **plstack, l_int32 freeflag );
+LEPT_DLL extern l_int32 lstackAdd ( L_STACK *lstack, void *item );
+LEPT_DLL extern void * lstackRemove ( L_STACK *lstack );
+LEPT_DLL extern l_int32 lstackExtendArray ( L_STACK *lstack );
+LEPT_DLL extern l_int32 lstackGetCount ( L_STACK *lstack );
+LEPT_DLL extern l_int32 lstackPrint ( FILE *fp, L_STACK *lstack );
+LEPT_DLL extern l_int32 * sudokuReadFile ( const char *filename );
+LEPT_DLL extern l_int32 * sudokuReadString ( const char *str );
+LEPT_DLL extern L_SUDOKU * sudokuCreate ( l_int32 *array );
+LEPT_DLL extern void sudokuDestroy ( L_SUDOKU **psud );
+LEPT_DLL extern l_int32 sudokuSolve ( L_SUDOKU *sud );
+LEPT_DLL extern l_int32 sudokuTestUniqueness ( l_int32 *array, l_int32 *punique );
+LEPT_DLL extern L_SUDOKU * sudokuGenerate ( l_int32 *array, l_int32 seed, l_int32 minelems, l_int32 maxtries );
+LEPT_DLL extern l_int32 sudokuOutput ( L_SUDOKU *sud, l_int32 arraytype );
+LEPT_DLL extern PIX * pixAddSingleTextblock ( PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location, l_int32 *poverflow );
+LEPT_DLL extern l_int32 pixSetTextblock ( PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 x0, l_int32 y0, l_int32 wtext, l_int32 firstindent, l_int32 *poverflow );
+LEPT_DLL extern l_int32 pixSetTextline ( PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 x0, l_int32 y0, l_int32 *pwidth, l_int32 *poverflow );
+LEPT_DLL extern SARRAY * bmfGetLineStrings ( L_BMF *bmf, const char *textstr, l_int32 maxw, l_int32 firstindent, l_int32 *ph );
+LEPT_DLL extern NUMA * bmfGetWordWidths ( L_BMF *bmf, const char *textstr, SARRAY *sa );
+LEPT_DLL extern l_int32 bmfGetStringWidth ( L_BMF *bmf, const char *textstr, l_int32 *pw );
+LEPT_DLL extern SARRAY * splitStringToParagraphs ( char *textstr, l_int32 splitflag );
+LEPT_DLL extern PIX * pixReadTiff ( const char *filename, l_int32 n );
+LEPT_DLL extern PIX * pixReadStreamTiff ( FILE *fp, l_int32 n );
+LEPT_DLL extern l_int32 pixWriteTiff ( const char *filename, PIX *pix, l_int32 comptype, const char *modestring );
+LEPT_DLL extern l_int32 pixWriteTiffCustom ( const char *filename, PIX *pix, l_int32 comptype, const char *modestring, NUMA *natags, SARRAY *savals, SARRAY *satypes, NUMA *nasizes );
+LEPT_DLL extern l_int32 pixWriteStreamTiff ( FILE *fp, PIX *pix, l_int32 comptype );
+LEPT_DLL extern PIXA * pixaReadMultipageTiff ( const char *filename );
+LEPT_DLL extern l_int32 writeMultipageTiff ( const char *dirin, const char *substr, const char *fileout );
+LEPT_DLL extern l_int32 writeMultipageTiffSA ( SARRAY *sa, const char *fileout );
+LEPT_DLL extern l_int32 fprintTiffInfo ( FILE *fpout, const char *tiffile );
+LEPT_DLL extern l_int32 tiffGetCount ( FILE *fp, l_int32 *pn );
+LEPT_DLL extern l_int32 getTiffResolution ( FILE *fp, l_int32 *pxres, l_int32 *pyres );
+LEPT_DLL extern l_int32 readHeaderTiff ( const char *filename, l_int32 n, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat );
+LEPT_DLL extern l_int32 freadHeaderTiff ( FILE *fp, l_int32 n, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat );
+LEPT_DLL extern l_int32 readHeaderMemTiff ( const l_uint8 *cdata, size_t size, l_int32 n, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat );
+LEPT_DLL extern l_int32 findTiffCompression ( FILE *fp, l_int32 *pcomptype );
+LEPT_DLL extern l_int32 extractG4DataFromFile ( const char *filein, l_uint8 **pdata, size_t *pnbytes, l_int32 *pw, l_int32 *ph, l_int32 *pminisblack );
+LEPT_DLL extern PIX * pixReadMemTiff ( const l_uint8 *cdata, size_t size, l_int32 n );
+LEPT_DLL extern l_int32 pixWriteMemTiff ( l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 comptype );
+LEPT_DLL extern l_int32 pixWriteMemTiffCustom ( l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 comptype, NUMA *natags, SARRAY *savals, SARRAY *satypes, NUMA *nasizes );
+LEPT_DLL extern l_int32 returnErrorInt ( const char *msg, const char *procname, l_int32 ival );
+LEPT_DLL extern l_float32 returnErrorFloat ( const char *msg, const char *procname, l_float32 fval );
+LEPT_DLL extern void * returnErrorPtr ( const char *msg, const char *procname, void *pval );
+LEPT_DLL extern void l_error ( const char *msg, const char *procname );
+LEPT_DLL extern void l_errorString ( const char *msg, const char *procname, const char *str );
+LEPT_DLL extern void l_errorInt ( const char *msg, const char *procname, l_int32 ival );
+LEPT_DLL extern void l_errorFloat ( const char *msg, const char *procname, l_float32 fval );
+LEPT_DLL extern void l_warning ( const char *msg, const char *procname );
+LEPT_DLL extern void l_warningString ( const char *msg, const char *procname, const char *str );
+LEPT_DLL extern void l_warningInt ( const char *msg, const char *procname, l_int32 ival );
+LEPT_DLL extern void l_warningInt2 ( const char *msg, const char *procname, l_int32 ival1, l_int32 ival2 );
+LEPT_DLL extern void l_warningFloat ( const char *msg, const char *procname, l_float32 fval );
+LEPT_DLL extern void l_warningFloat2 ( const char *msg, const char *procname, l_float32 fval1, l_float32 fval2 );
+LEPT_DLL extern void l_info ( const char *msg, const char *procname );
+LEPT_DLL extern void l_infoString ( const char *msg, const char *procname, const char *str );
+LEPT_DLL extern void l_infoInt ( const char *msg, const char *procname, l_int32 ival );
+LEPT_DLL extern void l_infoInt2 ( const char *msg, const char *procname, l_int32 ival1, l_int32 ival2 );
+LEPT_DLL extern void l_infoFloat ( const char *msg, const char *procname, l_float32 fval );
+LEPT_DLL extern void l_infoFloat2 ( const char *msg, const char *procname, l_float32 fval1, l_float32 fval2 );
+LEPT_DLL extern char * stringNew ( const char *src );
+LEPT_DLL extern l_int32 stringCopy ( char *dest, const char *src, l_int32 n );
+LEPT_DLL extern l_int32 stringReplace ( char **pdest, const char *src );
+LEPT_DLL extern l_int32 stringLength ( const char *src, size_t size );
+LEPT_DLL extern l_int32 stringCat ( char *dest, size_t size, const char *src );
+LEPT_DLL extern char * stringJoin ( const char *src1, const char *src2 );
+LEPT_DLL extern char * stringReverse ( const char *src );
+LEPT_DLL extern char * strtokSafe ( char *cstr, const char *seps, char **psaveptr );
+LEPT_DLL extern l_int32 stringSplitOnToken ( char *cstr, const char *seps, char **phead, char **ptail );
+LEPT_DLL extern char * stringRemoveChars ( const char *src, const char *remchars );
+LEPT_DLL extern l_int32 stringFindSubstr ( const char *src, const char *sub, l_int32 *ploc );
+LEPT_DLL extern char * stringReplaceSubstr ( const char *src, const char *sub1, const char *sub2, l_int32 *pfound, l_int32 *ploc );
+LEPT_DLL extern char * stringReplaceEachSubstr ( const char *src, const char *sub1, const char *sub2, l_int32 *pcount );
+LEPT_DLL extern L_DNA * arrayFindEachSequence ( const l_uint8 *data, l_int32 datalen, const l_uint8 *sequence, l_int32 seqlen );
+LEPT_DLL extern l_int32 arrayFindSequence ( const l_uint8 *data, l_int32 datalen, const l_uint8 *sequence, l_int32 seqlen, l_int32 *poffset, l_int32 *pfound );
+LEPT_DLL extern void * reallocNew ( void **pindata, l_int32 oldsize, l_int32 newsize );
+LEPT_DLL extern l_uint8 * l_binaryRead ( const char *filename, size_t *pnbytes );
+LEPT_DLL extern l_uint8 * l_binaryReadStream ( FILE *fp, size_t *pnbytes );
+LEPT_DLL extern l_int32 l_binaryWrite ( const char *filename, const char *operation, void *data, size_t nbytes );
+LEPT_DLL extern size_t nbytesInFile ( const char *filename );
+LEPT_DLL extern size_t fnbytesInFile ( FILE *fp );
+LEPT_DLL extern l_uint8 * l_binaryCopy ( l_uint8 *datas, size_t size );
+LEPT_DLL extern l_int32 fileCopy ( const char *srcfile, const char *newfile );
+LEPT_DLL extern l_int32 fileConcatenate ( const char *srcfile, const char *destfile );
+LEPT_DLL extern l_int32 fileAppendString ( const char *filename, const char *str );
+LEPT_DLL extern l_int32 filesAreIdentical ( const char *fname1, const char *fname2, l_int32 *psame );
+LEPT_DLL extern l_uint16 convertOnLittleEnd16 ( l_uint16 shortin );
+LEPT_DLL extern l_uint16 convertOnBigEnd16 ( l_uint16 shortin );
+LEPT_DLL extern l_uint32 convertOnLittleEnd32 ( l_uint32 wordin );
+LEPT_DLL extern l_uint32 convertOnBigEnd32 ( l_uint32 wordin );
+LEPT_DLL extern FILE * fopenReadStream ( const char *filename );
+LEPT_DLL extern FILE * fopenWriteStream ( const char *filename, const char *modestring );
+LEPT_DLL extern FILE * lept_fopen ( const char *filename, const char *mode );
+LEPT_DLL extern l_int32 lept_fclose ( FILE *fp );
+LEPT_DLL extern void * lept_calloc ( size_t nmemb, size_t size );
+LEPT_DLL extern void lept_free ( void *ptr );
+LEPT_DLL extern l_int32 lept_mkdir ( const char *subdir );
+LEPT_DLL extern l_int32 lept_rmdir ( const char *subdir );
+LEPT_DLL extern void lept_direxists ( const char *dirname, l_int32 *pexists );
+LEPT_DLL extern l_int32 lept_rm ( const char *subdir, const char *filename );
+LEPT_DLL extern l_int32 lept_mv ( const char *srcfile, const char *newfile );
+LEPT_DLL extern l_int32 lept_cp ( const char *srcfile, const char *newfile );
+LEPT_DLL extern l_int32 splitPathAtDirectory ( const char *pathname, char **pdir, char **ptail );
+LEPT_DLL extern l_int32 splitPathAtExtension ( const char *pathname, char **pbasename, char **pextension );
+LEPT_DLL extern char * pathJoin ( const char *dir, const char *fname );
+LEPT_DLL extern char * genPathname ( const char *dir, const char *fname );
+LEPT_DLL extern char * genTempFilename ( const char *dir, const char *tail, l_int32 usetime, l_int32 usepid );
+LEPT_DLL extern l_int32 extractNumberFromFilename ( const char *fname, l_int32 numpre, l_int32 numpost );
+LEPT_DLL extern l_int32 genRandomIntegerInRange ( l_int32 range, l_int32 seed, l_int32 *pval );
+LEPT_DLL extern l_int32 lept_roundftoi ( l_float32 fval );
+LEPT_DLL extern char * getLeptonicaVersion ( );
+LEPT_DLL extern void startTimer ( void );
+LEPT_DLL extern l_float32 stopTimer ( void );
+LEPT_DLL extern L_TIMER startTimerNested ( void );
+LEPT_DLL extern l_float32 stopTimerNested ( L_TIMER rusage_start );
+LEPT_DLL extern void l_getCurrentTime ( l_int32 *sec, l_int32 *usec );
+LEPT_DLL extern char * l_getFormattedDate ( );
+LEPT_DLL extern l_uint8 * arrayRead ( const char *fname, l_int32 *pnbytes );
+LEPT_DLL extern l_uint8 * arrayReadStream ( FILE *fp, l_int32 *pnbytes );
+LEPT_DLL extern l_int32 pixHtmlViewer ( const char *dirin, const char *dirout, const char *rootname, l_int32 thumbwidth, l_int32 viewwidth, l_int32 copyorig );
+LEPT_DLL extern PIX * pixSimpleCaptcha ( PIX *pixs, l_int32 border, l_int32 nterms, l_uint32 seed, l_uint32 color, l_int32 cmapflag );
+LEPT_DLL extern PIX * pixRandomHarmonicWarp ( PIX *pixs, l_float32 xmag, l_float32 ymag, l_float32 xfreq, l_float32 yfreq, l_int32 nx, l_int32 ny, l_uint32 seed, l_int32 grayval );
+LEPT_DLL extern PIX * pixWarpStereoscopic ( PIX *pixs, l_int32 zbend, l_int32 zshiftt, l_int32 zshiftb, l_int32 ybendt, l_int32 ybendb, l_int32 redleft );
+LEPT_DLL extern PIX * pixStretchHorizontal ( PIX *pixs, l_int32 dir, l_int32 type, l_int32 hmax, l_int32 operation, l_int32 incolor );
+LEPT_DLL extern PIX * pixStretchHorizontalSampled ( PIX *pixs, l_int32 dir, l_int32 type, l_int32 hmax, l_int32 incolor );
+LEPT_DLL extern PIX * pixStretchHorizontalLI ( PIX *pixs, l_int32 dir, l_int32 type, l_int32 hmax, l_int32 incolor );
+LEPT_DLL extern PIX * pixQuadraticVShear ( PIX *pixs, l_int32 dir, l_int32 vmaxt, l_int32 vmaxb, l_int32 operation, l_int32 incolor );
+LEPT_DLL extern PIX * pixQuadraticVShearSampled ( PIX *pixs, l_int32 dir, l_int32 vmaxt, l_int32 vmaxb, l_int32 incolor );
+LEPT_DLL extern PIX * pixQuadraticVShearLI ( PIX *pixs, l_int32 dir, l_int32 vmaxt, l_int32 vmaxb, l_int32 incolor );
+LEPT_DLL extern PIX * pixStereoFromPair ( PIX *pix1, PIX *pix2, l_float32 rwt, l_float32 gwt, l_float32 bwt );
+LEPT_DLL extern L_WSHED * wshedCreate ( PIX *pixs, PIX *pixm, l_int32 mindepth, l_int32 debugflag );
+LEPT_DLL extern void wshedDestroy ( L_WSHED **pwshed );
+LEPT_DLL extern l_int32 wshedApply ( L_WSHED *wshed );
+LEPT_DLL extern l_int32 wshedBasins ( L_WSHED *wshed, PIXA **ppixa, NUMA **pnalevels );
+LEPT_DLL extern PIX * wshedRenderFill ( L_WSHED *wshed );
+LEPT_DLL extern PIX * wshedRenderColors ( L_WSHED *wshed );
+LEPT_DLL extern PIX * pixReadStreamWebP ( FILE *fp );
+LEPT_DLL extern l_int32 readHeaderWebP ( const char *filename, l_int32 *pwidth, l_int32 *pheight );
+LEPT_DLL extern l_int32 pixWriteWebP ( const char *filename, PIX *pixs, l_int32 quality );
+LEPT_DLL extern l_int32 pixWriteStreamWebP ( FILE *fp, PIX *pixs, l_int32 quality );
+LEPT_DLL extern l_int32 pixaWriteFiles ( const char *rootname, PIXA *pixa, l_int32 format );
+LEPT_DLL extern l_int32 pixWrite ( const char *filename, PIX *pix, l_int32 format );
+LEPT_DLL extern l_int32 pixWriteStream ( FILE *fp, PIX *pix, l_int32 format );
+LEPT_DLL extern l_int32 pixWriteImpliedFormat ( const char *filename, PIX *pix, l_int32 quality, l_int32 progressive );
+LEPT_DLL extern l_int32 pixWriteTempfile ( const char *dir, const char *tail, PIX *pix, l_int32 format, char **pfilename );
+LEPT_DLL extern l_int32 pixChooseOutputFormat ( PIX *pix );
+LEPT_DLL extern l_int32 getImpliedFileFormat ( const char *filename );
+LEPT_DLL extern const char * getFormatExtension ( l_int32 format );
+LEPT_DLL extern l_int32 pixWriteMem ( l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 format );
+LEPT_DLL extern l_int32 pixDisplay ( PIX *pixs, l_int32 x, l_int32 y );
+LEPT_DLL extern l_int32 pixDisplayWithTitle ( PIX *pixs, l_int32 x, l_int32 y, const char *title, l_int32 dispflag );
+LEPT_DLL extern l_int32 pixDisplayMultiple ( const char *filepattern );
+LEPT_DLL extern l_int32 pixDisplayWrite ( PIX *pixs, l_int32 reduction );
+LEPT_DLL extern l_int32 pixDisplayWriteFormat ( PIX *pixs, l_int32 reduction, l_int32 format );
+LEPT_DLL extern l_int32 pixSaveTiled ( PIX *pixs, PIXA *pixa, l_int32 reduction, l_int32 newrow, l_int32 space, l_int32 dp );
+LEPT_DLL extern l_int32 pixSaveTiledOutline ( PIX *pixs, PIXA *pixa, l_int32 reduction, l_int32 newrow, l_int32 space, l_int32 linewidth, l_int32 dp );
+LEPT_DLL extern l_int32 pixSaveTiledWithText ( PIX *pixs, PIXA *pixa, l_int32 outwidth, l_int32 newrow, l_int32 space, l_int32 linewidth, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location );
+LEPT_DLL extern void l_chooseDisplayProg ( l_int32 selection );
+LEPT_DLL extern l_uint8 * zlibCompress ( l_uint8 *datain, size_t nin, size_t *pnout );
+LEPT_DLL extern l_uint8 * zlibUncompress ( l_uint8 *datain, size_t nin, size_t *pnout );
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* NO_PROTOS */
+
+
+#endif /* LEPTONICA_ALLHEADERS_H */
+
diff --git a/card.io/src/main/jni/leptonica/alltypes.h b/card.io/src/main/jni/leptonica/alltypes.h
new file mode 100644
index 00000000..feb03be0
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/alltypes.h
@@ -0,0 +1,60 @@
+/*====================================================================*
+ - 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_ALLTYPES_H
+#define LEPTONICA_ALLTYPES_H
+
+ /* Standard */
+#include
+#include
+
+ /* General and configuration defs */
+#include "environ.h"
+
+ /* Imaging */
+#include "array.h"
+#include "arrayaccess.h"
+#include "bbuffer.h"
+#include "bmf.h"
+#include "ccbord.h"
+#include "dewarp.h"
+#include "gplot.h"
+#include "heap.h"
+#include "imageio.h"
+#include "jbclass.h"
+#include "list.h"
+#include "morph.h"
+#include "pix.h"
+#include "ptra.h"
+#include "queue.h"
+#include "regutils.h"
+#include "sudoku.h"
+#include "stack.h"
+#include "watershed.h"
+
+
+#endif /* LEPTONICA_ALLTYPES_H */
+
diff --git a/card.io/src/main/jni/leptonica/array.h b/card.io/src/main/jni/leptonica/array.h
new file mode 100644
index 00000000..33e3da0f
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/array.h
@@ -0,0 +1,163 @@
+/*====================================================================*
+ - 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_ARRAY_H
+#define LEPTONICA_ARRAY_H
+
+/*
+ * Contains the following structs:
+ * struct Numa
+ * struct Numaa
+ * struct Numa2d
+ * struct NumaHash
+ * struct L_Dna
+ * struct L_Dnaa
+ * struct Sarray
+ * struct L_Bytea
+ *
+ * Contains definitions for:
+ * Numa interpolation flags
+ */
+
+
+/*------------------------------------------------------------------------*
+ * Array Structs *
+ *------------------------------------------------------------------------*/
+
+#define NUMA_VERSION_NUMBER 1
+
+ /* Number array: an array of floats */
+struct Numa
+{
+ l_int32 nalloc; /* size of allocated number array */
+ l_int32 n; /* number of numbers saved */
+ l_int32 refcount; /* reference count (1 if no clones) */
+ l_float32 startx; /* x value assigned to array[0] */
+ l_float32 delx; /* change in x value as i --> i + 1 */
+ l_float32 *array; /* number array */
+};
+typedef struct Numa NUMA;
+
+
+ /* Array of number arrays */
+struct Numaa
+{
+ l_int32 nalloc; /* size of allocated ptr array */
+ l_int32 n; /* number of Numa saved */
+ struct Numa **numa; /* array of Numa */
+};
+typedef struct Numaa NUMAA;
+
+
+ /* Sparse 2-dimensional array of number arrays */
+struct Numa2d
+{
+ l_int32 nrows; /* number of rows allocated for ptr array */
+ l_int32 ncols; /* number of cols allocated for ptr array */
+ l_int32 initsize; /* initial size of each numa that is made */
+ struct Numa ***numa; /* 2D array of Numa */
+};
+typedef struct Numa2d NUMA2D;
+
+
+ /* A hash table of Numas */
+struct NumaHash
+{
+ l_int32 nbuckets;
+ l_int32 initsize; /* initial size of each numa that is made */
+ struct Numa **numa;
+};
+typedef struct NumaHash NUMAHASH;
+
+
+#define DNA_VERSION_NUMBER 1
+
+ /* Double number array: an array of doubles */
+struct L_Dna
+{
+ l_int32 nalloc; /* size of allocated number array */
+ l_int32 n; /* number of numbers saved */
+ l_int32 refcount; /* reference count (1 if no clones) */
+ l_float64 startx; /* x value assigned to array[0] */
+ l_float64 delx; /* change in x value as i --> i + 1 */
+ l_float64 *array; /* number array */
+};
+typedef struct L_Dna L_DNA;
+
+
+ /* Array of double number arrays */
+struct L_Dnaa
+{
+ l_int32 nalloc; /* size of allocated ptr array */
+ l_int32 n; /* number of L_Dna saved */
+ struct L_Dna **dna; /* array of L_Dna */
+};
+typedef struct L_Dnaa L_DNAA;
+
+
+#define SARRAY_VERSION_NUMBER 1
+
+ /* String array: an array of C strings */
+struct Sarray
+{
+ l_int32 nalloc; /* size of allocated ptr array */
+ l_int32 n; /* number of strings allocated */
+ l_int32 refcount; /* reference count (1 if no clones) */
+ char **array; /* string array */
+};
+typedef struct Sarray SARRAY;
+
+
+ /* Byte array (analogous to C++ "string") */
+struct L_Bytea
+{
+ size_t nalloc; /* number of bytes allocated in data array */
+ size_t size; /* number of bytes presently used */
+ l_int32 refcount; /* reference count (1 if no clones) */
+ l_uint8 *data; /* data array */
+};
+typedef struct L_Bytea L_BYTEA;
+
+
+/*------------------------------------------------------------------------*
+ * Array flags *
+ *------------------------------------------------------------------------*/
+
+ /* Flags for interpolation in Numa */
+enum {
+ L_LINEAR_INTERP = 1, /* linear */
+ L_QUADRATIC_INTERP = 2 /* quadratic */
+};
+
+ /* Flags for added borders in Numa and Fpix */
+enum {
+ L_CONTINUED_BORDER = 1, /* extended with same value */
+ L_SLOPE_BORDER = 2, /* extended with constant normal derivative */
+ L_MIRRORED_BORDER = 3 /* mirrored */
+};
+
+
+#endif /* LEPTONICA_ARRAY_H */
diff --git a/card.io/src/main/jni/leptonica/arrayaccess.h b/card.io/src/main/jni/leptonica/arrayaccess.h
new file mode 100644
index 00000000..2ac8c4a0
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/arrayaccess.h
@@ -0,0 +1,205 @@
+/*====================================================================*
+ - 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_ARRAY_ACCESS_H
+#define LEPTONICA_ARRAY_ACCESS_H
+
+/*
+ * arrayaccess.h
+ *
+ * 1, 2, 4, 8, 16 and 32 bit data access within an array of 32-bit words
+ *
+ * This is used primarily to access 1, 2, 4, 8, 16 and 32 bit pixels
+ * in a line of image data, represented as an array of 32-bit words.
+ *
+ * pdata: pointer to first 32-bit word in the array
+ * n: index of the pixel in the array
+ *
+ * Function calls for these accessors are defined in arrayaccess.c.
+ *
+ * However, for efficiency we use the inline macros for all accesses.
+ * Even though the 2 and 4 bit set* accessors are more complicated,
+ * they are about 10% faster than the function calls.
+ *
+ * The 32 bit access is just a cast and ptr arithmetic. We include
+ * it so that the input ptr can be void*.
+ *
+ * At the end of this file is code for invoking the function calls
+ * instead of inlining.
+ *
+ * The macro SET_DATA_BIT_VAL(pdata, n, val) is a bit slower than
+ * if (val == 0)
+ * CLEAR_DATA_BIT(pdata, n);
+ * else
+ * SET_DATA_BIT(pdata, n);
+ */
+
+
+ /* Use the inline accessors (except with _MSC_VER), because they
+ * are faster. */
+#define USE_INLINE_ACCESSORS 1
+
+#if USE_INLINE_ACCESSORS
+#ifndef _MSC_VER
+
+ /*--------------------------------------------------*
+ * 1 bit access *
+ *--------------------------------------------------*/
+#define GET_DATA_BIT(pdata, n) \
+ ((*((l_uint32 *)(pdata) + ((n) >> 5)) >> (31 - ((n) & 31))) & 1)
+
+#define SET_DATA_BIT(pdata, n) \
+ (*((l_uint32 *)(pdata) + ((n) >> 5)) |= (0x80000000 >> ((n) & 31)))
+
+#define CLEAR_DATA_BIT(pdata, n) \
+ (*((l_uint32 *)(pdata) + ((n) >> 5)) &= ~(0x80000000 >> ((n) & 31)))
+
+#define SET_DATA_BIT_VAL(pdata, n, val) \
+ ({l_uint32 *_TEMP_WORD_PTR_; \
+ _TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 5); \
+ *_TEMP_WORD_PTR_ &= ~(0x80000000 >> ((n) & 31)); \
+ *_TEMP_WORD_PTR_ |= ((val) << (31 - ((n) & 31))); \
+ })
+
+
+ /*--------------------------------------------------*
+ * 2 bit access *
+ *--------------------------------------------------*/
+#define GET_DATA_DIBIT(pdata, n) \
+ ((*((l_uint32 *)(pdata) + ((n) >> 4)) >> (2 * (15 - ((n) & 15)))) & 3)
+
+#define SET_DATA_DIBIT(pdata, n, val) \
+ ({l_uint32 *_TEMP_WORD_PTR_; \
+ _TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 4); \
+ *_TEMP_WORD_PTR_ &= ~(0xc0000000 >> (2 * ((n) & 15))); \
+ *_TEMP_WORD_PTR_ |= (((val) & 3) << (30 - 2 * ((n) & 15))); \
+ })
+
+#define CLEAR_DATA_DIBIT(pdata, n) \
+ (*((l_uint32 *)(pdata) + ((n) >> 4)) &= ~(0xc0000000 >> (2 * ((n) & 15))))
+
+
+ /*--------------------------------------------------*
+ * 4 bit access *
+ *--------------------------------------------------*/
+#define GET_DATA_QBIT(pdata, n) \
+ ((*((l_uint32 *)(pdata) + ((n) >> 3)) >> (4 * (7 - ((n) & 7)))) & 0xf)
+
+#define SET_DATA_QBIT(pdata, n, val) \
+ ({l_uint32 *_TEMP_WORD_PTR_; \
+ _TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 3); \
+ *_TEMP_WORD_PTR_ &= ~(0xf0000000 >> (4 * ((n) & 7))); \
+ *_TEMP_WORD_PTR_ |= (((val) & 15) << (28 - 4 * ((n) & 7))); \
+ })
+
+#define CLEAR_DATA_QBIT(pdata, n) \
+ (*((l_uint32 *)(pdata) + ((n) >> 3)) &= ~(0xf0000000 >> (4 * ((n) & 7))))
+
+
+ /*--------------------------------------------------*
+ * 8 bit access *
+ *--------------------------------------------------*/
+#ifdef L_BIG_ENDIAN
+#define GET_DATA_BYTE(pdata, n) \
+ (*((l_uint8 *)(pdata) + (n)))
+#else /* L_LITTLE_ENDIAN */
+#define GET_DATA_BYTE(pdata, n) \
+ (*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3))
+#endif /* L_BIG_ENDIAN */
+
+#ifdef L_BIG_ENDIAN
+#define SET_DATA_BYTE(pdata, n, val) \
+ (*((l_uint8 *)(pdata) + (n)) = (val))
+#else /* L_LITTLE_ENDIAN */
+#define SET_DATA_BYTE(pdata, n, val) \
+ (*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3) = (val))
+#endif /* L_BIG_ENDIAN */
+
+
+ /*--------------------------------------------------*
+ * 16 bit access *
+ *--------------------------------------------------*/
+#ifdef L_BIG_ENDIAN
+#define GET_DATA_TWO_BYTES(pdata, n) \
+ (*((l_uint16 *)(pdata) + (n)))
+#else /* L_LITTLE_ENDIAN */
+#define GET_DATA_TWO_BYTES(pdata, n) \
+ (*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2))
+#endif /* L_BIG_ENDIAN */
+
+#ifdef L_BIG_ENDIAN
+#define SET_DATA_TWO_BYTES(pdata, n, val) \
+ (*((l_uint16 *)(pdata) + (n)) = (val))
+#else /* L_LITTLE_ENDIAN */
+#define SET_DATA_TWO_BYTES(pdata, n, val) \
+ (*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2) = (val))
+#endif /* L_BIG_ENDIAN */
+
+
+ /*--------------------------------------------------*
+ * 32 bit access *
+ *--------------------------------------------------*/
+#define GET_DATA_FOUR_BYTES(pdata, n) \
+ (*((l_uint32 *)(pdata) + (n)))
+
+#define SET_DATA_FOUR_BYTES(pdata, n, val) \
+ (*((l_uint32 *)(pdata) + (n)) = (val))
+
+
+#endif /* ! _MSC_VER */
+#endif /* USE_INLINE_ACCESSORS */
+
+
+
+ /*--------------------------------------------------*
+ * Slower, using function calls for all accessors *
+ *--------------------------------------------------*/
+#if !USE_INLINE_ACCESSORS || defined(_MSC_VER)
+#define GET_DATA_BIT(pdata, n) l_getDataBit(pdata, n)
+#define SET_DATA_BIT(pdata, n) l_setDataBit(pdata, n)
+#define CLEAR_DATA_BIT(pdata, n) l_clearDataBit(pdata, n)
+#define SET_DATA_BIT_VAL(pdata, n, val) l_setDataBitVal(pdata, n, val)
+
+#define GET_DATA_DIBIT(pdata, n) l_getDataDibit(pdata, n)
+#define SET_DATA_DIBIT(pdata, n, val) l_setDataDibit(pdata, n, val)
+#define CLEAR_DATA_DIBIT(pdata, n) l_clearDataDibit(pdata, n)
+
+#define GET_DATA_QBIT(pdata, n) l_getDataQbit(pdata, n)
+#define SET_DATA_QBIT(pdata, n, val) l_setDataQbit(pdata, n, val)
+#define CLEAR_DATA_QBIT(pdata, n) l_clearDataQbit(pdata, n)
+
+#define GET_DATA_BYTE(pdata, n) l_getDataByte(pdata, n)
+#define SET_DATA_BYTE(pdata, n, val) l_setDataByte(pdata, n, val)
+
+#define GET_DATA_TWO_BYTES(pdata, n) l_getDataTwoBytes(pdata, n)
+#define SET_DATA_TWO_BYTES(pdata, n, val) l_setDataTwoBytes(pdata, n, val)
+
+#define GET_DATA_FOUR_BYTES(pdata, n) l_getDataFourBytes(pdata, n)
+#define SET_DATA_FOUR_BYTES(pdata, n, val) l_setDataFourBytes(pdata, n, val)
+#endif /* !USE_INLINE_ACCESSORS || _MSC_VER */
+
+
+#endif /* LEPTONICA_ARRAY_ACCESS_H */
diff --git a/card.io/src/main/jni/leptonica/bbuffer.h b/card.io/src/main/jni/leptonica/bbuffer.h
new file mode 100644
index 00000000..3d308eb8
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/bbuffer.h
@@ -0,0 +1,57 @@
+/*====================================================================*
+ - 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_BBUFFER_H
+#define LEPTONICA_BBUFFER_H
+
+/*
+ * bbuffer.h
+ *
+ * Expandable byte buffer for reading data in from memory and
+ * writing data out to other memory.
+ *
+ * This implements a queue of bytes, so data read in is put
+ * on the "back" of the queue (i.e., the end of the byte array)
+ * and data written out is taken from the "front" of the queue
+ * (i.e., from an index marker "nwritten" that is initially set at
+ * the beginning of the array.) As usual with expandable
+ * arrays, we keep the size of the allocated array and the
+ * number of bytes that have been read into the array.
+ *
+ * For implementation details, see bbuffer.c.
+ */
+
+struct ByteBuffer
+{
+ l_int32 nalloc; /* size of allocated byte array */
+ l_int32 n; /* number of bytes read into to the array */
+ l_int32 nwritten; /* number of bytes written from the array */
+ l_uint8 *array; /* byte array */
+};
+typedef struct ByteBuffer BBUFFER;
+
+
+#endif /* LEPTONICA_BBUFFER_H */
diff --git a/card.io/src/main/jni/leptonica/bmf.h b/card.io/src/main/jni/leptonica/bmf.h
new file mode 100644
index 00000000..007534c3
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/bmf.h
@@ -0,0 +1,62 @@
+/*====================================================================*
+ - 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_BMF_H
+#define LEPTONICA_BMF_H
+
+/*
+ * bmf.h
+ *
+ * Simple data structure to hold bitmap fonts and related data
+ */
+
+ /* Constants for deciding when text block is divided into paragraphs */
+enum {
+ SPLIT_ON_LEADING_WHITE = 1, /* tab or space at beginning of line */
+ SPLIT_ON_BLANK_LINE = 2, /* newline with optional white space */
+ SPLIT_ON_BOTH = 3 /* leading white space or newline */
+};
+
+
+struct L_Bmf
+{
+ struct Pixa *pixa; /* pixa of bitmaps for 93 characters */
+ l_int32 size; /* font size (in points at 300 ppi) */
+ char *directory; /* directory containing font bitmaps */
+ l_int32 baseline1; /* baseline offset for ascii 33 - 57 */
+ l_int32 baseline2; /* baseline offset for ascii 58 - 91 */
+ l_int32 baseline3; /* baseline offset for ascii 93 - 126 */
+ l_int32 lineheight; /* max height of line of chars */
+ l_int32 kernwidth; /* pixel dist between char bitmaps */
+ l_int32 spacewidth; /* pixel dist between word bitmaps */
+ l_int32 vertlinesep; /* extra vertical space between text lines */
+ l_int32 *fonttab; /* table mapping ascii --> font index */
+ l_int32 *baselinetab; /* table mapping ascii --> baseline offset */
+ l_int32 *widthtab; /* table mapping ascii --> char width */
+};
+typedef struct L_Bmf L_BMF;
+
+#endif /* LEPTONICA_BMF_H */
diff --git a/card.io/src/main/jni/leptonica/bmp.h b/card.io/src/main/jni/leptonica/bmp.h
new file mode 100644
index 00000000..c50b7b4f
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/bmp.h
@@ -0,0 +1,85 @@
+/*====================================================================*
+ - 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_BMP_H
+#define LEPTONICA_BMP_H
+
+/*
+ * This file is here to describe the fields in the header of
+ * the BMP file. These fields are not used directly in Leptonica.
+ * The only thing we use are the sizes of these two headers.
+ * Furthermore, because of potential namespace conflicts with
+ * the typedefs and defined sizes, we have changed the names
+ * to protect anyone who may also need to use the original definitions.
+ * Thanks to J. D. Bryan for pointing out the potential problems when
+ * developing on Win32 compatible systems.
+ */
+
+/*-------------------------------------------------------------*
+ * BMP file header *
+ *-------------------------------------------------------------*/
+struct BMP_FileHeader
+{
+ l_int16 bfType; /* file type; must be "BM" */
+ l_int16 bfSize; /* length of the file;
+ sizeof(BMP_FileHeader) +
+ sizeof(BMP_InfoHeader) +
+ size of color table +
+ size of DIB bits */
+ l_int16 bfFill1; /* remainder of the bfSize field */
+ l_int16 bfReserved1; /* don't care (set to 0)*/
+ l_int16 bfReserved2; /* don't care (set to 0)*/
+ l_int16 bfOffBits; /* offset from beginning of file */
+ l_int16 bfFill2; /* remainder of the bfOffBits field */
+};
+typedef struct BMP_FileHeader BMP_FH;
+
+#define BMP_FHBYTES sizeof(BMP_FH)
+
+
+/*-------------------------------------------------------------*
+ * BMP info header *
+ *-------------------------------------------------------------*/
+struct BMP_InfoHeader
+{
+ l_int32 biSize; /* size of the BMP_InfoHeader struct */
+ l_int32 biWidth; /* bitmap width in pixels */
+ l_int32 biHeight; /* bitmap height in pixels */
+ l_int16 biPlanes; /* number of bitmap planes */
+ l_int16 biBitCount; /* number of bits per pixel */
+ l_int32 biCompression; /* compression format (0 == uncompressed) */
+ l_int32 biSizeImage; /* size of image in bytes */
+ l_int32 biXPelsPerMeter; /* pixels per meter in x direction */
+ l_int32 biYPelsPerMeter; /* pixels per meter in y direction */
+ l_int32 biClrUsed; /* number of colors used */
+ l_int32 biClrImportant; /* number of important colors used */
+};
+typedef struct BMP_InfoHeader BMP_IH;
+
+#define BMP_IHBYTES sizeof(BMP_IH)
+
+
+#endif /* LEPTONICA_BMP_H */
diff --git a/card.io/src/main/jni/leptonica/ccbord.h b/card.io/src/main/jni/leptonica/ccbord.h
new file mode 100644
index 00000000..9c976aa2
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/ccbord.h
@@ -0,0 +1,114 @@
+/*====================================================================*
+ - 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_CCBORD_H
+#define LEPTONICA_CCBORD_H
+
+/*
+ * ccbord.h
+ *
+ * CCBord: represents a single connected component
+ * CCBorda: an array of CCBord
+ */
+
+ /* Use in ccbaStepChainsToPixCoords() */
+enum {
+ CCB_LOCAL_COORDS = 1,
+ CCB_GLOBAL_COORDS = 2
+};
+
+ /* Use in ccbaGenerateSPGlobalLocs() */
+enum {
+ CCB_SAVE_ALL_PTS = 1,
+ CCB_SAVE_TURNING_PTS = 2
+};
+
+
+ /* CCBord contains:
+ *
+ * (1) a minimally-clipped bitmap of the component (pix),
+ * (2) a boxa consisting of:
+ * for the primary component:
+ * (xul, yul) pixel location in global coords
+ * (w, h) of the bitmap
+ * for the hole components:
+ * (x, y) in relative coordinates in primary component
+ * (w, h) of the hole border (which is 2 pixels
+ * larger in each direction than the hole itself)
+ * (3) a pta ('start') of the initial border pixel location for each
+ * closed curve, all in relative coordinates of the primary
+ * component. This is given for the primary component,
+ * followed by the hole components, if any.
+ * (4) a refcount of the ccbord; used internally when a ccbord
+ * is accessed from a ccborda (array of ccbord)
+ * (5) a ptaa for the chain code for the border in relative
+ * coordinates, where the first pta is the exterior border
+ * and all other pta are for interior borders (holes)
+ * (6) a ptaa for the global pixel loc rendition of the border,
+ * where the first pta is the exterior border and all other
+ * pta are for interior borders (holes).
+ * This is derived from the local or step chain code.
+ * (7) a numaa for the chain code for the border as orientation
+ * directions between successive border pixels, where
+ * the first numa is the exterior border and all other
+ * numa are for interior borders (holes). This is derived
+ * from the local chain code. The 8 directions are 0 - 7.
+ * (8) a pta for a single chain for each c.c., comprised of outer
+ * and hole borders, plus cut paths between them, all in
+ * local coords.
+ * (9) a pta for a single chain for each c.c., comprised of outer
+ * and hole borders, plus cut paths between them, all in
+ * global coords.
+ */
+struct CCBord
+{
+ struct Pix *pix; /* component bitmap (min size) */
+ struct Boxa *boxa; /* regions of each closed curve */
+ struct Pta *start; /* initial border pixel locations */
+ l_int32 refcount; /* number of handles; start at 1 */
+ struct Ptaa *local; /* ptaa of chain pixels (local) */
+ struct Ptaa *global; /* ptaa of chain pixels (global) */
+ struct Numaa *step; /* numaa of chain code (step dir) */
+ struct Pta *splocal; /* pta of single chain (local) */
+ struct Pta *spglobal; /* pta of single chain (global) */
+};
+typedef struct CCBord CCBORD;
+
+
+struct CCBorda
+{
+ struct Pix *pix; /* input pix (may be null) */
+ l_int32 w; /* width of pix */
+ l_int32 h; /* height of pix */
+ l_int32 n; /* number of ccbord in ptr array */
+ l_int32 nalloc; /* number of ccbord ptrs allocated */
+ struct CCBord **ccb; /* ccb ptr array */
+};
+typedef struct CCBorda CCBORDA;
+
+
+#endif /* LEPTONICA_CCBORD_H */
+
diff --git a/card.io/src/main/jni/leptonica/dewarp.h b/card.io/src/main/jni/leptonica/dewarp.h
new file mode 100644
index 00000000..d83a8c9e
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/dewarp.h
@@ -0,0 +1,151 @@
+/*====================================================================*
+ - 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_DEWARP_H
+#define LEPTONICA_DEWARP_H
+
+/*
+ * dewarp.h
+ *
+ * Data structure to hold arrays and results for generating
+ * horizontal and vertical disparity arrays based on textlines.
+ * Each disparity array is two-dimensional. The vertical disparity
+ * array gives a vertical displacement, relative to the lowest point
+ * in the textlines. The horizontal disparty array gives a horizontal
+ * displacement, relative to the minimum values (for even pages)
+ * or maximum values (for odd pages) of the left and right ends of
+ * full textlines. Horizontal alignment always involves translations
+ * away from the book gutter.
+ *
+ * We have intentionally separated the process of building models
+ * from the rendering process that uses the models. For any page,
+ * the building operation either creates an actual model (that is,
+ * a model with at least the vertical disparity being computed, and
+ * for which the 'success' flag is set) or fails to create a model.
+ * However, at rendering time, a page can have one of two different
+ * types of models.
+ * (1) A valid model is an actual model that meets the rendering
+ * requirements, including whether a full model (horizontal
+ * and vertical disparity) is required, and limits on model
+ * curvatures. See dewarpaTestForValidModel() for details.
+ * Valid models are identified by dewarpaInsertRefModels(), which
+ * sets the 'valid' field. Only valid models are used for rendering.
+ * (2) A reference model is used by a page that doesn't have
+ * a valid model, but has a nearby valid model of the same
+ * parity (even/odd page) that it can use. The range to search
+ * for a valid model is given by the 'maxdist' field.
+ * A page may have neither a valid nor a reference model, in
+ * which case rendering simply copies the input image.
+ * By default, only the vertical disparity is required for
+ * an actual model ('fullmodel' = 0). The 'maxdist' parameter is
+ * input when the dewarpa is created. The other rendering parameters
+ * have default values given in dewarp.c. All parameters used by
+ * rendering can be set (or reset) using accessors.
+ *
+ * After dewarping, use of the vertical disparity will cause all
+ * points on each altered curve to have a y-value equal to the
+ * minimum. Use of horizontal disparity will cause the left
+ * and right edges of the textlines to be vertically aligned if
+ * they had been typeset flush-left and flush-right, respectively.
+ *
+ * The sampled disparity arrays are expanded to full resolution,
+ * using linear interpolation, and this is further expanded
+ * by slope continuation to the right and below if the image
+ * is larger than the full resolution disparity arrays. Then
+ * the disparity correction can be applied to the input image.
+ * If the input pix are 2x reduced, the expansion from sampled
+ * to full res uses the product of (sampling) * (redfactor).
+ *
+ * The most accurate results are produced at full resolution, and
+ * this is generally recommended.
+ */
+
+ /* Note on versioning of the serialization of this data structure:
+ * The dewarping utility and the stored data can be expected to change.
+ * In most situations, the serialized version is ephemeral -- it is
+ * not needed after being used. No functions will be provided to
+ * convert between different versions. */
+#define DEWARP_VERSION_NUMBER 2
+
+struct L_Dewarpa
+{
+ l_int32 nalloc; /* size of dewarp ptr array */
+ l_int32 maxpage; /* maximum page number in array */
+ struct L_Dewarp **dewarp; /* array of ptrs to page dewarp */
+ struct Numa *namodels; /* list of page numbers for pages */
+ /* with page models */
+ struct Numa *napages; /* list of page numbers with either */
+ /* page models or ref page models */
+ l_int32 redfactor; /* reduction factor of input: 1 or 2 */
+ l_int32 sampling; /* disparity arrays sampling factor */
+ l_int32 minlines; /* min number of long lines required */
+ l_int32 maxdist; /* max distance for getting ref pages */
+ l_int32 min_medcurv; /* minimum median abs line curvature, */
+ /* in micro-units */
+ l_int32 max_medcurv; /* maximum median abs line curvature, */
+ /* in micro-units */
+ l_int32 max_leftcurv; /* maximum left edge line curvature, */
+ /* in micro-units */
+ l_int32 max_rightcurv; /* maximum right edge line curvature, */
+ /* in micro-units */
+ l_int32 fullmodel; /* both disparity arrays required */
+ l_int32 modelsready; /* invalid models have been removed */
+ /* and refs built against valid set */
+};
+typedef struct L_Dewarpa L_DEWARPA;
+
+
+struct L_Dewarp
+{
+ struct Pix *pixs; /* source pix, 1 bpp */
+ struct Pix *pixd; /* dewarped pix; 1, 8 or 32 bpp */
+ struct FPix *sampvdispar; /* sampled vert disparity array */
+ struct FPix *samphdispar; /* sampled horiz disparity array */
+ struct FPix *fullvdispar; /* full vert disparity array */
+ struct FPix *fullhdispar; /* full horiz disparity array */
+ struct Numa *naflats; /* sorted flat location of each line */
+ struct Numa *nacurves; /* sorted curvature of each line */
+ l_int32 w; /* width of source image */
+ l_int32 h; /* height of source image */
+ l_int32 pageno; /* page number; important for reuse */
+ l_int32 sampling; /* sampling factor of disparity arrays */
+ l_int32 redfactor; /* reduction factor of pixs: 1 or 2 */
+ l_int32 minlines; /* min number of long lines required */
+ l_int32 nlines; /* number of long lines found */
+ l_int32 medcurv; /* median abs curvature in micro-units */
+ l_int32 leftcurv; /* left edge curvature in micro-units */
+ l_int32 rightcurv; /* right edge curvature in micro-units */
+ l_int32 nx; /* number of sampling pts in x direction */
+ l_int32 ny; /* number of sampling pts in y direction */
+ l_int32 hasref; /* 0 if normal; 1 if has a refpage */
+ l_int32 refpage; /* page with disparity model to use here */
+ l_int32 success; /* sets to 1 if model build succeeds */
+ l_int32 valid; /* sets to 1 if model is valid */
+ l_int32 debug; /* sets to 1 if debug output requested */
+};
+typedef struct L_Dewarp L_DEWARP;
+
+#endif /* LEPTONICA_DEWARP_H */
diff --git a/card.io/src/main/jni/leptonica/endianness.h b/card.io/src/main/jni/leptonica/endianness.h
new file mode 100644
index 00000000..e9eaba90
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/endianness.h
@@ -0,0 +1,11 @@
+#if !defined (L_BIG_ENDIAN) && !defined (L_LITTLE_ENDIAN)
+# if 0
+# ifdef __BIG_ENDIAN__
+# define L_BIG_ENDIAN
+# else
+# define L_LITTLE_ENDIAN
+# endif
+# else
+# define L_LITTLE_ENDIAN
+# endif
+#endif
diff --git a/card.io/src/main/jni/leptonica/environ.h b/card.io/src/main/jni/leptonica/environ.h
new file mode 100644
index 00000000..da2cbd99
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/environ.h
@@ -0,0 +1,292 @@
+/*====================================================================*
+ - 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_ENVIRON_H
+#define LEPTONICA_ENVIRON_H
+
+/*------------------------------------------------------------------------*
+ * Defines and includes differ for Unix and Windows. Also for Windows, *
+ * differentiate between conditionals based on platform and compiler. *
+ * For platforms: *
+ * _WIN32 => Windows, 32- or 64-bit *
+ * _WIN64 => Windows, 64-bit only *
+ * __CYGWIN__ => Cygwin *
+ * For compilers: *
+ * __GNUC__ => gcc *
+ * _MSC_VER => msvc *
+ *------------------------------------------------------------------------*/
+
+/* MS VC++ does not provide stdint.h, so define the missing types here */
+
+#ifndef _MSC_VER
+#include
+
+#else
+/* Note that _WIN32 is defined for both 32 and 64 bit applications,
+ whereas _WIN64 is defined only for the latter */
+
+#ifdef _WIN64
+typedef __int64 intptr_t;
+typedef unsigned __int64 uintptr_t;
+#else
+typedef int intptr_t;
+typedef unsigned int uintptr_t;
+#endif
+
+/* VC++6 doesn't seem to have powf, expf. */
+#if (_MSC_VER < 1400)
+#define powf(x, y) (float)pow((double)(x), (double)(y))
+#define expf(x) (float)exp((double)(x))
+#endif
+
+#endif /* _MSC_VER */
+
+/* Windows specifics */
+
+#ifdef _WIN32
+
+/* DLL EXPORTS and IMPORTS:
+ * Important: LEPTONLIB_* is deprected. It is retained here only for
+ * compatibility with tesseract 3.00. In your project files, use
+ * LIBLEPT_EXPORTS and LIBLEPT_IMPORTS */
+#if defined(LIBLEPT_EXPORTS) || defined(LEPTONLIB_EXPORTS)
+#define LEPT_DLL __declspec(dllexport)
+#elif defined(LIBLEPT_IMPORTS) || defined(LEPTONLIB_IMPORTS)
+#define LEPT_DLL __declspec(dllimport)
+#else
+#define LEPT_DLL
+#endif
+
+#else /* non-WINDOWS-SPECIFICS */
+#include
+#define LEPT_DLL
+#endif /* _WIN32 */
+
+typedef intptr_t l_intptr_t;
+typedef uintptr_t l_uintptr_t;
+typedef void *L_TIMER;
+
+
+/*--------------------------------------------------------------------*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
+ * USER CONFIGURABLE *
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
+ * Environ variables with I/O libraries *
+ * Manual Configuration Only: NOT AUTO_CONF *
+ *--------------------------------------------------------------------*/
+/*
+ * Leptonica provides interfaces to link to five external image I/O
+ * libraries, plus zlib. Setting any of these to 0 here causes
+ * non-functioning stubs to be linked.
+ */
+#ifndef HAVE_CONFIG_H
+#define HAVE_LIBJPEG 1
+#define HAVE_LIBTIFF 1
+#define HAVE_LIBPNG 1
+#define HAVE_LIBZ 1
+#define HAVE_LIBGIF 0
+#define HAVE_LIBUNGIF 0
+#define HAVE_LIBWEBP 0
+#endif /* ~HAVE_CONFIG_H */
+
+/*
+ * On linux systems, you can do I/O between Pix and memory. Specifically,
+ * you can compress (write compressed data to memory from a Pix) and
+ * uncompress (read from compressed data in memory to a Pix).
+ * For jpeg, png, pnm and bmp, these use the non-posix GNU functions
+ * fmemopen() and open_memstream(). These functions are not
+ * available on other systems. To use these functions in linux,
+ * you must define HAVE_FMEMOPEN to be 1 here.
+ */
+#ifndef HAVE_CONFIG_H
+#define HAVE_FMEMOPEN 0
+#endif /* ~HAVE_CONFIG_H */
+
+
+/*--------------------------------------------------------------------*
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
+ * USER CONFIGURABLE *
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
+ * Environ variables for uncompressed formatted image I/O *
+ *--------------------------------------------------------------------*/
+/*
+ * Leptonica supplies image I/O for pnm, bmp, ps, and pdf.
+ * Setting any of these to 0 causes non-functioning stubs to be linked.
+ */
+#define USE_BMPIO 1
+#define USE_PNMIO 1
+#define USE_PSIO 1
+#define USE_PDFIO 1
+
+
+/*--------------------------------------------------------------------*
+ * Built-in types *
+ *--------------------------------------------------------------------*/
+typedef signed char l_int8;
+typedef unsigned char l_uint8;
+typedef short l_int16;
+typedef unsigned short l_uint16;
+typedef int l_int32;
+typedef unsigned int l_uint32;
+typedef float l_float32;
+typedef double l_float64;
+
+
+/*------------------------------------------------------------------------*
+ * Standard macros *
+ *------------------------------------------------------------------------*/
+#ifndef L_MIN
+#define L_MIN(x,y) (((x) < (y)) ? (x) : (y))
+#endif
+
+#ifndef L_MAX
+#define L_MAX(x,y) (((x) > (y)) ? (x) : (y))
+#endif
+
+#ifndef L_ABS
+#define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
+#endif
+
+#ifndef L_SIGN
+#define L_SIGN(x) (((x) < 0) ? -1 : 1)
+#endif
+
+#ifndef UNDEF
+#define UNDEF -1
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+/*--------------------------------------------------------------------*
+ * Environ variables used within compiler invocation *
+ *--------------------------------------------------------------------*/
+/*
+ * To control conditional compilation, one of two variables
+ *
+ * L_LITTLE_ENDIAN (e.g., for Intel X86)
+ * L_BIG_ENDIAN (e.g., for Sun SPARC, Mac Power PC)
+ *
+ * is defined when the GCC compiler is invoked.
+ * All code should compile properly for both hardware architectures.
+ */
+
+
+/*------------------------------------------------------------------------*
+ * Simple search state variables *
+ *------------------------------------------------------------------------*/
+enum {
+ L_NOT_FOUND = 0,
+ L_FOUND = 1
+};
+
+
+/*------------------------------------------------------------------------*
+ * Standard memory allocation *
+ *
+ * These specify the memory management functions that are used
+ * on all heap data except for Pix. Memory management for Pix
+ * also defaults to malloc and free. See pix1.c for details.
+ *------------------------------------------------------------------------*/
+#define MALLOC(blocksize) malloc(blocksize)
+#define CALLOC(numelem, elemsize) calloc(numelem, elemsize)
+#define REALLOC(ptr, blocksize) realloc(ptr, blocksize)
+#define FREE(ptr) free(ptr)
+
+
+/*------------------------------------------------------------------------*
+ * Control printing of error, warning, and info messages *
+ * *
+ * (Use -DNO_CONSOLE_IO on compiler line to prevent text output) *
+ *------------------------------------------------------------------------*/
+#ifdef NO_CONSOLE_IO
+
+#define PROCNAME(name)
+#define ERROR_PTR(a,b,c) ((void *)(c))
+#define ERROR_INT(a,b,c) ((l_int32)(c))
+#define ERROR_FLOAT(a,b,c) ((l_float32)(c))
+#define L_ERROR(a,b)
+#define L_ERROR_STRING(a,b,c)
+#define L_ERROR_INT(a,b,c)
+#define L_ERROR_FLOAT(a,b,c)
+#define L_WARNING(a,b)
+#define L_WARNING_STRING(a,b,c)
+#define L_WARNING_INT(a,b,c)
+#define L_WARNING_INT2(a,b,c,d)
+#define L_WARNING_FLOAT(a,b,c)
+#define L_WARNING_FLOAT2(a,b,c,d)
+#define L_INFO(a,b)
+#define L_INFO_STRING(a,b,c)
+#define L_INFO_INT(a,b,c)
+#define L_INFO_INT2(a,b,c,d)
+#define L_INFO_FLOAT(a,b,c)
+#define L_INFO_FLOAT2(a,b,c,d)
+
+#else
+
+#define PROCNAME(name) static const char procName[] = name
+#define ERROR_PTR(a,b,c) returnErrorPtr((a),(b),(c))
+#define ERROR_INT(a,b,c) returnErrorInt((a),(b),(c))
+#define ERROR_FLOAT(a,b,c) returnErrorFloat((a),(b),(c))
+#define L_ERROR(a,b) l_error((a),(b))
+#define L_ERROR_STRING(a,b,c) l_errorString((a),(b),(c))
+#define L_ERROR_INT(a,b,c) l_errorInt((a),(b),(c))
+#define L_ERROR_FLOAT(a,b,c) l_errorFloat((a),(b),(c))
+#define L_WARNING(a,b) l_warning((a),(b))
+#define L_WARNING_STRING(a,b,c) l_warningString((a),(b),(c))
+#define L_WARNING_INT(a,b,c) l_warningInt((a),(b),(c))
+#define L_WARNING_INT2(a,b,c,d) l_warningInt2((a),(b),(c),(d))
+#define L_WARNING_FLOAT(a,b,c) l_warningFloat((a),(b),(c))
+#define L_WARNING_FLOAT2(a,b,c,d) l_warningFloat2((a),(b),(c),(d))
+#define L_INFO(a,b) l_info((a),(b))
+#define L_INFO_STRING(a,b,c) l_infoString((a),(b),(c))
+#define L_INFO_INT(a,b,c) l_infoInt((a),(b),(c))
+#define L_INFO_INT2(a,b,c,d) l_infoInt2((a),(b),(c),(d))
+#define L_INFO_FLOAT(a,b,c) l_infoFloat((a),(b),(c))
+#define L_INFO_FLOAT2(a,b,c,d) l_infoFloat2((a),(b),(c),(d))
+
+#endif /* NO_CONSOLE_IO */
+
+
+/*------------------------------------------------------------------------*
+ * snprintf() renamed in MSVC *
+ *------------------------------------------------------------------------*/
+#ifdef _MSC_VER
+#define snprintf(buf, size, ...) _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
+#endif
+
+
+#endif /* LEPTONICA_ENVIRON_H */
diff --git a/card.io/src/main/jni/leptonica/freetype.h b/card.io/src/main/jni/leptonica/freetype.h
new file mode 100644
index 00000000..17fa11a4
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/freetype.h
@@ -0,0 +1,23 @@
+/*====================================================================*
+ - Copyright (C) 2008 Leptonica. All rights reserved.
+ - This software is distributed in the hope that it will be
+ - useful, but with NO WARRANTY OF ANY KIND.
+ - No author or distributor accepts responsibility to anyone for the
+ - consequences of using this software, or for whether it serves any
+ - particular purpose or works at all, unless he or she says so in
+ - writing. Everyone is granted permission to copy, modify and
+ - redistribute this source code, for commercial or non-commercial
+ - purposes, with the following restrictions: (1) the origin of this
+ - source code must not be misrepresented; (2) modified versions must
+ - be plainly marked as such; and (3) this notice may not be removed
+ - or altered from any source or modified source distribution.
+ *====================================================================*/
+
+#ifndef LEPTONICA_FREETYPE_H
+#define LEPTONICA_FREETYPE_H
+
+#define LEPTONICA_FT_RESOLUTION 96
+
+typedef struct ft_library_st FT_LIBRARY;
+
+#endif /* LEPTONICA_FREETYPE_H */
diff --git a/card.io/src/main/jni/leptonica/gplot.h b/card.io/src/main/jni/leptonica/gplot.h
new file mode 100644
index 00000000..57460c09
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/gplot.h
@@ -0,0 +1,88 @@
+/*====================================================================*
+ - 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_GPLOT_H
+#define LEPTONICA_GPLOT_H
+
+/*
+ * gplot.h
+ *
+ * Data structures and parameters for generating gnuplot files
+ */
+
+#define GPLOT_VERSION_NUMBER 1
+
+#define NUM_GPLOT_STYLES 5
+enum GPLOT_STYLE {
+ GPLOT_LINES = 0,
+ GPLOT_POINTS = 1,
+ GPLOT_IMPULSES = 2,
+ GPLOT_LINESPOINTS = 3,
+ GPLOT_DOTS = 4
+};
+
+#define NUM_GPLOT_OUTPUTS 6
+enum GPLOT_OUTPUT {
+ GPLOT_NONE = 0,
+ GPLOT_PNG = 1,
+ GPLOT_PS = 2,
+ GPLOT_EPS = 3,
+ GPLOT_X11 = 4,
+ GPLOT_LATEX = 5
+};
+
+enum GPLOT_SCALING {
+ GPLOT_LINEAR_SCALE = 0, /* default */
+ GPLOT_LOG_SCALE_X = 1,
+ GPLOT_LOG_SCALE_Y = 2,
+ GPLOT_LOG_SCALE_X_Y = 3
+};
+
+extern const char *gplotstylenames[]; /* used in gnuplot cmd file */
+extern const char *gplotfilestyles[]; /* used in simple file input */
+extern const char *gplotfileoutputs[]; /* used in simple file input */
+
+struct GPlot
+{
+ char *rootname; /* for cmd, data, output */
+ char *cmdname; /* command file name */
+ struct Sarray *cmddata; /* command file contents */
+ struct Sarray *datanames; /* data file names */
+ struct Sarray *plotdata; /* plot data (1 string/file) */
+ struct Sarray *plottitles; /* title for each individual plot */
+ struct Numa *plotstyles; /* plot style for individual plots */
+ l_int32 nplots; /* current number of plots */
+ char *outname; /* output file name */
+ l_int32 outformat; /* GPLOT_OUTPUT values */
+ l_int32 scaling; /* GPLOT_SCALING values */
+ char *title; /* optional */
+ char *xlabel; /* optional x axis label */
+ char *ylabel; /* optional y axis label */
+};
+typedef struct GPlot GPLOT;
+
+
+#endif /* LEPTONICA_GPLOT_H */
diff --git a/card.io/src/main/jni/leptonica/heap.h b/card.io/src/main/jni/leptonica/heap.h
new file mode 100644
index 00000000..b5faf598
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/heap.h
@@ -0,0 +1,84 @@
+/*====================================================================*
+ - 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_HEAP_H
+#define LEPTONICA_HEAP_H
+
+/*
+ * heap.h
+ *
+ * Expandable priority queue configured as a heap for arbitrary void* data
+ *
+ * The L_Heap is used to implement a priority queue. The elements
+ * in the heap are ordered in either increasing or decreasing key value.
+ * The key is a float field 'keyval' that is required to be
+ * contained in the elements of the queue.
+ *
+ * The heap is a simple binary tree with the following constraints:
+ * - the key of each node is >= the keys of the two children
+ * - the tree is complete, meaning that each level (1, 2, 4, ...)
+ * is filled and the last level is filled from left to right
+ *
+ * The tree structure is implicit in the queue array, with the
+ * array elements numbered as a breadth-first search of the tree
+ * from left to right. It is thus guaranteed that the largest
+ * (or smallest) key belongs to the first element in the array.
+ *
+ * Heap sort is used to sort the array. Once an array has been
+ * sorted as a heap, it is convenient to use it as a priority queue,
+ * because the min (or max) elements are always at the root of
+ * the tree (element 0), and once removed, the heap can be
+ * resorted in not more than log[n] steps, where n is the number
+ * of elements on the heap. Likewise, if an arbitrary element is
+ * added to the end of the array A, the sorted heap can be restored
+ * in not more than log[n] steps.
+ *
+ * A L_Heap differs from a L_Queue in that the elements in the former
+ * are sorted by a key. Internally, the array is maintained
+ * as a queue, with a pointer to the end of the array. The
+ * head of the array always remains at array[0]. The array is
+ * maintained (sorted) as a heap. When an item is removed from
+ * the head, the last item takes its place (thus reducing the
+ * array length by 1), and this is followed by array element
+ * swaps to restore the heap property. When an item is added,
+ * it goes at the end of the array, and is swapped up to restore
+ * the heap. If the ptr array is full, adding another item causes
+ * the ptr array size to double.
+ *
+ * For further implementation details, see heap.c.
+ */
+
+struct L_Heap
+{
+ l_int32 nalloc; /* size of allocated ptr array */
+ l_int32 n; /* number of elements stored in the heap */
+ void **array; /* ptr array */
+ l_int32 direction; /* L_SORT_INCREASING or L_SORT_DECREASING */
+};
+typedef struct L_Heap L_HEAP;
+
+
+#endif /* LEPTONICA_HEAP_H */
diff --git a/card.io/src/main/jni/leptonica/imageio.h b/card.io/src/main/jni/leptonica/imageio.h
new file mode 100644
index 00000000..e3926725
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/imageio.h
@@ -0,0 +1,163 @@
+/*====================================================================*
+ - 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_IMAGEIO_H
+#define LEPTONICA_IMAGEIO_H
+
+/* ------------------ Image file format types -------------- */
+/*
+ * The IFF_DEFAULT flag is used to write the file out in the
+ * same (input) file format that the pix was read from. If the pix
+ * was not read from file, the input format field will be
+ * IFF_UNKNOWN and the output file format will be chosen to
+ * be compressed and lossless; namely, IFF_TIFF_G4 for d = 1
+ * and IFF_PNG for everything else. IFF_JP2 is for jpeg2000, which
+ * is not supported in leptonica.
+ *
+ * In the future, new format types that have defined extensions
+ * will be added before IFF_DEFAULT, and will be kept in sync with
+ * the file format extensions in writefile.c. The positions of
+ * file formats before IFF_DEFAULT will remain invariant.
+ */
+enum {
+ IFF_UNKNOWN = 0,
+ IFF_BMP = 1,
+ IFF_JFIF_JPEG = 2,
+ IFF_PNG = 3,
+ IFF_TIFF = 4,
+ IFF_TIFF_PACKBITS = 5,
+ IFF_TIFF_RLE = 6,
+ IFF_TIFF_G3 = 7,
+ IFF_TIFF_G4 = 8,
+ IFF_TIFF_LZW = 9,
+ IFF_TIFF_ZIP = 10,
+ IFF_PNM = 11,
+ IFF_PS = 12,
+ IFF_GIF = 13,
+ IFF_JP2 = 14,
+ IFF_WEBP = 15,
+ IFF_LPDF = 16,
+ IFF_DEFAULT = 17,
+ IFF_SPIX = 18
+};
+
+
+/* ---------------------- Format header ids --------------------- */
+enum {
+ BMP_ID = 0x4d42,
+ TIFF_BIGEND_ID = 0x4d4d, /* MM - for 'motorola' */
+ TIFF_LITTLEEND_ID = 0x4949 /* II - for 'intel' */
+};
+
+
+/* ------------------ Gray hinting in jpeg reader --------------- */
+enum {
+ L_HINT_GRAY = 1, /* only want grayscale information */
+};
+
+
+/* ------------------ Pdf formated encoding types --------------- */
+enum {
+ L_JPEG_ENCODE = 1, /* use dct encoding: 8 and 32 bpp, no cmap */
+ L_G4_ENCODE = 2, /* use ccitt g4 fax encoding: 1 bpp */
+ L_FLATE_ENCODE = 3 /* use flate encoding: any depth, cmap ok */
+};
+
+
+/* ------------------ Compressed image data --------------------- */
+/*
+ * In use, either datacomp or data85 will be produced, depending
+ * on whether the data needs to be ascii85 encoded. PostScript
+ * requires ascii85 encoding; pdf does not.
+ *
+ * For the colormap (flate compression only), PostScript uses ascii85
+ * encoding and pdf uses a bracketed array of space-separated
+ * hex-encoded rgb triples. Only tiff g4 (type == L_G4_ENCODE) uses
+ * the minisblack field.
+ */
+struct L_Compressed_Data
+{
+ l_int32 type; /* encoding type: L_JPEG_ENCODE, etc */
+ l_uint8 *datacomp; /* gzipped raster data */
+ size_t nbytescomp; /* number of compressed bytes */
+ char *data85; /* ascii85-encoded gzipped raster data */
+ size_t nbytes85; /* number of ascii85 encoded bytes */
+ char *cmapdata85; /* ascii85-encoded uncompressed cmap */
+ char *cmapdatahex; /* hex pdf array for the cmap */
+ l_int32 ncolors; /* number of colors in cmap */
+ l_int32 w; /* image width */
+ l_int32 h; /* image height */
+ l_int32 bps; /* bits/sample; typ. 1, 2, 4 or 8 */
+ l_int32 spp; /* samples/pixel; typ. 1 or 3 */
+ l_int32 minisblack; /* tiff g4 photometry */
+ size_t nbytes; /* number of uncompressed raster bytes */
+ l_int32 res; /* resolution (ppi) */
+};
+typedef struct L_Compressed_Data L_COMPRESSED_DATA;
+
+
+/* ------------------------ Pdf multi-image flags ------------------------ */
+enum {
+ L_FIRST_IMAGE = 1, /* first image to be used */
+ L_NEXT_IMAGE = 2, /* intermediate image; not first or last */
+ L_LAST_IMAGE = 3 /* last image to be used */
+};
+
+
+/* ------------------ Intermediate pdf generation data -------------------- */
+/*
+ * This accumulates data for generating a pdf of a single page consisting
+ * of an arbitrary number of images.
+ *
+ * None of the strings have a trailing newline.
+ */
+struct L_Pdf_Data
+{
+ char *title; /* optional title for pdf */
+ l_int32 n; /* number of images */
+ l_int32 ncmap; /* number of colormaps */
+ struct L_Ptra *cida; /* array of compressed image data */
+ char *id; /* %PDF-1.2 id string */
+ char *obj1; /* catalog string */
+ char *obj2; /* metadata string */
+ char *obj3; /* pages string */
+ char *obj4; /* page string (variable data) */
+ char *obj5; /* content string (variable data) */
+ char *poststream; /* post-binary-stream string */
+ char *trailer; /* trailer string (variable data) */
+ struct Pta *xy; /* store (xpt, ypt) array */
+ struct Pta *wh; /* store (wpt, hpt) array */
+ struct Box *mediabox; /* bounding region for all images */
+ struct Sarray *saprex; /* pre-binary-stream xobject strings */
+ struct Sarray *sacmap; /* colormap pdf object strings */
+ struct L_Dna *objsize; /* sizes of each pdf string object */
+ struct L_Dna *objloc; /* location of each pdf string object */
+ l_int32 xrefloc; /* location of xref */
+};
+typedef struct L_Pdf_Data L_PDF_DATA;
+
+
+#endif /* LEPTONICA_IMAGEIO_H */
diff --git a/card.io/src/main/jni/leptonica/jbclass.h b/card.io/src/main/jni/leptonica/jbclass.h
new file mode 100644
index 00000000..0a22ab33
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/jbclass.h
@@ -0,0 +1,133 @@
+/*====================================================================*
+ - 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_JBCLASS_H
+#define LEPTONICA_JBCLASS_H
+
+/*
+ * jbclass.h
+ *
+ * JbClasser
+ * JbData
+ */
+
+
+ /* The JbClasser struct holds all the data accumulated during the
+ * classification process that can be used for a compressed
+ * jbig2-type representation of a set of images. This is created
+ * in an initialization process and added to as the selected components
+ * on each successive page are analyzed. */
+struct JbClasser
+{
+ struct Sarray *safiles; /* input page image file names */
+ l_int32 method; /* JB_RANKHAUS, JB_CORRELATION */
+ l_int32 components; /* JB_CONN_COMPS, JB_CHARACTERS or */
+ /* JB_WORDS */
+ l_int32 maxwidth; /* max component width allowed */
+ l_int32 maxheight; /* max component height allowed */
+ l_int32 npages; /* number of pages already processed */
+ l_int32 baseindex; /* number of components already processed */
+ /* on fully processed pages */
+ struct Numa *nacomps; /* number of components on each page */
+ l_int32 sizehaus; /* size of square struct element for haus */
+ l_float32 rankhaus; /* rank val of haus match, each way */
+ l_float32 thresh; /* thresh value for correlation score */
+ l_float32 weightfactor; /* corrects thresh value for heaver */
+ /* components; use 0 for no correction */
+ struct Numa *naarea; /* w * h of each template, without extra */
+ /* border pixels */
+ l_int32 w; /* max width of original src images */
+ l_int32 h; /* max height of original src images */
+ l_int32 nclass; /* current number of classes */
+ l_int32 keep_pixaa; /* If zero, pixaa isn't filled */
+ struct Pixaa *pixaa; /* instances for each class; unbordered */
+ struct Pixa *pixat; /* templates for each class; bordered */
+ /* and not dilated */
+ struct Pixa *pixatd; /* templates for each class; bordered */
+ /* and dilated */
+ struct NumaHash *nahash; /* Hash table to find templates by size */
+ struct Numa *nafgt; /* fg areas of undilated templates; */
+ /* only used for rank < 1.0 */
+ struct Pta *ptac; /* centroids of all bordered cc */
+ struct Pta *ptact; /* centroids of all bordered template cc */
+ struct Numa *naclass; /* array of class ids for each component */
+ struct Numa *napage; /* array of page nums for each component */
+ struct Pta *ptaul; /* array of UL corners at which the */
+ /* template is to be placed for each */
+ /* component */
+ struct Pta *ptall; /* similar to ptaul, but for LL corners */
+};
+typedef struct JbClasser JBCLASSER;
+
+
+ /* The JbData struct holds all the data required for
+ * the compressed jbig-type representation of a set of images.
+ * The data can be written to file, read back, and used
+ * to regenerate an approximate version of the original,
+ * which differs in two ways from the original:
+ * (1) It uses a template image for each c.c. instead of the
+ * original instance, for each occurrence on each page.
+ * (2) It discards components with either a height or width larger
+ * than the maximuma, given here by the lattice dimensions
+ * used for storing the templates. */
+struct JbData
+{
+ struct Pix *pix; /* template composite for all classes */
+ l_int32 npages; /* number of pages */
+ l_int32 w; /* max width of original page images */
+ l_int32 h; /* max height of original page images */
+ l_int32 nclass; /* number of classes */
+ l_int32 latticew; /* lattice width for template composite */
+ l_int32 latticeh; /* lattice height for template composite */
+ struct Numa *naclass; /* array of class ids for each component */
+ struct Numa *napage; /* array of page nums for each component */
+ struct Pta *ptaul; /* array of UL corners at which the */
+ /* template is to be placed for each */
+ /* component */
+};
+typedef struct JbData JBDATA;
+
+
+ /* Classifier methods */
+enum {
+ JB_RANKHAUS = 0,
+ JB_CORRELATION = 1
+};
+
+ /* For jbGetComponents(): type of component to extract from images */
+enum {
+ JB_CONN_COMPS = 0,
+ JB_CHARACTERS = 1,
+ JB_WORDS = 2
+};
+
+ /* These parameters are used for naming the two files
+ * in which the jbig2-like compressed data is stored. */
+#define JB_TEMPLATE_EXT ".templates.png"
+#define JB_DATA_EXT ".data"
+
+
+#endif /* LEPTONICA_JBCLASS_H */
diff --git a/card.io/src/main/jni/leptonica/leptwin.h b/card.io/src/main/jni/leptonica/leptwin.h
new file mode 100644
index 00000000..451da6b6
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/leptwin.h
@@ -0,0 +1,45 @@
+/*====================================================================*
+ - 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.
+ *====================================================================*/
+
+#ifdef _WIN32
+#ifndef LEPTONICA_LEPTWIN_H
+#define LEPTONICA_LEPTWIN_H
+
+#include "allheaders.h"
+#include
+
+#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/card.io/src/main/jni/leptonica/list.h b/card.io/src/main/jni/leptonica/list.h
new file mode 100644
index 00000000..375e44be
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/list.h
@@ -0,0 +1,87 @@
+/*====================================================================*
+ - 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
+
+/*
+ * 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 macros */
+#define L_BEGIN_LIST_FORWARD(head, element) \
+ { \
+ DLLIST *_leptvar_nextelem_; \
+ for ((element) = (head); (element); (element) = _leptvar_nextelem_) { \
+ _leptvar_nextelem_ = (element)->next;
+
+
+#define L_BEGIN_LIST_REVERSE(tail, element) \
+ { \
+ DLLIST *_leptvar_prevelem_; \
+ for ((element) = (tail); (element); (element) = _leptvar_prevelem_) { \
+ _leptvar_prevelem_ = (element)->prev;
+
+
+#define L_END_LIST }}
+
+
+#endif /* LEPTONICA_LIST_H */
diff --git a/card.io/src/main/jni/leptonica/morph.h b/card.io/src/main/jni/leptonica/morph.h
new file mode 100644
index 00000000..ca2065af
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/morph.h
@@ -0,0 +1,229 @@
+/*====================================================================*
+ - 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
+
+/*
+ * 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
+ * color content flags
+ */
+
+/*-------------------------------------------------------------------------*
+ * Sel and Sel array *
+ *-------------------------------------------------------------------------*/
+#define SEL_VERSION_NUMBER 1
+
+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;
+
+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
+
+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.
+ *-------------------------------------------------------------------------*/
+enum {
+ SYMMETRIC_MORPH_BC = 0,
+ ASYMMETRIC_MORPH_BC = 1
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Structuring element types *
+ *-------------------------------------------------------------------------*/
+enum {
+ SEL_DONT_CARE = 0,
+ SEL_HIT = 1,
+ SEL_MISS = 2
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Runlength flags for granulometry *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_RUN_OFF = 0,
+ L_RUN_ON = 1
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Direction flags for grayscale morphology, granulometry, *
+ * composable Sels, and convolution *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_HORIZ = 1,
+ L_VERT = 2,
+ L_BOTH_DIRECTIONS = 3
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Morphological operation flags *
+ *-------------------------------------------------------------------------*/
+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 *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_LINEAR_SCALE = 1,
+ L_LOG_SCALE = 2
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Morphological tophat flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_TOPHAT_WHITE = 0,
+ L_TOPHAT_BLACK = 1
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Arithmetic and logical operator flags *
+ * (use on grayscale images and Numas) *
+ *-------------------------------------------------------------------------*/
+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 *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_CHOOSE_MIN = 1, /* useful in a downscaling "erosion" */
+ L_CHOOSE_MAX = 2, /* useful in a downscaling "dilation" */
+ L_CHOOSE_MAX_MIN_DIFF = 3 /* useful in a downscaling contrast */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Distance function b.c. flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_BOUNDARY_BG = 1, /* assume bg outside image */
+ L_BOUNDARY_FG = 2 /* assume fg outside image */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Image comparison flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_COMPARE_XOR = 1,
+ L_COMPARE_SUBTRACT = 2,
+ L_COMPARE_ABS_DIFF = 3
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Color content flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_MAX_DIFF_FROM_AVERAGE_2 = 1,
+ L_MAX_MIN_DIFF_FROM_2 = 2,
+ L_MAX_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/card.io/src/main/jni/leptonica/pix.h b/card.io/src/main/jni/leptonica/pix.h
new file mode 100644
index 00000000..332453eb
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/pix.h
@@ -0,0 +1,971 @@
+/*====================================================================*
+ - 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
+
+/*
+ * pix.h
+ *
+ * Contains the following structures:
+ * 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
+ *
+ * Contains definitions for:
+ * Colors for RGB
+ * 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 filtering flags
+ * Color component selection flags
+ * Rotation and shear flags
+ * Affine transform order flags
+ * Grayscale filling flags
+ * Flags for setting to white or black
+ * Dithering flags
+ * Distance flags
+ * Statistical measures
+ * Set selection flags
+ * Text orientation flags
+ * Edge orientation flags
+ * Line orientation flags
+ * Scan direction flags
+ * Box size adjustment flags
+ * Horizontal warp
+ * Pixel selection for resampling
+ * Thinning flags
+ * Runlength flags
+ * Edge filter flags
+ * Handling negative values in conversion to unsigned int
+ * Subpixel color component ordering in LCD display
+ * Relative to zero flags
+ * HSV histogram flags
+ * Region flags (inclusion, exclusion)
+ * Flags for adding text to a pix
+ * Flags for selecting display program
+ */
+
+
+/*-------------------------------------------------------------------------*
+ * Basic Pix *
+ *-------------------------------------------------------------------------*/
+struct Pix
+{
+ l_uint32 w; /* width in pixels */
+ l_uint32 h; /* height in pixels */
+ l_uint32 d; /* depth in bits */
+ l_uint32 wpl; /* 32-bit words/line */
+ l_uint32 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_* */
+ char *text; /* text string associated with pix */
+ struct PixColormap *colormap; /* colormap (may be null) */
+ l_uint32 *data; /* the image data */
+};
+typedef struct Pix 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 */
+};
+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). */
+struct RGBA_Quad
+{
+ l_uint8 blue;
+ l_uint8 green;
+ l_uint8 red;
+ l_uint8 reserved;
+};
+typedef struct RGBA_Quad RGBA_QUAD;
+
+
+
+/*-------------------------------------------------------------------------*
+ * Colors for 32 bpp *
+ *-------------------------------------------------------------------------*/
+/* 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 not explicitly used in leptonica.
+ * (2) If you redefine these values, functions that have the shifts
+ * hardcoded (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.
+ * Advice: Do not change these values!
+ * (3) The shifts to extract the red, green and blue components
+ * from a 32 bit pixel are defined in terms of these colors.
+ */
+enum {
+ COLOR_RED = 0,
+ COLOR_GREEN = 1,
+ COLOR_BLUE = 2,
+ L_ALPHA_CHANNEL = 3
+};
+
+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 */
+
+
+/*-------------------------------------------------------------------------*
+ * Perceptual color weights *
+ *-------------------------------------------------------------------------*/
+/* Notes:
+ * (1) These numbers are ad-hoc, but they do add up to 1.
+ * Unlike, for example, the weighting factor for conversion
+ * of 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.3;
+static const l_float32 L_GREEN_WEIGHT = 0.5;
+static const l_float32 L_BLUE_WEIGHT = 0.2;
+
+
+/*-------------------------------------------------------------------------*
+ * Flags for colormap conversion *
+ *-------------------------------------------------------------------------*/
+enum {
+ REMOVE_CMAP_TO_BINARY = 0,
+ REMOVE_CMAP_TO_GRAYSCALE = 1,
+ REMOVE_CMAP_TO_FULL_COLOR = 2,
+ REMOVE_CMAP_BASED_ON_SRC = 3
+};
+
+
+/*-------------------------------------------------------------------------*
+ *
+ * The following operation bit flags have been modified from
+ * Sun's pixrect.h.
+ *
+ * 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 would like to 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
+ *
+ * Now, 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.
+ *
+ * However, if you include Sun's xview package, you will get their
+ * definitions, and because I like using these flags, we will
+ * adopt the original Sun definitions to avoid redefinition conflicts.
+ *
+ * Then we have, for reference, the following 16 unique op flags:
+ *
+ * PIX_CLR 00000 0x0
+ * PIX_SET 11110 0x1e
+ * PIX_SRC 11000 0x18
+ * PIX_DST 10100 0x14
+ * PIX_NOT(PIX_SRC) 00110 0x06
+ * PIX_NOT(PIX_DST) 01010 0x0a
+ * PIX_SRC | PIX_DST 11100 0x1c
+ * PIX_SRC & PIX_DST 10000 0x10
+ * PIX_SRC ^ PIX_DST 01100 0x0c
+ * PIX_NOT(PIX_SRC) | PIX_DST 10110 0x16
+ * PIX_NOT(PIX_SRC) & PIX_DST 00100 0x04
+ * PIX_SRC | PIX_NOT(PIX_DST) 11010 0x1a
+ * PIX_SRC & PIX_NOT(PIX_DST) 01000 0x08
+ * PIX_NOT(PIX_SRC | PIX_DST) 00010 0x02
+ * PIX_NOT(PIX_SRC & PIX_DST) 01110 0x0e
+ * PIX_NOT(PIX_SRC ^ PIX_DST) 10010 0x12
+ *
+ *-------------------------------------------------------------------------*/
+#define PIX_SRC (0xc << 1)
+#define PIX_DST (0xa << 1)
+#define PIX_NOT(op) ((op) ^ 0x1e)
+#define PIX_CLR (0x0 << 1)
+#define PIX_SET (0xf << 1)
+
+#define PIX_PAINT (PIX_SRC | PIX_DST)
+#define PIX_MASK (PIX_SRC & PIX_DST)
+#define PIX_SUBTRACT (PIX_DST & PIX_NOT(PIX_SRC))
+#define PIX_XOR (PIX_SRC ^ PIX_DST)
+
+
+/*-------------------------------------------------------------------------*
+ *
+ * Important Notes:
+ *
+ * (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) For 24-bit color images, use 32 bpp data, leaving
+ * the fourth byte unused. Within each 4 byte pixel, the
+ * colors are ordered from MSB to LSB, as follows:
+ *
+ * | MSB | 2nd MSB | 3rd MSB | LSB |
+ * red green blue unused
+ * 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)
+ *
+ * This specific color assignment is made in this file,
+ * through the definitions of COLOR_RED, etc. Then the R, G
+ * and B 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);
+ * 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);
+ *
+ * For extra speed we extract the R, G and B colors directly
+ * by shifting and masking, explicitly using the values in
+ * L_RED_SHIFT, L_GREEN_SHIFT and L_BLUE_SHIFT:
+ * (pixel32 >> L_RED_SHIFT) & 0xff; (red)
+ * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
+ * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
+ * All these operations work properly on both big- and little-endians.
+ *
+ * For a few situations, these color shift values are hard-coded.
+ * Changing the RGB color component ordering through the assignments
+ * in this file will cause functions marked with "***" to fail.
+ *
+ * (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. Provision is currently made for
+ * backward compatibility in reading from boxaa version 2.
+ *
+ * (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
+ *
+ *-------------------------------------------------------------------------*/
+
+
+
+/*-------------------------------------------------------------------------*
+ * Array of pix *
+ *-------------------------------------------------------------------------*/
+
+ /* Serialization for primary data structures */
+#define PIXAA_VERSION_NUMBER 2
+#define PIXA_VERSION_NUMBER 2
+#define BOXA_VERSION_NUMBER 2
+#define BOXAA_VERSION_NUMBER 3
+
+
+struct Pixa
+{
+ l_int32 n; /* number of Pix in ptr array */
+ l_int32 nalloc; /* number of Pix ptrs allocated */
+ l_uint32 refcount; /* reference count (1 if no clones) */
+ struct Pix **pix; /* the array of ptrs to pix */
+ struct Boxa *boxa; /* array of boxes */
+};
+typedef struct Pixa PIXA;
+
+
+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 */
+};
+typedef struct Pixaa PIXAA;
+
+
+/*-------------------------------------------------------------------------*
+ * Basic rectangle and rectangle arrays *
+ *-------------------------------------------------------------------------*/
+struct Box
+{
+ l_int32 x;
+ l_int32 y;
+ l_int32 w;
+ l_int32 h;
+ l_uint32 refcount; /* reference count (1 if no clones) */
+
+};
+typedef struct Box BOX;
+
+struct Boxa
+{
+ l_int32 n; /* number of box in ptr array */
+ l_int32 nalloc; /* number of box ptrs allocated */
+ l_uint32 refcount; /* reference count (1 if no clones) */
+ struct Box **box; /* box ptr array */
+};
+typedef struct Boxa 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 */
+};
+typedef struct Boxaa BOXAA;
+
+
+/*-------------------------------------------------------------------------*
+ * Array of points *
+ *-------------------------------------------------------------------------*/
+#define PTA_VERSION_NUMBER 1
+
+struct Pta
+{
+ l_int32 n; /* actual number of pts */
+ l_int32 nalloc; /* size of allocated arrays */
+ l_uint32 refcount; /* reference count (1 if no clones) */
+ l_float32 *x, *y; /* arrays of floats */
+};
+typedef struct Pta 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 */
+};
+typedef struct Ptaa PTAA;
+
+
+/*-------------------------------------------------------------------------*
+ * 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 */
+};
+typedef struct Pixacc PIXACC;
+
+
+/*-------------------------------------------------------------------------*
+ * 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 */
+};
+typedef struct PixTiling PIXTILING;
+
+
+/*-------------------------------------------------------------------------*
+ * FPix: pix with float array *
+ *-------------------------------------------------------------------------*/
+#define FPIX_VERSION_NUMBER 2
+
+struct FPix
+{
+ l_int32 w; /* width in pixels */
+ l_int32 h; /* height in pixels */
+ l_int32 wpl; /* 32-bit words/line */
+ l_uint32 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 */
+};
+typedef struct FPix FPIX;
+
+
+struct FPixa
+{
+ l_int32 n; /* number of fpix in ptr array */
+ l_int32 nalloc; /* number of fpix ptrs allocated */
+ l_uint32 refcount; /* reference count (1 if no clones) */
+ struct FPix **fpix; /* the array of ptrs to fpix */
+};
+typedef struct FPixa FPIXA;
+
+
+/*-------------------------------------------------------------------------*
+ * DPix: pix with double array *
+ *-------------------------------------------------------------------------*/
+#define DPIX_VERSION_NUMBER 2
+
+struct DPix
+{
+ l_int32 w; /* width in pixels */
+ l_int32 h; /* height in pixels */
+ l_int32 wpl; /* 32-bit words/line */
+ l_uint32 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 */
+};
+typedef struct DPix DPIX;
+
+
+/*-------------------------------------------------------------------------*
+ * PixComp: 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 */
+};
+typedef struct PixComp PIXC;
+
+
+/*-------------------------------------------------------------------------*
+ * PixaComp: array of compressed pix *
+ *-------------------------------------------------------------------------*/
+#define PIXACOMP_VERSION_NUMBER 2
+
+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 */
+};
+typedef struct PixaComp PIXAC;
+
+
+/*-------------------------------------------------------------------------*
+ * 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. Safe to do unless you're changing
+ * data through one of the handles but don't want those
+ * changes to be seen by the other handle.)
+ *
+ * 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., that
+ * you don't own!). You must not free or insert such a string!
+ * Specifically, for an Sarray, the copyflag for retrieval is either:
+ * TRUE (or 1 or L_COPY)
+ * or
+ * FALSE (or 0 or L_NOCOPY)
+ * For insertion, the copyflag is either:
+ * TRUE (or 1 or L_COPY)
+ * or
+ * FALSE (or 0 or L_INSERT)
+ * Note that L_COPY is always 1, and L_INSERT and L_NOCOPY are always 0.
+ */
+enum {
+ L_INSERT = 0, /* stuff it in; no copy, clone or copy-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 object and fill with with clones */
+ /* of each object in the array(s) */
+};
+static const l_int32 L_NOCOPY = 0; /* copyflag value in sarrayGetString() */
+
+
+/*--------------------------------------------------------------------------*
+ * Sort flags *
+ *--------------------------------------------------------------------------*/
+enum {
+ L_SORT_INCREASING = 1, /* sort in increasing order */
+ L_SORT_DECREASING = 2 /* sort in decreasing order */
+};
+
+enum {
+ L_SORT_BY_X = 3, /* sort box or c.c. by horiz location */
+ L_SORT_BY_Y = 4, /* sort box or c.c. by vert 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 *
+ *-------------------------------------------------------------------------*/
+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 */
+};
+
+enum {
+ L_PAINT_LIGHT = 1, /* colorize non-black pixels */
+ L_PAINT_DARK = 2 /* colorize non-white pixels */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Graphics 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 filter flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_SELECT_WIDTH = 1, /* width must satisfy constraint */
+ L_SELECT_HEIGHT = 2, /* height must satisfy constraint */
+ L_SELECT_IF_EITHER = 3, /* either width or height can satisfy */
+ L_SELECT_IF_BOTH = 4 /* both width and height must satisfy */
+};
+
+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 */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Color component selection flags *
+ *-------------------------------------------------------------------------*/
+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 */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Rotate and shear flags *
+ *-------------------------------------------------------------------------*/
+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 */
+};
+
+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 */
+};
+
+enum {
+ L_SHEAR_ABOUT_CORNER = 1, /* shear image about UL corner */
+ L_SHEAR_ABOUT_CENTER = 2 /* shear image about center */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Affine transform order flags *
+ *-------------------------------------------------------------------------*/
+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 *
+ *-------------------------------------------------------------------------*/
+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 *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_SET_WHITE = 1, /* set pixels to white */
+ L_SET_BLACK = 2 /* set pixels to black */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Dither parameters *
+ * If within this grayscale distance from black or white, *
+ * do not propagate excess or deficit to neighboring pixels. *
+ *-------------------------------------------------------------------------*/
+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 flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_MANHATTAN_DISTANCE = 1, /* L1 distance (e.g., in color space) */
+ L_EUCLIDEAN_DISTANCE = 2 /* L2 distance */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Statistical measures *
+ *-------------------------------------------------------------------------*/
+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 selection flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_CHOOSE_CONSECUTIVE = 1, /* select 'n' consecutive */
+ L_CHOOSE_SKIP_BY = 2 /* select at intervals of 'n' */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Text orientation flags *
+ *-------------------------------------------------------------------------*/
+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 *
+ *-------------------------------------------------------------------------*/
+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 *
+ *-------------------------------------------------------------------------*/
+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 */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Scan direction flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_FROM_LEFT = 0, /* scan from left */
+ L_FROM_RIGHT = 1, /* scan from right */
+ L_FROM_TOP = 2, /* scan from top */
+ L_FROM_BOTTOM = 3 /* scan from bottom */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Box size adjustment flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_ADJUST_LEFT = 0, /* adjust left edge */
+ L_ADJUST_RIGHT = 1, /* adjust right edge */
+ L_ADJUST_LEFT_AND_RIGHT = 2, /* adjust both left and right edges */
+ L_ADJUST_TOP = 3, /* adjust top edge */
+ L_ADJUST_BOT = 4, /* adjust bottom edge */
+ L_ADJUST_TOP_AND_BOT = 5 /* adjust both top and bottom edges */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Horizontal warp *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_WARP_TO_LEFT = 1, /* increasing stretch or contraction to left */
+ L_WARP_TO_RIGHT = 2 /* increasing stretch or contraction to right */
+};
+
+enum {
+ L_LINEAR_WARP = 1, /* stretch or contraction grows linearly */
+ L_QUADRATIC_WARP = 2 /* stretch or contraction grows quadratically */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Pixel selection for resampling *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_INTERPOLATED = 1, /* linear interpolation from src pixels */
+ L_SAMPLED = 2 /* nearest src pixel sampling only */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Thinning flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_THIN_FG = 1, /* thin foreground of 1 bpp image */
+ L_THIN_BG = 2 /* thin background of 1 bpp image */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Runlength flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_HORIZONTAL_RUNS = 0, /* determine runlengths of horizontal runs */
+ L_VERTICAL_RUNS = 1 /* determine runlengths of vertical runs */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Edge filter flags *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_SOBEL_EDGE = 1, /* Sobel edge filter */
+ L_TWO_SIDED_EDGE = 2 /* Two-sided edge filter */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Handling negative values in conversion to unsigned int *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_CLIP_TO_ZERO = 1, /* Clip negative values to 0 */
+ L_TAKE_ABSVAL = 2 /* Convert to positive using L_ABS() */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Subpixel color component ordering in LCD display *
+ *-------------------------------------------------------------------------*/
+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 */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Relative to zero flags *
+ *-------------------------------------------------------------------------*/
+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 */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * HSV histogram flags *
+ *-------------------------------------------------------------------------*/
+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 */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Region flags (inclusion, exclusion) *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_INCLUDE_REGION = 1, /* Use hue-saturation histogram */
+ L_EXCLUDE_REGION = 2 /* Use hue-value histogram */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Flags for adding text to a pix *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_ADD_ABOVE = 1, /* Add text above the image */
+ L_ADD_AT_TOP = 2, /* Add text over the top of the image */
+ L_ADD_AT_BOTTOM = 3, /* Add text over the bottom of the image */
+ L_ADD_BELOW = 4 /* Add text below the image */
+};
+
+
+/*-------------------------------------------------------------------------*
+ * Flags for selecting display program *
+ *-------------------------------------------------------------------------*/
+enum {
+ L_DISPLAY_WITH_XV = 1, /* Use xv with pixDisplay() */
+ L_DISPLAY_WITH_XLI = 2, /* Use xli with pixDisplay() */
+ L_DISPLAY_WITH_XZGV = 3, /* Use xzgv with pixDisplay() */
+ L_DISPLAY_WITH_IV = 4 /* Use irfvanview with pixDisplay() */
+};
+
+#endif /* LEPTONICA_PIX_H */
diff --git a/card.io/src/main/jni/leptonica/ptra.h b/card.io/src/main/jni/leptonica/ptra.h
new file mode 100644
index 00000000..17ab2b20
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/ptra.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.
+ *====================================================================*/
+
+#ifndef LEPTONICA_PTRA_H
+#define LEPTONICA_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
+ */
+
+
+/*------------------------------------------------------------------------*
+ * 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;
+
+
+
+/*------------------------------------------------------------------------*
+ * Array flags *
+ *------------------------------------------------------------------------*/
+
+ /* Flags for removal from L_Ptra */
+enum {
+ L_NO_COMPACTION = 1, /* null the pointer only */
+ L_COMPACTION = 2 /* compact the array */
+};
+
+ /* Flags for insertion into L_Ptra */
+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 */
+};
+
+ /* Accessor flags for L_Ptraa */
+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/card.io/src/main/jni/leptonica/queue.h b/card.io/src/main/jni/leptonica/queue.h
new file mode 100644
index 00000000..581e5d4d
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/queue.h
@@ -0,0 +1,74 @@
+/*====================================================================*
+ - 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
+
+/*
+ * 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.
+ */
+
+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/card.io/src/main/jni/leptonica/readbarcode.h b/card.io/src/main/jni/leptonica/readbarcode.h
new file mode 100644
index 00000000..44ae29c1
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/readbarcode.h
@@ -0,0 +1,231 @@
+/*====================================================================*
+ - 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 *
+ * ----------------------------------------------------------------- */
+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. *
+ * ----------------------------------------------------------------- */
+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. *
+ * ----------------------------------------------------------------- */
+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
+};
+static const char *SupportedBarcodeFormatName[] = {
+ "Code2of5",
+ "CodeI2of5",
+ "Code93",
+ "Code39",
+ "Codabar",
+ "Upca",
+ "Ean13"
+};
+static const l_int32 NumSupportedBarcodeFormats = 7;
+
+
+ /* ----------------------------------------------------------------- *
+ * 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/card.io/src/main/jni/leptonica/regutils.h b/card.io/src/main/jni/leptonica/regutils.h
new file mode 100644
index 00000000..9d1e74ed
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/regutils.h
@@ -0,0 +1,133 @@
+/*====================================================================*
+ - 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
+
+/*
+ * 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".
+ *
+ * Such regression tests can be called in three ways.
+ * For example, for distance_reg:
+ *
+ * Case 1: distance_reg generate
+ * This generates golden files in /tmp for the reg test.
+ *
+ * Case 2: 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)
+ *
+ * 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. Using 'display' on the command line is optional.
+ *
+ * Regression tests follow the pattern given below. 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);
+ *
+ * // 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);
+ *
+ * // Generation of outputs and testing for identity
+ * // These files can be anything, of course.
+ * regTestCheckFile(rp, );
+ * regTestCheckFile(rp, );
+ *
+ * // Test pairs of output golden files for identity. Here we
+ * // are comparing golden files 4 and 5.
+ * regTestCompareFiles(rp, 4, 5);
+ *
+ * // "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);
+ * regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG);
+ *
+ * // 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 *
+ *-------------------------------------------------------------------------*/
+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 */
+enum {
+ L_REG_GENERATE = 0,
+ L_REG_COMPARE = 1,
+ L_REG_DISPLAY = 2
+};
+
+
+#endif /* LEPTONICA_REGUTILS_H */
+
diff --git a/card.io/src/main/jni/leptonica/stack.h b/card.io/src/main/jni/leptonica/stack.h
new file mode 100644
index 00000000..a200c53e
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/stack.h
@@ -0,0 +1,66 @@
+/*====================================================================*
+ - 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
+
+/*
+ * 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.
+ */
+
+
+ /* 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/card.io/src/main/jni/leptonica/sudoku.h b/card.io/src/main/jni/leptonica/sudoku.h
new file mode 100644
index 00000000..cd9f80ef
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/sudoku.h
@@ -0,0 +1,73 @@
+/*====================================================================*
+ - 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
+
+/*
+ * 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 */
+enum {
+ L_SUDOKU_INIT = 0,
+ L_SUDOKU_STATE = 1
+};
+
+#endif /* SUDOKU_H_INCLUDED */
+
+
diff --git a/card.io/src/main/jni/leptonica/watershed.h b/card.io/src/main/jni/leptonica/watershed.h
new file mode 100644
index 00000000..5350479b
--- /dev/null
+++ b/card.io/src/main/jni/leptonica/watershed.h
@@ -0,0 +1,63 @@
+/*====================================================================*
+ - 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
+
+/*
+ * watershed.h
+ *
+ * Simple data structure to hold watershed data.
+ * All data here is owned by the L_WShed and must be freed.
+ */
+
+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/card.io/src/main/jni/lib/arm64-v8a/libjpgt.so b/card.io/src/main/jni/lib/arm64-v8a/libjpgt.so
new file mode 100755
index 00000000..ed6f6f1c
Binary files /dev/null and b/card.io/src/main/jni/lib/arm64-v8a/libjpgt.so differ
diff --git a/card.io/src/main/jni/lib/arm64-v8a/liblept.so b/card.io/src/main/jni/lib/arm64-v8a/liblept.so
new file mode 100755
index 00000000..d1808953
Binary files /dev/null and b/card.io/src/main/jni/lib/arm64-v8a/liblept.so differ
diff --git a/card.io/src/main/jni/lib/arm64-v8a/libpngt.so b/card.io/src/main/jni/lib/arm64-v8a/libpngt.so
new file mode 100755
index 00000000..abb39b8c
Binary files /dev/null and b/card.io/src/main/jni/lib/arm64-v8a/libpngt.so differ
diff --git a/card.io/src/main/jni/lib/arm64-v8a/libtess.so b/card.io/src/main/jni/lib/arm64-v8a/libtess.so
new file mode 100755
index 00000000..96575704
Binary files /dev/null and b/card.io/src/main/jni/lib/arm64-v8a/libtess.so differ
diff --git a/card.io/src/main/jni/lib/armeabi-v7a/libjpgt.so b/card.io/src/main/jni/lib/armeabi-v7a/libjpgt.so
new file mode 100755
index 00000000..036a80a3
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi-v7a/libjpgt.so differ
diff --git a/card.io/src/main/jni/lib/armeabi-v7a/liblept.so b/card.io/src/main/jni/lib/armeabi-v7a/liblept.so
new file mode 100755
index 00000000..a2396436
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi-v7a/liblept.so differ
diff --git a/card.io/src/main/jni/lib/armeabi-v7a/libpngt.so b/card.io/src/main/jni/lib/armeabi-v7a/libpngt.so
new file mode 100755
index 00000000..077b7c66
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi-v7a/libpngt.so differ
diff --git a/card.io/src/main/jni/lib/armeabi-v7a/libtess.so b/card.io/src/main/jni/lib/armeabi-v7a/libtess.so
new file mode 100755
index 00000000..790417cc
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi-v7a/libtess.so differ
diff --git a/card.io/src/main/jni/lib/armeabi/libjpgt.so b/card.io/src/main/jni/lib/armeabi/libjpgt.so
new file mode 100755
index 00000000..1d63d6fd
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi/libjpgt.so differ
diff --git a/card.io/src/main/jni/lib/armeabi/liblept.so b/card.io/src/main/jni/lib/armeabi/liblept.so
new file mode 100755
index 00000000..ad1f76c2
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi/liblept.so differ
diff --git a/card.io/src/main/jni/lib/armeabi/libpngt.so b/card.io/src/main/jni/lib/armeabi/libpngt.so
new file mode 100755
index 00000000..92656b66
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi/libpngt.so differ
diff --git a/card.io/src/main/jni/lib/armeabi/libtess.so b/card.io/src/main/jni/lib/armeabi/libtess.so
new file mode 100755
index 00000000..2b820a36
Binary files /dev/null and b/card.io/src/main/jni/lib/armeabi/libtess.so differ
diff --git a/card.io/src/main/jni/lib/mips/libjpgt.so b/card.io/src/main/jni/lib/mips/libjpgt.so
new file mode 100755
index 00000000..d88e2b69
Binary files /dev/null and b/card.io/src/main/jni/lib/mips/libjpgt.so differ
diff --git a/card.io/src/main/jni/lib/mips/liblept.so b/card.io/src/main/jni/lib/mips/liblept.so
new file mode 100755
index 00000000..7743a8ab
Binary files /dev/null and b/card.io/src/main/jni/lib/mips/liblept.so differ
diff --git a/card.io/src/main/jni/lib/mips/libpngt.so b/card.io/src/main/jni/lib/mips/libpngt.so
new file mode 100755
index 00000000..b15198c5
Binary files /dev/null and b/card.io/src/main/jni/lib/mips/libpngt.so differ
diff --git a/card.io/src/main/jni/lib/mips/libtess.so b/card.io/src/main/jni/lib/mips/libtess.so
new file mode 100755
index 00000000..7373d24d
Binary files /dev/null and b/card.io/src/main/jni/lib/mips/libtess.so differ
diff --git a/card.io/src/main/jni/lib/mips64/libjpgt.so b/card.io/src/main/jni/lib/mips64/libjpgt.so
new file mode 100755
index 00000000..8d63f7ef
Binary files /dev/null and b/card.io/src/main/jni/lib/mips64/libjpgt.so differ
diff --git a/card.io/src/main/jni/lib/mips64/liblept.so b/card.io/src/main/jni/lib/mips64/liblept.so
new file mode 100755
index 00000000..47038fb8
Binary files /dev/null and b/card.io/src/main/jni/lib/mips64/liblept.so differ
diff --git a/card.io/src/main/jni/lib/mips64/libpngt.so b/card.io/src/main/jni/lib/mips64/libpngt.so
new file mode 100755
index 00000000..e73076bc
Binary files /dev/null and b/card.io/src/main/jni/lib/mips64/libpngt.so differ
diff --git a/card.io/src/main/jni/lib/mips64/libtess.so b/card.io/src/main/jni/lib/mips64/libtess.so
new file mode 100755
index 00000000..d9285668
Binary files /dev/null and b/card.io/src/main/jni/lib/mips64/libtess.so differ
diff --git a/card.io/src/main/jni/lib/x86/libjpgt.so b/card.io/src/main/jni/lib/x86/libjpgt.so
new file mode 100755
index 00000000..9f1ebbcb
Binary files /dev/null and b/card.io/src/main/jni/lib/x86/libjpgt.so differ
diff --git a/card.io/src/main/jni/lib/x86/liblept.so b/card.io/src/main/jni/lib/x86/liblept.so
new file mode 100755
index 00000000..69961bad
Binary files /dev/null and b/card.io/src/main/jni/lib/x86/liblept.so differ
diff --git a/card.io/src/main/jni/lib/x86/libpngt.so b/card.io/src/main/jni/lib/x86/libpngt.so
new file mode 100755
index 00000000..87f2a7cd
Binary files /dev/null and b/card.io/src/main/jni/lib/x86/libpngt.so differ
diff --git a/card.io/src/main/jni/lib/x86/libtess.so b/card.io/src/main/jni/lib/x86/libtess.so
new file mode 100755
index 00000000..5cb68379
Binary files /dev/null and b/card.io/src/main/jni/lib/x86/libtess.so differ
diff --git a/card.io/src/main/jni/lib/x86_64/libjpgt.so b/card.io/src/main/jni/lib/x86_64/libjpgt.so
new file mode 100755
index 00000000..27f07400
Binary files /dev/null and b/card.io/src/main/jni/lib/x86_64/libjpgt.so differ
diff --git a/card.io/src/main/jni/lib/x86_64/liblept.so b/card.io/src/main/jni/lib/x86_64/liblept.so
new file mode 100755
index 00000000..8289ac2d
Binary files /dev/null and b/card.io/src/main/jni/lib/x86_64/liblept.so differ
diff --git a/card.io/src/main/jni/lib/x86_64/libpngt.so b/card.io/src/main/jni/lib/x86_64/libpngt.so
new file mode 100755
index 00000000..a6f20938
Binary files /dev/null and b/card.io/src/main/jni/lib/x86_64/libpngt.so differ
diff --git a/card.io/src/main/jni/lib/x86_64/libtess.so b/card.io/src/main/jni/lib/x86_64/libtess.so
new file mode 100755
index 00000000..6b0e337f
Binary files /dev/null and b/card.io/src/main/jni/lib/x86_64/libtess.so differ
diff --git a/card.io/src/main/jni/nativeRecognizer.cpp b/card.io/src/main/jni/nativeRecognizer.cpp
index ef176b88..2e3b520a 100644
--- a/card.io/src/main/jni/nativeRecognizer.cpp
+++ b/card.io/src/main/jni/nativeRecognizer.cpp
@@ -18,6 +18,7 @@
#include "cv/warp.h"
#include "scan/scan.h"
+#include
#define DEBUG_TAG "card.io native"
@@ -164,9 +165,13 @@ JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nSetup__ZFI(JNIEnv *env,
if (dmz == NULL) {
dmz = dmz_context_create();
scanner_initialize(&scannerState);
+ //Set this string to match your package name!
+ setenv("TESSDATA_PREFIX","/storage/emulated/0/Android/data/org.my.scanExample.debug/files/Tesseract/",1);
+ ocre_scanner_init();
}
else {
scanner_reset(&scannerState);
+ ocre_scanner_reset();
}
dmz_refcount++;
@@ -359,8 +364,9 @@ JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nScanFrame(JNIEnv *env,
result.focus_score = focusScore;
result.flipped = flipped;
scanner_add_frame_with_expiry(&scannerState, cardY, jScanExpiry, &result);
+ ScannerResult scanResult;
if (result.usable) {
- ScannerResult scanResult;
+
scanner_result(&scannerState, &scanResult);
if (scanResult.complete) {
@@ -368,9 +374,32 @@ JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nScanFrame(JNIEnv *env,
logDinfo(env, dinfo);
}
}
- else if (result.upside_down) {
+ else if(result.upside_down) {
flipped = !flipped;
}
+ if(result.focus_score >= 9.0f && !result.usable && !flipped) {
+ ocre_scanner_scan(cardY);
+ if(ocre_scanner_complete()) {
+ ScannerResult * scannerResult = (ScannerResult*)malloc(sizeof(ScannerResult));
+ scannerResult->n_numbers = 16;
+ char* cardNumber = ocre_scanner_result();
+
+ for(int i = 0; i < scannerResult->n_numbers; i++) {
+ scannerResult->predictions[i] = cardNumber[i] - '0';
+ }
+
+ scannerResult->expiry_month = 0;
+ scannerResult->expiry_year = 0;
+ scannerResult->complete = true;
+ scannerState.timeOfCardNumberCompletionInMilliseconds = 1;
+ scannerState.successfulCardNumberResult = *scannerResult;
+ result.usable = true;
+ scanner_result(&scannerState, &scanResult);
+ setScanCardNumberResult(env, dinfo, &scanResult);
+ logDinfo(env, dinfo);
+ ocre_scanner_reset();
+ }
+ }
}
setDetectedCardImage(env, jCardResultBitmap, cardY, cb, cr, corner_points, orientation);
diff --git a/card.io/src/main/jni/tesseract/apitypes.h b/card.io/src/main/jni/tesseract/apitypes.h
new file mode 100644
index 00000000..2cb38add
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/apitypes.h
@@ -0,0 +1,33 @@
+///////////////////////////////////////////////////////////////////////
+// File: apitypes.h
+// Description: Types used in both the API and internally
+// Author: Ray Smith
+// Created: Wed Mar 03 09:22:53 PST 2010
+//
+// (C) Copyright 2010, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef TESSERACT_API_APITYPES_H__
+#define TESSERACT_API_APITYPES_H__
+
+#include "publictypes.h"
+
+// The types used by the API and Page/ResultIterator can be found in:
+// ccstruct/publictypes.h
+// ccmain/resultiterator.h
+// ccmain/pageiterator.h
+// API interfaces and API users should be sure to include this file, rather
+// than the lower-level one, and lower-level code should be sure to include
+// only the lower-level file.
+
+#endif // TESSERACT_API_APITYPES_H__
diff --git a/card.io/src/main/jni/tesseract/baseapi.h b/card.io/src/main/jni/tesseract/baseapi.h
new file mode 100644
index 00000000..a52c41de
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/baseapi.h
@@ -0,0 +1,793 @@
+///////////////////////////////////////////////////////////////////////
+// File: baseapi.h
+// Description: Simple API for calling tesseract.
+// Author: Ray Smith
+// Created: Fri Oct 06 15:35:01 PDT 2006
+//
+// (C) Copyright 2006, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef TESSERACT_API_BASEAPI_H__
+#define TESSERACT_API_BASEAPI_H__
+
+#include
+// To avoid collision with other typenames include the ABSOLUTE MINIMUM
+// complexity of includes here. Use forward declarations wherever possible
+// and hide includes of complex types in baseapi.cpp.
+#include "platform.h"
+#include "apitypes.h"
+#include "thresholder.h"
+#include "unichar.h"
+#include "tesscallback.h"
+#include "publictypes.h"
+#include "pageiterator.h"
+#include "resultiterator.h"
+
+template class GenericVector;
+class PAGE_RES;
+class PAGE_RES_IT;
+class ParagraphModel;
+class BlamerBundle;
+class BLOCK_LIST;
+class DENORM;
+class IMAGE;
+class MATRIX;
+class PBLOB;
+class ROW;
+class STRING;
+class WERD;
+struct Pix;
+struct Box;
+struct Pixa;
+struct Boxa;
+class ETEXT_DESC;
+struct OSResults;
+class TBOX;
+class UNICHARSET;
+
+// From oldlist.h
+// TODO(antonova): remove when oldlist is deprecated.
+struct list_rec;
+typedef list_rec *LIST;
+
+#define MAX_NUM_INT_FEATURES 512
+struct INT_FEATURE_STRUCT;
+typedef INT_FEATURE_STRUCT *INT_FEATURE;
+typedef INT_FEATURE_STRUCT INT_FEATURE_ARRAY[MAX_NUM_INT_FEATURES];
+struct TBLOB;
+
+namespace tesseract {
+
+class CubeRecoContext;
+class Dawg;
+class Dict;
+class EquationDetect;
+class LTRResultIterator;
+class MutableIterator;
+class Tesseract;
+class Trie;
+class Wordrec;
+
+typedef int (Dict::*DictFunc)(void* void_dawg_args,
+ UNICHAR_ID unichar_id, bool word_end) const;
+typedef double (Dict::*ProbabilityInContextFunc)(const char* lang,
+ const char* context,
+ int context_bytes,
+ const char* character,
+ int character_bytes);
+typedef void (Wordrec::*FillLatticeFunc)(const MATRIX &ratings,
+ const LIST &best_choices,
+ const UNICHARSET &unicharset,
+ BlamerBundle *blamer_bundle);
+typedef TessCallback3 TruthCallback;
+
+/**
+ * Base class for all tesseract APIs.
+ * Specific classes can add ability to work on different inputs or produce
+ * different outputs.
+ * This class is mostly an interface layer on top of the Tesseract instance
+ * class to hide the data types so that users of this class don't have to
+ * include any other Tesseract headers.
+ */
+class TESS_API TessBaseAPI {
+ public:
+ TessBaseAPI();
+ virtual ~TessBaseAPI();
+
+ /**
+ * Returns the version identifier as a static string. Do not delete.
+ */
+ static const char* Version();
+
+ /**
+ * Set the name of the input file. Needed only for training and
+ * reading a UNLV zone file.
+ */
+ void SetInputName(const char* name);
+
+ /** Set the name of the bonus output files. Needed only for debugging. */
+ void SetOutputName(const char* name);
+
+ /**
+ * Set the value of an internal "parameter."
+ * Supply the name of the parameter and the value as a string, just as
+ * you would in a config file.
+ * Returns false if the name lookup failed.
+ * Eg SetVariable("tessedit_char_blacklist", "xyz"); to ignore x, y and z.
+ * Or SetVariable("classify_bln_numeric_mode", "1"); to set numeric-only mode.
+ * SetVariable may be used before Init, but settings will revert to
+ * defaults on End().
+ * TODO(rays) Add a command-line option to dump the parameters to stdout
+ * and add a pointer to it in the FAQ
+ *
+ * Note: Must be called after Init(). Only works for non-init variables
+ * (init variables should be passed to Init()).
+ */
+ bool SetVariable(const char* name, const char* value);
+ bool SetDebugVariable(const char* name, const char* value);
+
+ /**
+ * Returns true if the parameter was found among Tesseract parameters.
+ * Fills in value with the value of the parameter.
+ */
+ bool GetIntVariable(const char *name, int *value) const;
+ bool GetBoolVariable(const char *name, bool *value) const;
+ bool GetDoubleVariable(const char *name, double *value) const;
+
+ /**
+ * Returns the pointer to the string that represents the value of the
+ * parameter if it was found among Tesseract parameters.
+ */
+ const char *GetStringVariable(const char *name) const;
+
+ /**
+ * Print Tesseract parameters to the given file.
+ */
+ void PrintVariables(FILE *fp) const;
+
+ /**
+ * Get value of named variable as a string, if it exists.
+ */
+ bool GetVariableAsString(const char *name, STRING *val);
+
+ /**
+ * Instances are now mostly thread-safe and totally independent,
+ * but some global parameters remain. Basically it is safe to use multiple
+ * TessBaseAPIs in different threads in parallel, UNLESS:
+ * you use SetVariable on some of the Params in classify and textord.
+ * If you do, then the effect will be to change it for all your instances.
+ *
+ * Start tesseract. Returns zero on success and -1 on failure.
+ * NOTE that the only members that may be called before Init are those
+ * listed above here in the class definition.
+ *
+ * The datapath must be the name of the parent directory of tessdata and
+ * must end in / . Any name after the last / will be stripped.
+ * The language is (usually) an ISO 639-3 string or NULL will default to eng.
+ * It is entirely safe (and eventually will be efficient too) to call
+ * Init multiple times on the same instance to change language, or just
+ * to reset the classifier.
+ * The language may be a string of the form [~][+[~]]* indicating
+ * that multiple languages are to be loaded. Eg hin+eng will load Hindi and
+ * English. Languages may specify internally that they want to be loaded
+ * with one or more other languages, so the ~ sign is available to override
+ * that. Eg if hin were set to load eng by default, then hin+~eng would force
+ * loading only hin. The number of loaded languages is limited only by
+ * memory, with the caveat that loading additional languages will impact
+ * both speed and accuracy, as there is more work to do to decide on the
+ * applicable language, and there is more chance of hallucinating incorrect
+ * words.
+ * WARNING: On changing languages, all Tesseract parameters are reset
+ * back to their default values. (Which may vary between languages.)
+ * If you have a rare need to set a Variable that controls
+ * initialization for a second call to Init you should explicitly
+ * call End() and then use SetVariable before Init. This is only a very
+ * rare use case, since there are very few uses that require any parameters
+ * to be set before Init.
+ *
+ * If set_only_non_debug_params is true, only params that do not contain
+ * "debug" in the name will be set.
+ */
+ int Init(const char* datapath, const char* language, OcrEngineMode mode,
+ char **configs, int configs_size,
+ const GenericVector *vars_vec,
+ const GenericVector *vars_values,
+ bool set_only_non_debug_params);
+ int Init(const char* datapath, const char* language, OcrEngineMode oem) {
+ return Init(datapath, language, oem, NULL, 0, NULL, NULL, false);
+ }
+ int Init(const char* datapath, const char* language) {
+ return Init(datapath, language, OEM_DEFAULT, NULL, 0, NULL, NULL, false);
+ }
+
+ /**
+ * Returns the languages string used in the last valid initialization.
+ * If the last initialization specified "deu+hin" then that will be
+ * returned. If hin loaded eng automatically as well, then that will
+ * not be included in this list. To find the languages actually
+ * loaded use GetLoadedLanguagesAsVector.
+ * The returned string should NOT be deleted.
+ */
+ const char* GetInitLanguagesAsString() const;
+
+ /**
+ * Returns the loaded languages in the vector of STRINGs.
+ * Includes all languages loaded by the last Init, including those loaded
+ * as dependencies of other loaded languages.
+ */
+ void GetLoadedLanguagesAsVector(GenericVector* langs) const;
+
+ /**
+ * Returns the available languages in the vector of STRINGs.
+ */
+ void GetAvailableLanguagesAsVector(GenericVector* langs) const;
+
+ /**
+ * Init only the lang model component of Tesseract. The only functions
+ * that work after this init are SetVariable and IsValidWord.
+ * WARNING: temporary! This function will be removed from here and placed
+ * in a separate API at some future time.
+ */
+ int InitLangMod(const char* datapath, const char* language);
+
+ /**
+ * Init only for page layout analysis. Use only for calls to SetImage and
+ * AnalysePage. Calls that attempt recognition will generate an error.
+ */
+ void InitForAnalysePage();
+
+ /**
+ * Read a "config" file containing a set of param, value pairs.
+ * Searches the standard places: tessdata/configs, tessdata/tessconfigs
+ * and also accepts a relative or absolute path name.
+ * Note: only non-init params will be set (init params are set by Init()).
+ */
+ void ReadConfigFile(const char* filename);
+ /** Same as above, but only set debug params from the given config file. */
+ void ReadDebugConfigFile(const char* filename);
+
+ /**
+ * Set the current page segmentation mode. Defaults to PSM_SINGLE_BLOCK.
+ * The mode is stored as an IntParam so it can also be modified by
+ * ReadConfigFile or SetVariable("tessedit_pageseg_mode", mode as string).
+ */
+ void SetPageSegMode(PageSegMode mode);
+
+ /** Return the current page segmentation mode. */
+ PageSegMode GetPageSegMode() const;
+
+ /**
+ * Recognize a rectangle from an image and return the result as a string.
+ * May be called many times for a single Init.
+ * Currently has no error checking.
+ * Greyscale of 8 and color of 24 or 32 bits per pixel may be given.
+ * Palette color images will not work properly and must be converted to
+ * 24 bit.
+ * Binary images of 1 bit per pixel may also be given but they must be
+ * byte packed with the MSB of the first byte being the first pixel, and a
+ * 1 represents WHITE. For binary images set bytes_per_pixel=0.
+ * The recognized text is returned as a char* which is coded
+ * as UTF8 and must be freed with the delete [] operator.
+ *
+ * Note that TesseractRect is the simplified convenience interface.
+ * For advanced uses, use SetImage, (optionally) SetRectangle, Recognize,
+ * and one or more of the Get*Text functions below.
+ */
+ char* TesseractRect(const unsigned char* imagedata,
+ int bytes_per_pixel, int bytes_per_line,
+ int left, int top, int width, int height);
+
+ /**
+ * Call between pages or documents etc to free up memory and forget
+ * adaptive data.
+ */
+ void ClearAdaptiveClassifier();
+
+ /**
+ * @defgroup AdvancedAPI Advanced API
+ * The following methods break TesseractRect into pieces, so you can
+ * get hold of the thresholded image, get the text in different formats,
+ * get bounding boxes, confidences etc.
+ */
+ /* @{ */
+
+ /**
+ * Provide an image for Tesseract to recognize. Format is as
+ * TesseractRect above. Does not copy the image buffer, or take
+ * ownership. The source image may be destroyed after Recognize is called,
+ * either explicitly or implicitly via one of the Get*Text functions.
+ * SetImage clears all recognition results, and sets the rectangle to the
+ * full image, so it may be followed immediately by a GetUTF8Text, and it
+ * will automatically perform recognition.
+ */
+ void SetImage(const unsigned char* imagedata, int width, int height,
+ int bytes_per_pixel, int bytes_per_line);
+
+ /**
+ * Provide an image for Tesseract to recognize. As with SetImage above,
+ * Tesseract doesn't take a copy or ownership or pixDestroy the image, so
+ * it must persist until after Recognize.
+ * Pix vs raw, which to use?
+ * Use Pix where possible. A future version of Tesseract may choose to use Pix
+ * as its internal representation and discard IMAGE altogether.
+ * Because of that, an implementation that sources and targets Pix may end up
+ * with less copies than an implementation that does not.
+ */
+ void SetImage(const Pix* pix);
+
+ /**
+ * Set the resolution of the source image in pixels per inch so font size
+ * information can be calculated in results. Call this after SetImage().
+ */
+ void SetSourceResolution(int ppi);
+
+ /**
+ * Restrict recognition to a sub-rectangle of the image. Call after SetImage.
+ * Each SetRectangle clears the recogntion results so multiple rectangles
+ * can be recognized with the same image.
+ */
+ void SetRectangle(int left, int top, int width, int height);
+
+ /**
+ * In extreme cases only, usually with a subclass of Thresholder, it
+ * is possible to provide a different Thresholder. The Thresholder may
+ * be preloaded with an image, settings etc, or they may be set after.
+ * Note that Tesseract takes ownership of the Thresholder and will
+ * delete it when it it is replaced or the API is destructed.
+ */
+ void SetThresholder(ImageThresholder* thresholder) {
+ if (thresholder_ != NULL)
+ delete thresholder_;
+ thresholder_ = thresholder;
+ ClearResults();
+ }
+
+ /**
+ * Get a copy of the internal thresholded image from Tesseract.
+ * Caller takes ownership of the Pix and must pixDestroy it.
+ * May be called any time after SetImage, or after TesseractRect.
+ */
+ Pix* GetThresholdedImage();
+
+ /**
+ * Get the result of page layout analysis as a leptonica-style
+ * Boxa, Pixa pair, in reading order.
+ * Can be called before or after Recognize.
+ */
+ Boxa* GetRegions(Pixa** pixa);
+
+ /**
+ * Get the textlines as a leptonica-style
+ * Boxa, Pixa pair, in reading order.
+ * Can be called before or after Recognize.
+ * If blockids is not NULL, the block-id of each line is also returned
+ * as an array of one element per line. delete [] after use.
+ */
+ Boxa* GetTextlines(Pixa** pixa, int** blockids);
+
+ /**
+ * Get textlines and strips of image regions as a leptonica-style Boxa, Pixa
+ * pair, in reading order. Enables downstream handling of non-rectangular
+ * regions.
+ * Can be called before or after Recognize.
+ * If blockids is not NULL, the block-id of each line is also returned as an
+ * array of one element per line. delete [] after use.
+ */
+ Boxa* GetStrips(Pixa** pixa, int** blockids);
+
+ /**
+ * Get the words as a leptonica-style
+ * Boxa, Pixa pair, in reading order.
+ * Can be called before or after Recognize.
+ */
+ Boxa* GetWords(Pixa** pixa);
+
+ /**
+ * Gets the individual connected (text) components (created
+ * after pages segmentation step, but before recognition)
+ * as a leptonica-style Boxa, Pixa pair, in reading order.
+ * Can be called before or after Recognize.
+ * Note: the caller is responsible for calling boxaDestroy()
+ * on the returned Boxa array and pixaDestroy() on cc array.
+ */
+ Boxa* GetConnectedComponents(Pixa** cc);
+
+ /**
+ * Get the given level kind of components (block, textline, word etc.) as a
+ * leptonica-style Boxa, Pixa pair, in reading order.
+ * Can be called before or after Recognize.
+ * If blockids is not NULL, the block-id of each component is also returned
+ * as an array of one element per component. delete [] after use.
+ * If text_only is true, then only text components are returned.
+ */
+ Boxa* GetComponentImages(PageIteratorLevel level,
+ bool text_only,
+ Pixa** pixa, int** blockids);
+
+ /**
+ * Returns the scale factor of the thresholded image that would be returned by
+ * GetThresholdedImage() and the various GetX() methods that call
+ * GetComponentImages().
+ * Returns 0 if no thresholder has been set.
+ */
+ int GetThresholdedImageScaleFactor() const;
+
+ /**
+ * Dump the internal binary image to a PGM file.
+ * @deprecated Use GetThresholdedImage and write the image using pixWrite
+ * instead if possible.
+ */
+ void DumpPGM(const char* filename);
+
+ /**
+ * Runs page layout analysis in the mode set by SetPageSegMode.
+ * May optionally be called prior to Recognize to get access to just
+ * the page layout results. Returns an iterator to the results.
+ * Returns NULL on error.
+ * The returned iterator must be deleted after use.
+ * WARNING! This class points to data held within the TessBaseAPI class, and
+ * therefore can only be used while the TessBaseAPI class still exists and
+ * has not been subjected to a call of Init, SetImage, Recognize, Clear, End
+ * DetectOS, or anything else that changes the internal PAGE_RES.
+ */
+ PageIterator* AnalyseLayout();
+
+ /**
+ * Recognize the image from SetAndThresholdImage, generating Tesseract
+ * internal structures. Returns 0 on success.
+ * Optional. The Get*Text functions below will call Recognize if needed.
+ * After Recognize, the output is kept internally until the next SetImage.
+ */
+ int Recognize(ETEXT_DESC* monitor);
+
+ /**
+ * Methods to retrieve information after SetAndThresholdImage(),
+ * Recognize() or TesseractRect(). (Recognize is called implicitly if needed.)
+ */
+
+ /** Variant on Recognize used for testing chopper. */
+ int RecognizeForChopTest(ETEXT_DESC* monitor);
+
+ /**
+ * Recognizes all the pages in the named file, as a multi-page tiff or
+ * list of filenames, or single image, and gets the appropriate kind of text
+ * according to parameters: tessedit_create_boxfile,
+ * tessedit_make_boxes_from_boxes, tessedit_write_unlv, tessedit_create_hocr.
+ * Calls ProcessPage on each page in the input file, which may be a
+ * multi-page tiff, single-page other file format, or a plain text list of
+ * images to read. If tessedit_page_number is non-negative, processing begins
+ * at that page of a multi-page tiff file, or filelist.
+ * The text is returned in text_out. Returns false on error.
+ * If non-zero timeout_millisec terminates processing after the timeout on
+ * a single page.
+ * If non-NULL and non-empty, and some page fails for some reason,
+ * the page is reprocessed with the retry_config config file. Useful
+ * for interactively debugging a bad page.
+ */
+ bool ProcessPages(const char* filename,
+ const char* retry_config, int timeout_millisec,
+ STRING* text_out);
+
+ /**
+ * Recognizes a single page for ProcessPages, appending the text to text_out.
+ * The pix is the image processed - filename and page_index are metadata
+ * used by side-effect processes, such as reading a box file or formatting
+ * as hOCR.
+ * If non-zero timeout_millisec terminates processing after the timeout.
+ * If non-NULL and non-empty, and some page fails for some reason,
+ * the page is reprocessed with the retry_config config file. Useful
+ * for interactively debugging a bad page.
+ * The text is returned in text_out. Returns false on error.
+ */
+ bool ProcessPage(Pix* pix, int page_index, const char* filename,
+ const char* retry_config, int timeout_millisec,
+ STRING* text_out);
+
+ /**
+ * Get a reading-order iterator to the results of LayoutAnalysis and/or
+ * Recognize. The returned iterator must be deleted after use.
+ * WARNING! This class points to data held within the TessBaseAPI class, and
+ * therefore can only be used while the TessBaseAPI class still exists and
+ * has not been subjected to a call of Init, SetImage, Recognize, Clear, End
+ * DetectOS, or anything else that changes the internal PAGE_RES.
+ */
+ ResultIterator* GetIterator();
+
+ /**
+ * Get a mutable iterator to the results of LayoutAnalysis and/or Recognize.
+ * The returned iterator must be deleted after use.
+ * WARNING! This class points to data held within the TessBaseAPI class, and
+ * therefore can only be used while the TessBaseAPI class still exists and
+ * has not been subjected to a call of Init, SetImage, Recognize, Clear, End
+ * DetectOS, or anything else that changes the internal PAGE_RES.
+ */
+ MutableIterator* GetMutableIterator();
+
+ /**
+ * The recognized text is returned as a char* which is coded
+ * as UTF8 and must be freed with the delete [] operator.
+ */
+ char* GetUTF8Text();
+
+ /**
+ * Make a HTML-formatted string with hOCR markup from the internal
+ * data structures.
+ * page_number is 0-based but will appear in the output as 1-based.
+ */
+ char* GetHOCRText(int page_number);
+ /**
+ * The recognized text is returned as a char* which is coded in the same
+ * format as a box file used in training. Returned string must be freed with
+ * the delete [] operator.
+ * Constructs coordinates in the original image - not just the rectangle.
+ * page_number is a 0-based page index that will appear in the box file.
+ */
+ char* GetBoxText(int page_number);
+ /**
+ * The recognized text is returned as a char* which is coded
+ * as UNLV format Latin-1 with specific reject and suspect codes
+ * and must be freed with the delete [] operator.
+ */
+ char* GetUNLVText();
+ /** Returns the (average) confidence value between 0 and 100. */
+ int MeanTextConf();
+ /**
+ * Returns all word confidences (between 0 and 100) in an array, terminated
+ * by -1. The calling function must delete [] after use.
+ * The number of confidences should correspond to the number of space-
+ * delimited words in GetUTF8Text.
+ */
+ int* AllWordConfidences();
+
+ /**
+ * Applies the given word to the adaptive classifier if possible.
+ * The word must be SPACE-DELIMITED UTF-8 - l i k e t h i s , so it can
+ * tell the boundaries of the graphemes.
+ * Assumes that SetImage/SetRectangle have been used to set the image
+ * to the given word. The mode arg should be PSM_SINGLE_WORD or
+ * PSM_CIRCLE_WORD, as that will be used to control layout analysis.
+ * The currently set PageSegMode is preserved.
+ * Returns false if adaption was not possible for some reason.
+ */
+ bool AdaptToWordStr(PageSegMode mode, const char* wordstr);
+
+ /**
+ * Free up recognition results and any stored image data, without actually
+ * freeing any recognition data that would be time-consuming to reload.
+ * Afterwards, you must call SetImage or TesseractRect before doing
+ * any Recognize or Get* operation.
+ */
+ void Clear();
+
+ /**
+ * Close down tesseract and free up all memory. End() is equivalent to
+ * destructing and reconstructing your TessBaseAPI.
+ * Once End() has been used, none of the other API functions may be used
+ * other than Init and anything declared above it in the class definition.
+ */
+ void End();
+
+ /**
+ * Check whether a word is valid according to Tesseract's language model
+ * @return 0 if the word is invalid, non-zero if valid.
+ * @warning temporary! This function will be removed from here and placed
+ * in a separate API at some future time.
+ */
+ int IsValidWord(const char *word);
+
+ bool GetTextDirection(int* out_offset, float* out_slope);
+
+ /** Sets Dict::letter_is_okay_ function to point to the given function. */
+ void SetDictFunc(DictFunc f);
+
+ /** Sets Dict::probability_in_context_ function to point to the given
+ * function.
+ */
+ void SetProbabilityInContextFunc(ProbabilityInContextFunc f);
+
+ /** Sets Wordrec::fill_lattice_ function to point to the given function. */
+ void SetFillLatticeFunc(FillLatticeFunc f);
+
+ /**
+ * Estimates the Orientation And Script of the image.
+ * @return true if the image was processed successfully.
+ */
+ bool DetectOS(OSResults*);
+
+ /** This method returns the features associated with the input image. */
+ void GetFeaturesForBlob(TBLOB* blob, const DENORM& denorm,
+ INT_FEATURE_ARRAY int_features,
+ int* num_features, int* FeatureOutlineIndex);
+
+ /**
+ * This method returns the row to which a box of specified dimensions would
+ * belong. If no good match is found, it returns NULL.
+ */
+ static ROW* FindRowForBox(BLOCK_LIST* blocks, int left, int top,
+ int right, int bottom);
+
+ /**
+ * Method to run adaptive classifier on a blob.
+ * It returns at max num_max_matches results.
+ */
+ void RunAdaptiveClassifier(TBLOB* blob, const DENORM& denorm,
+ int num_max_matches,
+ int* unichar_ids,
+ float* ratings,
+ int* num_matches_returned);
+
+ /** This method returns the string form of the specified unichar. */
+ const char* GetUnichar(int unichar_id);
+
+ /** Return the pointer to the i-th dawg loaded into tesseract_ object. */
+ const Dawg *GetDawg(int i) const;
+
+ /** Return the number of dawgs loaded into tesseract_ object. */
+ int NumDawgs() const;
+
+ /** Returns a ROW object created from the input row specification. */
+ static ROW *MakeTessOCRRow(float baseline, float xheight,
+ float descender, float ascender);
+
+ /** Returns a TBLOB corresponding to the entire input image. */
+ static TBLOB *MakeTBLOB(Pix *pix);
+
+ /**
+ * This method baseline normalizes a TBLOB in-place. The input row is used
+ * for normalization. The denorm is an optional parameter in which the
+ * normalization-antidote is returned.
+ */
+ static void NormalizeTBLOB(TBLOB *tblob, ROW *row,
+ bool numeric_mode, DENORM *denorm);
+
+ Tesseract* const tesseract() const {
+ return tesseract_;
+ }
+
+ OcrEngineMode const oem() const {
+ return last_oem_requested_;
+ }
+
+ void InitTruthCallback(TruthCallback *cb) { truth_cb_ = cb; }
+
+ /** Return a pointer to underlying CubeRecoContext object if present. */
+ CubeRecoContext *GetCubeRecoContext() const;
+
+ void set_min_orientation_margin(double margin);
+
+ /**
+ * Return text orientation of each block as determined by an earlier run
+ * of layout analysis.
+ */
+ void GetBlockTextOrientations(int** block_orientation,
+ bool** vertical_writing);
+
+ /** Find lines from the image making the BLOCK_LIST. */
+ BLOCK_LIST* FindLinesCreateBlockList();
+
+ /**
+ * Delete a block list.
+ * This is to keep BLOCK_LIST pointer opaque
+ * and let go of including the other headers.
+ */
+ static void DeleteBlockList(BLOCK_LIST* block_list);
+ /* @} */
+
+ protected:
+
+ /** Common code for setting the image. Returns true if Init has been called. */
+ TESS_LOCAL bool InternalSetImage();
+
+ /**
+ * Run the thresholder to make the thresholded image. If pix is not NULL,
+ * the source is thresholded to pix instead of the internal IMAGE.
+ */
+ TESS_LOCAL virtual void Threshold(Pix** pix);
+
+ /**
+ * Find lines from the image making the BLOCK_LIST.
+ * @return 0 on success.
+ */
+ TESS_LOCAL int FindLines();
+
+ /** Delete the pageres and block list ready for a new page. */
+ TESS_LOCAL void ClearResults();
+
+ /**
+ * Return an LTR Result Iterator -- used only for training, as we really want
+ * to ignore all BiDi smarts at that point.
+ * delete once you're done with it.
+ */
+ TESS_LOCAL LTRResultIterator* GetLTRIterator();
+
+ /**
+ * Return the length of the output text string, as UTF8, assuming
+ * one newline per line and one per block, with a terminator,
+ * and assuming a single character reject marker for each rejected character.
+ * Also return the number of recognized blobs in blob_count.
+ */
+ TESS_LOCAL int TextLength(int* blob_count);
+
+ /** @defgroup ocropusAddOns ocropus add-ons */
+ /* @{ */
+
+ /**
+ * Adapt to recognize the current image as the given character.
+ * The image must be preloaded and be just an image of a single character.
+ */
+ TESS_LOCAL void AdaptToCharacter(const char *unichar_repr,
+ int length,
+ float baseline,
+ float xheight,
+ float descender,
+ float ascender);
+
+ /** Recognize text doing one pass only, using settings for a given pass. */
+ TESS_LOCAL PAGE_RES* RecognitionPass1(BLOCK_LIST* block_list);
+ TESS_LOCAL PAGE_RES* RecognitionPass2(BLOCK_LIST* block_list, PAGE_RES* pass1_result);
+
+ //// paragraphs.cpp ////////////////////////////////////////////////////
+ TESS_LOCAL void DetectParagraphs(bool after_text_recognition);
+
+ /**
+ * Extract the OCR results, costs (penalty points for uncertainty),
+ * and the bounding boxes of the characters.
+ */
+ TESS_LOCAL static int TesseractExtractResult(char** text,
+ int** lengths,
+ float** costs,
+ int** x0,
+ int** y0,
+ int** x1,
+ int** y1,
+ PAGE_RES* page_res);
+
+ TESS_LOCAL const PAGE_RES* GetPageRes() const {
+ return page_res_;
+ };
+ /* @} */
+
+ protected:
+ Tesseract* tesseract_; ///< The underlying data object.
+ Tesseract* osd_tesseract_; ///< For orientation & script detection.
+ EquationDetect* equ_detect_; ///* paragraph_models_;
+ BLOCK_LIST* block_list_; ///< The page layout.
+ PAGE_RES* page_res_; ///< The page-level data.
+ STRING* input_file_; ///< Name used by training code.
+ STRING* output_file_; ///< Name used by debug code.
+ STRING* datapath_; ///< Current location of tessdata.
+ STRING* language_; ///< Last initialized language.
+ OcrEngineMode last_oem_requested_; ///< Last ocr language mode requested.
+ bool recognition_done_; ///< page_res_ contains recognition data.
+ TruthCallback *truth_cb_; /// fxn for setting truth_* in WERD_RES
+
+ /**
+ * @defgroup ThresholderParams Thresholder Parameters
+ * Parameters saved from the Thresholder. Needed to rebuild coordinates.
+ */
+ /* @{ */
+ int rect_left_;
+ int rect_top_;
+ int rect_width_;
+ int rect_height_;
+ int image_width_;
+ int image_height_;
+ /* @} */
+
+};
+
+} // namespace tesseract.
+
+#endif // TESSERACT_API_BASEAPI_H__
diff --git a/card.io/src/main/jni/tesseract/errcode.h b/card.io/src/main/jni/tesseract/errcode.h
new file mode 100644
index 00000000..2bc2a03c
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/errcode.h
@@ -0,0 +1,105 @@
+/**********************************************************************
+ * File: errcode.h (Formerly error.h)
+ * Description: Header file for generic error handler class
+ * Author: Ray Smith
+ * Created: Tue May 1 16:23:36 BST 1990
+ *
+ * (C) Copyright 1990, Hewlett-Packard Ltd.
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ *
+ **********************************************************************/
+
+#ifndef ERRCODE_H
+#define ERRCODE_H
+
+#include "host.h"
+
+/*Control parameters for error()*/
+enum TessErrorLogCode {
+ DBG = -1, /*log without alert */
+ TESSLOG = 0, /*alert user */
+ TESSEXIT = 1, /*exit after erro */
+ ABORT = 2 /*abort after error */
+};
+
+/* Explicit Error Abort codes */
+#define NO_ABORT_CODE 0
+#define LIST_ABORT 1
+#define MEMORY_ABORT 2
+#define FILE_ABORT 3
+
+/* Location of code at error codes Reserve 0..2 (status codes 0..23 for UNLV)*/
+#define LOC_UNUSED0 0
+#define LOC_UNUSED1 1
+#define LOC_UNUSED2 2
+#define LOC_INIT 3
+#define LOC_EDGE_PROG 4
+#define LOC_TEXT_ORD_ROWS 5
+#define LOC_TEXT_ORD_WORDS 6
+#define LOC_PASS1 7
+#define LOC_PASS2 8
+/* Reserve up to 8..13 for adding subloc 0/3 plus subsubloc 0/1/2 */
+#define LOC_FUZZY_SPACE 14
+/* Reserve up to 14..20 for adding subloc 0/3 plus subsubloc 0/1/2 */
+#define LOC_MM_ADAPT 21
+#define LOC_DOC_BLK_REJ 22
+#define LOC_WRITE_RESULTS 23
+#define LOC_ADAPTIVE 24
+/* DONT DEFINE ANY LOCATION > 31 !!! */
+
+/* Sub locatation determines whether pass2 was in normal mode or fix xht mode*/
+#define SUBLOC_NORM 0
+#define SUBLOC_FIX_XHT 3
+
+/* Sub Sub locatation determines whether match_word_pass2 was in Tess
+ matcher, NN matcher or somewhere else */
+
+#define SUBSUBLOC_OTHER 0
+#define SUBSUBLOC_TESS 1
+#define SUBSUBLOC_NN 2
+
+class TESS_API ERRCODE { // error handler class
+ const char *message; // error message
+ public:
+ void error( // error print function
+ const char *caller, // function location
+ TessErrorLogCode action, // action to take
+ const char *format, ... // fprintf format
+ ) const;
+ ERRCODE(const char *string) {
+ message = string;
+ } // initialize with string
+};
+
+const ERRCODE ASSERT_FAILED = "Assert failed";
+
+#define ASSERT_HOST(x) if (!(x)) \
+{ \
+ ASSERT_FAILED.error(#x,ABORT,"in file %s, line %d", \
+ __FILE__,__LINE__); \
+}
+
+void signal_exit( //
+ int signal_code //Signal which
+ );
+extern "C"
+{
+ void err_exit();
+ //The real signal
+ void signal_termination_handler(int sig);
+};
+
+void set_global_loc_code(int loc_code);
+
+void set_global_subloc_code(int loc_code);
+
+void set_global_subsubloc_code(int loc_code);
+#endif
diff --git a/card.io/src/main/jni/tesseract/genericvector.h b/card.io/src/main/jni/tesseract/genericvector.h
new file mode 100644
index 00000000..5ac3532a
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/genericvector.h
@@ -0,0 +1,807 @@
+///////////////////////////////////////////////////////////////////////
+// File: genericvector.h
+// Description: Generic vector class
+// Author: Daria Antonova
+// Created: Mon Jun 23 11:26:43 PDT 2008
+//
+// (C) Copyright 2007, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+//
+#ifndef TESSERACT_CCUTIL_GENERICVECTOR_H_
+#define TESSERACT_CCUTIL_GENERICVECTOR_H_
+
+#include
+#include
+
+#include "tesscallback.h"
+#include "errcode.h"
+#include "helpers.h"
+#include "ndminx.h"
+
+// Use PointerVector below in preference to GenericVector, as that
+// provides automatic deletion of pointers, [De]Serialize that works, and
+// sort that works.
+template
+class GenericVector {
+ public:
+ GenericVector() { this->init(kDefaultVectorSize); }
+ explicit GenericVector(int size) { this->init(size); }
+
+ // Copy
+ GenericVector(const GenericVector& other) {
+ this->init(other.size());
+ this->operator+=(other);
+ }
+ GenericVector &operator+=(const GenericVector& other);
+ GenericVector &operator=(const GenericVector& other);
+
+ virtual ~GenericVector();
+
+ // Reserve some memory.
+ void reserve(int size);
+ // Double the size of the internal array.
+ void double_the_size();
+
+ // Resizes to size and sets all values to t.
+ void init_to_size(int size, T t);
+
+ // Return the size used.
+ int size() const {
+ return size_used_;
+ }
+
+ int length() const {
+ return size_used_;
+ }
+
+ // Return true if empty.
+ bool empty() const {
+ return size_used_ == 0;
+ }
+
+ // Return the object from an index.
+ T &get(int index) const;
+ T &back() const;
+ T &operator[](int index) const;
+
+ // Return the index of the T object.
+ // This method NEEDS a compare_callback to be passed to
+ // set_compare_callback.
+ int get_index(T object) const;
+
+ // Return true if T is in the array
+ bool contains(T object) const;
+
+ // Return true if the index is valid
+ T contains_index(int index) const;
+
+ // Push an element in the end of the array
+ int push_back(T object);
+ void operator+=(T t);
+
+ // Push an element in the end of the array if the same
+ // element is not already contained in the array.
+ int push_back_new(T object);
+
+ // Push an element in the front of the array
+ // Note: This function is O(n)
+ int push_front(T object);
+
+ // Set the value at the given index
+ void set(T t, int index);
+
+ // Insert t at the given index, push other elements to the right.
+ void insert(T t, int index);
+
+ // Removes an element at the given index and
+ // shifts the remaining elements to the left.
+ virtual void remove(int index);
+
+ // Truncates the array to the given size by removing the end.
+ // If the current size is less, the array is not expanded.
+ virtual void truncate(int size) {
+ if (size < size_used_)
+ size_used_ = size;
+ }
+
+ // Add a callback to be called to delete the elements when the array took
+ // their ownership.
+ void set_clear_callback(TessCallback1* cb);
+
+ // Add a callback to be called to compare the elements when needed (contains,
+ // get_id, ...)
+ void set_compare_callback(TessResultCallback2* cb);
+
+ // Clear the array, calling the clear callback function if any.
+ // All the owned callbacks are also deleted.
+ // If you don't want the callbacks to be deleted, before calling clear, set
+ // the callback to NULL.
+ virtual void clear();
+
+ // Delete objects pointed to by data_[i]
+ void delete_data_pointers();
+
+ // This method clears the current object, then, does a shallow copy of
+ // its argument, and finally invalidates its argument.
+ // Callbacks are moved to the current object;
+ void move(GenericVector* from);
+
+ // Read/Write the array to a file. This does _NOT_ read/write the callbacks.
+ // The callback given must be permanent since they will be called more than
+ // once. The given callback will be deleted at the end.
+ // If the callbacks are NULL, then the data is simply read/written using
+ // fread (and swapping)/fwrite.
+ // Returns false on error or if the callback returns false.
+ // DEPRECATED. Use [De]Serialize[Classes] instead.
+ bool write(FILE* f, TessResultCallback2* cb) const;
+ bool read(FILE* f, TessResultCallback3* cb, bool swap);
+ // Writes a vector of simple types to the given file. Assumes that bitwise
+ // read/write of T will work. Returns false in case of error.
+ virtual bool Serialize(FILE* fp) const;
+ // Reads a vector of simple types from the given file. Assumes that bitwise
+ // read/write will work with ReverseN according to sizeof(T).
+ // Returns false in case of error.
+ // If swap is true, assumes a big/little-endian swap is needed.
+ virtual bool DeSerialize(bool swap, FILE* fp);
+ // Writes a vector of classes to the given file. Assumes the existence of
+ // bool T::Serialize(FILE* fp) const that returns false in case of error.
+ // Returns false in case of error.
+ bool SerializeClasses(FILE* fp) const;
+ // Reads a vector of classes from the given file. Assumes the existence of
+ // bool T::Deserialize(bool swap, FILE* fp) that returns false in case of
+ // error. Also needs T::T() and T::T(constT&), as init_to_size is used in
+ // this function. Returns false in case of error.
+ // If swap is true, assumes a big/little-endian swap is needed.
+ bool DeSerializeClasses(bool swap, FILE* fp);
+
+ // Allocates a new array of double the current_size, copies over the
+ // information from data to the new location, deletes data and returns
+ // the pointed to the new larger array.
+ // This function uses memcpy to copy the data, instead of invoking
+ // operator=() for each element like double_the_size() does.
+ static T *double_the_size_memcpy(int current_size, T *data) {
+ T *data_new = new T[current_size * 2];
+ memcpy(data_new, data, sizeof(T) * current_size);
+ delete[] data;
+ return data_new;
+ }
+
+ // Sorts the members of this vector using the less than comparator (cmp_lt),
+ // which compares the values. Useful for GenericVectors to primitive types.
+ // Will not work so great for pointers (unless you just want to sort some
+ // pointers). You need to provide a specialization to sort_cmp to use
+ // your type.
+ void sort();
+
+ // Sort the array into the order defined by the qsort function comparator.
+ // The comparator function is as defined by qsort, ie. it receives pointers
+ // to two Ts and returns negative if the first element is to appear earlier
+ // in the result and positive if it is to appear later, with 0 for equal.
+ void sort(int (*comparator)(const void*, const void*)) {
+ qsort(data_, size_used_, sizeof(*data_), comparator);
+ }
+
+ // Searches the array (assuming sorted in ascending order, using sort()) for
+ // an element equal to target and returns true if it is present.
+ // Use binary_search to get the index of target, or its nearest candidate.
+ bool bool_binary_search(const T& target) const {
+ int index = binary_search(target);
+ if (index >= size_used_)
+ return false;
+ return data_[index] == target;
+ }
+ // Searches the array (assuming sorted in ascending order, using sort()) for
+ // an element equal to target and returns the index of the best candidate.
+ // The return value is conceptually the largest index i such that
+ // data_[i] <= target or 0 if target < the whole vector.
+ // NOTE that this function uses operator> so really the return value is
+ // the largest index i such that data_[i] > target is false.
+ int binary_search(const T& target) const {
+ int bottom = 0;
+ int top = size_used_;
+ do {
+ int middle = (bottom + top) / 2;
+ if (data_[middle] > target)
+ top = middle;
+ else
+ bottom = middle;
+ }
+ while (top - bottom > 1);
+ return bottom;
+ }
+
+ // Compact the vector by deleting elements using operator!= on basic types.
+ // The vector must be sorted.
+ void compact_sorted() {
+ if (size_used_ == 0)
+ return;
+
+ // First element is in no matter what, hence the i = 1.
+ int last_write = 0;
+ for (int i = 1; i < size_used_; ++i) {
+ // Finds next unique item and writes it.
+ if (data_[last_write] != data_[i])
+ data_[++last_write] = data_[i];
+ }
+ // last_write is the index of a valid data cell, so add 1.
+ size_used_ = last_write + 1;
+ }
+
+ // Compact the vector by deleting elements for which delete_cb returns
+ // true. delete_cb is a permanent callback and will be deleted.
+ void compact(TessResultCallback1* delete_cb) {
+ int new_size = 0;
+ int old_index = 0;
+ // Until the callback returns true, the elements stay the same.
+ while (old_index < size_used_ && !delete_cb->Run(old_index++))
+ ++new_size;
+ // Now just copy anything else that gets false from delete_cb.
+ for (; old_index < size_used_; ++old_index) {
+ if (!delete_cb->Run(old_index)) {
+ data_[new_size++] = data_[old_index];
+ }
+ }
+ size_used_ = new_size;
+ delete delete_cb;
+ }
+
+ T dot_product(const GenericVector& other) const {
+ T result = static_cast(0);
+ for (int i = MIN(size_used_, other.size_used_) - 1; i >= 0; --i)
+ result += data_[i] * other.data_[i];
+ return result;
+ }
+
+ protected:
+
+ // Init the object, allocating size memory.
+ void init(int size);
+
+ // We are assuming that the object generally placed in thie
+ // vector are small enough that for efficiency it makes sence
+ // to start with a larger initial size.
+ static const int kDefaultVectorSize = 4;
+ inT32 size_used_;
+ inT32 size_reserved_;
+ T* data_;
+ TessCallback1* clear_cb_;
+ // Mutable because Run method is not const
+ mutable TessResultCallback2* compare_cb_;
+};
+
+namespace tesseract {
+
+template
+bool cmp_eq(T const & t1, T const & t2) {
+ return t1 == t2;
+}
+
+// Used by sort()
+// return < 0 if t1 < t2
+// return 0 if t1 == t2
+// return > 0 if t1 > t2
+template
+int sort_cmp(const void* t1, const void* t2) {
+ const T* a = static_cast (t1);
+ const T* b = static_cast (t2);
+ if (*a < *b) {
+ return -1;
+ } else if (*b < *a) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+// Used by PointerVector::sort()
+// return < 0 if t1 < t2
+// return 0 if t1 == t2
+// return > 0 if t1 > t2
+template
+int sort_ptr_cmp(const void* t1, const void* t2) {
+ const T* a = *reinterpret_cast(t1);
+ const T* b = *reinterpret_cast(t2);
+ if (*a < *b) {
+ return -1;
+ } else if (*b < *a) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+// Subclass for a vector of pointers. Use in preference to GenericVector
+// as it provides automatic deletion and correct serialization, with the
+// corollary that all copy operations are deep copies of the pointed-to objects.
+template
+class PointerVector : public GenericVector {
+ public:
+ PointerVector() : GenericVector() { }
+ explicit PointerVector(int size) : GenericVector(size) { }
+ virtual ~PointerVector() {
+ // Clear must be called here, even though it is called again by the base,
+ // as the base will call the wrong clear.
+ clear();
+ }
+ // Copy must be deep, as the pointers will be automatically deleted on
+ // destruction.
+ PointerVector(const PointerVector& other) {
+ this->init(other.size());
+ this->operator+=(other);
+ }
+ PointerVector& operator+=(const PointerVector& other) {
+ this->reserve(this->size_used_ + other.size_used_);
+ for (int i = 0; i < other.size(); ++i) {
+ this->push_back(new T(*other.data_[i]));
+ }
+ return *this;
+ }
+
+ PointerVector& operator=(const PointerVector& other) {
+ this->truncate(0);
+ this->operator+=(other);
+ return *this;
+ }
+
+ // Removes an element at the given index and
+ // shifts the remaining elements to the left.
+ virtual void remove(int index) {
+ delete GenericVector::data_[index];
+ GenericVector::remove(index);
+ }
+
+ // Truncates the array to the given size by removing the end.
+ // If the current size is less, the array is not expanded.
+ virtual void truncate(int size) {
+ for (int i = size; i < GenericVector::size_used_; ++i)
+ delete GenericVector::data_[i];
+ GenericVector::truncate(size);
+ }
+
+ // Compact the vector by deleting elements for which delete_cb returns
+ // true. delete_cb is a permanent callback and will be deleted.
+ void compact(TessResultCallback1* delete_cb) {
+ int new_size = 0;
+ int old_index = 0;
+ // Until the callback returns true, the elements stay the same.
+ while (old_index < GenericVector::size_used_ &&
+ !delete_cb->Run(GenericVector::data_[old_index++]))
+ ++new_size;
+ // Now just copy anything else that gets false from delete_cb.
+ for (; old_index < GenericVector::size_used_; ++old_index) {
+ if (!delete_cb->Run(GenericVector::data_[old_index])) {
+ GenericVector::data_[new_size++] =
+ GenericVector::data_[old_index];
+ } else {
+ delete GenericVector::data_[old_index];
+ }
+ }
+ GenericVector::size_used_ = new_size;
+ delete delete_cb;
+ }
+
+ // Clear the array, calling the clear callback function if any.
+ // All the owned callbacks are also deleted.
+ // If you don't want the callbacks to be deleted, before calling clear, set
+ // the callback to NULL.
+ virtual void clear() {
+ GenericVector::delete_data_pointers();
+ GenericVector::clear();
+ }
+
+ // Writes a vector of simple types to the given file. Assumes that bitwise
+ // read/write of T will work. Returns false in case of error.
+ virtual bool Serialize(FILE* fp) const {
+ inT32 used = GenericVector::size_used_;
+ if (fwrite(&used, sizeof(used), 1, fp) != 1) return false;
+ for (int i = 0; i < used; ++i) {
+ inT8 non_null = GenericVector::data_[i] != NULL;
+ if (fwrite(&non_null, sizeof(non_null), 1, fp) != 1) return false;
+ if (non_null && !GenericVector::data_[i]->Serialize(fp)) return false;
+ }
+ return true;
+ }
+ // Reads a vector of simple types from the given file. Assumes that bitwise
+ // read/write will work with ReverseN according to sizeof(T).
+ // Also needs T::T(), as new T is used in this function.
+ // Returns false in case of error.
+ // If swap is true, assumes a big/little-endian swap is needed.
+ virtual bool DeSerialize(bool swap, FILE* fp) {
+ inT32 reserved;
+ if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
+ if (swap) Reverse32(&reserved);
+ GenericVector::reserve(reserved);
+ for (int i = 0; i < reserved; ++i) {
+ inT8 non_null;
+ if (fread(&non_null, sizeof(non_null), 1, fp) != 1) return false;
+ T* item = NULL;
+ if (non_null) {
+ item = new T;
+ if (!item->DeSerialize(swap, fp)) return false;
+ }
+ this->push_back(item);
+ }
+ return true;
+ }
+
+ // Sorts the items pointed to by the members of this vector using
+ // t::operator<().
+ void sort() {
+ sort(&sort_ptr_cmp);
+ }
+};
+
+} // namespace tesseract
+
+// A useful vector that uses operator== to do comparisons.
+template
+class GenericVectorEqEq : public GenericVector {
+ public:
+ GenericVectorEqEq() {
+ GenericVector::set_compare_callback(
+ NewPermanentTessCallback(tesseract::cmp_eq));
+ }
+ GenericVectorEqEq(int size) : GenericVector(size) {
+ GenericVector::set_compare_callback(
+ NewPermanentTessCallback(tesseract::cmp_eq));
+ }
+};
+
+template
+void GenericVector::init(int size) {
+ size_used_ = 0;
+ size_reserved_ = 0;
+ data_ = 0;
+ clear_cb_ = 0;
+ compare_cb_ = 0;
+ reserve(size);
+}
+
+template
+GenericVector::~GenericVector() {
+ clear();
+}
+
+// Reserve some memory. If the internal array contains elements, they are
+// copied.
+template
+void GenericVector::reserve(int size) {
+ if (size_reserved_ >= size || size <= 0)
+ return;
+ T* new_array = new T[size];
+ for (int i = 0; i < size_used_; ++i)
+ new_array[i] = data_[i];
+ if (data_ != NULL) delete[] data_;
+ data_ = new_array;
+ size_reserved_ = size;
+}
+
+template
+void GenericVector::double_the_size() {
+ if (size_reserved_ == 0) {
+ reserve(kDefaultVectorSize);
+ }
+ else {
+ reserve(2 * size_reserved_);
+ }
+}
+
+// Resizes to size and sets all values to t.
+template
+void GenericVector::init_to_size(int size, T t) {
+ reserve(size);
+ size_used_ = size;
+ for (int i = 0; i < size; ++i)
+ data_[i] = t;
+}
+
+
+// Return the object from an index.
+template
+T &GenericVector::get(int index) const {
+ ASSERT_HOST(index >= 0 && index < size_used_);
+ return data_[index];
+}
+
+template
+T &GenericVector::operator[](int index) const {
+ return data_[index];
+}
+
+template
+T &GenericVector::back() const {
+ ASSERT_HOST(size_used_ > 0);
+ return data_[size_used_ - 1];
+}
+
+// Return the object from an index.
+template
+void GenericVector::set(T t, int index) {
+ ASSERT_HOST(index >= 0 && index < size_used_);
+ data_[index] = t;
+}
+
+// Shifts the rest of the elements to the right to make
+// space for the new elements and inserts the given element
+// at the specified index.
+template
+void GenericVector::insert(T t, int index) {
+ ASSERT_HOST(index >= 0 && index < size_used_);
+ if (size_reserved_ == size_used_)
+ double_the_size();
+ for (int i = size_used_; i > index; --i) {
+ data_[i] = data_[i-1];
+ }
+ data_[index] = t;
+ size_used_++;
+}
+
+// Removes an element at the given index and
+// shifts the remaining elements to the left.
+template
+void GenericVector::remove(int index) {
+ ASSERT_HOST(index >= 0 && index < size_used_);
+ for (int i = index; i < size_used_ - 1; ++i) {
+ data_[i] = data_[i+1];
+ }
+ size_used_--;
+}
+
+// Return true if the index is valindex
+template
+T GenericVector::contains_index(int index) const {
+ return index >= 0 && index < size_used_;
+}
+
+// Return the index of the T object.
+template
+int GenericVector::get_index(T object) const {
+ for (int i = 0; i < size_used_; ++i) {
+ ASSERT_HOST(compare_cb_ != NULL);
+ if (compare_cb_->Run(object, data_[i]))
+ return i;
+ }
+ return -1;
+}
+
+// Return true if T is in the array
+template
+bool GenericVector::contains(T object) const {
+ return get_index(object) != -1;
+}
+
+// Add an element in the array
+template
+int GenericVector::push_back(T object) {
+ int index = 0;
+ if (size_used_ == size_reserved_)
+ double_the_size();
+ index = size_used_++;
+ data_[index] = object;
+ return index;
+}
+
+template
+int GenericVector::push_back_new(T object) {
+ int index = get_index(object);
+ if (index >= 0)
+ return index;
+ return push_back(object);
+}
+
+// Add an element in the array (front)
+template
+int GenericVector::push_front(T object) {
+ if (size_used_ == size_reserved_)
+ double_the_size();
+ for (int i = size_used_; i > 0; --i)
+ data_[i] = data_[i-1];
+ data_[0] = object;
+ ++size_used_;
+ return 0;
+}
+
+template
+void GenericVector::operator+=(T t) {
+ push_back(t);
+}
+
+template
+GenericVector &GenericVector::operator+=(const GenericVector& other) {
+ this->reserve(size_used_ + other.size_used_);
+ for (int i = 0; i < other.size(); ++i) {
+ this->operator+=(other.data_[i]);
+ }
+ return *this;
+}
+
+template
+GenericVector &GenericVector::operator=(const GenericVector& other) {
+ this->truncate(0);
+ this->operator+=(other);
+ return *this;
+}
+
+// Add a callback to be called to delete the elements when the array took
+// their ownership.
+template
+void GenericVector::set_clear_callback(TessCallback1* cb) {
+ clear_cb_ = cb;
+}
+
+// Add a callback to be called to delete the elements when the array took
+// their ownership.
+template
+void GenericVector::set_compare_callback(TessResultCallback2* cb) {
+ compare_cb_ = cb;
+}
+
+// Clear the array, calling the callback function if any.
+template
+void GenericVector::clear() {
+ if (size_reserved_ > 0) {
+ if (clear_cb_ != NULL)
+ for (int i = 0; i < size_used_; ++i)
+ clear_cb_->Run(data_[i]);
+ delete[] data_;
+ data_ = NULL;
+ size_used_ = 0;
+ size_reserved_ = 0;
+ }
+ if (clear_cb_ != NULL) {
+ delete clear_cb_;
+ clear_cb_ = NULL;
+ }
+ if (compare_cb_ != NULL) {
+ delete compare_cb_;
+ compare_cb_ = NULL;
+ }
+}
+
+template
+void GenericVector::delete_data_pointers() {
+ for (int i = 0; i < size_used_; ++i)
+ if (data_[i]) {
+ delete data_[i];
+ }
+}
+
+
+template
+bool GenericVector::write(
+ FILE* f, TessResultCallback2* cb) const {
+ if (fwrite(&size_reserved_, sizeof(size_reserved_), 1, f) != 1) return false;
+ if (fwrite(&size_used_, sizeof(size_used_), 1, f) != 1) return false;
+ if (cb != NULL) {
+ for (int i = 0; i < size_used_; ++i) {
+ if (!cb->Run(f, data_[i])) {
+ delete cb;
+ return false;
+ }
+ }
+ delete cb;
+ } else {
+ if (fwrite(data_, sizeof(T), size_used_, f) != size_used_) return false;
+ }
+ return true;
+}
+
+template
+bool GenericVector::read(FILE* f,
+ TessResultCallback3* cb,
+ bool swap) {
+ inT32 reserved;
+ if (fread(&reserved, sizeof(reserved), 1, f) != 1) return false;
+ if (swap) Reverse32(&reserved);
+ reserve(reserved);
+ if (fread(&size_used_, sizeof(size_used_), 1, f) != 1) return false;
+ if (swap) Reverse32(&size_used_);
+ if (cb != NULL) {
+ for (int i = 0; i < size_used_; ++i) {
+ if (!cb->Run(f, data_ + i, swap)) {
+ delete cb;
+ return false;
+ }
+ }
+ delete cb;
+ } else {
+ if (fread(data_, sizeof(T), size_used_, f) != size_used_) return false;
+ if (swap) {
+ for (int i = 0; i < size_used_; ++i)
+ ReverseN(&data_[i], sizeof(T));
+ }
+ }
+ return true;
+}
+
+// Writes a vector of simple types to the given file. Assumes that bitwise
+// read/write of T will work. Returns false in case of error.
+template
+bool GenericVector::Serialize(FILE* fp) const {
+ if (fwrite(&size_used_, sizeof(size_used_), 1, fp) != 1) return false;
+ if (fwrite(data_, sizeof(*data_), size_used_, fp) != size_used_) return false;
+ return true;
+}
+
+// Reads a vector of simple types from the given file. Assumes that bitwise
+// read/write will work with ReverseN according to sizeof(T).
+// Returns false in case of error.
+// If swap is true, assumes a big/little-endian swap is needed.
+template
+bool GenericVector::DeSerialize(bool swap, FILE* fp) {
+ inT32 reserved;
+ if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
+ if (swap) Reverse32(&reserved);
+ reserve(reserved);
+ size_used_ = reserved;
+ if (fread(data_, sizeof(T), size_used_, fp) != size_used_) return false;
+ if (swap) {
+ for (int i = 0; i < size_used_; ++i)
+ ReverseN(&data_[i], sizeof(data_[i]));
+ }
+ return true;
+}
+
+// Writes a vector of classes to the given file. Assumes the existence of
+// bool T::Serialize(FILE* fp) const that returns false in case of error.
+// Returns false in case of error.
+template
+bool GenericVector::SerializeClasses(FILE* fp) const {
+ if (fwrite(&size_used_, sizeof(size_used_), 1, fp) != 1) return false;
+ for (int i = 0; i < size_used_; ++i) {
+ if (!data_[i].Serialize(fp)) return false;
+ }
+ return true;
+}
+
+// Reads a vector of classes from the given file. Assumes the existence of
+// bool T::Deserialize(bool swap, FILE* fp) that returns false in case of
+// error. Alse needs T::T() and T::T(constT&), as init_to_size is used in
+// this function. Returns false in case of error.
+// If swap is true, assumes a big/little-endian swap is needed.
+template
+bool GenericVector::DeSerializeClasses(bool swap, FILE* fp) {
+ uinT32 reserved;
+ if (fread(&reserved, sizeof(reserved), 1, fp) != 1) return false;
+ if (swap) Reverse32(&reserved);
+ T empty;
+ init_to_size(reserved, empty);
+ for (int i = 0; i < reserved; ++i) {
+ if (!data_[i].DeSerialize(swap, fp)) return false;
+ }
+ return true;
+}
+
+// This method clear the current object, then, does a shallow copy of
+// its argument, and finally invalidates its argument.
+template
+void GenericVector::move(GenericVector* from) {
+ this->clear();
+ this->data_ = from->data_;
+ this->size_reserved_ = from->size_reserved_;
+ this->size_used_ = from->size_used_;
+ this->compare_cb_ = from->compare_cb_;
+ this->clear_cb_ = from->clear_cb_;
+ from->data_ = NULL;
+ from->clear_cb_ = NULL;
+ from->compare_cb_ = NULL;
+ from->size_used_ = 0;
+ from->size_reserved_ = 0;
+}
+
+template
+void GenericVector::sort() {
+ sort(&tesseract::sort_cmp);
+}
+
+#endif // TESSERACT_CCUTIL_GENERICVECTOR_H_
diff --git a/card.io/src/main/jni/tesseract/helpers.h b/card.io/src/main/jni/tesseract/helpers.h
new file mode 100644
index 00000000..6d58520b
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/helpers.h
@@ -0,0 +1,152 @@
+/* -*-C-*-
+ ********************************************************************************
+ *
+ * File: helpers.h
+ * Description: General utility functions
+ * Author: Daria Antonova
+ * Created: Wed Apr 8 14:37:00 2009
+ * Language: C++
+ * Package: N/A
+ * Status: Reusable Software Component
+ *
+ * (c) Copyright 2009, Google Inc.
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ *
+ ********************************************************************************/
+
+#ifndef TESSERACT_CCUTIL_HELPERS_H_
+#define TESSERACT_CCUTIL_HELPERS_H_
+
+#include
+#include
+
+// Remove newline (if any) at the end of the string.
+inline void chomp_string(char *str) {
+ int last_index = strlen(str) - 1;
+ while (last_index >= 0 &&
+ (str[last_index] == '\n' || str[last_index] == '\r')) {
+ str[last_index--] = '\0';
+ }
+}
+
+// Advance the current pointer of the file if it points to a newline character.
+inline void SkipNewline(FILE *file) {
+ if (fgetc(file) != '\n') fseek(file, -1, SEEK_CUR);
+}
+
+// qsort function to sort 2 floats.
+inline int sort_floats(const void *arg1, const void *arg2) {
+ float diff = *((float *) arg1) - *((float *) arg2);
+ if (diff > 0) {
+ return 1;
+ } else if (diff < 0) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+// return the smallest multiple of block_size greater than or equal to n.
+inline int RoundUp(int n, int block_size) {
+ return block_size * ((n + block_size - 1) / block_size);
+}
+
+// Clip a numeric value to the interval [lower_bound, upper_bound].
+template
+inline T ClipToRange(const T& x, const T& lower_bound, const T& upper_bound) {
+ if (x < lower_bound)
+ return lower_bound;
+ if (x > upper_bound)
+ return upper_bound;
+ return x;
+}
+
+// Extend the range [lower_bound, upper_bound] to include x.
+template
+inline void UpdateRange(const T1& x, T2* lower_bound, T2* upper_bound) {
+ if (x < *lower_bound)
+ *lower_bound = x;
+ if (x > *upper_bound)
+ *upper_bound = x;
+}
+
+// Decrease lower_bound to be <= x_lo AND increase upper_bound to be >= x_hi.
+template
+inline void UpdateRange(const T1& x_lo, const T1& x_hi,
+ T2* lower_bound, T2* upper_bound) {
+ if (x_lo < *lower_bound)
+ *lower_bound = x_lo;
+ if (x_hi > *upper_bound)
+ *upper_bound = x_hi;
+}
+
+// Intersect the range [*lower2, *upper2] with the range [lower1, upper1],
+// putting the result back in [*lower2, *upper2].
+// If non-intersecting ranges are given, we end up with *lower2 > *upper2.
+template
+inline void IntersectRange(const T& lower1, const T& upper1,
+ T* lower2, T* upper2) {
+ if (lower1 > *lower2)
+ *lower2 = lower1;
+ if (upper1 < *upper2)
+ *upper2 = upper1;
+}
+
+// Proper modulo arithmetic operator. Returns a mod b that works for -ve a.
+// For any integer a and positive b, returns r : 0<=r= 0 ? (a + b / 2) / b : (a - b / 2) / b;
+}
+
+// Return a double cast to int with rounding.
+inline int IntCastRounded(double x) {
+ return x >= 0.0 ? static_cast(x + 0.5) : -static_cast(-x + 0.5);
+}
+
+// Reverse the order of bytes in a n byte quantity for big/little-endian switch.
+inline void ReverseN(void* ptr, int num_bytes) {
+ char *cptr = reinterpret_cast(ptr);
+ int halfsize = num_bytes / 2;
+ for (int i = 0; i < halfsize; ++i) {
+ char tmp = cptr[i];
+ cptr[i] = cptr[num_bytes - 1 - i];
+ cptr[num_bytes - 1 - i] = tmp;
+ }
+}
+
+// Reverse the order of bytes in a 16 bit quantity for big/little-endian switch.
+inline void Reverse16(void *ptr) {
+ ReverseN(ptr, 2);
+}
+
+// Reverse the order of bytes in a 32 bit quantity for big/little-endian switch.
+inline void Reverse32(void *ptr) {
+ ReverseN(ptr, 4);
+}
+
+// Reverse the order of bytes in a 64 bit quantity for big/little-endian switch.
+inline void Reverse64(void* ptr) {
+ ReverseN(ptr, 8);
+}
+
+
+#endif // TESSERACT_CCUTIL_HELPERS_H_
diff --git a/card.io/src/main/jni/tesseract/host.h b/card.io/src/main/jni/tesseract/host.h
new file mode 100644
index 00000000..5c27d706
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/host.h
@@ -0,0 +1,153 @@
+/******************************************************************************
+ ** Filename: Host.h
+ ** Purpose: This is the system independent typedefs and defines
+ ** Author: MN, JG, MD
+ ** Version: 5.4.1
+ ** History: 11/7/94 MCD received the modification that Lennart made
+ ** to port to 32 bit world and modify this file so that it
+ ** will be shared between platform.
+ ** 11/9/94 MCD Make MSW32 subset of MSW. Now MSW means
+ ** MicroSoft Window and MSW32 means the 32 bit worlds
+ ** of MicroSoft Window. Therefore you want the environment
+ ** to be MicroSoft Window and in the 32 bit world -
+ ** _WIN32 must be defined by your compiler.
+ ** 11/30/94 MCD Incorporated comments received for more
+ ** readability and the missing typedef for FLOAT.
+ ** 12/1/94 MCD Added PFVOID typedef
+ ** 5/1/95 MCD. Made many changes based on the inputs.
+ ** Changes:
+ ** 1) Rearrange the #ifdef so that there're definitions for
+ ** particular platforms.
+ ** 2) Took out the #define for computer and environment
+ ** that developer can uncomment
+ ** 3) Added __OLDCODE__ where the defines will be
+ ** obsoleted in the next version and advise not to use.
+ ** 4) Added the definitions for the following:
+ ** FILE_HANDLE, MEMORY_HANDLE, BOOL8,
+ ** MAX_INT8, MAX_INT16, MAX_INT32, MAX_UINT8
+ ** MAX_UINT16, MAX_UINT32, MAX_FLOAT32
+ ** 06/19/96 MCD. Took out MAX_FLOAT32
+ ** 07/15/96 MCD. Fixed the comments error
+ ** Add back BOOL8.
+ **
+ ** (c) Copyright Hewlett-Packard Company, 1988-1996.
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+
+#ifndef __HOST__
+#define __HOST__
+
+/******************************************************************************
+ ** IMPORTANT!!! **
+ ** **
+ ** Defines either _WIN32, __MAC__, __UNIX__, __OS2__, __PM__ to
+ ** use the specified definitions indicated below in the preprocessor settings. **
+ ** **
+ ** Also define either __FarProc__ or __FarData__ and __MOTO__ to use the
+ ** specified definitions indicated below in the preprocessor settings. **
+ ** **
+ ** If a preprocessor settings is not allow in the compiler that is being use,
+ ** then it is recommended that a "platform.h" is created with the definition
+ ** of the computer and/or operating system.
+ ******************************************************************************/
+
+#include "platform.h"
+/* _WIN32 */
+#ifdef _WIN32
+#include
+#include // winbase.h contains windows.h
+#endif
+
+/********************************************************/
+/* __MAC__ */
+#ifdef __MAC__
+#include
+/*----------------------------*/
+/*----------------------------*/
+#endif
+/********************************************************/
+#if defined(__UNIX__) || defined( __DOS__ ) || defined(__OS2__) || defined(__PM__)
+/*----------------------------*/
+/* FarProc and FarData */
+/*----------------------------*/
+/*----------------------------*/
+#endif
+/*****************************************************************************
+ **
+ ** Standard GHC Definitions
+ **
+ *****************************************************************************/
+
+#ifdef __MOTO__
+#define __NATIVE__ MOTO
+#else
+#define __NATIVE__ INTEL
+#endif
+
+//typedef HANDLE FD* PHANDLE;
+
+// definitions of portable data types (numbers and characters)
+typedef SIGNED char inT8;
+typedef unsigned char uinT8;
+typedef short inT16;
+typedef unsigned short uinT16;
+typedef int inT32;
+typedef unsigned int uinT32;
+#if (_MSC_VER >= 1200) //%%% vkr for VC 6.0
+typedef INT64 inT64;
+typedef UINT64 uinT64;
+#else
+typedef long long int inT64;
+typedef unsigned long long int uinT64;
+#endif //%%% vkr for VC 6.0
+typedef float FLOAT32;
+typedef double FLOAT64;
+typedef unsigned char BOOL8;
+
+#define INT32FORMAT "%d"
+#define INT64FORMAT "%lld"
+
+#define MAX_INT8 0x7f
+#define MAX_INT16 0x7fff
+#define MAX_INT32 0x7fffffff
+#define MAX_UINT8 0xff
+#define MAX_UINT16 0xffff
+#define MAX_UINT32 0xffffffff
+#define MAX_FLOAT32 ((float)3.40282347e+38)
+
+#define MIN_INT8 0x80
+#define MIN_INT16 0x8000
+#define MIN_INT32 0x80000000
+#define MIN_UINT8 0x00
+#define MIN_UINT16 0x0000
+#define MIN_UINT32 0x00000000
+#define MIN_FLOAT32 ((float)1.17549435e-38)
+
+// Defines
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef NULL
+#define NULL 0L
+#endif
+
+// Return true if x is within tolerance of y
+template bool NearlyEqual(T x, T y, T tolerance) {
+ T diff = x - y;
+ return diff <= tolerance && -diff <= tolerance;
+}
+
+#endif
diff --git a/card.io/src/main/jni/tesseract/ltrresultiterator.h b/card.io/src/main/jni/tesseract/ltrresultiterator.h
new file mode 100644
index 00000000..9464aaed
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/ltrresultiterator.h
@@ -0,0 +1,203 @@
+///////////////////////////////////////////////////////////////////////
+// File: ltrresultiterator.h
+// Description: Iterator for tesseract results in strict left-to-right
+// order that avoids using tesseract internal data structures.
+// Author: Ray Smith
+// Created: Fri Feb 26 11:01:06 PST 2010
+//
+// (C) Copyright 2010, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H__
+#define TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H__
+
+#include "platform.h"
+#include "pageiterator.h"
+#include "unicharset.h"
+
+class BLOB_CHOICE_IT;
+class WERD_RES;
+
+namespace tesseract {
+
+class Tesseract;
+
+// Class to iterate over tesseract results, providing access to all levels
+// of the page hierarchy, without including any tesseract headers or having
+// to handle any tesseract structures.
+// WARNING! This class points to data held within the TessBaseAPI class, and
+// therefore can only be used while the TessBaseAPI class still exists and
+// has not been subjected to a call of Init, SetImage, Recognize, Clear, End
+// DetectOS, or anything else that changes the internal PAGE_RES.
+// See apitypes.h for the definition of PageIteratorLevel.
+// See also base class PageIterator, which contains the bulk of the interface.
+// LTRResultIterator adds text-specific methods for access to OCR output.
+
+class TESS_API LTRResultIterator : public PageIterator {
+ friend class ChoiceIterator;
+ public:
+ // page_res and tesseract come directly from the BaseAPI.
+ // The rectangle parameters are copied indirectly from the Thresholder,
+ // via the BaseAPI. They represent the coordinates of some rectangle in an
+ // original image (in top-left-origin coordinates) and therefore the top-left
+ // needs to be added to any output boxes in order to specify coordinates
+ // in the original image. See TessBaseAPI::SetRectangle.
+ // The scale and scaled_yres are in case the Thresholder scaled the image
+ // rectangle prior to thresholding. Any coordinates in tesseract's image
+ // must be divided by scale before adding (rect_left, rect_top).
+ // The scaled_yres indicates the effective resolution of the binary image
+ // that tesseract has been given by the Thresholder.
+ // After the constructor, Begin has already been called.
+ LTRResultIterator(PAGE_RES* page_res, Tesseract* tesseract,
+ int scale, int scaled_yres,
+ int rect_left, int rect_top,
+ int rect_width, int rect_height);
+ virtual ~LTRResultIterator();
+
+ // LTRResultIterators may be copied! This makes it possible to iterate over
+ // all the objects at a lower level, while maintaining an iterator to
+ // objects at a higher level. These constructors DO NOT CALL Begin, so
+ // iterations will continue from the location of src.
+ // TODO: For now the copy constructor and operator= only need the base class
+ // versions, but if new data members are added, don't forget to add them!
+
+ // ============= Moving around within the page ============.
+
+ // See PageIterator.
+
+ // ============= Accessing data ==============.
+
+ // Returns the null terminated UTF-8 encoded text string for the current
+ // object at the given level. Use delete [] to free after use.
+ char* GetUTF8Text(PageIteratorLevel level) const;
+
+ // Set the string inserted at the end of each text line. "\n" by default.
+ void SetLineSeparator(const char *new_line);
+
+ // Set the string inserted at the end of each paragraph. "\n" by default.
+ void SetParagraphSeparator(const char *new_para);
+
+ // Returns the mean confidence of the current object at the given level.
+ // The number should be interpreted as a percent probability. (0.0f-100.0f)
+ float Confidence(PageIteratorLevel level) const;
+
+ // ============= Functions that refer to words only ============.
+
+ // Returns the font attributes of the current word. If iterating at a higher
+ // level object than words, eg textlines, then this will return the
+ // attributes of the first word in that textline.
+ // The actual return value is a string representing a font name. It points
+ // to an internal table and SHOULD NOT BE DELETED. Lifespan is the same as
+ // the iterator itself, ie rendered invalid by various members of
+ // TessBaseAPI, including Init, SetImage, End or deleting the TessBaseAPI.
+ // Pointsize is returned in printers points (1/72 inch.)
+ const char* WordFontAttributes(bool* is_bold,
+ bool* is_italic,
+ bool* is_underlined,
+ bool* is_monospace,
+ bool* is_serif,
+ bool* is_smallcaps,
+ int* pointsize,
+ int* font_id) const;
+
+ // Return the name of the language used to recognize this word.
+ // On error, NULL. Do not delete this pointer.
+ const char* WordRecognitionLanguage() const;
+
+ // Return the overall directionality of this word.
+ StrongScriptDirection WordDirection() const;
+
+ // Returns true if the current word was found in a dictionary.
+ bool WordIsFromDictionary() const;
+
+ // Returns true if the current word is numeric.
+ bool WordIsNumeric() const;
+
+ // Returns true if the word contains blamer information.
+ bool HasBlamerInfo() const;
+
+ // Returns the pointer to ParamsTrainingBundle stored in the BlamerBundle
+ // of the current word.
+ void *GetParamsTrainingBundle() const;
+
+ // Returns a pointer to the string with blamer information for this word.
+ // Assumes that the word's blamer_bundle is not NULL.
+ const char *GetBlamerDebug() const;
+
+ // Returns a pointer to the string with misadaption information for this word.
+ // Assumes that the word's blamer_bundle is not NULL.
+ const char *GetBlamerMisadaptionDebug() const;
+
+ // Returns a null terminated UTF-8 encoded truth string for the current word.
+ // Use delete [] to free after use.
+ char* WordTruthUTF8Text() const;
+
+ // Returns a pointer to serialized choice lattice.
+ // Fills lattice_size with the number of bytes in lattice data.
+ const char *WordLattice(int *lattice_size) const;
+
+ // ============= Functions that refer to symbols only ============.
+
+ // Returns true if the current symbol is a superscript.
+ // If iterating at a higher level object than symbols, eg words, then
+ // this will return the attributes of the first symbol in that word.
+ bool SymbolIsSuperscript() const;
+ // Returns true if the current symbol is a subscript.
+ // If iterating at a higher level object than symbols, eg words, then
+ // this will return the attributes of the first symbol in that word.
+ bool SymbolIsSubscript() const;
+ // Returns true if the current symbol is a dropcap.
+ // If iterating at a higher level object than symbols, eg words, then
+ // this will return the attributes of the first symbol in that word.
+ bool SymbolIsDropcap() const;
+
+ protected:
+ const char *line_separator_;
+ const char *paragraph_separator_;
+};
+
+// Class to iterate over the classifier choices for a single RIL_SYMBOL.
+class ChoiceIterator {
+ public:
+ // Construction is from a LTRResultIterator that points to the symbol of
+ // interest. The ChoiceIterator allows a one-shot iteration over the
+ // choices for this symbol and after that is is useless.
+ explicit ChoiceIterator(const LTRResultIterator& result_it);
+ ~ChoiceIterator();
+
+ // Moves to the next choice for the symbol and returns false if there
+ // are none left.
+ bool Next();
+
+ // ============= Accessing data ==============.
+
+ // Returns the null terminated UTF-8 encoded text string for the current
+ // choice.
+ // NOTE: Unlike LTRResultIterator::GetUTF8Text, the return points to an
+ // internal structure and should NOT be delete[]ed to free after use.
+ const char* GetUTF8Text() const;
+
+ // Returns the confidence of the current choice.
+ // The number should be interpreted as a percent probability. (0.0f-100.0f)
+ float Confidence() const;
+
+ private:
+ // Pointer to the WERD_RES object owned by the API.
+ WERD_RES* word_res_;
+ // Iterator over the blob choices.
+ BLOB_CHOICE_IT* choice_it_;
+};
+
+} // namespace tesseract.
+
+#endif // TESSERACT_CCMAIN_LTR_RESULT_ITERATOR_H__
diff --git a/card.io/src/main/jni/tesseract/memry.h b/card.io/src/main/jni/tesseract/memry.h
new file mode 100644
index 00000000..66e146e6
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/memry.h
@@ -0,0 +1,43 @@
+/**********************************************************************
+ * File: memry.h (Formerly memory.h)
+ * Description: Header file for basic memory allocation/deallocation.
+ * Author: Ray Smith
+ * Created: Tue May 8 16:03:48 BST 1990
+ *
+ * (C) Copyright 1990, Hewlett-Packard Ltd.
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ *
+ **********************************************************************/
+
+#ifndef MEMRY_H
+#define MEMRY_H
+
+#include
+#include "host.h"
+
+// allocate string
+extern char *alloc_string(inT32 count);
+// free a string.
+extern void free_string(char *string);
+// allocate memory
+extern void *alloc_struct(inT32 count, const char *name = NULL);
+// free a structure.
+extern void free_struct(void *deadstruct, inT32, const char *name = NULL);
+// get some memory
+extern void *alloc_mem(inT32 count);
+// get some memory initialized to 0.
+extern void *alloc_big_zeros(inT32 count);
+// free mem from alloc_mem
+extern void free_mem(void *oldchunk);
+// free mem from alloc_big_zeros
+extern void free_big_mem(void *oldchunk);
+
+#endif
diff --git a/card.io/src/main/jni/tesseract/ndminx.h b/card.io/src/main/jni/tesseract/ndminx.h
new file mode 100644
index 00000000..9eee76c0
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/ndminx.h
@@ -0,0 +1,31 @@
+/**********************************************************************
+ * File: ndminx.h (Formerly ndminmax.h)
+ * Description: Extended ascii chars
+ * Author: Phil Cheatle
+ * Created: Mon Mar 29 14:46:01 BST 1993
+ *
+ * (C) Copyright 1991, Hewlett-Packard Ltd.
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ *
+ **********************************************************************/
+
+#ifndef NDMINX_H
+#define NDMINX_H
+
+#ifndef MAX
+#define MAX(x,y) (((x) >= (y))?(x):(y))
+#endif
+
+#ifndef MIN
+#define MIN(x,y) (((x) <= (y))?(x):(y))
+#endif
+
+#endif
diff --git a/card.io/src/main/jni/tesseract/ocrclass.h b/card.io/src/main/jni/tesseract/ocrclass.h
new file mode 100644
index 00000000..37556b30
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/ocrclass.h
@@ -0,0 +1,153 @@
+/**********************************************************************
+ * File: ocrclass.h
+ * Description: Class definitions and constants for the OCR API.
+ * Author: Hewlett-Packard Co
+ *
+ * (C) Copyright 1996, Hewlett-Packard Co.
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * This file contains typedefs for all the structures used by
+ * the HP OCR interface.
+ * The code is designed to be used with either a C or C++ compiler.
+ * The structures are designed to allow them to be used with any
+ * structure alignment upto 8.
+ **********************************************************************/
+
+#ifndef CCUTIL_OCRCLASS_H_
+#define CCUTIL_OCRCLASS_H_
+
+#ifndef __GNUC__
+#ifdef _WIN32
+#include
+#include "gettimeofday.h"
+#endif
+#else
+#include
+#endif
+#include
+#include "host.h"
+
+/*Maximum lengths of various strings*/
+#define MAX_FONT_NAME 34 /*name of font */
+#define MAX_OCR_NAME 32 /*name of engine */
+#define MAX_OCR_VERSION 17 /*version code of engine */
+
+/*pitch set definitions are identical to RTF*/
+#define PITCH_DEF 0 /*default */
+#define PITCH_FIXED 1 /*fixed pitch */
+#define PITCH_VAR 2 /*variable pitch */
+
+/**********************************************************************
+ * EANYCODE_CHAR
+ * Description of a single character. The character code is defined by
+ * the character set of the current font.
+ * Output text is sent as an array of these structures.
+ * Spaces and line endings in the output are represented in the
+ * structures of the surrounding characters. They are not directly
+ * represented as characters.
+ * The first character in a word has a positive value of blanks.
+ * Missing information should be set to the defaults in the comments.
+ * If word bounds are known, but not character bounds, then the top and
+ * bottom of each character should be those of the word. The left of the
+ * first and right of the last char in each word should be set. All other
+ * lefts and rights should be set to -1.
+ * If set, the values of right and bottom are left+width and top+height.
+ * Most of the members come directly from the parameters to ocr_append_char.
+ * The formatting member uses the enhancement parameter and combines the
+ * line direction stuff into the top 3 bits.
+ * The coding is 0=RL char, 1=LR char, 2=DR NL, 3=UL NL, 4=DR Para,
+ * 5=UL Para, 6=TB char, 7=BT char. API users do not need to know what
+ * the coding is, only that it is backwards compatible with the previous
+ * version.
+ **********************************************************************/
+
+typedef struct { /*single character */
+// It should be noted that the format for char_code for version 2.0 and beyond
+// is UTF8 which means that ASCII characters will come out as one structure but
+// other characters will be returned in two or more instances of this structure
+// with a single byte of the UTF8 code in each, but each will have the same
+// bounding box. Programs which want to handle languagues with different
+// characters sets will need to handle extended characters appropriately, but
+// *all* code needs to be prepared to receive UTF8 coded characters for
+// characters such as bullet and fancy quotes.
+ uinT16 char_code; /*character itself */
+ inT16 left; /*of char (-1) */
+ inT16 right; /*of char (-1) */
+ inT16 top; /*of char (-1) */
+ inT16 bottom; /*of char (-1) */
+ inT16 font_index; /*what font (0) */
+ uinT8 confidence; /*0=perfect, 100=reject (0/100) */
+ uinT8 point_size; /*of char, 72=i inch, (10) */
+ inT8 blanks; /*no of spaces before this char (1) */
+ uinT8 formatting; /*char formatting (0) */
+} EANYCODE_CHAR; /*single character */
+
+/**********************************************************************
+ * ETEXT_DESC
+ * Description of the output of the OCR engine.
+ * This structure is used as both a progress monitor and the final
+ * output header, since it needs to be a valid progress monitor while
+ * the OCR engine is storing its output to shared memory.
+ * During progress, all the buffer info is -1.
+ * Progress starts at 0 and increases to 100 during OCR. No other constraint.
+ * Every progress callback, the OCR engine must set ocr_alive to 1.
+ * The HP side will set ocr_alive to 0. Repeated failure to reset
+ * to 1 indicates that the OCR engine is dead.
+ * If the cancel function is not null then it is called with the number of
+ * user words found. If it returns true then operation is cancelled.
+ **********************************************************************/
+typedef bool (*CANCEL_FUNC)(void* cancel_this, int words);
+
+class ETEXT_DESC { // output header
+ public:
+ inT16 count; // chars in this buffer(0)
+ inT16 progress; // percent complete increasing (0-100)
+ inT8 more_to_come; // true if not last
+ volatile inT8 ocr_alive; // ocr sets to 1, HP 0
+ inT8 err_code; // for errcode use
+ CANCEL_FUNC cancel; // returns true to cancel
+ void* cancel_this; // this or other data for cancel
+ struct timeval end_time; // time to stop. expected to be set only by call
+ // to set_deadline_msecs()
+ EANYCODE_CHAR text[1]; // character data
+
+ ETEXT_DESC() : count(0), progress(0), more_to_come(0), ocr_alive(0),
+ err_code(0), cancel(NULL), cancel_this(NULL) {
+ end_time.tv_sec = 0;
+ end_time.tv_usec = 0;
+ }
+
+ // Sets the end time to be deadline_msecs milliseconds from now.
+ void set_deadline_msecs(inT32 deadline_msecs) {
+ gettimeofday(&end_time, NULL);
+ inT32 deadline_secs = deadline_msecs / 1000;
+ end_time.tv_sec += deadline_secs;
+ end_time.tv_usec += (deadline_msecs - deadline_secs * 1000) * 1000;
+ if (end_time.tv_usec > 1000000) {
+ end_time.tv_usec -= 1000000;
+ ++end_time.tv_sec;
+ }
+ }
+
+ // Returns false if we've not passed the end_time, or have not set a deadline.
+ bool deadline_exceeded() const {
+ if (end_time.tv_sec == 0 && end_time.tv_usec == 0) return false;
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ return (now.tv_sec > end_time.tv_sec || (now.tv_sec == end_time.tv_sec &&
+ now.tv_usec > end_time.tv_usec));
+ }
+};
+
+#endif // CCUTIL_OCRCLASS_H_
diff --git a/card.io/src/main/jni/tesseract/pageiterator.h b/card.io/src/main/jni/tesseract/pageiterator.h
new file mode 100644
index 00000000..0d6084f9
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/pageiterator.h
@@ -0,0 +1,327 @@
+///////////////////////////////////////////////////////////////////////
+// File: pageiterator.h
+// Description: Iterator for tesseract page structure that avoids using
+// tesseract internal data structures.
+// Author: Ray Smith
+// Created: Fri Feb 26 11:01:06 PST 2010
+//
+// (C) Copyright 2010, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef TESSERACT_CCMAIN_PAGEITERATOR_H__
+#define TESSERACT_CCMAIN_PAGEITERATOR_H__
+
+#include "publictypes.h"
+#include "platform.h"
+
+class C_BLOB_IT;
+class PBLOB_IT;
+class PAGE_RES;
+class PAGE_RES_IT;
+class WERD;
+struct Pix;
+
+namespace tesseract {
+
+class Tesseract;
+
+/**
+ * Class to iterate over tesseract page structure, providing access to all
+ * levels of the page hierarchy, without including any tesseract headers or
+ * having to handle any tesseract structures.
+ * WARNING! This class points to data held within the TessBaseAPI class, and
+ * therefore can only be used while the TessBaseAPI class still exists and
+ * has not been subjected to a call of Init, SetImage, Recognize, Clear, End
+ * DetectOS, or anything else that changes the internal PAGE_RES.
+ * See apitypes.h for the definition of PageIteratorLevel.
+ * See also ResultIterator, derived from PageIterator, which adds in the
+ * ability to access OCR output with text-specific methods.
+ */
+
+class TESS_API PageIterator {
+ public:
+ /**
+ * page_res and tesseract come directly from the BaseAPI.
+ * The rectangle parameters are copied indirectly from the Thresholder,
+ * via the BaseAPI. They represent the coordinates of some rectangle in an
+ * original image (in top-left-origin coordinates) and therefore the top-left
+ * needs to be added to any output boxes in order to specify coordinates
+ * in the original image. See TessBaseAPI::SetRectangle.
+ * The scale and scaled_yres are in case the Thresholder scaled the image
+ * rectangle prior to thresholding. Any coordinates in tesseract's image
+ * must be divided by scale before adding (rect_left, rect_top).
+ * The scaled_yres indicates the effective resolution of the binary image
+ * that tesseract has been given by the Thresholder.
+ * After the constructor, Begin has already been called.
+ */
+ PageIterator(PAGE_RES* page_res, Tesseract* tesseract,
+ int scale, int scaled_yres,
+ int rect_left, int rect_top,
+ int rect_width, int rect_height);
+ virtual ~PageIterator();
+
+ /**
+ * Page/ResultIterators may be copied! This makes it possible to iterate over
+ * all the objects at a lower level, while maintaining an iterator to
+ * objects at a higher level. These constructors DO NOT CALL Begin, so
+ * iterations will continue from the location of src.
+ */
+ PageIterator(const PageIterator& src);
+ const PageIterator& operator=(const PageIterator& src);
+
+ /** Are we positioned at the same location as other? */
+ bool PositionedAtSameWord(const PAGE_RES_IT* other) const;
+
+ // ============= Moving around within the page ============.
+
+ /**
+ * Moves the iterator to point to the start of the page to begin an
+ * iteration.
+ */
+ virtual void Begin();
+
+ /**
+ * Moves the iterator to the beginning of the paragraph.
+ * This class implements this functionality by moving it to the zero indexed
+ * blob of the first (leftmost) word on the first row of the paragraph.
+ */
+ virtual void RestartParagraph();
+
+ /**
+ * Return whether this iterator points anywhere in the first textline of a
+ * paragraph.
+ */
+ bool IsWithinFirstTextlineOfParagraph() const;
+
+ /**
+ * Moves the iterator to the beginning of the text line.
+ * This class implements this functionality by moving it to the zero indexed
+ * blob of the first (leftmost) word of the row.
+ */
+ virtual void RestartRow();
+
+ /**
+ * Moves to the start of the next object at the given level in the
+ * page hierarchy, and returns false if the end of the page was reached.
+ * NOTE that RIL_SYMBOL will skip non-text blocks, but all other
+ * PageIteratorLevel level values will visit each non-text block once.
+ * Think of non text blocks as containing a single para, with a single line,
+ * with a single imaginary word.
+ * Calls to Next with different levels may be freely intermixed.
+ * This function iterates words in right-to-left scripts correctly, if
+ * the appropriate language has been loaded into Tesseract.
+ */
+ virtual bool Next(PageIteratorLevel level);
+
+ /**
+ * Returns true if the iterator is at the start of an object at the given
+ * level.
+ *
+ * For instance, suppose an iterator it is pointed to the first symbol of the
+ * first word of the third line of the second paragraph of the first block in
+ * a page, then:
+ * it.IsAtBeginningOf(RIL_BLOCK) = false
+ * it.IsAtBeginningOf(RIL_PARA) = false
+ * it.IsAtBeginningOf(RIL_TEXTLINE) = true
+ * it.IsAtBeginningOf(RIL_WORD) = true
+ * it.IsAtBeginningOf(RIL_SYMBOL) = true
+ */
+ virtual bool IsAtBeginningOf(PageIteratorLevel level) const;
+
+ /**
+ * Returns whether the iterator is positioned at the last element in a
+ * given level. (e.g. the last word in a line, the last line in a block)
+ *
+ * Here's some two-paragraph example
+ * text. It starts off innocuously
+ * enough but quickly turns bizarre.
+ * The author inserts a cornucopia
+ * of words to guard against confused
+ * references.
+ *
+ * Now take an iterator it pointed to the start of "bizarre."
+ * it.IsAtFinalElement(RIL_PARA, RIL_SYMBOL) = false
+ * it.IsAtFinalElement(RIL_PARA, RIL_WORD) = true
+ * it.IsAtFinalElement(RIL_BLOCK, RIL_WORD) = false
+ */
+ virtual bool IsAtFinalElement(PageIteratorLevel level,
+ PageIteratorLevel element) const;
+
+ /**
+ * Returns whether this iterator is positioned
+ * before other: -1
+ * equal to other: 0
+ * after other: 1
+ */
+ int Cmp(const PageIterator &other) const;
+
+ // ============= Accessing data ==============.
+ // Coordinate system:
+ // Integer coordinates are at the cracks between the pixels.
+ // The top-left corner of the top-left pixel in the image is at (0,0).
+ // The bottom-right corner of the bottom-right pixel in the image is at
+ // (width, height).
+ // Every bounding box goes from the top-left of the top-left contained
+ // pixel to the bottom-right of the bottom-right contained pixel, so
+ // the bounding box of the single top-left pixel in the image is:
+ // (0,0)->(1,1).
+ // If an image rectangle has been set in the API, then returned coordinates
+ // relate to the original (full) image, rather than the rectangle.
+
+ /**
+ * Returns the bounding rectangle of the current object at the given level.
+ * See comment on coordinate system above.
+ * Returns false if there is no such object at the current position.
+ * The returned bounding box is guaranteed to match the size and position
+ * of the image returned by GetBinaryImage, but may clip foreground pixels
+ * from a grey image. The padding argument to GetImage can be used to expand
+ * the image to include more foreground pixels. See GetImage below.
+ */
+ bool BoundingBox(PageIteratorLevel level,
+ int* left, int* top, int* right, int* bottom) const;
+ /**
+ * Returns the bounding rectangle of the object in a coordinate system of the
+ * working image rectangle having its origin at (rect_left_, rect_top_) with
+ * respect to the original image and is scaled by a factor scale_.
+ */
+ bool BoundingBoxInternal(PageIteratorLevel level,
+ int* left, int* top, int* right, int* bottom) const;
+
+ /** Returns whether there is no object of a given level. */
+ bool Empty(PageIteratorLevel level) const;
+
+ /**
+ * Returns the type of the current block. See apitypes.h for
+ * PolyBlockType.
+ */
+ PolyBlockType BlockType() const;
+
+ /**
+ * Returns a binary image of the current object at the given level.
+ * The position and size match the return from BoundingBoxInternal, and so
+ * this could be upscaled with respect to the original input image.
+ * Use pixDestroy to delete the image after use.
+ */
+ Pix* GetBinaryImage(PageIteratorLevel level) const;
+
+ /**
+ * Returns an image of the current object at the given level in greyscale
+ * if available in the input. To guarantee a binary image use BinaryImage.
+ * NOTE that in order to give the best possible image, the bounds are
+ * expanded slightly over the binary connected component, by the supplied
+ * padding, so the top-left position of the returned image is returned
+ * in (left,top). These will most likely not match the coordinates
+ * returned by BoundingBox.
+ * Use pixDestroy to delete the image after use.
+ */
+ Pix* GetImage(PageIteratorLevel level, int padding,
+ int* left, int* top) const;
+
+ /**
+ * Returns the baseline of the current object at the given level.
+ * The baseline is the line that passes through (x1, y1) and (x2, y2).
+ * WARNING: with vertical text, baselines may be vertical!
+ * Returns false if there is no baseline at the current position.
+ */
+ bool Baseline(PageIteratorLevel level,
+ int* x1, int* y1, int* x2, int* y2) const;
+
+ /**
+ * Returns orientation for the block the iterator points to.
+ * orientation, writing_direction, textline_order: see publictypes.h
+ * deskew_angle: after rotating the block so the text orientation is
+ * upright, how many radians does one have to rotate the
+ * block anti-clockwise for it to be level?
+ * -Pi/4 <= deskew_angle <= Pi/4
+ */
+ void Orientation(tesseract::Orientation *orientation,
+ tesseract::WritingDirection *writing_direction,
+ tesseract::TextlineOrder *textline_order,
+ float *deskew_angle) const;
+
+ /**
+ * Returns information about the current paragraph, if available.
+ *
+ * justification -
+ * LEFT if ragged right, or fully justified and script is left-to-right.
+ * RIGHT if ragged left, or fully justified and script is right-to-left.
+ * unknown if it looks like source code or we have very few lines.
+ * is_list_item -
+ * true if we believe this is a member of an ordered or unordered list.
+ * is_crown -
+ * true if the first line of the paragraph is aligned with the other
+ * lines of the paragraph even though subsequent paragraphs have first
+ * line indents. This typically indicates that this is the continuation
+ * of a previous paragraph or that it is the very first paragraph in
+ * the chapter.
+ * first_line_indent -
+ * For LEFT aligned paragraphs, the first text line of paragraphs of
+ * this kind are indented this many pixels from the left edge of the
+ * rest of the paragraph.
+ * for RIGHT aligned paragraphs, the first text line of paragraphs of
+ * this kind are indented this many pixels from the right edge of the
+ * rest of the paragraph.
+ * NOTE 1: This value may be negative.
+ * NOTE 2: if *is_crown == true, the first line of this paragraph is
+ * actually flush, and first_line_indent is set to the "common"
+ * first_line_indent for subsequent paragraphs in this block
+ * of text.
+ */
+ void ParagraphInfo(tesseract::ParagraphJustification *justification,
+ bool *is_list_item,
+ bool *is_crown,
+ int *first_line_indent) const;
+
+ protected:
+ /**
+ * Sets up the internal data for iterating the blobs of a new word, then
+ * moves the iterator to the given offset.
+ */
+ TESS_LOCAL void BeginWord(int offset);
+
+ /** Pointer to the page_res owned by the API. */
+ PAGE_RES* page_res_;
+ /** Pointer to the Tesseract object owned by the API. */
+ Tesseract* tesseract_;
+ /**
+ * The iterator to the page_res_. Owned by this ResultIterator.
+ * A pointer just to avoid dragging in Tesseract includes.
+ */
+ PAGE_RES_IT* it_;
+ /**
+ * The current input WERD being iterated. If there is an output from OCR,
+ * then word_ is NULL. Owned by the API
+ */
+ WERD* word_;
+ /** The length of the current word_. */
+ int word_length_;
+ /** The current blob index within the word. */
+ int blob_index_;
+ /**
+ * Iterator to the blobs within the word. If NULL, then we are iterating
+ * OCR results in the box_word.
+ * Owned by this ResultIterator.
+ */
+ C_BLOB_IT* cblob_it_;
+ /** Parameters saved from the Thresholder. Needed to rebuild coordinates.*/
+ int scale_;
+ int scaled_yres_;
+ int rect_left_;
+ int rect_top_;
+ int rect_width_;
+ int rect_height_;
+};
+
+} // namespace tesseract.
+
+#endif // TESSERACT_CCMAIN_PAGEITERATOR_H__
diff --git a/card.io/src/main/jni/tesseract/platform.h b/card.io/src/main/jni/tesseract/platform.h
new file mode 100644
index 00000000..4f8a8164
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/platform.h
@@ -0,0 +1,72 @@
+///////////////////////////////////////////////////////////////////////
+// File: platform.h
+// Description: Place holder
+// Author:
+// Created:
+//
+// (C) Copyright 2006, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef TESSERACT_CCUTIL_PLATFORM_H__
+#define TESSERACT_CCUTIL_PLATFORM_H__
+
+#define DLLSYM
+#ifdef _WIN32
+#ifdef __GNUC__
+#define ultoa _ultoa
+typedef struct _BLOB {
+ unsigned int cbSize;
+ char *pBlobData;
+} BLOB, *LPBLOB;
+#endif /* __GNUC__ */
+#define SIGNED
+#define snprintf _snprintf
+#if (_MSC_VER <= 1400)
+#define vsnprintf _vsnprintf
+#endif /* _WIN32 */
+#else
+#define __UNIX__
+#include
+#ifndef PATH_MAX
+#define MAX_PATH 4096
+#else
+#define MAX_PATH PATH_MAX
+#endif
+#define SIGNED signed
+#endif
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+ #if defined(TESS_EXPORTS)
+ #define TESS_API __declspec(dllexport)
+ #elif defined(TESS_IMPORTS)
+ #define TESS_API __declspec(dllimport)
+ #else
+ #define TESS_API
+ #endif
+ #define TESS_LOCAL
+#else
+ #if __GNUC__ >= 4
+ #if defined(TESS_EXPORTS) || defined(TESS_IMPORTS)
+ #define TESS_API __attribute__ ((visibility ("default")))
+ #define TESS_LOCAL __attribute__ ((visibility ("hidden")))
+ #else
+ #define TESS_API
+ #define TESS_LOCAL
+ #endif
+ #else
+ #define TESS_API
+ #define TESS_LOCAL
+ #endif
+#endif
+
+#endif // TESSERACT_CCUTIL_PLATFORM_H__
diff --git a/card.io/src/main/jni/tesseract/publictypes.h b/card.io/src/main/jni/tesseract/publictypes.h
new file mode 100644
index 00000000..3640d54f
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/publictypes.h
@@ -0,0 +1,249 @@
+///////////////////////////////////////////////////////////////////////
+// File: publictypes.h
+// Description: Types used in both the API and internally
+// Author: Ray Smith
+// Created: Wed Mar 03 09:22:53 PST 2010
+//
+// (C) Copyright 2010, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef TESSERACT_CCSTRUCT_PUBLICTYPES_H__
+#define TESSERACT_CCSTRUCT_PUBLICTYPES_H__
+
+// This file contains types that are used both by the API and internally
+// to Tesseract. In order to decouple the API from Tesseract and prevent cyclic
+// dependencies, THIS FILE SHOULD NOT DEPEND ON ANY OTHER PART OF TESSERACT.
+// Restated: It is OK for low-level Tesseract files to include publictypes.h,
+// but not for the low-level tesseract code to include top-level API code.
+// This file should not use other Tesseract types, as that would drag
+// their includes into the API-level.
+// API-level code should include apitypes.h in preference to this file.
+
+/** Number of printers' points in an inch. The unit of the pointsize return. */
+const int kPointsPerInch = 72;
+
+/**
+ * Possible types for a POLY_BLOCK or ColPartition.
+ * Must be kept in sync with kPBColors in polyblk.cpp and PTIs*Type functions
+ * below, as well as kPolyBlockNames in publictypes.cpp.
+ * Used extensively by ColPartition, and POLY_BLOCK.
+*/
+enum PolyBlockType {
+ PT_UNKNOWN, // Type is not yet known. Keep as the first element.
+ PT_FLOWING_TEXT, // Text that lives inside a column.
+ PT_HEADING_TEXT, // Text that spans more than one column.
+ PT_PULLOUT_TEXT, // Text that is in a cross-column pull-out region.
+ PT_EQUATION, // Partition belonging to an equation region.
+ PT_INLINE_EQUATION, // Partition has inline equation.
+ PT_TABLE, // Partition belonging to a table region.
+ PT_VERTICAL_TEXT, // Text-line runs vertically.
+ PT_CAPTION_TEXT, // Text that belongs to an image.
+ PT_FLOWING_IMAGE, // Image that lives inside a column.
+ PT_HEADING_IMAGE, // Image that spans more than one column.
+ PT_PULLOUT_IMAGE, // Image that is in a cross-column pull-out region.
+ PT_HORZ_LINE, // Horizontal Line.
+ PT_VERT_LINE, // Vertical Line.
+ PT_NOISE, // Lies outside of any column.
+ PT_COUNT
+};
+
+/** Returns true if PolyBlockType is of horizontal line type */
+inline bool PTIsLineType(PolyBlockType type) {
+ return type == PT_HORZ_LINE || type == PT_VERT_LINE;
+}
+/** Returns true if PolyBlockType is of image type */
+inline bool PTIsImageType(PolyBlockType type) {
+ return type == PT_FLOWING_IMAGE || type == PT_HEADING_IMAGE ||
+ type == PT_PULLOUT_IMAGE;
+}
+/** Returns true if PolyBlockType is of text type */
+inline bool PTIsTextType(PolyBlockType type) {
+ return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
+ type == PT_PULLOUT_TEXT || type == PT_TABLE ||
+ type == PT_VERTICAL_TEXT || type == PT_CAPTION_TEXT ||
+ type == PT_INLINE_EQUATION;
+}
+
+/** String name for each block type. Keep in sync with PolyBlockType. */
+extern const char* kPolyBlockNames[];
+
+namespace tesseract {
+/**
+ * +------------------+ Orientation Example:
+ * | 1 Aaaa Aaaa Aaaa | ====================
+ * | Aaa aa aaa aa | To left is a diagram of some (1) English and
+ * | aaaaaa A aa aaa. | (2) Chinese text and a (3) photo credit.
+ * | 2 |
+ * | ####### c c C | Upright Latin characters are represented as A and a.
+ * | ####### c c c | '<' represents a latin character rotated
+ * | < ####### c c c | anti-clockwise 90 degrees.
+ * | < ####### c c |
+ * | < ####### . c | Upright Chinese characters are represented C and c.
+ * | 3 ####### c |
+ * +------------------+ NOTA BENE: enum values here should match goodoc.proto
+
+ * If you orient your head so that "up" aligns with Orientation,
+ * then the characters will appear "right side up" and readable.
+ *
+ * In the example above, both the English and Chinese paragraphs are oriented
+ * so their "up" is the top of the page (page up). The photo credit is read
+ * with one's head turned leftward ("up" is to page left).
+ *
+ * The values of this enum match the convention of Tesseract's osdetect.h
+*/
+enum Orientation {
+ ORIENTATION_PAGE_UP = 0,
+ ORIENTATION_PAGE_RIGHT = 1,
+ ORIENTATION_PAGE_DOWN = 2,
+ ORIENTATION_PAGE_LEFT = 3,
+};
+
+/**
+ * The grapheme clusters within a line of text are laid out logically
+ * in this direction, judged when looking at the text line rotated so that
+ * its Orientation is "page up".
+ *
+ * For English text, the writing direction is left-to-right. For the
+ * Chinese text in the above example, the writing direction is top-to-bottom.
+*/
+enum WritingDirection {
+ WRITING_DIRECTION_LEFT_TO_RIGHT = 0,
+ WRITING_DIRECTION_RIGHT_TO_LEFT = 1,
+ WRITING_DIRECTION_TOP_TO_BOTTOM = 2,
+};
+
+/**
+ * The text lines are read in the given sequence.
+ *
+ * In English, the order is top-to-bottom.
+ * In Chinese, vertical text lines are read right-to-left. Mongolian is
+ * written in vertical columns top to bottom like Chinese, but the lines
+ * order left-to right.
+ *
+ * Note that only some combinations make sense. For example,
+ * WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM
+*/
+enum TextlineOrder {
+ TEXTLINE_ORDER_LEFT_TO_RIGHT = 0,
+ TEXTLINE_ORDER_RIGHT_TO_LEFT = 1,
+ TEXTLINE_ORDER_TOP_TO_BOTTOM = 2,
+};
+
+/**
+ * Possible modes for page layout analysis. These *must* be kept in order
+ * of decreasing amount of layout analysis to be done, except for OSD_ONLY,
+ * so that the inequality test macros below work.
+*/
+enum PageSegMode {
+ PSM_OSD_ONLY, ///< Orientation and script detection only.
+ PSM_AUTO_OSD, ///< Automatic page segmentation with orientation and
+ ///< script detection. (OSD)
+ PSM_AUTO_ONLY, ///< Automatic page segmentation, but no OSD, or OCR.
+ PSM_AUTO, ///< Fully automatic page segmentation, but no OSD.
+ PSM_SINGLE_COLUMN, ///< Assume a single column of text of variable sizes.
+ PSM_SINGLE_BLOCK_VERT_TEXT, ///< Assume a single uniform block of vertically
+ ///< aligned text.
+ PSM_SINGLE_BLOCK, ///< Assume a single uniform block of text. (Default.)
+ PSM_SINGLE_LINE, ///< Treat the image as a single text line.
+ PSM_SINGLE_WORD, ///< Treat the image as a single word.
+ PSM_CIRCLE_WORD, ///< Treat the image as a single word in a circle.
+ PSM_SINGLE_CHAR, ///< Treat the image as a single character.
+
+ PSM_COUNT ///< Number of enum entries.
+};
+
+/**
+ * Macros that act on a PageSegMode to determine whether components of
+ * layout analysis are enabled.
+ * *Depend critically on the order of elements of PageSegMode.*
+*/
+#define PSM_OSD_ENABLED(pageseg_mode) ((pageseg_mode) <= PSM_AUTO_OSD)
+#define PSM_COL_FIND_ENABLED(pageseg_mode) \
+ ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_AUTO)
+#define PSM_BLOCK_FIND_ENABLED(pageseg_mode) \
+ ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_COLUMN)
+#define PSM_LINE_FIND_ENABLED(pageseg_mode) \
+ ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_BLOCK)
+#define PSM_WORD_FIND_ENABLED(pageseg_mode) \
+ ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_LINE)
+
+/**
+ * enum of the elements of the page hierarchy, used in ResultIterator
+ * to provide functions that operate on each level without having to
+ * have 5x as many functions.
+*/
+enum PageIteratorLevel {
+ RIL_BLOCK, // Block of text/image/separator line.
+ RIL_PARA, // Paragraph within a block.
+ RIL_TEXTLINE, // Line within a paragraph.
+ RIL_WORD, // Word within a textline.
+ RIL_SYMBOL // Symbol/character within a word.
+};
+
+/**
+ * JUSTIFICATION_UNKNONW
+ * The alignment is not clearly one of the other options. This could happen
+ * for example if there are only one or two lines of text or the text looks
+ * like source code or poetry.
+ *
+ * NOTA BENE: Fully justified paragraphs (text aligned to both left and right
+ * margins) are marked by Tesseract with JUSTIFICATION_LEFT if their text
+ * is written with a left-to-right script and with JUSTIFICATION_RIGHT if
+ * their text is written in a right-to-left script.
+ *
+ * Interpretation for text read in vertical lines:
+ * "Left" is wherever the starting reading position is.
+ *
+ * JUSTIFICATION_LEFT
+ * Each line, except possibly the first, is flush to the same left tab stop.
+ *
+ * JUSTIFICATION_CENTER
+ * The text lines of the paragraph are centered about a line going
+ * down through their middle of the text lines.
+ *
+ * JUSTIFICATION_RIGHT
+ * Each line, except possibly the first, is flush to the same right tab stop.
+*/
+enum ParagraphJustification {
+ JUSTIFICATION_UNKNOWN,
+ JUSTIFICATION_LEFT,
+ JUSTIFICATION_CENTER,
+ JUSTIFICATION_RIGHT,
+};
+
+/**
+ * When Tesseract/Cube is initialized we can choose to instantiate/load/run
+ * only the Tesseract part, only the Cube part or both along with the combiner.
+ * The preference of which engine to use is stored in tessedit_ocr_engine_mode.
+ *
+ * ATTENTION: When modifying this enum, please make sure to make the
+ * appropriate changes to all the enums mirroring it (e.g. OCREngine in
+ * cityblock/workflow/detection/detection_storage.proto). Such enums will
+ * mention the connection to OcrEngineMode in the comments.
+*/
+enum OcrEngineMode {
+ OEM_TESSERACT_ONLY, // Run Tesseract only - fastest
+ OEM_CUBE_ONLY, // Run Cube only - better accuracy, but slower
+ OEM_TESSERACT_CUBE_COMBINED, // Run both and combine results - best accuracy
+ OEM_DEFAULT // Specify this mode when calling init_*(),
+ // to indicate that any of the above modes
+ // should be automatically inferred from the
+ // variables in the language-specific config,
+ // command-line configs, or if not specified
+ // in any of the above should be set to the
+ // default OEM_TESSERACT_ONLY.
+};
+
+} // namespace tesseract.
+
+#endif // TESSERACT_CCSTRUCT_PUBLICTYPES_H__
diff --git a/card.io/src/main/jni/tesseract/resultiterator.h b/card.io/src/main/jni/tesseract/resultiterator.h
new file mode 100644
index 00000000..c9d880b4
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/resultiterator.h
@@ -0,0 +1,237 @@
+///////////////////////////////////////////////////////////////////////
+// File: resultiterator.h
+// Description: Iterator for tesseract results that is capable of
+// iterating in proper reading order over Bi Directional
+// (e.g. mixed Hebrew and English) text.
+// Author: David Eger
+// Created: Fri May 27 13:58:06 PST 2011
+//
+// (C) Copyright 2011, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef TESSERACT_CCMAIN_RESULT_ITERATOR_H__
+#define TESSERACT_CCMAIN_RESULT_ITERATOR_H__
+
+#include "platform.h"
+#include "ltrresultiterator.h"
+#include "genericvector.h"
+
+class BLOB_CHOICE_IT;
+class WERD_RES;
+class STRING;
+
+namespace tesseract {
+
+class Tesseract;
+
+class TESS_API ResultIterator : public LTRResultIterator {
+ public:
+ static ResultIterator *StartOfParagraph(const LTRResultIterator &resit);
+
+ /**
+ * ResultIterator is copy constructible!
+ * The default copy constructor works just fine for us.
+ */
+ virtual ~ResultIterator() {}
+
+ // ============= Moving around within the page ============.
+ /**
+ * Moves the iterator to point to the start of the page to begin
+ * an iteration.
+ */
+ virtual void Begin();
+
+ /**
+ * Moves to the start of the next object at the given level in the
+ * page hierarchy in the appropriate reading order and returns false if
+ * the end of the page was reached.
+ * NOTE that RIL_SYMBOL will skip non-text blocks, but all other
+ * PageIteratorLevel level values will visit each non-text block once.
+ * Think of non text blocks as containing a single para, with a single line,
+ * with a single imaginary word.
+ * Calls to Next with different levels may be freely intermixed.
+ * This function iterates words in right-to-left scripts correctly, if
+ * the appropriate language has been loaded into Tesseract.
+ */
+ virtual bool Next(PageIteratorLevel level);
+
+ /**
+ * IsAtBeginningOf() returns whether we're at the logical beginning of the
+ * given level. (as opposed to ResultIterator's left-to-right top-to-bottom
+ * order). Otherwise, this acts the same as PageIterator::IsAtBeginningOf().
+ * For a full description, see pageiterator.h
+ */
+ virtual bool IsAtBeginningOf(PageIteratorLevel level) const;
+
+ /**
+ * Implement PageIterator's IsAtFinalElement correctly in a BiDi context.
+ * For instance, IsAtFinalElement(RIL_PARA, RIL_WORD) returns whether we
+ * point at the last word in a paragraph. See PageIterator for full comment.
+ */
+ virtual bool IsAtFinalElement(PageIteratorLevel level,
+ PageIteratorLevel element) const;
+
+ // ============= Accessing data ==============.
+
+ /**
+ * Returns the null terminated UTF-8 encoded text string for the current
+ * object at the given level. Use delete [] to free after use.
+ */
+ virtual char* GetUTF8Text(PageIteratorLevel level) const;
+
+ /**
+ * Return whether the current paragraph's dominant reading direction
+ * is left-to-right (as opposed to right-to-left).
+ */
+ bool ParagraphIsLtr() const;
+
+ // ============= Exposed only for testing =============.
+
+ /**
+ * Yields the reading order as a sequence of indices and (optional)
+ * meta-marks for a set of words (given left-to-right).
+ * The meta marks are passed as negative values:
+ * kMinorRunStart Start of minor direction text.
+ * kMinorRunEnd End of minor direction text.
+ * kComplexWord The next indexed word contains both left-to-right and
+ * right-to-left characters and was treated as neutral.
+ *
+ * For example, suppose we have five words in a text line,
+ * indexed [0,1,2,3,4] from the leftmost side of the text line.
+ * The following are all believable reading_orders:
+ *
+ * Left-to-Right (in ltr paragraph):
+ * { 0, 1, 2, 3, 4 }
+ * Left-to-Right (in rtl paragraph):
+ * { kMinorRunStart, 0, 1, 2, 3, 4, kMinorRunEnd }
+ * Right-to-Left (in rtl paragraph):
+ * { 4, 3, 2, 1, 0 }
+ * Left-to-Right except for an RTL phrase in words 2, 3 in an ltr paragraph:
+ * { 0, 1, kMinorRunStart, 3, 2, kMinorRunEnd, 4 }
+ */
+ static void CalculateTextlineOrder(
+ bool paragraph_is_ltr,
+ const GenericVector &word_dirs,
+ GenericVectorEqEq *reading_order);
+
+ static const int kMinorRunStart;
+ static const int kMinorRunEnd;
+ static const int kComplexWord;
+
+ protected:
+ /**
+ * We presume the data associated with the given iterator will outlive us.
+ * NB: This is private because it does something that is non-obvious:
+ * it resets to the beginning of the paragraph instead of staying wherever
+ * resit might have pointed.
+ */
+ TESS_LOCAL explicit ResultIterator(const LTRResultIterator &resit);
+
+ private:
+ /**
+ * Calculates the current paragraph's dominant writing direction.
+ * Typically, members should use current_paragraph_ltr_ instead.
+ */
+ bool CurrentParagraphIsLtr() const;
+
+ /**
+ * Returns word indices as measured from resit->RestartRow() = index 0
+ * for the reading order of words within a textline given an iterator
+ * into the middle of the text line.
+ * In addition to non-negative word indices, the following negative values
+ * may be inserted:
+ * kMinorRunStart Start of minor direction text.
+ * kMinorRunEnd End of minor direction text.
+ * kComplexWord The previous word contains both left-to-right and
+ * right-to-left characters and was treated as neutral.
+ */
+ void CalculateTextlineOrder(bool paragraph_is_ltr,
+ const LTRResultIterator &resit,
+ GenericVectorEqEq *indices) const;
+ /** Same as above, but the caller's ssd gets filled in if ssd != NULL. */
+ void CalculateTextlineOrder(bool paragraph_is_ltr,
+ const LTRResultIterator &resit,
+ GenericVector *ssd,
+ GenericVectorEqEq *indices) const;
+
+ /**
+ * What is the index of the current word in a strict left-to-right reading
+ * of the row?
+ */
+ int LTRWordIndex() const;
+
+ /**
+ * Given an iterator pointing at a word, returns the logical reading order
+ * of blob indices for the word.
+ */
+ void CalculateBlobOrder(GenericVector *blob_indices) const;
+
+ /** Precondition: current_paragraph_is_ltr_ is set. */
+ void MoveToLogicalStartOfTextline();
+
+ /**
+ * Precondition: current_paragraph_is_ltr_ and in_minor_direction_
+ * are set.
+ */
+ void MoveToLogicalStartOfWord();
+
+ /** Are we pointing at the final (reading order) symbol of the word? */
+ bool IsAtFinalSymbolOfWord() const;
+
+ /** Are we pointing at the first (reading order) symbol of the word? */
+ bool IsAtFirstSymbolOfWord() const;
+
+ /**
+ * Append any extra marks that should be appended to this word when printed.
+ * Mostly, these are Unicode BiDi control characters.
+ */
+ void AppendSuffixMarks(STRING *text) const;
+
+ /** Appends the current word in reading order to the given buffer.*/
+ void AppendUTF8WordText(STRING *text) const;
+
+ /**
+ * Appends the text of the current text line, *assuming this iterator is
+ * positioned at the beginning of the text line* This function
+ * updates the iterator to point to the first position past the text line.
+ * Each textline is terminated in a single newline character.
+ * If the textline ends a paragraph, it gets a second terminal newline.
+ */
+ void IterateAndAppendUTF8TextlineText(STRING *text);
+
+ /**
+ * Appends the text of the current paragraph in reading order
+ * to the given buffer.
+ * Each textline is terminated in a single newline character, and the
+ * paragraph gets an extra newline at the end.
+ */
+ void AppendUTF8ParagraphText(STRING *text) const;
+
+ /** Returns whether the bidi_debug flag is set to at least min_level. */
+ bool BidiDebug(int min_level) const;
+
+ bool current_paragraph_is_ltr_;
+
+ /**
+ * Is the currently pointed-at character at the beginning of
+ * a minor-direction run?
+ */
+ bool at_beginning_of_minor_run_;
+
+ /** Is the currently pointed-at character in a minor-direction sequence? */
+ bool in_minor_direction_;
+};
+
+} // namespace tesseract.
+
+#endif // TESSERACT_CCMAIN_RESULT_ITERATOR_H__
diff --git a/card.io/src/main/jni/tesseract/strngs.h b/card.io/src/main/jni/tesseract/strngs.h
new file mode 100644
index 00000000..04d7314d
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/strngs.h
@@ -0,0 +1,161 @@
+/**********************************************************************
+ * File: strngs.h (Formerly strings.h)
+ * Description: STRING class definition.
+ * Author: Ray Smith
+ * Created: Fri Feb 15 09:15:01 GMT 1991
+ *
+ * (C) Copyright 1991, Hewlett-Packard Ltd.
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ *
+ **********************************************************************/
+
+#ifndef STRNGS_H
+#define STRNGS_H
+
+#include
+#include
+#include "platform.h"
+#include "memry.h"
+
+// STRING_IS_PROTECTED means that string[index] = X is invalid
+// because you have to go through strings interface to modify it.
+// This allows the string to ensure internal integrity and maintain
+// its own string length. Unfortunately this is not possible because
+// STRINGS are used as direct-manipulation data buffers for things
+// like length arrays and many places cast away the const on string()
+// to mutate the string. Turning this off means that internally we
+// cannot assume we know the strlen.
+#define STRING_IS_PROTECTED 0
+
+template class GenericVector;
+
+class TESS_API STRING
+{
+ public:
+ STRING();
+ STRING(const STRING &string);
+ STRING(const char *string);
+ ~STRING ();
+
+ // Writes to the given file. Returns false in case of error.
+ bool Serialize(FILE* fp) const;
+ // Reads from the given file. Returns false in case of error.
+ // If swap is true, assumes a big/little-endian swap is needed.
+ bool DeSerialize(bool swap, FILE* fp);
+
+ BOOL8 contains(const char c) const;
+ inT32 length() const;
+ inT32 size() const { return length(); }
+ const char *string() const;
+
+ inline char* strdup() const {
+ inT32 len = length() + 1;
+ return strncpy(new char[len], GetCStr(), len);
+ }
+
+#if STRING_IS_PROTECTED
+ const char &operator[] (inT32 index) const;
+ // len is number of chars in s to insert starting at index in this string
+ void insert_range(inT32 index, const char*s, int len);
+ void erase_range(inT32 index, int len);
+#else
+ char &operator[] (inT32 index) const;
+#endif
+ void split(const char c, GenericVector *splited);
+ void truncate_at(inT32 index);
+
+ BOOL8 operator== (const STRING & string) const;
+ BOOL8 operator!= (const STRING & string) const;
+ BOOL8 operator!= (const char *string) const;
+
+ STRING & operator= (const char *string);
+ STRING & operator= (const STRING & string);
+
+ STRING operator+ (const STRING & string) const;
+ STRING operator+ (const char ch) const;
+
+ STRING & operator+= (const char *string);
+ STRING & operator+= (const STRING & string);
+ STRING & operator+= (const char ch);
+
+ // Assignment for strings which are not null-terminated.
+ void assign(const char *cstr, int len);
+
+ // Appends the given string and int (as a %d) to this.
+ // += cannot be used for ints as there as a char += operator that would
+ // be ambiguous, and ints usually need a string before or between them
+ // anyway.
+ void add_str_int(const char* str, int number);
+
+ // ensure capcaity but keep pointer encapsulated
+ inline void ensure(inT32 min_capacity) { ensure_cstr(min_capacity); }
+
+ private:
+ typedef struct STRING_HEADER {
+ // How much space was allocated in the string buffer for char data.
+ int capacity_;
+
+ // used_ is how much of the capacity is currently being used,
+ // including a '\0' terminator.
+ //
+ // If used_ is 0 then string is NULL (not even the '\0')
+ // else if used_ > 0 then it is strlen() + 1 (because it includes '\0')
+ // else strlen is >= 0 (not NULL) but needs to be computed.
+ // this condition is set when encapsulation is violated because
+ // an API returned a mutable string.
+ //
+ // capacity_ - used_ = excess capacity that the string can grow
+ // without reallocating
+ mutable int used_;
+ } STRING_HEADER;
+
+ // To preserve the behavior of the old serialization, we only have space
+ // for one pointer in this structure. So we are embedding a data structure
+ // at the start of the storage that will hold additional state variables,
+ // then storing the actual string contents immediately after.
+ STRING_HEADER* data_;
+
+ // returns the header part of the storage
+ inline STRING_HEADER* GetHeader() {
+ return data_;
+ }
+ inline const STRING_HEADER* GetHeader() const {
+ return data_;
+ }
+
+ // returns the string data part of storage
+ inline char* GetCStr() {
+ return ((char *)data_) + sizeof(STRING_HEADER);
+ };
+
+ inline const char* GetCStr() const {
+ return ((const char *)data_) + sizeof(STRING_HEADER);
+ };
+ inline bool InvariantOk() const {
+#if STRING_IS_PROTECTED
+ return (GetHeader()->used_ == 0) ?
+ (string() == NULL) : (GetHeader()->used_ == (strlen(string()) + 1));
+#else
+ return true;
+#endif
+ }
+
+ // Ensure string has requested capacity as optimization
+ // to avoid unnecessary reallocations.
+ // The return value is a cstr buffer with at least requested capacity
+ char* ensure_cstr(inT32 min_capacity);
+
+ void FixHeader() const; // make used_ non-negative, even if const
+
+ char* AllocData(int used, int capacity);
+ void DiscardData();
+};
+#endif
diff --git a/card.io/src/main/jni/tesseract/tesscallback.h b/card.io/src/main/jni/tesseract/tesscallback.h
new file mode 100644
index 00000000..b34cdb14
--- /dev/null
+++ b/card.io/src/main/jni/tesseract/tesscallback.h
@@ -0,0 +1,1238 @@
+///////////////////////////////////////////////////////////////////////
+// File: tesscallback.h
+// Description: classes and functions to replace pointer-to-functions
+// Author: Samuel Charron
+//
+// (C) Copyright 2006, Google Inc.
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+///////////////////////////////////////////////////////////////////////
+
+#ifndef _TESS_CALLBACK_SPECIALIZATIONS_H
+#define _TESS_CALLBACK_SPECIALIZATIONS_H
+
+#include "host.h" // For NULL.
+
+struct TessCallbackUtils_ {
+ static void FailIsRepeatable(const char* name);
+};
+
+
+class TessClosure {
+ public:
+ virtual ~TessClosure() { }
+ virtual void Run() = 0;
+};
+
+template
+class TessResultCallback {
+ public:
+ virtual ~TessResultCallback() { }
+ virtual R Run() = 0;
+};
+
+template
+class _ConstTessMemberResultCallback_0_0 : public TessResultCallback {
+ public:
+ typedef TessResultCallback base;
+ typedef R (T::*MemberSignature)() const;
+
+ private:
+ const T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _ConstTessMemberResultCallback_0_0(
+ const T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual R Run() {
+ if (!del) {
+ R result = (object_->*member_)();
+ return result;
+ } else {
+ R result = (object_->*member_)();
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ return result;
+ }
+ }
+};
+
+template
+class _ConstTessMemberResultCallback_0_0
+ : public TessClosure {
+ public:
+ typedef TessClosure base;
+ typedef void (T::*MemberSignature)() const;
+
+ private:
+ const T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _ConstTessMemberResultCallback_0_0(
+ const T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual void Run() {
+ if (!del) {
+ (object_->*member_)();
+ } else {
+ (object_->*member_)();
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ }
+ }
+};
+
+#ifndef SWIG
+template
+inline typename _ConstTessMemberResultCallback_0_0::base*
+NewTessCallback(
+ const T1* obj, R (T2::*member)() const) {
+ return new _ConstTessMemberResultCallback_0_0(
+ obj, member);
+}
+#endif
+
+#ifndef SWIG
+template
+inline typename _ConstTessMemberResultCallback_0_0::base*
+NewPermanentTessCallback(
+ const T1* obj, R (T2::*member)() const) {
+ return new _ConstTessMemberResultCallback_0_0(
+ obj, member);
+}
+#endif
+
+template
+class _TessMemberResultCallback_0_0 : public TessResultCallback {
+ public:
+ typedef TessResultCallback base;
+ typedef R (T::*MemberSignature)() ;
+
+ private:
+ T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _TessMemberResultCallback_0_0(
+ T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual R Run() {
+ if (!del) {
+ R result = (object_->*member_)();
+ return result;
+ } else {
+ R result = (object_->*member_)();
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ return result;
+ }
+ }
+};
+
+template
+class _TessMemberResultCallback_0_0
+ : public TessClosure {
+ public:
+ typedef TessClosure base;
+ typedef void (T::*MemberSignature)() ;
+
+ private:
+ T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _TessMemberResultCallback_0_0(
+ T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual void Run() {
+ if (!del) {
+ (object_->*member_)();
+ } else {
+ (object_->*member_)();
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ }
+ }
+};
+
+#ifndef SWIG
+template
+inline typename _TessMemberResultCallback_0_0::base*
+NewTessCallback(
+ T1* obj, R (T2::*member)() ) {
+ return new _TessMemberResultCallback_0_0(
+ obj, member);
+}
+#endif
+
+#ifndef SWIG
+template
+inline typename _TessMemberResultCallback_0_0::base*
+NewPermanentTessCallback(
+ T1* obj, R (T2::*member)() ) {
+ return new _TessMemberResultCallback_0_0(
+ obj, member);
+}
+#endif
+
+template
+class _TessFunctionResultCallback_0_0 : public TessResultCallback {
+ public:
+ typedef TessResultCallback base;
+ typedef R (*FunctionSignature)();
+
+ private:
+ FunctionSignature function_;
+
+ public:
+ inline _TessFunctionResultCallback_0_0(
+ FunctionSignature function)
+ : function_(function) {
+ }
+
+ virtual R Run() {
+ if (!del) {
+ R result = (*function_)();
+ return result;
+ } else {
+ R result = (*function_)();
+ // zero out the pointer to ensure segfault if used again
+ function_ = NULL;
+ delete this;
+ return result;
+ }
+ }
+};
+
+template
+class _TessFunctionResultCallback_0_0
+ : public TessClosure {
+ public:
+ typedef TessClosure base;
+ typedef void (*FunctionSignature)();
+
+ private:
+ FunctionSignature function_;
+
+ public:
+ inline _TessFunctionResultCallback_0_0(
+ FunctionSignature function)
+ : function_(function) {
+ }
+
+ virtual void Run() {
+ if (!del) {
+ (*function_)();
+ } else {
+ (*function_)();
+ // zero out the pointer to ensure segfault if used again
+ function_ = NULL;
+ delete this;
+ }
+ }
+};
+
+template
+inline typename _TessFunctionResultCallback_0_0::base*
+NewTessCallback(R (*function)()) {
+ return new _TessFunctionResultCallback_0_0(function);
+}
+
+template
+inline typename _TessFunctionResultCallback_0_0::base*
+NewPermanentTessCallback(R (*function)()) {
+ return new _TessFunctionResultCallback_0_0(function);
+}
+
+template
+class TessCallback1 {
+ public:
+ virtual ~TessCallback1() { }
+ virtual void Run(A1) = 0;
+};
+
+template
+class TessResultCallback1 {
+ public:
+ virtual ~TessResultCallback1() { }
+ virtual R Run(A1) = 0;
+};
+
+template
+class _ConstTessMemberResultCallback_0_1 : public TessResultCallback1 {
+ public:
+ typedef TessResultCallback1 base;
+ typedef R (T::*MemberSignature)(A1) const;
+
+ private:
+ const T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _ConstTessMemberResultCallback_0_1(
+ const T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual R Run(A1 a1) {
+ if (!del) {
+ R result = (object_->*member_)(a1);
+ return result;
+ } else {
+ R result = (object_->*member_)(a1);
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ return result;
+ }
+ }
+};
+
+template
+class _ConstTessMemberResultCallback_0_1
+ : public TessCallback1 {
+ public:
+ typedef TessCallback1 base;
+ typedef void (T::*MemberSignature)(A1) const;
+
+ private:
+ const T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _ConstTessMemberResultCallback_0_1(
+ const T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual void Run(A1 a1) {
+ if (!del) {
+ (object_->*member_)(a1);
+ } else {
+ (object_->*member_)(a1);
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ }
+ }
+};
+
+#ifndef SWIG
+template
+inline typename _ConstTessMemberResultCallback_0_1::base*
+NewTessCallback(
+ const T1* obj, R (T2::*member)(A1) const) {
+ return new _ConstTessMemberResultCallback_0_1(
+ obj, member);
+}
+#endif
+
+#ifndef SWIG
+template
+inline typename _ConstTessMemberResultCallback_0_1::base*
+NewPermanentTessCallback(
+ const T1* obj, R (T2::*member)(A1) const) {
+ return new _ConstTessMemberResultCallback_0_1(
+ obj, member);
+}
+#endif
+
+template
+class _TessMemberResultCallback_0_1 : public TessResultCallback1 {
+ public:
+ typedef TessResultCallback1 base;
+ typedef R (T::*MemberSignature)(A1) ;
+
+ private:
+ T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _TessMemberResultCallback_0_1(
+ T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual R Run(A1 a1) {
+ if (!del) {
+ R result = (object_->*member_)(a1);
+ return result;
+ } else {
+ R result = (object_->*member_)(a1);
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ return result;
+ }
+ }
+};
+
+template
+class _TessMemberResultCallback_0_1
+ : public TessCallback1 {
+ public:
+ typedef TessCallback1 base;
+ typedef void (T::*MemberSignature)(A1) ;
+
+ private:
+ T* object_;
+ MemberSignature member_;
+
+ public:
+ inline _TessMemberResultCallback_0_1(
+ T* object, MemberSignature member)
+ : object_(object),
+ member_(member) {
+ }
+
+ virtual void Run(A1 a1) {
+ if (!del) {
+ (object_->*member_)(a1);
+ } else {
+ (object_->*member_)(a1);
+ // zero out the pointer to ensure segfault if used again
+ member_ = NULL;
+ delete this;
+ }
+ }
+};
+
+#ifndef SWIG
+template
+inline typename _TessMemberResultCallback_0_1::base*
+NewTessCallback(
+ T1* obj, R (T2::*member)(A1) ) {
+ return new _TessMemberResultCallback_0_1(
+ obj, member);
+}
+#endif
+
+#ifndef SWIG
+template
+inline typename _TessMemberResultCallback_0_1::base*
+NewPermanentTessCallback(
+ T1* obj, R (T2::*member)(A1) ) {
+ return new _TessMemberResultCallback_0_1(
+ obj, member);
+}
+#endif
+
+template
+class _TessFunctionResultCallback_0_1 : public TessResultCallback1 {
+ public:
+ typedef TessResultCallback1 base;
+ typedef R (*FunctionSignature)(A1);
+
+ private:
+ FunctionSignature function_;
+
+ public:
+ inline _TessFunctionResultCallback_0_1(
+ FunctionSignature function)
+ : function_(function) {
+ }
+
+ virtual R Run(A1 a1) {
+ if (!del) {
+ R result = (*function_)(a1);
+ return result;
+ } else {
+ R result = (*function_)(a1);
+ // zero out the pointer to ensure segfault if used again
+ function_ = NULL;
+ delete this;
+ return result;
+ }
+ }
+};
+
+template
+class _TessFunctionResultCallback_0_1
+ : public TessCallback1 {
+ public:
+ typedef TessCallback1 base;
+ typedef void (*FunctionSignature)(A1);
+
+ private:
+ FunctionSignature function_;
+
+ public:
+ inline _TessFunctionResultCallback_0_1(
+ FunctionSignature function)
+ : function_(function) {
+ }
+
+ virtual void Run(A1 a1) {
+ if (!del) {
+ (*function_)(a1);
+ } else {
+ (*function_)(a1);
+ // zero out the pointer to ensure segfault if used again
+ function_ = NULL;
+ delete this;
+ }
+ }
+};
+
+template
+inline typename _TessFunctionResultCallback_0_1::base*
+NewTessCallback(R (*function)(A1)) {
+ return new _TessFunctionResultCallback_0_1(function);
+}
+
+template
+inline typename _TessFunctionResultCallback_0_1::base*
+NewPermanentTessCallback(R (*function)(A1)) {
+ return new _TessFunctionResultCallback_0_1