我已将OpenCV的文档跟踪到implement the camera preview。这里,CvVideoCamera初始化为UIIamgeView
。我现在设置了UIImageView的约束来填充整个屏幕。
相机初始化如下:
self.videoCamera = [[VideoCamera alloc] initWithParentView:imageView];
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPresetMedium;
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.videoCamera.defaultFPS = 30;
self.videoCamera.grayscaleMode = false;
self.videoCamera.delegate = self;
[self.videoCamera start];
我还设置了contentMode:
[imageView setContentMode:UIViewContentModeScaleAspectFill]
仍然,相机预览失真:
在相机应用程序中进行比较:
答案 0 :(得分:0)
您需要调整defaultAVCaptureSessionPreset
,例如:
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset1280x720;
以下是支持iOS 9的设备上所有经过测试的相机sessionPreset的表格