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