栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

根据不同的id画不同颜色的框(yolo+deepsort)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

根据不同的id画不同颜色的框(yolo+deepsort)

这是在使用yolo+deepsort时候想要用不同的颜色来区分不同的人
版本v3.0有这个功能
但是我下载的版本v5.0是根据种类的不同来区分颜色的
针对只有一种种类的时候,就只能绘制一种颜色的框,不能有效的区分
所以记录一下。
GitHub地址 :v3.0版本:yolo+deepsort track.py

两种方法:
第一种是将本来根据不同标签生成不同颜色的改成不同id对应不同颜色的
但是这个方法不知道会不会因为目标过多而受限,因为他的颜色好像是一个固定的列表。。。

#annotator.box_label(bboxes, label, color=colors(c, True))
annotator.box_label(bboxes, label, color=colors(int(id), True))

第二种:

# 根据不同的id生成颜色
def compute_color_for_labels(label):
    """
    Simple function that adds fixed color depending on the class
    """
    color = [int((p * (label ** 2 - label + 1)) % 255) for p in palette]
    return tuple(color)
  

#省略很多代码。。。。。。。

if save_vid or save_crop or show_vid:  # Add bbox to image
   c = int(cls)  # integer class 这是根据种类来划分颜色的
   id = int(id)
   label = f'{id} {names[c]} {conf:.2f}'
   # annotator.box_label(bboxes, label, color=colors(c, True))
   color = compute_color_for_labels(id)
   annotator.box_label(bboxes, label, color=color)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/948193.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号