0
我使用GPUImage面臨以下問題: 1st我正在爲相機添加灰度過濾器,然後我使用GPUImageAverageColor
來獲取平均顏色。問題是我通過塊的顏色不在灰度範圍內。我做錯了什麼?GPUImage平均顏色不適用於應用的灰度過濾器
這是代碼:
GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
GPUImageView *filterView = (GPUImageView *)self.cameraLayer;
[filterView setFillMode:kGPUImageFillModePreserveAspectRatioAndFill];
GPUImageGrayscaleFilter *grayscaleFilter = [[GPUImageGrayscaleFilter alloc] init];
[videoCamera addTarget:grayscaleFilter];
[grayscaleFilter addTarget:filterView];
GPUImageAverageColor *averageColor = [[GPUImageAverageColor alloc] init];
[averageColor setColorAverageProcessingFinishedBlock:^(CGFloat redComponent, CGFloat greenComponent, CGFloat blueComponent, CGFloat alphaComponent, CMTime frameTime){
NSLog(@"Red: %f, green: %f, blue: %f, alpha: %f", redComponent, greenComponent, blueComponent, alphaComponent);
}];
[videoCamera addTarget:averageColor];
[videoCamera startCameraCapture];
嘗試以該攝像機爲目標 - > averageColor-> grayscaleFilter-> filterView – ghkaren 2015-02-16 09:59:38