SCCameraKitLensProcessor
Objective-C
@protocol SCCameraKitLensProcessor <NSObject>
Swift
protocol LensProcessor : NSObjectProtocol
The lens processor handles transforming camera frames and adding effects to them.
-
Lens hint delegate to show/hide hints for applied lenses
Declaration
Objective-C
@property (nonatomic, weak) id<SCCameraKitLensHintDelegate> _Nullable hintDelegate;
-
Specifies whether lenses will have their audio muted. NO by default. @note: Does NOT mute the device microphone, only prevents lenses from producing audio output.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL audioMuted;
Swift
var audioMuted: Bool { get }
-
Applies a specified lens.
Note
Launch data for a specific lens gets persisted automatically so passing nil will reuse the launch data passed to the lens from the previous time applied.Note
To reset launch data passed to the lens from the previous time applied pass inEmptyLensLaunchData
instance.Warning
If the lens provided is NOT provided by the repository, and simply conforms to the protocol, a runtime error will occur.Declaration
Objective-C
- (void)applyLens:(nonnull id<SCCameraKitLens>)lens launchData:(nullable id<SCCameraKitLensLaunchData>)launchData completion:(nullable void (^)(BOOL))completion;
Parameters
lens
the lens to apply. This should be a lens provided by the repository.
launchData
launch data to pass to lens.
completion
a completion handler called once the operation finishes.
-
Removes any applied lenses.
Declaration
Objective-C
- (void)clearWithCompletion:(nullable void (^)(BOOL))completion;
Swift
func clear() async -> Bool
Parameters
completion
a completion handler called once the operation finishes.
-
Configures touch handling for a given view.
Declaration
Objective-C
- (void)configureTouchHandlingInView:(nonnull UIView *)view gestureRecognizerDelegate:(nullable id<UIGestureRecognizerDelegate>) gestureRecognizerDelegate;
Swift
func configureTouchHandling(in view: UIView, gestureRecognizerDelegate: UIGestureRecognizerDelegate?)
Parameters
view
the view to configure.
gestureRecognizerDelegate
an optional gesture recognizer delegate. @note: this method modifies the UIView so it must be called on the main thread
-
Clears all touch handling for a given view
Declaration
Objective-C
- (void)removeTouchHandlingInView:(nonnull UIView *)view;
Swift
func removeTouchHandling(in view: UIView)
Parameters
view
the view to configure @note: this method modifies the UIView so it must be called on the main thread
-
Mutes or unmutes audio. @note: Does NOT mute the device microphone, only prevents lenses from producing audio output. @note: Muting/unmuting is async. The audioMuted property may not immediately reflect your change, but will once completion is called.
Declaration
Objective-C
- (void)setAudioMuted:(BOOL)audioMuted completion:(nullable void (^)(void))completion;
Swift
func setAudioMuted(_ audioMuted: Bool) async
Parameters
audioMuted
whether audio should be muted or not.
completion
an optional completion block to be called when the mute/unmute has taken effect.
-
Process image with lens effect using current camera session configuration
Note
because this uses current session configuration this should mainly be used to process captured photosDeclaration
Objective-C
- (nullable UIImage *)processImage:(nonnull UIImage *)image;
Swift
func processImage(_ image: UIImage) -> UIImage?
Parameters
image
image to process with current lens
-
Adds observer to receive notifications of changes to lens processor state. Returns if observer got successfully added
Declaration
Objective-C
- (BOOL)addObserver:(nonnull id<SCCameraKitLensProcessorObserver>)observer;
Parameters
observer
the observer who wishes to receive callbacks.
-
Removes observer from receiving notifications of changes to lens availability.
Declaration
Objective-C
- (void)removeObserver:(nonnull id<SCCameraKitLensProcessorObserver>)observer;
Parameters
observer
the observer who wishes to stop receiving callbacks.