def loadPersonOne(): file = open("/data/person1Frame.txt", 'r') # currWin = None person = Person() poseSequence = [] count = 0 index = 0 poseSequence.append(Pose()) for line in file: if "#" in line: poseSequence[index].Normalize(10) poseSequence.append(Pose()) count = 0 index += 1 else: x, y, con = line.split(" ") node = Node(count, int(x), int(y), con) poseSequence[index].addNode(node) count += 1 person.addPoseSequence(poseSequence) # currWin = GraphWin("window", 1000, 1000) # for poseIndex in person.getPoseSequence(): # currWin = GraphWin("window", 1000, 1000) # for node in poseIndex.getNormalizedPoseNodes(): # circle = Circle(Point(node.getX(), node.getY()), 3) # circle.setFill("red") # circle.draw(currWin) # currWin.getMouse() file.close() return person
def loadPersonTwo(cwd, viewWidth, viewHeight): file = open(cwd + "/data/person2Frame.txt", 'r') # currWin = None person = Person(viewWidth, viewHeight) person.setOriginalAngle(120) poseSequence = [] count = 0 index = 0 poseSequence.append(Pose()) for line in file: line = line.replace("\n", "") if "#" in line: poseSequence[index].rawNormalize() poseSequence.append(Pose()) count = 0 index += 1 else: print(line) x, y, con = line.split(" ") node = Node(count, int(x), int(y), con) poseSequence[index].addNode(node) count += 1 person.addPoseSequence(poseSequence) file.close() return person
def createRandomNoise(currPose): newPose = Pose() for node in currPose.getPoseNodes(): newNode = Node(node.getID(), node.getX() / (1 + (50 / node.getX())), node.getY() / (1 + (50 / node.getY())), node.getConfidence()) newPose.addNode(newNode) return newPose
def walk(self, speed, changingAngle): self.walkingDirection += changingAngle dx = speed * math.cos(math.radians(self.walkingDirection)) dy = speed * math.sin(math.radians(self.walkingDirection)) self.currX += dx self.currY -= dy newPose = Pose() minX, minY, maxX, maxY = newPose.getBound() xMean = maxX / 2 for node in self.poseSequence[self.poseIndex % len( self.poseSequence)].getNormalizedPoseNodes(): newNode = Node( node.getID(), self.currX + (1800 / self.getCurrentDistance()) * (node.getX() - xMean) * math.cos( math.radians(self.walkingDirection - self.originalAngle)), self.currY + (1800 / self.getCurrentDistance()) * (node.getY() + 0.25 * (node.getX() - xMean) * math.sin( math.radians(self.walkingDirection - self.originalAngle))), node.getConfidence()) newPose.addNode(newNode) self.walkingTrace.append(newPose) self.poseIndex += 1 return newPose
def addPose(self, pose): self.poseSequence.append(pose) if len(self.poseSequence) == 1: self.nextPosePrediction = self.poseSequence[0] else: predictPose = Pose() lastPose = self.poseSequence[-1] lastlastPose = self.poseSequence[-2] for i in range(len(lastPose.getPoseNodes())): if i > 17: break lastNodes = lastPose.getPoseNodes() lastlastNodes = lastlastPose.getPoseNodes() if lastNodes[i].getConfidence( ) != 0 and lastlastNodes[i].getConfidence() != 0: node = Node( i, 2 * lastNodes[i].getX() - lastlastNodes[i].getX(), 2 * lastNodes[i].getY() - lastlastNodes[i].getY(), 0.5 * (lastNodes[i].getConfidence() + lastlastNodes[i].getConfidence())) else: node = Node(i, 0, 0, 0) predictPose.addNode(node) self.nextPosePrediction = predictPose
def createNewPose(pose1, pose2): newPose = Pose() for i in range(0, len(pose1.getPoseNodes())): n = randint(0, 1) print("ggg", i) if n == 0: newPose.addNode(pose1.getPoseNodes()[i]) else: newPose.addNode(pose2.getPoseNodes()[i]) return newPose
def existPerson(pose): if len(person) == 0: return False else: for p in person: if comparator.isPoseBelongsPerson(pose, p): return p return False for line in file: line.replace("\n", "") numbers = line.split(" ") for i in range(1, len(numbers), 54): pose = Pose() count = 0 for j in range(i, i + 54, 3): if j + 2 > len(numbers) - 1: break print(count, numbers[j], numbers[j + 1], numbers[j + 2]) pose.addNode( Node(count, float(numbers[j]), float(numbers[j + 1]), float(numbers[j + 2]))) count += 1 if pose.getAveConfidence() >= 0.4: if existPerson(pose) != False: existPerson(pose).addPose(pose) else: newPerson = Person() newPerson.addPose(pose)
from poseModel.Node import Node from poseModel.Person import Person from poseModel.Pose import Pose from poseModel.graphics import GraphWin, Circle, Point file = open("/data/person1Frame.txt", 'r') # currWin = None person = Person() poseSequence = [] count = 0 index = 0 poseSequence.append(Pose()) for line in file: if "#" in line: poseSequence[index].rawNormalize() poseSequence.append(Pose()) count = 0 index += 1 else: x, y, con = line.split(" ") node = Node(count, int(x), int(y), con) poseSequence[index].addNode(node) count += 1 person.addPoseSequence(poseSequence) currWin = GraphWin("window", 1000, 1000) for poseIndex in person.getPoseSequence(): currWin = GraphWin("window", 1000, 1000) for node in poseIndex.getNormalizedPoseNodes(): circle = Circle(Point(node.getX(), node.getY()), 3) circle.setFill("red") circle.draw(currWin)