question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to dynamically know which image target found ?

See original GitHub issue

Environment

Please provide the following information about your environment:

  1. Development OS: Mac Android Note 9 – OS 8.1
  2. Version: ViroReact 2.12.0 and React Native 0.56.0

Description

When I register multiple ViroARImageMarker using loop, it recognize all the images but only trigger the last one on onAnchorFound.

here is how I’m doing. this._onAnchorFoundForVideoTarget = this._onAnchorFoundForVideoTarget.bind(this);

  ViroARTrackingTargets.createTargets({
    videoTarget_0 : {
      source :  { uri: videosData[0].ImageUrl } ,
      orientation : "Up",
      physicalWidth : 5 // real world width in meters
    },
    videoTarget_1 : {
      source :  { uri: videosData[1].ImageUrl } ,
      orientation : "Up",
      physicalWidth : 5 // real world width in meters
    },
    videoTarget_2 : {
      source :  { uri: videosData[2].ImageUrl } ,
      orientation : "Up",
      physicalWidth : 5 // real world width in meters
    },
  });

let views = [];
  let i = 0;
   console.log('_loadAllVideoMarkers',apiVideosData)
  if(apiVideosData){
    for (i = 0; i < apiVideosData.length; i++){

      views.push((
        <ViroARImageMarker
          key={`videoTarget_${i}`}
          target={`videoTarget_${i}`}
          onAnchorFound={(e) =>  this._onAnchorFoundForVideoTarget(e, i)}
          pauseUpdates={this.state.pauseUpdates}>
        </ViroARImageMarker>
      ));
    }
  }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
faisal3413commented, Mar 18, 2019

Hi @dthian ,

Thanks for your answer. Yes, onAnchorFound returns an object containing anchorId, but I cannot use it to found which image triggered? So, for now I added extra ‘target’ parameter in _onAnchorFound in ViroARImageMarker.js class like below.

If you add the found target name in response of the onAnchorFound callback it will be really helpful.

Thanks

image

Now I can use it like

  <ViroARImageMarker
          key={`videoTarget_${i}`}
          target={this.videoTargetImages[i]}        
          onAnchorFound={ (e, targetName) => this._onAnchorFoundForVideoTarget(e,targetName)}
          pauseUpdates={this.state.pauseUpdates}>

          // rest of code

  </ViroARImageMarker>
1reaction
dthiancommented, Mar 18, 2019

From https://docs.viromedia.com/docs/viroarimagemarker it looks like onAnchorFound already provides you the anchor that was found and from it the id of the anchor. Thus you should already be able to dynamically know which anchor is found?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to dynamically change image target image
In order to create Image Targets, you can use the Target Manager or use Insta Image Targets (which creates Image Targets at Run-time)....
Read more >
Dynamic load of Image Target in Vuforia is possible
However as far as I know, all custom Image Targets have to be loaded through the 'My Trackables' part of the site then...
Read more >
Setting up Image Targets - Unity - Manual
This section shows you how to set up a simple Image Target and get it responding to basic tracking events. To allow your...
Read more >
About dynamic search ads - Microsoft Advertising Help Center
Dynamic search ads automatically target relevant search queries based on ... See What you need to know about dynamic ad targets below for...
Read more >
Vuforia Engine: How to Create Image Targets - YouTube
In this Vuforia Engine augmented reality tutorial you'll learn how to create Image Targets using both the method through the developer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found