Hello, I need to get the ID of the target has recognized. That's when I use the recognition cloud target. I did when the target detected (cloud recognition) downloading the necessary files from the server for the scene of augmented reality, but now I need to for each target has download different files, but how to get the ID targeta I could not understand, please help me, я новичек в Vuforia SDK. Thanks in advance.
- Sort Posts
- 8 replies
- Last post
How to get ID cloud image target?
How to get ID cloud image target?
You need to use JNI to pass objects or primitive values from C++ to Java;
this is a quick introduction on JNI with Vuforia:
https://developer.vuforia.com/resources/dev-guide/java-native-interface
But a more comprehensive guide on JNI programming can be found here:
http://docs.oracle.com/javase/6/docs/technotes/guides/jni/
How to get ID cloud image target?
How to get ID cloud image target?
Use the getUniqueTargetId() method on the TargetSearchResult instance.
See:
https://developer.vuforia.com/resources/api/ios/class_q_c_a_r_1_1_target_search_result
How to get ID cloud image target?
Hi TokiTok,
you can definitely look at the code snippet that NalinS has shared;
in addition to what NalinS has suggested, you can also query the "unique target ID" of the cloud Target (if that's what you mean by "ID");
the code to add is just:
string uniqueID = targetSearchResult.UniqueTargetId;
This will return the unique target id generated by the Cloud when you uploaded the target.
How to get ID cloud image target?
Hi TokiTok,
I am not quite sure what you mean by ID?
The best thing to do is to study the CloudRecoEventHandler.cs and this has a callback as shown below that is called on each new search result. Here you can check for the metadata that was uploaded for each target as a way of uniquely identifiying them.
This example is from the cloud reco sample. Over at this thread I posted up a very simple handler which simply displays an augmentation for a CloudReco target: https://developer.vuforia.com/forum/cloud-recognition/creating-my-books-json-ios
One other suggestion also is to read through the CloudReco forums as there is lots of information there and you can learn from the experiences of other developers.
HTH
N
public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
{
// This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
// Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(),
// or to create a new ImageTargetBehaviour for each new result
// Vuforia will return a new object with the right script automatically if you use
// TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)
//Check if the metadata isn't null
if(targetSearchResult.MetaData == null)
{
return;
}
// enable the new result with the same ImageTargetBehaviour:
ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate);
if (imageTargetBehaviour != null)
{
// stop the target finder
mCloudRecoBehaviour.CloudRecoEnabled = false;
// Calls the TargetCreated Method of the SceneManager object to start loading
// the BookData from the JSON
mContentManager.TargetCreated(targetSearchResult.MetaData);
}
}
Please see tthis code i am not able to Extract id from this. Can u pllese just write 2 line of code . I will be thanksfull to you,,