Log in or register to post comments

Image Targets in run time

December 22, 2019 - 1:56pm #9

Hi,

I tried to set the image targets at runtime based on:

https://library.vuforia.com/content/vuforia-library/en/articles/Solution/how-to-create-and-load-targets-in-unity.html

And part : "The code example below will allow you to download a texture image from a web URL and generate an image target from it."

But I have the RuntimeImageSource error in this line:

"var runtimeImageSource = objectTracker.RuntimeImageSource;"

 

my error is :

'ObjectTracker' does not contain a definition for 'RuntimeImageSource' and no accessible extension method 'RuntimeImageSource' accepting a first argument of type 'ObjectTracker' could be found (are you missing a using directive or an assembly reference?)

 

My code is attached

My Vuforia version is 8.3.8

 

Thanks

 

AttachmentSize
Plain text icon error.txt1.7 KB

Image Targets in run time

December 23, 2019 - 6:41am #8

I think this feature is only available in the latest Vuforia, 8.6.7+

 

 

Image Targets in run time

December 24, 2019 - 4:33am #7

Hi,

I'm Beginner

I'm sorry for my English.

my last bug fixed with Vuforia 8.6.7

but my app don't work! 



My steps :

 

1- Create AR Camera in Scene and add app License key (imag1 in attach)

2- Create ImageTarget in Scene (image2 in attach)

3- Create Child (Quad) for ImageTarget (image3 in attach)

3.1-Add Material from Resources to Quad (image3.1 in attach)

4- Create C# Script in Asset and write code (image4 in attach)

4.1-my code is attached

5- add my script to ImageTarget (image5 in attach)

6-build and run

 

 

Thanks

 

 

AttachmentSize
Image icon image1.JPG11.94 KB
Image icon image2.JPG11.62 KB
Image icon image3.JPG12.57 KB
Image icon image3.1.JPG42 KB
Image icon image4.JPG19.63 KB
Image icon image5.JPG58.13 KB
Plain text icon mycode.txt1.87 KB

Image Targets in run time

December 26, 2019 - 12:21am #6

Peyman97 wrote:

Hi,

I'm Beginner

I'm sorry for my English.

my last bug fixed with Vuforia 8.6.7

but my app don't work! 



My steps :

 

1- Create AR Camera in Scene and add app License key (imag1 in attach)

2- Create ImageTarget in Scene (image2 in attach)

3- Create Child (Quad) for ImageTarget (image3 in attach)

3.1-Add Material from Resources to Quad (image3.1 in attach)

4- Create C# Script in Asset and write code (image4 in attach)

4.1-my code is attached

5- add my script to ImageTarget (image5 in attach)

6-build and run

 

 

Thanks

 

 

 

Please Help Me

Image Targets in run time

December 29, 2019 - 9:47am #5

Peyman97 wrote:

Peyman97 wrote:

Hi,

I'm Beginner

I'm sorry for my English.

my last bug fixed with Vuforia 8.6.7

but my app don't work! 



My steps :

 

1- Create AR Camera in Scene and add app License key (imag1 in attach)

2- Create ImageTarget in Scene (image2 in attach)

3- Create Child (Quad) for ImageTarget (image3 in attach)

3.1-Add Material from Resources to Quad (image3.1 in attach)

4- Create C# Script in Asset and write code (image4 in attach)

4.1-my code is attached

5- add my script to ImageTarget (image5 in attach)

6-build and run

 

 

Thanks

 

 

 

Please Help Me

 

No one to help me?

Image Targets in run time

January 3, 2020 - 6:49am #4

Hi Peyman,

 

I have the same issue but only on an Android device. I load the image direct from storage not by a web request. I think the feature isn't done so far. Maybe it will fixed in the next version.



At the moment I can't help. I will try something more. If I have a solution (or you have already) I will tell you, okay?



[EDIT]



Seconds later after a very small change also the Android versiomn works for me.



This is the code:

// This method is callled after a button was clicked

public void StartTracking()

{

   VuforiaARController.Instance.RegisterVuforiaStartedCallback(CreateImageTargetProjections);

}




private void CreateImageTargetProjections()

{

   var objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>(); // ObjectTracker with capital 'O' not like the doumentation with lower 'o'

   var dataset = objectTracker.CreateDataSet();

   foreach (var imageTarget in imageTargetFiles) // I have a list of image targets

   {

      imageTarget.Load(); // My special object which loads an image into a Texture2D

      var runtimeImageSource = objectTracker.RuntimeImageSource;

      var imageTargetTexture = imageTarget.AsTexture(); // This was my little change

      var imageSourceIsLoaded = runtimeImageSource.SetImage(

         imageTargetTexture,

         imageTarget.Dimensions.WidthInMeters, // My special object mesures its own dimensions :)

         imageTarget.Name);

      if (imageSourceIsLoaded){

         var trackableBehaviour = dataset.CreateTrackable(runtimeImageSource, imageTarget.Name);

 

         /// Here I have some code to put an object as child to the image target

         projection.transform.parent = trackableBehaviour.transform;

         projection.transform.rotation = Quaternion.Euler(90, 0, 0); // By default my assigned object have to rotat to spawn it correctly but ist only for me

      }

   }

   objectTracker.ActivateDataSet(dataset);

}

