본문 바로가기
ML | DL/Pose estimation

Pose Similarity - Weight Distance Python 코드

by Leeys 2022. 3. 17.
반응형

코사인 거리는 매우 훌륭하고 좋은 결과 값을 주긴 하지만 아직 큰 결함이 있다. Confidence Score는 Pose를 추정할 때 이 좌표에는 어떤 키포인트가 있을지 얼마나 확신하는지 알려주는 정도이다. 이 정보를 무시한다면 우리는 매우 중요한 정보를 버리는 것이다.

 

weight distance 공식

def weightedDistanceMatching(poseVector1, poseVector2, score):
    """ 
        poseVector1 = [120(x), 230(y) ...]
        poseVector2 = [324(x), 232(y) ...]
        score = [0.2, 0.3 ....]
    """
    
    # test coordinate
    vector1PoseXY = poseVector1
    vector1Confidences = score
    
    # test threshold score sum
    vector1ConfidenceSum = sum(vector1Confidences)
    
    # train coordinate
    vector2PoseXY = poseVector2

    summation1 = 1 / vector1ConfidenceSum
    summation2 = 0
    
    for i in range(len(vector1PoseXY)):
        count += 1
        tempConf = math.floor(i / 2)
        # multiplying each joint's reliability and distance
        tempSum = vector1Confidences[tempConf] * abs(vector1PoseXY[i] - vector2PoseXY[i])
        # Add joint distance by joint count
        summation2 = summation2 + tempSum
    
    # WeightedDistance
    summation = summation1 * summation2

    return summation
반응형

댓글