Hi Sarah,
you can also store the .wto file on your servers and load it from there (You just need to put the server url of the .wto file once you create the TargetCollectionResource --> AR.TargetCollectionResource("https://.....",....
Thx and greetings
Nicola
Hi, Aitor
I don't really understand the structure (where should I put this, where should I put that) and what should I do to show the name and the description on each object when it scanned.
This is my latest javascript code and I don't even know why and where my mistake that cause the name and the description didn't shown
var ServerInformation = { OBJECTDATA_SERVER: "https://.....", OBJECTDATA_SERVER_ARG_NAME: "nama_objek", OBJECTDATA_SERVER_ARG_DESC: "description" }; var World = { loaded: false, objectData: [], drawables: [], init: function initFn() { World.requestDataFromServer(); World.createDescriptionDrawable(); World.createTracker(); }, requestDataFromServer: function requestDataFromServerFn(nama_objek, description) { /* Set helper var to avoid requesting places while loading. */ World.isRequestingData = true; World.updateStatusMessage('Requesting places from web-service'); /* Server-url to JSON content provider. */ var serverUrl = ServerInformation.OBJECTDATA_SERVER + "?" + ServerInformation.OBJECTDATA_SERVER_ARG_NAME + "=" + nama_objek + "&" + ServerInformation.OBJECTDATA_SERVER_ARG_DESC + "=" + description; var jqxhr = $.getJSON(serverUrl, function(objectData) { World.loadObjectsFromJsonData(objectData); }) .error(function(err) { World.updateStatusMessage("Invalid web-service response.", true); World.isRequestingData = false; }) .complete(function() { World.isRequestingData = false; }); }, }, loadObjectsFromJsonData: function loadObjectsFromJsonDataFn(objectData) { /* Loop through Object-information and create an AR.Object (=Marker) per Object. */ for (var currentObjectNr = 0; currentObjectNr < objectData.length; currentObjectNr++) { var singleObject = { "id": objectData[currentObjectNr].id, "nama_objek": objectData[currentObjectNr].nama_objek, "description": objectData[currentObjectNr].description }; World.objectData.push(singleObject); } }, createDescriptionDrawable: function createDescriptionDrawableFn() { titleLabel = new AR.Label(objectData.nama_objek.trunc(30), 0.7, { zOrder: 1, translate: { x: 0.7, y: 0.2 }, style: { textColor: '#FFFFFF', fontStyle: AR.CONST.FONT_STYLE.BOLD } }); }, createTracker: function createTrackerFn() { this.targetCollectionResource = new AR.TargetCollectionResource("https://..../file_name.wto", { onError: World.onError }); this.tracker = new AR.ObjectTracker(this.targetCollectionResource, { onError: World.onError }); for (var i = 0; i < objectData.length; i++) { this.objectTrackable = new AR.ObjectTrackable(this.tracker, objectData[i].id, { drawables: { cam: World.drawables, }, onObjectRecognized: World.objectRecognized, onObjectLost: World.objectLost, onError: World.onError }); } }, objectRecognized: function objectRecognizedFn() { World.hideInfoBar(); World.setAugmentationsEnabled(true); }, objectLost: function objectLostFn() { World.setAugmentationsEnabled(false); }, setAugmentationsEnabled: function setAugmentationsEnabledFn(enabled) { for (var i = 0; i < World.drawables.length; i++) { World.drawables[i].enabled = enabled; } }, onError: function onErrorFn(error) { alert(error); }, hideInfoBar: function hideInfoBarFn() { document.getElementById("infoBox").style.display = "none"; }, showInfoBar: function worldLoadedFn() { document.getElementById("infoBox").style.display = "table"; document.getElementById("loadingMessage").style.display = "none"; } }; World.init();
Could you give me the structure or an simple example program that included all I need to this? Thank you
Regards,
Sarah.
Hi Sarah,
I see that this thread covers a lot of code samples and details provided by Aitor and I'd like to add details to our support process in general to manage your expectations. For questions such as the one we're having in this thread, our approach is to give code snippets, descriptions and ideas on how to solve the problem, links to the Wikitude documentation and the SDK sample app. We're not providing 3rd party development and therefore are not implementing any code or samples. As the support is done by our core team to ensure a high quality support process, I hope you can understand that we need to work efficiently and can't provide any other details that provided by Aitor already.
Ideally, make sure that you fully understand the sample app, how it works and also seek for input in different support channels online.
Thx for your understanding,
Nicola
Hi Sarah,
We don't provide that kind of service by our own, but it could be possible if alongside you .wto file, you have another file (a json for example) which lists the targets and their descriptions. In your code, you could download the .wto + the json files and iterate through it, adding an ObjectTrackable for each item.
Regards,
Aitor.
Hi,
Let me explain about the project that I will make and the issue that I need to solve.
1. I need to add new objects to the .wto file periodically, when there are new objects, I have to download a new .wto file and upload it to the web service. The function is that every time there are additional objects, I don't need to change the code or re-import the .wto file manually .
2. I don't display object 3d as augmentation. I display the description text of each detected object (each object has a different description). this also required to new objects added to the .wto file. I think it's almost like cloud recognition. But I need object detection not image detection.
What should I do to resolve the issue?
Regards
Sarah
Hi,
Could you please send me you javascript so i can check how are you using our SDK?
In our samples, the request is being called like:
requestDataFromServer: function requestDataFromServerFn(lat, lon) { /* Set helper var to avoid requesting places while loading. */ World.isRequestingData = true; World.updateStatusMessage('Requesting places from web-service'); /* Server-url to JSON content provider. */ var serverUrl = ServerInformation.POIDATA_SERVER + "?" + ServerInformation.POIDATA_SERVER_ARG_LAT + "=" + lat + "&" + ServerInformation.POIDATA_SERVER_ARG_LON + "=" + lon + "&" + ServerInformation.POIDATA_SERVER_ARG_NR_POIS + "=20"; var jqxhr = $.getJSON(serverUrl, function(data) { World.loadPoisFromJsonData(data); }) .error(function(err) { World.updateStatusMessage("Invalid web-service response.", true); World.isRequestingData = false; }) .complete(function() { World.isRequestingData = false; }); },
The $.getJSON is the method we are calling with our testing url from the server. Did you check if the data variable is not empty? In case it is empty, the problem is coming from your webservice, in case is not empty, maybe the data you are sending is not the same that the data we require and you should take a look at the samples/documentation to see what data do we need.
Regards,
Aitor.
Hi Sarah,
When you have created an ObjectTracker, then you will have to create an ObjectTrackable that let you to draw an augmentation for the .wto file. If you have more than one object to track inside the .wto file, you can create as many ObjectTrackables as objects are in the file:
this.objectTrackable = new AR.ObjectTrackable(this.tracker, "NAME_OF_THE_OBJECT_TO_TRACK", { drawables: { cam: [...] } });
Take a look at the API reference: https://www.wikitude.com/external/doc/documentation/latest/Reference/JavaScript%20API/classes/ObjectTrackable.html and you will see that you can create an ObjectTrackable that points to an specific object of the TargetCollection you are loading and then, draw an augmentation that depends direcly on that object.
Regards,
Aitor.
Hi Aitor,
Thanks fot the solution that could be possible to do. But I don't really understand how to do this statement
"In your code, you could download the .wto + the json files and iterate through it, adding an ObjectTrackable for each item"
Could you hep me with an example what should I do and where should I put my code in Android Studio or javascript file? I really need your help.
Thank You
Regards,
Sarah.
Hi,
As you mentioned previously, you have a .wto file uploaded to a web service which is updated everytime you need to add some objects. In the same way, you could have a .json file uploaded to a web service that contains the list of the targets and their descriptions. Once both are downloaded, you just need to iterate the .json file, and for every item that exists, create an ObjectTrackable in the same way we are doing in the Wikitude Sample app, attaching the description that is in the .json file.
Regards,
Aitor.
Hi Aitor,
this is my code in javascript, can you check it where actually my mistake is?
var ServerInformation = { OBJECTDATA_SERVER: "https://.....", OBJECTDATA_SERVER_ARG_NAME: "nama_objek", OBJECTDATA_SERVER_ARG_DESC: "description" }; var World = { loaded: false, drawables: [], init: function initFn() { World.createTracker(); }, requestDataFromServer: function requestDataFromServerFn(nama_objek, description) { /* Set helper var to avoid requesting places while loading. */ World.isRequestingData = true; World.updateStatusMessage('Requesting places from web-service'); /* Server-url to JSON content provider. */ var serverUrl = ServerInformation.OBJECTDATA_SERVER + "?" + ServerInformation.OBJECTDATA_SERVER_ARG_NAME + "=" + nama_objek + "&" + ServerInformation.OBJECTDATA_SERVER_ARG_DESC + "=" + description; var jqxhr = $.getJSON(serverUrl, function(data) { World.loadPoisFromJsonData(data); }) .error(function(err) { World.updateStatusMessage("Invalid web-service response.", true); World.isRequestingData = false; }) .complete(function() { World.isRequestingData = false; }); }, }, loadObjectsFromJsonData: function loadObjectsFromJsonDataFn(objectData) { /* Loop through Object-information and create an AR.Object (=Marker) per Object. */ for (var currentObjectNr = 0; currentObjectNr < objectData.length; currentObjectNr++) { var singleObject = { "id": objectData[currentObjectNr].id, "nama_objek": objectData[currentObjectNr].nama_objek, "description": objectData[currentObjectNr].description }; World.markerList.push(new Marker(singleObject)); } }, createTracker: function createTrackerFn() { this.targetCollectionResource = new AR.TargetCollectionResource("https://...../file_name.wto", { onError: World.onError }); this.tracker = new AR.ObjectTracker(this.targetCollectionResource, { onError: World.onError }); for (var i = 0; i < objectData.length; i++) { this.objectTrackable = new AR.ObjectTrackable(this.tracker, objectData[i].id, { drawables: { cam: createDescriptionDrawable(objectData[i].description, }, onObjectRecognized: World.objectRecognized, onObjectLost: World.objectLost, onError: World.onError }); } }, objectRecognized: function objectRecognizedFn() { World.hideInfoBar(); World.setAugmentationsEnabled(true); }, objectLost: function objectLostFn() { World.setAugmentationsEnabled(false); }, setAugmentationsEnabled: function setAugmentationsEnabledFn(enabled) { for (var i = 0; i < World.drawables.length; i++) { World.drawables[i].enabled = enabled; } }, onError: function onErrorFn(error) { alert(error); }, hideInfoBar: function hideInfoBarFn() { document.getElementById("infoBox").style.display = "none"; }, showInfoBar: function worldLoadedFn() { document.getElementById("infoBox").style.display = "table"; document.getElementById("loadingMessage").style.display = "none"; } }; World.init();
Thankyou
Regards,
Sarah.
Sarah Olivia Meily
Hi,
How to get .wto file (object tracking ) from web service using android javascript API?
Because on the Wikitude sample we need to import our .wto file.
All I need is my project can automatically get the new .wto file that I uploaded on my web service.
I'm using Wikitude SDK Android 8.10
Thanks