Пример #1
0
def get_all_windows(img, shape, mv):
    scales = np.arange(0.2, 0.35, 0.02)
    m, n = shape
    for scl in scales:
        img_ = misc.imresize(img, scl)
        mv.change_image(img_)
        x, y = img_.shape[:2]
        if x < m or y < n:
            continue
        for i, j in funcs.iter_shape((x, y), shape, 4):
            val = mv.valuefy((i, j))
            if val > 0:
                res_i = (int(i[0] / scl), int(i[1] / scl))
                res_j = (int(j[0] / scl), int(j[1] / scl))
                yield ((res_i, res_j), val)
Пример #2
0
 def _find_nearest(self, shape, svm):
     mv = MyViola()
     max_ = -math.inf
     res_i = (0, 0)
     res_j = (0, 0)
     m, n = shape
     for scl in self._scale:
         img = misc.imresize(self._img, scl)
         mv.change_image(img)
         x, y = img.shape[:2]
         if x < m or y < n:
             continue
         for i, j in funcs.iter_shape((x, y), shape):
             val = svm.valuefy(mv.calc_features((i,j)))
             if val > max_:
                 max_ = val
                 res_i = (int(i[0] / scl), int(i[1] / scl))
                 res_j = (int(j[0] / scl), int(j[1] / scl))
     return res_i, res_j
Пример #3
0
def find_face(img, shape, mv):
    res_i = (0, 0)
    res_j = (0, 0)
    res_scl = 1
    max_ = 0
    scales = np.arange(0.2, 0.35, 0.025)
    m, n = shape
    for scl in scales:
        img_ = misc.imresize(img, scl)
        mv.change_image(img_)
        x, y = img_.shape[:2]
        if x < m or y < n:
            continue
        for i, j in funcs.iter_shape((x, y), shape, 4):
            val = mv.valuefy((i, j))
            if val > max_:
                max_ = val
                res_i, res_j = i, j
                res_scl = scl
    return (int(res_i[0] / res_scl), int(res_i[1] / res_scl)), (int(res_j[0] / res_scl), int(res_j[1] / res_scl))