Merge remote-tracking branch 'origin/master'
@@ -4,6 +4,7 @@ import pydirectinput
|
|||||||
from nltk.corpus import words
|
from nltk.corpus import words
|
||||||
from pytesseract import pytesseract
|
from pytesseract import pytesseract
|
||||||
|
|
||||||
|
import utils
|
||||||
from utils import mse
|
from utils import mse
|
||||||
from game_base_class import GameBase
|
from game_base_class import GameBase
|
||||||
import random
|
import random
|
||||||
@@ -87,7 +88,7 @@ class MentiWords(GameBase):
|
|||||||
|
|
||||||
with open("menti_dic") as file:
|
with open("menti_dic") as file:
|
||||||
self.word_list = [line.rstrip() for line in file]
|
self.word_list = [line.rstrip() for line in file]
|
||||||
self.word_list2 = words.words()
|
#self.word_list2 = words.words()
|
||||||
|
|
||||||
def reset_lists(self):
|
def reset_lists(self):
|
||||||
self.current_letters = []
|
self.current_letters = []
|
||||||
@@ -126,7 +127,7 @@ class MentiWords(GameBase):
|
|||||||
|
|
||||||
#screenshot = cv.imread("menti_words/screenshot.jpg")
|
#screenshot = cv.imread("menti_words/screenshot.jpg")
|
||||||
screenshot = self.capture_window.get_screenshot()
|
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.imshow("screenshot", screenshot)
|
||||||
#cv.waitKey(150)
|
#cv.waitKey(150)
|
||||||
@@ -134,26 +135,35 @@ class MentiWords(GameBase):
|
|||||||
for needle_key in self.needles.keys():
|
for needle_key in self.needles.keys():
|
||||||
# gray_needle = cv.cvtColor(self.needles[needle_key], cv.COLOR_BGR2GRAY)
|
# 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]
|
# 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, 2)
|
||||||
#rectangles = self.vision_stun.find(screenshot, self.needles[needle_key], 0.95, 1 ,True, self.masks[needle_key])
|
#rectangles = self.vision_stun.find(screenshot, self.needles[needle_key], 0.95, 1 ,True, self.masks[needle_key])
|
||||||
if len(rectangles) == 0:
|
if len(rectangles) == 0:
|
||||||
continue
|
continue
|
||||||
|
points = self.vision_stun.get_click_points(rectangles)
|
||||||
|
for point in points:
|
||||||
|
self.current_letters.append(needle_key)
|
||||||
|
self.letter_coords[needle_key] = (int(point[0]/2), int(point[1]/2))
|
||||||
|
'''
|
||||||
cropped1 = self.vision_stun.draw_display_picture(screenshot, rectangles, 10)
|
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()
|
text_1 = pytesseract.image_to_string(cropped1, lang='eng', config='--psm 6').strip()
|
||||||
if str.isalpha(text_1):
|
if str.isalpha(text_1):
|
||||||
#cv.imshow("cropped1", cropped1)
|
#cv.imshow("cropped1", cropped1)
|
||||||
#cv.waitKey(150)
|
#cv.waitKey(150)
|
||||||
points = self.vision_stun.get_click_points(rectangles)
|
points = self.vision_stun.get_click_points(rectangles)
|
||||||
self.current_letters.append(text_1)
|
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':
|
if self.overlay.run_mode == 'stopped' or self.overlay.run_mode == 'paused':
|
||||||
return
|
return
|
||||||
|
|
||||||
def possible_words(self, lwords, charSet):
|
def possible_words(self, lwords, charSet):
|
||||||
lst = []
|
lst = []
|
||||||
for word in lwords:
|
for word in lwords:
|
||||||
if len(word) <= 2:
|
if len(word) <= 1:
|
||||||
continue
|
continue
|
||||||
flag = 1
|
flag = 1
|
||||||
chars = self.charCount(word)
|
chars = self.charCount(word)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
12
utils.py
@@ -61,18 +61,20 @@ def check_for_bl_line(line_item, black_list):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def scale_screenshot(screenshot):
|
def scale_screenshot(screenshot, percent = 200, thresh_mode = True):
|
||||||
scale_percent = 200 # percent of original size
|
scale_percent = percent # percent of original size
|
||||||
width = int(screenshot.shape[1] * scale_percent / 100)
|
width = int(screenshot.shape[1] * scale_percent / 100)
|
||||||
height = int(screenshot.shape[0] * scale_percent / 100)
|
height = int(screenshot.shape[0] * scale_percent / 100)
|
||||||
dim = (width, height)
|
dim = (width, height)
|
||||||
resized_img = cv.resize(screenshot, dim, interpolation=4)
|
resized_img = cv.resize(screenshot, dim, interpolation=4)
|
||||||
|
|
||||||
gray = cv.cvtColor(resized_img, cv.COLOR_BGR2GRAY)
|
if thresh_mode:
|
||||||
thresh = cv.threshold(gray, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU)[1]
|
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.imshow("Tresh", thresh)
|
||||||
# cv.waitKey(1000)
|
# cv.waitKey(1000)
|
||||||
return thresh
|
return resized_img
|
||||||
|
|
||||||
|
|
||||||
def save_line_item_npy_jpg(short_pic_list):
|
def save_line_item_npy_jpg(short_pic_list):
|
||||||
|
|||||||