【问题标题】:Setting the image capture view in AVCaptureStillImageOutput class在 AVCaptureStillImageOutput 类中设置图像捕获视图
【发布时间】:2013-05-23 09:21:57
【问题描述】:

我正在使用AVCaptureConnectionAVCaptureStillImageOutput 类来创建覆盖屏幕并捕获图像。在视图中,我有一个自定义标签栏,其中包含一些自定义控件,如捕获按钮、闪光按钮等。

问题是相机正在捕获整个图像,并且在预览页面中可以看到。即自定义标签栏为 40 像素,因此向用户显示带有标签栏的捕获区域。用户将图像拍摄到自定义标签栏。但在预览屏幕中,图像被扩展,除了他拍摄的图像外,他看到了更多.

我尝试在AVCaptureConnection中查找属性以设置捕获区域,但找不到任何东西。任何人之前遇到过这个问题,请帮助。

正如你所看到的,用户看到的除了他所服用的东西之外还有额外的东西

【问题讨论】:

    标签: iphone ios ios6 avcapturesession image-capture


    【解决方案1】:

    我认为没有办法在 AVCaptureConnection 中设置捕获区域。相反,您可以尝试从屏幕上读取图像,然后将其裁剪为您的要求。

    如果 UIImage *photoImage 是拍摄照片时返回的图像

    CGRect refRect; //Define this to the exact frame which you want to crop the larger image to i.e. with smaller frame.size.height
    CGFloat deviceScale = photoImage.scale;
    CGImageRef imageRef = CGImageCreateWithImageInRect(photoImage.CGImage. refRect);
    UIIImage *finalPhoto = [[UIImage alloc] initWithCGImage:imageRef deviceScale orientation:photoImage.imageOrientation];
    

    finalPhoto 现在将被裁剪成你想要的样子

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-10
      相关资源
      最近更新 更多