viromedia / virocore

ViroCore cross-platform AR/VR renderer
MIT License
370 stars 108 forks source link

Unable to detect the same image for multiple times #236

Open anthonyliu32 opened 5 years ago

anthonyliu32 commented 5 years ago

Environment

Please provide the following information about your environment:

  1. OS: Mac
  2. Version: ViroCore version 1.9
  3. Device(s): Pixel 2, Sony XZ2, Samsung S9+

Description

We use ViroCore 1.9 to do image detection and display node (3D object) in the ARScene. We have also implemented a method with a button to refresh the ViroView / ARScene by removing the node displayed like the method below: private void reinitViroCore() { if (mNode != null) { mNode.removeFromParentNode(); } mImageTargetFound = false; mNode = null; }

In our testing, camera can detect the image and render 3D model upon the ViroView starts in an activity. However, after removing the node from the ViroView / ARScene, the camera cannot detect the same image again. No events are received in onAnchorFound() callback.

So are there any recommended ways to restart the AR tracking without restarting the whole activity?

manbod commented 5 years ago

Hi @anthonyliu32 , Thanks for reaching out. You are right. We call this out in our documentation as a note here that

for each ARImageTarget added to the scene, there will be only one instance of that target found.

So in order for the scene to detect the image again and re-trigger onAnchorFound(...) callback, you'll need to remove the ARImageTarget that you added to the scene and the add it back. So your reinitViroCore() should look something like below:

private void reinitViroCore() { 
    ... your other business logic ...
    mScene.removeARImageTarget(mImageTarget);
    mImageTargetFound = false;
    mScene.addARImageTarget(mImageTarget);
}

That should trigger onAnchorFound() again when the scene finds that target again.

Hope that helps. Let us know if you have more questions :)

anthonyliu32 commented 5 years ago

Hi @manbod, we have multiple image targets for image recognition that will be passed to ViroViewARCore (e.g. image1.jpg, image2.jpg, image3.jpg). We have also adopted the method you mentioned. However, it seems like after removing and adding the detected image target (e.g. image1.jpg), the camera view cannot detect other image targets in the scene (e.g. image2.jpg, image3.jpg). Is it a normal behavior?

achuvm commented 5 years ago

Hi @anthonyliu32,

This does look like a bug within our platform and we'll fix it in a future release. In the meantime, we'd suggest not removing image1.jpg if possible and simply ignoring updates for it.

Thanks for reporting this issue!

anthonyliu32 commented 5 years ago

Hi @achuvm, so we implemented the workaround with re-adding the image targets (e.g. image1.jpg, image2.jpg, image3.jpg) and without removing the original detected image target (e.g. image1.jpg) as below. Could you advise if there are any risks for this workaround? (e.g. will re-adding image targets overflow the pool of image target as ARCore/ViroCore can only track up to 20 images simultaneously in the environment)

private void reinitViroCore() { 
    //Remove the node displayed in scene
    if (mNode != null) {
            mNode.removeFromParentNode();
    }
     //Try to re-add the Image Targets
        if (anchorIdForNode != null) {
            for (Map.Entry<String, ARImageTarget> entry : ImageTargetList.entrySet()) {
                mScene.addARImageTarget(entry.getValue());
            }
    }
    mImageTargetFound = false;
}

And for this issue, what is the target date / release that the fix will be ready?

achuvm commented 5 years ago

Hi @anthonyliu32,

According to the ARCore documentation, the underlying AugmentedImageDatabase supports up to 1000 images: https://developers.google.com/ar/reference/java/arcore/reference/com/google/ar/core/AugmentedImageDatabase

As for performance, here's a comment by the ARCore team regarding runtime performance: https://github.com/google-ar/arcore-android-sdk/issues/372#issuecomment-445402737

Our next release containing this fix will be sometime in January. We'll leave this issue open and update it when we have the fix live.

Thanks,

DuplexDodge commented 5 years ago

Is this fix live yet? I didn't see anything about it in the release notes. Just wanted to double check if it was added or not. Thanks

achuvm commented 5 years ago

Hi @DuplexDodge, yes we fixed the issue where removing images prevented other images from being found. We have not implemented the feature to allow detecting the same image being found multiple times.

Thanks,

Satish2804 commented 5 years ago

Is this issue fixed?

marvinernst-cognitio commented 4 years ago

Are there any news about this?