纯原创,略带点科技艺术气息的目标检测框

简介: 纯原创,略带点科技艺术气息的目标检测框

🔱前言


       如果说作为一名程序员,我要求我自己要不断的求证,那么同时作为一名热爱艺术的人,我则无法忍受主流的那种“丑陋”目标检测框(下图),所以这篇文章也就应用而生了。


1dc618a0ed9580ce8bfa6facb208c08f.png


🔱检测框展览


1dc618a0ed9580ce8bfa6facb208c08f.png



5d4c6812c8535adbb050f4ddf2e1bce8.png

46a9d80a6e05e4e3b19d57a0ee70bcdf.png


🔱在实际应用中效果的展览


📍Face


b001cd2dd849a60e17405f7ed5f145b8.jpeg


📍Body


66ba272a0bfc97be54a5fa679e3d5482.png


🔱Code柜


📍magic_bbox.py


# -*- coding: UTF-8 -*-
"""
@Time    : 2022-9-15
@Author  : 江子良
@Email   : 2642898145@qq.com
"""
import cv2
import numpy as np
class Magic_Bbox(object):
    def __init__(self, color=(255, 255, 0), threasould=25):
        self.color = color
        self.threasould = threasould
        self.out_img = np.array([])
    def draw(self, old_image, b, draw_type):
        if draw_type == '0':
            cv2.rectangle(old_image, (b[0], b[1]), (b[2], b[3]), self.color, 1)
            b0_, b1_, b2_, b3_ = self.threasould, self.threasould, self.threasould, self.threasould
            # 左上
            cv2.line(old_image, (b[0], b[1]), (b[0], b[1] + b1_), self.color, 4, 4)
            cv2.line(old_image, (b[0], b[1]), (b[0] + b0_, b[1]), self.color, 4, 4)
            # 右下
            cv2.line(old_image, (b[2], b[3]), (b[2], b[3] - b3_), self.color, 4, 4)
            cv2.line(old_image, (b[2], b[3]), (b[2] - b2_, b[3]), self.color, 4, 4)
            # 左下
            cv2.line(old_image, (b[0], b[3]), (b[0], b[3] - b3_), self.color, 4, 4)
            cv2.line(old_image, (b[0], b[3]), (b[0] + b0_, b[3]), self.color, 4, 4)
            # 右上
            cv2.line(old_image, (b[2], b[1]), (b[2], b[1] + b1_), self.color, 4, 4)
            cv2.line(old_image, (b[2], b[1]), (b[2] - b2_, b[1]), self.color, 4, 4)
        elif draw_type == '1':
            cv2.rectangle(old_image, (b[0], b[1]), (b[2], b[3]), self.color, 1)
            b0_, b1_, b2_, b3_ = 25, 25, 25, 25
            temp = 10
            # 左上
            cv2.line(old_image, (b[0] - temp, b[1] - temp), (b[0], b[1] + b1_), self.color, 4, 4)
            cv2.line(old_image, (b[0] - temp, b[1] - temp), (b[0] + b0_, b[1]), self.color, 4, 4)
            # 右下
            cv2.line(old_image, (b[2] + temp, b[3] + temp), (b[2], b[3] - b3_), self.color, 4, 4)
            cv2.line(old_image, (b[2] + temp, b[3] + temp), (b[2] - b2_, b[3]), self.color, 4, 4)
            # 左下
            cv2.line(old_image, (b[0] - temp, b[3] + temp), (b[0], b[3] - b3_), self.color, 4, 4)
            cv2.line(old_image, (b[0] - temp, b[3] + temp), (b[0] + b0_, b[3]), self.color, 4, 4)
            # 右上
            cv2.line(old_image, (b[2] + temp, b[1] - temp), (b[2], b[1] + b1_), self.color, 4, 4)
            cv2.line(old_image, (b[2] + temp, b[1] - temp), (b[2] - b2_, b[1]), self.color, 4, 4)
        elif draw_type == '2':
            cv2.rectangle(old_image, (b[0], b[1]), (b[2], b[3]), self.color, 1)
            b0_, b1_, b2_, b3_ = 25, 25, 25, 25
            temp = 10
            # 左上
            cv2.line(old_image, (b[0] - temp, b[1] - temp), (b[0] - temp, b[1] + b1_ - temp), self.color, 4, 4)
            cv2.line(old_image, (b[0] - temp, b[1] - temp), (b[0] - temp + b0_, b[1] - temp), self.color, 4, 4)
            # 右下
            cv2.line(old_image, (b[2] + temp, b[3] + temp), (b[2] + temp, b[3] - b3_ + temp), self.color, 4, 4)
            cv2.line(old_image, (b[2] + temp, b[3] + temp), (b[2] + temp - b2_, b[3] + temp), self.color, 4, 4)
            # 左下
            cv2.line(old_image, (b[0] - temp, b[3] + temp), (b[0] - temp, b[3] - b3_ + temp), self.color, 4, 4)
            cv2.line(old_image, (b[0] - temp, b[3] + temp), (b[0] - temp + b0_, b[3] + temp), self.color, 4, 4)
            # 右上
            cv2.line(old_image, (b[2] + temp, b[1] - temp), (b[2] + temp, b[1] + b1_ - temp), self.color, 4, 4)
            cv2.line(old_image, (b[2] + temp, b[1] - temp), (b[2] + temp - b2_, b[1] - temp), self.color, 4, 4)
        return old_image
    def show(self, img):
        cv2.imshow('fame', img)
        cv2.waitKey(0)


