def search_opponent_card(screen_area, db, stack_collection=0, is_postflop=False): try: folder_name = 'images/' + str(datetime.datetime.now().date()) opponent_area = save_opponent_card_image(screen_area, folder_name, db)[0] check_is_headsup = 0 card_area = db_query.get_opponent_card_area(screen_area, db) opponent_data = [] last_screen = db_query.get_last_screen(card_area, db, 2) last_screen = last_screen[::-1] for item in last_screen: path = item['image_path'] img_rgb = cv2.imread(path, 0) template_path = 'is_headsup/is_headsup.png' if image_processing.cv_data_template(template_path, img_rgb) > 0: check_is_headsup += 1 if is_postflop is False: opponent_data.append( current_stack.search_opponent_stack( screen_area, opponent_area, stack_collection, db)) opponent_area += 1 if check_is_headsup != 1: check_is_headsup = 0 opponent_data.insert(0, check_is_headsup) return opponent_data except Exception as e: print(e)
def check_is_cbet_available(screen_area, db): element_area = introduction.save_element(screen_area, 'limp_area', db) path = db_query.get_last_screen(element_area, db) path = path[0]['image_path'] img_rgb = cv2.imread(path, 0) template_path = 'action_buttons/check.png' if cv_data_template(template_path, img_rgb) > 0: return True
def search_last_opponent_action(screen_area, db): element_area = introduction.save_element(screen_area, 'limp_area', db) path = db_query.get_last_screen(element_area, db) path = path[0]['image_path'] img_rgb = cv2.imread(path, 0) for item in db_query.get_actions_buttons(db): if cv_data_template(item['image_path'], img_rgb) > 0: return item return 'push'
def search_element(screen_area, elements, folder, db): for item in elements: path = db_query.get_last_screen(screen_area, db) path = path[0]['image_path'] img_rgb = cv2.imread(path, 0) template_path = folder + item + '.png' if cv_data_template(template_path, img_rgb): return True return False
def search_bar(screen_area, db): save_bar_image(screen_area, str(math.floor(time.time())), 'images/', db) path = db_query.get_last_screen(db_query.get_bar_area(screen_area, db), db) path = path[0]['image_path'] img_rgb = cv2.imread(path, 0) template_path = 'bar/red_mark.png' if image_processing.cv_data_template(template_path, img_rgb) > 0: return True return False
def seacrh_blind_chips(screen_area, image_name, folder_name, db): save_blind_image(screen_area, image_name, folder_name, db) blinds = ('big_blind', 'small_blind', 'pop_up') path = db_query.get_last_screen(db_query.get_blind_area(screen_area, db), db) path = path[0]['image_path'] img_rgb = cv2.imread(path, 0) for blind in blinds: template_path = 'blinds/' + blind + '.png' if image_processing.cv_data_template(template_path, img_rgb) > 0: if blind == 'pop_up': time.sleep(2) return seacrh_blind_chips(screen_area, image_name, folder_name, db) return blind return 'button'
def search_bar(screen_area, db): save_bar_image(screen_area, str(math.floor(time.time())), 'images/', db) path = db_query.get_last_screen(db_query.get_bar_area(screen_area, db), db) path = path[0]['image_path'] img_rgb = cv2.imread(path, 0) template_path = 'bar/red_mark.png' if image_processing.cv_data_template(template_path, img_rgb) > 0: return True blue_mark = 'bar/blue_mark.png' #if windows license expired if image_processing.cv_data_template(blue_mark, img_rgb) > 0: os.system("taskkill /im StarsCaption.exe") error_log.play_alarm_sound() error_log.error_log('bar', 'license expired') os.startfile('C:\\StarsCaption\\StarsCaption.exe') return False
def search_allin_stack(screen_area, db): try: save_allin_stack_image(screen_area, db) screen_area = db_query.get_allin_stack_area(screen_area, db) for item in db_query.get_last_screen(screen_area, db): path = item['image_path'] img_rgb = cv2.imread(path, 0) for value in db_query.get_allin_stack_images(db): if image_processing.cv_data_template(value['image_path'], img_rgb) > 0: all_in_stack = int(value['stack_value']) return all_in_stack return DEFAULT_STACK except Exception as e: error_log.error_log('searchAllinStack', str(e)) print(e)
def search_opponent_stack(screen_area, opponent_area, stack_collection, db): try: folder_name = 'images/' + str(datetime.datetime.now().date()) save_opponent_stack_image(screen_area, folder_name, opponent_area, db) screen_area = db_query.get_opponent_stack_area(screen_area, db) for item in db_query.get_last_screen(screen_area, db): path = item['image_path'] img_rgb = cv2.imread(path, 0) for value in stack_collection: if image_processing.cv_data_template(value['image_path'], img_rgb) > 0: opponent_stack = int(value['stack_value']) return opponent_stack return DEFAULT_STACK except Exception as e: error_log.error_log('searchOpponentStack', str(e)) print(e)
def search_cards(screen_area, deck, list_length, db): hand = '' try: for item in db_query.get_last_screen(screen_area, db): path = item['image_path'] img_rgb = cv2.imread(path, 0) for value in deck: if cv_data_template(value['image_path'], img_rgb) > 0: hand += value['alias'] if len(hand) == list_length: return hand except Exception as e: error_log.error_log('searchCards', str(e)) print(e) if len(hand) < 4 and list_length > 2: print(hand) hand = '7h2d' return hand
def search_current_stack(screen_area, stack_collection, db): try: image_name = str(math.floor(time.time())) + ".png" folder_name = "images/" + str(datetime.datetime.now().date()) save_stack_image(screen_area, image_name, folder_name, db) for item in db_query.get_last_screen( db_query.get_stack_area(screen_area, db), db): path = item['image_path'] img_rgb = cv2.imread(path, 0) for value in stack_collection: if image_processing.cv_data_template(value['image_path'], img_rgb) > 0: current_stack = int(value['stack_value']) return current_stack return DEFAULT_STACK except Exception as e: error_log.error_log('searchCurrentStack', str(e)) print(e)