我使用iPhone相机在我的iOS APP中捕捉图像。
AVCaptureVideoDataOutputSampleBufferDelegate
用于从iPhone相机获取图像。
该计划的一部分如下所示。
AVCaptureDevice *videoDevice = [AVCamViewController deviceWithMediaType:AVMediaTypeVideo preferringPosition:AVCaptureDevicePositionBack];
AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
if (error)
{
NSLog(@"%@", error);
}
if ([session canAddInput:videoDeviceInput])
{
[session addInput:videoDeviceInput];
[self setVideoDeviceInput:videoDeviceInput];
dispatch_async(dispatch_get_main_queue(), ^{
// Why are we dispatching this to the main queue?
// Because AVCaptureVideoPreviewLayer is the backing layer for AVCamPreviewView and UIView can only be manipulated on main thread.
// Note: As an exception to the above rule, it is not necessary to serialize video orientation changes on the AVCaptureVideoPreviewLayer’s connection with other session manipulation.
//[self previewView] layer
[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:(AVCaptureVideoOrientation)[self interfaceOrientation]];
});
}
有时,环境有点暗。在iPhone相机应用程序中,它可以通过点击较暗部分的iPhone屏幕来增亮图像。但我不喜欢这样的参与。 我检查RGB强度,一旦我意识到亮度不够,我想通过调整程序中的相机参数(如相机曝光等)来提亮图像。在iPhone编程中有可能吗? 感谢