Search in sources :

Example 1 with AuditingInfo

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);
}
Also used : ImageAuditingResponse(com.qcloud.cos.model.ciModel.auditing.ImageAuditingResponse) BatchImageAuditingResponse(com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingResponse) BatchImageAuditingRequest(com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingRequest) ImageAuditingRequest(com.qcloud.cos.model.ciModel.auditing.ImageAuditingRequest) AuditingInfo(com.qcloud.cos.model.ciModel.auditing.AuditingInfo)

Example 2 with AuditingInfo

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);
    }
}
Also used : AudioAuditingResponse(com.qcloud.cos.model.ciModel.auditing.AudioAuditingResponse) AudioAuditingRequest(com.qcloud.cos.model.ciModel.auditing.AudioAuditingRequest) AuditingInfo(com.qcloud.cos.model.ciModel.auditing.AuditingInfo)

Example 3 with AuditingInfo

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;
}
Also used : IllegalInfo(com.qcloud.cos.model.ciModel.auditing.IllegalInfo) PornInfo(com.qcloud.cos.model.ciModel.auditing.PornInfo) TerroristInfo(com.qcloud.cos.model.ciModel.auditing.TerroristInfo) ArrayList(java.util.ArrayList) AuditingInfo(com.qcloud.cos.model.ciModel.auditing.AuditingInfo) AdsInfo(com.qcloud.cos.model.ciModel.auditing.AdsInfo) AbuseInfo(com.qcloud.cos.model.ciModel.auditing.AbuseInfo) SnapshotInfo(com.qcloud.cos.model.ciModel.auditing.SnapshotInfo) PoliticsInfo(com.qcloud.cos.model.ciModel.auditing.PoliticsInfo) SectionInfo(com.qcloud.cos.model.ciModel.auditing.SectionInfo)

Example 4 with AuditingInfo

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());
}
Also used : TextAuditingResponse(com.qcloud.cos.model.ciModel.auditing.TextAuditingResponse) AuditingInfo(com.qcloud.cos.model.ciModel.auditing.AuditingInfo) TextAuditingRequest(com.qcloud.cos.model.ciModel.auditing.TextAuditingRequest)

Example 5 with AuditingInfo

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);
    }
}
Also used : AuditingInfo(com.qcloud.cos.model.ciModel.auditing.AuditingInfo)

Aggregations

AuditingInfo (com.qcloud.cos.model.ciModel.auditing.AuditingInfo)7 BatchImageAuditingRequest (com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingRequest)2 BatchImageAuditingResponse (com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingResponse)2 AbuseInfo (com.qcloud.cos.model.ciModel.auditing.AbuseInfo)1 AdsInfo (com.qcloud.cos.model.ciModel.auditing.AdsInfo)1 AudioAuditingRequest (com.qcloud.cos.model.ciModel.auditing.AudioAuditingRequest)1 AudioAuditingResponse (com.qcloud.cos.model.ciModel.auditing.AudioAuditingResponse)1 BatchImageAuditingInputObject (com.qcloud.cos.model.ciModel.auditing.BatchImageAuditingInputObject)1 BatchImageJobDetail (com.qcloud.cos.model.ciModel.auditing.BatchImageJobDetail)1 IllegalInfo (com.qcloud.cos.model.ciModel.auditing.IllegalInfo)1 ImageAuditingRequest (com.qcloud.cos.model.ciModel.auditing.ImageAuditingRequest)1 ImageAuditingResponse (com.qcloud.cos.model.ciModel.auditing.ImageAuditingResponse)1 PoliticsInfo (com.qcloud.cos.model.ciModel.auditing.PoliticsInfo)1 PornInfo (com.qcloud.cos.model.ciModel.auditing.PornInfo)1 SectionInfo (com.qcloud.cos.model.ciModel.auditing.SectionInfo)1 SnapshotInfo (com.qcloud.cos.model.ciModel.auditing.SnapshotInfo)1 TerroristInfo (com.qcloud.cos.model.ciModel.auditing.TerroristInfo)1 TextAuditingRequest (com.qcloud.cos.model.ciModel.auditing.TextAuditingRequest)1 TextAuditingResponse (com.qcloud.cos.model.ciModel.auditing.TextAuditingResponse)1 VideoAuditingRequest (com.qcloud.cos.model.ciModel.auditing.VideoAuditingRequest)1