cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Image Processing

BAR3887
5-Regular Member

Image Processing

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

4 REPLIES 4
VladimirN
24-Ruby II
(To:BAR3887)

 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 */
});

 

==========================================

BAR3887
5-Regular Member
(To:sgreywilson)

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&colon;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);
}

}

Top Tags