use of com.qcloud.cos.model.ciModel.auditing.ImageAuditingRequest 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.ImageAuditingRequest in project cos-java-sdk-v5 by tencentyun.
the class TransferManager method batchPostImageAuditing.
public MultipleImageAuditingImpl batchPostImageAuditing(List<ImageAuditingRequest> requestList) {
String description = "Send image auditing jobs in bulk";
TransferProgress transferProgress = new TransferProgress();
List<ImageAuditingImpl> imageAuditingList = new ArrayList<>();
final MultipleImageAuditingImpl multipleImageAuditing = new MultipleImageAuditingImpl(description, transferProgress, imageAuditingList);
multipleImageAuditing.setMonitor(new MultipleFileTransferMonitor(multipleImageAuditing, imageAuditingList));
final CountDownLatch latch = new CountDownLatch(1);
MultipleFileTransferStateChangeListener transferListener = new MultipleFileTransferStateChangeListener(latch, multipleImageAuditing);
for (ImageAuditingRequest imageAuditingRequest : requestList) {
imageAuditingList.add(doImageAuditing(imageAuditingRequest, transferListener));
}
latch.countDown();
return multipleImageAuditing;
}
use of com.qcloud.cos.model.ciModel.auditing.ImageAuditingRequest in project cos-java-sdk-v5 by tencentyun.
the class ImageAuditingDemo method batchPostImageAuditing.
/**
* 批量发送图片审核任务 使用sdk并发发送
*/
public static void batchPostImageAuditing(COSClient client) throws InterruptedException {
List<ImageAuditingRequest> requestList = new ArrayList<>();
ImageAuditingRequest request = new ImageAuditingRequest();
request.setBucketName("demo-123456789");
request.setObjectKey("1.png");
request.setDetectType("all");
requestList.add(request);
request = new ImageAuditingRequest();
request.setBucketName("demo-123456789");
request.setObjectKey("1.jpg");
request.setDetectType("all");
requestList.add(request);
// 传入一个threadpool, 若不传入线程池, 默认TransferManager中会生成一个单线程的线程池。
ExecutorService threadPool = Executors.newFixedThreadPool(4);
TransferManager transferManager = new TransferManager(client, threadPool);
MultipleImageAuditingImpl multipleImageAuditing = transferManager.batchPostImageAuditing(requestList);
multipleImageAuditing.waitForCompletion();
List<ImageAuditingImpl> imageAuditingList = multipleImageAuditing.getImageAuditingList();
for (ImageAuditingImpl imageAuditing : imageAuditingList) {
System.out.println(imageAuditing.getState());
System.out.println(imageAuditing.getResponse());
System.out.println(imageAuditing.getErrMsg());
}
transferManager.shutdownNow();
client.shutdown();
}
Aggregations