带有Cordova Camera的Microsoft Oxford Face API [英] Microsoft Oxford Face API with Cordova Camera

查看:68
本文介绍了带有Cordova Camera的Microsoft Oxford Face API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


你好,



 



 我一直在尝试使用cordova相机捕获作为Microsoft Project Oxford的参数 - Face API输入



(https://dev.projectoxford.ai/docs/services/54d85c1d5eefd00dc474a0ef/operations/54f0375749c3f70a50e79b82)
 



我有相机为我捕获图像并能够分配到表格中的< img>标签。但是当我使用相同的字节数据发送到项目牛津时它说格式不正确。我应该做一些编码调整吗?



 



我的Cordova代码如下:


 

 _getPhoto:function(source){
var that = this;
//从指定的源检索图像文件位置。
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拍摄的照片。
smallImage.src =" data:image / jpeg; base64," + imageData;
GetIdentity(imageData);
},



函数GetIdentity(imageData){

var params = {
//指定您的订阅密钥
'subscription-key':'XXXXXXXXXXX',
// analyzeFaceLandmarks:" false",
analyzeAge:" true",
analyzeGender:" true",
// analyzeHeadPose:" 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(数据,函数(commentIndex,comment){
html + ='faceid:'+ comment ['faceId'] +" \r\ n" ;;
});
alert(html);
})。失败(function(x){
alert(" error:" + x.statusText + x.responseText);
} )
}





 



 



请帮忙我如何解决这个问题

解决方案

格式不正确,你请查看以下详细信息:


支持的输入图像格式包括JPEG,PNG,GIF(第一帧),BMP和图像文件大小不应大于4MB。


可检测的面部尺寸范围为36x36到4096x4096像素。不会检测到超出此范围的面部。


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 on how I can resolve this issue

解决方案

For format is incorrect, you could check below details please :

The supported input image formats includes JPEG, PNG, GIF(the first frame), BMP, and image file size should be no larger than 4MB.

The detectable face size range is 36x36 to 4096x4096 pixels. The faces out of this range will not be detected.


这篇关于带有Cordova Camera的Microsoft Oxford Face API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