예제 #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)
예제 #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()))
예제 #3
0
파일: mixin.py 프로젝트: zzzyw-work/ATX
            log.debug('confidence: %s', point.confidence)
            if not point.matched:
                log.info('Ignore confidence: %s', point.confidence)
                continue
            
            # wait for program ready
            if delay and delay > 0:
                self.delay(delay)

            func = getattr(self, action)
            func(*point.pos)

            found = True
            break
        sys.stdout.write('\n')

        if not found:
            if safe:
                log.info("Image(%s) not found, safe=True, skip", pattern)
                return None
            raise errors.ImageNotFoundError('Not found image %s' % pattern, point)

        # FIXME(ssx): maybe this function is too complex
        return point #collections.namedtuple('X', ['pattern', 'point'])(pattern, point)


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