added fruit game support

This commit is contained in:
Thaloria@web.de
2023-04-28 15:12:00 +02:00
parent c4c6c34709
commit 187cb80cf2

View File

@@ -20,7 +20,7 @@ class Fruit(GameBase):
self.colors = [GREEN, YELLOW, RED, BLUE, ORANGE]
self.offset_left = 553
self.offset_left = 390
self.offset_down = 188
self.fill_data_coordinates()
@@ -35,7 +35,10 @@ class Fruit(GameBase):
def fill_data_coordinates(self):
# 553 to 1861 = 1330 / 11 = 119
# 188 to 1022 = 1076 / 7 = 119
dim = 119
# 390 to 2000 = 1610 / 11 = 143
# 188 to 1210 = 1076 / 7 = 119
dim = 143
for e in range(0, 7, 1):
for i in range(0, 11, 1):
self.data_coordinates[e][i] = [i * dim, e * dim, dim, dim]
@@ -94,7 +97,12 @@ class Fruit(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.74, 56)
rectangles = self.vision_stun.find(screenshot, self.needles[needle_key], 0.78, 56)
#output_image = self.vision_stun.draw_rectangles(screenshot, rectangles)
#cv.imshow("output_image", output_image)
#cv.waitKey(150)
if len(rectangles) == 0:
continue
points = self.vision_stun.get_click_points(rectangles)