Arcore-android-sdk: Transform 3D anchor/pose to corresponding 2D screen coordinates

Created on 28 Feb 2018  路  3Comments  路  Source: google-ar/arcore-android-sdk

I'm struggling to get this transformation. given an anchor Pose in arcore how can I obtain the corresponding 2D coordinates in the screen of the same. I'm trying to reuse the following OpenGL code:

 Vector2 Convert(Vector3 pos, const Matrix& viewMatrix, const Matrix& projectionMatrix, int screenWidth, int screenHeight)
{
    pos = Vector3::Transform(pos, viewMatrix);
    pos = Vector3::Transform(pos, projectionMatrix);

    pos.X = screenWidth*(pos.X + 1.0)/2.0;
    pos.Y = screenHeight * (1.0 - ((pos.Y + 1.0) / 2.0));

    return Vector2(pos.X, pos.Y);
}

But I don't know how to transform a Pose (Anchor) object to a point in 3D let's say a Vector3.

Please, let me know if If there's a straightforward way to do it using arcore (without using opengl).

question

Most helpful comment

Thank you very much for the response. I was interested on how to convert from arcore 3D pose to screen coordinates. Finally I managed to solve the problem my self. I answered my question on SO with the details:

https://stackoverflow.com/questions/49026297/transform-3d-anchor-pose-to-corresponding-2d-screen-coordinates/49066308#49066308

All 3 comments

It looks like you're using C++ based on the :: operator, so I assume you're using the C API.

the world-space location of a Pose can be retrieved using ArPose_getPoseRaw and taking elements 4-6 of the output array.

Thank you very much for the response. I was interested on how to convert from arcore 3D pose to screen coordinates. Finally I managed to solve the problem my self. I answered my question on SO with the details:

https://stackoverflow.com/questions/49026297/transform-3d-anchor-pose-to-corresponding-2d-screen-coordinates/49066308#49066308

Closing as seems to be resolved.

Was this page helpful?
0 / 5 - 0 ratings