menti words init

This commit is contained in:
2023-07-26 22:00:57 +02:00
parent 2d23f8e311
commit ef7669f015
37 changed files with 29 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
import cv2 as cv import cv2 as cv
import numpy as np import numpy as np
import pydirectinput import pydirectinput
from nltk.corpus import words
from utils import mse from utils import mse
from game_base_class import GameBase from game_base_class import GameBase
import random import random
@@ -51,9 +51,30 @@ class MentiWords(GameBase):
'W': cv.imread("menti_words/w.jpg", cv.IMREAD_COLOR) 'W': cv.imread("menti_words/w.jpg", cv.IMREAD_COLOR)
}
self.masks = {
'A': cv.imread("menti_words/a-mask.png", cv.IMREAD_COLOR),
'B': cv.imread("menti_words/b-mask.png", cv.IMREAD_COLOR),
'C': cv.imread("menti_words/c-mask.png", cv.IMREAD_COLOR),
'D': cv.imread("menti_words/d-mask.png", cv.IMREAD_COLOR),
'E': cv.imread("menti_words/e-mask.png", cv.IMREAD_COLOR),
'F': cv.imread("menti_words/f-mask.png", cv.IMREAD_COLOR),
'H': cv.imread("menti_words/h-mask.png", cv.IMREAD_COLOR),
'I': cv.imread("menti_words/i-mask.png", cv.IMREAD_COLOR),
'L': cv.imread("menti_words/l-mask.png", cv.IMREAD_COLOR),
'M': cv.imread("menti_words/m-mask.png", cv.IMREAD_COLOR),
'N': cv.imread("menti_words/n-mask.png", cv.IMREAD_COLOR),
'O': cv.imread("menti_words/o-mask.png", cv.IMREAD_COLOR),
'P': cv.imread("menti_words/p-mask.png", cv.IMREAD_COLOR),
'R': cv.imread("menti_words/r-mask.png", cv.IMREAD_COLOR),
'S': cv.imread("menti_words/s-mask.png", cv.IMREAD_COLOR),
'T': cv.imread("menti_words/t-mask.png", cv.IMREAD_COLOR),
'U': cv.imread("menti_words/u-mask.png", cv.IMREAD_COLOR),
'W': cv.imread("menti_words/w-mask.png", cv.IMREAD_COLOR)
} }
@@ -62,6 +83,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()
def reset_lists(self): def reset_lists(self):
self.current_letters = [] self.current_letters = []
@@ -98,17 +120,18 @@ class MentiWords(GameBase):
def get_current_board_state(self): def get_current_board_state(self):
#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 = screenshot[870:1270, 1080:1480]
#cv.imshow("screenshot", screenshot) cv.imshow("screenshot", screenshot)
#cv.waitKey(150) cv.waitKey(150)
#continue #continue
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, 56) #rectangles = self.vision_stun.find(screenshot, self.needles[needle_key], 0.85, 56)
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) points = self.vision_stun.get_click_points(rectangles)

BIN
menti_words/a-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

BIN
menti_words/a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
menti_words/b-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

BIN
menti_words/b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
menti_words/c-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
menti_words/c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
menti_words/d-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

BIN
menti_words/d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
menti_words/e-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

BIN
menti_words/e.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
menti_words/f-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

BIN
menti_words/f.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
menti_words/h-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

BIN
menti_words/h.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
menti_words/i-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

BIN
menti_words/i.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

BIN
menti_words/l-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

BIN
menti_words/l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
menti_words/m-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

BIN
menti_words/m.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
menti_words/n-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

BIN
menti_words/n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
menti_words/o-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

BIN
menti_words/o.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
menti_words/p-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

BIN
menti_words/p.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
menti_words/r-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

BIN
menti_words/r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
menti_words/s-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

BIN
menti_words/s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
menti_words/t-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

BIN
menti_words/t.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
menti_words/u-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

BIN
menti_words/u.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
menti_words/w-mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

BIN
menti_words/w.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB