refactor: 重构图片检测功能,拆分组件并优化返回格式
1. 后端api修改:将图片结果返回从文件路径改为base64格式,移除本地文件存储 2. 新增图片检测组件ImageDetection.vue,封装独立的图片检测UI逻辑 3. 重构Home页面,使用tab切换图片/视频检测模块,简化原有布局 4. 更新web包名与rollup依赖版本
This commit is contained in:
@@ -37,17 +37,16 @@ async def detect_image(
|
|||||||
if result['success']:
|
if result['success']:
|
||||||
annotated_frame = detection_service.draw_detections(frame, result['detections'])
|
annotated_frame = detection_service.draw_detections(frame, result['detections'])
|
||||||
|
|
||||||
import uuid
|
# 将标注后的图片转换为 base64
|
||||||
result_filename = f"result_{uuid.uuid4().hex[:8]}.jpg"
|
_, buffer = cv2.imencode('.jpg', annotated_frame)
|
||||||
result_path = f"static/results/{result_filename}"
|
img_base64 = base64.b64encode(buffer).decode('utf-8')
|
||||||
cv2.imwrite(result_path, annotated_frame)
|
|
||||||
|
|
||||||
return ImageDetectionResult(
|
return ImageDetectionResult(
|
||||||
success=True,
|
success=True,
|
||||||
message="检测完成",
|
message="检测完成",
|
||||||
data={
|
data={
|
||||||
"detections": result['detections'],
|
"detections": result['detections'],
|
||||||
"image_url": f"/static/results/{result_filename}",
|
"image_base64": img_base64,
|
||||||
"stats": result['stats']
|
"stats": result['stats']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
673
apps/web/src/components/ImageDetection.vue
Normal file
673
apps/web/src/components/ImageDetection.vue
Normal file
@@ -0,0 +1,673 @@
|
|||||||
|
<template>
|
||||||
|
<div class="image-detection-container">
|
||||||
|
<!-- 左侧配置面板 -->
|
||||||
|
<div class="left-panel" :style="{ width: leftPanelWidth + 'px' }">
|
||||||
|
<el-card class="config-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<el-icon class="header-icon"><Setting /></el-icon>
|
||||||
|
<span>图片检测配置</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-form label-position="top" class="config-form">
|
||||||
|
<el-form-item label="选择模型">
|
||||||
|
<el-select
|
||||||
|
v-model="config.model"
|
||||||
|
placeholder="选择检测模型"
|
||||||
|
class="full-width"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="model in models"
|
||||||
|
:key="model.id"
|
||||||
|
:label="model.name"
|
||||||
|
:value="model.id"
|
||||||
|
>
|
||||||
|
<span>{{ model.name }}</span>
|
||||||
|
<span class="model-size">{{ model.size }}</span>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<template #label>
|
||||||
|
<span>置信度阈值</span>
|
||||||
|
<el-tooltip placement="top" :show-after="200">
|
||||||
|
<template #content>
|
||||||
|
<div style="max-width: 300px; line-height: 1.6;">
|
||||||
|
<p><strong>置信度是什么?</strong></p>
|
||||||
|
<p>表示模型对检测结果的"确定程度",范围 0-1</p>
|
||||||
|
<ul style="margin: 8px 0; padding-left: 16px;">
|
||||||
|
<li>大于等于0.8:高置信度(绿色)- 模型非常确定</li>
|
||||||
|
<li>0.6-0.8:中等置信度(黄色)- 模型比较确定</li>
|
||||||
|
<li>小于0.6:低置信度(红色)- 模型不太确定</li>
|
||||||
|
</ul>
|
||||||
|
<p><strong>阈值作用:</strong></p>
|
||||||
|
<p>低于此值的检测结果会被过滤掉</p>
|
||||||
|
<p>建议:0.3-0.5(火灾检测可适当降低)</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-icon class="help-icon"><QuestionFilled /></el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<el-slider
|
||||||
|
v-model="config.confidence"
|
||||||
|
:min="0.1"
|
||||||
|
:max="1.0"
|
||||||
|
:step="0.05"
|
||||||
|
:format-tooltip="formatConfidence"
|
||||||
|
/>
|
||||||
|
<div class="slider-value">{{ config.confidence.toFixed(2) }}</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<template #label>
|
||||||
|
<span>IOU阈值</span>
|
||||||
|
<el-tooltip placement="top" :show-after="200">
|
||||||
|
<template #content>
|
||||||
|
<div style="max-width: 320px; line-height: 1.6;">
|
||||||
|
<p><strong>IOU是什么?</strong></p>
|
||||||
|
<p>交并比(Intersection Over Union),衡量两个检测框的重叠程度</p>
|
||||||
|
<p style="margin: 8px 0;"><strong>计算公式:</strong></p>
|
||||||
|
<p style=" padding: 4px 8px; border-radius: 4px; font-family: monospace;">IOU = 交集面积 / 并集面积</p>
|
||||||
|
<p style="margin: 8px 0;"><strong>阈值作用:</strong></p>
|
||||||
|
<p>用于NMS去重,IOU超过此值的框被认为是重复检测</p>
|
||||||
|
<ul style="margin: 8px 0; padding-left: 16px;">
|
||||||
|
<li>高阈值(0.7-0.9):保留更多框,适合密集场景</li>
|
||||||
|
<li>中阈值(0.45-0.6):平衡,适合一般场景</li>
|
||||||
|
<li>低阈值(0.1-0.3):结果更精简,适合稀疏场景</li>
|
||||||
|
</ul>
|
||||||
|
<p><strong>建议:0.45-0.6</strong></p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-icon class="help-icon"><QuestionFilled /></el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<el-slider
|
||||||
|
v-model="config.iou"
|
||||||
|
:min="0.1"
|
||||||
|
:max="0.9"
|
||||||
|
:step="0.05"
|
||||||
|
:format-tooltip="formatIOU"
|
||||||
|
/>
|
||||||
|
<div class="slider-value">{{ config.iou.toFixed(2) }}</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 拖拽调整条 -->
|
||||||
|
<div
|
||||||
|
class="resize-handle"
|
||||||
|
@mousedown="startResize"
|
||||||
|
:class="{ 'resizing': isResizing }"
|
||||||
|
>
|
||||||
|
<div class="resize-indicator"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 右侧展示区域 -->
|
||||||
|
<div class="right-panel" :style="{ width: `calc(100% - ${leftPanelWidth}px - 8px)` }">
|
||||||
|
<!-- 检测结果和统计信息并排 -->
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<!-- 检测结果区域 -->
|
||||||
|
<el-col :span="stats ? 16 : 24">
|
||||||
|
<el-card class="image-card result-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="header-left">
|
||||||
|
<el-icon class="header-icon"><View /></el-icon>
|
||||||
|
<span>检测结果</span>
|
||||||
|
</div>
|
||||||
|
<el-upload
|
||||||
|
:action="uploadUrl"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
:show-file-list="false"
|
||||||
|
accept="image/*"
|
||||||
|
class="header-upload"
|
||||||
|
>
|
||||||
|
<el-button type="primary" size="small">
|
||||||
|
<el-icon><UploadFilled /></el-icon>
|
||||||
|
<span>{{ resultImage ? '上传新图片' : '上传图片' }}</span>
|
||||||
|
</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="image-container">
|
||||||
|
<img
|
||||||
|
v-if="resultImage"
|
||||||
|
:src="resultImage"
|
||||||
|
class="display-image"
|
||||||
|
alt="检测结果"
|
||||||
|
/>
|
||||||
|
<div v-else class="empty-placeholder">
|
||||||
|
<el-icon class="empty-icon"><Picture /></el-icon>
|
||||||
|
<p class="empty-text">请上传图片进行检测</p>
|
||||||
|
<p class="empty-hint">支持 JPG、PNG、WEBP 格式</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<!-- 统计信息 -->
|
||||||
|
<el-col v-if="stats" :span="8">
|
||||||
|
<el-card class="stats-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<el-icon class="header-icon"><DataLine /></el-icon>
|
||||||
|
<span>检测统计</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="stats-content">
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">检测数量</div>
|
||||||
|
<el-tag size="large" type="primary">{{ stats.total_detections }} 个</el-tag>
|
||||||
|
</div>
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">平均置信度</div>
|
||||||
|
<el-tag size="large" :type="getConfidenceType(stats.avg_confidence)">
|
||||||
|
{{ stats.avg_confidence?.toFixed(2) }}
|
||||||
|
</el-tag>
|
||||||
|
</div>
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">处理时间</div>
|
||||||
|
<el-tag size="large" type="info">{{ stats.processing_time?.toFixed(2) }}s</el-tag>
|
||||||
|
</div>
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">使用模型</div>
|
||||||
|
<el-tag size="large" type="success">{{ modelName }}</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 检测详情 -->
|
||||||
|
<el-card v-if="detections.length > 0" class="details-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<el-icon class="header-icon"><List /></el-icon>
|
||||||
|
<span>检测详情</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-table :data="detections" border class="details-table">
|
||||||
|
<el-table-column prop="label" label="类别" min-width="120" />
|
||||||
|
<el-table-column prop="confidence" label="置信度" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag :type="getConfidenceType(scope.row.confidence)">
|
||||||
|
{{ scope.row.confidence }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="bbox" label="位置" min-width="200">
|
||||||
|
<template #default="scope">
|
||||||
|
<code class="bbox-code">[{{ scope.row.bbox.join(', ') }}]</code>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import {
|
||||||
|
UploadFilled,
|
||||||
|
Picture,
|
||||||
|
Document,
|
||||||
|
Setting,
|
||||||
|
View,
|
||||||
|
DataLine,
|
||||||
|
List,
|
||||||
|
QuestionFilled
|
||||||
|
} from '@element-plus/icons-vue'
|
||||||
|
import { detectionApi } from '@/api/detection'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
models: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const config = ref({
|
||||||
|
model: props.models.length > 0 ? props.models[0].id : 'fire_detection',
|
||||||
|
confidence: 0.5,
|
||||||
|
iou: 0.45
|
||||||
|
})
|
||||||
|
|
||||||
|
// 可拖拽调整宽度相关
|
||||||
|
const leftPanelWidth = ref(320)
|
||||||
|
const isResizing = ref(false)
|
||||||
|
const startX = ref(0)
|
||||||
|
const startWidth = ref(0)
|
||||||
|
|
||||||
|
const startResize = (e) => {
|
||||||
|
isResizing.value = true
|
||||||
|
startX.value = e.clientX
|
||||||
|
startWidth.value = leftPanelWidth.value
|
||||||
|
|
||||||
|
document.addEventListener('mousemove', handleResize)
|
||||||
|
document.addEventListener('mouseup', stopResize)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleResize = (e) => {
|
||||||
|
if (!isResizing.value) return
|
||||||
|
const delta = e.clientX - startX.value
|
||||||
|
const newWidth = startWidth.value + delta
|
||||||
|
leftPanelWidth.value = Math.max(280, Math.min(500, newWidth))
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopResize = () => {
|
||||||
|
isResizing.value = false
|
||||||
|
document.removeEventListener('mousemove', handleResize)
|
||||||
|
document.removeEventListener('mouseup', stopResize)
|
||||||
|
}
|
||||||
|
|
||||||
|
const originalImage = ref('')
|
||||||
|
const resultImage = ref('')
|
||||||
|
const detections = ref([])
|
||||||
|
const stats = ref(null)
|
||||||
|
const uploadUrl = computed(() => `/api/detect/image?model_id=${config.value.model}&confidence=${config.value.confidence}&iou=${config.value.iou}`)
|
||||||
|
|
||||||
|
const formatConfidence = (value) => {
|
||||||
|
return `置信度: ${value.toFixed(2)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatIOU = (value) => {
|
||||||
|
return `IOU: ${value.toFixed(2)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const beforeUpload = (file) => {
|
||||||
|
const isImage = file.type.startsWith('image/')
|
||||||
|
if (!isImage) {
|
||||||
|
ElMessage.error('只能上传图片文件')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
originalImage.value = URL.createObjectURL(file)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleUploadSuccess = (response) => {
|
||||||
|
console.log('Upload success response:', response)
|
||||||
|
if (response.success) {
|
||||||
|
// 使用 base64 图片数据
|
||||||
|
if (response.data.image_base64) {
|
||||||
|
resultImage.value = `data:image/jpeg;base64,${response.data.image_base64}`
|
||||||
|
console.log('Result image set, length:', response.data.image_base64.length)
|
||||||
|
} else {
|
||||||
|
console.error('No image_base64 in response:', response.data)
|
||||||
|
}
|
||||||
|
detections.value = response.data.detections || []
|
||||||
|
stats.value = response.data.stats
|
||||||
|
ElMessage.success('检测完成')
|
||||||
|
} else {
|
||||||
|
ElMessage.error(response.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getConfidenceType = (confidence) => {
|
||||||
|
if (!confidence && confidence !== 0) return 'info'
|
||||||
|
if (confidence >= 0.8) return 'success'
|
||||||
|
if (confidence >= 0.6) return 'warning'
|
||||||
|
return 'danger'
|
||||||
|
}
|
||||||
|
|
||||||
|
const modelName = computed(() => {
|
||||||
|
const model = props.models.find(m => m.id === config.value.model)
|
||||||
|
return model ? model.name : config.value.model
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.image-detection-container {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: calc(100vh - 100px);
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel {
|
||||||
|
flex-shrink: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel .config-card {
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 拖拽调整条 */
|
||||||
|
.resize-handle {
|
||||||
|
width: 8px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
cursor: col-resize;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: transparent;
|
||||||
|
transition: background 0.2s;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle:hover {
|
||||||
|
background: #d0d0d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle.resizing {
|
||||||
|
background: #409eff;
|
||||||
|
cursor: col-resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-indicator {
|
||||||
|
width: 3px;
|
||||||
|
height: 40px;
|
||||||
|
background: #c0c4cc;
|
||||||
|
border-radius: 2px;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle:hover .resize-indicator,
|
||||||
|
.resize-handle.resizing .resize-indicator {
|
||||||
|
background: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 卡片通用样式 */
|
||||||
|
:deep(.el-card) {
|
||||||
|
border-radius: 12px;
|
||||||
|
border: none;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-card__header) {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-bottom: 1px solid #e4e7ed;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 12px 12px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 卡片头部样式 */
|
||||||
|
.card-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-upload :deep(.el-upload) {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 配置卡片样式 */
|
||||||
|
.config-card {
|
||||||
|
height: auto;
|
||||||
|
max-height: calc(100vh - 100px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-card :deep(.el-card__body) {
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-form :deep(.el-form-item) {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-form :deep(.el-form-item__label) {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #303133;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 模型选择器 */
|
||||||
|
.model-size {
|
||||||
|
float: right;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滑块样式 */
|
||||||
|
.slider-value {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #409eff;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
background: #ecf5ff;
|
||||||
|
border-radius: 20px;
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 空状态占位区域 */
|
||||||
|
.empty-placeholder {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-icon {
|
||||||
|
font-size: 64px;
|
||||||
|
color: #dcdfe6;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #606266;
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-hint {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #909399;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 图片展示区域 */
|
||||||
|
.image-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-card :deep(.el-card__body) {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-container {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
min-height: 400px;
|
||||||
|
max-height: 600px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 0 0 12px 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.display-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder {
|
||||||
|
text-align: center;
|
||||||
|
color: #909399;
|
||||||
|
padding: 40px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder-icon {
|
||||||
|
font-size: 64px;
|
||||||
|
color: #dcdfe6;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder p {
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 统计卡片 */
|
||||||
|
.stats-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
height: calc(100% - 20px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #606266;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-item :deep(.el-tag) {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 详情卡片 */
|
||||||
|
.details-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-card :deep(.el-card__body) {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-table :deep(.el-table__header) {
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-table :deep(.el-table__header th) {
|
||||||
|
background: #f5f7fa;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bbox-code {
|
||||||
|
background: #f5f7fa;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 帮助图标样式 */
|
||||||
|
.help-icon {
|
||||||
|
margin-left: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #909399;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-icon:hover {
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式布局 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.image-detection-container {
|
||||||
|
flex-direction: column;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-card {
|
||||||
|
max-height: none;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-container {
|
||||||
|
aspect-ratio: 4 / 3;
|
||||||
|
min-height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-descriptions :deep(.el-descriptions__body) {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-descriptions :deep(.el-descriptions__cell) {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.image-container {
|
||||||
|
aspect-ratio: 1 / 1;
|
||||||
|
min-height: 180px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
932
apps/web/src/components/VideoDetection.vue
Normal file
932
apps/web/src/components/VideoDetection.vue
Normal file
@@ -0,0 +1,932 @@
|
|||||||
|
<template>
|
||||||
|
<div class="video-detection-container">
|
||||||
|
<!-- 左侧配置面板 -->
|
||||||
|
<div class="left-panel" :style="{ width: leftPanelWidth + 'px' }">
|
||||||
|
<el-card class="config-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<el-icon class="header-icon"><Setting /></el-icon>
|
||||||
|
<span>视频检测配置</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<el-form label-position="top" class="config-form">
|
||||||
|
<el-form-item label="选择模型">
|
||||||
|
<el-select
|
||||||
|
v-model="config.model"
|
||||||
|
placeholder="选择检测模型"
|
||||||
|
class="full-width"
|
||||||
|
@change="updateCameraConfig"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="model in models"
|
||||||
|
:key="model.id"
|
||||||
|
:label="model.name"
|
||||||
|
:value="model.id"
|
||||||
|
>
|
||||||
|
<span>{{ model.name }}</span>
|
||||||
|
<span class="model-size">{{ model.size }}</span>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<template #label>
|
||||||
|
<span>置信度阈值</span>
|
||||||
|
<el-tooltip placement="top" :show-after="200">
|
||||||
|
<template #content>
|
||||||
|
<div style="max-width: 300px; line-height: 1.6;">
|
||||||
|
<p><strong>置信度是什么?</strong></p>
|
||||||
|
<p>表示模型对检测结果的"确定程度",范围 0-1</p>
|
||||||
|
<ul style="margin: 8px 0; padding-left: 16px;">
|
||||||
|
<li>≥0.8:高置信度(绿色)- 模型非常确定</li>
|
||||||
|
<li>0.6-0.8:中等置信度(黄色)- 模型比较确定</li>
|
||||||
|
<li><0.6:低置信度(红色)- 模型不太确定</li>
|
||||||
|
</ul>
|
||||||
|
<p><strong>阈值作用:</strong></p>
|
||||||
|
<p>低于此值的检测结果会被过滤掉</p>
|
||||||
|
<p>建议:0.3-0.5(火灾检测可适当降低)</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-icon class="help-icon"><QuestionFilled /></el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<el-slider
|
||||||
|
v-model="config.confidence"
|
||||||
|
:min="0.1"
|
||||||
|
:max="1.0"
|
||||||
|
:step="0.05"
|
||||||
|
:format-tooltip="formatConfidence"
|
||||||
|
@change="updateCameraConfig"
|
||||||
|
/>
|
||||||
|
<div class="slider-value">{{ config.confidence.toFixed(2) }}</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item>
|
||||||
|
<template #label>
|
||||||
|
<span>IOU阈值</span>
|
||||||
|
<el-tooltip placement="top" :show-after="200">
|
||||||
|
<template #content>
|
||||||
|
<div style="max-width: 320px; line-height: 1.6;">
|
||||||
|
<p><strong>IOU是什么?</strong></p>
|
||||||
|
<p>交并比(Intersection Over Union),衡量两个检测框的重叠程度</p>
|
||||||
|
<p style="margin: 8px 0;"><strong>计算公式:</strong></p>
|
||||||
|
<p style="background: #f5f5f5; padding: 4px 8px; border-radius: 4px; font-family: monospace;">IOU = 交集面积 / 并集面积</p>
|
||||||
|
<p style="margin: 8px 0;"><strong>阈值作用:</strong></p>
|
||||||
|
<p>用于NMS去重,IOU超过此值的框被认为是重复检测</p>
|
||||||
|
<ul style="margin: 8px 0; padding-left: 16px;">
|
||||||
|
<li>高阈值(0.7-0.9):保留更多框,适合密集场景</li>
|
||||||
|
<li>中阈值(0.45-0.6):平衡,适合一般场景</li>
|
||||||
|
<li>低阈值(0.1-0.3):结果更精简,适合稀疏场景</li>
|
||||||
|
</ul>
|
||||||
|
<p><strong>建议:0.45-0.6</strong></p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-icon class="help-icon"><QuestionFilled /></el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<el-slider
|
||||||
|
v-model="config.iou"
|
||||||
|
:min="0.1"
|
||||||
|
:max="0.9"
|
||||||
|
:step="0.05"
|
||||||
|
:format-tooltip="formatIOU"
|
||||||
|
@change="updateCameraConfig"
|
||||||
|
/>
|
||||||
|
<div class="slider-value">{{ config.iou.toFixed(2) }}</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 拖拽调整条 -->
|
||||||
|
<div
|
||||||
|
class="resize-handle"
|
||||||
|
@mousedown="startResize"
|
||||||
|
:class="{ 'resizing': isResizing }"
|
||||||
|
>
|
||||||
|
<div class="resize-indicator"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 右侧展示区域 -->
|
||||||
|
<div class="right-panel" :style="{ width: `calc(100% - ${leftPanelWidth}px - 8px)` }">
|
||||||
|
<!-- 检测结果和统计信息并排 -->
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<!-- 检测结果区域 -->
|
||||||
|
<el-col :span="stats ? 16 : 24">
|
||||||
|
<el-card class="video-card result-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="header-left">
|
||||||
|
<el-icon class="header-icon"><View /></el-icon>
|
||||||
|
<span>检测结果</span>
|
||||||
|
</div>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="toggleCamera"
|
||||||
|
:loading="cameraStarting"
|
||||||
|
>
|
||||||
|
<el-icon v-if="!cameraConnected"><VideoPlay /></el-icon>
|
||||||
|
<el-icon v-else><VideoPause /></el-icon>
|
||||||
|
<span>{{ cameraConnected ? '停止摄像头' : '启用摄像头' }}</span>
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="video-container">
|
||||||
|
<img
|
||||||
|
v-if="resultCameraFrame"
|
||||||
|
:src="'data:image/jpeg;base64,' + resultCameraFrame"
|
||||||
|
class="display-video"
|
||||||
|
alt="检测结果"
|
||||||
|
/>
|
||||||
|
<div v-else class="empty-placeholder">
|
||||||
|
<el-icon class="empty-icon"><VideoCamera /></el-icon>
|
||||||
|
<p class="empty-text">请启用摄像头进行检测</p>
|
||||||
|
<p class="empty-hint">点击右上角按钮开启摄像头</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<!-- 统计信息 -->
|
||||||
|
<el-col v-if="stats" :span="8">
|
||||||
|
<el-card class="stats-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<el-icon class="header-icon"><DataLine /></el-icon>
|
||||||
|
<span>检测统计</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="stats-content">
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">检测数量</div>
|
||||||
|
<el-tag size="large" type="primary">{{ stats.total_detections }} 个</el-tag>
|
||||||
|
</div>
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">平均置信度</div>
|
||||||
|
<el-tag size="large" :type="getConfidenceType(stats.avg_confidence)">
|
||||||
|
{{ stats.avg_confidence?.toFixed(2) }}
|
||||||
|
</el-tag>
|
||||||
|
</div>
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">处理时间</div>
|
||||||
|
<el-tag size="large" type="info">{{ stats.processing_time?.toFixed(2) }}s</el-tag>
|
||||||
|
</div>
|
||||||
|
<div class="stat-item">
|
||||||
|
<div class="stat-label">使用模型</div>
|
||||||
|
<el-tag size="large" type="success">{{ modelName }}</el-tag>
|
||||||
|
</div>
|
||||||
|
<div v-if="stats.fps" class="stat-item">
|
||||||
|
<div class="stat-label">FPS</div>
|
||||||
|
<el-tag size="large" type="warning">{{ stats.fps }}</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 检测详情 -->
|
||||||
|
<el-card v-if="detections.length > 0" class="details-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<el-icon class="header-icon"><List /></el-icon>
|
||||||
|
<span>检测详情</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-table :data="detections" border class="details-table">
|
||||||
|
<el-table-column prop="label" label="类别" min-width="120" />
|
||||||
|
<el-table-column prop="confidence" label="置信度" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag :type="getConfidenceType(scope.row.confidence)">
|
||||||
|
{{ scope.row.confidence }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="bbox" label="位置" min-width="200">
|
||||||
|
<template #default="scope">
|
||||||
|
<code class="bbox-code">[{{ scope.row.bbox.join(', ') }}]</code>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 检测日志 -->
|
||||||
|
<el-card v-if="detectionLogs.length > 0" class="logs-card" shadow="hover">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="header-left">
|
||||||
|
<el-icon class="header-icon"><Timer /></el-icon>
|
||||||
|
<span>检测日志</span>
|
||||||
|
<el-tag size="small" type="info" class="log-count">{{ detectionLogs.length }} 条</el-tag>
|
||||||
|
</div>
|
||||||
|
<el-button type="danger" size="small" @click="clearLogs" plain>
|
||||||
|
<el-icon><Delete /></el-icon>
|
||||||
|
清空日志
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="logs-container">
|
||||||
|
<el-timeline>
|
||||||
|
<el-timeline-item
|
||||||
|
v-for="log in detectionLogs.slice(0, 20)"
|
||||||
|
:key="log.id"
|
||||||
|
:type="getConfidenceType(log.confidence)"
|
||||||
|
:timestamp="log.timestamp"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<div class="log-item">
|
||||||
|
<div class="log-header">
|
||||||
|
<el-tag :type="getConfidenceType(log.confidence)" size="small">
|
||||||
|
{{ log.label }}
|
||||||
|
</el-tag>
|
||||||
|
<span class="log-confidence">置信度: {{ log.confidence }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="log-detail">
|
||||||
|
<span class="log-model">模型: {{ log.model }}</span>
|
||||||
|
<code class="log-bbox">[{{ log.bbox.join(', ') }}]</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-timeline-item>
|
||||||
|
</el-timeline>
|
||||||
|
<div v-if="detectionLogs.length > 20" class="logs-more">
|
||||||
|
<el-tag type="info" size="small">还有 {{ detectionLogs.length - 20 }} 条记录...</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed, onUnmounted } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import {
|
||||||
|
VideoCamera,
|
||||||
|
Document,
|
||||||
|
Setting,
|
||||||
|
VideoPlay,
|
||||||
|
VideoPause,
|
||||||
|
CircleCheck,
|
||||||
|
View,
|
||||||
|
DataLine,
|
||||||
|
List,
|
||||||
|
QuestionFilled,
|
||||||
|
Timer,
|
||||||
|
Delete
|
||||||
|
} from '@element-plus/icons-vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
models: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const config = ref({
|
||||||
|
model: props.models.length > 0 ? props.models[0].id : 'fire_detection',
|
||||||
|
confidence: 0.5,
|
||||||
|
iou: 0.45
|
||||||
|
})
|
||||||
|
|
||||||
|
// 可拖拽调整宽度相关
|
||||||
|
const leftPanelWidth = ref(320)
|
||||||
|
const isResizing = ref(false)
|
||||||
|
const startX = ref(0)
|
||||||
|
const startWidth = ref(0)
|
||||||
|
|
||||||
|
const startResize = (e) => {
|
||||||
|
isResizing.value = true
|
||||||
|
startX.value = e.clientX
|
||||||
|
startWidth.value = leftPanelWidth.value
|
||||||
|
|
||||||
|
document.addEventListener('mousemove', handleResize)
|
||||||
|
document.addEventListener('mouseup', stopResize)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleResize = (e) => {
|
||||||
|
if (!isResizing.value) return
|
||||||
|
const delta = e.clientX - startX.value
|
||||||
|
const newWidth = startWidth.value + delta
|
||||||
|
leftPanelWidth.value = Math.max(280, Math.min(500, newWidth))
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopResize = () => {
|
||||||
|
isResizing.value = false
|
||||||
|
document.removeEventListener('mousemove', handleResize)
|
||||||
|
document.removeEventListener('mouseup', stopResize)
|
||||||
|
}
|
||||||
|
|
||||||
|
const cameraConnected = ref(false)
|
||||||
|
const cameraStarting = ref(false)
|
||||||
|
const originalCameraFrame = ref('')
|
||||||
|
const resultCameraFrame = ref('')
|
||||||
|
const detections = ref([])
|
||||||
|
const stats = ref(null)
|
||||||
|
const websocket = ref(null)
|
||||||
|
|
||||||
|
// 检测日志
|
||||||
|
const detectionLogs = ref([])
|
||||||
|
const maxLogs = 100 // 最多保留100条日志
|
||||||
|
|
||||||
|
// 添加检测日志
|
||||||
|
const addDetectionLog = (detections, stats) => {
|
||||||
|
if (!detections || detections.length === 0) return
|
||||||
|
|
||||||
|
const now = new Date()
|
||||||
|
const timeStr = now.toLocaleTimeString('zh-CN')
|
||||||
|
|
||||||
|
detections.forEach(detection => {
|
||||||
|
const logEntry = {
|
||||||
|
id: Date.now() + Math.random(),
|
||||||
|
timestamp: timeStr,
|
||||||
|
datetime: now,
|
||||||
|
label: detection.label,
|
||||||
|
confidence: detection.confidence,
|
||||||
|
bbox: detection.bbox,
|
||||||
|
model: stats?.model_used || config.value.model,
|
||||||
|
totalDetections: stats?.total_detections || detections.length
|
||||||
|
}
|
||||||
|
|
||||||
|
detectionLogs.value.unshift(logEntry)
|
||||||
|
|
||||||
|
// 限制日志数量
|
||||||
|
if (detectionLogs.value.length > maxLogs) {
|
||||||
|
detectionLogs.value = detectionLogs.value.slice(0, maxLogs)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清空日志
|
||||||
|
const clearLogs = () => {
|
||||||
|
detectionLogs.value = []
|
||||||
|
ElMessage.success('日志已清空')
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatConfidence = (value) => {
|
||||||
|
return `置信度: ${value.toFixed(2)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatIOU = (value) => {
|
||||||
|
return `IOU: ${value.toFixed(2)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleCamera = async () => {
|
||||||
|
if (cameraConnected.value) {
|
||||||
|
stopCamera()
|
||||||
|
} else {
|
||||||
|
await startCamera()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const startCamera = async () => {
|
||||||
|
cameraStarting.value = true
|
||||||
|
try {
|
||||||
|
websocket.value = new WebSocket('ws://localhost:8000/ws/camera')
|
||||||
|
|
||||||
|
websocket.value.onopen = () => {
|
||||||
|
console.log('WebSocket connected')
|
||||||
|
cameraConnected.value = true
|
||||||
|
cameraStarting.value = false
|
||||||
|
|
||||||
|
websocket.value.send(JSON.stringify({
|
||||||
|
action: 'start',
|
||||||
|
config: {
|
||||||
|
model_id: config.value.model,
|
||||||
|
confidence: config.value.confidence,
|
||||||
|
iou: config.value.iou
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
websocket.value.onmessage = (event) => {
|
||||||
|
const message = JSON.parse(event.data)
|
||||||
|
console.log('WebSocket message received:', message)
|
||||||
|
|
||||||
|
if (message.type === 'original_frame') {
|
||||||
|
originalCameraFrame.value = message.frame
|
||||||
|
} else if (message.type === 'annotated_frame') {
|
||||||
|
resultCameraFrame.value = message.frame
|
||||||
|
} else if (message.type === 'detection') {
|
||||||
|
console.log('Detection result:', message)
|
||||||
|
detections.value = message.detections
|
||||||
|
stats.value = message.stats
|
||||||
|
// 添加检测日志
|
||||||
|
addDetectionLog(message.detections, message.stats)
|
||||||
|
} else if (message.type === 'error') {
|
||||||
|
ElMessage.error(message.message)
|
||||||
|
} else if (message.type === 'camera_started') {
|
||||||
|
ElMessage.success(message.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
websocket.value.onerror = (error) => {
|
||||||
|
console.error('WebSocket error:', error)
|
||||||
|
ElMessage.error('摄像头连接失败')
|
||||||
|
cameraStarting.value = false
|
||||||
|
cameraConnected.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
websocket.value.onclose = () => {
|
||||||
|
console.log('WebSocket closed')
|
||||||
|
cameraConnected.value = false
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('启动摄像头失败')
|
||||||
|
cameraStarting.value = false
|
||||||
|
cameraConnected.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopCamera = () => {
|
||||||
|
if (websocket.value) {
|
||||||
|
websocket.value.send(JSON.stringify({ action: 'stop' }))
|
||||||
|
websocket.value.close()
|
||||||
|
websocket.value = null
|
||||||
|
}
|
||||||
|
cameraConnected.value = false
|
||||||
|
originalCameraFrame.value = ''
|
||||||
|
resultCameraFrame.value = ''
|
||||||
|
ElMessage.success('摄像头已停止')
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateCameraConfig = () => {
|
||||||
|
if (websocket.value && cameraConnected.value) {
|
||||||
|
websocket.value.send(JSON.stringify({
|
||||||
|
action: 'update_config',
|
||||||
|
config: {
|
||||||
|
model_id: config.value.model,
|
||||||
|
confidence: config.value.confidence,
|
||||||
|
iou: config.value.iou
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getConfidenceType = (confidence) => {
|
||||||
|
if (!confidence && confidence !== 0) return 'info'
|
||||||
|
if (confidence >= 0.8) return 'success'
|
||||||
|
if (confidence >= 0.6) return 'warning'
|
||||||
|
return 'danger'
|
||||||
|
}
|
||||||
|
|
||||||
|
const modelName = computed(() => {
|
||||||
|
const model = props.models.find(m => m.id === config.value.model)
|
||||||
|
return model ? model.name : config.value.model
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (websocket.value) {
|
||||||
|
websocket.value.close()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.video-detection-container {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: calc(100vh - 100px);
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel {
|
||||||
|
flex-shrink: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel .config-card {
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 拖拽调整条 */
|
||||||
|
.resize-handle {
|
||||||
|
width: 8px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
cursor: col-resize;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: transparent;
|
||||||
|
transition: background 0.2s;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle:hover {
|
||||||
|
background: #d0d0d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle.resizing {
|
||||||
|
background: #409eff;
|
||||||
|
cursor: col-resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-indicator {
|
||||||
|
width: 3px;
|
||||||
|
height: 40px;
|
||||||
|
background: #c0c4cc;
|
||||||
|
border-radius: 2px;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle:hover .resize-indicator,
|
||||||
|
.resize-handle.resizing .resize-indicator {
|
||||||
|
background: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 卡片通用样式 */
|
||||||
|
:deep(.el-card) {
|
||||||
|
border-radius: 12px;
|
||||||
|
border: none;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-card__header) {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-bottom: 1px solid #e4e7ed;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 12px 12px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 卡片头部样式 */
|
||||||
|
.card-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 配置卡片样式 */
|
||||||
|
.config-card {
|
||||||
|
height: auto;
|
||||||
|
max-height: calc(100vh - 100px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-card :deep(.el-card__body) {
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-form :deep(.el-form-item) {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-form :deep(.el-form-item__label) {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #303133;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 模型选择器 */
|
||||||
|
.model-size {
|
||||||
|
float: right;
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滑块样式 */
|
||||||
|
.slider-value {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #409eff;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
background: #ecf5ff;
|
||||||
|
border-radius: 20px;
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 帮助图标样式 */
|
||||||
|
.help-icon {
|
||||||
|
margin-left: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #909399;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-icon:hover {
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 摄像头状态 */
|
||||||
|
.camera-status {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.camera-status :deep(.el-tag) {
|
||||||
|
padding: 8px 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 视频展示区域 */
|
||||||
|
.video-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-card :deep(.el-card__body) {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-container {
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
min-height: 400px;
|
||||||
|
max-height: 600px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 0 0 12px 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.display-video {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder {
|
||||||
|
text-align: center;
|
||||||
|
color: #909399;
|
||||||
|
padding: 40px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder-icon {
|
||||||
|
font-size: 64px;
|
||||||
|
color: #dcdfe6;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder p {
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 空状态占位区域 */
|
||||||
|
.empty-placeholder {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-icon {
|
||||||
|
font-size: 64px;
|
||||||
|
color: #dcdfe6;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-text {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #606266;
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-hint {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #909399;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 统计卡片 */
|
||||||
|
.stats-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
height: calc(100% - 20px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-card :deep(.el-card__body) {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #606266;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-item :deep(.el-tag) {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 详情卡片 */
|
||||||
|
.details-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-card :deep(.el-card__body) {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-table :deep(.el-table__header) {
|
||||||
|
background: #f5f7fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-table :deep(.el-table__header th) {
|
||||||
|
background: #f5f7fa;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bbox-code {
|
||||||
|
background: #f5f7fa;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 帮助图标样式 */
|
||||||
|
.help-icon {
|
||||||
|
margin-left: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #909399;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-icon:hover {
|
||||||
|
color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 日志卡片 */
|
||||||
|
.logs-card {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-card :deep(.el-card__header) {
|
||||||
|
padding: 12px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-card .card-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-count {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-container {
|
||||||
|
max-height: 400px;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-item {
|
||||||
|
background: #f5f7fa;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-confidence {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-detail {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-model {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-bbox {
|
||||||
|
font-size: 11px;
|
||||||
|
color: #606266;
|
||||||
|
background: #fff;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logs-more {
|
||||||
|
text-align: center;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式布局 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.video-detection-container {
|
||||||
|
flex-direction: column;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.config-card {
|
||||||
|
max-height: none;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resize-handle {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-panel {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-container {
|
||||||
|
aspect-ratio: 4 / 3;
|
||||||
|
min-height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-descriptions :deep(.el-descriptions__body) {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-descriptions :deep(.el-descriptions__cell) {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.video-container {
|
||||||
|
aspect-ratio: 1 / 1;
|
||||||
|
min-height: 180px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,809 +1,95 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="home-container">
|
<div class="home-container">
|
||||||
<div class="resizable-layout">
|
<!-- Tab 切换 -->
|
||||||
<!-- 左侧配置面板 -->
|
<div class="tab-header">
|
||||||
<div class="left-panel" :style="{ width: leftPanelWidth + 'px' }">
|
<el-radio-group v-model="activeTab" size="large" class="tab-group">
|
||||||
<el-card class="config-card" shadow="hover">
|
<el-radio-button label="image">
|
||||||
<template #header>
|
<el-icon><Picture /></el-icon>
|
||||||
<div class="card-header">
|
<span>图片检测</span>
|
||||||
<el-icon class="header-icon"><Setting /></el-icon>
|
</el-radio-button>
|
||||||
<span>检测配置</span>
|
<el-radio-button label="video">
|
||||||
</div>
|
<el-icon><VideoCamera /></el-icon>
|
||||||
</template>
|
<span>视频检测</span>
|
||||||
|
</el-radio-button>
|
||||||
<el-form label-position="top" class="config-form">
|
</el-radio-group>
|
||||||
<el-form-item label="选择模型">
|
|
||||||
<el-select
|
|
||||||
v-model="config.model"
|
|
||||||
placeholder="选择检测模型"
|
|
||||||
class="full-width"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="model in models"
|
|
||||||
:key="model.id"
|
|
||||||
:label="model.name"
|
|
||||||
:value="model.id"
|
|
||||||
>
|
|
||||||
<span>{{ model.name }}</span>
|
|
||||||
<span class="model-size">{{ model.size }}</span>
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="置信度阈值">
|
|
||||||
<el-slider
|
|
||||||
v-model="config.confidence"
|
|
||||||
:min="0.1"
|
|
||||||
:max="1.0"
|
|
||||||
:step="0.05"
|
|
||||||
:format-tooltip="formatConfidence"
|
|
||||||
/>
|
|
||||||
<div class="slider-value">{{ config.confidence.toFixed(2) }}</div>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="IOU阈值">
|
|
||||||
<el-slider
|
|
||||||
v-model="config.iou"
|
|
||||||
:min="0.1"
|
|
||||||
:max="0.9"
|
|
||||||
:step="0.05"
|
|
||||||
:format-tooltip="formatIOU"
|
|
||||||
/>
|
|
||||||
<div class="slider-value">{{ config.iou.toFixed(2) }}</div>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-divider />
|
|
||||||
|
|
||||||
<el-form-item label="输入方式">
|
|
||||||
<el-radio-group v-model="inputType" class="input-type-group">
|
|
||||||
<el-radio-button label="image">
|
|
||||||
<el-icon><Picture /></el-icon>
|
|
||||||
<span>图片</span>
|
|
||||||
</el-radio-button>
|
|
||||||
<el-radio-button label="camera">
|
|
||||||
<el-icon><VideoCamera /></el-icon>
|
|
||||||
<span>摄像头</span>
|
|
||||||
</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-upload
|
|
||||||
v-if="inputType === 'image'"
|
|
||||||
:action="uploadUrl"
|
|
||||||
:on-success="handleUploadSuccess"
|
|
||||||
:before-upload="beforeUpload"
|
|
||||||
:show-file-list="false"
|
|
||||||
accept="image/*"
|
|
||||||
drag
|
|
||||||
class="upload-area"
|
|
||||||
>
|
|
||||||
<el-icon class="upload-icon"><UploadFilled /></el-icon>
|
|
||||||
<div class="upload-text">点击或拖拽图片到此处上传</div>
|
|
||||||
</el-upload>
|
|
||||||
|
|
||||||
<div v-if="inputType === 'camera'" class="camera-section">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
@click="toggleCamera"
|
|
||||||
:loading="cameraStarting"
|
|
||||||
class="full-width"
|
|
||||||
>
|
|
||||||
<el-icon v-if="!cameraConnected"><VideoPlay /></el-icon>
|
|
||||||
<el-icon v-else><VideoPause /></el-icon>
|
|
||||||
{{ cameraConnected ? '停止摄像头' : '启用摄像头' }}
|
|
||||||
</el-button>
|
|
||||||
|
|
||||||
<div v-if="cameraConnected" class="camera-status">
|
|
||||||
<el-tag type="success" effect="dark">
|
|
||||||
<el-icon><CircleCheck /></el-icon>
|
|
||||||
摄像头已连接
|
|
||||||
</el-tag>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-form>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 拖拽调整条 -->
|
|
||||||
<div
|
|
||||||
class="resize-handle"
|
|
||||||
@mousedown="startResize"
|
|
||||||
:class="{ 'resizing': isResizing }"
|
|
||||||
>
|
|
||||||
<div class="resize-indicator"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 右侧展示区域 -->
|
|
||||||
<div class="right-panel" :style="{ width: `calc(100% - ${leftPanelWidth}px - 8px)` }">
|
|
||||||
<!-- 图片对比区域 -->
|
|
||||||
<el-row :gutter="20" class="image-row">
|
|
||||||
<el-col :xs="24" :sm="24" :md="12">
|
|
||||||
<el-card class="image-card" shadow="hover">
|
|
||||||
<template #header>
|
|
||||||
<div class="card-header">
|
|
||||||
<el-icon class="header-icon"><Picture /></el-icon>
|
|
||||||
<span>{{ inputType === 'camera' ? '摄像头画面' : '原始图片' }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div class="image-container">
|
|
||||||
<img
|
|
||||||
v-if="inputType === 'camera' && originalCameraFrame"
|
|
||||||
:src="'data:image/jpeg;base64,' + originalCameraFrame"
|
|
||||||
class="display-image"
|
|
||||||
alt="摄像头画面"
|
|
||||||
/>
|
|
||||||
<img
|
|
||||||
v-if="inputType === 'image' && originalImage"
|
|
||||||
:src="originalImage"
|
|
||||||
class="display-image"
|
|
||||||
alt="原始图片"
|
|
||||||
/>
|
|
||||||
<div v-if="(inputType === 'camera' && !originalCameraFrame) || (inputType === 'image' && !originalImage)" class="placeholder">
|
|
||||||
<el-icon class="placeholder-icon"><Picture /></el-icon>
|
|
||||||
<p>{{ inputType === 'camera' ? '等待摄像头...' : '等待图片...' }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :xs="24" :sm="24" :md="12">
|
|
||||||
<el-card class="image-card" shadow="hover">
|
|
||||||
<template #header>
|
|
||||||
<div class="card-header">
|
|
||||||
<el-icon class="header-icon"><View /></el-icon>
|
|
||||||
<span>检测结果</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div class="image-container">
|
|
||||||
<img
|
|
||||||
v-if="inputType === 'camera' && resultCameraFrame"
|
|
||||||
:src="'data:image/jpeg;base64,' + resultCameraFrame"
|
|
||||||
class="display-image"
|
|
||||||
alt="检测结果"
|
|
||||||
/>
|
|
||||||
<img
|
|
||||||
v-if="inputType === 'image' && resultImage"
|
|
||||||
:src="resultImage"
|
|
||||||
class="display-image"
|
|
||||||
alt="检测结果"
|
|
||||||
/>
|
|
||||||
<div v-if="(inputType === 'camera' && !resultCameraFrame) || (inputType === 'image' && !resultImage)" class="placeholder">
|
|
||||||
<el-icon class="placeholder-icon"><Document /></el-icon>
|
|
||||||
<p>{{ inputType === 'camera' ? '等待摄像头画面...' : '等待检测结果...' }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<!-- 统计信息 -->
|
|
||||||
<el-card v-if="stats" class="stats-card" shadow="hover">
|
|
||||||
<template #header>
|
|
||||||
<div class="card-header">
|
|
||||||
<el-icon class="header-icon"><DataLine /></el-icon>
|
|
||||||
<span>检测统计</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<el-descriptions :column="4" border class="stats-descriptions">
|
|
||||||
<el-descriptions-item label="检测数量">
|
|
||||||
<el-tag size="large" type="primary">{{ stats.totalDetections }} 个</el-tag>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="平均置信度">
|
|
||||||
<el-tag size="large" :type="getConfidenceType(stats.avgConfidence)">
|
|
||||||
{{ stats.avgConfidence.toFixed(2) }}
|
|
||||||
</el-tag>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="处理时间">
|
|
||||||
<el-tag size="large" type="info">{{ stats.processingTime.toFixed(2) }}s</el-tag>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="使用模型">
|
|
||||||
<el-tag size="large" type="success">{{ modelName }}</el-tag>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item v-if="stats.fps" label="FPS" :span="4">
|
|
||||||
<el-tag size="large" type="warning">{{ stats.fps }}</el-tag>
|
|
||||||
</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
</el-card>
|
|
||||||
|
|
||||||
<!-- 检测详情 -->
|
|
||||||
<el-card v-if="detections.length > 0" class="details-card" shadow="hover">
|
|
||||||
<template #header>
|
|
||||||
<div class="card-header">
|
|
||||||
<el-icon class="header-icon"><List /></el-icon>
|
|
||||||
<span>检测详情</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<el-table :data="detections" border class="details-table">
|
|
||||||
<el-table-column prop="label" label="类别" min-width="120" />
|
|
||||||
<el-table-column prop="confidence" label="置信度" width="120">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-tag :type="getConfidenceType(scope.row.confidence)">
|
|
||||||
{{ scope.row.confidence }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="bbox" label="位置" min-width="200">
|
|
||||||
<template #default="scope">
|
|
||||||
<code class="bbox-code">[{{ scope.row.bbox.join(', ') }}]</code>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 图片检测模块 -->
|
||||||
|
<ImageDetection
|
||||||
|
v-if="activeTab === 'image'"
|
||||||
|
:models="models"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 视频检测模块 -->
|
||||||
|
<VideoDetection
|
||||||
|
v-if="activeTab === 'video'"
|
||||||
|
:models="models"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onUnmounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import {
|
import { Picture, VideoCamera } from '@element-plus/icons-vue'
|
||||||
UploadFilled,
|
|
||||||
Picture,
|
|
||||||
Document,
|
|
||||||
Setting,
|
|
||||||
VideoCamera,
|
|
||||||
VideoPlay,
|
|
||||||
VideoPause,
|
|
||||||
CircleCheck,
|
|
||||||
View,
|
|
||||||
DataLine,
|
|
||||||
List
|
|
||||||
} from '@element-plus/icons-vue'
|
|
||||||
import { detectionApi } from '@/api/detection'
|
import { detectionApi } from '@/api/detection'
|
||||||
|
import ImageDetection from '@/components/ImageDetection.vue'
|
||||||
|
import VideoDetection from '@/components/VideoDetection.vue'
|
||||||
|
|
||||||
const config = ref({
|
const activeTab = ref('image')
|
||||||
model: 'fire_detection',
|
|
||||||
confidence: 0.5,
|
|
||||||
iou: 0.45
|
|
||||||
})
|
|
||||||
|
|
||||||
// 可拖拽调整宽度相关
|
|
||||||
const leftPanelWidth = ref(320)
|
|
||||||
const isResizing = ref(false)
|
|
||||||
const startX = ref(0)
|
|
||||||
const startWidth = ref(0)
|
|
||||||
|
|
||||||
const startResize = (e) => {
|
|
||||||
isResizing.value = true
|
|
||||||
startX.value = e.clientX
|
|
||||||
startWidth.value = leftPanelWidth.value
|
|
||||||
|
|
||||||
document.addEventListener('mousemove', handleResize)
|
|
||||||
document.addEventListener('mouseup', stopResize)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleResize = (e) => {
|
|
||||||
if (!isResizing.value) return
|
|
||||||
const delta = e.clientX - startX.value
|
|
||||||
const newWidth = startWidth.value + delta
|
|
||||||
// 限制最小和最大宽度
|
|
||||||
leftPanelWidth.value = Math.max(280, Math.min(500, newWidth))
|
|
||||||
}
|
|
||||||
|
|
||||||
const stopResize = () => {
|
|
||||||
isResizing.value = false
|
|
||||||
document.removeEventListener('mousemove', handleResize)
|
|
||||||
document.removeEventListener('mouseup', stopResize)
|
|
||||||
}
|
|
||||||
|
|
||||||
const inputType = ref('image')
|
|
||||||
const models = ref([])
|
const models = ref([])
|
||||||
const originalImage = ref('')
|
|
||||||
const resultImage = ref('')
|
|
||||||
const detections = ref([])
|
|
||||||
const stats = ref(null)
|
|
||||||
const uploadUrl = computed(() => `/api/detect/image?model_id=${config.value.model}&confidence=${config.value.confidence}&iou=${config.value.iou}`)
|
|
||||||
|
|
||||||
const cameraConnected = ref(false)
|
|
||||||
const cameraStarting = ref(false)
|
|
||||||
const originalCameraFrame = ref('') // 原始摄像头画面
|
|
||||||
const resultCameraFrame = ref('') // 检测结果画面(标注后)
|
|
||||||
const websocket = ref(null)
|
|
||||||
const cameraVideo = ref(null)
|
|
||||||
|
|
||||||
const loadModels = async () => {
|
const loadModels = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await detectionApi.getModels()
|
const response = await detectionApi.getModels()
|
||||||
models.value = response.data
|
models.value = response.data
|
||||||
if (models.value.length > 0) {
|
|
||||||
config.value.model = models.value[0].id
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error('加载模型列表失败')
|
ElMessage.error('加载模型列表失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatConfidence = (value) => {
|
onMounted(() => {
|
||||||
return `置信度: ${value.toFixed(2)}`
|
loadModels()
|
||||||
}
|
|
||||||
|
|
||||||
const formatIOU = (value) => {
|
|
||||||
return `IOU: ${value.toFixed(2)}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const beforeUpload = (file) => {
|
|
||||||
const isImage = file.type.startsWith('image/')
|
|
||||||
if (!isImage) {
|
|
||||||
ElMessage.error('只能上传图片文件')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
originalImage.value = URL.createObjectURL(file)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleUploadSuccess = (response) => {
|
|
||||||
if (response.success) {
|
|
||||||
resultImage.value = response.data.image_url
|
|
||||||
detections.value = response.data.detections
|
|
||||||
stats.value = response.data.stats
|
|
||||||
ElMessage.success('检测完成')
|
|
||||||
} else {
|
|
||||||
ElMessage.error(response.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleCamera = async () => {
|
|
||||||
if (cameraConnected.value) {
|
|
||||||
stopCamera()
|
|
||||||
} else {
|
|
||||||
await startCamera()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const startCamera = async () => {
|
|
||||||
cameraStarting.value = true
|
|
||||||
try {
|
|
||||||
websocket.value = new WebSocket('ws://localhost:8000/ws/camera')
|
|
||||||
|
|
||||||
websocket.value.onopen = () => {
|
|
||||||
console.log('WebSocket connected')
|
|
||||||
cameraConnected.value = true
|
|
||||||
cameraStarting.value = false
|
|
||||||
|
|
||||||
websocket.value.send(JSON.stringify({
|
|
||||||
action: 'start',
|
|
||||||
config: {
|
|
||||||
model_id: config.value.model,
|
|
||||||
confidence: config.value.confidence,
|
|
||||||
iou: config.value.iou
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
websocket.value.onmessage = (event) => {
|
|
||||||
const message = JSON.parse(event.data)
|
|
||||||
console.log('WebSocket message received:', message)
|
|
||||||
|
|
||||||
if (message.type === 'original_frame') {
|
|
||||||
originalCameraFrame.value = message.frame // 更新原始摄像头画面
|
|
||||||
} else if (message.type === 'annotated_frame') {
|
|
||||||
resultCameraFrame.value = message.frame // 更新检测结果画面(标注后)
|
|
||||||
} else if (message.type === 'detection') {
|
|
||||||
console.log('Detection result:', message)
|
|
||||||
detections.value = message.detections
|
|
||||||
stats.value = message.stats
|
|
||||||
} else if (message.type === 'error') {
|
|
||||||
ElMessage.error(message.message)
|
|
||||||
} else if (message.type === 'camera_started') {
|
|
||||||
ElMessage.success(message.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
websocket.value.onerror = (error) => {
|
|
||||||
console.error('WebSocket error:', error)
|
|
||||||
ElMessage.error('摄像头连接失败')
|
|
||||||
cameraStarting.value = false
|
|
||||||
cameraConnected.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
websocket.value.onclose = () => {
|
|
||||||
console.log('WebSocket closed')
|
|
||||||
cameraConnected.value = false
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
ElMessage.error('启动摄像头失败')
|
|
||||||
cameraStarting.value = false
|
|
||||||
cameraConnected.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const stopCamera = () => {
|
|
||||||
if (websocket.value) {
|
|
||||||
websocket.value.send(JSON.stringify({ action: 'stop' }))
|
|
||||||
websocket.value.close()
|
|
||||||
websocket.value = null
|
|
||||||
}
|
|
||||||
cameraConnected.value = false
|
|
||||||
originalCameraFrame.value = ''
|
|
||||||
resultCameraFrame.value = ''
|
|
||||||
ElMessage.success('摄像头已停止')
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateCameraConfig = () => {
|
|
||||||
if (websocket.value && cameraConnected.value) {
|
|
||||||
websocket.value.send(JSON.stringify({
|
|
||||||
action: 'update_config',
|
|
||||||
config: {
|
|
||||||
model_id: config.value.model,
|
|
||||||
confidence: config.value.confidence,
|
|
||||||
iou: config.value.iou
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const getConfidenceType = (confidence) => {
|
|
||||||
if (confidence >= 0.8) return 'success'
|
|
||||||
if (confidence >= 0.6) return 'warning'
|
|
||||||
return 'danger'
|
|
||||||
}
|
|
||||||
|
|
||||||
const modelName = computed(() => {
|
|
||||||
const model = models.value.find(m => m.id === config.value.model)
|
|
||||||
return model ? model.name : config.value.model
|
|
||||||
})
|
|
||||||
|
|
||||||
loadModels()
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (websocket.value) {
|
|
||||||
websocket.value.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* 容器样式 */
|
|
||||||
.home-container {
|
.home-container {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
min-height: calc(100vh - 60px);
|
min-height: calc(100vh - 60px);
|
||||||
background: #f0f2f5;
|
background: #f0f2f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 可拖拽布局 */
|
.tab-header {
|
||||||
.resizable-layout {
|
margin-bottom: 20px;
|
||||||
display: flex;
|
text-align: center;
|
||||||
width: 100%;
|
|
||||||
height: calc(100vh - 100px);
|
|
||||||
gap: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-panel {
|
.tab-group {
|
||||||
flex-shrink: 0;
|
background: #fff;
|
||||||
overflow: hidden;
|
padding: 4px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-panel .config-card {
|
.tab-group :deep(.el-radio-button__inner) {
|
||||||
height: 100%;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 拖拽调整条 */
|
|
||||||
.resize-handle {
|
|
||||||
width: 8px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
cursor: col-resize;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: transparent;
|
|
||||||
transition: background 0.2s;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.resize-handle:hover {
|
|
||||||
background: #d0d0d0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.resize-handle.resizing {
|
|
||||||
background: #409eff;
|
|
||||||
cursor: col-resize;
|
|
||||||
}
|
|
||||||
|
|
||||||
.resize-indicator {
|
|
||||||
width: 3px;
|
|
||||||
height: 40px;
|
|
||||||
background: #c0c4cc;
|
|
||||||
border-radius: 2px;
|
|
||||||
transition: background 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.resize-handle:hover .resize-indicator,
|
|
||||||
.resize-handle.resizing .resize-indicator {
|
|
||||||
background: #409eff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-panel {
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 卡片通用样式 */
|
|
||||||
:deep(.el-card) {
|
|
||||||
border-radius: 12px;
|
|
||||||
border: none;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-card__header) {
|
|
||||||
padding: 16px 20px;
|
|
||||||
border-bottom: 1px solid #e4e7ed;
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
border-radius: 12px 12px 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 卡片头部样式 */
|
|
||||||
.card-header {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
font-weight: 600;
|
padding: 12px 24px;
|
||||||
font-size: 16px;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-icon {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 配置卡片样式 */
|
|
||||||
.config-card {
|
|
||||||
height: auto;
|
|
||||||
max-height: calc(100vh - 100px);
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.config-card :deep(.el-card__body) {
|
|
||||||
padding: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.config-form :deep(.el-form-item) {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.config-form :deep(.el-form-item__label) {
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 14px;
|
|
||||||
color: #303133;
|
|
||||||
padding-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.full-width {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 模型选择器 */
|
|
||||||
.model-size {
|
|
||||||
float: right;
|
|
||||||
color: #909399;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 滑块样式 */
|
|
||||||
.slider-value {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #409eff;
|
|
||||||
margin-top: 8px;
|
|
||||||
padding: 6px 12px;
|
|
||||||
background: #ecf5ff;
|
|
||||||
border-radius: 20px;
|
|
||||||
display: inline-block;
|
|
||||||
min-width: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 输入方式选择 */
|
|
||||||
.input-type-group {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-type-group :deep(.el-radio-button) {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-type-group :deep(.el-radio-button__inner) {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 6px;
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 上传区域 */
|
|
||||||
.upload-area {
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-area :deep(.el-upload) {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-area :deep(.el-upload-dragger) {
|
|
||||||
width: 100%;
|
|
||||||
padding: 40px 20px;
|
|
||||||
border: 2px dashed #d9d9d9;
|
|
||||||
border-radius: 12px;
|
|
||||||
background: #fafafa;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-area :deep(.el-upload-dragger:hover) {
|
|
||||||
border-color: #409eff;
|
|
||||||
background: #ecf5ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-icon {
|
|
||||||
font-size: 48px;
|
|
||||||
color: #409eff;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.upload-text {
|
|
||||||
color: #606266;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 摄像头区域 */
|
|
||||||
.camera-section {
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.camera-status {
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.camera-status :deep(.el-tag) {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-size: 14px;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 图片展示区域 */
|
|
||||||
.image-row {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-card {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-card :deep(.el-card__body) {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-container {
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 4 / 3;
|
|
||||||
min-height: 300px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: #f5f7fa;
|
|
||||||
border-radius: 0 0 12px 12px;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.display-image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: contain;
|
|
||||||
background: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.display-video {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
.placeholder {
|
|
||||||
text-align: center;
|
|
||||||
color: #909399;
|
|
||||||
padding: 40px 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.placeholder-icon {
|
|
||||||
font-size: 64px;
|
|
||||||
color: #dcdfe6;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.placeholder p {
|
|
||||||
font-size: 14px;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 统计卡片 */
|
|
||||||
.stats-card {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stats-card :deep(.el-card__body) {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stats-descriptions :deep(.el-descriptions__cell) {
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stats-descriptions :deep(.el-tag) {
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 详情卡片 */
|
/* 响应式 */
|
||||||
.details-card {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details-card :deep(.el-card__body) {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details-table :deep(.el-table__header) {
|
|
||||||
background: #f5f7fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details-table :deep(.el-table__header th) {
|
|
||||||
background: #f5f7fa;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #303133;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bbox-code {
|
|
||||||
background: #f5f7fa;
|
|
||||||
padding: 4px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 响应式布局 */
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.home-container {
|
.home-container {
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.config-card {
|
.tab-group :deep(.el-radio-button__inner) {
|
||||||
max-height: none;
|
padding: 10px 16px;
|
||||||
margin-bottom: 16px;
|
font-size: 13px;
|
||||||
}
|
|
||||||
|
|
||||||
.image-container {
|
|
||||||
aspect-ratio: 4 / 3;
|
|
||||||
min-height: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stats-descriptions :deep(.el-descriptions__body) {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stats-descriptions :deep(.el-descriptions__cell) {
|
|
||||||
padding: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
|
||||||
.image-container {
|
|
||||||
aspect-ratio: 1 / 1;
|
|
||||||
min-height: 180px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-type-group :deep(.el-radio-button__inner) {
|
|
||||||
padding: 10px 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user