Kofax Mobile SDK API Reference
Classes | Public Member Functions | List of all members
ImageClassifier Class 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...
 

Detailed Description

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();
ImageClassifier imgClass = new ImageClassifier();
imgClass.addImageClassificationCompletedEventListener(this);
imgClass.loadConfigurationFile(pathToClassifyConfig);
imgClass.loadModel(pathToClassifyModel);
imgClass.setMaxNumberOfResults(5);
imgClass.classifyImage(imgToClassify);
}
@Override
public void onImageClassified(ImageClassificationCompleteEvent event) {
Image imageClassified = event.getImage();
List<ImageClassificationResult> results = imageClassified.getImageClassifyResults();
}
See also
ImageClassificationCompletedListener
ImageClassificationResult
Deprecated:
Deprecated in SDK 3.4.

Constructor & Destructor Documentation

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.

Member Function Documentation

void addImageClassificationCompletedEventListener ( ImageClassificationCompletedListener  listener)

Adds the specified listener to receive classification completed events.

Parameters
listenerthe listener
See also
ImageClassificationCompletedListener
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.

Parameters
imageImage 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.

Returns
the maximum number of classification results

Returns the current state of the image classification object. It could be available, or it could be processing an image classification.

Returns
the status of this classifier
int loadConfigurationFile ( String  configFileName)

Loads a file that contains configuration values for the classifier.

Parameters
configFileNamePath to the configuration file.
int loadModel ( String  modelFileName)

Loads a model file that contains the knowledge source for classification.

Parameters
modelFileNameThe path to the model file.
void removeImageClassificationCompletedEventListener ( ImageClassificationCompletedListener  listener)

Removes the specified listener from receiving classification completed events.

Parameters
listenerthe listener to remove
See also
ImageClassificationCompletedListener
void setMaxNumberOfResults ( int  maxNumberOfResults)

Set the maximum number of classification results to return for an image.

Minimum = 1, Maximum: 64

Parameters
maxNumberOfResultsthe maximum number of classification results to return

The documentation for this class was generated from the following file:
Untitled Document © 2018 Kofax, Inc. All rights reserved. Use is subject to license terms.