I modify sample HelloAR project. Add the following source code to function OnDrawFrame()
public void onDrawFrame(GL10 gl) {
...
Camera camera = frame.getCamera();
//test code
if(show) {
show = false;
Pose p = camera.getPose(); //Get camera pose
Pose locpose = Pose.makeTranslation(0.0f, 0.0f, -2.0f);//define a translation
targetpose = p.compose(locpose); //make a new pose based on camera pose
④anchors.add(session.createAnchor(targetpose)); //add a new anchor
}
// Handle taps. Handling only one tap per frame, as taps are usually low frequency
// compared to frame rate.
...
}
There is an exception occur when ④ is executed, i think that pose is not correct. My target is as below, Create a new anchor, about anchor's postion, i hope that it is screen center in point of view of phone and the distance between camera and anchor is 2 meter in point of 3D world.
How to define that pose?
I found the root cause: Test code is executed too earlier, when some pointcloud is create, then execute test code, a new anchor is created. i will close the issue