Hi! I am looking into how the Projection matrix is created in Vuforia using the Native iOS SDK and I am finding some inconsistencies. First off, I have reviewed the pages that cover how the projection matrix is created: https://developer.vuforia.com/resources/dev-guide/projection-matrix-explained and https://developer.vuforia.com/resources/dev-guide/camera-parameters.
So, I took the code that creates the projection matrix and tried to create my own. The results are DIFFERENT than the Vuforia getProjectionGL method. Here is the code and results:
Create Projection Matrix Manually:
float nearPlane = 2.0f; float farPlane = 2000.0f; const QCAR::CameraCalibration& cameraCalibration = QCAR::CameraDevice::getInstance().getCameraCalibration(); QCAR::Vec2F size = cameraCalibration.getSize(); QCAR::Vec2F focalLength = cameraCalibration.getFocalLength(); QCAR::Vec2F principalPoint = cameraCalibration.getPrincipalPoint(); float dx = principalPoint.data[0] - size.data[0] / 2; float dy = principalPoint.data[1] - size.data[1] / 2; float x = 2.0f * focalLength.data[0] / size.data[0]; float y = -2.0f * focalLength.data[1] / size.data[1]; float a = 2.0f * dx / size.data[0]; float b = -2.0f * (dy + 1.0f) / size.data[1]; float c = (farPlane + nearPlane) / (farPlane - nearPlane); float d = -nearPlane * (1.0f + c); QCAR::Matrix44F mat; mat.data[0] = x; mat.data[1] = 0.0f; mat.data[2] = 0.0f; mat.data[3] = 0.0f; mat.data[4] = 0.0f; mat.data[5] = y; mat.data[6] = 0.0f; mat.data[7] = 0.0f; mat.data[8] = a; mat.data[9] = b; mat.data[10] = c; mat.data[11] = 1.0f; mat.data[12] = 0.0f; mat.data[13] = 0.0f; mat.data[14] = d; mat.data[15] = 0.0f;
Get Projection Matrix via Vuforia:
float nearPlane = 2.0f; float farPlane = 2000.0f; QCAR::Matrix44F projectionMatrix = QCAR::Tool::getProjectionGL(cameraCalibration, nearPlane, farPlane);
Results:
mat.data: 1.86, 0.00, 0.00, 0.00 0.00, -2.48, 0.00, 0.00 0.00, 0.00, 1.00, 1.00 0.00, 0.00, -4.00, 0.00 projectionMatrix.data: 0.00, -1.86, 0.00, 0.00 -2.48, 0.00, 0.00, 0.00 0.01, -0.00, 1.00, 1.00 0.00, 0.00, -4.00, 0.00
As one can see, the two matrices are DIFFERENT. Why? The code I used above was copied exactly from https://developer.vuforia.com/resources/dev-guide/camera-parameters and the code can also be found at https://developer.vuforia.com/forum/faq/technical-how-do-i-build-my-own-camera-projection-matrix.
Projection Matrix creation?
Have you tried both Landscape and Portrait modes ?
Projection Matrix creation?
I am also having the same problem... the correct projection matrix according to the code given in the previous post should be :
QCAR:: <<Is C++?
QCAR:: <<Is C++?
Unity C # how to write?