Log in or register to post comments

Locate the center of a Marker

August 2, 2011 - 12:34pm #1

I know how to find a Marker. What I don't understand is how to obtain its location within the overall image, find the Marker's center, and then use my own (Cocoa-based) drawing code to write text into the Marker.

Any pointers would be much appreciated!

Re: Locate the center of a Marker

August 3, 2011 - 7:13am #3

You can use the projectPoint function to locate the target center in screen coordinates..

QCAR::Vec2F screenPoint = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F(0, 0, 0));

[ that should read :: projectPoint ] not :P

If you do a search on the forum, you'll find a few threads that deal with drawing and rendering onto the marker. Basically you use the same sequence of transforms that are shown in the samples - i.e. deriving a modelviewprojection.

Re: Locate the center of a Marker

August 2, 2011 - 1:58pm #2

In EAGLView.m you can find this matrix:
modelViewMatrix.data [ 4x4 matrix 16 float values ]

So if you project 0,0,0,1 on that you will get the center. So basically modelViewMatrix.data[12],modelViewMatrix.data[13],modelViewMatrix.data[14] is your center. You will need to project it on projectionMatrix.data[0] and you should get the value on screen.

You should be able to use modelViewProjection matrix as well after following call.
ShaderUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]);

Log in or register to post comments