By pedro
on Wed, 06/20/2012 - 17:06
Hello,
I'm having a problem that I have no idea how to solve.
When a trackable is detected it is suppose o open a android list view with some option on top of it. I've been able to send to android the name of the trackable and it's coordinates. The problem is that the coordinates don't match the screen coordinates.
Here is the code I have so far on the ImageTargets.cpp:
[CODE]
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv * env, jobject obj)
{
//LOG("Java_com_qualcomm_QCARSamples_ImageTargets_GLRenderer_renderFrame");
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render video background:
QCAR::State state = QCAR::Renderer::getInstance().begin();
const QCAR::Tracker& tracker = QCAR::Tracker::getInstance();
const QCAR::CameraCalibration& cameraCalibration = tracker.getCameraCalibration();
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
// Compare this trackable's id to a globally stored id
// If this is a new trackable, find the displayMessage java method and
// call it with the trackable's name
QCAR::Vec2F cameraPoint = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F(0, 0, 0));
QCAR::VideoMode videoMode = QCAR::CameraDevice::getInstance().getVideoMode(QCAR::CameraDevice::MODE_DEFAULT);
QCAR::VideoBackgroundConfig config = QCAR::Renderer::getInstance().getVideoBackgroundConfig();
int xOffset = ((int) screenWidth - config.mSize.data[0]) / 2.0f + config.mPosition.data[0];
int yOffset = ((int) screenHeight - config.mSize.data[1]) / 2.0f - config.mPosition.data[1];
QCAR::Vec2F screenPoint = QCAR::Vec2F(cameraPoint.data[0] * config.mSize.data[0] / (float) videoMode.mWidth + xOffset,
cameraPoint.data[1] * config.mSize.data[1] / (float) videoMode.mHeight + yOffset);
char mystring[128];
sprintf(mystring, "track: %s x: %f y: %f", trackable->getName(), screenPoint.data[0], screenPoint.data[1]);
jstring js = env->NewStringUTF(mystring);
jclass javaClass = env->GetObjectClass(obj);
jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");
env->CallVoidMethod(obj, method, js);
}
QCAR::Renderer::getInstance().end();
}
[/CODE]
I got the coordinates code from another post.
Could someone help me please? I'm really in a jam.
Thanks
Re: Context Android options
Re: Context Android options