Ask Your Question

Revision history [back]

Hey , Thank you for the wonderful answer. I have one more query.I have 3x3 camera calibration Matrix, how can i use camera calibration matrix with the openGL projection matrix. I used above glViewMatrix and now I am able see 3d object on my camera screen. but i think there is some issue with size. it may be because i am not doing anything with OpenGL projection matrix

@Override public void onSurfaceChanged(GL10 glUnused, int width, int height) { // Set the OpenGL viewport to the same size as the surface. GLES30.glViewport(0, 0, width, height);

    // Create a new perspective projection matrix. The height will stay the same
    // while the width will vary as per aspect ratio.
    final float ratio = (float) width / height;
    final float left = -ratio;
    final float right = ratio;
    final float bottom = -1.0f;
    final float top = 1.0f;
    final float near = 1.0f;
    final float far = 10.0f;

    Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}

I am calculating glViewMatrix same as you said.and saving that in mViewMatrix. by doing this i am able to see my 3d object on the screen. but it has some size issues.

Mat glViewMatrix = Mat.zeros(new Size(4,4),CV_64FC1);

    getglViewMatrix(glViewMatrix.getNativeObjAddr());
    int index=0;
    for(int rows=0;rows<glViewMatrix.rows();rows++){
        for(int cols=0;cols<glViewMatrix.cols();cols++){
            mViewMatrix[index]= (float) glViewMatrix.get(rows,cols)[0];
            index++;
        }
    }

So my question is how we should use camera calibration matrix to correct the size?