【发布时间】:2021-04-13 13:53:51
【问题描述】:
我正在尝试在 Javascript 中使用 Microsoft Azure Face API 来验证两个面孔。我按照他们的示例代码找到了一个 javascript API。在下面的示例代码中,如何在此 API 的正文部分传递我想要验证的两个图像?谁能给我一个例子吗?
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">
</script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
};
$.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: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
【问题讨论】:
-
您的问题解决了吗?有进展吗?