def runRectification(image_name):
    img = imageio.readImageFloat(image_name)

    points = pointselecter.getFourPoints(img)

    print "Processing..... Please, wait."

    D_W = RESULTING_RECTIFICATION_WIDTH
    D_H = RESULTING_RECTIFICATION_HEIGHT
    border = RECTIFICATION_BORDER_FRACTION
    points_view = np.array([(border * D_W, border * D_H),
                            ((1 - border) * D_W, border * D_H),
                            ((1 - border) * D_W, (1 - border) * D_H),
                            (border * D_W, (1 - border) * D_H)])

    H = transforms.computeHomography(points, points_view)

    pts_x, pts_y = zip(*points)

    result_image = 0 * np.ones((D_H, D_W, 3))
    fill(img, result_image, H)

    print "Displaying the final result."
    figure, axis = plt.subplots(ncols=1)
    axis.imshow(result_image, vmin=0, vmax=1)
    plt.show()
예제 #2
0
def runRectification(image_name):
	img = imageio.readImageFloat(image_name)

	points = pointselecter.getFourPoints(img)

	print "Processing..... Please, wait."

	D_W = RESULTING_RECTIFICATION_WIDTH
	D_H = RESULTING_RECTIFICATION_HEIGHT
	border = RECTIFICATION_BORDER_FRACTION
	points_view = np.array([(border*D_W,border*D_H),((1-border)*D_W,border*D_H),((1-border)*D_W,(1-border)*D_H),(border*D_W,(1-border)*D_H)])

	H = transforms.computeHomography(points,points_view)

	pts_x, pts_y = zip(*points)

	result_image = 0*np.ones((D_H,D_W,3))
	fill(img,result_image,H)

	print "Displaying the final result."
	figure, axis = plt.subplots(ncols=1)
	axis.imshow(result_image, vmin=0, vmax=1)
	plt.show()
      matrix_msg = matrix3_3()

      # This is placeholder code that will draw a 4 by 3 grid in the corner of
      # the image
      H = np.eye(3)
      nx = 4
      ny = 3

      WIDTH_POINTS = nx*TILE_LENGTH
      HEIGHT_POINTS = ny*TILE_LENGTH

      points_source = points
      points_target = [(0,0),(WIDTH_POINTS,0),(WIDTH_POINTS,HEIGHT_POINTS),(0,HEIGHT_POINTS)]

      H = np.array(transforms.computeHomography(points_target,points_source))

      matrix_msg.e00 = H[0,0]
      matrix_msg.e01 = H[0,1]
      matrix_msg.e02 = H[0,2]
      matrix_msg.e10 = H[1,0]
      matrix_msg.e11 = H[1,1]
      matrix_msg.e12 = H[1,2]
      matrix_msg.e20 = H[2,0]
      matrix_msg.e21 = H[2,1]
      matrix_msg.e22 = H[2,2]

      matrix_pub.publish(matrix_msg)

# ==============================================================================