RS.py 文件源码

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

项目:osrmacro 作者: jjvilm 项目源码 文件源码
def find_bank_booth():
    """Finds bank booth and clicks it.  Returns True if found, else False"""

    bank_booth_glass_window = ([0,72,149],[179,82,163])
    # take screenshot of playing area
    play_area_screen,psx,psy = getPlayingScreen()

    # find glasswindow for bankbooth
    mask = cv2.inRange(play_area_screen, np.array(bank_booth_glass_window[0]), np.array(bank_booth_glass_window[1]))

    # gets RS window's position
    rsx,rsy = position()

    psx += rsx
    psy += rsy

    kernel = np.ones((3,3), np.uint8)
    closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)


    #cv2.imshow('img', closing)
    #cv2.waitKey(0)

    # Finds contours
    _,contours,_ = cv2.findContours(closing.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

    try:
        for con in contours:
            if cv2.contourArea(con) > 10:
                #print(cv2.contourArea(con))
                M = cv2.moments(con)
                # finds centroid
                cx,cy = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                psx += cx
                psy += cy
                # adds randomness to coords
                psx += random.randint(-7,7)
                psy += random.randint(-7,7)

                #move click
                Mouse.moveClick(psx,psy,1)
                RandTime.randTime(0,0,0,0,9,9)
                return 1
    except Exception as e:
        print("Bank NOT found!\nMove camera around!")
    # returns False if bank not found
    return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号