Log in or register to post comments

Object moves when moving camera

September 6, 2016 - 12:23pm #1

Hello all,

I am working with Vuforia 5.5.9 and an external library for 3D objects - Rajawali. I have encountered and issue - when my camera is pointing straight at image target everything is all right but when I move the device the object also moves a bit - it is not staying in the centre off image.

I've read that it could be related to different viewports or camera FOV but I'm not really aware what exactly it could be.

The code mainly comes from the external library but something could be outdated:

getCurrentCamera().setProjectionMatrix(getFOV(), getVid(), getVideoHeight());

 



getFOV(JNIEnv *env, jobject object) {

    const Vuforia::CameraCalibration& cameraCalibration =  Vuforia::CameraDevice::getInstance().getCameraCalibration();

    Vuforia::Vec2F size = cameraCalibration.getSize();

    Vuforia::Vec2F focalLength = cameraCalibration.getFocalLength();

    float fovRadians = 2 * atan(0.5f * size.data[1] / focalLength.data[1]);

    float fovDegrees = fovRadians * 180.0f / M_PI;

    return fovDegrees;

}

 

Vuforia::VideoBackgroundConfig config;

config.mEnabled = true;

config.mPosition.data[0] = 0.0f;

config.mPosition.data[1] = 0.0f;

if (isActivityInPortraitMode) {

  config.mSize.data[0] = videoMode.mHeight

    * (screenHeight / (float) videoMode.mWidth);

  config.mSize.data[1] = screenHeight;

  if (config.mSize.data[0] < screenWidth) {

   config.mSize.data[0] = screenWidth;

   config.mSize.data[1] = screenWidth

     * (videoMode.mWidth / (float) videoMode.mHeight);

  }

} else {

  config.mSize.data[0] = screenWidth;

  config.mSize.data[1] = videoMode.mHeight

    * (screenWidth / (float) videoMode.mWidth);

  if (config.mSize.data[1] < screenHeight) {

   config.mSize.data[0] = screenHeight

     * (videoMode.mWidth / (float) videoMode.mHeight);

   config.mSize.data[1] = screenHeight;

  }

}

videoWidth = config.mSize.data[0];

videoHeight = config.mSize.data[1];

Vuforia::Renderer::getInstance().setVideoBackgroundConfig(config);

 

 

Sorry for the format, I can't get the highlighter working.

Log in or register to post comments