flappy init
This commit is contained in:
@@ -13,15 +13,15 @@ class FlappyPosDiscovery(threading.Thread):
|
||||
self.capture_window = WindowCapture(None, None, self.config)
|
||||
self.vision_stun = Vision()
|
||||
|
||||
self.needle_f = cv.imread("flappy/flappy.jpg")
|
||||
self.mask_f = cv.imread("flappy/flappy-mask.png")
|
||||
self.needle_f = self.scale_picture(cv.imread("flappy/flappy.jpg"), 50)
|
||||
self.mask_f = self.scale_picture(cv.imread("flappy/flappy-mask.png"), 50)
|
||||
|
||||
self.needle_g = cv.imread("flappy/gate.png")
|
||||
self.mask_g = cv.imread("flappy/gate-mask.png")
|
||||
self.needle_g = self.scale_picture(cv.imread("flappy/gate.jpg"), 50)
|
||||
self.mask_g = self.scale_picture(cv.imread("flappy/gate-mask.png"), 50)
|
||||
|
||||
self.run_mode = 'run'
|
||||
self.current_pet_height = 0
|
||||
self.next_gate_height = 0
|
||||
self.next_gate_height = [0,0,0]
|
||||
|
||||
self.offset_down = 90
|
||||
|
||||
@@ -29,19 +29,38 @@ class FlappyPosDiscovery(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
while self.run_mode == 'run':
|
||||
screenshot_g = self.capture_window.get_screenshot_by_area([1600, 1200, 800, 90])
|
||||
screenshot_f = self.capture_window.get_screenshot_by_area([200, 1250, 610, 90])
|
||||
rectangles_g = self.vision_stun.find(screenshot_g, self.needle_g, 0.97, 5, True, self.mask_g)
|
||||
screenshot_g = self.scale_picture(self.capture_window.get_screenshot_by_area([700, 1200, 1860, 90]), 50)
|
||||
screenshot_f = self.scale_picture(self.capture_window.get_screenshot_by_area([200, 1250, 610, 90]), 50)
|
||||
|
||||
#cv.imshow("screenshot_g", screenshot_g)
|
||||
#cv.waitKey(150)
|
||||
|
||||
rectangles_g = self.vision_stun.find(screenshot_g, self.needle_g, 0.95, 1)
|
||||
rectangles_f = self.vision_stun.find(screenshot_f, self.needle_f, 0.97, 1, True, self.mask_f)
|
||||
|
||||
if len(rectangles_g) is not 0:
|
||||
self.next_gate_height = rectangles_g[0][1] + rectangles_g[0][3] + self.offset_down
|
||||
height = rectangles_g[0][1] + rectangles_g[0][3] + (self.offset_down /2)
|
||||
if self.next_gate_height[0] is not height:
|
||||
self.next_gate_height.append(height)
|
||||
if len(self.next_gate_height) > 3:
|
||||
self.next_gate_height.pop(0)
|
||||
#pro_screen = self.vision_stun.draw_rectangles(screenshot_g, rectangles_g)
|
||||
#cv.imshow("screenshot_g", pro_screen)
|
||||
#cv.waitKey(150)
|
||||
else:
|
||||
pass
|
||||
|
||||
if len(rectangles_f) is not 0:
|
||||
self.current_pet_height = rectangles_f[0][1] + rectangles_f[0][3] + self.offset_down
|
||||
|
||||
#print("pet_pos: ", self.current_pet_height)
|
||||
#print("next gate: ", self.next_gate_height)
|
||||
print("pet_pos: ", self.current_pet_height)
|
||||
print("next gate: ", self.next_gate_height)
|
||||
|
||||
def scale_picture(self, img, scale_percent):
|
||||
width = int(img.shape[1] * scale_percent / 100)
|
||||
height = int(img.shape[0] * scale_percent / 100)
|
||||
return cv.resize(img, (width, height), interpolation=4)
|
||||
|
||||
def get_actual_pet_height(self):
|
||||
return self.current_pet_height
|
||||
|
||||
|
||||
Reference in New Issue
Block a user