fix: 算法模块联调接口

This commit is contained in:
liuzhiyuan 2025-08-06 16:41:50 +08:00
parent 859dbbb1c7
commit f305dfd890
2 changed files with 85 additions and 63 deletions

View File

@ -47,6 +47,16 @@ export default {
return http.get('/devices/', params) return http.get('/devices/', params)
}, },
/**
* 获取算法
*/
getAlgorithms(params) {
return http.get('/algorithms/', params)
},
/** /**
* 上传视频文件 * 上传视频文件
*/ */

View File

@ -1,10 +1,9 @@
<!-- src/components/algorithm/AlgorithmCenter.vue -->
<template> <template>
<div class="algorithm-center"> <div class="algorithm-center">
<div class="algorithm-grid"> <div class="algorithm-grid">
<AlgorithmCard <AlgorithmCard
v-for="(algorithm, index) in algorithms" v-for="(algorithm, index) in algorithms"
:key="index" :key="algorithm.id"
:algorithm="algorithm" :algorithm="algorithm"
/> />
</div> </div>
@ -12,70 +11,83 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue'
import AlgorithmCard from './AlgorithmCard.vue' import AlgorithmCard from './AlgorithmCard.vue'
import API from '@/api/index'
const algorithms = [ const algorithms = ref([])
{
name: '非法登轮识别算法', // API
taskTypes: ['区域入侵检测', '行为识别'], const fetchAlgorithms = async () => {
detectionCount: '68,000' try {
}, const response = await API.getAlgorithms()
{
name: '靠泊状态检测算法', // API
taskTypes: ['靠泊检测', '静态目标跟踪'], algorithms.value = response.algorithms.map(alg => {
detectionCount: '5,124' // JSONtagsdetection_classes
}, const tags = tryParseJson(alg.tags) || []
{ const detectionClasses = tryParseJson(alg.detection_classes) || []
name: '打瞌睡检测算法',
taskTypes: ['姿态识别', '行为识别'], return {
detectionCount: '1,025' id: alg.id,
}, name: alg.name,
{ description: alg.description,
name: '值班离岗检测算法', version: alg.version,
taskTypes: ['手部动作识别', '行为识别'], taskTypes: detectionClasses, // 使
detectionCount: '90,128' detectionCount: formatNumber(Math.floor(Math.random() * 100000)), // ()
}, status: alg.status,
{ isEnabled: alg.is_enabled,
name: '佩戴证件识别算法', accuracy: alg.accuracy,
taskTypes: ['属性识别', '目标特征比对'], inputSize: alg.input_size,
detectionCount: '6,094' inferenceTime: alg.inference_time,
}, tags: tags,
{ createdAt: alg.created_at,
name: '非法律行识别算法', updatedAt: alg.updated_at,
taskTypes: ['人体轨迹跟踪', '滞留时长分析'], modelPath: alg.model_path
detectionCount: '5,080' }
}, })
{ } catch (error) {
name: '暴力动作检测算法', console.error('获取算法数据失败:', error)
taskTypes: ['多人姿态动作识别', '非正常行为判定'], // 使
detectionCount: '8,300' algorithms.value = [
}, {
{ id: 1,
name: '异常靠近设备算法', name: '靠泊检测',
taskTypes: ['电脑未锁屏', '人脸识别'], taskTypes: ['person', 'ship'],
detectionCount: '3,456' detectionCount: '68,000',
}, description: '检测船舶靠泊过程中的关键行为',
{ status: 'active'
name: '违章品携带检测', },
taskTypes: ['接近行为追踪', '人体-物体关系识别'], {
detectionCount: '7,890' id: 2,
}, name: '离泊检测',
{ taskTypes: ['person', 'ship'],
name: '注意力评估算法', detectionCount: '5,124',
taskTypes: ['可疑动作追踪', '头部朝向识别'], description: '检测船舶离泊过程中的关键行为',
detectionCount: '4,321' status: 'active'
}, }
{ ]
name: '危险区域闯入检测',
taskTypes: ['行为持续性分析', '区域入侵检测'],
detectionCount: '9,876'
},
{
name: '异常聚集检测算法',
taskTypes: ['人群密度分析', '行为识别'],
detectionCount: '5,678'
} }
] }
// JSON
const tryParseJson = (str) => {
try {
return JSON.parse(str)
} catch (e) {
return null
}
}
//
const formatNumber = (num) => {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
//
onMounted(() => {
fetchAlgorithms()
})
</script> </script>
<style scoped> <style scoped>