Hello there,
I have been trying to use cordova camera capture as a parameter for Microsoft Project Oxford - Face API Input
(https://dev.projectoxford.ai/docs/services/54d85c1d5eefd00dc474a0ef/operations/54f0375749c3f70a50e79b82)
I have for the camera capture the image for me and able to assign to <img> tag in the form. But when I use the same byte data to send to project oxford it says that the format is incorrect. Is there some encoding adaptations I should be doing ?
My Cordova code is as :
_getPhoto: function(source) {
var that = this;
// Retrieve image file location from specified source.
navigator.camera.getPicture(function(){
that._onPhotoURISuccess.apply(that,arguments);
}, function(){
cameraApp._onFail.apply(that,arguments);
}, {
quality: 50,
destinationType: cameraApp._destinationType.FILE_URI,
sourceType: source
});
},
_onPhotoDataSuccess: function(imageData) {
var smallImage = document.getElementById('smallImage');
smallImage.style.display = 'block';
// Show the captured photo.
smallImage.src = "data:image/jpeg;base64," + imageData;
GetIdentity(imageData);
},
function GetIdentity(imageData){
var params = {
// Specify your subscription key
'subscription-key': 'XXXXXXXXXXX',
// analyzesFaceLandmarks: "false",
analyzesAge: "true",
analyzesGender: "true",
// analyzesHeadPose: "false",
};
$.support.cors = true;
$.ajax({
url: 'https://api.projectoxford.ai/face/v0/detections?' + $.param(params),
contentType: "application/octet-stream",
data: imageData,
type: "POST"
}).success(function(){
var html = '';
$.each(data, function (commentIndex, comment) {
html += 'faceid:' + comment['faceId']+"\r\n";
});
alert(html);
}).fail(function(x){
alert("error:"+x.statusText+x.responseText);
})
}
Please help