فهرست منبع

feat: 轨迹追踪功能修正

WANGKANG 9 ماه پیش
والد
کامیت
6610eca0fc

+ 15 - 9
taais-modules/taais-biz/src/main/java/com/taais/biz/constant/BizConstant.java

@@ -7,10 +7,16 @@ public class BizConstant {
     // 视频文件存储目录
     public static final String UPLOAD_DIR = "uploads/";
 
+    public static class SubSystem {
+        public static final String  ToInfrared = "0";
+        public static final String  TargetDetection = "1";
+        public static final String TrackSequence = "2";
+    }
+
     public static class AlgorithmType {
-            public static final String TRAIN = "0";
-            public static final String TEST = "1";
-            public static final String REASONING = "2";
+        public static final String TRAIN = "0";
+        public static final String TEST = "1";
+        public static final String REASONING = "2";
     }
 
     public class VideoStatus {
@@ -34,10 +40,10 @@ public class BizConstant {
 
     public static final String TASK_FOLDER_PATH_TRAIL_EXPANSION = "/expansion/";
 
-    public static final String TASK_FOLDER_PATH_TRAIL_RESULT= "/result/";
+    public static final String TASK_FOLDER_PATH_TRAIL_RESULT = "/result/";
 
-    public static final String TASK_FOLDER_PATH_LOG= "log/";
-    public static final String TASK_FOLDER_LOG_PATH= TASK_FOLDER_PATH_LOG+"log.log";
+    public static final String TASK_FOLDER_PATH_LOG = "log/";
+    public static final String TASK_FOLDER_LOG_PATH = TASK_FOLDER_PATH_LOG + "log.log";
     public static final String IMAGE = "images/";
     public static final String LABEL = "labels/";
 
@@ -77,7 +83,7 @@ public class BizConstant {
     public static final String R_CURVE = "R_curve.png";
     public static final String P_CURVE = "P_curve.png";
     public static final String F1_CURVE = "F1_curve.png";
-    public static final String ORIGINAL_IMAGE= "原始图片";
-    public static final String DOCKER_BASE_PATH= "/home/ObjectDetection_Web";
-    public static final String DOCKER_PT_PATH= "weights/best.pt";
+    public static final String ORIGINAL_IMAGE = "原始图片";
+    public static final String DOCKER_BASE_PATH = "/home/ObjectDetection_Web";
+    public static final String DOCKER_PT_PATH = "weights/best.pt";
 }

+ 1 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/TrackSequence.java

@@ -74,5 +74,5 @@ private static final long serialVersionUID = 1L;
     /** zip文件输出路径 */
     private String zipFilePath;
 
-
+    private Long algorithmModelId;
 }

+ 1 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/bo/TrackSequenceBo.java

@@ -94,5 +94,5 @@ public class TrackSequenceBo extends BaseEntity{
      */
     private String zipFilePath;
 
-
+    private Long algorithmModelId;
 }

+ 1 - 1
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceImportVo.java

@@ -85,5 +85,5 @@ public class TrackSequenceImportVo implements Serializable
     @ExcelProperty(value = "zip文件输出路径")
     private String zipFilePath;
 
-
+    private Long algorithmModelId;
 }

+ 1 - 2
taais-modules/taais-biz/src/main/java/com/taais/biz/domain/vo/TrackSequenceVo.java

@@ -91,6 +91,5 @@ private static final long serialVersionUID = 1L;
     @ExcelProperty(value = "zip文件输出路径")
     private String zipFilePath;
 
-
-
+    private Long algorithmModelId;
 }

+ 56 - 9
taais-modules/taais-biz/src/main/java/com/taais/biz/service/impl/TrackSequenceServiceImpl.java

@@ -4,14 +4,16 @@ import java.io.File;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
 import com.taais.biz.constant.BizConstant;
-import com.taais.biz.domain.HttpResponseEntity;
-import com.taais.biz.domain.ToInfrared;
+import com.taais.biz.domain.*;
+import com.taais.biz.domain.vo.StartToInfraredTask;
+import com.taais.biz.utils.ZipUtils;
 import com.taais.common.core.config.TaaisConfig;
 import com.taais.common.core.constant.Constants;
 import com.taais.common.core.core.domain.CommonResult;
@@ -32,15 +34,14 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import com.taais.biz.mapper.TrackSequenceMapper;
-import com.taais.biz.domain.TrackSequence;
 import com.taais.biz.domain.bo.TrackSequenceBo;
 import com.taais.biz.domain.vo.TrackSequenceVo;
 import com.taais.biz.service.ITrackSequenceService;
 
 import static com.taais.biz.constant.BizConstant.VideoStatus.NOT_START;
 import static com.taais.biz.domain.table.TrackSequenceTableDef.TRACK_SEQUENCE;
