switch.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Manimouse 作者: shivamkajale 项目源码 文件源码
def chooseAction(yp, rc, bc, actionHistory):
    out = np.array(['move', 'false'])
    if rc[0]!=-1 and bc[0]!=-1:

        if not leftHand and checkActionHistory( actionHistory, 'ONOFF'):
            if bc[0]-yp[0]>130 and bc[1]-yp[1]>170 and bc[1]-rc[1]<40:
                out[0] = 'ONOFF'
                return out
        elif leftHand and checkActionHistory( actionHistory, 'ONOFF'):      
            if yp[0]-bc[0]>130 and bc[1]-yp[1]>170 and bc[1]-rc[1]<40:
                out[0] = 'ONOFF'
                return out

        if distance(yp,rc)<50 and distance(yp,bc)<50 and distance(rc,bc)<50 :
            out[0] = 'drag'
            out[1] = 'true'
            return out
        elif distance(rc,bc)<40: 
            out[0] = 'left'
            return out
        elif distance(yp,rc)<40 and checkActionHistory( actionHistory, 'right'):    
            out[0] = 'right'
            return out
        elif distance(yp,rc)>40 and rc[1]-bc[1]>120:
            out[0] = 'down'
            return out  
        elif bc[1]-rc[1]>110:
            out[0] = 'up'
            return out
        else:
            return out

    else:
        out[0] = -1
        return out      

# Movement of cursor on screen, left click, right click,scroll up, scroll down
# and dragging actions are performed here based on value stored in 'action'.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号