| | |
| | | } |
| | | return |
| | | } |
| | | |
| | | // 根据cid查询视频 |
| | | func GetTaskTotal(cid string) (total int, err error) { |
| | | sql := "select count(1) as total from mal_task_video_link where video_id='" + cid + "'" |
| | | err = db.Raw(sql).Count(&total).Error |
| | | if err != nil { |
| | | return 0, err |
| | | } |
| | | return total, nil |
| | | } |
| | |
| | | if cid == "" { |
| | | return &bhomeclient.Reply{Msg: "参数有误,摄像机id不能为空"} |
| | | } |
| | | |
| | | //判断是否有配置任务 |
| | | total, _ := models.GetTaskTotal(cid) |
| | | if total > 0 { |
| | | return &bhomeclient.Reply{Success: false, Msg: "请先删除配置的任务"} |
| | | } |
| | | |
| | | rows, _ := cam.Delete(cid) |
| | | if rows == 0 { |
| | | return &bhomeclient.Reply{Success: true, Msg: "记录不存在"} |
| | |
| | | } |
| | | |
| | | var ModleProc = map[string]string{ |
| | | "python smart_detect.py": "目标检测模型", |
| | | "/usr/bin/python qwen_detect.py": "图片解析模型", |
| | | "python app.py": "对话检索模型", |
| | | "python smart_detect.py": "目标检测模型", |
| | | "/usr/bin/python smart_detect.py": "目标检测模型", |
| | | "python qwen_detect.py": "图片解析模型", |
| | | "/usr/bin/python qwen_detect.py": "图片解析模型", |
| | | "python app.py": "对话检索模型", |
| | | "/usr/bin/python app.py": "对话检索模型", |
| | | } |
| | | |
| | | type UsedMap map[int]int64 |
| | |
| | | |
| | | ps, _ := process.Processes() |
| | | |
| | | for k, v := range ModleProc { |
| | | proc := Proc{ |
| | | Name: k, |
| | | Desc: v, |
| | | } |
| | | |
| | | for _, p := range ps { |
| | | for _, p := range ps { |
| | | for k, v := range ModleProc { |
| | | if name, err := p.Cmdline(); err == nil { |
| | | |
| | | if name == k { |
| | | proc := Proc{ |
| | | Name: k, |
| | | Desc: v, |
| | | Cpu: 0, |
| | | Mem: 0, |
| | | Gpu: 0, |
| | | } |
| | | proc.Pid = p.Pid |
| | | proc.Cpu, _ = p.CPUPercent() |
| | | proc.Mem, _ = p.MemoryPercent() |
| | | proc.Gpu = gpuPer.Get(int(p.Pid)) |
| | | break |
| | | rsp = append(rsp, proc) |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | rsp = append(rsp, proc) |
| | | } |
| | | |
| | | return |