我在 iOS 7 上使用 OpenGL 将前置摄像头视频捕获渲染到 UIView
在 iPhone 显示屏上(相同的 iphone 5)。我正在使用 AVCaptureSessionPreset640x480
并将其传递给 AVCaptureSession
方法
[captureSession setSessionPreset:AVCaptureSessionPreset640x480];
然而渲染的视频似乎比上面设置的分辨率低,
它似乎是 AVCaptureSessionPreset352x288
。事实上,无论我通过什么常数
从这些没有区别,分辨率是相同的
NSString *const AVCaptureSessionPresetPhoto;
NSString *const AVCaptureSessionPresetHigh;
NSString *const AVCaptureSessionPresetMedium;
NSString *const AVCaptureSessionPresetLow;
NSString *const AVCaptureSessionPreset352x288;
NSString *const AVCaptureSessionPreset640x480;
NSString *const AVCaptureSessionPreset1280x720;
NSString *const AVCaptureSessionPreset1920x1080;
NSString *const AVCaptureSessionPresetiFrame960x540;
NSString *const AVCaptureSessionPresetiFrame1280x720;
NSString *const AVCaptureSessionPresetInputPriority;
如何检查相机实际拍摄的分辨率?
谢谢
最佳答案
读取正在捕获的缓冲区的尺寸,如下所示(对于AVCaptureSessionPresetPhoto
,您当然需要捕获静止图像,而不是读取视频帧...):
- (void) captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
CVPixelBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer,0);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
CVPixelBufferUnlockBaseAddress(imageBuffer,0);
// "width" and "height" now hold your dimensions...
}
关于ios - 检查相机的 iOS 捕获分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25069027/