示例#1
0
def palm_position_histogram(frames, bins=8, range=(-1., 1.)):
    """
        Feature based on a 3d histogram of the normalized positions of each palm
    """
    length = range[1] - range[0]
    bin_size = length / bins

    def hround(v):
        return min(bins - 1, int((v - range[0]) / bin_size))

    l = list_3d(bins)
    positions = []
    for frame in frames:
        for hand in frame.hands():
            palm = hand.palm()
            if palm:
                p = palm.position
                positions.append(p)
    average_p = utils.ave_v(positions)
    for index, position in enumerate(positions):
        positions[index] = utils.subtract(position, average_p)
        v = positions[index]
        x = v.x / utils.norm(v)
        y = v.y / utils.norm(v)
        z = v.z / utils.norm(v)
        l[hround(x)][hround(y)][hround(z)] += 1
    return l
示例#2
0
def palm_position_histogram(frames,bins = 8,range=(-1.,1.)):
    """
        Feature based on a 3d histogram of the normalized positions of each palm
    """
    length = range[1]-range[0]
    bin_size = length/bins

    def hround(v):
        return min(bins-1,int((v-range[0])/bin_size))

    l = list_3d(bins)
    positions = []
    for frame in frames:
        for hand in frame.hands():
            palm = hand.palm()
            if palm:
                p = palm.position
                positions.append(p)
    average_p = utils.ave_v(positions)
    for index,position in enumerate(positions):
        positions[index] = utils.subtract(position,average_p)
        v = positions[index]
        x = v.x/utils.norm(v)
        y = v.y/utils.norm(v)
        z = v.z/utils.norm(v)
        l[hround(x)][hround(y)][hround(z)] += 1
    return l
示例#3
0
def position_histogram(frames,bins = 4,range=(-1.,1.)):
    length = range[1]-range[0]
    bin_size = length/bins

    def hround(v):
        return min(bins-1,int((v-range[0])/bin_size))

    l = list_3d(bins)
    positions = []
    for frame in frames:
        for hand in frame.hands():
            for finger in hand.fingers():
                p = finger.tip().position
                positions.append(p)
    average_p = utils.ave_v(positions)
    for index,position in enumerate(positions):
        positions[index] = utils.subtract(position,average_p)
        v = positions[index]
        x = v.x/utils.norm(v)
        y = v.y/utils.norm(v)
        z = v.z/utils.norm(v)
        l[hround(x)][hround(y)][hround(z)] += 1
    return l
示例#4
0
def position_histogram(frames, bins=8, range=(-1., 1.)):
    length = range[1] - range[0]
    bin_size = length / bins

    def hround(v):
        return min(bins - 1, int((v - range[0]) / bin_size))

    l = list_3d(bins)
    positions = []
    for frame in frames:
        for hand in frame.hands():
            for finger in hand.fingers():
                p = finger.tip().position
                positions.append(p)
    average_p = utils.ave_v(positions)
    for index, position in enumerate(positions):
        positions[index] = utils.subtract(position, average_p)
        v = positions[index]
        x = v.x / utils.norm(v)
        y = v.y / utils.norm(v)
        z = v.z / utils.norm(v)
        l[hround(x)][hround(y)][hround(z)] += 1
    return l