Get Started         Best Practices         Developer Guide         FAQ        
Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

cloudRecognition.search with a base64 image

Lucas Mafrica Nov 30, 2018

Hi,
I'm working with the cloudrecognition in javascript with cordova but i don't use the input type file in html. I'm using a personnalized camera which give me a image in base64 instead of an URL. Is it possible to make cloudRecognition.search with a base64 image?
If not, how can i transform a base64 to a correct URL for cloudRecognition.search?

thank for help, have a nice day!


( Agent )
Luis Martinell

Nov 30, 2018

Hi Lucas,

You can create a CraftarImage both from a file or from a dataurl image (which allows to embed a base64 inside the url:

CraftARImage.fromFile = function( file, callback ){ var options = {canvas:true, maxWidth: 1000}; loadImage.parseMetaData(file, function (data) { if (data.exif) { options.orientation = data.exif.get(‘Orientation’); } loadImage(file, function(image) { if (!(image.src || image instanceof HTMLCanvasElement)) { callback(null); } else { var craftarImage = new CraftARImage(); craftarImage.canvasImage = image; callback(craftarImage); } }, options); }); }; CraftARImage.fromDataUrl = function( dataurl ){ var craftarImage = new CraftARImage(); craftarImage.dataUrl = dataurl; return craftarImage; };

More on dataURIs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

I hope this helps.

Best regards,
Luis

0 rated
Lucas Mafrica

Dec 03, 2018

Hi, thank for your answer

I have a new error, i don't know if i'm making something wrong or if i didn't understand what you say but this is my code:

var file = "data:image/png;base64,....";
CraftARImage.fromFile = function( file, callback ){
var options = {canvas:true, maxWidth: 1000};
loadImage.parseMetaData(file, function (data) {
console.log(file);
console.log(data);
if (data.exif) {
options.orientation = data.exif.get('Orientation');
}
loadImage(file, function(image) {
if (!(image.src || image instanceof HTMLCanvasElement)) {
callback(null);
}
else {
var craftarImage = new CraftARImage();
craftarImage.canvasImage = image;
callback(craftarImage);
}
}, options);
});
};

and this is my error:

ReferenceError: CraftARImage is not defined

can you help me on this point?

Thank a lot
have a nice day
0 rated
Lucas Mafrica

Dec 03, 2018

No sorry, this is not the problem, I'm working with cordova to make an app and after some research this is not the problem!

The problem is that loadImage not working on cordova, so i'm not sure you can help me on this but we never know

Thank
Have a nice day
0 rated
( Agent )
Luis Martinell

Dec 04, 2018

Hi Lucas,

If you can share the cordova project with us and explain the use case that doesn’t work for you, maybe we can have a look at it and help you.

Thanks!
Luis

0 rated

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Couldn't find what you were looking for?

support@catchoom.com
https://cdn.desk.com/
false
catchoom
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete