def CreatFrame(self): for point in self.lastFrame.pointsList: if point.flag == 1: #如果当前点为真实点,则将改点传入对应的真实点产生函数中 RP = Point.RealPtGenerator(point.x, point.y, point.moveType, point.speed, point.accelerate, point.movAngle) self.pointsList.append(RP) else: #如果当前点为虚假点,则调用虚假点产生函数 FP = Point.FakePtGenerator() self.pointsList.append(FP)
def __init__(self, realTrackNum=5, fakeTrackNum=10, frameNo=0, lastFrame=None): self.pointsList = [] self.realTrackNum = realTrackNum self.fakeTrackNum = fakeTrackNum self.frameNo = frameNo if lastFrame == None: #第一帧数据由用户给出 for i in range(int(self.realTrackNum)): if AUTOTESTEN == False: #非自动测试的情况下,需要用户手动输入运动参数 print("第", i + 1, "个航迹的运动类型(UL,AL,UT):", end='') movType = input() if movType != 'UL' and movType != 'AL' and movType != 'UT': raise Exception("Wrong Move Type!") print("第", i + 1, "个航迹的x坐标(-7.5~7.5):", end='') x = float(input()) print("第", i + 1, "个航迹的y坐标(0~40):", end='') y = float(input()) print("第", i + 1, "个航迹的初始速度:", end='') speed = float(input()) print("第", i + 1, "个航迹的运动角度(-0.2~0.2):", end='') movAngle = float(input()) if movType == 'AL': print("第", i + 1, "个航迹的加速度:", end='') accelerate = float(input()) else: accelerate = 0.0 else: #自动测试时读取参数列表作为仿真数据来源 autoTestData = AutoTestDataGen(DefaultData, AUTOTESTSET['realTrackNum']) movType = autoTestData[i]["movType"] x = autoTestData[i]["x"] y = autoTestData[i]["y"] speed = autoTestData[i]["speed"] movAngle = autoTestData[i]["movAngle"] accelerate = autoTestData[i]["accelerate"] RP = Point.RealPtGenerator(x, y, movType, speed, accelerate, movAngle) #根据第一帧运动产生真实点迹 self.pointsList.append(RP) for i in range(int(self.fakeTrackNum)): #根据设置的每帧虚假点个数生成虚假点 FP = Point.FakePtGenerator() self.pointsList.append(FP) else: self.lastFrame = lastFrame