Inherits from UIView
Conforms to AVCaptureVideoDataOutputSampleBufferDelegate
Declared in FMStickerCaptureView.h

Overview

FMStickerCaptureView is a subclass of UIView used to display the video feed coming from the camera of iPhone and iPad and overlay images that use points generated by the Face Detection API available from iOS 5 onwards. It can be setup both in Interface Builder or programmatically in code and the video is automatically scaled to fit the view.

The view is initialised by the startCapture method. Face Detection can be paused and resumed programmatically with pauseFaceDetection and resumeFaceDetection methods.

There are also two convenience methods to handle the camera. Calling switchCamera: will perform a transition between the front and back facing camera. The shutter button should call the takePicture: method which on completion returns the final UIImage with the sticker attached or a NSError if something went wrong.

Images applied to the preview and the final picture should be set on the sticker property.

Tasks

Public properties

Initializing a capture session

Manage face detection

Manage camera

Apply stickers to an image

Properties

accessoryView

A view positioned between the previewLayer and the stickers.

@property (readonly) UIView *accessoryView

Discussion

This view can be used to display additional items between the video feed and the stickers.

Declared In

FMStickerCaptureView.h

numberOfStickerDetected

The number of stickers currently detected

@property (readonly) NSInteger numberOfStickerDetected

Discussion

This property indicates the number of stickers detected in the video feed, in real time.

Declared In

FMStickerCaptureView.h

showFlash

A flag to activate a flash-like effect on the preview view.

@property (assign, nonatomic) BOOL showFlash

Discussion

Setting this value to YES will trigger a fade-to-white animation of the preview view every time a picture is taken.

Declared In

FMStickerCaptureView.h

sticker

The FMSticker object currently used.

@property (strong, nonatomic) FMSticker *sticker

Discussion

This property defines the current FMSticker object used by the preview view and that will be attached to the final image.

Declared In

FMStickerCaptureView.h

Class Methods

license

Returns the current license string

+ (NSString *)license

Declared In

FMStickerCaptureView.h

setLicense:

Sets the license string for the authorised bundle ID.

+ (void)setLicense:(NSString *)license

Parameters

license

The license NSString

Discussion

The FMStickerEngine framework is a paid component. You can try it for free in development by using the bundle ID and the license provided in this project.

In order to publish your app on the App Store, you need to purchase a valid license and set this property accordingly.

Declared In

FMStickerCaptureView.h

Instance Methods

pauseFaceDetection

Pause the face detection.

- (void)pauseFaceDetection

Declared In

FMStickerCaptureView.h

processPicture:completion:

Takes the picture and starts the image manipulation process.

- (void)processPicture:(UIImage *)image completion:(void ( ^ ) ( UIImage *picture , NSError *error ))completion

Parameters

image

A UIImage on which the sticker will be applied. You should supply an image with the correct orientation.

completion

A block which is called when the detection process is completed. It returns an UIImage.

Declared In

FMStickerCaptureView.h

resumeFaceDetection

Resume the face detection.

- (void)resumeFaceDetection

Declared In

FMStickerCaptureView.h

startCapture

Starts the capture session and initialise all the required components.

- (void)startCapture

Discussion

This method should be called when ready to show the preview view.

Declared In

FMStickerCaptureView.h

switchCamera:

Switch between the front and back facing camera.

- (void)switchCamera:(void ( ^ ) ( void ))completion

Parameters

completion

A block which is called when the camera switch is completed.

Declared In

FMStickerCaptureView.h

takePicture:

Takes the picture from the camera and starts the image manipulation process.

- (void)takePicture:(void ( ^ ) ( UIImage *picture , NSError *error ))completion

Parameters

completion

A block which is called when the detection process is completed. It returns an UIImage.

Declared In

FMStickerCaptureView.h