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

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

🔱前言


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


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)

完毕!


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


相关文章
|
2月前
|
测试技术 网络架构 计算机视觉
中科院领衔发表首篇基于扩散模型的图像编辑综述
【2月更文挑战第17天】中科院领衔发表首篇基于扩散模型的图像编辑综述
39 1
中科院领衔发表首篇基于扩散模型的图像编辑综述
|
2月前
|
人工智能 自然语言处理 vr&ar
ControlNet作者重磅新作LayerDiffusion,AI绘画能分图层了
【2月更文挑战第13天】ControlNet作者重磅新作LayerDiffusion,AI绘画能分图层了
73 2
ControlNet作者重磅新作LayerDiffusion,AI绘画能分图层了
|
2月前
|
人工智能
AI画出奥特曼是否侵权?
【2月更文挑战第9天】AI画出奥特曼是否侵权?
50 1
AI画出奥特曼是否侵权?
|
机器学习/深度学习 网络架构
多模态图像合成与编辑这么火,马普所、南洋理工等出了份详细综述
多模态图像合成与编辑这么火,马普所、南洋理工等出了份详细综述
|
机器学习/深度学习 编解码 vr&ar
DALL-E、「女娲」刷屏背后,多模态图像合成与编辑领域进展如何?
DALL-E、「女娲」刷屏背后,多模态图像合成与编辑领域进展如何?
150 0
|
传感器 文字识别 监控
【技术分享】计算机视觉常见的十种图像标注方法
【技术分享】计算机视觉常见的十种图像标注方法
469 0
【技术分享】计算机视觉常见的十种图像标注方法
|
机器学习/深度学习 人工智能 监控
视频目标跟踪研究背景介绍
视频目标跟踪是计算机视觉领域重要的研究内容,主要研究在视频流或者图像序列中定位其中感兴趣的物体。视频目标跟踪在视频监控、无人驾驶、精确制导等领域中具有广泛的应用,因此,全面地综述视频目标跟踪算法具有重要的意义。
350 0
|
机器学习/深度学习 人工智能 前端开发
AI教父Hinton胶囊模型又出新作——胶囊如何表示视觉层次结构
AI教父Hinton胶囊模型又出新作——胶囊如何表示视觉层次结构
240 0
AI教父Hinton胶囊模型又出新作——胶囊如何表示视觉层次结构
|
机器学习/深度学习 人工智能 算法
给图片打「马赛克」可骗过AI视觉系统,阿里安全新研究入选ICCV 2021
来自阿里安全人工智能治理与可持续发展实验室(AAIG)等机构的研究者提出了一个新的机制来生成对抗样本,即与增加对抗扰动相反,他们通过扔掉一些不可察觉的图像细节来生成对抗样本。这项研究成果已被 AI 顶会 ICCV 2021 收录。
239 0
给图片打「马赛克」可骗过AI视觉系统,阿里安全新研究入选ICCV 2021
|
机器学习/深度学习 人工智能 自然语言处理
发表Nature封面论文「大脑语义地图」之后的研究进展
加州伯克利大学的 Jack Gallant 和他的团队(Gallant 认知、计算和系统神经科学实验室)终于成功绘制出大脑语义地图(985 个英语常用词汇语义)。
585 0
发表Nature封面论文「大脑语义地图」之后的研究进展