Log in or register to post comments

QCAR Projection/ModelView Matrix to OpenGL projection/modelView Matrix

July 24, 2014 - 8:16am #1

Hi,

I use QCAR libairie to create an AR scene. During rendering i save the background as a texture (the camera rendering) and the projection matrix and the trackable modelview matrix.

When i recreate the scene without the AR, just an simple OpenGL scene. I apply the saved projection matrix and the saved modelview matrix to the scene. But the rendering appears to be height scale down.

I just want to create a scene with the AR, save it and reload it to edit the mesh with the background texture.

Do you know how i can get the correct projection and modelview matrix from the QCAR matrix to get the correct rendering in a GL scene?

 

I get the projection matrix like :

const QCAR::CameraCalibration& cameraCalibration = QCAR::CameraDevice::getInstance().getCameraCalibration();
QCAR::Tool::getProjectionGL(cameraCalibration, 100.0f, 1000.0f)

and the model view matrix like:

const QCAR::TrackableResult* result = mState.getTrackableResult(numTrack);
matrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());

Thank you for your help

QCAR Projection/ModelView Matrix to OpenGL projection/modelView

July 24, 2014 - 9:26am #2

i come back because i test without renderin the video background and i don't have the deformation if i comment QCAR::Renderer::drawVideoBackgound() call....

Here is my AR rendering loop :

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
mState = camera.mRenderer->begin();
camera.mRenderer->drawVideoBackground();
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

QCAR::Matrix44F modelViewMatrix;
QCAR::Matrix44F projectionMatrix;
QCAR::Matrix44F modelViewProjection;

const QCAR::CameraCalibration& cameraCalibration = QCAR::CameraDevice::getInstance().getCameraCalibration();
projectionMatrix = QCAR::Tool::getProjectionGL(cameraCalibration, 100.0f, 1000.0f);

for(int numTrack = 0; numTrack < autoRenderVideo.getNumTrackableResults(); ++numTrack)
{
    const QCAR::TrackableResult* result = mState.getTrackableResult(numTrack);
    modelViewMatrix =  QCAR::Tool::convertPose2GLMatrix(result->getPose())

    const float* customScale = mesh->getCustomScale();
    SampleUtils::scalePoseMatrix(customScale[0], customScale[1],customScale[2], &modelViewMatrix.data[0]);

    const float* customTranslation = mesh->getCustomTranslation();
    SampleUtils::translatePoseMatrix(customTranslation[0], customTranslation[1], customTranslation[2], &modelViewMatrix.data[0]);

    SampleUtils::multiplyMatrix(&projectionMatrix.data[0],    
    			        &modelViewMatrix.data[0] ,
    			        &modelViewProjection.data[0]);
    mesh->draw((GLfloat*)&modelViewProjection.data[0]);
}

 

So if i comment

camera.mRenderer->drawVideoBackground();

everything works fine. But if i keep it, object is rescale..

Any idea?

 

Thanks

Log in or register to post comments