Simple ECM Image Processing SDK for iOS

Screenshot

Features

Quick Setup for the Wizard

1. Include the required dependencies:

2. Include the SDK files

Whenever you need to import the headers, use
			
#import <SimpleECM Image Processing SDK/SECM_Image_Processing.h>
			
		

3. Configure the build settings

Your application's product name must match with your license.
The supported architectures are armv7, armv7s, arm64.
Add the -ObjC option to the Other Linker Flags build setting.

4. Verify your license

In your AppDelegate's -(void)application:didFinishLaunchingWithOptions: method, load your license and your signed license files and pass them to + [SECMLicense verifyLicense:withSignedLicense:]
			
NSData *license = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"licenseFile" ofType:@""]];
NSData *signature = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"licenseFile" ofType:@"signed"]];
[SECMLicense verifyLicense:license withSignedLicense:signature];
			
		

Note: If you don't verify the license, the SDK won't apply any of the operations to the images

5. Create an SECMCaptureDocumentWizardBuilder instance

			
SECMCaptureDocumentWizardBuilder *builder = [[SECMCaptureDocumentWizardBuilder alloc] init];
			
		

6. Configure the wizard builder

You can customize different display options in the wizard. To do so, just set the different properties it has before creating the wizard. If you don't set a property, it will be ignored and the wizard will use its default values
For example, by setting the following properties, you can modify the wizard's navigation bar colors.
			
@property (nonatomic, strong) UIColor *navigationBarBarTintColor;
@property (nonatomic, strong) UIColor *navigationBarTintColor;
			
		

Note: the wizard will set the UINavigationBar's barTintColor property regardless of the iOS version the user is running. If you're supporting iOS 6, do not set the barTintColor properties in the builder.

7. Set the builder's delegate

The wizard will notify its delegate whenever the it is closed or the capture is finished.
			
builder.delegate = self;
			
		

8. Create and present the wizard

			
UIViewController *wizard = [builder createDocumentWizardController];
[self presentViewController:wizard animated:YES completion:^{}];
			
		

Implementing the SECMCaptureDocumentWizardDelegate

When the user closes the capture, the wizard will notify its delegate using the following method:
							
- (void)documentBuilderDidClose:(SECMDocumentBuilder *)builder deleting:(BOOL)deleting;
			
		
The deleting flag will specify if the user wants to delete the document.
You can do so using the method -[SECMDocumentBuilder deleteDocument]
When the user finishes the capture, the wizard will notify its delegate using the following method:
			
- (void)documentBuilderDidFinish:(SECMDocumentBuilder *)builder;
			
		
You can obtain the captured images by using the SECMDocumentBuilder's methods:
			
//Build a pdf with all the enhanced images
- (void)buildPDFDocument;

//Obtain the built pdf 
- (NSData *)PDFDocument;
			
			
//Access each image individually using the following methods

//returns the number of images
- (NSUInteger)numberOfImages;

//returns the enhanced image (with brightness and contrast, and rotation applied)
- (UIImage *)enhancedImageAtIndex:(NSUInteger)index;
			
		

Note: It is your responsibility to dismiss the wizard by calling -[UIViewController dismissViewControllerAnimated:completion:]

Using the Core SDK functions

If you require something different from what the wizard provides, you can use the Core SDK functions instead. To do so, you create an SECMImage object and initialize it with an UIImage object.
			
/**
 Adjust the brightness and contrast of an image. Modifies the current SECMImage object.
 @param float brightness the brightness modifier. Range goes from -1.0f to 1.0f.
 @param float contrast the contrast modifier. Range goes from 0.0f to 2.0f.
 */
- (void)adjustBrightness:(float) brightness andContrast:(float) contrast;

/**
 Converts the image to black and white. Modifies the current image object.
 */
- (void)convertToBlackAndWhite;

/**
 Converts the image to grayscale. Modifies the current SECMImage object.
 */
- (void)convertToGrayScale;


/**
 Rotates the image to a fixed angle. Modifies the current SECMImage object.
 @param SECMImageRotation rotation the desired rotation. Options are available in SECMImageRotation.
 */
- (void)rotateFixed:(SECMImageRotation)rotation;


/**
 Rotates the image. Modifies the current SECMImage object.
 @param float degrees the rotation angle
 */
- (void)rotate:(float)degrees;

/**
 Detects a document in the image
 @param float *aptitude output parameter that will hold the detected quadrangle's aptitude
 @return SECMQuadrangle the detected quadrangle
 */
- (SECMQuadrangle *)detectEdgesAndAptitude:(float *)aptitude;

/**
 Dewarps a quadrangle in the image
 @param SECMQuadrangle *quadrangle the quadrangle to be dewarped
 */
- (void)dewarpWithQuadrangle:(SECMQuadrangle *)quadrangle;
			
		

The SECMImage object is mutable, and applying the image operations on it will change its contents.


Once you've applied the operations to the SECMImage, you can obtain a UIImage from it using its image property. You can also use the SECMExporter to export the SECMImage directly to a PDF, PNG or JPEG file.

Multithreading

The SDK provides NSOperations (SECMImageOperation and its sublcasses) for each operation. Once the operations are completed, they notify the delegate through the -(void)SECMImageOperation:didFinishWithResult: method. You can then obtain information from the passed dictionary using the following constants:
			
extern NSString * const SECMImageOperationOutputImage; ///< Key to obtain the resulting image from the results dictionary
extern NSString * const SECMImageOperationName; ///< Key to obtain the operation name from the results dictionary

//For the adjust brightness and contrast operation
extern NSString * const SECMImageOperationBrightness;///< Key to obtain the brightness modifier in the results dictionary
extern NSString * const SECMImageOperationContrast;///< Key to obtain the contrast modifier in the results dictionary

//For the fixed rotation operation
extern NSString * const SECMImageOperationFixedRotationValue;///< the desired fixed rotation angle

//For the rotation operation
extern NSString * const SECMImageOperationRotationAngle;///< the rotation angle

//For the dewarp operation
extern NSString * const SECMImageOperationQuadrangle;///< the quadrangle to be dewarped

//For the detect edges operation
extern NSString * const SECMImageOperationDetectEdges;///< The operation's name in the results dictionary
extern NSString * const SECMImageOperationDetectedQuadrangle;///< Key to obtain the detected quadrangle from the results dictionary
extern NSString * const SECMImageOperationQuadrangleAptitude;///< Key to obtain the detected quadrangle's aptitude from the results dictionary (values goes from 0 to 1)