使用 Microsoft face api its object return 400 该图像无效或参数无效
Using Microsoft face api its object return 400 that image is invalid or argument is invalid
这是我的代码
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
"returnFaceId": "true",
"returnFaceLandmarks": "false",
"returnFaceAttributes": "{string}",
};
$.ajax({
url: "https://westus.api.cognitive.microsoft.com/face/v1.0/detect?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","8b99a9ed839a40a08aa8b529ef0f9b8c");
},
type: "POST",
// Request body
data: '{ "url": "http://heightline.com/wp-content/uploads/Tom-Cruise-smile.jpg" }'
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
这是有关服务器 400 响应的文档图像,当我进入或访问该页面时,它显示错误帮助解决此问题
"returnFaceAttributes": "{string}" 出错了。
实际上它是 {string} 值。应注明,即年龄、性别...
尝试用 "returnFaceAttributes": "age" 替换 "returnFaceAttributes": "{string}" ,它应该可以工作。
查看文档:https://www.microsoft.com/cognitive-services/en-us/face-api/documentation/glossary
这是我的代码
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
"returnFaceId": "true",
"returnFaceLandmarks": "false",
"returnFaceAttributes": "{string}",
};
$.ajax({
url: "https://westus.api.cognitive.microsoft.com/face/v1.0/detect?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","8b99a9ed839a40a08aa8b529ef0f9b8c");
},
type: "POST",
// Request body
data: '{ "url": "http://heightline.com/wp-content/uploads/Tom-Cruise-smile.jpg" }'
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
这是有关服务器 400 响应的文档图像,当我进入或访问该页面时,它显示错误帮助解决此问题
"returnFaceAttributes": "{string}" 出错了。 实际上它是 {string} 值。应注明,即年龄、性别...
尝试用 "returnFaceAttributes": "age" 替换 "returnFaceAttributes": "{string}" ,它应该可以工作。
查看文档:https://www.microsoft.com/cognitive-services/en-us/face-api/documentation/glossary