Ejemplo n.º 1
0
def grabDiscussionTitle(xResolution: int, yResolution: int):
    
    settings = {'top': int(0.08 * yResolution) + adjust_y, 'left':int(xResolution * 0.18) + adjust_x, 'width':int(xResolution * 0.7), 'height':int(0.25 * yResolution)}

    sct = mss()

    first_time = True

    while True:
        #Take image of screen
        sct_img = sct.grab(settings)
        img = Image.frombytes('RGB', (sct_img.size.width, sct_img.size.height), sct_img.rgb)
        frame = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)

        if first_time:
            print("Ready.\nYou can play now.\n")
            first_time = False

        #Process image
        module_process.processDiscussion(frame)
Ejemplo n.º 2
0
def grabScreen(xResolution: int, yResolution: int):
    settings = {
        "top": int(0.08 * yResolution) + adjust_y,
        "left": int(xResolution * 0.18) + adjust_x,
        "width": int(xResolution * 0.7),
        "height": int(0.25 * yResolution),
        "mon": monitor_number
    }

    first_time = True

    x_crop = int(xResolution * 0.18)
    y_crop = int(yResolution * 0.08)

    with mss() as sct:
        while True:
            frame = returnFrame(settings, sct)

            try:
                #Crop image to fit only "voting ended" and "whos the imposter?"
                cropped_frame = frame[10:(y_crop + y_extend_crop),
                                      int(x_crop / 2 - x_extend_crop +
                                          80):-int(x_crop / 2 +
                                                   x_extend_crop)].copy()

                if debug_mode:
                    cv2.imshow(
                        'Test',
                        np.array(frame))  #output screen, for testing only
                    cv2.imshow('Test Cropped', np.array(
                        cropped_frame))  #output screen, for testing only

            except Exception as e:
                print(
                    f"{e}\nLooks like your x_extend_crop or y_extend_crop values are way too high"
                )
                exit()

            if first_time:
                print("Ready.\nYou can play now.\n")
                first_time = False

            #Process image
            found = module_process.processDiscussion(cropped_frame)

            if found == False:  #If discussion or voting ends found, you dont need to process ending
                found = module_process.processEnding(frame)

            if cv2.waitKey(25) & 0xFF == ord(
                    'q'):  #Press Q on debug windows to exit
                cv2.destroyAllWindows()
                break
Ejemplo n.º 3
0
else:
    print("Invalid test_window_type specified")
    exit

mon = {
    'top': int(top * y) + adjust_y,
    'left': int(x * left) + adjust_x,
    'width': int(x * width),
    'height': int(height * y)
}

sct = mss()

while 1:
    sct_img = sct.grab(mon)
    img = Image.frombytes('RGB', (sct_img.size.width, sct_img.size.height),
                          sct_img.rgb)
    img_bgr = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)

    time.sleep(1)

    if test_window_type == "discuss":
        module_process.processDiscussion(img_bgr)
    elif test_window_type == "ending":
        module_process.processEnding(img_bgr)

    cv2.imshow('Among Us Test', np.array(img_bgr))
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break
Ejemplo n.º 4
0
def grabScreen(xResolution: int, yResolution: int):
    keep_grabbing = False

    settings = {
        "top": int(0.08 * yResolution) + adjust_y,
        "left": int(xResolution * 0.18) + adjust_x,
        "width": int(xResolution * 0.7),
        "height": int(0.25 * yResolution),
        "mon": monitor_number
    }

    first_time = True

    x_crop = int(xResolution * 0.18)
    y_crop = int(yResolution * 0.08)

    with mss() as sct:
        while True:
            frame = returnFrame(settings, sct)

            try:
                #Crop image to fit only "voting ended" and "whos the imposter?"
                cropped_frame = frame[10:(y_crop + y_extend_crop),
                                      int(x_crop / 2 - x_extend_crop +
                                          80):-int(x_crop / 2 +
                                                   x_extend_crop)].copy()

                if debug_mode:
                    cv2.imshow(
                        'Test',
                        np.array(frame))  #output screen, for testing only
                    cv2.imshow('Test Cropped', np.array(
                        cropped_frame))  #output screen, for testing only

                    if cv2.waitKey(25) & 0xFF == ord(
                            'q'):  #Press Q on debug windows to exit
                        cv2.destroyAllWindows()
                        break

            except Exception as e:
                print(
                    f"{e}\n[*] Looks like your x_extend_crop or y_extend_crop values are way too high"
                )
                exit()

            if first_time:
                print("[*] Screen grab ready.\n")
                first_time = False

            #Process image
            found = module_process.processDiscussion(cropped_frame)

            if found == 1:  #If discussion or voting ends found, you dont need to process ending
                module_process.processEnding(frame)

            elif found == 3:
                start_time = time.time()

                while True:
                    see_if_ended = returnFrame(settings, sct)
                    ended = module_process.processEnding(see_if_ended)

                    if ended:
                        break

                    elif time.time() - start_time >= 6 + delay_voting:
                        requests.get(f"http://{address}:{port}/mute")
                        break
            else:
                pass