From d85ef2db16c748db50b1ac04ba50c733a9d2a498 Mon Sep 17 00:00:00 2001 From: Robert Theis Date: Thu, 7 Sep 2017 21:46:50 -0700 Subject: [PATCH] Add support annotations --- .../android/test/TessBaseAPITest.java | 1 - tess-two/build.gradle | 3 +- .../leptonica/android/Binarize.java | 9 +++-- .../com/googlecode/leptonica/android/Box.java | 3 +- .../googlecode/leptonica/android/Boxa.java | 3 +- .../leptonica/android/Constants.java | 19 ++++++++++ .../googlecode/leptonica/android/Edge.java | 11 +++++- .../googlecode/leptonica/android/JpegIO.java | 4 ++- .../leptonica/android/MorphApp.java | 14 ++++++-- .../com/googlecode/leptonica/android/Pix.java | 6 ++-- .../googlecode/leptonica/android/Pixa.java | 11 +++--- .../googlecode/leptonica/android/Rotate.java | 4 ++- .../tesseract/android/PageIterator.java | 6 ++-- .../tesseract/android/ResultIterator.java | 9 ++--- .../tesseract/android/TessBaseAPI.java | 36 ++++++++++++++++--- 15 files changed, 107 insertions(+), 32 deletions(-) diff --git a/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java b/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java index 2cc90742a..1e5277a70 100644 --- a/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java +++ b/tess-two-test/src/com/googlecode/tesseract/android/test/TessBaseAPITest.java @@ -16,7 +16,6 @@ package com.googlecode.tesseract.android.test; -import android.annotation.SuppressLint; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Canvas; diff --git a/tess-two/build.gradle b/tess-two/build.gradle index b471e07ba..bcbb63f23 100644 --- a/tess-two/build.gradle +++ b/tess-two/build.gradle @@ -9,7 +9,7 @@ properties.load(project.rootProject.file('local.properties').newDataInputStream( android { compileSdkVersion 23 - buildToolsVersion '25.0.0' + buildToolsVersion '25.0.3' defaultConfig { minSdkVersion 9 @@ -61,6 +61,7 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:support-annotations:25.3.1' } diff --git a/tess-two/src/com/googlecode/leptonica/android/Binarize.java b/tess-two/src/com/googlecode/leptonica/android/Binarize.java index b765d66c5..07e807d4b 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Binarize.java +++ b/tess-two/src/com/googlecode/leptonica/android/Binarize.java @@ -16,6 +16,8 @@ package com.googlecode.leptonica.android; +import android.support.annotation.FloatRange; + /** * Image binarization methods. * @@ -118,8 +120,8 @@ public static Pix otsuAdaptiveThreshold(Pix pixs) { * for standard Otsu). * @return A 1 bpp thresholded PIX image. */ - public static Pix otsuAdaptiveThreshold( - Pix pixs, int sizeX, int sizeY, int smoothX, int smoothY, float scoreFraction) { + public static Pix otsuAdaptiveThreshold(Pix pixs, int sizeX, int sizeY, int smoothX, int smoothY, + @FloatRange(from=0.0, to=1.0) float scoreFraction) { if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null"); if (pixs.getDepth() != 8) @@ -185,7 +187,8 @@ public static Pix sauvolaBinarizeTiled(Pix pixs) { * @param ny Subdivision into tiles; >= 1 * @return A 1 bpp thresholded PIX image. */ - public static Pix sauvolaBinarizeTiled(Pix pixs, int whsize, float factor, int nx, int ny) { + public static Pix sauvolaBinarizeTiled(Pix pixs, int whsize, @FloatRange(from=0.0) float factor, + int nx, int ny) { if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null"); if (pixs.getDepth() != 8) diff --git a/tess-two/src/com/googlecode/leptonica/android/Box.java b/tess-two/src/com/googlecode/leptonica/android/Box.java index 823244106..4f2b44165 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Box.java +++ b/tess-two/src/com/googlecode/leptonica/android/Box.java @@ -17,6 +17,7 @@ package com.googlecode.leptonica.android; import android.graphics.Rect; +import android.support.annotation.Size; import android.util.Log; /** @@ -186,7 +187,7 @@ public int[] getGeometry() { * @param geometry A 4+ element integer array to fill with coordinates. * @return true on success */ - public boolean getGeometry(int[] geometry) { + public boolean getGeometry(@Size(min=4) int[] geometry) { if (mRecycled) throw new IllegalStateException(); diff --git a/tess-two/src/com/googlecode/leptonica/android/Boxa.java b/tess-two/src/com/googlecode/leptonica/android/Boxa.java index 052548e06..ec1a5903d 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Boxa.java +++ b/tess-two/src/com/googlecode/leptonica/android/Boxa.java @@ -17,6 +17,7 @@ package com.googlecode.leptonica.android; import android.graphics.Rect; +import android.support.annotation.Size; import android.util.Log; /** @@ -117,7 +118,7 @@ public int[] getGeometry(int index) { * @param geometry A 4+ element integer array to fill with coordinates. * @return true on success */ - public boolean getGeometry(int index, int[] geometry) { + public boolean getGeometry(int index, @Size(min=4) int[] geometry) { if (mRecycled) throw new IllegalStateException(); diff --git a/tess-two/src/com/googlecode/leptonica/android/Constants.java b/tess-two/src/com/googlecode/leptonica/android/Constants.java index 9dc5b8eec..fb94763e1 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Constants.java +++ b/tess-two/src/com/googlecode/leptonica/android/Constants.java @@ -16,6 +16,12 @@ package com.googlecode.leptonica.android; +import android.support.annotation.IntDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + /** * Leptonica constants. * @@ -46,6 +52,10 @@ public class Constants { * and L_INSERT and L_NOCOPY are always 0. */ + @Retention(SOURCE) + @IntDef({L_INSERT, L_COPY, L_CLONE}) + public @interface StorageFlag {} + /* Stuff it in; no copy, clone or copy-clone */ public static final int L_INSERT = 0; @@ -65,12 +75,21 @@ public class Constants { * Sort flags * *--------------------------------------------------------------------------*/ + @Retention(SOURCE) + @IntDef({L_SORT_INCREASING, L_SORT_DECREASING}) + public @interface SortOrder {} + /* Sort in increasing order */ public static final int L_SORT_INCREASING = 1; /* Sort in decreasing order */ public static final int L_SORT_DECREASING = 2; + @Retention(SOURCE) + @IntDef({L_SORT_BY_X, L_SORT_BY_Y, L_SORT_BY_WIDTH, L_SORT_BY_HEIGHT, L_SORT_BY_MIN_DIMENSION, + L_SORT_BY_MAX_DIMENSION, L_SORT_BY_PERIMETER, L_SORT_BY_ASPECT_RATIO}) + public @interface SortBy {} + /* Sort box or c.c. by horiz location */ public static final int L_SORT_BY_X = 3; diff --git a/tess-two/src/com/googlecode/leptonica/android/Edge.java b/tess-two/src/com/googlecode/leptonica/android/Edge.java index 984cf5b15..08e7a79e3 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Edge.java +++ b/tess-two/src/com/googlecode/leptonica/android/Edge.java @@ -16,6 +16,12 @@ package com.googlecode.leptonica.android; +import android.support.annotation.IntDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + /** * Edge detection. */ @@ -28,6 +34,9 @@ public class Edge { } // Edge orientation flags + @Retention(SOURCE) + @IntDef({L_HORIZONTAL_EDGES, L_VERTICAL_EDGES, L_ALL_EDGES}) + public @interface EdgeOrientationFlag {} /** Filters for horizontal edges */ public static final int L_HORIZONTAL_EDGES = 0; @@ -65,7 +74,7 @@ public class Edge { * L_VERTICAL_EDGES, L_ALL_EDGES) * @return a new Pix image (8bpp, edges are brighter), or null on error */ - public static Pix pixSobelEdgeFilter(Pix pixs, int orientFlag) { + public static Pix pixSobelEdgeFilter(Pix pixs, @EdgeOrientationFlag int orientFlag) { if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null"); if (pixs.getDepth() != 8) diff --git a/tess-two/src/com/googlecode/leptonica/android/JpegIO.java b/tess-two/src/com/googlecode/leptonica/android/JpegIO.java index d6195bc9b..870aa6ad2 100644 --- a/tess-two/src/com/googlecode/leptonica/android/JpegIO.java +++ b/tess-two/src/com/googlecode/leptonica/android/JpegIO.java @@ -18,6 +18,7 @@ import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; +import android.support.annotation.IntRange; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -60,7 +61,8 @@ public static byte[] compressToJpeg(Pix pixs) { * @param progressive Whether to use progressive compression. * @return a compressed JPEG byte array representation of the Pix */ - public static byte[] compressToJpeg(Pix pixs, int quality, boolean progressive) { + public static byte[] compressToJpeg(Pix pixs, @IntRange(from=0, to=100) int quality, + boolean progressive) { if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null"); if (quality < 0 || quality > 100) diff --git a/tess-two/src/com/googlecode/leptonica/android/MorphApp.java b/tess-two/src/com/googlecode/leptonica/android/MorphApp.java index 7297abf58..0c64292a4 100644 --- a/tess-two/src/com/googlecode/leptonica/android/MorphApp.java +++ b/tess-two/src/com/googlecode/leptonica/android/MorphApp.java @@ -16,6 +16,12 @@ package com.googlecode.leptonica.android; +import android.support.annotation.IntDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + /** * Composite image processing operations. */ @@ -28,7 +34,9 @@ public class MorphApp { } // Morphological tophat flags - + @Retention(SOURCE) + @IntDef({L_TOPHAT_BLACK, L_TOPHAT_WHITE}) + public @interface TophatType {} public static final int L_TOPHAT_WHITE = 0; public static final int L_TOPHAT_BLACK = 1; @@ -55,7 +63,7 @@ public class MorphApp { * @param type L_TOPHAT_WHITE: image - opening or L_TOPHAT_BLACK: closing - image * @return a new Pix image */ - public static Pix pixTophat(Pix pixs, int hsize, int vsize, int type) { + public static Pix pixTophat(Pix pixs, int hsize, int vsize, @TophatType int type) { if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null"); if (pixs.getDepth() != 8) @@ -127,7 +135,7 @@ public static Pix pixFastTophatWhite(Pix pixs) { * @param type L_TOPHAT_WHITE: image - min, or L_TOPHAT_BLACK: max - image * @return a new Pix image */ - public static Pix pixFastTophat(Pix pixs, int xsize, int ysize, int type) { + public static Pix pixFastTophat(Pix pixs, int xsize, int ysize, @TophatType int type) { if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null"); if (pixs.getDepth() != 8) diff --git a/tess-two/src/com/googlecode/leptonica/android/Pix.java b/tess-two/src/com/googlecode/leptonica/android/Pix.java index cef205e05..c1a215cb3 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Pix.java +++ b/tess-two/src/com/googlecode/leptonica/android/Pix.java @@ -17,6 +17,8 @@ package com.googlecode.leptonica.android; import android.graphics.Rect; +import android.support.annotation.ColorInt; +import android.support.annotation.Size; /** * Java representation of a native Leptonica PIX object. @@ -125,7 +127,7 @@ public int[] getDimensions() { * @param dimensions An integer array with at least three elements. * @return true on success */ - public boolean getDimensions(int[] dimensions) { + public boolean getDimensions(@Size(min=3) int[] dimensions) { if (mRecycled) throw new IllegalStateException(); @@ -297,7 +299,7 @@ public int getPixel(int x, int y) { * specified coordinate. * @throws IllegalArgumentException If x, y exceeds the image bounds. */ - public void setPixel(int x, int y, int color) { + public void setPixel(int x, int y, @ColorInt int color) { if (mRecycled) throw new IllegalStateException(); diff --git a/tess-two/src/com/googlecode/leptonica/android/Pixa.java b/tess-two/src/com/googlecode/leptonica/android/Pixa.java index e91fe6317..20d343f3b 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Pixa.java +++ b/tess-two/src/com/googlecode/leptonica/android/Pixa.java @@ -17,6 +17,7 @@ package com.googlecode.leptonica.android; import android.graphics.Rect; +import android.support.annotation.Size; import android.util.Log; import java.io.File; @@ -138,7 +139,7 @@ public Pixa copy() { * Constants.L_SORT_INCREASING or Constants.L_SORT_DECREASING. * @return a sorted copy of this Pixa */ - public Pixa sort(int field, int order) { + public Pixa sort(@Constants.SortBy int field, @Constants.SortOrder int order) { if (mRecycled) throw new IllegalStateException(); @@ -211,7 +212,7 @@ public boolean join(Pixa otherPixa) { * @param mode The mode in which to add this Pix, typically * Constants.L_CLONE. */ - public void addPix(Pix pix, int mode) { + public void addPix(Pix pix, @Constants.StorageFlag int mode) { if (mRecycled) throw new IllegalStateException(); @@ -225,7 +226,7 @@ public void addPix(Pix pix, int mode) { * @param mode The mode in which to add this Box, typically * Constants.L_CLONE. */ - public void addBox(Box box, int mode) { + public void addBox(Box box, @Constants.StorageFlag int mode) { if (mRecycled) throw new IllegalStateException(); @@ -240,7 +241,7 @@ public void addBox(Box box, int mode) { * @param mode The mode in which to add this Pix and Box, typically * Constants.L_CLONE. */ - public void add(Pix pix, Box box, int mode) { + public void add(Pix pix, Box box, @Constants.StorageFlag int mode) { if (mRecycled) throw new IllegalStateException(); @@ -355,7 +356,7 @@ public int[] getBoxGeometry(int index) { * elements. * @return true on success */ - public boolean getBoxGeometry(int index, int[] dimensions) { + public boolean getBoxGeometry(int index, @Size(min=4) int[] dimensions) { if (mRecycled) throw new IllegalStateException(); diff --git a/tess-two/src/com/googlecode/leptonica/android/Rotate.java b/tess-two/src/com/googlecode/leptonica/android/Rotate.java index 769bbf055..a9a379e6e 100644 --- a/tess-two/src/com/googlecode/leptonica/android/Rotate.java +++ b/tess-two/src/com/googlecode/leptonica/android/Rotate.java @@ -16,6 +16,8 @@ package com.googlecode.leptonica.android; +import android.support.annotation.IntRange; + /** * @author alanv@google.com (Alan Viverette) */ @@ -101,7 +103,7 @@ public static Pix rotate(Pix pixs, float degrees, boolean quality, boolean resiz * @param quads 0-3; number of 90 degree cw rotations * @return the rotated source image */ - public static Pix rotateOrth(Pix pixs, int quads) { + public static Pix rotateOrth(Pix pixs, @IntRange(from=0, to=3) int quads) { if (pixs == null) throw new IllegalArgumentException("Source pix must be non-null"); if (quads < 0 || quads > 3) diff --git a/tess-two/src/com/googlecode/tesseract/android/PageIterator.java b/tess-two/src/com/googlecode/tesseract/android/PageIterator.java index 18952a517..5330d7332 100644 --- a/tess-two/src/com/googlecode/tesseract/android/PageIterator.java +++ b/tess-two/src/com/googlecode/tesseract/android/PageIterator.java @@ -60,7 +60,7 @@ public void begin() { * @return {@code false} if the end of the page was reached, {@code true} * otherwise. */ - public boolean next(int level) { + public boolean next(@PageIteratorLevel.Level int level) { return nativeNext(mNativePageIterator, level); } @@ -90,7 +90,7 @@ public boolean next(int level) { * @param level the page iterator level. See {@link PageIteratorLevel}. * @return the bounding rectangle of the current object at the given level */ - public int[] getBoundingBox(int level) { + public int[] getBoundingBox(@PageIteratorLevel.Level int level) { return nativeBoundingBox(mNativePageIterator, level); } @@ -102,7 +102,7 @@ public int[] getBoundingBox(int level) { * @param level the page iterator level. See {@link PageIteratorLevel}. * @return the bounding rectangle of the current object at the given level */ - public Rect getBoundingRect(int level) { + public Rect getBoundingRect(@PageIteratorLevel.Level int level) { int[] box = getBoundingBox(level); return new Rect(box[0], box[1], box[2], box[3]); } diff --git a/tess-two/src/com/googlecode/tesseract/android/ResultIterator.java b/tess-two/src/com/googlecode/tesseract/android/ResultIterator.java index abde1023b..dcdc5c53d 100644 --- a/tess-two/src/com/googlecode/tesseract/android/ResultIterator.java +++ b/tess-two/src/com/googlecode/tesseract/android/ResultIterator.java @@ -54,7 +54,7 @@ public class ResultIterator extends PageIterator { * @param level the page iterator level. See {@link PageIteratorLevel}. * @return the text string for the current object at the given level. */ - public String getUTF8Text(int level) { + public String getUTF8Text(@PageIteratorLevel.Level int level) { return nativeGetUTF8Text(mNativeResultIterator, level); } @@ -65,7 +65,7 @@ public String getUTF8Text(int level) { * @param level the page iterator level. See {@link PageIteratorLevel}. * @return the mean confidence of the current object at the given level. */ - public float confidence(int level) { + public float confidence(@PageIteratorLevel.Level int level) { return nativeConfidence(mNativeResultIterator, level); } @@ -77,7 +77,7 @@ public float confidence(int level) { * @param level the page iterator level. See {@link PageIteratorLevel}. * @return {@code true} if iterator points to the start of an object at the given level. */ - public boolean isAtBeginningOf(int level) { + public boolean isAtBeginningOf(@PageIteratorLevel.Level int level) { return nativeIsAtBeginningOf(mNativeResultIterator, level); } @@ -89,7 +89,8 @@ public boolean isAtBeginningOf(int level) { * @param element the page iterator level. See {@link PageIteratorLevel}. * @return {@code true} if iterator points to the last element in a given level. */ - public boolean isAtFinalElement(int level, int element) { + public boolean isAtFinalElement(@PageIteratorLevel.Level int level, + @PageIteratorLevel.Level int element) { return nativeIsAtFinalElement(mNativeResultIterator, level, element); } diff --git a/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java b/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java index f7ff12bcc..a11095d69 100644 --- a/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java +++ b/tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java @@ -17,15 +17,20 @@ package com.googlecode.tesseract.android; -import java.io.File; - import android.graphics.Bitmap; import android.graphics.Rect; +import android.support.annotation.IntDef; +import android.support.annotation.WorkerThread; import com.googlecode.leptonica.android.Pix; import com.googlecode.leptonica.android.Pixa; import com.googlecode.leptonica.android.ReadFile; +import java.io.File; +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + /** * Java interface for the Tesseract OCR engine. Does not implement all available * JNI methods, but does implement enough to be useful. Comments are adapted @@ -51,6 +56,12 @@ public class TessBaseAPI { /** Page segmentation mode. */ public static final class PageSegMode { + @Retention(SOURCE) + @IntDef({PSM_OSD_ONLY, PSM_AUTO_OSD, PSM_AUTO_ONLY, PSM_AUTO, PSM_SINGLE_COLUMN, + PSM_SINGLE_BLOCK_VERT_TEXT, PSM_SINGLE_BLOCK, PSM_SINGLE_LINE, PSM_SINGLE_WORD, + PSM_CIRCLE_WORD, PSM_SINGLE_CHAR, PSM_SPARSE_TEXT, PSM_SPARSE_TEXT_OSD, PSM_RAW_LINE}) + public @interface Mode {} + /** Orientation and script detection only. */ public static final int PSM_OSD_ONLY = 0; @@ -109,6 +120,10 @@ public static final class PageSegMode { /** String value used to assign a boolean variable to false. */ public static final String VAR_FALSE = "F"; + @Retention(SOURCE) + @IntDef({OEM_TESSERACT_ONLY, OEM_CUBE_ONLY, OEM_TESSERACT_CUBE_COMBINED, OEM_DEFAULT}) + public @interface OcrEngineMode {} + /** Run Tesseract only - fastest */ public static final int OEM_TESSERACT_ONLY = 0; @@ -132,6 +147,10 @@ public static final class PageSegMode { * as there is no paragraph internally yet. */ public static final class PageIteratorLevel { + @Retention(SOURCE) + @IntDef({RIL_BLOCK, RIL_PARA, RIL_TEXTLINE, RIL_WORD, RIL_SYMBOL}) + public @interface Level {} + /** Block of text/image/separator line. */ public static final int RIL_BLOCK = 0; @@ -296,7 +315,7 @@ public boolean init(String datapath, String language) { * @param ocrEngineMode the OCR engine mode to be set * @return true on success */ - public boolean init(String datapath, String language, int ocrEngineMode) { + public boolean init(String datapath, String language, @OcrEngineMode int ocrEngineMode) { if (datapath == null) throw new IllegalArgumentException("Data path must not be null!"); if (!datapath.endsWith(File.separator)) @@ -409,7 +428,7 @@ public boolean setVariable(String var, String value) { * * @return value of the current page segmentation mode */ - public int getPageSegMode() { + public @PageSegMode.Mode int getPageSegMode() { if (mRecycled) throw new IllegalStateException(); @@ -426,7 +445,7 @@ public int getPageSegMode() { * * @param mode the {@link PageSegMode} to set */ - public void setPageSegMode(int mode) { + public void setPageSegMode(@PageSegMode.Mode int mode) { if (mRecycled) throw new IllegalStateException(); @@ -486,6 +505,7 @@ public void setRectangle(int left, int top, int width, int height) { * * @param file absolute path to the image file */ + @WorkerThread public void setImage(File file) { if (mRecycled) throw new IllegalStateException(); @@ -510,6 +530,7 @@ public void setImage(File file) { * * @param bmp bitmap representation of the image */ + @WorkerThread public void setImage(Bitmap bmp) { if (mRecycled) throw new IllegalStateException(); @@ -532,6 +553,7 @@ public void setImage(Bitmap bmp) { * * @param image Leptonica pix representation of the image */ + @WorkerThread public void setImage(Pix image) { if (mRecycled) throw new IllegalStateException(); @@ -552,6 +574,7 @@ public void setImage(Pix image) { * @param bpp bytes per pixel * @param bpl bytes per line */ + @WorkerThread public void setImage(byte[] imagedata, int width, int height, int bpp, int bpl) { if (mRecycled) throw new IllegalStateException(); @@ -567,6 +590,7 @@ public void setImage(byte[] imagedata, int width, int height, int bpp, int bpl) * * @return the recognized text */ + @WorkerThread public String getUTF8Text() { if (mRecycled) throw new IllegalStateException(); @@ -726,6 +750,7 @@ public ResultIterator getResultIterator() { * @param page is 0-based but will appear in the output as 1-based. * @return HTML-formatted string with hOCR markup */ + @WorkerThread public String getHOCRText(int page){ if (mRecycled) throw new IllegalStateException(); @@ -934,6 +959,7 @@ private native void nativeSetImageBytes( private native void nativeSetDebug(long mNativeData, boolean debug); + @PageSegMode.Mode private native int nativeGetPageSegMode(long mNativeData); private native void nativeSetPageSegMode(long mNativeData, int mode);