API | 操作名 | 操作描述 |
图片同步审核 | 用于图片同步审核 | |
图片批量审核 | 用于图片批量审核 | |
查询图片审核任务结果 | 用于查询图片审核任务结果 |
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";String key = "exampleobject"; //对象键SensitiveContentRecognitionRequest sensitiveContentRecognitionRequest = new SensitiveContentRecognitionRequest(bucket, key);sensitiveContentRecognitionRequest.addType("ads");// CIService 是 CosXmlService 的子类,初始化方法和 CosXmlService 一致ciService.sensitiveContentRecognitionAsync(sensitiveContentRecognitionRequest, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {SensitiveContentRecognitionResult sensitiveContentRecognitionResult = (SensitiveContentRecognitionResult) result;}@Overridepublic void onFail(CosXmlRequest request, CosXmlClientException clientException, CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// 存储桶名称,格式为 BucketName-APPIDString bucket = "examplebucket-1250000000";// 对象键,是对象在 COS 上的完整路径,如果带目录的话,格式为 "dir1/object1"String cosPath1 = "dir1/exampleobject1.jpg";String cosPath2 = "dir1/exampleobject2.jpg";//图片的链接地址,Object 和 Url 只能选择其中一种String imageUrl = "https://myqcloud.com/%205image.jpg";PostImagesAuditRequest request = new PostImagesAuditRequest(bucket);PostImagesAudit.ImagesAuditInput image1 = new PostImagesAudit.ImagesAuditInput();image1.object = cosPath1;//设置原始内容,长度限制为512字节,该字段会在响应中原样返回image1.dataId = "DataId1";//截帧频率,GIF 图检测专用,默认值为5,表示从第一帧(包含)开始每隔5帧截取一帧image1.interval = 2;//最大截帧数量,GIF 图检测专用,默认值为5,表示只截取 GIF 的5帧图片进行审核,必须大于0image1.maxFrames = 5;PostImagesAudit.ImagesAuditInput image2 = new PostImagesAudit.ImagesAuditInput();image2.object = cosPath2;image2.dataId = "DataId2";image2.interval = 2;image2.maxFrames = 5;PostImagesAudit.ImagesAuditInput image3 = new PostImagesAudit.ImagesAuditInput();image3.url = imageUrl;image3.dataId = "DataId3";image3.interval = 2;image3.maxFrames = 5;request.addImage(image1);request.addImage(image2);request.addImage(image3);//审核的场景类型,有效值:Porn(涉黄)、Ads(广告),可以传入多种类型,不同类型以,分隔,例如:Porn,Ads。request.setDetectType("Porn,Ads");ciService.postImagesAuditAsync(request, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult cosResult) {// result 图片批量审核的结果// 详细字段请查看api文档或者SDK源码PostImagesAuditResult result = (PostImagesAuditResult) cosResult;}@Overridepublic void onFail(CosXmlRequest request, CosXmlClientException clientException, CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
// 存储桶名称,格式为 BucketName-APPIDString bucket = "examplebucket-1250000000";// 审核任务的 IDString jobId = "iab1ca9fc8a3ed11ea834c525400863904";GetImageAuditRequest request = new GetImageAuditRequest(bucket, jobId);ciService.getImageAuditAsync(request, new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult cosResult) {// result 查询图片审核任务的结果// 详细字段请查看api文档或者SDK源码GetImageAuditResult result = (GetImageAuditResult) cosResult;}@Overridepublic void onFail(CosXmlRequest request, CosXmlClientException clientException, CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
本页内容是否解决了您的问题?