Implement Recognize

This commit is contained in:
David Ventura 2025-07-16 18:25:42 +02:00
parent d7de990ef7
commit 41affbf144
2 changed files with 19 additions and 0 deletions

View File

@ -752,6 +752,15 @@ jboolean Java_com_googlecode_tesseract_android_TessBaseAPI_nativeAddPageToDocume
return JNI_TRUE;
}
extern "C"
JNIEXPORT void JNICALL
Java_com_googlecode_tesseract_android_TessBaseAPI_nativeRecognize(JNIEnv *env, jobject thiz,
jlong mNativeData) {
native_data_t *nat = (native_data_t*) mNativeData;
nat->api.Recognize(nullptr);
}
#ifdef __cplusplus
}
#endif

View File

@ -716,6 +716,14 @@ public class TessBaseAPI {
return text != null ? text.trim() : null;
}
@WorkerThread
public void recognize() {
if (mRecycled)
throw new IllegalStateException();
nativeRecognize(mNativeData);
}
/**
* Returns text where items on the given iterator level (symbol, word, line, paragraph, block)
* which has confidence lower than given threshold are filtered out.
@ -1218,4 +1226,6 @@ public class TessBaseAPI {
private native boolean nativeEndDocument(long rendererPointer);
private native boolean nativeAddPageToDocument(long mNativeData, long nativePix, String imagePath, long rendererPointer);
private native void nativeRecognize(long mNativeData);
}