facedetection.html 1.69 KB
<!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>