1148 lines
39 KiB
HTML
1148 lines
39 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>智能视频分析系统</title>
|
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--primary-color: #2962ff;
|
|
--secondary-color: #82b1ff;
|
|
--background-color: #f8f9fa;
|
|
--sidebar-color: #ffffff;
|
|
--text-primary: #2c3e50;
|
|
--text-secondary: #7f8c8d;
|
|
--success-color: #4caf50;
|
|
--warning-color: #ff9800;
|
|
--danger-color: #f44336;
|
|
--border-radius: 12px;
|
|
--card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
--transition: all 0.3s ease;
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
|
|
}
|
|
|
|
body {
|
|
background-color: var(--background-color);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.container {
|
|
display: flex;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
/* 侧边栏样式 */
|
|
.sidebar {
|
|
background-color: var(--sidebar-color);
|
|
padding: 24px;
|
|
box-shadow: var(--card-shadow);
|
|
position: fixed;
|
|
width: 280px;
|
|
height: 100vh;
|
|
overflow-y: auto;
|
|
top: 0;
|
|
left: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.logo {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding-bottom: 24px;
|
|
border-bottom: 1px solid #eee;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.logo img {
|
|
width: 40px;
|
|
height: 40px;
|
|
}
|
|
|
|
.logo h1 {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
.camera-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
|
|
.camera-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 16px;
|
|
background-color: #fff;
|
|
border-radius: var(--border-radius);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
border: 1px solid #eee;
|
|
}
|
|
|
|
.camera-item:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.camera-item.active {
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.camera-status {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background-color: var(--success-color);
|
|
}
|
|
|
|
/* 主内容区样式 */
|
|
.main-content {
|
|
flex: 1;
|
|
padding: 24px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 24px;
|
|
margin-left: 280px;
|
|
min-height: 100vh;
|
|
width: calc(100% - 280px);
|
|
}
|
|
|
|
/* 顶部工具栏 */
|
|
.toolbar {
|
|
display: flex;
|
|
gap: 16px;
|
|
background-color: white;
|
|
padding: 16px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.search-box {
|
|
flex: 1;
|
|
position: relative;
|
|
}
|
|
|
|
.search-box i {
|
|
position: absolute;
|
|
left: 12px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.search-box input {
|
|
width: 100%;
|
|
padding: 12px 12px 12px 40px;
|
|
border: 1px solid #eee;
|
|
border-radius: var(--border-radius);
|
|
font-size: 14px;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.search-box input:focus {
|
|
outline: none;
|
|
border-color: var(--primary-color);
|
|
box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.1);
|
|
}
|
|
|
|
.date-picker input {
|
|
padding: 12px;
|
|
border: 1px solid #eee;
|
|
border-radius: var(--border-radius);
|
|
font-size: 14px;
|
|
}
|
|
|
|
.button {
|
|
padding: 12px 24px;
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
border: none;
|
|
border-radius: var(--border-radius);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.button:hover {
|
|
background-color: var(--secondary-color);
|
|
}
|
|
|
|
/* 时间轴样式 */
|
|
.timeline-card {
|
|
background-color: white;
|
|
border-radius: var(--border-radius);
|
|
padding: 24px;
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.card-header h2 {
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.timeline-content {
|
|
height: 240px;
|
|
background-color: #f8f9fa;
|
|
border-radius: var(--border-radius);
|
|
overflow-x: auto;
|
|
overflow-y: hidden;
|
|
}
|
|
|
|
.timeline-ruler {
|
|
height: 40px;
|
|
display: flex;
|
|
background-color: white;
|
|
border-bottom: 1px solid #eee;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.timeline-hour {
|
|
flex: 1;
|
|
min-width: 50px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
border-right: 1px solid #eee;
|
|
padding: 0 4px;
|
|
}
|
|
|
|
.timeline-events {
|
|
position: relative;
|
|
height: 200px;
|
|
padding: 20px 0;
|
|
}
|
|
|
|
.event-item {
|
|
position: absolute;
|
|
height: 24px;
|
|
background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
|
|
border-radius: 12px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: white;
|
|
font-size: 12px;
|
|
padding: 0 8px;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
will-change: transform, opacity, height;
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.event-item:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.event-item.active {
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.camera-status {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background-color: var(--success-color);
|
|
}
|
|
|
|
/* 数据卡片网格 */
|
|
.dashboard-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 24px;
|
|
}
|
|
|
|
.stat-card {
|
|
background-color: white;
|
|
padding: 24px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.stat-card h3 {
|
|
color: var(--text-secondary);
|
|
font-size: 14px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 32px;
|
|
font-weight: 600;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
/* 图表容器 */
|
|
.chart-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 24px;
|
|
}
|
|
|
|
.chart-card {
|
|
background-color: white;
|
|
padding: 24px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.chart-container {
|
|
height: 300px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
/* 事件列表 */
|
|
.event-list {
|
|
background-color: white;
|
|
padding: 24px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.event-list-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.event-list-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 16px;
|
|
border-bottom: 1px solid #eee;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.event-list-item:hover {
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.event-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.event-icon {
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.event-details {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.event-time {
|
|
font-size: 14px;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.confidence-badge {
|
|
padding: 6px 12px;
|
|
border-radius: 20px;
|
|
font-size: 14px;
|
|
background-color: #e3f2fd;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
.highlight {
|
|
background-color: rgba(41, 98, 255, 0.1);
|
|
border-radius: 4px;
|
|
padding: 2px 4px;
|
|
}
|
|
|
|
/* 新增样式 */
|
|
.sidebar-divider {
|
|
height: 1px;
|
|
background-color: #eee;
|
|
margin: 24px 0;
|
|
}
|
|
|
|
.nav-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 16px;
|
|
border-radius: var(--border-radius);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
border: 1px solid #eee;
|
|
}
|
|
|
|
.nav-item:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--card-shadow);
|
|
background-color: rgba(41, 98, 255, 0.1);
|
|
}
|
|
|
|
.nav-item.active {
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.summary-section {
|
|
background-color: white;
|
|
border-radius: var(--border-radius);
|
|
padding: 24px;
|
|
box-shadow: var(--card-shadow);
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.summary-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.insight-card {
|
|
background-color: #f8f9fa;
|
|
border-radius: var(--border-radius);
|
|
padding: 20px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.insight-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
color: var(--primary-color);
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.recommendation {
|
|
background-color: #e3f2fd;
|
|
border-left: 4px solid var(--primary-color);
|
|
padding: 16px;
|
|
margin-top: 16px;
|
|
border-radius: 0 var(--border-radius) var(--border-radius) 0;
|
|
}
|
|
|
|
.trend-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.trend-up {
|
|
color: var(--success-color);
|
|
}
|
|
|
|
.trend-down {
|
|
color: var(--danger-color);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- 侧边栏 -->
|
|
<div class="sidebar">
|
|
<div class="logo">
|
|
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232962ff'%3E%3Cpath d='M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z'/%3E%3C/svg%3E" alt="Logo">
|
|
<h1>智能视频分析</h1>
|
|
</div>
|
|
<div class="camera-list">
|
|
<div class="camera-item active">
|
|
<span class="camera-status"></span>
|
|
<span>摄像头 01</span>
|
|
</div>
|
|
<div class="camera-item">
|
|
<span class="camera-status"></span>
|
|
<span>摄像头 02</span>
|
|
</div>
|
|
<div class="camera-item">
|
|
<span class="camera-status"></span>
|
|
<span>摄像头 03</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sidebar-divider"></div>
|
|
<div class="nav-item daily-summary">
|
|
<i class="material-icons">analytics</i>
|
|
<span>每日行为分析</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 主内容区 -->
|
|
<div class="main-content">
|
|
<!-- 工具栏 -->
|
|
<div class="toolbar">
|
|
<div class="search-box">
|
|
<i class="material-icons">search</i>
|
|
<input type="text" placeholder="搜索行为或事件...">
|
|
</div>
|
|
<div class="date-picker">
|
|
<input type="date">
|
|
</div>
|
|
<button class="button">
|
|
<i class="material-icons">filter_list</i>
|
|
筛选
|
|
</button>
|
|
</div>
|
|
|
|
<!-- 数据卡片 -->
|
|
<div class="dashboard-grid">
|
|
<div class="stat-card">
|
|
<h3>今日识别行为</h3>
|
|
<div class="stat-value">--</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>平均置信度</h3>
|
|
<div class="stat-value">--%</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>异常行为</h3>
|
|
<div class="stat-value">--</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 时间轴 -->
|
|
<div class="timeline-card">
|
|
<div class="card-header">
|
|
<h2>行为时间轴</h2>
|
|
<button class="button">导出数据</button>
|
|
</div>
|
|
<div class="timeline-content">
|
|
<div class="timeline-ruler">
|
|
<div class="timeline-hour">00:00</div>
|
|
<div class="timeline-hour">01:00</div>
|
|
<div class="timeline-hour">02:00</div>
|
|
<div class="timeline-hour">03:00</div>
|
|
<div class="timeline-hour">04:00</div>
|
|
<div class="timeline-hour">05:00</div>
|
|
<div class="timeline-hour">06:00</div>
|
|
<div class="timeline-hour">07:00</div>
|
|
<div class="timeline-hour">08:00</div>
|
|
<div class="timeline-hour">09:00</div>
|
|
<div class="timeline-hour">10:00</div>
|
|
<div class="timeline-hour">11:00</div>
|
|
<div class="timeline-hour">12:00</div>
|
|
<div class="timeline-hour">13:00</div>
|
|
<div class="timeline-hour">14:00</div>
|
|
<div class="timeline-hour">15:00</div>
|
|
<div class="timeline-hour">16:00</div>
|
|
<div class="timeline-hour">17:00</div>
|
|
<div class="timeline-hour">18:00</div>
|
|
<div class="timeline-hour">19:00</div>
|
|
<div class="timeline-hour">20:00</div>
|
|
<div class="timeline-hour">21:00</div>
|
|
<div class="timeline-hour">22:00</div>
|
|
<div class="timeline-hour">23:00</div>
|
|
</div>
|
|
<div class="timeline-events">
|
|
<!-- 事件将通过JavaScript动态添加 -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 图表区域 -->
|
|
<div class="chart-grid">
|
|
<div class="chart-card">
|
|
<div class="card-header">
|
|
<h2>行为分布</h2>
|
|
</div>
|
|
<div class="chart-container" id="behaviorChart"></div>
|
|
</div>
|
|
<div class="chart-card">
|
|
<div class="card-header">
|
|
<h2>时段分析</h2>
|
|
</div>
|
|
<div class="chart-container" id="timeChart"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 事件列表 -->
|
|
<div class="event-list">
|
|
<div class="event-list-header">
|
|
<h2>最新事件</h2>
|
|
<button class="button">查看全部</button>
|
|
</div>
|
|
<!-- 事件将通过 JavaScript 动态添加 -->
|
|
</div>
|
|
|
|
<!-- 每日总结分析 -->
|
|
<div class="summary-section">
|
|
<div class="summary-header">
|
|
<h2>每日行为分析</h2>
|
|
<div class="date-picker">
|
|
<input type="date">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="insight-card">
|
|
<div class="insight-title">
|
|
<i class="material-icons">trending_up</i>
|
|
<h3>整体活动趋势</h3>
|
|
</div>
|
|
<p>今日共记录 2,547 个行为事件,较昨日增长 15%</p>
|
|
<div class="trend-indicator trend-up">
|
|
<i class="material-icons">arrow_upward</i>
|
|
<span>活跃度上升</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="insight-card">
|
|
<div class="insight-title">
|
|
<i class="material-icons">access_time</i>
|
|
<h3>高峰时段分析</h3>
|
|
</div>
|
|
<p>活动高峰出现在 9:00-11:00 和 14:00-16:00</p>
|
|
<div class="chart-container" id="peakTimeChart" style="height: 200px;"></div>
|
|
</div>
|
|
|
|
<div class="insight-card">
|
|
<div class="insight-title">
|
|
<i class="material-icons">warning</i>
|
|
<h3>异常行为分析</h3>
|
|
</div>
|
|
<p>检测到 23 起异常行为,主要集中在午夜时段</p>
|
|
<div class="recommendation">
|
|
<strong>建议:</strong>
|
|
<p>建议加强夜间监控,特别是在 23:00-凌晨 2:00 时段</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
|
<script>
|
|
const API_BASE_URL = 'https://dev.obscura.work/web';
|
|
|
|
// 获取摄像头数据
|
|
async function fetchCameraData(cameraId, date) {
|
|
try {
|
|
// 如果没有传入日期,使用当前日期
|
|
const currentDate = date || new Date().toISOString().split('T')[0].replace(/-/g, '');
|
|
const response = await fetch(`${API_BASE_URL}/${cameraId}/data?date=${currentDate}`);
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
return await response.json();
|
|
} catch (error) {
|
|
console.error('Error fetching camera data:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// 解析视频分析数据
|
|
function parseVideoAnalysis(data) {
|
|
const behaviors = new Map();
|
|
const timeDistribution = new Map();
|
|
let totalEvents = 0;
|
|
let totalConfidence = 0;
|
|
let abnormalCount = 0;
|
|
|
|
// 初始化24小时时间分布
|
|
for (let i = 0; i < 24; i++) {
|
|
timeDistribution.set(i, 0);
|
|
}
|
|
|
|
// 遍历所有摄像头数据
|
|
Object.values(data).forEach(cameraData => {
|
|
Object.values(cameraData).forEach(record => {
|
|
if (record.video_analysis?.['qwen-7B']?.extracted_info) {
|
|
const info = record.video_analysis['qwen-7B'].extracted_info;
|
|
const timestamp = new Date(record.timestamp);
|
|
|
|
// 统计行为
|
|
info.actions.forEach(action => {
|
|
behaviors.set(action, (behaviors.get(action) || 0) + 1);
|
|
totalEvents++;
|
|
});
|
|
|
|
// 记录时间分布
|
|
const hour = timestamp.getHours();
|
|
timeDistribution.set(hour, (timeDistribution.get(hour) || 0) + 1);
|
|
|
|
// 统计异常行为(可以根据实际需求调整判断标准)
|
|
if (info.actions.some(action =>
|
|
action.includes('异常') ||
|
|
action.includes('可疑'))) {
|
|
abnormalCount++;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
return {
|
|
behaviors: Object.fromEntries(behaviors),
|
|
timeDistribution: Object.fromEntries(timeDistribution),
|
|
totalEvents,
|
|
abnormalCount
|
|
};
|
|
}
|
|
|
|
// 更新统计卡片
|
|
function updateStatCards(stats) {
|
|
document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = stats.totalEvents;
|
|
document.querySelector('.stat-card:nth-child(2) .stat-value').textContent =
|
|
`${stats.totalEvents ? Math.round((stats.totalEvents - stats.abnormalCount) / stats.totalEvents * 100) : 0}%`;
|
|
document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = stats.abnormalCount;
|
|
}
|
|
|
|
// 更新时间轴
|
|
function updateTimeline(data) {
|
|
const timelineEvents = document.querySelector('.timeline-events');
|
|
timelineEvents.innerHTML = '';
|
|
|
|
// 获取所有事件
|
|
const events = [];
|
|
Object.values(data).forEach(cameraData => {
|
|
Object.entries(cameraData).forEach(([key, value]) => {
|
|
if (value.video_analysis?.['qwen-7B']?.extracted_info) {
|
|
events.push({
|
|
timestamp: new Date(value.timestamp),
|
|
info: value.video_analysis['qwen-7B'].extracted_info
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// 在时间轴上显示事件
|
|
events.forEach((event, index) => {
|
|
const hour = event.timestamp.getHours();
|
|
const minute = event.timestamp.getMinutes();
|
|
|
|
const eventElement = document.createElement('div');
|
|
eventElement.className = 'event-item';
|
|
eventElement.style.left = `${(hour * 60 + minute) / (24 * 60) * 100}%`;
|
|
eventElement.style.width = '8%';
|
|
eventElement.style.top = `${20 + (index % 3) * 30}px`;
|
|
|
|
eventElement.textContent = event.info.actions[0] || '未知行为';
|
|
eventElement.title = `${event.timestamp.toLocaleTimeString()} - ${event.info.actions.join(', ')}`;
|
|
|
|
timelineEvents.appendChild(eventElement);
|
|
});
|
|
}
|
|
|
|
// 更新图表
|
|
function updateCharts(stats) {
|
|
// 行为分布图表
|
|
const behaviorChart = echarts.init(document.getElementById('behaviorChart'));
|
|
const behaviorData = Object.entries(stats.behaviors).map(([name, value]) => ({
|
|
name,
|
|
value
|
|
}));
|
|
|
|
behaviorChart.setOption({
|
|
tooltip: {
|
|
trigger: 'item',
|
|
formatter: '{b}: {c} ({d}%)'
|
|
},
|
|
legend: {
|
|
orient: 'horizontal',
|
|
bottom: 'bottom'
|
|
},
|
|
series: [{
|
|
name: '行为分布',
|
|
type: 'pie',
|
|
radius: ['40%', '70%'],
|
|
avoidLabelOverlap: false,
|
|
itemStyle: {
|
|
borderRadius: 10,
|
|
borderColor: '#fff',
|
|
borderWidth: 2
|
|
},
|
|
label: {
|
|
show: false,
|
|
position: 'center'
|
|
},
|
|
emphasis: {
|
|
label: {
|
|
show: true,
|
|
fontSize: '20',
|
|
fontWeight: 'bold'
|
|
}
|
|
},
|
|
labelLine: {
|
|
show: false
|
|
},
|
|
data: behaviorData
|
|
}]
|
|
});
|
|
|
|
// 时段分析图表
|
|
const timeChart = echarts.init(document.getElementById('timeChart'));
|
|
const hours = Array.from({length: 24}, (_, i) => `${i}:00`);
|
|
const timeData = hours.map(hour => stats.timeDistribution[parseInt(hour)] || 0);
|
|
|
|
timeChart.setOption({
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
type: 'shadow'
|
|
}
|
|
},
|
|
grid: {
|
|
left: '3%',
|
|
right: '4%',
|
|
bottom: '3%',
|
|
containLabel: true
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
data: hours,
|
|
axisTick: {
|
|
alignWithLabel: true
|
|
}
|
|
},
|
|
yAxis: {
|
|
type: 'value'
|
|
},
|
|
series: [{
|
|
name: '行为数量',
|
|
type: 'bar',
|
|
barWidth: '60%',
|
|
data: timeData,
|
|
itemStyle: {
|
|
color: '#2962ff'
|
|
}
|
|
}]
|
|
});
|
|
|
|
// 高峰时段分析图表
|
|
const peakTimeChart = echarts.init(document.getElementById('peakTimeChart'));
|
|
peakTimeChart.setOption({
|
|
tooltip: {
|
|
trigger: 'axis'
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
data: hours
|
|
},
|
|
yAxis: {
|
|
type: 'value',
|
|
name: '行为数量'
|
|
},
|
|
series: [{
|
|
data: timeData,
|
|
type: 'line',
|
|
smooth: true,
|
|
areaStyle: {
|
|
opacity: 0.3
|
|
},
|
|
lineStyle: {
|
|
width: 3
|
|
},
|
|
itemStyle: {
|
|
color: '#2962ff'
|
|
}
|
|
}]
|
|
});
|
|
}
|
|
|
|
// 更新事件列表
|
|
function updateEventList(data) {
|
|
const eventList = document.querySelector('.event-list');
|
|
const eventListContent = document.createElement('div');
|
|
|
|
// 获取所有事件并按时间排序
|
|
const events = [];
|
|
Object.values(data).forEach(cameraData => {
|
|
Object.entries(cameraData).forEach(([key, value]) => {
|
|
if (value.video_analysis?.['qwen-7B']?.extracted_info) {
|
|
events.push({
|
|
timestamp: new Date(value.timestamp),
|
|
info: value.video_analysis['qwen-7B'].extracted_info,
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// 按时间降序排序
|
|
events.sort((a, b) => b.timestamp - a.timestamp);
|
|
|
|
// 只显示前3个事件
|
|
events.slice(0, 3).forEach(event => {
|
|
const eventItem = document.createElement('div');
|
|
eventItem.className = 'event-list-item';
|
|
eventItem.innerHTML = `
|
|
<div class="event-info">
|
|
<div class="event-icon">
|
|
<i class="material-icons">${getActionIcon(event.info.actions[0])}</i>
|
|
</div>
|
|
<div class="event-details">
|
|
<strong>${event.info.actions.join(', ')}</strong>
|
|
<span class="event-time">${event.timestamp.toLocaleTimeString()}</span>
|
|
</div>
|
|
</div>
|
|
<div class="event-features">
|
|
<span class="confidence-badge">人数: ${event.info.num_people}</span>
|
|
</div>
|
|
`;
|
|
eventListContent.appendChild(eventItem);
|
|
});
|
|
|
|
// 清除现有事件列表并添加新的
|
|
const oldContent = eventList.querySelector('.event-list-header').nextElementSibling;
|
|
if (oldContent) {
|
|
oldContent.remove();
|
|
}
|
|
eventList.appendChild(eventListContent);
|
|
}
|
|
|
|
// 获取行为对应的图标
|
|
function getActionIcon(action) {
|
|
const iconMap = {
|
|
'走': 'directions_walk',
|
|
'站': 'accessibility',
|
|
'跑': 'directions_run',
|
|
'坐': 'event_seat',
|
|
'工作': 'computer',
|
|
'吃': 'restaurant',
|
|
'喝水': 'local_drink'
|
|
};
|
|
|
|
for (const [key, icon] of Object.entries(iconMap)) {
|
|
if (action.includes(key)) {
|
|
return icon;
|
|
}
|
|
}
|
|
return 'help_outline';
|
|
}
|
|
|
|
// 初始化页面
|
|
async function initPage() {
|
|
// 绑定摄像头切换事件
|
|
const cameraItems = document.querySelectorAll('.camera-item');
|
|
cameraItems.forEach((item, index) => {
|
|
item.addEventListener('click', async () => {
|
|
// 更新UI状态
|
|
cameraItems.forEach(cam => cam.classList.remove('active'));
|
|
item.classList.add('active');
|
|
|
|
// 设置日期为今天
|
|
const today = new Date().toISOString().split('T')[0];
|
|
const datePickers = document.querySelectorAll('input[type="date"]');
|
|
datePickers.forEach(picker => picker.value = today);
|
|
|
|
// 清除页面数据
|
|
clearPageData();
|
|
|
|
// 重新加载数据
|
|
await loadCameraData(`camera00${index + 1}`);
|
|
});
|
|
});
|
|
|
|
// 绑定日期选择事件
|
|
const datePickers = document.querySelectorAll('input[type="date"]');
|
|
datePickers.forEach(picker => {
|
|
picker.valueAsDate = new Date();
|
|
picker.addEventListener('change', async () => {
|
|
const activeCamera = document.querySelector('.camera-item.active');
|
|
const cameraIndex = Array.from(cameraItems).indexOf(activeCamera);
|
|
await loadCameraData(`camera00${cameraIndex + 1}`, picker.value.replace(/-/g, ''));
|
|
});
|
|
});
|
|
|
|
// 绑定搜索框事件
|
|
const searchInput = document.querySelector('.search-box input');
|
|
searchInput.addEventListener('input', handleSearch);
|
|
|
|
// 初始加载第一个摄像头的数据
|
|
await loadCameraData('camera001');
|
|
|
|
// 绑定窗口大小改变事件
|
|
window.addEventListener('resize', function() {
|
|
const charts = document.querySelectorAll('.chart-container');
|
|
charts.forEach(container => {
|
|
const chart = echarts.getInstanceByDom(container);
|
|
if (chart) {
|
|
chart.resize();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// 加载摄像头数据
|
|
async function loadCameraData(cameraId, date) {
|
|
const data = await fetchCameraData(cameraId, date);
|
|
if (data && data.data) {
|
|
const stats = parseVideoAnalysis(data.data);
|
|
updateStatCards(stats);
|
|
updateTimeline(data.data);
|
|
updateCharts(stats);
|
|
updateEventList(data.data);
|
|
}
|
|
}
|
|
|
|
// 处理搜索
|
|
function handleSearch(e) {
|
|
const searchText = e.target.value.toLowerCase();
|
|
|
|
// 处理时间轴事件
|
|
const timelineEvents = document.querySelectorAll('.event-item');
|
|
timelineEvents.forEach(event => {
|
|
const eventText = event.textContent;
|
|
if (searchText === '') {
|
|
event.style.opacity = '1';
|
|
event.style.transform = 'translateY(0)';
|
|
event.style.height = '24px';
|
|
event.style.backgroundColor = '';
|
|
} else if (eventText.toLowerCase().includes(searchText)) {
|
|
event.style.opacity = '1';
|
|
event.style.transform = 'translateY(-2px)';
|
|
event.style.height = '28px';
|
|
event.style.backgroundColor = 'var(--primary-color)';
|
|
} else {
|
|
event.style.opacity = '0.3';
|
|
event.style.transform = 'translateY(2px)';
|
|
event.style.height = '20px';
|
|
}
|
|
});
|
|
|
|
// 处理事件列表
|
|
const eventItems = document.querySelectorAll('.event-list-item');
|
|
eventItems.forEach(item => {
|
|
const behaviorElement = item.querySelector('.event-details strong');
|
|
const timeElement = item.querySelector('.event-time');
|
|
const behaviorText = behaviorElement.textContent;
|
|
const timeText = timeElement.textContent;
|
|
|
|
if (behaviorText.toLowerCase().includes(searchText) ||
|
|
timeText.toLowerCase().includes(searchText)) {
|
|
item.style.display = 'flex';
|
|
if (searchText) {
|
|
behaviorElement.innerHTML = highlightText(behaviorText, searchText);
|
|
timeElement.innerHTML = highlightText(timeText, searchText);
|
|
} else {
|
|
behaviorElement.textContent = behaviorText;
|
|
timeElement.textContent = timeText;
|
|
}
|
|
} else {
|
|
item.style.display = 'none';
|
|
}
|
|
});
|
|
}
|
|
|
|
// 高亮搜索文本
|
|
function highlightText(text, searchText) {
|
|
if (!searchText) return text;
|
|
const regex = new RegExp(`(${searchText})`, 'gi');
|
|
return text.replace(regex, '<span class="highlight">$1</span>');
|
|
}
|
|
|
|
function initPageSwitching() {
|
|
const dailySummaryNav = document.querySelector('.daily-summary');
|
|
const cameraItems = document.querySelectorAll('.camera-item');
|
|
const regularContent = document.querySelectorAll('.dashboard-grid, .timeline-card, .chart-grid, .event-list');
|
|
const summarySection = document.querySelector('.summary-section');
|
|
|
|
// 初始状态设置
|
|
summarySection.style.display = 'none';
|
|
|
|
dailySummaryNav.addEventListener('click', function() {
|
|
// 隐藏常规内容
|
|
regularContent.forEach(item => item.style.display = 'none');
|
|
// 显示总结内容
|
|
summarySection.style.display = 'block';
|
|
// 更新导航状态
|
|
cameraItems.forEach(item => item.classList.remove('active'));
|
|
dailySummaryNav.classList.add('active');
|
|
});
|
|
|
|
// 点击摄像头时的处理
|
|
cameraItems.forEach(item => {
|
|
item.addEventListener('click', function() {
|
|
// 显示常规内容,根据不同类型设置不同的display值
|
|
regularContent.forEach(content => {
|
|
if (content.classList.contains('dashboard-grid')) {
|
|
content.style.display = 'grid';
|
|
} else if (content.classList.contains('chart-grid')) {
|
|
content.style.display = 'grid';
|
|
} else {
|
|
content.style.display = 'block';
|
|
}
|
|
});
|
|
// 隐藏总结内容
|
|
summarySection.style.display = 'none';
|
|
// 更新导航状态
|
|
dailySummaryNav.classList.remove('active');
|
|
cameraItems.forEach(cam => cam.classList.remove('active'));
|
|
this.classList.add('active');
|
|
});
|
|
});
|
|
}
|
|
|
|
// 添加清除页面数据的函数
|
|
function clearPageData() {
|
|
// 清除统计卡片数据
|
|
document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = '0';
|
|
document.querySelector('.stat-card:nth-child(2) .stat-value').textContent = '0%';
|
|
document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = '0';
|
|
|
|
// 清除时间轴事件
|
|
const timelineEvents = document.querySelector('.timeline-events');
|
|
timelineEvents.innerHTML = '';
|
|
|
|
// 清除图表数据
|
|
const charts = document.querySelectorAll('.chart-container');
|
|
charts.forEach(container => {
|
|
const chart = echarts.getInstanceByDom(container);
|
|
if (chart) {
|
|
chart.clear();
|
|
}
|
|
});
|
|
|
|
// 清除事件列表
|
|
const eventList = document.querySelector('.event-list');
|
|
const eventListContent = eventList.querySelector('.event-list-header').nextElementSibling;
|
|
if (eventListContent) {
|
|
eventListContent.remove();
|
|
}
|
|
}
|
|
|
|
window.onload = function() {
|
|
initPage();
|
|
initPageSwitching();
|
|
|
|
// 保留窗口大小改变事件监听
|
|
window.addEventListener('resize', function() {
|
|
const charts = document.querySelectorAll('.chart-container');
|
|
charts.forEach(container => {
|
|
const chart = echarts.getInstanceByDom(container);
|
|
if (chart) {
|
|
chart.resize();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
</script>
|
|
</body>
|
|
</html> |