Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I am currently taking an image using the mobile device camera widget in one experience, sending it to ThingWorx as the base64 text. Then in a different experience, calling a service to retrieve that text. I am running into a road block of figuring out how to take that text and then process it to be able to insert it to an image widget on demand. By on demand, I mean if i were to have a list of image texts, to be able to have one image widget and change the image source programmatically with UI functions by the experience user.
Thanks,
Brian
Hi Brian,
Look at "Images & Objects" section in "Vuforia Developer Library": https://library.vuforia.com/objects/image-targets
Brian,
You may have already worked through this so apologies if you already know this.
Thingworx has a Repository thing and has a service SaveImage and LoadImage.
The SaveImage used inside the method UploadPhoto accepts the content as base64 shown below
Once the image is loaded you can use LoadImage to get the url from the Repository thing by using the LoadImage service.
If you are already doing this and its not working for you please provide more info on your issue.
Method UploadPhoto
===========================================
logger.debug("Entering UploadPhoto" );
if (fileName === undefined || fileName === "") {
var d = new Date();
fileName = "Photo-" + d.getTime();
}
// result: STRING
var usename = Resources["CurrentSessionInfo"].GetCurrentUser();
//Create Folder in doesn't exist
try {
me.CreateFolder({
path: '/photos/'+ usename /* STRING */
});
} catch (ex) {
}
me.SaveImage({
path: '/photos/'+ usename + '/'+fileName /* STRING */,
content: imageContent /* IMAGE */
});
==========================================
I am currently storing the pictures (base64 strings) in an array that is field of a data table in TW already. As well as have built services for sending/receiving this data associated to these images. I was attempting to accomplish this inside Vuforia since the camera widget is the item generating the base64 string. I figured there was a simple manner in which that text could be used inside Vuforia that I just couldn't seem to locate.
Below is a piece of code that may help you explore (which you may already know)
$scope.BuildList = function() {
var imagesData = $scope.view.wdg["dataGridImages"].data; // this is from a grid that is populated via service
try {
if (imagesData > 0 ) {
var index = 1;
Object.keys(imagesData).forEach(function(item){
if (index < 6 ) {
console.log ("Name =" +imagesData[item].name);
//console.log ("Content =" +imagesData[item].content);
$scope.view.wdg['image' +index].imgsrc='data:image/png;base64,' + imagesData[item].content; // imagesData[item].downloadLink; //
index++;
}
});
}
} catch(ex) {
console.log ("Possible Error: When trying to work through images Data data passed from IOT service there Exception:"+ex);
}
}