use of com.qcloud.cos.model.ciModel.auditing.AuditingInfo in project cos-java-sdk-v5 by tencentyun.
the class ImageAuditingDemo method imageAuditing.
/**
* createImageAuditingJob 接口用于创建图片审核任务。(发送单个任务 推荐)
*
* @param client
*/
public static void imageAuditing(COSClient client) {
// 1.创建任务请求对象
ImageAuditingRequest request = new ImageAuditingRequest();
// 2.添加请求参数 参数详情请见api接口文档
// 2.1设置请求bucket
request.setBucketName("demo-123456789");
// 2.2设置审核类型
request.setDetectType("porn");
// 2.3设置bucket中的图片位置
request.setObjectKey("1.jpg");
// 2.4设置图片压缩参数 0(不压缩),1(压缩)默认为零
request.setLargeImageDetect("1");
// 3.调用接口,获取任务响应对象
ImageAuditingResponse response = client.imageAuditing(request);
// 4调用工具类,获取各审核类型详情集合 (也可自行根据业务解析)
List<AuditingInfo> imageInfoList = AuditingResultUtil.getImageInfoList(response);
System.out.println(response);
}
use of com.qcloud.cos.model.ciModel.auditing.AuditingInfo in project cos-java-sdk-v5 by tencentyun.
the class AudioAuditingJobDemo method describeAudioAuditingJob.
/**
* describeAudioAuditingJob 接口用于创建音频审核任务。
*
* @param client
*/
public static void describeAudioAuditingJob(COSClient client) throws InterruptedException {
// 1.创建任务请求对象
AudioAuditingRequest request = new AudioAuditingRequest();
// 2.添加请求参数 参数详情请见api接口文档
request.setBucketName("demo-123456789");
request.setJobId("sa9175bc451c4b11ecb3fa5254009*****");
while (true) {
// 3.调用接口,获取任务响应对象
AudioAuditingResponse response = client.describeAudioAuditingJob(request);
String state = response.getJobsDetail().getState();
if ("Success".equalsIgnoreCase(state) || "Failed".equalsIgnoreCase(state)) {
System.out.println(response.getRequestId());
System.out.println(response.getJobsDetail());
// 4.根据业务逻辑进行处理结果,此处工具类处理操作仅供参考。
List<AuditingInfo> auditingInfoList = AuditingResultUtil.getAuditingInfoList(response.getJobsDetail());
System.out.println(auditingInfoList);
break;
}
Thread.sleep(100);
}
}
use of com.qcloud.cos.model.ciModel.auditing.AuditingInfo in project cos-java-sdk-v5 by tencentyun.
the class AuditingResultUtil method getAuditingInfoList.
public static List<AuditingInfo> getAuditingInfoList(AuditingJobsDetail jobsDetail) {
List<AuditingInfo> list = new ArrayList<>();
List<SnapshotInfo> snapshotList = jobsDetail.getSnapshotList();
for (SnapshotInfo snapshotInfo : snapshotList) {
AdsInfo adsInfo = snapshotInfo.getAdsInfo();
PoliticsInfo politicsInfo = snapshotInfo.getPoliticsInfo();
PornInfo pornInfo = snapshotInfo.getPornInfo();
TerroristInfo terroristInfo = snapshotInfo.getTerroristInfo();
addAuditingInfoList(list, DetectType.Ads, adsInfo);
addAuditingInfoList(list, DetectType.Politics, politicsInfo);
addAuditingInfoList(list, DetectType.Porn, pornInfo);
addAuditingInfoList(list, DetectType.Terrorism, terroristInfo);
}
List<SectionInfo> sectionList = jobsDetail.getSectionList();
for (SectionInfo sectionInfo : sectionList) {
AdsInfo adsInfo = sectionInfo.getAdsInfo();
PoliticsInfo politicsInfo = sectionInfo.getPoliticsInfo();
PornInfo pornInfo = sectionInfo.getPornInfo();
TerroristInfo terroristInfo = sectionInfo.getTerroristInfo();
IllegalInfo illegalInfo = sectionInfo.getIllegalInfo();
AbuseInfo abuseInfo = sectionInfo.getAbuseInfo();
addAuditingInfoList(list, DetectType.Ads, adsInfo);
addAuditingInfoList(list, DetectType.Politics, politicsInfo);
addAuditingInfoList(list, DetectType.Porn, pornInfo);
addAuditingInfoList(list, DetectType.Terrorism, terroristInfo);
addAuditingInfoList(list, DetectType.Illegal, illegalInfo);
addAuditingInfoList(list, DetectType.Abuse, abuseInfo);
}
return list;
}
use of com.qcloud.cos.model.ciModel.auditing.AuditingInfo in project cos-java-sdk-v5 by tencentyun.
the class TextAuditingJobDemo method createAuditingTextJobs.
/**
* createAuditingTextJobs 接口用于创建文本审核任务。
*/
public static void createAuditingTextJobs(COSClient client) {
// 1.创建任务请求对象
TextAuditingRequest request = new TextAuditingRequest();
// 2.添加请求参数 参数详情请见api接口文档
request.setBucketName("demo-1234567898");
// 2.1.1设置对象地址
// request.getInput().setObject("1.txt");
// 2.1.2或直接设置请求内容,文本内容的Base64编码
request.getInput().setContent("Base64Str");
// 2.2设置审核类型参数
request.getConf().setDetectType("all");
// 2.3设置审核模板(可选)
// request.getConf().setBizType("aa3e9d84a6a079556b0109a935c*****");
// 设置回调信息内容类型 simple精简 Detail详细
request.getConf().setCallbackVersion(CallbackVersion.Simple);
// 3.调用接口,获取任务响应对象
TextAuditingResponse response = client.createAuditingTextJobs(request);
// 4.调用工具类,获取各审核类型详情集合 (也可自行根据业务解析)
List<AuditingInfo> auditingInfoList = AuditingResultUtil.getAuditingInfoList(response.getJobsDetail());
}
use of com.qcloud.cos.model.ciModel.auditing.AuditingInfo in project cos-java-sdk-v5 by tencentyun.
the class AuditingResultUtil method addAuditingInfoList.
private static void addAuditingInfoList(List<AuditingInfo> list, DetectType detectType, AudtingCommonInfo info) {
int flag = getAuditingResult(info);
if (flag != 0) {
AuditingInfo auditingInfo = new AuditingInfo();
auditingInfo.setType(detectType);
auditingInfo.setTypeName(detectType.getName());
auditingInfo.setCount(info.getCount());
auditingInfo.setHitFlag(info.getHitFlag());
auditingInfo.setScore(info.getScore());
String label = info.getLabel();
if (!"".equals(label) && label != null) {
auditingInfo.setKeyWords(label.split(","));
}
list.add(auditingInfo);
}
}
Aggregations