문제

I'm using AVFoundationFramework to show preview from camera. I do it like that:

self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];
self.previewLayer.frame = cameraPreview.bounds;
self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.previewLayer.connection setVideoOrientation:AVCaptureVideoOrientationPortrait];

[cameraPreview.layer addSublayer:previewLayer];

cameraPreview is simple UIView. It works like a charm but I need to have blur on this preview. Is there any build-in feature on AVFoundationFramework? If not how can I do such blur?

도움이 되었습니까?

해결책

Should use GPUImage - https://github.com/BradLarson/GPUImage - for this. Runs on GPU so it is fast enough I think. You'll need convert UIImages from CMSampleBuffers that AVCaptureSession spits out. This - https://github.com/eppz/eppz.capture/blob/master/eppz!capture/EPPZCaptureBufferParser.m#L81 - may help.

// Create filter.
self.blurFilter = [GPUImageiOSBlurFilter new];

// Apply filter.
UIImage *blurredSnapshotImage = [self.blurFilter imageByFilteringImage:snapshotImage];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top