Пример #1
0
    def __call__(self, spotted, context):
        parent = spotted.parent
        topleft = parent.topleft
        contours = context.rois[self.label]

        roi = tuple((i, i + n) for (i, n) in izip(spotted.offset, spotted.data.shape))

        def inroi(i, r):
            for ((a, n), x) in izip(r, i):
                if not (a <= x < n):
                    return False

            return True

        counts = ballot()
        for i in product(*[range(*x) for x in roi]):
            for c in contours:
                if inroi(i, c):
                    counts.vote(c)

        roi = counts.winner()
        if roi != None:
            return percept(parent.data[fancy_index(roi)], tuple(i[0] for i in roi), parent)
        else:
            return spotted
Пример #2
0
 def __init__(self, *roi, **options):
     self.roi = fancy_index(roi)
     self.precision = options.get('precision', 0.0)