Closed haemi closed 8 years ago
You should be able to create a chain of filters using GPUImage which this project uses.
sorry, I don't get it yet; can you give a short example for how to achieve that?
here is sample GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
// 创建一个 filter GPUImageSketchFilter filter = [[GPUImageSketchFilter alloc] init]; __weak typeof(self) wself = self; filter.frameProcessingCompletionBlock = ^(GPUImageOutput output, CMTime time) { __strong typeof(wself) strongSelf = wself; if (strongSelf && PLStreamStateConnected == strongSelf.session.streamState) { // 从 filter 中读取 GPUImageFramebuffer 对象 GPUImageFramebuffer *imageFramebuffer = output.framebufferForOutput;
// 通过上面添加的方法获取到 CVPixelBufferReft
CVPixelBufferRef pixelBuffer = [imageFramebuffer renderTarget];
if (pixelBuffer) {
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
CVPixelBufferRetain(pixelBuffer);
// 发送视频数据
[strongSelf.session pushPixelBuffer:pixelBuffer completion:^{
CVPixelBufferRelease(pixelBuffer);
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
}];
}
}
};
GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:(CGRect){0, 64, width, height}];
// Add the view somewhere so it's visible [self.view addSubview:filteredVideoView];
[videoCamera addTarget:filter]; [filter addTarget:filteredVideoView];
[videoCamera startCameraCapture];
there is no renderTarget
method on GPUImageFramebuffer
- how can I achieve this conversion?
you can modify the GPUimageFilter and add this method
I would like to modify the video coming from the device - is this possible somehow? E.g. with OpenCV?