Best Regards

jf^

Image Targets in run time

January 5, 2020 - 11:56pm #3

DevInclusify wrote:

Hi Peyman,

 

I have the same issue but only on an Android device. I load the image direct from storage not by a web request. I think the feature isn't done so far. Maybe it will fixed in the next version.



At the moment I can't help. I will try something more. If I have a solution (or you have already) I will tell you, okay?



[EDIT]



Seconds later after a very small change also the Android versiomn works for me.



This is the code:

// This method is callled after a button was clicked

public void StartTracking()

{

   VuforiaARController.Instance.RegisterVuforiaStartedCallback(CreateImageTargetProjections);

}




private void CreateImageTargetProjections()

{

   var objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>(); // ObjectTracker with capital 'O' not like the doumentation with lower 'o'

   var dataset = objectTracker.CreateDataSet();

   foreach (var imageTarget in imageTargetFiles) // I have a list of image targets

   {

      imageTarget.Load(); // My special object which loads an image into a Texture2D

      var runtimeImageSource = objectTracker.RuntimeImageSource;

      var imageTargetTexture = imageTarget.AsTexture(); // This was my little change

      var imageSourceIsLoaded = runtimeImageSource.SetImage(

         imageTargetTexture,

         imageTarget.Dimensions.WidthInMeters, // My special object mesures its own dimensions :)

         imageTarget.Name);

      if (imageSourceIsLoaded){

         var trackableBehaviour = dataset.CreateTrackable(runtimeImageSource, imageTarget.Name);

 

         /// Here I have some code to put an object as child to the image target

         projection.transform.parent = trackableBehaviour.transform;

         projection.transform.rotation = Quaternion.Euler(90, 0, 0); // By default my assigned object have to rotat to spawn it correctly but ist only for me

      }

   }

   objectTracker.ActivateDataSet(dataset);

}

Best Regards

jf^

Thank you so much 

But I have to solve this issue in unity

Image Targets in run time

January 9, 2020 - 5:49am #2

Hi @Peyman,

In the provided code txt, you have at the end of the code:

// TODO: add virtual content as child object(s)

This seems to be missing from the implementation. Have you tried @DevInclusify example code? he adds his approach for adding child objects.

Thank you.

Vuforia Engine Support

Image Targets in run time

January 15, 2020 - 3:01am #1

DevInclusify wrote:

Hi Peyman,

 

I have the same issue but only on an Android device. I load the image direct from storage not by a web request. I think the feature isn't done so far. Maybe it will fixed in the next version.



At the moment I can't help. I will try something more. If I have a solution (or you have already) I will tell you, okay?



[EDIT]



Seconds later after a very small change also the Android versiomn works for me.



This is the code:

// This method is callled after a button was clicked

public void StartTracking()

{

   VuforiaARController.Instance.RegisterVuforiaStartedCallback(CreateImageTargetProjections);

}




private void CreateImageTargetProjections()

{

   var objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>(); // ObjectTracker with capital 'O' not like the doumentation with lower 'o'

   var dataset = objectTracker.CreateDataSet();

   foreach (var imageTarget in imageTargetFiles) // I have a list of image targets

   {

      imageTarget.Load(); // My special object which loads an image into a Texture2D

      var runtimeImageSource = objectTracker.RuntimeImageSource;

      var imageTargetTexture = imageTarget.AsTexture(); // This was my little change

      var imageSourceIsLoaded = runtimeImageSource.SetImage(

         imageTargetTexture,

         imageTarget.Dimensions.WidthInMeters, // My special object mesures its own dimensions :)

         imageTarget.Name);

      if (imageSourceIsLoaded){

         var trackableBehaviour = dataset.CreateTrackable(runtimeImageSource, imageTarget.Name);

 

         /// Here I have some code to put an object as child to the image target

         projection.transform.parent = trackableBehaviour.transform;

         projection.transform.rotation = Quaternion.Euler(90, 0, 0); // By default my assigned object have to rotat to spawn it correctly but ist only for me

      }

   }

   objectTracker.ActivateDataSet(dataset);

}

Best Regards

jf^

 

Thank you .

Can you Help me to load Image target from storage in Android Step by Step?

Log in or register to post comments