def METHOD_NAME():
    args = parse_args()
    with open(args.bundler_path, "r") as fid:
        line = fid.readline()
        line = fid.readline()
        num_images, num_points = map(int, line.split())
        for i in range(5 * num_images):
            fid.readline()
        xyz = np.zeros((num_points, 3), dtype=np.float64)
        rgb = np.zeros((num_points, 3), dtype=np.uint16)
        track_lengths = np.zeros((num_points,), dtype=np.uint32)
        for i in range(num_points):
            if i % 1000 == 0:
                print("Reading point", i, "/", num_points)
            xyz[i] = map(float, fid.readline().split())
            rgb[i] = map(int, fid.readline().split())
            track_lengths[i] = int(fid.readline().split()[0])
    mask = track_lengths >= args.min_track_length
    xyz = xyz[mask]
    rgb = rgb[mask]
    if args.normalize:
        sorted_x = np.sort(xyz[:, 0])
        sorted_y = np.sort(xyz[:, 1])
        sorted_z = np.sort(xyz[:, 2])
        num_coords = sorted_x.size
        min_coord = int(args.normalize_p0 * num_coords)
        max_coord = int(args.normalize_p1 * num_coords)
        mean_coords = xyz.mean(0)
        bbox_min = np.array([sorted_x[min_coord], sorted_y[min_coord],
                             sorted_z[min_coord]])
        bbox_max = np.array([sorted_x[max_coord], sorted_y[max_coord],
                             sorted_z[max_coord]])
        extent = np.linalg.norm(bbox_max - bbox_min)
        scale = 10.0 / extent
        xyz -= mean_coords
        xyz *= scale
    xyz[:, 2] *= -1
    with open(args.ply_path, "w") as fid:
        fid.write("ply\n")
        fid.write("format ascii 1.0\n")
        fid.write("element vertex %d\n" % xyz.shape[0])
        fid.write("property float x\n")
        fid.write("property float y\n")
        fid.write("property float z\n")
        fid.write("property float nx\n")
        fid.write("property float ny\n")
        fid.write("property float nz\n")
        fid.write("property uchar diffuse_red\n")
        fid.write("property uchar diffuse_green\n")
        fid.write("property uchar diffuse_blue\n")
        fid.write("end_header\n")
        for i in range(xyz.shape[0]):
            if i % 1000 == 0:
                print("Writing point", i, "/", xyz.shape[0])
            fid.write("%f %f %f 0 0 0 %d %d %d\n" % (xyz[i, 0], xyz[i, 1],
                                                     xyz[i, 2], rgb[i, 0],
                                                     rgb[i, 1], rgb[i, 2]))