|
@@ -1,6 +1,12 @@
|
|
|
package com.taais.biz.controller;
|
|
|
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.util.Base64;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import com.taais.biz.domain.bo.VideoStableStartBo;
|
|
|
import com.taais.biz.domain.bo.VideoStableStartResultBo;
|
|
@@ -8,6 +14,7 @@ import jakarta.validation.Valid;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import com.taais.common.core.core.domain.CommonResult;
|
|
@@ -23,6 +30,8 @@ import com.taais.biz.service.IVideoStableService;
|
|
|
|
|
|
import com.taais.common.core.core.page.PageResult;
|
|
|
|
|
|
+import static com.taais.biz.constant.BizConstant.UPLOAD_DIR;
|
|
|
+
|
|
|
/**
|
|
|
* 视频去抖动Controller
|
|
|
*
|
|
@@ -37,6 +46,32 @@ public class VideoStableController extends BaseController {
|
|
|
@Resource
|
|
|
private IVideoStableService videoStableService;
|
|
|
|
|
|
+ @GetMapping("/compare/{task_name}/{idx}")
|
|
|
+ public ResponseEntity<Map<String, String>> getCompareImages(@PathVariable("task_name") String taskName, @PathVariable("idx") int idx) {
|
|
|
+ try {
|
|
|
+ Path baseDir = Paths.get(UPLOAD_DIR, taskName);
|
|
|
+ // 读取两张图片
|
|
|
+ System.out.println(baseDir.resolve("images/" + String.format("%05d", idx) + ".jpg").toString());
|
|
|
+ byte[] image1 = Files.readAllBytes(baseDir.resolve("images/" + String.format("%05d", idx) + ".jpg"));
|
|
|
+ byte[] image2 = Files.readAllBytes(baseDir.resolve("stable/" + String.format("%05d", idx) + ".jpg"));
|
|
|
+
|
|
|
+ // 将图片编码成Base64字符串
|
|
|
+ String base64Image1 = Base64.getEncoder().encodeToString(image1);
|
|
|
+ String base64Image2 = Base64.getEncoder().encodeToString(image2);
|
|
|
+
|
|
|
+ // 创建一个Map来存储Base64编码的图片
|
|
|
+ Map<String, String> images = new HashMap<>();
|
|
|
+ images.put("origin", base64Image1);
|
|
|
+ images.put("stable", base64Image2);
|
|
|
+
|
|
|
+ // 返回Map
|
|
|
+ return ResponseEntity.ok(images);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return ResponseEntity.status(500).build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/get_result")
|
|
|
public CommonResult getResult(@Valid @RequestBody VideoStableStartResultBo videoStableStartResultBo) {
|
|
|
return videoStableService.getResult(videoStableStartResultBo);
|