public class Recognizer
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Recognizer.State |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
If there is ongoing recognition process, this method will request cancellation of it and wait for
recognition process to complete.
|
Recognizer.State |
getCurrentState()
Returns the current state of the recognizer.
|
static Recognizer |
getSingletonInstance()
Returns the recognizer singleton.
|
void |
initialize(android.content.Context context,
RecognitionSettings recognitionSettings,
DirectApiErrorListener errorListener)
Initialize native library for recognition and returns true if initialization has been performed.
|
void |
recognizeBitmap(android.graphics.Bitmap image,
Orientation imageOrientation,
Rectangle scanRegion,
ScanResultListener resultListener)
Perform recognition of image represented as Android Bitmap.
|
void |
recognizeBitmap(android.graphics.Bitmap image,
Orientation imageOrientation,
ScanResultListener resultListener)
Perform recognition of image represented as Android Bitmap.
|
void |
recognizeBitmapWithSettings(android.graphics.Bitmap image,
Orientation imageOrientation,
Rectangle scanRegion,
ScanResultListener resultListener,
RecognitionSettings recognitionSettings)
Perform recognition of image represented as Android Bitmap.
|
void |
recognizeBitmapWithSettings(android.graphics.Bitmap image,
Orientation imageOrientation,
ScanResultListener resultListener,
RecognitionSettings recognitionSettings)
Perform recognition of image represented as Android Bitmap.
|
void |
recognizeImage(Image image,
ScanResultListener resultListener)
Use this method to directly recognize Image object obtained via MetadataListener while recognizer is active.
|
void |
recognizeImageWithSettings(Image image,
ScanResultListener resultListener,
RecognitionSettings recognitionSettings)
Use this method to directly recognize Image object obtained via MetadataListener while recognizer is active.
|
void |
setLicenseKey(android.content.Context context,
java.lang.String licenseKey)
Sets the license key required for unlocking the library.
|
void |
setLicenseKey(java.lang.String licenseKey,
java.lang.String licensee)
Sets the license key required for unlocking the library.
|
void |
setMetadataListener(MetadataListener metadataListener,
MetadataSettings metadataSettings)
Sets the listener that will obtain metadata that is being processed.
|
void |
terminate()
Terminates the native library.
|
public static Recognizer getSingletonInstance() throws FeatureNotSupportedException
FeatureNotSupportedExceptionpublic final Recognizer.State getCurrentState()
public final void setLicenseKey(@NonNull
android.content.Context context,
@NonNull
java.lang.String licenseKey)
throws InvalidLicenceKeyException
context - Application context used for license checking.licenseKey - License key.java.lang.IllegalStateException - if recognizer is not in offline state (use getCurrentState method to obtain the state)InvalidLicenceKeyException - if licence key is invalidpublic final void setLicenseKey(@NonNull
java.lang.String licenseKey,
@NonNull
java.lang.String licensee)
throws InvalidLicenceKeyException
licenseKey - License key.licensee - Licensee to which license key is bound.java.lang.IllegalStateException - if recognizer is not in offline state (use getCurrentState method to obtain the state)InvalidLicenceKeyException - if licence key is invalidpublic final void initialize(@NonNull
android.content.Context context,
@NonNull
RecognitionSettings recognitionSettings,
@NonNull
DirectApiErrorListener errorListener)
context - Application context used for loading required resources.recognitionSettings - Recognition settings defining a recognition process.errorListener - Listener that will be notified of any error in native library in background thread.java.lang.IllegalStateException - if recognizer is already initializedjava.lang.NullPointerException - if context, settings array or errorListener is nullpublic final void recognizeBitmap(@NonNull
android.graphics.Bitmap image,
@NonNull
Orientation imageOrientation,
@NonNull
ScanResultListener resultListener)
image - Image that needs to be recognized.imageOrientation - Orientation of the bitmap image.resultListener - Result listener that will handle recognition done event.java.lang.IllegalStateException - if recognizer is not initialized or is currently workingjava.lang.NullPointerException - if given null scan result listenerpublic final void recognizeBitmap(@NonNull
android.graphics.Bitmap image,
@NonNull
Orientation imageOrientation,
@NonNull
Rectangle scanRegion,
@NonNull
ScanResultListener resultListener)
image - Image that needs to be recognized.imageOrientation - Orientation of the bitmap image.scanRegion - Region of image that needs to be recognized. Rectangle is given as percentages
of image size - x coordinate and width are percentages of image width and y coordinate
and height are percentages of image height. Therefore, rectangle(0.f, 0.f, 1.f, 1.f)
represents the whole image, whilst rectangle(0.5f, 0.f, 0.5f, 1.f) represents the
right half of the image.resultListener - Result listener that will handle recognition done event.java.lang.IllegalStateException - if recognizer is not initialized or is currently workingjava.lang.NullPointerException - if given null scan result listenerpublic final void recognizeBitmapWithSettings(@NonNull
android.graphics.Bitmap image,
@NonNull
Orientation imageOrientation,
@NonNull
ScanResultListener resultListener,
RecognitionSettings recognitionSettings)
image - Image that needs to be recognized.imageOrientation - Orientation of the bitmap image.resultListener - Result listener that will handle recognition done event.recognitionSettings - Recognition settings that will be used to perform this recognition.java.lang.IllegalStateException - if recognizer is not initialized or is currently workingjava.lang.NullPointerException - if given null scan result listenerpublic final void recognizeBitmapWithSettings(@NonNull
android.graphics.Bitmap image,
@NonNull
Orientation imageOrientation,
@NonNull
Rectangle scanRegion,
@NonNull
ScanResultListener resultListener,
RecognitionSettings recognitionSettings)
image - Image that needs to be recognized.imageOrientation - Orientation of the bitmap image.scanRegion - Region of image that needs to be recognized. Rectangle is given as percentages
of image size - x coordinate and width are percentages of image width and y coordinate
and height are percentages of image height. Therefore, rectangle(0.f, 0.f, 1.f, 1.f)
represents the whole image, whilst rectangle(0.5f, 0.f, 0.5f, 1.f) represents the
right half of the image.resultListener - Result listener that will handle recognition done event.recognitionSettings - Recognition settings that will be used to perform this recognition.java.lang.IllegalStateException - if recognizer is not initialized or is currently workingjava.lang.NullPointerException - if given null scan result listener@UiThread
public final void recognizeImage(@NonNull
Image image,
@NonNull
ScanResultListener resultListener)
image - Image to be processed (usually obtained from ImageListener)resultListener - Listener that will be invoked with recognition result.@UiThread
public final void recognizeImageWithSettings(@NonNull
Image image,
@NonNull
ScanResultListener resultListener,
RecognitionSettings recognitionSettings)
image - Image to be processed (usually obtained from MetadataListener).resultListener - Listener that will be invoked with recognition result.recognitionSettings - Recognition settings that will be used to perform this recognition.java.lang.IllegalStateException - if recognizer is not initialized or is currently working or Image object is already disposedjava.lang.NullPointerException - if given null scan result listenerpublic void cancel()
ScanResultListener given to last
recognition requiest will be called with result or not - in some cases it could happen, in some it
would not.public void terminate()
public void setMetadataListener(MetadataListener metadataListener, MetadataSettings metadataSettings)
metadataListener - metadata listener that will be notified about available metadatametadataSettings - settings defining which metadata should be reported to metadata listener