Example #1
0
def read_user_dots(path, number_points, x, y, w, h, shape):
    dco = DetectContours()
    points = []
    for i in range(0, number_points):
        #if i < 10:
        #    i = str(0) + str(i)
        print path + "/" + str(i + 1) + ".jpg"
        img = cv2.imread(path + "/" + str(i + 1) + ".jpg")
        # make image for userpt_locations
        blank = np.zeros(shape)
        f_x = 1.0 * w / img.shape[1]
        f_y = 1.0 * h / img.shape[0]

        print img.shape
        print f_y, f_x
        print w / img.shape[1], h / img.shape[0]
        sys.stdout.flush()

        dots = cv2.resize(img, (None),
                          fx=f_x,
                          fy=f_y,
                          interpolation=cv2.INTER_LINEAR)
        blank[y:int(y + h), x:int(x + w)] = dots
        print blank.dtype
        sys.stdout.flush()
        a = dco.getContours(np.asarray(blank, np.uint8))
        #dci.get_circles(img)
        points.append(dco.getCentroids(a))
        #points.append(dci.get)
    return points
Example #2
0
def read_dots(path, number_points):
    dco = DetectContours()
    points = []
    for i in range(0, number_points):
        #if i < 10:
        #    i = str(0) + str(i)

        img = cv2.imread(path + "/" + str(i + 1) + ".jpg")
        a = dco.getContours(img)
        #dci.get_circles(img)
        points.append(dco.getCentroids(a))
        #points.append(dci.get)
    return points
Example #3
0
fh = FindHomography()
cam_points = []
cam_shape = []
x = 100
y = 50
w = 300
h = 200
#userpt_locations = read_user_dots(os.getcwd() + "/user/generated/" + sys.argv[3], number_points, x,y,w,h,
#            cv2.imread(os.getcwd() + "/user/camera/" + sys.argv[3] + "/0.jpg").shape)
#origpoints = read_dots(os.getcwd() + "/user/generated/" + sys.argv[3], number_points) #camera points

for i in range(0, number_points):
    #if i < 10:
    #    i = str(0) + str(i)
    img = cv2.imread("images/" + sys.argv[1] + "/" + str(i) + ".jpg")
    a = dco.getContours(img)
    #dci.get_circles(img)
    cam_points.append(dco.getCentroids(a))
    #points.append(dci.get)

#userpt_locations = get_dots(cv2.imread("images/user/3e18user.jpg"))
userpts = read_user_dots("images/4e28", number_points, x, y, w, h,
                         cv2.imread("images/4c28/0.jpg").shape)
userpts = map(lambda x: x[0], userpts)
#userpt_orig_locations = original_locations(userpt_locations, (3,6), orig18, points)


def rvs_warp_pts(points_shape, user_points, cam_points):
    #blank = np.zeros(cv2.imread("images/" + sys.argv[1] + "/0.jpg").shape, dtype=np.uint8)
    blank = cv2.imread("images/4c28/0.jpg")
    rows = points_shape[0]