(推薦)提交視頻非同步檢測任務
介面 | 描述 | 支援的地區 |
VideoAsyncScanRequest | 提交視頻非同步檢測任務,對視頻進行多個風險情境的識別,包括色情、暴恐涉政、廣告 、不良情境、Logo(商標台標)識別。 | cn-shanghai:華東2(上海) cn-beijing:華北2(北京) cn-shenzhen:華南1(深圳) ap-southeast-1:新加坡
|
查詢視頻非同步檢測結果
介面 | 描述 | 支援的地區 |
VideoAsyncScanResultsRequest | 查詢視頻非同步檢測任務的結果。 說明 該方法需要輪詢結果,建議使用callback的方式擷取結果。 | cn-shanghai:華東2(上海) cn-beijing:華北2(北京) cn-shenzhen:華南1(深圳) ap-southeast-1:新加坡
|
範例程式碼
using System;
using Newtonsoft.Json;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Green.Model.V20180509;
using System.Collections.Generic;
namespace csharp_sdk_sample
{
class Program
{
static void Main(string[] args)
{
/**
* 常見擷取環境變數方式:
* 擷取RAM使用者AccessKey ID:Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID");
* 擷取RAM使用者AccessKey Secret:Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
*/
DefaultProfile profile = DefaultProfile.GetProfile(
"cn-shanghai",
"建議從環境變數中擷取RAM使用者AccessKey ID",
"建議從環境變數中擷取RAM使用者AccessKey Secret");
// 注意:此處執行個體化的client儘可能重複使用,提升檢測效能。避免重複建立串連。
DefaultAcsClient client = new DefaultAcsClient(profile);
VideoAsyncScanResultsRequest request = new VideoAsyncScanResultsRequest();
request.AcceptFormat = FormatType.JSON;
request.ContentType = FormatType.JSON;
request.Method = MethodType.POST;
request.Encoding = "UTF-8";
List<string> taskIdList = new List<string> { "視頻非同步檢測任務ID" };
request.SetContent(System.Text.Encoding.Default.GetBytes(JsonConvert.SerializeObject(taskIdList)), "utf-8", FormatType.JSON);
try
{
VideoAsyncScanResultsResponse response = client.GetAcsResponse(request);
if (response.HttpResponse.Status != 200)
{
Console.WriteLine("the request failed. status:{0}", response.HttpResponse.Status);
}
Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
}
catch (Exception ex)
{
Console.WriteLine("Failed with error info: {0}", ex.Message);
}
}
}
}
視頻截幀同步檢測
介面 | 描述 | 支援的地區 |
VideoSyncScanRequest | 提交視頻同步檢測任務,同步檢測視頻中的風險內容。 說明 同步檢測只支援傳遞視訊框架序列,不支援檢測視頻檔案,推薦使用非同步檢測介面。 | cn-shanghai:華東2(上海) cn-beijing:華北2(北京) cn-shenzhen:華南1(深圳) ap-southeast-1:新加坡
|
範例程式碼
以下範例程式碼中使用幀序列方式提交待檢測的視頻。
using System;
using Newtonsoft.Json;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Green.Model.V20180509;
using System.Collections.Generic;
namespace csharp_sdk_sample
{
class Program
{
static void Main(string[] args)
{
/**
* 常見擷取環境變數方式:
* 擷取RAM使用者AccessKey ID:Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID");
* 擷取RAM使用者AccessKey Secret:Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
*/
DefaultProfile profile = DefaultProfile.GetProfile(
"cn-shanghai",
"建議從環境變數中擷取RAM使用者AccessKey ID",
"建議從環境變數中擷取RAM使用者AccessKey Secret");
// 注意:此處執行個體化的client儘可能重複使用,提升檢測效能。避免重複建立串連。
DefaultAcsClient client = new DefaultAcsClient(profile);
VideoSyncScanRequest request = new VideoSyncScanRequest();
request.AcceptFormat = FormatType.JSON;
request.ContentType = FormatType.JSON;
request.Method = MethodType.POST;
request.Encoding = "UTF-8";
Dictionary<string, object> frame1 = new Dictionary<string, object>();
frame1.Add("offset", "0");
frame1.Add("url", "您的視頻截幀連結地址1");
Dictionary<string, object> frame2 = new Dictionary<string, object>();
frame2.Add("offset", "5");
frame2.Add("url", "您的視頻截幀連結地址2");
Dictionary<string, object> frame3 = new Dictionary<string, object>();
frame3.Add("offset", "10");
frame3.Add("url", "您的視頻截幀連結地址3");
Dictionary<string, object> task1 = new Dictionary<string, object>();
task1.Add("dataId", "檢測資料ID");
task1.Add("frames", new List<Dictionary<string, object>> { frame1, frame2, frame3 });
Dictionary<string, object> httpBody = new Dictionary<string, object>();
// scenes:檢測情境,支援指定多個情境。
httpBody.Add("scenes", new List<string> { "porn", "terrorism" });
httpBody.Add("bizType", "業務情境");
httpBody.Add("tasks", new List<Dictionary<string, object>> { task1 });
request.SetContent(System.Text.Encoding.Default.GetBytes(JsonConvert.SerializeObject(httpBody)), "utf-8", FormatType.JSON);
try
{
VideoSyncScanResponse response = client.GetAcsResponse(request);
if (response.HttpResponse.Status != 200)
{
Console.WriteLine("the request failed. status:{0}", response.HttpResponse.Status);
}
Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
}
catch (Exception ex)
{
Console.WriteLine("Failed with error info: {0}", ex.Message);
}
}
}
}
視頻檢測結果反饋
如果您認為視頻檢測結果與您的預期不符,可以通過視頻檢測結果反饋介面,對檢測結果進行糾正(系統會根據您反饋的結果,將視頻截幀添加到相似圖片的黑名單庫或者白名單庫)。當您再次提交相似的內容進行檢測時,以您反饋的label返回結果。
關於介面的說明,請參見檢測結果反饋。
介面 | 描述 | 支援的Region |
VideoFeedbackRequest | 提交視頻檢測結果的反饋,以人工反饋的檢測結果糾正演算法檢測結果。 | cn-shanghai:華東2(上海) cn-beijing:華北2(北京) cn-shenzhen:華南1(深圳) ap-southeast-1:新加坡
|
範例程式碼
using System;
using Newtonsoft.Json;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Green.Model.V20180509;
using System.Collections.Generic;
namespace csharp_sdk_sample
{
class Program
{
static void Main(string[] args)
{
/**
* 常見擷取環境變數方式:
* 擷取RAM使用者AccessKey ID:Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID");
* 擷取RAM使用者AccessKey Secret:Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
*/
DefaultProfile profile = DefaultProfile.GetProfile(
"cn-shanghai",
"建議從環境變數中擷取RAM使用者AccessKey ID",
"建議從環境變數中擷取RAM使用者AccessKey Secret");
// 注意:此處執行個體化的client儘可能重複使用,提升檢測效能。避免重複建立串連。
DefaultAcsClient client = new DefaultAcsClient(profile);
VideoFeedbackRequest request = new VideoFeedbackRequest();
request.AcceptFormat = FormatType.JSON;
request.ContentType = FormatType.JSON;
request.Method = MethodType.POST;
request.Encoding = "UTF-8";
Dictionary<string, object> frame1 = new Dictionary<string, object>();
frame1.Add("offset", "0");
frame1.Add("url", "您的視頻截幀連結地址1");
Dictionary<string, object> frame2 = new Dictionary<string, object>();
frame2.Add("offset", "0");
frame2.Add("url", "您的視頻截幀連結地址2");
List<Dictionary<string, object>> frames = new List<Dictionary<string, object>> { frame1, frame2 };
// scenes:檢測情境,支援指定多個情境。
// suggestion:期望的檢測結果,pass:正常;block:違規。
Dictionary<string, object> httpBody = new Dictionary<string, object>();
httpBody.Add("scenes", new List<string> { "porn", "terrorism" });
httpBody.Add("suggestion", "block");
httpBody.Add("taskId", "視頻審核任務ID");
httpBody.Add("dataId", "檢測資料ID");
httpBody.Add("url", "視頻連結地址");
httpBody.Add("frames", frames);
httpBody.Add("note", "備忘資訊");
request.SetContent(System.Text.Encoding.Default.GetBytes(JsonConvert.SerializeObject(httpBody)), "utf-8", FormatType.JSON);
try
{
VideoFeedbackResponse response = client.GetAcsResponse(request);
if (response.HttpResponse.Status != 200)
{
Console.WriteLine("the request failed. status:{0}", response.HttpResponse.Status);
}
Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
}
catch (Exception ex)
{
Console.WriteLine("Failed with error info: {0}", ex.Message);
}
}
}
}