首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用AVCaptureSession的ios光学变焦

使用AVCaptureSession的ios光学变焦
EN

Stack Overflow用户
提问于 2013-11-21 12:18:45
回答 1查看 648关注 0票数 0

嗨,我正在开发一个有条形扫描选项的应用程序,所以我使用zbar,但我正在制作自己的相机视图端口,并将图像发送到zbar扫描仪,但我需要以编程方式缩放相机,我需要光学变焦。我可以做数码变焦,但我需要光学变焦选项。有什么帮助吗?为了制作摄像头视图端口,我使用了AVCaptureSession。下面是我的代码

代码语言:javascript
复制
-(void)initializecam{ 
AVCaptureSession *session = [[AVCaptureSession alloc] init];
//session.sessionPreset = AVCaptureSessionPresetMedium;
session.sessionPreset = AVCaptureSessionPresetPhoto;

AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];

captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
[captureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];


[self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
if (!input) {
    // Handle the error appropriately.
    NSLog(@"ERROR: trying to open camera: %@", error);
}
[session addInput:input];
_stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys: AVVideoCodecJPEG, AVVideoCodecKey, nil];
[_stillImageOutput setOutputSettings:outputSettings];

[session addOutput:_stillImageOutput];
[session startRunning];
}
EN

回答 1

Stack Overflow用户

发布于 2013-11-21 13:00:50

你不能使用光学变焦,因为目前iOS设备上还没有光学变焦。刚看过最新款的iPhone 5s,而且只有数码变焦功能。所以你需要外部设备来使用光学变焦。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20112370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档