ITPub博客

首页 > 数据库 > 数据库开发技术 > 阿里云安全 - 图片审核

阿里云安全 - 图片审核

原创 数据库开发技术 作者:后端Q 时间:2021-11-23 00:00:00 0 删除 编辑

背景

阿里云图像审核服务是阿里云对外提供的图像智能审核服务,支持对图像的多个维度进行审核,包括色情识别、暴恐识别、政治敏感识别、恶心图识别、广告识别等。图像审核应用场景广泛,例如游戏、社交、论坛、生活服务类、UGC等场景。如游戏厂商需要对玩家上传的自定义头像进行审核,就可以借助图像审核服务对头像进行审核。


图像审核服务和阿里云对象存储进行了深度集成,您可以通过阿里云对象存储 API、SDK、CLI等方式调用图像审核能力。

代码

示例代码


public static ScanImageRoot ScanImage(string ImageURL) { IClientProfile profile = DefaultProfile.GetProfile("cn-shanghai", ConfigHelper.GetAppSetting("accessKeyId"), ConfigHelper.GetAppSetting("accessKeySecret")); DefaultAcsClient client = new DefaultAcsClient(profile); CommonRequest request = new CommonRequest(); request.Method = MethodType.POST; request.Domain = "imageaudit.cn-shanghai.aliyuncs.com"; request.Version = "2019-12-30"; request.Action = "ScanImage"; // request.Protocol = ProtocolType.HTTP; request.AddQueryParameters("Scene.1", "porn"); request.AddQueryParameters("Scene.2", "terrorism"); request.AddQueryParameters("Scene.3", "ad"); request.AddQueryParameters("Scene.4", "live"); request.AddQueryParameters("Scene.5", "logo");
//https://vision.aliyun.com/experience/detail?spm=a2c4g.11186623.0.0.6baf5b249UE3wM&tagName=imageaudit&children=IdentifyPorn&accounttraceid=036a909d906141a0bb9f5d8539f73520xebk
request.AddQueryParameters("Task.1.ImageURL", ImageURL); try { CommonResponse response = client.GetCommonResponse(request); Console.WriteLine(System.Text.Encoding.UTF8.GetString(response.HttpResponse.Content)); Logger.Debug(System.Text.Encoding.UTF8.GetString(response.HttpResponse.Content)); var r = JsonConvert.DeserializeObject<ScanImageRoot>(System.Text.Encoding.UTF8.GetString(response.HttpResponse.Content));
return r; } catch (Exception e) { Console.WriteLine(e); Logger.Error("图像检测:ImageURL " + ImageURL + " " + e.ToString()); return null; } }

测试

测试:

测试结果,ImageURL审核不通过

    _Logger.Debug(ImageURL);
//阿里云 var result2 = Xmzy.Common.Tools.huawei.Moderation.TryScanImage(ImageURL); if (result2 != null) { var SubResults = result2?.Data?.Results?.FirstOrDefault()?.SubResults ?? new List<SubResultsItem>(); if (SubResults.Any(x => x.Suggestion == "block"))




原文作者:后端Q;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2023-01-22

  • 博文量
    1540
  • 访问量
    726154