FMStickerCaptureView Class Reference
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
-
sticker
The FMSticker object currently used.
property -
showFlash
A flag to activate a flash-like effect on the preview view.
property -
numberOfStickerDetected
The number of stickers currently detected
property -
accessoryView
A view positioned between the previewLayer and the stickers.
property
Initializing a capture session
-
+ setLicense:
Sets the license string for the authorised bundle ID.
-
+ license
Returns the current license string
-
– startCapture
Starts the capture session and initialise all the required components.
Manage face detection
-
– pauseFaceDetection
Pause the face detection.
-
– resumeFaceDetection
Resume the face detection.
Manage camera
-
– switchCamera:
Switch between the front and back facing camera.
-
– takePicture:
Takes the picture from the camera and starts the image manipulation process.
Apply stickers to an image
-
– processPicture:completion:
Takes the picture and starts the image manipulation process.
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
Class Methods
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
See Also
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
See Also
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