Live camera filter with CIFilter in Objective-C
Add KTCamera.h
and KTCamera.m
in your project.
Setup & Running camera session
-(void)setupCamera {
self.camera = [KTCamera new];
self.camera.delegate = self;
self.camera.flashMode = AVCaptureFlashModeOff;
[self.camera setupSessionWithCompletionHandler:^(NSError * _Nonnull error) {
if (error != nil) {
NSLog(@"Setup camera error: %@", error.localizedDescription);
return;
}
[self.camera startRunning];
}];
}
Add camera filter
self.camera.filter = [CIFilter filterWithName:@"CIComicEffect"];
Capture photo
[self.camera capturePhoto];
Delegate handle
-(void)camera:(KTCamera *)camera didOutputSampleImage:(CIImage *)ciImage {
dispatch_async(dispatch_get_main_queue(), ^{
//Using ciImage for preview
});
}
-(void)camera:(KTCamera *)camera didCaptureImage:(UIImage *)image {
//Handle capture photo (filtered image)
}
As the creators, and maintainers of this project, we're glad to invite contributors to help us stay up to date.
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
KTCamera is available under the MIT license. See the LICENSE file for more info.