From 30ea6eb0fbf704f8ddb794eb687d4ca527e9673a Mon Sep 17 00:00:00 2001 From: wuzhuorong <973204353@qq.com> Date: Wed, 10 Jun 2026 14:37:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=E8=A1=A5=E5=85=85YOLOv8=E7=9A=84?= =?UTF-8?q?=E6=89=93=E6=9E=B6=E6=96=97=E6=AE=B4=E6=A8=A1=E5=9E=8BWeb?= =?UTF-8?q?=E5=92=8CVue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/api/detection.js | 20 ++ apps/web/src/components/ImageDetection.vue | 362 ++++++++++++++++++++- 2 files changed, 368 insertions(+), 14 deletions(-) diff --git a/apps/web/src/api/detection.js b/apps/web/src/api/detection.js index 7653011..e1715d6 100644 --- a/apps/web/src/api/detection.js +++ b/apps/web/src/api/detection.js @@ -10,6 +10,12 @@ const dockerApi = axios.create({ timeout: 120000 }) +// 视频检测专用,超时更长 +const videoApi = axios.create({ + baseURL: '/api', + timeout: 300000 +}) + export const detectionApi = { getModels() { return api.get('/models') @@ -39,5 +45,19 @@ export const detectionApi = { 'Content-Type': 'multipart/form-data' } }) + }, + + // 本地 YOLO 视频检测(打架斗殴检测等) + detectLocalVideo(formData, modelId = 'fight_detection', confidence = 0.5, iou = 0.45) { + return videoApi.post('/detect/video', formData, { + headers: { + 'Content-Type': 'multipart/form-data' + }, + params: { + model_id: modelId, + confidence, + iou + } + }) } } diff --git a/apps/web/src/components/ImageDetection.vue b/apps/web/src/components/ImageDetection.vue index 3bab4c3..44c757f 100644 --- a/apps/web/src/components/ImageDetection.vue +++ b/apps/web/src/components/ImageDetection.vue @@ -39,13 +39,13 @@ :on-error="handleUploadError" :before-upload="beforeUpload" :show-file-list="false" - :accept="isActionDetection ? 'video/*' : 'image/*'" + :accept="supportsVideoUpload ? 'image/*,video/*' : 'image/*'" :disabled="isDetecting" class="header-upload" > - {{ resultImage || resultVideo ? '上传新文件' : (isActionDetection ? '上传视频' : '上传图片') }} + {{ resultImage || resultVideo ? '上传新文件' : (supportsVideoUpload ? '上传图片/视频' : '上传图片') }} @@ -53,31 +53,39 @@
检测结果 - -
+ +
@@ -136,8 +144,80 @@
- - + + + +
+
+ +
+ {{ kf.timestamp }}s + #{{ kf.frame_index }} +
+
+ + {{ det.label }} {{ (det.confidence * 100).toFixed(0) }}% + + + +{{ kf.detections.length - 2 }} + +
+
+
+
+ + + + + + + + + + + + + + + + + +