Viro: ViroARImageMarker: onAnchorRemoved never fires

Created on 28 May 2018  路  15Comments  路  Source: viromedia/viro

in a simple example like the following, onAnchorRemoved never gets called when i move the camera away from the anchor. likewise, onAnchorFound only get's called the first time the anchor is found.

working around this with onHover is not a good solution as it still fires with isHovering == true if i hover of the spot the anchor initially was at, even if the anchor isn't visible anymore.

think of turning a page in a brochure. if i scan a ViroARTrackingTarget on page 1 and then turn the page, my wrapped component (ViroVideo is my example) would still be visible if i hover over the spot the anchor was at before.

      <ViroARScene>
        <ViroARImageMarker
          target={'targetOne'}
          onAnchorFound={this.onAnchorFound}
          onAnchorRemoved={this.onAnchorRemoved}
          >
          <ViroVideo
              source={require('./res/test.mp4')}
              height={0.06}
              width={0.08}
              rotation={[270,0,0]}
           />
        </ViroARImageMarker>
      </ViroARScene>

Most helpful comment

@Tamiyadd do you have found a solution about that? I'm trying to remove a content when ViroArImageMarker doesn't track a target but there is no callback to use...
I have to load a content when ViroArImageMarker detect a marker and remove when it's not longer in the scene.

A solution would be to set an interval that remove all objects when timeout and resetting when onAnchorUpdate is called but if the user does not move the camera and the ancor does not move, onAnchorUpdate never called. The result is that the medias will be removed though the target is on the scene...

Thanks

All 15 comments

i'm having the same issue, if you find a solution can you share it?

I have a carousel of images that trigger ViroARImageMarker but when i change image the old wrapper component is still there and visible

Hi all,

This is currently how the Image Detection (ARKit)/Augmented Image (ARCore) features currently work.

Since we wrap these API's for the ViroARImageMarker API, we currently don't support this feature. However, this is something that we are aware of.

In the meantime, if you do remove the ViroARImageMarker or change the target, then you will get an onAnchorRemoved callback. With this, you can work around the issue with "removing" the old ViroARImageMarker when a new one is found and/or providing controls so your users can let you know when they are done with an image.

Thanks,

@achuvm i'm trying to adopt your suggestions but it seems that when you remove then read a ViroArImageMarker the callback onAnchorFound is fired even if you are pointing away the camera

@Tamiyadd do you have found a solution about that? I'm trying to remove a content when ViroArImageMarker doesn't track a target but there is no callback to use...
I have to load a content when ViroArImageMarker detect a marker and remove when it's not longer in the scene.

A solution would be to set an interval that remove all objects when timeout and resetting when onAnchorUpdate is called but if the user does not move the camera and the ancor does not move, onAnchorUpdate never called. The result is that the medias will be removed though the target is on the scene...

Thanks

Hey guys! Did you find any solutions to this? Does ARKit 2.0 has solution for this? @achuvm

Seems like ARKit 2.0 fixes with problem.
https://stackoverflow.com/questions/49997025/check-whether-the-arreferenceimage-is-no-longer-visible-in-the-cameras-view

Waiting for a new release with ARKit 2.0 !

@marconett did you find a solution? I'm also having the same problem as you described. But I can't work out how you solved the issue with your workaround either :/

Thanks

i ended up not using viro

What did you use instead?

Me and my teammates had a similar problem. We created multiple targets and we needed the anchor to be removed when camera finds a new anchor. However onAnchorRemoved did not work, we tried couple different ways to deal with this, but either anchors were not getting removed or coming back to the target that we've found previously would not anchor second time, so we found a way around it:
onAnchorFound={
(e) => {
if (this.state.anchorId !== e.anchorId) {
this._reactInternalFiber.pendingProps.arSceneNavigator.resetARSession(true, true)
//if the anchor we find is different from the previous anchor we're resetting the ARSession (which luckily doesn't reset the whole thing, which means we don't have to make a new call to the database every time)
}
this.setState({
soundUrl: imageTarget.soundUrl,
runAnimation: true,
initialized: true,
isTracking: true,
anchorId: e.anchorId, // and here we're setting the anchorId on state to the newly found anchor
audioPaused: true,
visibleText: true
})
}}

It's a temporary solution until onAnchorRemoved becomes functional, but it's working.

Can you please give reference of other library

i ended up not using viro

I used vuforia / unity without react native

Thanks for quick reply, I want something that can be used in react native

@NGabuaeva Thanks for the solution but it's not working in my case do we need to pass something from parent component. im using class component which hold multiple Thanks in advance..!

@Arjunmore6673 can you elaborate on what you are trying to do/what your Markers are doing?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

funkyfourier picture funkyfourier  路  3Comments

starantino picture starantino  路  6Comments

WillGeller picture WillGeller  路  3Comments

ascorbic picture ascorbic  路  4Comments

SathishSaminathan picture SathishSaminathan  路  4Comments