Atalasoft MobileImage API Reference
Instance Methods | Class Methods | Properties | List of all members
kfxKCLImageClassifier Class Reference

The Image Classifier Singleton Object. More...

#import <kfxKCLImageClassifier.h>

Inheritance diagram for kfxKCLImageClassifier:

Instance Methods

(int) - loadConfigurationFile:
 Loads a file that contains the configuration values for the classifier. More...
 
(int) - loadModel:
 Loads a model file that contains the knowledge source for classification. More...
 
(int) - classifyImage:
 Starts the image classification process. More...
 
(void) - DEPRECATED_ATTRIBUTE
 Begin an AppStats session. More...
 
(void) - DEPRECATED_ATTRIBUTE
 End an AppStats session. More...
 

Class Methods

(kfxKCLImageClassifier *) + DEPRECATED_ATTRIBUTE
 The Classifier factory method. More...
 

Properties

id< kfxKCLDelegatedelegate
 A delegate to receive messages from the engine. More...
 
int maxNumberOfResults
 The maximum number of results to return from a classify operation. More...
 

Detailed Description

The Image Classifier Singleton Object.

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.

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.

Method Documentation

- (int) classifyImage: (kfxKEDImage *)  imageToClassify

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.
+ (kfxKCLImageClassifier *) DEPRECATED_ATTRIBUTE

The Classifier factory method.

This method returns a instance of kfxKCLImageClassifier.

Returns
An instance of the classifier engine.

Example of how to get an object to work with the classifier, initializing the classifier and classifying an image.
int errorCount = 0; // use an error count just for testing purposes in this code snippet
// Create an image object to hold the image to be classified
kfxKEDImage * myOwnImage = [[kfxKEDImage alloc] init];
// Access the model and configuration files included in the application's bundle.
NSBundle* myBundle = [NSBundle mainBundle];
NSString* procImage = [myBundle pathForResource:@"imageToClassify" ofType:@"jpg"]; // a picture of a US Driver's license.
NSString* cfgFileName = [myBundle pathForResource:@"driverslicense_config" ofType:@"xml"];
NSString* modelFileName = [myBundle pathForResource:@"driverslicense_model" ofType:@"xml"];
// Get the instance of the image classifier.
kfxKCLImageClassifier* imageClassifier = [[kfxKCLImageClassifier alloc] init];
// Show the default number of results
int count = imageClassifier.maxNumberOfResults;
NSLog(@"Default Max Number of results: %d",count);
// Setup that we want a maximum of three classification result possibilities
imageClassifier.maxNumberOfResults = 3;
// Test loading an invalid configuration file
int error = [imageClassifier loadConfigurationFile:cfgFileName];
if (error != KMC_GN_FILE_NOT_FOUND)
errorCount++;
error = [imageClassifier loadModel:modelFileName];
if (error != KMC_GN_FILE_NOT_FOUND)
errorCount++;
// Initialize the classifier
[imageClassifier loadConfigurationFile:cfgFileName];
[imageClassifier loadModel:modelFileName];
// Setup the delegate to this view controller, so the classifier can notify me when the classification is completed.
imageClassifier.delegate = self;
self.classifydone = false;
// Get the image to classify from the file path created above.
UIImage *img = [UIImage imageWithContentsOfFile:procImage];
// Set the image into the kfxKEDImage object
error = [myOwnImage specifyImageBitmap:img];
if (error != KMC_SUCCESS)
errorCount++;
// Now classify the image using the asynchronous operation
error = [imageClassifier classifyImage:myOwnImage];
if (error != KMC_SUCCESS)
{
errorCount++;
// handle the error condition directly here, because the classification did not start.
}
// Continue on with your application after the classification delegate is called.
- (void) DEPRECATED_ATTRIBUTE

Begin an AppStats session.

This method begins a new AppStats session. It creates a new instance object and initializes it with the current time. In combination with SessionDismiss, it allows specified log information to be bracketed with begin and end times.

- (void) DEPRECATED_ATTRIBUTE

End an AppStats session.

This method ends an AppStats session. It updates a previously created instance object with a dismissal time.

- (int) loadConfigurationFile: (NSString *)  configFileName

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

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.

Property Documentation

- (id<kfxKCLDelegate>) delegate
readwriteatomicstrong

A delegate to receive messages from the engine.

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.

- (int) maxNumberOfResults
readwriteatomicassign

The maximum number of results to return from a classify operation.

Acceptable values are in the range [1, 64]. The default value is 1.


The documentation for this class was generated from the following file:
Untitled Document © 2016 Atalasoft, Inc., 116 Pleasant St, Suite 321, Easthampton, MA 01027, U.S.A. All rights reserved. Use is subject to license terms.