对接前端和py接口SegAnything

This commit is contained in:
litianxiang
2026-01-14 13:31:33 +08:00
parent 71211bfbc3
commit 112e9c3bc9
3 changed files with 62 additions and 0 deletions

View File

@@ -23,6 +23,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jakarta.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collections;
@@ -119,4 +122,14 @@ public class PythonController {
return Response.success(superResolutionService.prepareForSR(superResolutionDTO));
}
@CrossOrigin
@Operation(summary = "Seg Anything 转发接口")
@PostMapping("/segAnything")
public Response<JSONObject> segAnything(@RequestBody Map<String, Object> payload) {
// 将前端传来的 Map 转为 fastjson JSONObject 并转发给 python 服务
JSONObject requestJson = (JSONObject) JSON.toJSON(payload);
JSONObject result = pythonService.segAnything(requestJson);
return Response.success(result);
}
}