facedetection.html
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<title>Age Detection</title>
<meta charset="utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<img src="http://211.249.50.30:8080/user/mypic.jpg"></img>
<button onclick="test()">완료</button>
<script type="text/javascript">
function test(){
var params = {
// Request parameters <img src="http://localhost:8080/user/mypic.jpg"></img>
"returnFaceId": "true",
"returnFaceLandmarks": "false",
"returnFaceAttributes": "age,gender",
};
$.ajax({
// NOTE: You must use the same location in your REST call as you used to obtain your subscription keys.
// For example, if you obtained your subscription keys from westus, replace "westcentralus" in the
// URL below with "westus".
url: "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
// NOTE: Replace the "Ocp-Apim-Subscription-Key" value with a valid subscription key.
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","39716df1b81349fdabb0931c039eeaf2");
},
type: "POST",
// Request body.
data: '{"url":"http://211.249.50.30:8080/user/mypic.jpg"}',
})
.done(function(data) {
alert(JSON.stringify(data));
})
.fail(function(data) {
alert(JSON.stringify(data));
});
}
</script>
</body>
</html>