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

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

🔱前言


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


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)

完毕!


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


相关文章
|
5月前
|
人工智能 开发工具 计算机视觉
AI计算机视觉笔记三十:yolov8_obb旋转框训练
本文介绍了如何使用AUTODL环境搭建YOLOv8-obb的训练流程。首先创建虚拟环境并激活,然后通过指定清华源安装ultralytics库。接着下载YOLOv8源码,并使用指定命令开始训练,过程中可能会下载yolov8n.pt文件。训练完成后,可使用相应命令进行预测测试。
|
5月前
|
人工智能 监控 算法
AI计算机视觉笔记二十 八:基于YOLOv8实例分割的DeepSORT多目标跟踪
本文介绍了YOLOv8实例分割与DeepSORT视觉跟踪算法的结合应用,通过YOLOv8进行目标检测分割,并利用DeepSORT实现特征跟踪,在复杂环境中保持目标跟踪的准确性与稳定性。该技术广泛应用于安全监控、无人驾驶等领域。文章提供了环境搭建、代码下载及测试步骤,并附有详细代码示例。
|
机器学习/深度学习 编解码 算法
【阿里云OpenVI-视觉生产系列之图片上色】照片真实感上色算法DDColor ICCV2023论文深入解读
图像上色是老照片修复的一个关键步骤,本文介绍发表在 ICCV 2023 上的最新上色论文 DDColor
2954 10
【阿里云OpenVI-视觉生产系列之图片上色】照片真实感上色算法DDColor ICCV2023论文深入解读
|
机器学习/深度学习 算法 决策智能
计算机视觉实战(十二)全景图像拼接(附完整代码)
计算机视觉实战(十二)全景图像拼接(附完整代码)
481 0
|
机器学习/深度学习 编解码 自然语言处理
现代目标检测故事(二)
现代目标检测故事
303 0
|
机器学习/深度学习 编解码 算法
现代目标检测故事(一)
现代目标检测故事
128 0
|
机器学习/深度学习 编解码 并行计算
现代目标检测故事(三)
现代目标检测故事
222 0
|
传感器 文字识别 监控
【技术分享】计算机视觉常见的十种图像标注方法
【技术分享】计算机视觉常见的十种图像标注方法
616 0
【技术分享】计算机视觉常见的十种图像标注方法
|
机器学习/深度学习 人工智能 文字识别
大厂技术实现 | 图像检索及其在高德的应用 @计算机视觉系列
图像检索任务指的是,给定查询图像,从图像数据库中找到包含相同或相似实例的图像。本文研究的是高德地图POI信息更新,即根据自有图像源,将每个新增或调整的POI及时制作成数据。这是非常典型的图像检索垂直应用,整套方便背后也包含大量CV技术。本篇我们结合资深CV工程师章鱼的分享,一起研究『高德地图POI信息更新』这一业务背景中,应用到的计算机视觉技术。
4177 3
大厂技术实现 | 图像检索及其在高德的应用 @计算机视觉系列

热门文章

最新文章