def get_dis_i_j(gtFramesAll, prFramesAll, imgidx, joint_indx, FN_match_exc_thre_i): from eval_helpers import getHeadSize for i, pair_i in enumerate(FN_match_exc_thre_i): gt_i = pair_i["gt"] pred_i = pair_i["predict"] # print("imgidx,gt_i,joint_indx:",imgidx,gt_i,joint_indx) # print( get_kps_i(gtFramesAll,imgidx,gt_i,joint_indx,gt_flag=True) ) pointGT, head_coordinate = get_kps_i(gtFramesAll, imgidx, gt_i, joint_indx, gt_flag=True) pointPr = get_kps_i(prFramesAll, imgidx, pred_i, joint_indx) headSize = getHeadSize(head_coordinate[0], head_coordinate[1], head_coordinate[2], head_coordinate[3]) dist_i_j = np.linalg.norm(np.subtract(pointGT, pointPr)) / headSize FN_match_exc_thre_i[i]["gt"] = { "x": pointGT[0], "y": pointGT[1], "id": joint_indx, "head_size": headSize } FN_match_exc_thre_i[i]["predict"] = { "x": pointPr[0], "y": pointPr[1], "id": joint_indx } FN_match_exc_thre_i[i]["dis"] = dist_i_j return FN_match_exc_thre_i
def computeDist(preFrames, gtFrames): distAll = {} dist = {} keypoints_gt, label = eval_helpers.eval1(gtFrames) keypoints_pre = eval_helpers.eval(preFrames) for imgidx in keypoints_gt.keys(): gt = keypoints_gt[imgidx] pre = keypoints_pre[imgidx] head = gt[0] neck = ((gt[1][0] + gt[2][0]) / 2, (gt[1][1] + gt[2][1]) / 2) label_gt = label[imgidx] if imgidx in keypoints_pre.keys(): for index in range(len(label_gt)): if label_gt[index] == 0: dist[index] = 0 else: pointGT = gt[index] pointPre = pre[index] d = np.linalg.norm(np.subtract(pointGT, pointPre)) headSize = eval_helpers.getHeadSize( head[0], neck[0], head[1], neck[1]) dnormal = d / headSize * 0.1 dist[index] = dnormal distAll[imgidx] = dist dist = {} return distAll
def computeDist(gtFrames, prFrames): assert (len(gtFrames) == len(prFrames)) nJoints = eval_helpers.Joint().count distAll = {} for pidx in range(nJoints): distAll[pidx] = np.zeros([0, 0]) for imgidx in range(len(gtFrames)): # ground truth gtFrame = gtFrames[imgidx] # prediction detFrame = prFrames[imgidx] if (gtFrames[imgidx]["annorect"] != None): for ridx in range(len(gtFrames[imgidx]["annorect"])): rectGT = gtFrames[imgidx]["annorect"][ridx] rectPr = prFrames[imgidx]["annorect"][ridx] if ("annopoints" in rectGT.keys() and rectGT["annopoints"] != None): pointsGT = rectGT["annopoints"][0]["point"] pointsPr = rectPr["annopoints"][0]["point"] for pidx in range(len(pointsGT)): pointGT = [ pointsGT[pidx]["x"][0], pointsGT[pidx]["y"][0] ] idxGT = pointsGT[pidx]["id"][0] p = eval_helpers.getPointGTbyID(pointsPr, idxGT) if (len(p) > 0 and (type(p["x"][0]) == int or type(p["x"][0]) == float) and (type(p["y"][0]) == int or type(p["y"][0]) == float)): pointPr = [p["x"][0], p["y"][0]] # compute distance between GT and prediction d = np.linalg.norm(np.subtract(pointGT, pointPr)) # compute head size for distance normalization headSize = eval_helpers.getHeadSize( rectGT["x1"][0], rectGT["y1"][0], rectGT["x2"][0], rectGT["y2"][0]) # normalize distance dNorm = d / headSize else: dNorm = np.inf distAll[idxGT] = np.append(distAll[idxGT], [[dNorm]]) return distAll
def computeDist(gtFrames,prFrames): assert(len(gtFrames) == len(prFrames)) nJoints = eval_helpers.Joint().count distAll = {} for pidx in range(nJoints): distAll[pidx] = np.zeros([0,0]) for imgidx in range(len(gtFrames)): # ground truth gtFrame = gtFrames[imgidx] # prediction detFrame = prFrames[imgidx] if (gtFrames[imgidx]["annorect"] != None): for ridx in range(len(gtFrames[imgidx]["annorect"])): rectGT = gtFrames[imgidx]["annorect"][ridx] rectPr = prFrames[imgidx]["annorect"][ridx] if ("annopoints" in rectGT.keys() and rectGT["annopoints"] != None): pointsGT = rectGT["annopoints"][0]["point"] pointsPr = rectPr["annopoints"][0]["point"] for pidx in range(len(pointsGT)): pointGT = [pointsGT[pidx]["x"][0],pointsGT[pidx]["y"][0]] idxGT = pointsGT[pidx]["id"][0] p = eval_helpers.getPointGTbyID(pointsPr,idxGT) if (len(p) > 0 and (type(p["x"][0]) == int or type(p["x"][0]) == float) and (type(p["y"][0]) == int or type(p["y"][0]) == float)): pointPr = [p["x"][0],p["y"][0]] # compute distance between GT and prediction d = np.linalg.norm(np.subtract(pointGT,pointPr)) # compute head size for distance normalization headSize = eval_helpers.getHeadSize(rectGT["x1"][0],rectGT["y1"][0], rectGT["x2"][0],rectGT["y2"][0]) # normalize distance dNorm = d/headSize else: dNorm = np.inf distAll[idxGT] = np.append(distAll[idxGT],[[dNorm]]) return distAll