我正在使用微软的认知服务face-api,我已经完成了人脸检测,并获得了人脸ids。为了检测人脸,我使用了一个在线图像表单,并在rest api的请求正文中添加了urls。现在为了验证人脸,我使用了两张图片,并且我有两个urls。所以我在发送请求正文时遇到了一个问题。我不知道在请求正文中应该发送哪些数据
$(function() {
var params = {
{
"faceId1": "c5c24a82-6845-4031-9d5d-978df9175426",
"faceId2": "815df99c-598f-4926-930a-a734b3fd651c"
}
};
$.ajax({
url: "https://westus.api.cognitive.microsoft.com/face/v1.0/verify?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "POST",
// Request body
data:"{}";
})
.done(function(data) {
alert("success");
})
.fail(function(){
alert("error");
});
});发布于 2020-03-04 12:17:14
Face API for Verify显示了如何形成请求的正文,具体取决于您希望面对面验证还是面对面验证。face to Person将是与Person对象(您可能以前创建的对象)中的其他图像进行比较的图像。
Face的REST细节在这里:https://docs.microsoft.com/en-us/rest/api/cognitiveservices/face/face
实体必须具有面ID,而参数是可选的。因此,从技术上讲,您可以删除$.param(params),并使请求体中的data如下所示:
data:
"{
"faceId1": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"faceId2": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}"https://stackoverflow.com/questions/56616710
复制相似问题