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"
>
视频播放失败
+浏览器无法解码该视频,可能是编码格式不兼容。
+请查看下方的「关键帧截图」直观查看打架画面。
+正在进行打架检测...
-请稍候,视频检测可能需要几秒钟
+正在进行打架斗殴检测...
+请稍候,视频检测可能需要较长时间
请上传视频进行检测
-支持 MP4、AVI 等格式
+请上传图片或视频进行检测
+支持图片 (JPG/PNG) 和视频 (MP4/AVI) 格式