📍demo.py


@Time    : 2022-9-15
@Author  : 江子良
@Email   : 2642898145@qq.com
@param: img | 这个参数是要传入准备被作画的图片
@param:bbox| 这个参数是要传入准备作画的目标框位置 格式:(xmin,ymin,xmax,ymax)
@pararm:type| 这个参数是一一对应上面3种不同的目标检测框
@pararm:color| 请根据RGB表自行设置哦!
"""

RGB颜色对照表戳这里~

http://t.csdn.cn/9z0SF

How to use?


from magic_bbox import Magic_Bbox
import numpy as np
import cv2
if __name__ == "__main__":
    img = np.zeros((320, 320, 3), np.uint8)  # 生成一个空灰度图像
    bbox = (60, 60, 260, 260)
    color = (255,255,0)
    '''
    type: 0 | 1 | 2
    '''
    mb = Magic_Bbox(color=color)
    img = mb.draw(img, bbox, '1')
    mb.show(img)

完毕!


如果大家觉得有用的话,欢迎三连喔~


相关文章
|
6天前
|
机器学习/深度学习 编解码 人工智能
麻省理工AI新研究可将马赛克变视频
【2月更文挑战第30天】麻省理工学院等机构的研究团队推出AI新技术FeatUp,可将低分辨率图像提升为高清视频,该技术在2024年ICLR会议上引起关注。FeatUp基于深度特征提取,通过多视角一致性损失恢复空间信息,提高视频清晰度。模型通用性强,适用于多种任务和现有应用。实验显示,它在图像超分辨率和端到端学习模型性能提升上超越其他方法。然而,尚存在对某些内容处理不完善和计算资源需求高的局限性。
61 2
麻省理工AI新研究可将马赛克变视频
|
6天前
|
人工智能 计算机视觉
CVPR 2024:跳舞时飞扬的裙摆,AI也能高度还原了,南洋理工提出动态人体渲染新范式
【5月更文挑战第6天】南洋理工大学研究团队在CVPR 2024会议上提出SurMo,一种动态人体渲染新方法,能高度还原视频中的人物动作和细节,如飞扬的裙摆。SurMo通过4D运动建模,结合表面运动编码、物理运动解码和4D外观解码,实现动态图像的精确合成。尽管面临复杂动作捕捉和计算资源需求的挑战,SurMo在动态人体渲染任务上表现出色,展现了表面基运动三角平面的强大表达能力。[论文链接](https://arxiv.org/pdf/2404.01225.pdf)
19 1
|
6天前
|
人工智能 自然语言处理 vr&ar
ControlNet作者重磅新作LayerDiffusion,AI绘画能分图层了
【2月更文挑战第13天】ControlNet作者重磅新作LayerDiffusion,AI绘画能分图层了
49 2
ControlNet作者重磅新作LayerDiffusion,AI绘画能分图层了
|
6天前
|
人工智能
AI画出奥特曼是否侵权?
【2月更文挑战第9天】AI画出奥特曼是否侵权?
38 1
AI画出奥特曼是否侵权?
|
7月前
|
人工智能 机器人
人工智能 AI 绘画 AI绘制的图片 ? 简介的版权,以及如何使用图像生成AI 绘画 ?
人工智能 AI 绘画 AI绘制的图片 ? 简介的版权,以及如何使用图像生成AI 绘画 ?
245 0
|
8月前
|
机器学习/深度学习 人工智能 自然语言处理
让梦境绘入现实--AIGC人像绘画
在光怪陆离的梦境中,我们可以摆脱客观事实的约束,对自己的外在形象进行天马行空的畅想,有人化身威风凛凛的将军驰骋疆场,又有人化身亭亭玉立的公主正襟危坐,然而这些翩若惊鸿婉若游龙的美好瞬间却总是会随着一声闹钟的响声化为泡影。难道梦境中的自己总是不能被带回到现实之中吗?AIGC技术的快速发展使得这一点成为可能。
380 1
|
人工智能 自然语言处理
最懂中国传统文化的AI绘画模型,画作有形更有神,传达儒释道思想
最懂中国传统文化的AI绘画模型,画作有形更有神,传达儒释道思想
365 0
|
机器学习/深度学习 人工智能 数据可视化
CVPR 2022 | 北大、腾讯提出文字logo生成模型,脑洞大开堪比设计师
CVPR 2022 | 北大、腾讯提出文字logo生成模型,脑洞大开堪比设计师
163 0
|
机器学习/深度学习 人工智能 编解码
OpenAI的DALL·E迎来升级,不止文本生成图像,还可二次创作
OpenAI的DALL·E迎来升级,不止文本生成图像,还可二次创作
112 0
|
编解码 测试技术 网络架构
叫板DALL·E 2,预训练大模型做编码器,谷歌把文字转图像模型卷上天(2)
叫板DALL·E 2,预训练大模型做编码器,谷歌把文字转图像模型卷上天
147 0