List
Projecting from 3d coordinates to screen coordinates.
Posted Date: 2019-07-01 21:13     Edited Date: 2019-07-09 8:54     Writer: inactive

What I am attempting to do is place a TextView at certain coordinates with respect to each of my pins/anchors. However, whenever I place one of these TextViews, the View jitters around the screen, and is not in the correct place.

I have tried to get these coordinates in two ways:

1. Uisng gluProject method in Android

I used the folllowing call in Android (1,1,0 is the position of my TextView with respect to the pins/anchors).

GLU.gluProject(1,1,0,modelViewMatrix,0,projectionMatrix,0,view,0, win,0);

where modelViewMatrix=transform*translate*rotate*scale, and projectionMatrix is the same one used in the sample app.

However, this did not produce the desired effects. I read in another forum post (https://developer.maxst.com/BoardQuestions/Details/226) that the projectionMatrix in AR is actually the view matrix multiplied by the projection matrix, which could explain my problem. How do I get the modelView matrix and the projection matrix, instead of the model matrix, and the projectionView matrix.

2. Directly projecting. 

float[] win=new float[3];
int[] view={0,0,surfaceWidth,surfaceHeight};
float[] point={1f,1f,0f,1f};
float[] norm=new float[4];
Matrix.multiplyMV(norm,0,localMvpMatrix,0,point,0);
for(int i=0;i<4;i++){
    norm[i]=norm[i]/norm[3];
    Log.i("My own projection", ""+i+" : "+norm[i]);
    if(i<=1 && norm[i]>=-1 && norm[i]<=1){
        win[i]=view[i+2]*(norm[i]+1)/2;
    }
}

In this method, I try to directly use the projection formula in order to project. However, I still didn't get the right answer. localMvpMatrix is defined the same as it is in the sample application. 

I would appreciate any assistance in this matter. 

Auxiliary information:

1. SDK Version: 4.1.2
2. Development Environment:  Native Android
3. Tracker/Scanner: Object Tracker
4. License Type: Pro-One Time Fee (working with the sample app right now, though).


 

Posted Date: 2019-07-05 0:39     Edited Date: 2019-07-05 0:39     Writer: inactive

Hello rishabh.krishnan.

Is the ultimate goal you want to reduce jitter? If that's true, use the jitter reduction option.

 

Leo

Maxst Support Team

Posted Date: 2019-07-05 15:57     Edited Date: 2019-07-05 15:57     Writer: inactive

Hi Leo,

Thanks for your reply. Unfortunately, the jitter was only one of the problems. If I want to get the screen coordinates of a pin point, the projection algorithm is just giving me the wrong point. I know that TrackerManager has a method which gets the world coordinates from the screen coordinate, and I was wondering if there was an inverse method.

Additionally, if I did want to reduce the jitter, where would I enable the jitter reduction option? I should note that I don't see any jitter when I'm using the sample app on my own models; I only see it when I try to put a TextView at a certain coordinate.

 

Posted Date: 2019-07-09 8:54     Edited Date: 2019-07-09 8:54     Writer: inactive

Hi rishabh.krishnan,

The Matrix formula you gave me seems to be fine.

 

First of all, there are things you have to check.

1. Make sure you put the matrix of the model properly in the formula you use.

2. The distance of 1 meter is a fairly large distance, and you may not see the location where you want to place the content off the screen.

3. What tracker are you using? Image? Object?

 

Leo

Maxst Support Team