Beispiel #1
0
def find_clicked_bound(img, x, y, size=200):
    maxy, maxx = img.shape[:2]
    size = min(size, maxx, maxy)
    l, r, t, b = x - size / 2, x + size / 2, y - size / 2, y + size / 2
    if l < 0:
        l = 0
    elif r > maxx:
        l = maxx - size
    if t < 0:
        t = 0
    elif b > maxy:
        t = maxy - size
    return Bounds(l, t, size, size)
Beispiel #2
0
 def parse_bounds(text):
     m = re.match(r'\[(\d+),(\d+)\]\[(\d+),(\d+)\]', text)
     if m is None:
         return None
     return Bounds(*map(int, m.groups()))
Beispiel #3
0
        sys.stdout.write('\n')

        # wait until click area not same
        if found and wait_change:
            start_time = time.time()
            while time.time() - start_time < timeout:
                # screen_img = self.screenshot()
                ret = self.match(search_img)
                if ret is None:
                    break
        if not found:
            raise errors.ImageNotFoundError('Not found image %s' % (pattern, ))

    def watch(self, name, timeout=None):
        """Return a new watcher
        Args:
            name: string watcher name
            timeout: watch timeout

        Returns:
            watcher object
        """
        w = Watcher(self, name, timeout)
        w._dev = self
        return w


if __name__ == '__main__':
    b = Bounds(1, 2, 3, 4)
    print b
    print b * 1.0