Kofax Mobile SDK API Reference
Functions | Variables
kfxKCLImageClassifier.h File Reference
#import <Foundation/Foundation.h>
#import "kfxKEDImage.h"

Go to the source code of this file.

Functions

int loadConfigurationFile: (NSString *configFileName)
 Loads a file that contains the configuration values for the classifier. More...
 
int loadModel: (NSString *modelFileName)
 Loads a model file that contains the knowledge source for classification. More...
 
int classifyImage: (kfxKEDImage *imageToClassify)
 Starts the image classification process. More...
 

Variables

__deprecated_msg("Deprecated in SDK 3.4.")@protocol kfxKCLDelegate< NSObject > @optional-(void) imageClassifier end __deprecated_msg("Deprecated in SDK 3.4.")@interface kfxKCLImageClassifier int maxNumberOfResults
 Image Classification Protocol. More...
 

Function Documentation

int classifyImage: ( kfxKEDImage imageToClassify)
virtual

Starts the image classification process.

A configuration and model must be loaded before calling classifyImage. Classification will be performed asynchronously. Once classification is complete, the delegate will receive a imageClassifier:status:statusMsg:image: message.

After classification, an array of classification results will be saved in the input image.

Parameters
imageToClassifyA kfxKEDImage object containing the image that needs classification.
Return values
KMC_SUCCESSClassification started without error.
KMC_EV_LICENSINGA valid license has not yet been set.
KMC_CL_CONFIG_NOT_LOADEDA configuration has not been loaded.
KMC_CL_MODEL_NOT_LOADEDA model has not been loaded.
KMC_CL_CLASSIFIER_BUSYA classification is already in progress.
KMC_CL_NO_IMAGE_SUPPLIEDA null image was passed in.
KMC_CL_INVALID_IMAGE_SUPPLIEDThe input image had no valid bitmap or file.

See also
kfxKEDClassificationResult for information regarding one element of the array of possible classification results.
int loadConfigurationFile: ( NSString *  configFileName)
virtual

Loads a file that contains the configuration values for the classifier.

Both a configuration and model must be loaded before starting a classify operation.

Parameters
configFileNameFull path to the configuration file.
Return values
KMC_SUCCESSThe configuration loaded without error.
KMC_EV_LICENSINGA valid license has not yet been set.
KMC_CL_CONFIG_NULLThe configFileName parameter was null or empty.
KMC_CL_CLASSIFIER_BUSYA classification is already in progress.
KMC_GN_FILE_NOT_FOUNDThe configuration file could not be found.
int loadModel: ( NSString *  modelFileName)
virtual

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

Both a configuration and model must be loaded before starting a classify operation.

Parameters
modelFileNameFull path to the model file.
Return values
KMC_SUCCESSThe model loaded without error.
KMC_EV_LICENSINGA valid license has not yet been set.
KMC_CL_MODEL_NULLThe modelFileName parameter was null or empty.
KMC_CL_CLASSIFIER_BUSYA classification is already in progress.
KMC_GN_FILE_NOT_FOUNDThe model file could not be found.

Variable Documentation

__deprecated_msg ("Deprecated in SDK 3.4.") @protocol kfxKCLDelegate<NSObject> @optional - (void)imageClassifier end __deprecated_msg ("Deprecated in SDK 3.4.") @interface kfxKCLImageClassifier int maxNumberOfResults
readwriteassign

Image Classification Protocol.

The kfxKCLDelegate defines the protocol for all the delegates the Image Classification Engine during processing. Only a single delegate is defined, which signals the completion of asynchronous classification operations.Classification Complete Delegate The engine calls this delegate when a classification operation is complete. The image parameter is the same image that was passed into the corresponding classifyImage call. The classification results are available through the image's classificationResults property.

Parameters
imageClassifierThe imageClassifier instance that invoked the delegate.
statusThe status of the completed classification.
statusMsgA message corresponding to the given status.
imageThe image classification was performed on, with results set internally.The Image Classifier Class Framework: libKfxEngines
Import suggestion: #import <kfxLibEngines/kfxEngines.h>
Relevant Header File: kfxKCLImageClassifier.h
An instance of this class contains methods to classify images based on a 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 method to setup the classifier to classify United States drivers licenses.
Use the model file (driverslicense_model.xml) with the loadModel method to setup the model for the classifier. Once these files are loaded, you can use the classifyImage method to determine what type of drivers license is contained in the kfxKEDImage object.

Example of how to get an object to work with the classifier, initializing the classifier and classifying an image.
1 int errorCount = 0; // use an error count just for testing purposes in this code snippet
2 // Create an image object to hold the image to be classified
3 kfxKEDImage * myOwnImage = [[kfxKEDImage alloc] init];
4 
5 // Access the model and configuration files included in the application's bundle.
6 NSBundle* myBundle = [NSBundle mainBundle];
7 NSString* procImage = [myBundle pathForResource:@"imageToClassify" ofType:@"jpg"]; // a picture of a US Driver's license.
8 NSString* cfgFileName = [myBundle pathForResource:@"driverslicense_config" ofType:@"xml"];
9 NSString* modelFileName = [myBundle pathForResource:@"driverslicense_model" ofType:@"xml"];
10 
11 // Get the instance of the image classifier.
12 kfxKCLImageClassifier* imageClassifier = [[kfxKCLImageClassifier alloc] init];
13 
14 // Show the default number of results
15 int count = imageClassifier.maxNumberOfResults;
16 NSLog(@"Default Max Number of results: %d",count);
17 
18 // Setup that we want a maximum of three classification result possibilities
19 imageClassifier.maxNumberOfResults = 3;
20 
21 // Test loading an invalid configuration file
22 int error = [imageClassifier loadConfigurationFile:cfgFileName];
23 
24 if (error != KMC_GN_FILE_NOT_FOUND)
25  errorCount++;
26 
27 error = [imageClassifier loadModel:modelFileName];
28 if (error != KMC_GN_FILE_NOT_FOUND)
29  errorCount++;
30 
31 // Initialize the classifier
32 [imageClassifier loadConfigurationFile:cfgFileName];
33 [imageClassifier loadModel:modelFileName];
34 
35 // Setup the delegate to this view controller, so the classifier can notify me when the classification is completed.
36 imageClassifier.delegate = self;
37 self.classifydone = false;
38 
39 // Get the image to classify from the file path created above.
40 UIImage *img = [UIImage imageWithContentsOfFile:procImage];
41 
42 // Set the image into the kfxKEDImage object
43 error = [myOwnImage specifyImageBitmap:img];
44 if (error != KMC_SUCCESS)
45  errorCount++;
46 
47 // Now classify the image using the asynchronous operation
48 error = [imageClassifier classifyImage:myOwnImage];
49 if (error != KMC_SUCCESS)
50 {
51  errorCount++;
52  // handle the error condition directly here, because the classification did not start.
53 }
54 
55 // Continue on with your application after the classification delegate is called.


Licensing**

This is a license protected class. Certain methods in this object are protected by a license mechanism. If you attempt to use these methods without setting the license, then you will receive the KMC_IP_LICENSE_INVALID error code. Refer to the method descriptions to determine what methods are license protected. In order to set your license, you need to use the setMobileSDKLicense method on the kfxKUTLicensing object. Example code is provided to show you how to set your license, which can be found in the kfxKUTLicensing class of the kfxUtilities framework.

You must set this delegate to the reference of an object that will process messages at the end of classification. This is usually "self" of the object using the classifier.The maximum number of results to return from a classify operation. Acceptable values are in the range [1, 64]. The default value is 1.
Untitled Document © 2018 Kofax, Inc. All rights reserved. Use is subject to license terms.