读取txt中的xy,在单个图片上打点,融合视频
import numpy as np
import cv2,os
from PIL import ImageFont, ImageDraw, Image
import colorsys
import numpy as np
from collections import deque
from numpy.lib.npyio import savez_compressed
class DrawGroung():
def __init__(self,inputDir=r'C:\Users\78241\Desktop\7415\trj',outputDir=r'C:\Users\78241\Desktop\7415\trj',fontDir="./simsun.ttc"):
self._update_ms = 33.334 # 每个多少 毫秒更新一帧图片
self._window_shape = (1920, 1080) #绘制图片尺寸
self.ground_shape=(60,30) #真实场地尺寸
self.ground_init=(24,13) #中间场地位置
self.ground_line=1.4 #开始线的间隔
self.rootDir='./' # 绘制文件的根目录
self.people_ids = 1 #绘制人物数量
self.Track_length = 100 #轨迹的长度
self.inputDir=inputDir
self.ouputDir=outputDir
self.fontpath = fontDir
self.initialCanvas()
self.drawRoundRec()
def initialCanvas(self):
self.canvas = np.uint8(np.zeros((self._window_shape[1], self._window_shape[0], 3))) #初始化画布背景
self.backgorund_color=(255, 255, 255, 0) #背景颜色
self.word_color = (255, 255, 255, 0) #初始化文字颜色
self.middle_color = (0, 0, 0, 0,) #场地中部分的颜色
self.middle_border_color = (255, 0, 0, 0) #场地边框的颜色
self.line_color = (150, 0, 0, 0) #开始以及结束线的颜色
self.line_width = 1 #开始以及结束线的宽度
self.Magnification = min(self._window_shape[0]//self.ground_shape[0],self._window_shape[1]//self.ground_shape[1])#放大倍数
self.colors = []
for i in range(self.people_ids):
self.colors.append(self.create_unique_color_float(i))
def create_unique_color_float(self,tag, hue_step=0.41):
"""Create a unique RGB color code for a given track id (tag).
"""
h, v = (tag * hue_step) % 1, 1. - (int(tag * hue_step) % 4) / 5.
r, g, b = colorsys.hsv_to_rgb(h, 1., v)
return int(255 * r),