【问题标题】:iPhone 4S is unable to handle full resolution from AVCaptureSessionPresetPhotoiPhone 4S 无法处理来自 AVCaptureSessionPresetPhoto 的全分辨率
【发布时间】:2013-08-01 14:04:46
【问题描述】:

我一直在 iPhone 4S 和 iPhone5 上开发我的项目。在我的项目中,拍摄照片后,我将其裁剪,然后调整图像大小以应用照片滤镜。 iPhone 5 似乎处理得很好,但在 iPhone 4S 上,它似乎在拍照过程中的不同点崩溃。我检查了是否有任何我可能遗漏的内存泄漏。下面是代码:

[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
 {

     [captureSession stopRunning];

     NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
     UIImage *newImage = [[UIImage alloc] initWithData:imageData];

之后,我会自动检测所拍照片的方向并旋转照片,使其始终保持直立。

在此之后,我使用NYXImagesKit 将图像裁剪为正方形

     float filteringSquareRatio = 307.0/320.0;
     UIImage *cropped = [newImage cropToSize:CGSizeMake(filteringSquareRatio * newImage.size.width, filteringSquareRatio * newImage.size.width) usingMode:NYXCropModeCenter];

最后,我使用MGImageUtilities调整图像大小

    UIImage *resized = [cropped imageScaledToFitSize:CGSizeMake(320, 320)];

有没有更好的方法来做到这一点?我目前正在使用 AVCaptureSessionPresetPhoto 因为我想将原始高分辨率照片保存在设备上并将裁剪和调整大小的版本发送到服务器。我不想使用任何视频预设,因为相机已放大。什么可能导致崩溃?

【问题讨论】:

    标签: iphone memory-leaks photo avcapturesession


    【解决方案1】:

    如果您无法找到解决方案(我也看到了这个问题),您或许可以检测到 4s 并使用分辨率较低的“高”预设。

    【讨论】:

      猜你喜欢
      • 2012-10-02
      • 1970-01-01
      • 2013-10-12
      • 2015-06-05
      • 1970-01-01
      • 1970-01-01
      • 2011-09-14
      • 1970-01-01
      • 2011-05-23
      相关资源
      最近更新 更多