"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Placing UIView over image target - minor misalignment

Hi, I am working on placing an UIView over the image target. Starting from the ImageTarget example and timlai's class (http://pastebin.com/kmeVZ7jy) I use the following code in the render() method to create a CATransform3D structure from the pose matrix that later I can assign to the CALayer of UIView:

[code=c]

    const QCAR::ImageTarget* imageTarget = (const QCAR::ImageTarget*)trackable;    QCAR::Vec2F size = imageTarget->getSize();

    QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(imageTarget->getPose());    CGFloat ScreenScale = [[UIScreen mainScreen] scale];    float xscl = qUtils.viewport.sizeX/ScreenScale/2;    float yscl = qUtils.viewport.sizeY/ScreenScale/2;    QCAR::Matrix44F projectedTransform = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};    QCAR::Matrix44F qcarTransform = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};    ShaderUtils::translatePoseMatrix(size.data[0] / 2, size.data[1] / 2, 0, projectedTransform.data);    ShaderUtils::scalePoseMatrix(xscl, -yscl, 1.0, projectedTransform.data); // flip along y axis    ShaderUtils::multiplyMatrix(projectedTransform.data, qUtils.projectionMatrix.data, qcarTransform.data);    ShaderUtils::multiplyMatrix(qcarTransform.data, modelViewMatrix.data, qcarTransform.data);    CATransform3D transform = *((CATransform3D*)qcarTransform.data); // both are array[16] of float    // UIView* myView = ...    myView.frame = CGRectMake(0, 0, size.data[0], size.data[1]);    myView.layer.transform = transform;

[/code]

Now this code works almost as I expect, the view is positioned more or less over the image target. But unfortunately the position is inaccurate: if I walk around the image target the UVIew moves around the center of the target in a small circle with a radius of approxiamtely 5-10% of the width of the target and the view. The view seems to be placed somewhat closer to the camera then it should be, however I am unsure whether it is a misalignment in the z coordinate or an error in the transformation matrix calculation. Any hint on what could cause this error?

Hi mrtj,

Have you tried a range of different Image Targets?

Also, can I just check the dimensions and whether you set these in mm on the TMS?

Finally, if you place another augmentation (just in OpenGL) does this rotate as well, or is it just the UIView?

cheers,

N

Hi Nalin,

thanks for your reply. I use the image targets for the example (stones & chips) and my view is misaligned over both in the same way. I initialize it with the same dimensions as of the image target, currently hard coded: