I am developing an Android application based on ArCore (NDK) to augment certain objects (generated from blender tool) over real camera feed. Now that I am able to draw objects as anchors which scales up/down upon camera position changes.
I am using ArSession_acquireNewAnchor API to host an anchor about few inches away from the camera like below.
ArPose_create(ar_session_, nullptr, &camera_pose);
ArPose_getPoseRaw(ar_session_, camera_pose, raw_camera_pose);
ArAnchor *anchor = nullptr;
if (ArSession_acquireNewAnchor(ar_session_, raw_camera_pose, &anchor)!=AR_SUCCESS) {
LOGE("Anchor is not successfully acquired");
}
After launching the application and holding the device at the same direction, the above anchor is seen.
When the camera location/direction changes, those anchors are not appearing as expected. Please help - PFB the pictorial representation of the problem.
As I am acquiring the anchor based on camera pose, I assume that direction and pose attributes of anchor will be based on camera pose only i.e. when the camera moves (translation), the anchor too moves accordingly - Is my understanding correct?
ArSession_acquireNewAnchor(ar_session_, raw_camera_pose, &anchor)
Upon using hitResult based anchor acquisition, everything works fine i.e. anchor object appears when the devices changes from one direction to other direction at the appropriate location (touch co-ordinates) - However my use-case does not depend on touch input events. I need to achieve the same effect at the pre-defined location co-ordinates of a given scene.
if(ArHitResult_acquireNewAnchor(ar_session_, ar_hit_result, &anchor)!= AR_SUCCESS) { LOGE("NOT SUCCESSFUL"); return; }
Kindly note that this is being developed using ArCore NDK.
I am able to achieve this by adjusting the pose value of anchor object.
Camera raw pose is made of 7 parameters like below.
raw_pose = {0, 0, 0, 1.0, driftx, 0,-5.0};
API for anchor acquisition-
ArSession_acquireNewAnchor(ar_session_, raw_pose, &anchor);
Here, the 7th index-value places an anchor 5 units away from camera. And the 5th index-value(driftx) instructs ArCore to make necessary (driftx units) transformation in x for the given anchor. The attribute driftx is made to track the drift in camera pose (only the 5th index-value of camera pose) when the device turns from one side to other side.
The method by which driftx calculated is not yielding an accurate solution but close to what is expected is met. Further investigation is in progress in improving the driftx accuracy.