update menti
This commit is contained in:
@@ -4,6 +4,7 @@ import pydirectinput
|
||||
from nltk.corpus import words
|
||||
from pytesseract import pytesseract
|
||||
|
||||
import utils
|
||||
from utils import mse
|
||||
from game_base_class import GameBase
|
||||
import random
|
||||
@@ -126,7 +127,7 @@ class MentiWords(GameBase):
|
||||
|
||||
#screenshot = cv.imread("menti_words/screenshot.jpg")
|
||||
screenshot = self.capture_window.get_screenshot()
|
||||
screenshot = screenshot[870:1270, 1080:1480]
|
||||
screenshot = utils.scale_screenshot(screenshot[870:1270, 1080:1480], 200, False)
|
||||
|
||||
#cv.imshow("screenshot", screenshot)
|
||||
#cv.waitKey(150)
|
||||
@@ -134,19 +135,27 @@ class MentiWords(GameBase):
|
||||
for needle_key in self.needles.keys():
|
||||
# gray_needle = cv.cvtColor(self.needles[needle_key], cv.COLOR_BGR2GRAY)
|
||||
# thresh_needle = cv.threshold(gray_needle, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
|
||||
rectangles = self.vision_stun.find(screenshot, self.needles[needle_key], 0.85, 1)
|
||||
|
||||
thresh_needle = utils.scale_screenshot(self.needles[needle_key], 200, False)
|
||||
rectangles = self.vision_stun.find(screenshot, thresh_needle , 0.85, 1)
|
||||
#rectangles = self.vision_stun.find(screenshot, self.needles[needle_key], 0.95, 1 ,True, self.masks[needle_key])
|
||||
if len(rectangles) == 0:
|
||||
continue
|
||||
points = self.vision_stun.get_click_points(rectangles)
|
||||
self.current_letters.append(needle_key)
|
||||
self.letter_coords[needle_key] = points[0]
|
||||
'''
|
||||
cropped1 = self.vision_stun.draw_display_picture(screenshot, rectangles, 10)
|
||||
|
||||
#cropped1 = utils.scale_screenshot(cropped1)
|
||||
cv.imshow("cropped1", cropped1)
|
||||
cv.waitKey(150)
|
||||
text_1 = pytesseract.image_to_string(cropped1, lang='eng', config='--psm 6').strip()
|
||||
if str.isalpha(text_1):
|
||||
#cv.imshow("cropped1", cropped1)
|
||||
#cv.waitKey(150)
|
||||
points = self.vision_stun.get_click_points(rectangles)
|
||||
self.current_letters.append(text_1)
|
||||
self.letter_coords[text_1] = points[0]
|
||||
self.letter_coords[text_1] = points[0]'''
|
||||
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||
return
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.9 KiB |
12
utils.py
12
utils.py
@@ -61,18 +61,20 @@ def check_for_bl_line(line_item, black_list):
|
||||
return False
|
||||
|
||||
|
||||
def scale_screenshot(screenshot):
|
||||
scale_percent = 200 # percent of original size
|
||||
def scale_screenshot(screenshot, percent = 200, thresh_mode = True):
|
||||
scale_percent = percent # percent of original size
|
||||
width = int(screenshot.shape[1] * scale_percent / 100)
|
||||
height = int(screenshot.shape[0] * scale_percent / 100)
|
||||
dim = (width, height)
|
||||
resized_img = cv.resize(screenshot, dim, interpolation=4)
|
||||
|
||||
gray = cv.cvtColor(resized_img, cv.COLOR_BGR2GRAY)
|
||||
thresh = cv.threshold(gray, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
|
||||
if thresh_mode:
|
||||
gray = cv.cvtColor(resized_img, cv.COLOR_BGR2GRAY)
|
||||
thresh = cv.threshold(gray, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
|
||||
return thresh
|
||||
# cv.imshow("Tresh", thresh)
|
||||
# cv.waitKey(1000)
|
||||
return thresh
|
||||
return resized_img
|
||||
|
||||
|
||||
def save_line_item_npy_jpg(short_pic_list):
|
||||
|
||||
Reference in New Issue
Block a user