-import static com.taais.biz.service.impl.VideoStableServiceImpl.removeFileExtension;
-import static com.taais.biz.service.impl.VideoStableServiceImpl.sendPostMsg;
+import static com.taais.biz.service.impl.VideoStableServiceImpl.*;
+import static com.taais.biz.service.impl.VideoStableServiceImpl.makeDir;
 
 /**
  * 注视轨迹序列Service业务层处理
@@ -57,6 +58,11 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
     @Value("${server.track_sequence_stop_url}")
     private String track_sequence_stop_url;
 
+    @Autowired
+    private AlgorithmConfigTrackServiceImpl algorithmConfigTrackService;
+    @Autowired
+    private AlgorithmModelTrackServiceImpl algorithmModelTrackService;
+
     @Autowired
     private ISysOssService ossService;
 
@@ -176,6 +182,8 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
         trackSequence.setStatus(NOT_START);
         trackSequence.setRemarks(trackSequenceBo.getRemarks());
 
+        trackSequence.setAlgorithmModelId(trackSequenceBo.getAlgorithmModelId());
+
         return this.save(trackSequence);// 使用全局配置的雪花算法主键生成器生成ID值
     }
 
@@ -211,13 +219,52 @@ public class TrackSequenceServiceImpl extends BaseServiceImpl<TrackSequenceMappe
     public CommonResult start(Long id) {
         TrackSequence trackSequence = getById(id);
 
-        HttpResponseEntity responseEntity = sendPostMsg(track_sequence_start_url, trackSequence);
+        SysOssVo inputOssEntity = ossService.getById(trackSequence.getInputOssId());
+
+        String filePath = inputOssEntity.getFileName();
+        String localPath = TaaisConfig.getProfile();
+        String resourcePath = localPath + StringUtils.substringAfter(filePath, Constants.RESOURCE_PREFIX);
+
+        String fileName = StringUtils.substringAfterLast(filePath, "/");
+        String fileName_without_suffix = removeFileExtension(fileName);
+
+        Path path = Paths.get(resourcePath);
+        Path inputPath = path.resolveSibling(fileName_without_suffix + "_images");
+        Path outputPath = path.resolveSibling(fileName_without_suffix + "_to_infrared");
+
+        makeDir(inputPath.toString());
+        makeDir(outputPath.toString());
+
+        ZipUtils.unzip(resourcePath, inputPath.toString());
+
+        trackSequence.setInputPath(inputPath.toString());
+        trackSequence.setOutputPath(outputPath.toString());
+
+        trackSequence.setStartTime(new Date());
+
+        AlgorithmModelTrack algorithmModelTrack = algorithmModelTrackService.getById(trackSequence.getAlgorithmModelId());
+        AlgorithmConfigTrack algorithmConfigTrack = algorithmConfigTrackService.getById(algorithmModelTrack.getAlgorithmId());
+
+        StartToInfraredTask startToInfraredTask = new StartToInfraredTask();
+        startToInfraredTask.setBizId(trackSequence.getId());
+
+        // if (algorithmConfigTrack.getType() == AlgorithmType.TRAIN) {
+        startToInfraredTask.setModel_path(algorithmModelTrack.getModelAddress());
+        // }
+
+        startToInfraredTask.setOtherParams(algorithmConfigTrack.getParameterConfig());
+        startToInfraredTask.setSource_dir(trackSequence.getInputPath());
+        startToInfraredTask.setResult_dir(trackSequence.getOutputPath());
+
+        HttpResponseEntity responseEntity = sendPostMsg(algorithmConfigTrack.getAlgorithmAddress(), startToInfraredTask);
         if (ObjectUtil.isNotNull(responseEntity) && responseEntity.getStatus() == 200) {
-            trackSequence.setStatus(BizConstant.VideoStatus.INTERRUPTED);
+            trackSequence.setStatus(BizConstant.VideoStatus.RUNNING);
             updateById(trackSequence);
-            return CommonResult.fail("开始任务成功");
+            return CommonResult.success("任务开始成功,请等待完成");
         } else {
-            return CommonResult.fail("开始任务失败");
+            trackSequence.setStatus(BizConstant.VideoStatus.FAILED);
+            updateById(trackSequence);
+            return CommonResult.fail("任务开始失败,请检查!");
         }
     }