I am developing an iOS Augmented Reality application using OpenCV. I'm having trouble creating a camera projection matrix so that the OpenGL overlay displays directly on top of the marker. I feel this is because the iPhone 6 camera was not correctly calibrated in the app. I know there is OpenCV code for calibrating webcams, etc. Using a chessboard, but I can’t find a way to calibrate the built-in iPhone camera.
Is there any way? Or are there known estimates for the iPhone 6? These include: the focal length along x and y, the primary point along x and y, as well as the matrix of distortion coefficients.
Any help would be appreciated.
EDIT:
The highlighted values are as follows (using iPhone 6, camera resolution 1280x720):
fx=1229
cx=360
fy=1153
cy=640
This code provides an accurate estimate of the focal length and primary points for devices currently running on iOS 9.1.
AVCaptureDeviceFormat *format = deviceInput.device.activeFormat;
CMFormatDescriptionRef fDesc = format.formatDescription;
CGSize dim = CMVideoFormatDescriptionGetPresentationDimensions(fDesc, true, true);
float cx = float(dim.width) / 2.0;
float cy = float(dim.height) / 2.0;
float HFOV = format.videoFieldOfView;
float VFOV = ((HFOV)/cx)*cy;
float fx = abs(float(dim.width) / (2 * tan(HFOV / 180 * float(M_PI) / 2)));
float fy = abs(float(dim.height) / (2 * tan(VFOV / 180 * float(M_PI) / 2)));
Note:
I had a problem initializing with this code. I recommend that once the values are initialized and set correctly, to save them in the data file and read this file for the values.
source
share