예제 #1
0
 def waitChange(self, timeout=FOREVER, nbr_pix=1):
     self.stopWait.clear()
     start = perf_counter()
     initial = env.capture(self)
     while not self.stopWait.is_set() and perf_counter() - start < timeout:
         pix_diff = (initial != env.capture(self)).any(axis=2).sum()
         if pix_diff > nbr_pix:
             return True
         sleep(0.01)
     return False
예제 #2
0
 def capture(self, gray=False):
     self.bi = env.capture(self)
     if gray:
         self.bi = cv2.cvtColor(self.bi, cv2.COLOR_RGB2GRAY)
     else:
         self.bi = cv2.cvtColor(self.bi, cv2.COLOR_RGB2BGR)
     return self.bi
예제 #3
0
파일: walker.py 프로젝트: Me0w1ng/bot2pix
 def goToZaap(self, zapCoords):
     print("moving to zaap: ", zapCoords)
     pyautogui.press(dofus.HAVRE_SAC_SHORTCUT)
     sleep(2)
     dofus.HAVRE_SAC_ZAAP_R.click()
     sleep(2)
     while dofus.ZAAP_SCROLL_BAR_END_L.getpixel(
     ) != dofus.ZAAP_END_SCROLL_C:
         print(dofus.ZAAP_SCROLL_BAR_END_L.getpixel())
         for k in range(9):
             box_h = dofus.ZAAP_COORD_R.height() / 9
             box_y = dofus.ZAAP_COORD_R.y() + k * box_h
             box_x = dofus.ZAAP_COORD_R.x()
             box_w = dofus.ZAAP_COORD_R.width()
             box_r = Region(box_x, box_y, box_w, box_h)
             image = env.capture(box_r)
             gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
             low_bound = np.array([145, 0, 0])
             upper_bound = np.array([255, 255, 14])
             bgr_img = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
             mask = cv2.inRange(bgr_img, low_bound, upper_bound)
             result = cv2.bitwise_and(gray, gray, mask=mask)
             result = cv2.threshold(result, 0, 255,
                                    cv2.THRESH_BINARY_INV)[1]
             newShape = (int(box_w * 15), int(box_h * 15))
             result = cv2.resize(result, newShape)
             result = cv2.blur(result, (5, 5))
             text = pytesseract.image_to_string(result, config='--psm 6')
             res = re.findall("(-?\s*\d+),?(-?\s*\d+)", text)
             if res:
                 coord = tuple(
                     map(lambda x: int(x.replace(' ', '')), res[0]))
                 print(coord)
                 if coord == zapCoords:
                     box_r.click()
                     sleep(0.2)
                     box_r.click()
                     self.waitMapChange(*zapCoords, 60 * 15)
                     if zapCoords == (20, -29):
                         Region(618, 729, 36, 24).click()
                     return True
         dofus.ZAAP_COORD_R.scroll(clicks=-3, delay_between_ticks=0.1)
         dofus.OUT_OF_COMBAT_R.hover()
         sleep(0.5)
     raise Exception("Zaap coords not found!")
예제 #4
0
    def saveShot(self):
        rec = QtCore.QRect(self.begin, self.end)
        capture = [
            self.captureType,
            rec.x(),
            rec.y(),
            rec.width(),
            rec.height(), 'None'
        ]

        bi = env.capture(rec)
        image_id = str(uuid.uuid4().hex)
        image_file = os.path.join(self.parent.patternDir(self.captureType),
                                  image_id + ".png")
        cv2.imwrite(image_file, bi)
        capture[-1] = image_id
        self.snippetTaken.emit(capture)
        self.show()
예제 #5
0
파일: bot.py 프로젝트: Me0w1ng/bot2pix
    def parseMapCoords():
        image = env.capture(dofus.MAP_COORDS_R)
        gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        low_bound = np.array([160, 60, 0])
        upper_bound = np.array([255, 255, 255])

        bgr_img = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
        mask = cv2.inRange(bgr_img, low_bound, upper_bound)
        result = cv2.bitwise_and(gray, gray, mask=mask)
        result = cv2.threshold(result, 0, 255, cv2.THRESH_BINARY_INV)[1]
        newShape = (int(dofus.MAP_COORDS_R.width() * 10), int(dofus.MAP_COORDS_R.height() * 10))
        result = cv2.resize(result, newShape)
        result = cv2.blur(result, (7, 7))
        text = pytesseract.image_to_string(result, config='--psm 6')

        print(text)
        res = re.findall("(-?\d+)", text)
        if res:
            return int(res[0]), int(res[1])
        else:
            return None
예제 #6
0
 def getpixel(self):
     bi = env.capture(Region(self.x(), self.y(), 1, 1))
     ni = cv2.cvtColor(bi, cv2.COLOR_RGB2BGR)
     return QColor(*bi[0, 0])
예제 #7
0
 def stream(self, interval=FOREVER):
     s = perf_counter()
     while perf_counter() - s < interval:
         yield cv2.cvtColor(env.capture(self), cv2.COLOR_RGB2GRAY)