图像标注
This commit is contained in:
parent
8ae85f8991
commit
6e9a29284a
|
|
@ -11,6 +11,8 @@ public class UserOperaVo {
|
|||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
|
||||
private String operaId;
|
||||
/**
|
||||
* 操作名称
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -30,9 +30,23 @@ public class AlgorithmService {
|
|||
ImageRecognize vo = new ImageRecognize();
|
||||
sysFile.setType(operaName);
|
||||
vo.setContentImage(operaName);
|
||||
vo.setImageId(sysFile.getUrl());
|
||||
vo.setImageId(sysFile.getId());
|
||||
vo.setImagePath(sysFile.getUrl());
|
||||
vo.setType("2");
|
||||
//综合得分
|
||||
vo.setOverallScore("56");
|
||||
//清晰度
|
||||
vo.setClarity("32");
|
||||
//干净度
|
||||
vo.setCleanliness("16");
|
||||
//压缩痕迹
|
||||
vo.setCompressMarks("78");
|
||||
//整体观感
|
||||
vo.setImpression("65");
|
||||
//明暗均衡
|
||||
vo.setBalance("23");
|
||||
//细节体验
|
||||
vo.setDetail("25");
|
||||
list.add(vo);
|
||||
}
|
||||
return list;
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增评估数据
|
||||
* @param multipartFile
|
||||
|
|
@ -159,16 +160,13 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
if(multipartFile == null || multipartFile.length == 0){
|
||||
return AjaxResult.error("请上传图片");
|
||||
}
|
||||
|
||||
String userId= SecurityUtils.getUserId().toString();
|
||||
String operaName=DateUtils.getDate();
|
||||
//操作日期
|
||||
String path="image/"+year+"/"+month+"/"+day+"/";
|
||||
List<SysFile> fileList=new ArrayList<>();
|
||||
|
||||
//1 图片标注
|
||||
UserOperaVo userOperaVo=new UserOperaVo(userId,operaName,createTime,"2");
|
||||
//文件路径
|
||||
UserOperaVo userOperaVo=new UserOperaVo(userId,operaName,createTime,"2");
|
||||
if(StringUtils.isEmpty(vo.getId())){
|
||||
//1 图片标注
|
||||
Integer addOperaNum=mapper.addUserOperaVo(userOperaVo);
|
||||
|
|
@ -178,46 +176,46 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
}else{
|
||||
userOperaVo.setId(vo.getId());
|
||||
}
|
||||
//操作记录
|
||||
vo.setImageNum(multipartFile.length);
|
||||
vo.setBzNum(0);
|
||||
vo.setWbzNum(0);
|
||||
vo.setIsSure("1");
|
||||
vo.setOperaId(userOperaVo.getId());
|
||||
vo.setCreateTime(createTime);
|
||||
vo.setOperaType("2");
|
||||
vo.setUserId(userId);
|
||||
vo.setName(operaName);
|
||||
Integer addedAlgorithmNum= mapper.addAlgorithm(vo);
|
||||
if(addedAlgorithmNum==null || addedAlgorithmNum==0){
|
||||
return AjaxResult.error("操作记录添加失败!");
|
||||
}else{
|
||||
//文件路径
|
||||
for (MultipartFile file : multipartFile) {
|
||||
String originFileName = file.getOriginalFilename();
|
||||
String suffix=StringUtils.substringAfterLast(originFileName, ".");
|
||||
String uuid = StringUtils.randomUUID();
|
||||
String folderPath= path+uuid+"."+suffix;
|
||||
// 获取文件大小(字节)
|
||||
long sizeInBytes = file.getSize();
|
||||
// 转换为可读格式(如KB/MB)
|
||||
String humanReadableSize = convertToHumanReadable(sizeInBytes);
|
||||
SysFile sysFile=minioUtil.uploadFile(file,folderPath);
|
||||
sysFile.setId(StringUtils.randomUUID());
|
||||
sysFile.setOriginName(originFileName);
|
||||
sysFile.setFileSize(humanReadableSize);
|
||||
fileList.add(sysFile);
|
||||
}
|
||||
if(fileList.size()!=multipartFile.length){
|
||||
return AjaxResult.error("文件上传失败!");
|
||||
}
|
||||
//图片存储
|
||||
mapper.addUpLoadImage(fileList,vo.getId(),createTime,"2");
|
||||
//操作记录
|
||||
vo.setImageNum(multipartFile.length);
|
||||
vo.setBzNum(0);
|
||||
vo.setWbzNum(0);
|
||||
vo.setIsSure("0");
|
||||
vo.setOperaId(userOperaVo.getId());
|
||||
vo.setCreateTime(createTime);
|
||||
vo.setOperaType("2");
|
||||
vo.setUserId(userId);
|
||||
vo.setName(operaName);
|
||||
Integer addedAlgorithmNum= mapper.addAlgorithm(vo);
|
||||
if(addedAlgorithmNum==null || addedAlgorithmNum==0){
|
||||
return AjaxResult.error("操作记录添加失败!");
|
||||
}else{
|
||||
//文件上传标记
|
||||
for (MultipartFile file : multipartFile) {
|
||||
String originFileName = file.getOriginalFilename();
|
||||
String suffix=StringUtils.substringAfterLast(originFileName, ".");
|
||||
String uuid = StringUtils.randomUUID();
|
||||
String folderPath= path+uuid+"."+suffix;
|
||||
// 获取文件大小(字节)
|
||||
long sizeInBytes = file.getSize();
|
||||
// 转换为可读格式(如KB/MB)
|
||||
String humanReadableSize = convertToHumanReadable(sizeInBytes);
|
||||
SysFile sysFile=minioUtil.uploadFile(file,folderPath);
|
||||
sysFile.setOriginName(originFileName);
|
||||
sysFile.setFileSize(humanReadableSize);
|
||||
sysFile.setId(StringUtils.randomUUID());
|
||||
fileList.add(sysFile);
|
||||
}
|
||||
//TODO 调用算法进行照片评估
|
||||
if(fileList.size()!=multipartFile.length){
|
||||
return AjaxResult.error("文件上传失败!");
|
||||
}
|
||||
mapper.addUpLoadImage(fileList,vo.getId(),createTime,"2");
|
||||
}
|
||||
//TODO 调用算法识别 ,然后进行图片更换
|
||||
List<ImageRecognize> list= algorithmService.getImageRecognizeList(fileList,operaName);
|
||||
for (ImageRecognize sysFile : list) {
|
||||
mapper.addImageRecognize(sysFile);
|
||||
//更新标记的数量 和未标记的数量,同时更新 标记图片地址//
|
||||
for (ImageRecognize imageRecognize : list) {
|
||||
mapper.addImageRecognize(imageRecognize);
|
||||
}
|
||||
|
||||
// 查询数据历史集合
|
||||
|
|
@ -226,18 +224,20 @@ public class ImageCaptionServiceImpl implements ImageCaptionService {
|
|||
//查询 每次历史的 图片集合
|
||||
List<UploadFileVo> fileVoList=mapper.getImageListDetailsHistory(userOperaVo2);
|
||||
for (UploadFileVo obj : fileVoList) {
|
||||
String url=minioUtil.getFileUrl(obj.getBucketName(),obj.getBjFilePath(),60*60*7);
|
||||
String url=minioUtil.getFileUrl(obj.getBucketName(),obj.getFilePath(),60*60*7);
|
||||
obj.setBjUrl(url);
|
||||
}
|
||||
userOperaVo2.setFileVoList(fileVoList);
|
||||
}
|
||||
return AjaxResult.success(hisImageList);
|
||||
return AjaxResult.success(hisImageList);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
return AjaxResult.error("操作失败");
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询 图片数据结婚
|
||||
* @param vo
|
||||
|
|
|
|||
|
|
@ -74,12 +74,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getImageListHistory" resultType="com.bonus.business.domain.UserOperaVo">
|
||||
select tam.id, tam.oper_type, tam.name operaName,
|
||||
select tam.id, tam.oper_type, tam.name operaName,tam.oper_id operaId,
|
||||
tam.create_time operaTime, tam.user_id , tam.oper_type,
|
||||
tam.image_num imageNum ,tam.bz_num bzNum,tam.wbz_num wbzNum,tam.is_sure isSure
|
||||
from tb_algorithm tam
|
||||
where tam.oper_type=#{operaType}
|
||||
and tam.user_id=#{userId} and tam.oper_id=#{id}
|
||||
where tam.oper_id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getImageListDetails" resultType="com.bonus.file.vo.UploadFileVo">
|
||||
|
|
|
|||
|
|
@ -101,19 +101,22 @@ public class MinioUtil {
|
|||
public SysFile uploadFile(MultipartFile file, String folderPath) throws Exception {
|
||||
|
||||
if (file.getSize() < 10 * 1024 * 1024L) {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(minioConfig.getBucketName())
|
||||
.object(folderPath)
|
||||
// -1 表示不限制文件大小
|
||||
.stream(file.getInputStream(), file.getInputStream().available(), -1)
|
||||
.stream(inputStream, inputStream.available(), -1)
|
||||
.contentType(file.getContentType())
|
||||
.build());
|
||||
inputStream.close();
|
||||
} else {
|
||||
uploadLargeFile(folderPath, file);
|
||||
}
|
||||
|
||||
return SysFile.builder()
|
||||
.name(file.getOriginalFilename())
|
||||
.bucketName(minioConfig.getBucketName())
|
||||
.url(folderPath).build();
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +133,6 @@ public class MinioUtil {
|
|||
List<String> partNames = new ArrayList<>();
|
||||
// 创建线程池
|
||||
ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
|
||||
// 上传每个分片
|
||||
|
|
@ -147,7 +149,9 @@ public class MinioUtil {
|
|||
|
||||
// 异步上传每个分片
|
||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||
try (InputStream inputStream = file.getInputStream()) { // 获取文件的输入流
|
||||
try {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
// 获取文件的输入流
|
||||
// 跳过文件前面的部分,直到当前分片的起始位置
|
||||
long skipped = inputStream.skip(partOffset);
|
||||
if (skipped != partOffset) {
|
||||
|
|
@ -169,11 +173,12 @@ public class MinioUtil {
|
|||
.build());
|
||||
System.out.println("Uploaded part: " + partName);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error uploading part: " + partName, e);
|
||||
}
|
||||
}, executor); // 指定使用线程池执行任务
|
||||
|
||||
futures.add(future); // 将任务添加到 futures 列表
|
||||
}
|
||||
|
||||
|
|
@ -379,12 +384,13 @@ public class MinioUtil {
|
|||
@SneakyThrows(Exception.class)
|
||||
public String getFileUrl(String bucketName, String objectName, int expiryTimeInSeconds) {
|
||||
try{
|
||||
return minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
||||
String url =minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
.expiry(expiryTimeInSeconds)
|
||||
.method(Method.GET)
|
||||
.build());
|
||||
return url;
|
||||
}catch (Exception e){
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue