first
This commit is contained in:
1 parent
54ccfb11fe
commit
a0818377bb
194 files changed
+41681
-262
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+27
-4
@@ -1,6 +1,5 @@
|
||||
# Plotting utils
|
||||
# !usr/bin/env python
|
||||
# -*- coding:utf-8 _*-
|
||||
|
||||
import glob
|
||||
import math
|
||||
import os
|
||||
@@ -16,12 +15,13 @@ import pandas as pd
|
||||
import seaborn as sns
|
||||
import torch
|
||||
import yaml
|
||||
from common import global_para as gp
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from scipy.signal import butter, filtfilt
|
||||
|
||||
from Y5.utils.general import xywh2xyxy, xyxy2xywh
|
||||
from Y5.utils.metrics import fitness
|
||||
|
||||
from cv2AddChineseText import cv2AddChineseText
|
||||
# Settings
|
||||
matplotlib.rc('font', **{'size': 11})
|
||||
matplotlib.use('Agg') # for writing to files only
|
||||
@@ -55,7 +55,7 @@ def butter_lowpass_filtfilt(data, cutoff=1500, fs=50000, order=5):
|
||||
return filtfilt(b, a, data) # forward-backward filter
|
||||
|
||||
|
||||
def plot_one_box(x, img, color=None, label=None, line_thickness=3):
|
||||
def plot_one_box1(x, img, color=None, label=None, line_thickness=3):
|
||||
# Plots one bounding box on image img
|
||||
tl = line_thickness or round(0.002 * (img.shape[0] + img.shape[1]) / 2) + 1 # line/font thickness
|
||||
color = color or [random.randint(0, 255) for _ in range(3)]
|
||||
@@ -67,8 +67,31 @@ def plot_one_box(x, img, color=None, label=None, line_thickness=3):
|
||||
c2 = c1[0] + t_size[0], c1[1] - t_size[1] - 3
|
||||
cv2.rectangle(img, c1, c2, color, -1, cv2.LINE_AA) # filled
|
||||
cv2.putText(img, label, (c1[0], c1[1] - 2), 0, tl / 3, [225, 255, 255], thickness=tf, lineType=cv2.LINE_AA)
|
||||
def plot_one_box(x, draw, height,width,color=None, label=None, Index = None, line_thickness=3):
|
||||
# Plots one bounding box on image img
|
||||
tl = line_thickness or round(0.002 * (height + width) / 2) + 1 # line/font thickness
|
||||
color = color or tuple(random.randint(0, 255) for _ in range(3))
|
||||
c1, c2 = (int(x[0]), int(x[1])), (int(x[2]), int(x[3]))
|
||||
#ÏÔʾindex
|
||||
|
||||
|
||||
# draw.text((c1[0]-20, c1[1]), str(Index), (0, 0, 255),font=fontStyle)
|
||||
draw.rectangle((c1, c2), fill=None, outline=color, width=tl)
|
||||
if label:
|
||||
tf = max(tl - 1, 1) # font thickness
|
||||
t_size = cv2.getTextSize(label, fontFace=cv2.FONT_HERSHEY_COMPLEX, fontScale=gp.fontScale , thickness=tl)[0]
|
||||
print(label,t_size[0],t_size[1])
|
||||
c1 = c1[0],c1[1]-t_size[1]
|
||||
c2 = c1[0] + t_size[0], c1[1]+t_size[1]
|
||||
draw.rectangle((c1, c2), fill=color, outline=color, width=tl)
|
||||
#cv2.rectangle(img, c1, c2, color, -1, cv2.LINE_AA) # filled
|
||||
#cv2.putText(img, label, (c1[0], c1[1] - 2), 0, tl / 3, [225, 255, 255], thickness=tf, lineType=cv2.LINE_AA)
|
||||
#if not label == None:
|
||||
|
||||
draw = cv2AddChineseText(draw, label,(c1[0], c1[1]), textColor = (225, 255, 255), textSize=tf*17)
|
||||
#img = cv2AddChineseText(img, "ÊýÁ¿: {}".format(str("011")), (2000,100), textColor=(0, 255, 0), textSize=80)
|
||||
return draw
|
||||
|
||||
def plot_one_box_PIL(box, img, color=None, label=None, line_thickness=None):
|
||||
img = Image.fromarray(img)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
Reference in new issue
Block a user