|
@@ -44,74 +44,77 @@ public class AiServiceImpl implements IAiService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void detectScenePano(ScenePlus scenePlus, ScenePlusExt scenePlusExt, String path) {
|
|
public void detectScenePano(ScenePlus scenePlus, ScenePlusExt scenePlusExt, String path) {
|
|
|
|
+ try {
|
|
|
|
+ String resultsPath = path + File.separator + "results" + File.separator;
|
|
|
|
+ String highPath = resultsPath + "high" + File.separator;
|
|
|
|
+ String aiWorkPath = highPath + "ai" + File.separator;
|
|
|
|
+ List<File> highImgs = FileUtil.loopFiles(highPath);
|
|
|
|
+ if(CollUtil.isEmpty(highImgs)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- String resultsPath = path + File.separator + "results" + File.separator;
|
|
|
|
- String highPath = resultsPath + "high" + File.separator;
|
|
|
|
- String aiWorkPath = highPath + "ai" + File.separator;
|
|
|
|
- List<File> highImgs = FileUtil.loopFiles(highPath);
|
|
|
|
- if(CollUtil.isEmpty(highImgs)){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (File file : highImgs) {
|
|
|
|
- String absolutePath = file.getAbsolutePath();
|
|
|
|
- try {
|
|
|
|
- String name = FileUtil.getName(absolutePath);
|
|
|
|
- String prefix = FileUtil.getPrefix(name);
|
|
|
|
- String outPath = aiWorkPath + prefix + File.separator;
|
|
|
|
- String detectPath = outPath + "detect.json";
|
|
|
|
- String cutImagesPath = outPath + "cut_images";
|
|
|
|
- if(!ComputerUtil.checkComputeCompleted(detectPath, 5, 200)){
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- SceneMarkShape sceneMarkShape = readDetectJson(detectPath);
|
|
|
|
- if (ObjectUtil.isNotNull(sceneMarkShape)){
|
|
|
|
- sceneMarkShape.setNum(scenePlus.getNum());
|
|
|
|
- SceneMarkShape shape = sceneMarkShapeService.findByNumAndImagePathAndType(scenePlus.getNum(), sceneMarkShape.getImagePath(), DetectType.PANO.getCode());
|
|
|
|
- if (ObjectUtil.isNotNull(shape)){
|
|
|
|
- sceneMarkShape.setId(shape.getId());
|
|
|
|
- sceneMarkShape.setUpdateTime(new Date());
|
|
|
|
- sceneMarkShapeService.updateById(sceneMarkShape);
|
|
|
|
- }else {
|
|
|
|
- sceneMarkShape.setCreateTime(new Date());
|
|
|
|
- sceneMarkShape.setType(DetectType.PANO.getCode());
|
|
|
|
- sceneMarkShapeService.save(sceneMarkShape);
|
|
|
|
|
|
+ for (File file : highImgs) {
|
|
|
|
+ String absolutePath = file.getAbsolutePath();
|
|
|
|
+ try {
|
|
|
|
+ String name = FileUtil.getName(absolutePath);
|
|
|
|
+ String prefix = FileUtil.getPrefix(name);
|
|
|
|
+ String outPath = aiWorkPath + prefix + File.separator;
|
|
|
|
+ String detectPath = outPath + "detect.json";
|
|
|
|
+ String cutImagesPath = outPath + "cut_images";
|
|
|
|
+ if(!ComputerUtil.checkComputeCompleted(detectPath, 5, 200)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ SceneMarkShape sceneMarkShape = readDetectJson(detectPath);
|
|
|
|
+ if (ObjectUtil.isNotNull(sceneMarkShape)){
|
|
|
|
+ sceneMarkShape.setNum(scenePlus.getNum());
|
|
|
|
+ SceneMarkShape shape = sceneMarkShapeService.findByNumAndImagePathAndType(scenePlus.getNum(), sceneMarkShape.getImagePath(), DetectType.PANO.getCode());
|
|
|
|
+ if (ObjectUtil.isNotNull(shape)){
|
|
|
|
+ sceneMarkShape.setId(shape.getId());
|
|
|
|
+ sceneMarkShape.setUpdateTime(new Date());
|
|
|
|
+ sceneMarkShapeService.updateById(sceneMarkShape);
|
|
|
|
+ }else {
|
|
|
|
+ sceneMarkShape.setCreateTime(new Date());
|
|
|
|
+ sceneMarkShape.setType(DetectType.PANO.getCode());
|
|
|
|
+ sceneMarkShapeService.save(sceneMarkShape);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (FileUtil.exist(cutImagesPath)){
|
|
|
|
+ //上传这个文件夹所有的文件
|
|
|
|
+ List<File> files = FileUtil.loopFiles(cutImagesPath);
|
|
|
|
+ String keyPath = String.format(UploadFilePath.IMG_VIEW_PATH, scenePlus.getNum()) + "cut_images/";
|
|
|
|
+ files.forEach(v -> fYunFileService.uploadFile(v.getAbsolutePath(),keyPath+v.getName()));
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (FileUtil.exist(cutImagesPath)){
|
|
|
|
- //上传这个文件夹所有的文件
|
|
|
|
- List<File> files = FileUtil.loopFiles(cutImagesPath);
|
|
|
|
- String keyPath = String.format(UploadFilePath.IMG_VIEW_PATH, scenePlus.getNum()) + "cut_images/";
|
|
|
|
- files.forEach(v -> fYunFileService.uploadFile(v.getAbsolutePath(),keyPath+v.getName()));
|
|
|
|
- }
|
|
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
- log.error("ai识别报错,inPath:{}", absolutePath, e);
|
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("ai识别报错,inPath:{}", absolutePath, e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- //生成ai.json
|
|
|
|
- List<SceneMarkShape> sceneMarkShapes = sceneMarkShapeService.findByNumAndType(scenePlus.getNum(), DetectType.PANO.getCode());
|
|
|
|
- if(CollUtil.isNotEmpty(sceneMarkShapes)){
|
|
|
|
- for (SceneMarkShape sceneMarkShape : sceneMarkShapes) {
|
|
|
|
- if (ObjectUtil.isNotEmpty(sceneMarkShape.getShapes())){
|
|
|
|
- for (JSONObject shape : sceneMarkShape.getShapes()) {
|
|
|
|
- String category = shape.getString("category");
|
|
|
|
- SceneShapeEnum sceneShapeEnum = sceneShapeEnumService.findByClassName(category);
|
|
|
|
- if (ObjectUtil.isNotNull(sceneShapeEnum)){
|
|
|
|
- shape.put("name",sceneShapeEnum.getName());
|
|
|
|
- }
|
|
|
|
- if (category.contains("Tag_")){
|
|
|
|
- shape.put("category","Tag");
|
|
|
|
|
|
+ //生成ai.json
|
|
|
|
+ List<SceneMarkShape> sceneMarkShapes = sceneMarkShapeService.findByNumAndType(scenePlus.getNum(), DetectType.PANO.getCode());
|
|
|
|
+ if(CollUtil.isNotEmpty(sceneMarkShapes)){
|
|
|
|
+ for (SceneMarkShape sceneMarkShape : sceneMarkShapes) {
|
|
|
|
+ if (ObjectUtil.isNotEmpty(sceneMarkShape.getShapes())){
|
|
|
|
+ for (JSONObject shape : sceneMarkShape.getShapes()) {
|
|
|
|
+ String category = shape.getString("category");
|
|
|
|
+ SceneShapeEnum sceneShapeEnum = sceneShapeEnumService.findByClassName(category);
|
|
|
|
+ if (ObjectUtil.isNotNull(sceneShapeEnum)){
|
|
|
|
+ shape.put("name",sceneShapeEnum.getName());
|
|
|
|
+ }
|
|
|
|
+ if (category.contains("Tag_")){
|
|
|
|
+ shape.put("category","Tag");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- String ajJsonKey = String.format(UploadFilePath.IMG_VIEW_PATH, scenePlus.getNum()) + "ai.json";
|
|
|
|
- fYunFileService.uploadFile(JSON.toJSONString(sceneMarkShapes).getBytes(StandardCharsets.UTF_8), ajJsonKey);
|
|
|
|
|
|
+ String ajJsonKey = String.format(UploadFilePath.IMG_VIEW_PATH, scenePlus.getNum()) + "ai.json";
|
|
|
|
+ fYunFileService.uploadFile(JSON.toJSONString(sceneMarkShapes).getBytes(StandardCharsets.UTF_8), ajJsonKey);
|
|
|
|
|
|
- scenePlusExt.setHasAi(CommonStatus.YES.code().intValue());
|
|
|
|
|
|
+ scenePlusExt.setHasAi(CommonStatus.YES.code().intValue());
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("ai识别出错,num:{}", scenePlus.getNum());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|