def decodeMultiplePoses( scores, offsets, displacementsFwd, displacementsBwd, width_factor, height_factor, outputStride=16, maxPoseDetections=5, scoreThreshold=0.5, nmsRadius=30, ): poses = [] squaredNmsRadius = nmsRadius * nmsRadius scoresBuffer = np.squeeze(scores) offsetsBuffer = np.squeeze(offsets) displacementsBwdBuffer = np.squeeze(displacementsBwd) displacementsFwdBuffer = np.squeeze(displacementsFwd) height, width, numKeypoints = scoresBuffer.shape queue = MaxHeap(height * width * numKeypoints, scoresBuffer) buildPartWithScoreQueue(scoreThreshold, kLocalMaximumRadius, scoresBuffer, queue) while len(poses) < maxPoseDetections and queue.empty() is False: root = queue.dequeue() rootImageCoords = getImageCoords(root["part"], outputStride, offsetsBuffer) if (withinNmsRadiusOfCorrespondingPoint( poses, squaredNmsRadius, rootImageCoords, root["part"]["id"]) is True): continue # Start a new detection instance at the position of the root. keypoints = decodePose( root, scoresBuffer, offsetsBuffer, outputStride, displacementsFwdBuffer, displacementsBwdBuffer, ) for keypoint in keypoints: keypoint["position"]["y"] *= height_factor keypoint["position"]["x"] *= width_factor score = getInstanceScore(poses, squaredNmsRadius, keypoints) poses.append({"keypoints": keypoints, "score": score}) return poses
def decodeMultiplePoses(scores, offsets, displacementsFwd, displacementsBwd, \ width_factor, height_factor, \ outputStride=16, maxPoseDetections=5, scoreThreshold= 0.5, nmsRadius= 30): poses = [] squaredNmsRadius = nmsRadius * nmsRadius scoresBuffer = np.squeeze(scores) offsetsBuffer = np.squeeze(offsets) displacementsBwdBuffer = np.squeeze(displacementsBwd) displacementsFwdBuffer = np.squeeze(displacementsFwd) height, width, numKeypoints = scoresBuffer.shape queue = MaxHeap(height * width * numKeypoints, scoresBuffer) buildPartWithScoreQueue(scoreThreshold, kLocalMaximumRadius, scoresBuffer, queue) while len(poses) < maxPoseDetections and queue.empty() is False: root = queue.dequeue() rootImageCoords = getImageCoords(root['part'], outputStride, offsetsBuffer) if withinNmsRadiusOfCorrespondingPoint(poses, \ squaredNmsRadius, \ rootImageCoords, \ root['part']['id']) is True: continue #Start a new detection instance at the position of the root. keypoints = decodePose(root, \ scoresBuffer, \ offsetsBuffer, \ outputStride, \ displacementsFwdBuffer, \ displacementsBwdBuffer) for keypoint in keypoints: keypoint['position']['y'] *= (height_factor) keypoint['position']['x'] *= (width_factor) score = getInstanceScore(poses, squaredNmsRadius, keypoints) poses.append({'keypoints': keypoints, 'score': score}) return poses