diff --git a/src/api/aiAnalysis.ts b/src/api/aiAnalysis.ts index 2b182da..5c5367e 100644 --- a/src/api/aiAnalysis.ts +++ b/src/api/aiAnalysis.ts @@ -1,15 +1,15 @@ import request from '../request'; // 检测服务 Base URL -const DETECT_BASE = 'http://50.50.50.117:10101'; +const DETECT_BASE = 'http://47.100.102.7:10101'; // 热成像分割服务 Base URL -const SEGMENT_BASE = 'http://50.50.50.117:10102'; +const SEGMENT_BASE = 'http://47.100.102.7:10102'; /** * 获取检测模型列表 */ export function getDetectModels() { - return fetch(`${DETECT_BASE}/api/v1/detect/models`).then(res => res.json()); + return fetch(`${DETECT_BASE}/api/v1/detect/models`).then(res => res.json()); } /** @@ -17,24 +17,24 @@ export function getDetectModels() { * @param formData 包含 files, inputType, modelAlias, conf, iou, imgsz, device, maxDet, vidStride */ export function submitDetectJob(formData: FormData) { - return fetch(`${DETECT_BASE}/api/v1/detect/jobs`, { - method: 'POST', - body: formData - }).then(res => res.json()); + return fetch(`${DETECT_BASE}/api/v1/detect/jobs`, { + method: 'POST', + body: formData + }).then(res => res.json()); } /** * 查询检测任务状态 */ export function getDetectJobStatus(jobId: string) { - return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}`).then(res => res.json()); + return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}`).then(res => res.json()); } /** * 查询检测结果 */ export function getDetectJobResult(jobId: string) { - return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}/result`).then(res => res.json()); + return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}/result`).then(res => res.json()); } /** @@ -42,15 +42,15 @@ export function getDetectJobResult(jobId: string) { * @param formData 包含 thermal_file, array_mask_file, panel_geojson_file, threshold_c, min_area_px, max_regions, open_k, close_k, shrink_in, include_panel_segments */ export function submitSegmentationAnalyze(formData: FormData) { - return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyze`, { - method: 'POST', - body: formData - }).then(res => res.json()); + return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyze`, { + method: 'POST', + body: formData + }).then(res => res.json()); } /** * 获取热成像分析报告历史 */ export function getSegmentationHistory() { - return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyses/report`).then(res => res.json()); + return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyses/report`).then(res => res.json()); } diff --git a/src/pages/Agri.jsx b/src/pages/Agri.jsx index f48fef8..6e1f7ec 100644 --- a/src/pages/Agri.jsx +++ b/src/pages/Agri.jsx @@ -66,6 +66,8 @@ export default function Agri() { speedPreset: 'speed' }); const [detectFiles, setDetectFiles] = useState([]); + const [selectedHotspot, setSelectedHotspot] = useState(null); + const [detectJobId, setDetectJobId] = useState(null); const [detectStatus, setDetectStatus] = useState(null); const [detectResult, setDetectResult] = useState(null); @@ -119,6 +121,7 @@ export default function Agri() { const formData = new FormData(); detectFiles.forEach(file => { + console.log(file, "dsdsvc") formData.append('files', file.originFileObj); }); formData.append('inputType', detectForm.inputType); @@ -440,10 +443,12 @@ export default function Agri() {
setDetectFiles(info.fileList)} + onChange={info => { + setDetectFiles(info.fileList.slice(-1)); + }} beforeUpload={() => false} + limit={1} style={{ background: '#fafafa', borderRadius: 8 }} >

@@ -560,10 +565,100 @@ export default function Agri() {

); - // 渲染结果展示 - const renderResults = () => { - const result = activeAlgo === 'detect' ? detectResult : segResult; - const inputFiles = activeAlgo === 'detect' ? detectFiles : (thermalFile ? [thermalFile] : []); + // 1. 目标检测的结果布局(第一张图的样式:三列) + const renderDetectResultLayout = () => { + const inputFile = detectFiles[0]; + const hasResult = !!detectResult; + + return ( + 结果展示} + bordered={false} + style={{ marginTop: 12, borderRadius: 8 }} + bodyStyle={{ padding: '12px' }} + > + + 原始预览、结果图与完整 JSON 同屏查看 + + + {/* 输入预览 */} + + +
+ {inputFile && ( + detectForm.inputType === 'image' ? ( + input + ) : ( +
+
+ + + {/* 结果图/视频 */} + + + +
+ {hasResult ? ( + detectForm.inputType === 'image' ? ( + result + ) : ( +
+
+ + + {/* 结果JSON */} + + +
+ {hasResult ? ( +
{JSON.stringify(detectResult, null, 2)}
+ ) : ( + 暂无结果 + )} +
+
+ +
+
+ ); + }; + + // 2. 热成像分割的结果布局(第二张图的样式:两列) + // 2. 热成像分割的结果布局(第二张图的样式:两列 + 热点交互) + const renderSegResultLayout = () => { + const hasResult = !!segResult; + const inputFile = thermalFile; + const hotspots = segResult?.hotspots || []; + const panels = segResult?.panel_overview || []; + + // 选中的点位详情 + const selectedPoint = selectedHotspot + ? hotspots.find(h => h.hotspot_id === selectedHotspot) + : null; return ( - {activeAlgo === 'segmentation' && segResult && ( -
- - - - - - - - - - - - - - - - - - - - - - -
- )} + {/* 顶部统计卡片 */} +
+ 热成像交互分析视图 + 点击热点或面板查看温度、块号、GPS 与像素溯源信息 + + + + + + + + + + + + + + + + + + + + + + + + + +
- -
- {result ? ( - activeAlgo === 'detect' ? ( - detectForm.inputType === 'image' ? ( - result - ) : ( -