2013-05-05 45 views
3

在iPad 3的Retina与iOS 6.1,我初始化我的相机有:GPUImageStillCamera输出分辨率有限公司

stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack]; 
stillCamera.outputImageOrientation = UIInterfaceOrientationLandscapeLeft; 

我设置了摄像头,这些过滤器:

UIImage *inputImage = [UIImage imageNamed:@"blank-1x1.png"]; 
sourcePicture = [[GPUImagePicture alloc] initWithImage:inputImage smoothlyScaleOutput:YES]; 
[sourcePicture processImage]; 

chromaKeyBlendFilter = [[GPUImageChromaKeyBlendFilter alloc] init]; 
[chromaKeyBlendFilter setColorToReplaceRed:0.0 green:1.0 blue:0.0]; 
[chromaKeyBlendFilter setThresholdSensitivity:0.37f]; 
filter = chromaKeyBlendFilter; 

[stillCamera addTarget:filter]; 
[sourcePicture addTarget:filter]; 

[filter addTarget:videoPreviewView]; // 1024x768 view 
[stillCamera startCameraCapture]; 

当我捕捉我使用的图像:

[stillCamera capturePhotoAsPNGProcessedUpToFilter:filter withCompletionHandler:^(NSData *processedPNG, NSError *error){ 
    self.currentImage = [UIImage imageWithData:processedPNG]; 
}); 

但我得到的图像是屏幕大小(视网膜风格)2048x1536,而不是什么我期待后置摄像头为2420x1936。我也注意到#imageFromCurrentlyProcessedOutputWithOrientation#只返回屏幕大小,并且在GPUImageStillCamera.m中查看捕获代码,它看起来好像是输出源自的地方。

我不知道为什么,因为我也有一个选项/按钮来使用非GPUImage设置,我找回了2420x1936的PNG图像。

我在这里做错了什么?感谢您的任何提示(因为我真的想要2420x1936)。

回答

0

首先,我的意思是2592x1936的iPad后置相机全分辨率(我裁剪的图像为8x10尺寸)。事实证明,我试图变得太“聪明”。

当我点击一个按钮来捕捉图像时,我在后台线程中使用以下内容获取保存到属性中的图像(这种情况下PNG文件最多可达8mb)

[stillCamera capturePhotoAsPNGProcessedUpToFilter:filter withCompletionHandler:^(NSData *processedPNG, NSError *error) 
self.currentImage = [UIImage imageWithData:processedPNG]; 

BUT,调度该队列后,我立即segued到我抓起使用

[filter imageFromCurrentlyProcessedOutputWithOrientation:UIImageOrientationUp] 

这是2048x1516,足以在iPad视网膜显示的预览图像的预览图。然后,当该预览被解散时,self.currentImage被裁剪并保存到文件(和核心数据元数据)。

当我注意到预览显示的时候,我得到了太多的“智能”,但我仍然从摄像机获取了KVO控制台信息。因此,在看来我会放入一个“暂停摄像机”并重新出现“恢复摄像机”。显然,当发出暂停摄像头命令时,它立即停止处理,并将其对我的currentImage属性进行转储,并且如果预览可能已经等待了几秒钟,那么它始终是2048x1516图像,而不是全像素图像。

恕我直言,当相机暂停时,任何后台捕捉线程应该继续,直到完成,然后暂停相机。但我可以用这个工作,我很高兴我发现了这个问题。