I've followed the documentation of OpenCV to implement the camera preview. Here, CvVideoCamera is initialised with a UIIamgeView
. I've now set the constraints of my UIImageView to fill out the whole screen.
The initialisation of the camera is as follows:
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];
I've also set the contentMode:
[imageView setContentMode:UIViewContentModeScaleAspectFill]
Still, the camera preview is distorted:
For comparison the in the camera app: