Beispiel #1
0
 def map_to_input_space(self, scope):
     patch_shape = T.cast(self.cropper.patch_shape, floatX)
     image_shape = scope.x_shape
     if isinstance(image_shape, tuple):
         # for featurelevel_UCF101
         image_shape = image_shape[1][:, 1:]
     scope.true_location, scope.true_scale = static_map_to_input_space(
         scope.raw_location, scope.raw_scale, patch_shape, image_shape)
     # measure the extent to which raw_location is outside the image
     scope.excursion = util.rectify(scope.raw_location**2 - 1)
Beispiel #2
0
def model(X, w_L1, w_L2, w_L3, w_L4, p_drop_conv, p_drop_hidden):
    crossnormalizer = crossnorm(alpha=1e-4, k=2, beta=0.75, n=9)
    l1b = rectify(cuconv(X, w_L1, border_mode=(5, 5)))
    l1 = cupool(l1b, (3, 3), stride=(2, 2))
    l1 = crossnormalizer(l1)
    l1 = dropout(l1, p_drop_conv)

    l2b = rectify(cuconv(l1, w_L2, border_mode='full'))
    l2 = cupool(l2b, (3, 3), stride=(2, 2))
    l2 = crossnormalizer(l2)
    l2 = dropout(l2, p_drop_conv)

    l3b = rectify(cuconv(l2, w_L3, border_mode='full'))
    l3 = cupool(l3b, (3, 3), stride=(2, 2))
    l3 = crossnormalizer(l3)

    l4 = T.flatten(l3, outdim=2)

    pyx = dropout(l4, p_drop_hidden)
    pyx = softmax(T.dot(pyx, w_L4))
    return l1, l2, l3, pyx
Beispiel #3
0
def get_approx_poly(card, do_rectify=True, image=None):
    perimeter = cv2.arcLength(card, True)

    approximated_poly = cv2.approxPolyDP(card, 0.1 * perimeter, True)

    # TODO: deal with case where approximated_poly does not have 4 points (3 or 5)
    # kl = len(approximated_poly)
    # kif l != 4:
    # kfor p in approximated_poly:
    # kcv2.circle(image, (p[0][0], p[0][1]), 3, (255,0,0), 5)
    # kutil.show(image)
    # k# get rectified points in clockwise order

    if do_rectify:
        reapproximated_poly = util.rectify(approximated_poly)
        if reapproximated_poly.all():
            approximated_poly = reapproximated_poly
        else:
            # print 'Not rectified!'
            return None
    return approximated_poly