我正在AR项目中工作,我们想要操纵iPhone4相机的对焦距离.这甚至可能吗?到目前为止,我们发现只需将切换和自动聚焦作为此处列出的选项:http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVCaptureDevice_Class/Reference/Reference.html%23//apple_ref/OCC/instm/AVCaptureDevice/isAdjustingFocus
提前感谢任何提示!:)
我已经在这几天敲打了我的脑袋.
我想在CALayer(AVCaptureVideoPreviewLayer)上绘制一个矩形,恰好是iPhone4上摄像头的视频输入.
这是我设置的一部分;
//(in function for initialization)
-(void)initDevices {
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo] error:nil];
AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
captureOutput.alwaysDiscardsLateVideoFrames = YES;
captureOutput.minFrameDuration = CMTimeMake(1, 30);
dispatch_queue_t queue;
queue = dispatch_queue_create("cameraQueue", NULL);
[captureOutput setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
[captureOutput setVideoSettings:videoSettings];
self.captureSession = [[AVCaptureSession alloc] init];
[self.captureSession addInput:captureInput];
[self.captureSession addOutput:captureOutput];
[self.captureSession setSessionPreset:AVCaptureSessionPresetHigh];
self.prevLayer = [AVCaptureVideoPreviewLayer layerWithSession: self.captureSession];
self.prevLayer.frame = CGRectMake(0, 0, 400, 400);
self.prevLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; …
Run Code Online (Sandbox Code Playgroud)