gpt4 book ai didi

javascript - 如何使用微软视频API?

转载 作者:行者123 更新时间:2023-12-02 12:42:31 25 4
gpt4 key购买 nike

我希望用户插入视频的直接链接,例如 http://www.video.com/test.mp4

一旦您单击“提交”按钮,您就会查阅 MICROSOFT VIDEO API JSON 并获取此信息。

我能够为图像创建一个图像,并且我将在此处提供代码,但我在创建视频时遇到了很多麻烦。

我还想知道我是否可以通过“直播”获取此信息,例如在线摄像机的 IP。

视频

<!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
"sensitivityLevel": "{string}",
"frameSamplingValue": "{number}",
"detectionZones": "{string}",
"detectLightChange": "{boolean}",
"mergeTimeThreshold": "{number}",
};

$.ajax({
url: "https://westus.api.cognitive.microsoft.com/video/v1.0/detectmotion?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","INSERT KEY");
},
type: "POST",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>

图像 - 工作

<!DOCTYPE html>
<html>
<head>
<title>TESTANDO DETECTOR DE FACE EM FOTOS</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
function processImage() {
// **********************************************
// *** Update or verify the following values. ***
// **********************************************

// Replace the subscriptionKey string value with your valid subscription key.
var subscriptionKey = "INSERT KEY";

// Replace or verify the region.
//
// You must use the same region in your REST API call as you used to obtain your subscription keys.
// For example, if you obtained your subscription keys from the westus region, replace
// "westcentralus" in the URI below with "westus".
//
// NOTE: Free trial subscription keys are generated in the westcentralus region, so if you are using
// a free trial subscription key, you should not need to change this region.
var uriBase = "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect";

// Request parameters.
var params = {
"returnFaceId": "true",
"returnFaceLandmarks": "false",
"returnFaceAttributes": "age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise",
};

// Display the image.
var sourceImageUrl = document.getElementById("inputImage").value;
document.querySelector("#sourceImage").src = sourceImageUrl;

// Perform the REST API call.
$.ajax({
url: uriBase + "?" + $.param(params),

// Request headers.
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
},

type: "POST",

// Request body.
data: '{"url": ' + '"' + sourceImageUrl + '"}',
})

.done(function(data) {
// Show formatted JSON on webpage.
$("#responseTextArea").val(JSON.stringify(data, null, 2));
})

.fail(function(jqXHR, textStatus, errorThrown) {
// Display error message.
var errorString = (errorThrown === "") ? "Error. " : errorThrown + " (" + jqXHR.status + "): ";
errorString += (jqXHR.responseText === "") ? "" : (jQuery.parseJSON(jqXHR.responseText).message) ?
jQuery.parseJSON(jqXHR.responseText).message : jQuery.parseJSON(jqXHR.responseText).error.message;
alert(errorString);
});
};
</script>

<h1>Detectar Faces:</h1>
Entre com a URL para <strong>Analisar o Rosto</strong>.
<br><br>
Imagem para Analise: <input type="text" name="inputImage" id="inputImage" value="" />
<button onclick="processImage()">Analizar face</button>
<br><br>
<div id="wrapper" style="width:1020px; display:table;">
<div id="jsonOutput" style="width:600px; display:table-cell;">
Resposta
<br><br>
<textarea id="responseTextArea" class="UIInput" style="width:580px; height:400px;"></textarea>
</div>
<div id="imageDiv" style="width:420px; display:table-cell;">
Imagem Utilizada
<br><br>
<img id="sourceImage" width="400" />
</div>
</div>
</body>
</html>

最佳答案

I would also like to know if I can get this information through "Live Streams", as per example of IP's of online cameras.

根据Video API的文档,如果我们提交视频链接。视频将上传到服务进行分析。它不适合直播。

如果您想实时分析视频,您需要在客户端捕获视频帧并逐帧分析视频。这是 Live Camera 的代码示例使用 C#。

关于javascript - 如何使用微软视频API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45239299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com