iOS- AVCaptureStillImageOutput 快门声问题

iOS 码拜 8年前 (2016-02-02) 1461次浏览
之前没接触过摄像头这块。
现在遇到了点问题。
希望高人解答。
问题描述:
本人想获取摄像头对应的图片, 但不是通过UIImagePickerController获取系统的, 而是自定义拍照界面。
这里通过 AVCaptureStillImageOutput 来截取静图。 但是, 每次获取图片的时候, 都会有快门声。
本人的真机是日版的, 本身拍照是关不掉快门声音。
但是,本人用百度App的时候, 发现它图片搜索功能里面, 获取摄像头静图的时候是没有声音的。
所以想在获取静图的时候, 去掉快门声。
望高手支招..
本人的代码如下:
1. 初始化

//3.创建、配置输出
 captureOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys:AVVideoCodecJPEG,AVVideoCodecKey,nil];
[captureOutput setOutputSettings:outputSettings];
 [self.session addOutput:captureOutput];

2. 获取静图

-(void)Captureimage
{
    returnImage = [[UIImage alloc]init];
    //get connection
    AVCaptureConnection *videoConnection = nil;
    for (AVCaptureConnection *connection in captureOutput.connections) {
        for (AVCaptureInputPort *port in [connection inputPorts]) {
            if ([[port mediaType] isEqual:AVMediaTypeVideo] ) {
                videoConnection = connection;
                break;
            }
        }
        if (videoConnection) { break; }
    }
    
    //get UIImage
    [captureOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:
     ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
         CFDictionaryRef exifAttachments =
         CMGetAttachment(imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
         if (exifAttachments) {
             // Do something with the attachments.
         }   
         // Continue as appropriate.
         NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
         UIImage *t_image = [UIImage imageWithData:imageData];
         returnImage = [[UIImage alloc]initWithCGImage:t_image.CGImage scale:1.0 orientation:UIImageOrientationRight];
     }];
}
解决方案:66分
本人有一篇草稿,正是说的利用AVCaptureSession自定义拍照以及录制视频。但是本人在GitHub上已经更新了工程,你可以看一下:https://github.com/zhangao0086/iOS-CoreImage-Swift
实时滤镜:RealTimeFilter
解决方案:5分
坐等。
解决方案:5分
解决方案:5分
解决方案:5分
都是高手
解决方案:2分
该回复于2014-09-25 11:14:01被管理员删除

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明iOS- AVCaptureStillImageOutput 快门声问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)