def findCageOption(self):
"""Finds cage option in fishing guild when right clicked on fish bubbles"""
x1 = 5
y1 = 25
x2 = 767
y2 = 524
rs_window = Screenshot.shoot(x1,y1,x2,y2)
#cv2.imshow('img',rs_window)
#cv2.waitKey(0)
rsc = rs_window.copy()
# gets only all the black and white
ret,thresh1 = cv2.threshold(rsc,0,255,cv2.THRESH_BINARY)
# inverst to only get black cloros as white
ret,thresh1 = cv2.threshold(thresh1,0,255,cv2.THRESH_BINARY_INV)
_, contours,h = cv2.findContours(thresh1,1,2)
for cnt in contours:
# looks for biggest square
if cv2.contourArea(cnt) <= 1695.0:
continue
# checks contour sides
approx = cv2.approxPolyDP(cnt,0.01*cv2.arcLength(cnt,True),True)
# draws only if its squared
if len(approx)==4:
print("square of {}".format(cv2.contourArea(cnt)))
#cv2.drawContours(rs_window,[cnt],0,(255,255,255),-1)
# get geometry of approx
# add rs coords
x,y,w,h = cv2.boundingRect(cnt)
#combines rs_window coords
x += x1
y += y1
# scrshot of option menu on play window
img = Screenshot.shoot(x,y,x+w,y+h)
ret,thresh1 = cv2.threshold(img,254,255,cv2.THRESH_BINARY)
# loads image from db
img_from_dict = self.idb.pickled_dict['cage']
#finds a match
from modules import Match
# runs func when match is found returns true to keep looking for template
if Match.images(thresh1,img_from_dict,x,y, self.doInMatched):
# keep looking for other bubbles
return 1
else:
# found 'cage'
return 0
# in case the options menu is aginast an edge
return 1
评论列表
文章目录