Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function augmentedImage.createAnchor() returns null when augmentmentedImage is used? #18

Open
Leye-96 opened this issue Jul 11, 2023 · 2 comments

Comments

@Leye-96
Copy link

Leye-96 commented Jul 11, 2023

我想在识别的图片上放置物体,但是使用augmentedImage的时候,augmentedImage.createAnchor 返回是null,arcamera也获取不到arpose,请问这是什么问题,或者有别的方法实现吗?

-------------------------------------------------------------------English----------------------------------------------------------------

I try to place an 3D object on an augmentedImage. Howerver, when I used augmentedImage.createAnchor(), the returned value is null and also I can't get ARPose of ARCamra. How can I solve it? Appreciate if u have any idea.

@peura-toni
Copy link

Hi,

You can use the image_default.png image in the demo for AugmentedImage. This way you can see the arpose of the arcamera and the anchor.

Note: Make sure the device you are using supports AR Engine. You can access devices that support AR Engine from the link.

image_default.png

image_default

using AugmentedImage on Huawei P40

image

ImageRendererManager.java class

private void initTrackingImages(ARAugmentedImage augmentedImage) {
        // Create an anchor for the newly found image and bind it to the image object.
        if (!augmentedImageMap.containsKey(augmentedImage.getIndex())) {
            ARAnchor centerPoseAnchor = null;
            if (!mIsImageTrackOnly) {
                centerPoseAnchor = augmentedImage.createAnchor(augmentedImage.getCenterPose());
            }
            augmentedImageMap.put(augmentedImage.getIndex(), Pair.create(augmentedImage, centerPoseAnchor));
        }
    }

AugmentedImageActivity.java class

try {
                mArSession = new ARSession(this.getApplicationContext());
                mArConfigBase = new ARImageTrackingConfig(mArSession);
                mArConfigBase.setFocusMode(ARConfigBase.FocusMode.AUTO_FOCUS);
                if (!setupInitAugmentedImageDatabase(mArConfigBase, "Tech Park")) {
                    LogUtil.error(TAG, "Could not setup augmented image database");
                }
                mArSession.configure(mArConfigBase);

                // Use setImageTrackOnly(false) here if you use ARWorldTrackingConfig to configure sessions.
                mArFeatureRendererManager.isImageTrackOnly(true);
            } catch (Exception capturedException) {
                setMessageWhenError(capturedException);
            }

@Leye-96
Copy link
Author

Leye-96 commented Jul 13, 2023

Thx for your reply. I have read this from the demo. However, the code below does not work. Funtion augmentedImage.createAnchor() returns null and variable 'centerPoseAnchor' is never used.


if (!mIsImageTrackOnly) {
                centerPoseAnchor = augmentedImage.createAnchor(augmentedImage.getCenterPose());
            }

The AugmentedImage is drawn through Function 'augmentedImage.getCenterPose()' instead of an anchor. It is a displayed as an 2D Image in a camera view instead of a 3D object. To draw a 3D object, I need to get the ARPose of the AugmentedImage or ARCamera. It seems the author of the demo tried to do the same thing but the author gave up because he assigned the matrix 'cameraview' a value instead of retrieving it through ARCamera.

Up to now, I can't find a way to get world coordinates of ARCamera or the trackble AugmentedImage. Thx again.

@Leye-96 Leye-96 changed the title 使用augmentedImage的时候,为什么获取不到arcamera的arpose,或者获取到anchor? Function augmentedImage.createAnchor() returns null when augmentmentedImage is used? Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants