def Vis_Skeleton_2D_SPIN24()

in renderer/viewer2D.py [0:0]


def Vis_Skeleton_2D_SPIN24(pt2d, pt2d_visibility = None, image = None, bVis = False, color=None):
    pt2d = np.reshape(pt2d,(-1,2))          #Just in case. Make sure (32, 2)

    #Draw via opencv
    if not isinstance(image, np.ndarray):#not image: #If no image is given, generate Blank image
        image = np.ones((1000,1000,3),np.uint8) *255

    radius = 4



    #Openpose25 in Spin Defition + SPIN global 24
    # 'OP Nose', 'OP Neck', 'OP RShoulder',           #0,1,2
    # 'OP RElbow', 'OP RWrist', 'OP LShoulder',       #3,4,5
    # 'OP LElbow', 'OP LWrist', 'OP MidHip',          #6, 7,8
    # 'OP RHip', 'OP RKnee', 'OP RAnkle',             #9,10,11
    # 'OP LHip', 'OP LKnee', 'OP LAnkle',             #12,13,14
    # 'OP REye', 'OP LEye', 'OP REar',                #15,16,17
    # 'OP LEar', 'OP LBigToe', 'OP LSmallToe',        #18,19,20
    # 'OP LHeel', 'OP RBigToe', 'OP RSmallToe', 'OP RHeel',  #21, 22, 23, 24  ##Total 25 joints  for openpose
    link_openpose = [  [8,1], [1,0] , [0,16] , [16,18] , [0,15], [15,17],
                [1,2],[2,3],[3,4],      #Right Arm
                [1,5], [5,6], [6,7],       #Left Arm
                [8,12], [12,13], [13,14], [14,19], [19,20], [20,21],    #Left Leg
                [8,9], [9,10], [10,11], [11,22], [22,23], [23,24]       #Right left
                ]

    link_spin24 =[  [14,16], [16,12], [12,17] , [17,18] ,
                [12,9],[9,10],[10,11],      #Right Arm
                [12,8], [8,7], [7,6],       #Left Arm
                [14,3], [3,4], [4,5],
                [14,2], [2,1], [1,0]]


    link_spin24 = np.array(link_spin24) + 25

    # bLeft = [ 1,1,1,1,0,0,
    #     0,0,0,
    #     1,1,1,
    #     1,1,1,1,1,1,
    #     0,0,0,0,0,0]
    bLeft = [ 0,0,0,0,
        1,1,1,
        0,0,0,
        1,1,1,
        0,0,0]



    # for i in np.arange( len(link) ):
    for k in np.arange( 25,len(pt2d) ):
        if color is not None:
            if pt2d_visibility is None:
                cv2.circle(image, (int(pt2d[k][0]), int(pt2d[k][1]) ), radius, color,-1)
            else:
                if pt2d_visibility[k]:
                    cv2.circle(image, (int(pt2d[k][0]), int(pt2d[k][1]) ), radius, color,-1)
        else:
            if pt2d_visibility is None:
                cv2.circle(image, (int(pt2d[k][0]), int(pt2d[k][1]) ), radius, (0,0,255),-1)
            else:
                if pt2d_visibility[k]:
                    cv2.circle(image, (int(pt2d[k][0]), int(pt2d[k][1]) ), radius, (0,0,255),-1)

    # # #Openpose joint drawn as blue
    # for k in np.arange( len(link_openpose) ):
    #     parent = link_openpose[k][0]
    #     child = link_openpose[k][1]
    #     if color is not None:
    #         c = color
    #     else:
    #         if True:#bLeft[k]:
    #             c = (255,0,0)#BGR, Blue
    #         else:
    #             c = (0,0,0)
    #     if pt2d_visibility is None:
    #         cv2.line(image, (int(pt2d[parent][0]), int(pt2d[parent][1])), (int(pt2d[child][0]), int(pt2d[child][1])), c, radius - 2)
    #     else:
    #         if pt2d_visibility[parent] and pt2d_visibility[child]:
    #             cv2.line(image, (int(pt2d[parent][0]), int(pt2d[parent][1])), (int(pt2d[child][0]), int(pt2d[child][1])), c, radius - 2)


    #SPIN24 joint drawn as red
    for k in np.arange( len(link_spin24) ):
        parent = link_spin24[k][0]
        child = link_spin24[k][1]
        if color is not None:
            c = color
        else:
            if True:#bLeft[k]:
                c = (0,0,255)#BGR, RED
            else:
                c = (0,0,0)
        if pt2d_visibility is None:
            cv2.line(image, (int(pt2d[parent][0]), int(pt2d[parent][1])), (int(pt2d[child][0]), int(pt2d[child][1])), c, radius - 2)
        else:
            if pt2d_visibility[parent] and pt2d_visibility[child]:
                cv2.line(image, (int(pt2d[parent][0]), int(pt2d[parent][1])), (int(pt2d[child][0]), int(pt2d[child][1])), c, radius - 2)



    if bVis:
        ImShow(image)
    return image