Kofax Mobile SDK API Reference
|
This class is used to classify images based on given configuration and model. More...
Classes | |
enum | ImageClassificationStatus |
Public Member Functions | |
ImageClassifier () | |
Public constructor allows instantiation from other classes. More... | |
void | doCleanup () |
Clean up local objects. More... | |
ImageClassificationStatus | getStatus () |
void | addImageClassificationCompletedEventListener (ImageClassificationCompletedListener listener) |
Adds the specified listener to receive classification completed events. More... | |
void | removeImageClassificationCompletedEventListener (ImageClassificationCompletedListener listener) |
Removes the specified listener from receiving classification completed events. More... | |
void | setMaxNumberOfResults (int maxNumberOfResults) |
Set the maximum number of classification results to return for an image. More... | |
int | getMaxNumberOfResults () |
Returns the specified maximum number of classification results to return for an image. More... | |
int | loadConfigurationFile (String configFileName) |
Loads a file that contains configuration values for the classifier. More... | |
int | loadModel (String modelFileName) |
Loads a model file that contains the knowledge source for classification. More... | |
int | classifyImage (Image image) |
Use this method to start the image classification process. More... | |
This class is used to classify images based on given configuration and model.
An example of classification would be taking captured images of drivers licenses and classifying them by the issuing state.
The configuration files for use with this API are contained in the SDK in the "Configuration Files" folder of the SDK deliverable.
Use the configuration file driverslicense_config.xml
with the loadConfigurationFile(String) method to setup the classifier to classify United States drivers licenses.
Use the model file driverslicense_model.xml
with the loadModel(String) method to setup the model for the classifier.
Once these files are loaded, you can use the classifyImage(Image) method to determine what type of drivers license is contained in the Image object.
Example:
private void classificationExample() {String pathToClassifyConfig = getPathToClassifyConfig();String pathToClassifyModel = getPathToClassifyModel();Image imgToClassify = getImageToClassify();imgClass.addImageClassificationCompletedEventListener(this);imgClass.loadConfigurationFile(pathToClassifyConfig);imgClass.loadModel(pathToClassifyModel);imgClass.setMaxNumberOfResults(5);imgClass.classifyImage(imgToClassify);}@Overridepublic void onImageClassified(ImageClassificationCompleteEvent event) {Image imageClassified = event.getImage();List<ImageClassificationResult> results = imageClassified.getImageClassifyResults();}
ImageClassifier | ( | ) |
Public constructor allows instantiation from other classes.
Prior to SDK 2.2, ImageClassifier was a singleton object, only instantiated once from the getInstance() method. It is now a regular instance object although multiple instances are still not allowed to be used concurrently.
void addImageClassificationCompletedEventListener | ( | ImageClassificationCompletedListener | listener | ) |
Adds the specified listener to receive classification completed events.
listener | the listener |
int classifyImage | ( | Image | image | ) |
Use this method to start the image classification process.
Call the loadModel(String) and loadConfigurationFile(String) methods before calling classifyImage()
. Results are returned to objects added using the addImageClassificationCompletedEventListener() method.
image | Image to use for classification. A reference will be returned with populated results. |
void doCleanup | ( | ) |
Clean up local objects.
Call this method right before setting your ImageClassifier object to null. After calling this method, your ImageClassifier object is no longer usable.
int getMaxNumberOfResults | ( | ) |
Returns the specified maximum number of classification results to return for an image.
ImageClassificationStatus getStatus | ( | ) |
Returns the current state of the image classification object. It could be available, or it could be processing an image classification.
int loadConfigurationFile | ( | String | configFileName | ) |
Loads a file that contains configuration values for the classifier.
configFileName | Path to the configuration file. |
int loadModel | ( | String | modelFileName | ) |
Loads a model file that contains the knowledge source for classification.
modelFileName | The path to the model file. |
void removeImageClassificationCompletedEventListener | ( | ImageClassificationCompletedListener | listener | ) |
Removes the specified listener from receiving classification completed events.
listener | the listener to remove |
void setMaxNumberOfResults | ( | int | maxNumberOfResults | ) |
Set the maximum number of classification results to return for an image.
Minimum = 1, Maximum: 64
maxNumberOfResults | the maximum number of classification results to return |