Example #1
0
def generate_octomap_samples(octomap_file, query_positions, tmp_dir):

    if not os.path.exists(tmp_dir): os.makedirs(tmp_dir)

    tmp_query_positions_hdf5_file = os.path.join(tmp_dir, "_tmp_query_positions.hdf5")
    tmp_octomap_samples_hdf5_file = os.path.join(tmp_dir, "_tmp_octomap_samples.hdf5")

    with h5py.File(tmp_query_positions_hdf5_file, "w") as f: f.create_dataset("dataset", data=query_positions)

    current_source_path = path_utils.get_current_source_file_path(frame=inspect.currentframe())
    cpp_bin             = os.path.abspath(os.path.join(current_source_path, "..", "..", "cpp", "bin", "generate_octomap_samples"))

    cmd = \
        cpp_bin + \
        " --octomap_file="         + octomap_file                  + \
        " --query_positions_file=" + tmp_query_positions_hdf5_file + \
        " --output_file="          + tmp_octomap_samples_hdf5_file + \
        " --silent"
    # print("")
    # print(cmd)
    # print("")
    retval = os.system(cmd)
    assert retval == 0

    with h5py.File(tmp_octomap_samples_hdf5_file, "r") as f: octomap_samples = matrix(f["dataset"][:]).A1

    return octomap_samples
Example #2
0
def process_scene(s, args):

    scene_name = s["name"]
    scene_dir = os.path.abspath(os.path.join(dataset_scenes_dir, scene_name))

    if args.use_python_reference_implementation:
        use_python_reference_implementation_str = "--use_python_reference_implementation"
    else:
        use_python_reference_implementation_str = ""

    current_source_file_path = path_utils.get_current_source_file_path(
        frame=inspect.currentframe())
    cwd = os.getcwd()
    os.chdir(current_source_file_path)

    cmd = \
        _system_config.python_bin + " scene_generate_camera_trajectories_random_walk.py" + \
        " --scene_dir " + scene_dir + \
        " " + use_python_reference_implementation_str

    print("")
    print(cmd)
    print("")
    retval = os.system(cmd)
    assert retval == 0

    os.chdir(cwd)
def process_scene(s, args):

    scene_name = s["name"]
    scene_dir = os.path.abspath(os.path.join(dataset_scenes_dir, scene_name))
    detail_dir = os.path.abspath(os.path.join(scene_dir, "_detail"))
    asset_export_dir = os.path.abspath(os.path.join(scene_dir,
                                                    "_asset_export"))

    in_file = os.path.abspath(
        os.path.join(asset_export_dir, in_scene_fileroot + ".obj"))
    out_dir = os.path.abspath(os.path.join(detail_dir, "mesh"))

    current_source_file_path = path_utils.get_current_source_file_path(
        frame=inspect.currentframe())
    cwd = os.getcwd()
    os.chdir(current_source_file_path)

    cmd = \
        _system_config.python_bin + " generate_mesh_from_obj.py" + \
        " --in_file " + in_file + \
        " --out_dir " + out_dir
    print("")
    print(cmd)
    print("")
    retval = os.system(cmd)
    assert retval == 0

    os.chdir(cwd)
Example #4
0
def generate_octomap(mesh_vertices, mesh_faces_vi, start_camera_positions, octomap_min, octomap_max, n_rays, n_iters, n_voxel_size, n_ray_nearest_neighbors, octomap_file, tmp_dir):

    if not os.path.exists(tmp_dir): os.makedirs(tmp_dir)

    tmp_mesh_vertices_hdf5_file          = os.path.join(tmp_dir, "_tmp_mesh_vertices.hdf5")
    tmp_mesh_faces_vi_hdf5_file          = os.path.join(tmp_dir, "_tmp_mesh_faces_vi.hdf5")
    tmp_start_camera_positions_hdf5_file = os.path.join(tmp_dir, "_tmp_start_camera_positions.hdf5")
    tmp_ray_directions_hdf5_file         = os.path.join(tmp_dir, "_tmp_ray_directions.hdf5")
    tmp_ray_neighbor_indices_hdf5_file   = os.path.join(tmp_dir, "_tmp_ray_neighbor_indices.hdf5")
    tmp_octomap_min_hdf5_file            = os.path.join(tmp_dir, "_tmp_octomap_min.hdf5")
    tmp_octomap_max_hdf5_file            = os.path.join(tmp_dir, "_tmp_octomap_max.hdf5")
    tmp_free_space_min_hdf5_file         = os.path.join(tmp_dir, "_tmp_free_space_min.hdf5")
    tmp_free_space_max_hdf5_file         = os.path.join(tmp_dir, "_tmp_free_space_max.hdf5")

    # compute ray directions
    ray_directions = sphere_sampling_utils.generate_evenly_distributed_samples_on_sphere(n_rays)

    # compute ray neighbor indices
    pset                 = ray_directions.astype(float64)
    ckdtree              = scipy.spatial.cKDTree(pset, balanced_tree=False)
    d,i                  = ckdtree.query(pset, k=n_ray_nearest_neighbors)
    ray_neighbor_indices = i

    with h5py.File(tmp_mesh_vertices_hdf5_file,          "w") as f: f.create_dataset("dataset", data=mesh_vertices)
    with h5py.File(tmp_mesh_faces_vi_hdf5_file,          "w") as f: f.create_dataset("dataset", data=mesh_faces_vi)
    with h5py.File(tmp_start_camera_positions_hdf5_file, "w") as f: f.create_dataset("dataset", data=start_camera_positions)
    with h5py.File(tmp_ray_directions_hdf5_file,         "w") as f: f.create_dataset("dataset", data=ray_directions)
    with h5py.File(tmp_ray_neighbor_indices_hdf5_file,   "w") as f: f.create_dataset("dataset", data=ray_neighbor_indices)
    with h5py.File(tmp_octomap_min_hdf5_file,            "w") as f: f.create_dataset("dataset", data=octomap_min)
    with h5py.File(tmp_octomap_max_hdf5_file,            "w") as f: f.create_dataset("dataset", data=octomap_max)

    current_source_path = path_utils.get_current_source_file_path(frame=inspect.currentframe())
    cpp_bin             = os.path.abspath(os.path.join(current_source_path, "..", "..", "cpp", "bin", "generate_octomap"))

    cmd = \
        cpp_bin + \
        " --mesh_vertices_file="          + tmp_mesh_vertices_hdf5_file          + \
        " --mesh_faces_vi_file="          + tmp_mesh_faces_vi_hdf5_file          + \
        " --start_camera_positions_file=" + tmp_start_camera_positions_hdf5_file + \
        " --ray_directions_file="         + tmp_ray_directions_hdf5_file         + \
        " --ray_neighbor_indices_file="   + tmp_ray_neighbor_indices_hdf5_file   + \
        " --octomap_min_file="            + tmp_octomap_min_hdf5_file            + \
        " --octomap_max_file="            + tmp_octomap_max_hdf5_file            + \
        " --n_iters="                     + str(n_iters)                         + \
        " --n_voxel_size="                + str(n_voxel_size)                    + \
        " --octomap_file="                + octomap_file                         + \
        " --free_space_min_file="         + tmp_free_space_min_hdf5_file         + \
        " --free_space_max_file="         + tmp_free_space_max_hdf5_file
        # " --silent"
    print("")
    print(cmd)
    print("")
    retval = os.system(cmd)
    assert retval == 0

    with h5py.File(tmp_free_space_min_hdf5_file, "r") as f: free_space_min = matrix(f["dataset"][:]).A1
    with h5py.File(tmp_free_space_max_hdf5_file, "r") as f: free_space_max = matrix(f["dataset"][:]).A1

    return free_space_min, free_space_max
Example #5
0
def generate_ray_intersections(vertices, faces, ray_positions, ray_directions,
                               tmp_dir):

    if not os.path.exists(tmp_dir): os.makedirs(tmp_dir)

    tmp_vertices_hdf5_file = os.path.join(tmp_dir, "_tmp_vertices.hdf5")
    tmp_faces_hdf5_file = os.path.join(tmp_dir, "_tmp_faces.hdf5")
    tmp_ray_positions_hdf5_file = os.path.join(tmp_dir,
                                               "_tmp_ray_positions.hdf5")
    tmp_ray_directions_hdf5_file = os.path.join(tmp_dir,
                                                "_tmp_ray_directions.hdf5")
    tmp_output_ray_hit_data_float_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_ray_hit_data_float.hdf5")
    tmp_output_ray_hit_data_int_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_ray_hit_data_int.hdf5")

    with h5py.File(tmp_vertices_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=vertices)
    with h5py.File(tmp_faces_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=faces)
    with h5py.File(tmp_ray_positions_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=ray_positions)
    with h5py.File(tmp_ray_directions_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=ray_directions)

    current_source_path = path_utils.get_current_source_file_path(
        frame=inspect.currentframe())
    generate_ray_intersections_bin = os.path.abspath(
        os.path.join(current_source_path, "..", "..", "cpp", "bin",
                     "generate_ray_intersections"))

    cmd = \
        generate_ray_intersections_bin + \
        " --vertices_file="                  + tmp_vertices_hdf5_file                  + \
        " --faces_file="                     + tmp_faces_hdf5_file                     + \
        " --ray_positions_file="             + tmp_ray_positions_hdf5_file             + \
        " --ray_directions_file="            + tmp_ray_directions_hdf5_file            + \
        " --output_ray_hit_data_float_file=" + tmp_output_ray_hit_data_float_hdf5_file + \
        " --output_ray_hit_data_int_file="   + tmp_output_ray_hit_data_int_hdf5_file   + \
        " --silent"
    # print("")
    # print(cmd)
    # print("")
    retval = os.system(cmd)
    assert retval == 0

    with h5py.File(tmp_output_ray_hit_data_float_hdf5_file, "r") as f:
        ray_hit_data_float = f["dataset"][:]
    with h5py.File(tmp_output_ray_hit_data_int_hdf5_file, "r") as f:
        ray_hit_data_int = f["dataset"][:]

    intersection_distances = matrix(ray_hit_data_float[:, 0]).A1
    intersection_normals = matrix(ray_hit_data_float[:, 1:4]).A
    prim_ids = matrix(ray_hit_data_int[:, 0]).A1

    return intersection_distances, intersection_normals, prim_ids
def generate_oriented_bounding_box_3d(points, n_epsilon, n_point_samples,
                                      n_grid_size, n_diam_opt_loops,
                                      n_grid_search_opt_loops, tmp_dir):

    if not os.path.exists(tmp_dir): os.makedirs(tmp_dir)

    tmp_points_hdf5_file = os.path.join(tmp_dir, "_tmp_points.hdf5")
    tmp_output_bounding_box_center_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_bounding_box_center.hdf5")
    tmp_output_bounding_box_extent_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_bounding_box_extent.hdf5")
    tmp_output_bounding_box_orientation_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_bounding_box_orientation.hdf5")

    with h5py.File(tmp_points_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=points)

    current_source_path = path_utils.get_current_source_file_path(
        frame=inspect.currentframe())
    cpp_bin = os.path.abspath(
        os.path.join(current_source_path, "..", "..", "cpp", "bin",
                     "generate_oriented_bounding_box"))

    cmd = \
        cpp_bin + \
        " --points_file="                          + tmp_points_hdf5_file                     + \
        " --n_epsilon="                            + str(n_epsilon)                           + \
        " --n_point_samples="                      + str(n_point_samples)                     + \
        " --n_grid_size="                          + str(n_grid_size)                         + \
        " --n_diam_opt_loops="                     + str(n_diam_opt_loops)                    + \
        " --n_grid_search_opt_loops="              + str(n_grid_search_opt_loops)             + \
        " --output_bounding_box_center_file="      + tmp_output_bounding_box_center_hdf5_file + \
        " --output_bounding_box_extent_file="      + tmp_output_bounding_box_extent_hdf5_file + \
        " --output_bounding_box_orientation_file=" + tmp_output_bounding_box_orientation_hdf5_file
    # " --silent"
    print("")
    print(cmd)
    print("")
    retval = os.system(cmd)
    assert retval == 0

    with h5py.File(tmp_output_bounding_box_center_hdf5_file, "r") as f:
        bounding_box_center = matrix(f["dataset"][:]).A1
    with h5py.File(tmp_output_bounding_box_extent_hdf5_file, "r") as f:
        bounding_box_extent = matrix(f["dataset"][:]).A1
    with h5py.File(tmp_output_bounding_box_orientation_hdf5_file, "r") as f:
        bounding_box_orientation = matrix(f["dataset"][:]).A

    assert bounding_box_extent[0] >= bounding_box_extent[1]
    assert bounding_box_extent[1] >= bounding_box_extent[2]
    assert isclose(linalg.det(bounding_box_orientation), 1)

    return bounding_box_center, bounding_box_extent, bounding_box_orientation
def build_sympy_modules():

    print "flashlight.quadrotor_2d: Constructing sympy expressions..."
    sys_time_begin = time.time()

    # manipulator matrices
    H_expr,C_expr,G_expr,B_expr = construct_manipulator_matrix_expressions()

    # expressions to solve for df_dx and df_du
    q_dot_dot_expr = H_expr.inv()*(B_expr*u_expr - (C_expr*q_dot_expr + G_expr))
    x_dot_expr     = sympy_utils.construct_matrix_from_block_matrix( sympy.Matrix( [ [q_dot_expr], [q_dot_dot_expr] ] ) )
    df_dx_expr     = x_dot_expr.jacobian(x_expr)
    df_du_expr     = x_dot_expr.jacobian(u_expr)

    # expressions to solve for g_dynamics, given x_current x_next u_current dt_current
    # x_dot_current_expr           = x_dot_expr.subs( dict( zip(x_expr,x_current_expr) + zip(u_expr,u_current_expr) ) )
    # g_dynamics_ti_expr           = x_next_expr - (x_current_expr + x_dot_current_expr*dt_current_expr)
    # dgdynamicsti_dxcurrent_expr  = g_dynamics_ti_expr.jacobian(x_current_expr)
    # dgdynamicsti_dxnext_expr     = g_dynamics_ti_expr.jacobian(x_next_expr)
    # dgdynamicsti_ducurrent_expr  = g_dynamics_ti_expr.jacobian(u_current_expr)
    # dgdynamicsti_ddtcurrent_expr = g_dynamics_ti_expr.diff(dt_current_expr)

    sys_time_end = time.time()
    print "flashlight.quadrotor_2d: Finished constructing sympy expressions (%.03f seconds)." % (sys_time_end - sys_time_begin)

    print "flashlight.quadrotor_2d: Building sympy modules..."
    sys_time_begin = time.time()

    current_source_file_path = path_utils.get_current_source_file_path()

    sympy_utils.build_module_autowrap( expr=H_expr, syms=const_and_x_syms, module_name="quadrotor_2d_H", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor_2d", dummify=True, build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    sympy_utils.build_module_autowrap( expr=C_expr, syms=const_and_x_syms, module_name="quadrotor_2d_C", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor_2d", dummify=True, build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    sympy_utils.build_module_autowrap( expr=G_expr, syms=const_and_x_syms, module_name="quadrotor_2d_G", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor_2d", dummify=True, build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    sympy_utils.build_module_autowrap( expr=B_expr, syms=const_and_x_syms, module_name="quadrotor_2d_B", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor_2d", dummify=True, build_vectorized=True, verbose=True, request_delete_tmp_dir=True )

    sympy_utils.build_module_autowrap( expr=x_dot_expr, syms=const_and_x_and_u_syms, module_name="quadrotor_2d_x_dot", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor_2d", dummify=True, build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    sympy_utils.build_module_autowrap( expr=df_dx_expr, syms=const_and_x_and_u_syms, module_name="quadrotor_2d_df_dx", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor_2d", dummify=True, build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    sympy_utils.build_module_autowrap( expr=df_du_expr, syms=const_and_x_and_u_syms, module_name="quadrotor_2d_df_du", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor_2d", dummify=True, build_vectorized=True, verbose=True, request_delete_tmp_dir=True )

    # sympy_utils.build_module_autowrap( expr=g_dynamics_ti_expr,           syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_g_dynamics_ti",           tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_dxcurrent_expr,  syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_dxcurrent",  tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_dxnext_expr,     syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_dxnext",     tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ducurrent_expr,  syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ducurrent",  tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ddtcurrent_expr, syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ddtcurrent", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )

    sys_time_end = time.time()
    print "flashlight.quadrotor_2d: Finished building sympy modules (%.03f seconds)." % (sys_time_end - sys_time_begin)
Example #8
0
def load_exr_file(filename, tmp_dir):

    if not os.path.exists(tmp_dir): os.makedirs(tmp_dir)

    tmp_output_file_prefix = os.path.join(tmp_dir, "_tmp_output")
    tmp_output_header_csv_file = os.path.join(tmp_dir,
                                              "_tmp_output.header.csv")
    tmp_output_channels_csv_file = os.path.join(tmp_dir,
                                                "_tmp_output.channels.csv")

    current_source_path = path_utils.get_current_source_file_path(
        frame=inspect.currentframe())
    generate_hdf5_from_exr_bin = os.path.abspath(
        os.path.join(current_source_path, "..", "..", "cpp", "bin",
                     "generate_hdf5_from_exr"))

    cmd = \
        generate_hdf5_from_exr_bin + \
        " --input_file="  + filename               + \
        " --output_file=" + tmp_output_file_prefix + \
        " --silent"
    # print("")
    # print(cmd)
    # print("")
    retval = os.system(cmd)
    assert retval == 0

    df_header = pd.read_csv(tmp_output_header_csv_file)
    df_channels = pd.read_csv(tmp_output_channels_csv_file)

    channels = {}

    for dfi in df_channels.itertuples():

        params = df_channels.loc[dfi.Index].copy()
        channel_name = params["channel_name"]

        tmp_output_channel_hdf5_file = tmp_output_file_prefix + "." + channel_name + ".hdf5"

        with h5py.File(tmp_output_channel_hdf5_file, "r") as f:
            channel = f["dataset"][:]
        channels[channel_name] = channel

    return df_header, df_channels, channels
Example #9
0
def process_scene(s, args):

    scene_name = s["name"]
    scene_dir  = os.path.abspath(os.path.join(dataset_scenes_dir, scene_name))

    current_source_file_path = path_utils.get_current_source_file_path(frame=inspect.currentframe())
    cwd = os.getcwd()
    os.chdir(current_source_file_path)

    cmd = \
        _system_config.python_bin + " scene_generate_octomap.py" + \
        " --scene_dir " + scene_dir
    print("")
    print(cmd)
    print("")
    retval = os.system(cmd)
    assert retval == 0

    os.chdir(cwd)
def generate_camera_trajectory_random_walk(
        mesh_vertices, mesh_faces_vi, octomap_file, octomap_free_space_min,
        octomap_free_space_max, start_camera_position,
        start_camera_orientation, n_width_pixels, n_height_pixels, n_fov_x,
        n_samples_random_walk, n_samples_octomap_query,
        n_samples_camera_pose_candidates, n_voxel_size,
        n_query_half_extent_relative_to_current,
        n_query_half_extent_relative_to_start, tmp_dir):

    if not os.path.exists(tmp_dir): os.makedirs(tmp_dir)

    tmp_mesh_vertices_hdf5_file = os.path.join(tmp_dir,
                                               "_tmp_mesh_vertices.hdf5")
    tmp_mesh_faces_vi_hdf5_file = os.path.join(tmp_dir,
                                               "_tmp_mesh_faces_vi.hdf5")
    tmp_octomap_free_space_min_hdf5_file = os.path.join(
        tmp_dir, "_tmp_octomap_free_space_min.hdf5")
    tmp_octomap_free_space_max_hdf5_file = os.path.join(
        tmp_dir, "_tmp_octomap_free_space_max.hdf5")
    tmp_start_camera_position_hdf5_file = os.path.join(
        tmp_dir, "_tmp_start_camera_position.hdf5")
    tmp_start_camera_orientation_hdf5_file = os.path.join(
        tmp_dir, "_tmp_start_camera_orientation.hdf5")
    tmp_camera_rays_hdf5_file = os.path.join(tmp_dir, "_tmp_camera_rays.hdf5")
    tmp_camera_rays_distances_to_center_hdf5_file = os.path.join(
        tmp_dir, "_tmp_camera_rays_distances_to_center.hdf5")
    tmp_n_query_half_extent_relative_to_start_hdf5_file = os.path.join(
        tmp_dir, "_tmp_n_query_half_extent_relative_to_start.hdf5")
    tmp_n_query_half_extent_relative_to_current_hdf5_file = os.path.join(
        tmp_dir, "_tmp_n_query_half_extent_relative_to_current.hdf5")
    tmp_output_camera_look_from_positions_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_camera_look_from_positions.hdf5")
    tmp_output_camera_look_at_positions_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_camera_look_at_positions.hdf5")
    tmp_output_camera_orientations_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_camera_orientations.hdf5")
    tmp_output_intersection_distances_hdf5_file = os.path.join(
        tmp_dir, "_tmp_output_intersection_distances.hdf5")
    tmp_output_prim_ids_hdf5_file = os.path.join(tmp_dir,
                                                 "_tmp_output_prim_ids.hdf5")

    fov_y = 2.0 * arctan(n_height_pixels * tan(n_fov_x / 2) / n_width_pixels)

    uv_min = -1.0
    uv_max = 1.0
    half_du = 0.5 * (uv_max - uv_min) / n_width_pixels
    half_dv = 0.5 * (uv_max - uv_min) / n_height_pixels

    u, v = meshgrid(
        linspace(uv_min + half_du, uv_max - half_du, n_width_pixels),
        linspace(uv_min + half_dv, uv_max - half_dv, n_height_pixels)[::-1])

    ray_offset_x = u * tan(n_fov_x / 2.0)
    ray_offset_y = v * tan(fov_y / 2.0)
    ray_offset_z = -ones_like(ray_offset_x)

    rays_cam = dstack((ray_offset_x, ray_offset_y, ray_offset_z))
    V_cam = matrix(rays_cam.reshape(-1, 3)).T

    half_dx = 0.5
    half_dy = 0.5
    pixel_center = array([(n_width_pixels + 1) / 2.0,
                          (n_height_pixels + 1) / 2.0])
    pixel_x, pixel_y = meshgrid(
        linspace(half_dx, n_width_pixels + half_dx, n_width_pixels),
        linspace(half_dy, n_height_pixels + half_dy, n_height_pixels))

    pixels = dstack((pixel_x, pixel_y)).reshape(-1, 2)
    center_to_pixels = pixels - pixel_center
    center_to_pixels_distances = linalg.norm(center_to_pixels, axis=1)

    with h5py.File(tmp_mesh_vertices_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=mesh_vertices)
    with h5py.File(tmp_mesh_faces_vi_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=mesh_faces_vi)
    with h5py.File(tmp_octomap_free_space_min_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=octomap_free_space_min)
    with h5py.File(tmp_octomap_free_space_max_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=octomap_free_space_max)
    with h5py.File(tmp_start_camera_position_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=start_camera_position)
    with h5py.File(tmp_start_camera_orientation_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=start_camera_orientation)
    with h5py.File(tmp_camera_rays_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=V_cam.T)
    with h5py.File(tmp_camera_rays_distances_to_center_hdf5_file, "w") as f:
        f.create_dataset("dataset", data=center_to_pixels_distances)
    with h5py.File(tmp_n_query_half_extent_relative_to_start_hdf5_file,
                   "w") as f:
        f.create_dataset("dataset", data=n_query_half_extent_relative_to_start)
    with h5py.File(tmp_n_query_half_extent_relative_to_current_hdf5_file,
                   "w") as f:
        f.create_dataset("dataset",
                         data=n_query_half_extent_relative_to_current)

    current_source_path = path_utils.get_current_source_file_path(
        frame=inspect.currentframe())
    generate_camera_trajectory_random_walk_bin = os.path.abspath(
        os.path.join(current_source_path, "..", "..", "cpp", "bin",
                     "generate_camera_trajectory_random_walk"))

    cmd = \
        generate_camera_trajectory_random_walk_bin + \
        " --mesh_vertices_file="                           + tmp_mesh_vertices_hdf5_file                           + \
        " --mesh_faces_vi_file="                           + tmp_mesh_faces_vi_hdf5_file                           + \
        " --start_camera_position_file="                   + tmp_start_camera_position_hdf5_file                   + \
        " --start_camera_orientation_file="                + tmp_start_camera_orientation_hdf5_file                + \
        " --camera_rays_file="                             + tmp_camera_rays_hdf5_file                             + \
        " --camera_rays_distances_to_center_file="         + tmp_camera_rays_distances_to_center_hdf5_file         + \
        " --octomap_file="                                 + octomap_file                                          + \
        " --octomap_free_space_min_file="                  + tmp_octomap_free_space_min_hdf5_file                  + \
        " --octomap_free_space_max_file="                  + tmp_octomap_free_space_max_hdf5_file                  + \
        " --n_samples_random_walk="                        + str(n_samples_random_walk)                            + \
        " --n_samples_octomap_query="                      + str(n_samples_octomap_query)                          + \
        " --n_samples_camera_pose_candidates="             + str(n_samples_camera_pose_candidates)                 + \
        " --n_voxel_size="                                 + str(n_voxel_size)                                     + \
        " --n_query_half_extent_relative_to_start_file="   + tmp_n_query_half_extent_relative_to_start_hdf5_file   + \
        " --n_query_half_extent_relative_to_current_file=" + tmp_n_query_half_extent_relative_to_current_hdf5_file + \
        " --output_camera_look_from_positions_file="       + tmp_output_camera_look_from_positions_hdf5_file       + \
        " --output_camera_look_at_positions_file="         + tmp_output_camera_look_at_positions_hdf5_file         + \
        " --output_camera_orientations_file="              + tmp_output_camera_orientations_hdf5_file              + \
        " --output_intersection_distances_file="           + tmp_output_intersection_distances_hdf5_file           + \
        " --output_prim_ids_file="                         + tmp_output_prim_ids_hdf5_file
    # " --silent"
    print("")
    print(cmd)
    print("")
    retval = os.system(cmd)
    assert retval == 0 or retval == 256

    if retval == 256:
        print(
            "[HYPERSIM: GENERATE_CAMERA_TRAJECTORY_RANDOM_WALK] WARNING: generate_camera_trajectory_random_walk DID NOT EXECUTE SUCCESSFULLY. GIVING UP."
        )
        return None, None, None, None, None

    with h5py.File(tmp_output_camera_look_from_positions_hdf5_file, "r") as f:
        camera_look_from_positions = f["dataset"][:]
    with h5py.File(tmp_output_camera_look_at_positions_hdf5_file, "r") as f:
        camera_look_at_positions = f["dataset"][:]
    with h5py.File(tmp_output_camera_orientations_hdf5_file, "r") as f:
        camera_orientations = f["dataset"][:]
    with h5py.File(tmp_output_intersection_distances_hdf5_file, "r") as f:
        intersection_distances = f["dataset"][:]
    with h5py.File(tmp_output_prim_ids_hdf5_file, "r") as f:
        prim_ids = f["dataset"][:]

    intersection_distances = intersection_distances.reshape(
        -1, n_height_pixels, n_width_pixels)
    prim_ids = prim_ids.reshape(-1, n_height_pixels, n_width_pixels)

    for j in range(n_samples_random_walk):
        camera_orientations[j] = matrix(camera_orientations[j]).T.A

    return camera_look_from_positions, camera_look_at_positions, camera_orientations, intersection_distances, prim_ids
Example #11
0
def build_sympy_modules():

    print "flashlight.quadrotor_2d: Constructing sympy expressions..."
    sys_time_begin = time.time()

    # manipulator matrices
    H_expr, C_expr, G_expr, B_expr = construct_manipulator_matrix_expressions()

    # expressions to solve for df_dx and df_du
    q_dot_dot_expr = H_expr.inv() * (B_expr * u_expr -
                                     (C_expr * q_dot_expr + G_expr))
    x_dot_expr = sympy_utils.construct_matrix_from_block_matrix(
        sympy.Matrix([[q_dot_expr], [q_dot_dot_expr]]))
    df_dx_expr = x_dot_expr.jacobian(x_expr)
    df_du_expr = x_dot_expr.jacobian(u_expr)

    # expressions to solve for g_dynamics, given x_current x_next u_current dt_current
    # x_dot_current_expr           = x_dot_expr.subs( dict( zip(x_expr,x_current_expr) + zip(u_expr,u_current_expr) ) )
    # g_dynamics_ti_expr           = x_next_expr - (x_current_expr + x_dot_current_expr*dt_current_expr)
    # dgdynamicsti_dxcurrent_expr  = g_dynamics_ti_expr.jacobian(x_current_expr)
    # dgdynamicsti_dxnext_expr     = g_dynamics_ti_expr.jacobian(x_next_expr)
    # dgdynamicsti_ducurrent_expr  = g_dynamics_ti_expr.jacobian(u_current_expr)
    # dgdynamicsti_ddtcurrent_expr = g_dynamics_ti_expr.diff(dt_current_expr)

    sys_time_end = time.time()
    print "flashlight.quadrotor_2d: Finished constructing sympy expressions (%.03f seconds)." % (
        sys_time_end - sys_time_begin)

    print "flashlight.quadrotor_2d: Building sympy modules..."
    sys_time_begin = time.time()

    current_source_file_path = path_utils.get_current_source_file_path()

    sympy_utils.build_module_autowrap(expr=H_expr,
                                      syms=const_and_x_syms,
                                      module_name="quadrotor_2d_H",
                                      tmp_dir="tmp",
                                      out_dir=current_source_file_path +
                                      "/data/quadrotor_2d",
                                      dummify=True,
                                      build_vectorized=True,
                                      verbose=True,
                                      request_delete_tmp_dir=True)
    sympy_utils.build_module_autowrap(expr=C_expr,
                                      syms=const_and_x_syms,
                                      module_name="quadrotor_2d_C",
                                      tmp_dir="tmp",
                                      out_dir=current_source_file_path +
                                      "/data/quadrotor_2d",
                                      dummify=True,
                                      build_vectorized=True,
                                      verbose=True,
                                      request_delete_tmp_dir=True)
    sympy_utils.build_module_autowrap(expr=G_expr,
                                      syms=const_and_x_syms,
                                      module_name="quadrotor_2d_G",
                                      tmp_dir="tmp",
                                      out_dir=current_source_file_path +
                                      "/data/quadrotor_2d",
                                      dummify=True,
                                      build_vectorized=True,
                                      verbose=True,
                                      request_delete_tmp_dir=True)
    sympy_utils.build_module_autowrap(expr=B_expr,
                                      syms=const_and_x_syms,
                                      module_name="quadrotor_2d_B",
                                      tmp_dir="tmp",
                                      out_dir=current_source_file_path +
                                      "/data/quadrotor_2d",
                                      dummify=True,
                                      build_vectorized=True,
                                      verbose=True,
                                      request_delete_tmp_dir=True)

    sympy_utils.build_module_autowrap(expr=x_dot_expr,
                                      syms=const_and_x_and_u_syms,
                                      module_name="quadrotor_2d_x_dot",
                                      tmp_dir="tmp",
                                      out_dir=current_source_file_path +
                                      "/data/quadrotor_2d",
                                      dummify=True,
                                      build_vectorized=True,
                                      verbose=True,
                                      request_delete_tmp_dir=True)
    sympy_utils.build_module_autowrap(expr=df_dx_expr,
                                      syms=const_and_x_and_u_syms,
                                      module_name="quadrotor_2d_df_dx",
                                      tmp_dir="tmp",
                                      out_dir=current_source_file_path +
                                      "/data/quadrotor_2d",
                                      dummify=True,
                                      build_vectorized=True,
                                      verbose=True,
                                      request_delete_tmp_dir=True)
    sympy_utils.build_module_autowrap(expr=df_du_expr,
                                      syms=const_and_x_and_u_syms,
                                      module_name="quadrotor_2d_df_du",
                                      tmp_dir="tmp",
                                      out_dir=current_source_file_path +
                                      "/data/quadrotor_2d",
                                      dummify=True,
                                      build_vectorized=True,
                                      verbose=True,
                                      request_delete_tmp_dir=True)

    # sympy_utils.build_module_autowrap( expr=g_dynamics_ti_expr,           syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_g_dynamics_ti",           tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_dxcurrent_expr,  syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_dxcurrent",  tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_dxnext_expr,     syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_dxnext",     tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ducurrent_expr,  syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ducurrent",  tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ddtcurrent_expr, syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ddtcurrent", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )

    sys_time_end = time.time()
    print "flashlight.quadrotor_2d: Finished building sympy modules (%.03f seconds)." % (
        sys_time_end - sys_time_begin)
Example #12
0
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_dxnext_expr,     syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_dxnext",     tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ducurrent_expr,  syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ducurrent",  tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ddtcurrent_expr, syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ddtcurrent", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )

    sys_time_end = time.time()
    print "flashlight.quadrotor_2d: Finished building sympy modules (%.03f seconds)." % (
        sys_time_end - sys_time_begin)


if build_sympy_modules_on_import:
    build_sympy_modules()

print "flashlight.quadrotor_2d: Loading sympy modules..."
sys_time_begin = time.time()

current_source_file_path = path_utils.get_current_source_file_path()

H_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap(
    module_name="quadrotor_2d_H",
    path=current_source_file_path + "/data/quadrotor_2d")
C_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap(
    module_name="quadrotor_2d_C",
    path=current_source_file_path + "/data/quadrotor_2d")
G_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap(
    module_name="quadrotor_2d_G",
    path=current_source_file_path + "/data/quadrotor_2d")
B_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap(
    module_name="quadrotor_2d_B",
    path=current_source_file_path + "/data/quadrotor_2d")

x_dot_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap(
Example #13
0
def process_scene(s, args):

    scene_name = s["name"]
    tmp_dir = os.path.join(dataset_scenes_dir, scene_name, "_tmp")
    detail_dir = os.path.join(dataset_scenes_dir, scene_name, "_detail")
    images_dir = os.path.join(dataset_scenes_dir, scene_name, "images")

    metadata_cameras_csv_file = os.path.join(detail_dir,
                                             "metadata_cameras.csv")
    df = pd.read_csv(metadata_cameras_csv_file)

    if args.camera_names is not None:
        cameras = [
            c for c in df.to_records()
            if fnmatch.fnmatch(c["camera_name"], args.camera_names)
        ]
    else:
        cameras = df.to_records()

    for c in cameras:

        camera_name = c["camera_name"]

        print("[HYPERSIM: DATASET_GENERATE_HDF5_FROM_VRIMG] For scene " +
              scene_name + ", generating HDF5 files for camera " +
              camera_name + "...")

        #
        # generate HDF5 files for geometry render
        #

        if args.render_pass is None or args.render_pass == "geometry":

            in_vrimg_files = '"' + os.path.abspath(
                os.path.join(
                    images_dir, in_scene_fileroot + "_" + camera_name +
                    "_geometry", "*.vrimg")) + '"'
            in_camera_trajectory_dir = os.path.abspath(
                os.path.join(detail_dir, camera_name))
            in_metadata_nodes_file = os.path.abspath(
                os.path.join(detail_dir, "metadata_nodes.csv"))
            in_metadata_scene_file = os.path.abspath(
                os.path.join(detail_dir, "metadata_scene.csv"))
            out_hdf5_dir = os.path.abspath(
                os.path.join(
                    images_dir,
                    in_scene_fileroot + "_" + camera_name + "_geometry_hdf5"))
            out_preview_dir = os.path.abspath(
                os.path.join(
                    images_dir, in_scene_fileroot + "_" + camera_name +
                    "_geometry_preview"))
            tmp_dir_ = os.path.abspath(tmp_dir)

            current_source_file_path = path_utils.get_current_source_file_path(
                frame=inspect.currentframe())
            cwd = os.getcwd()
            os.chdir(current_source_file_path)

            cmd = \
                _system_config.python_bin + " generate_hdf5_from_vrimg.py" + \
                " --in_vrimg_files "           + in_vrimg_files           + \
                " --in_camera_trajectory_dir " + in_camera_trajectory_dir + \
                " --in_metadata_nodes_file "   + in_metadata_nodes_file   + \
                " --in_metadata_scene_file "   + in_metadata_scene_file   + \
                " --out_hdf5_dir "             + out_hdf5_dir             + \
                " --out_preview_dir "          + out_preview_dir          + \
                " --tmp_dir "                  + tmp_dir_                 + \
                " --render_pass geometry"
            print("")
            print(cmd)
            print("")
            retval = os.system(cmd)
            assert retval == 0

            os.chdir(cwd)

        #
        # generate HDF5 files for final render
        #

        if args.render_pass is None or args.render_pass == "final":

            in_vrimg_files = '"' + os.path.abspath(
                os.path.join(images_dir, in_scene_fileroot + "_" +
                             camera_name + "_final", "*.vrimg")) + '"'
            out_hdf5_dir = os.path.abspath(
                os.path.join(
                    images_dir,
                    in_scene_fileroot + "_" + camera_name + "_final_hdf5"))
            out_preview_dir = os.path.abspath(
                os.path.join(
                    images_dir,
                    in_scene_fileroot + "_" + camera_name + "_final_preview"))
            tmp_dir_ = os.path.abspath(tmp_dir)

            if args.denoise:
                denoise_arg = " --denoise"
            else:
                denoise_arg = ""

            current_source_file_path = path_utils.get_current_source_file_path(
                frame=inspect.currentframe())
            cwd = os.getcwd()
            os.chdir(current_source_file_path)

            cmd = \
                _system_config.python_bin + " generate_hdf5_from_vrimg.py" + \
                " --in_vrimg_files "   + in_vrimg_files  + \
                " --out_hdf5_dir "     + out_hdf5_dir    + \
                " --out_preview_dir "  + out_preview_dir + \
                " --tmp_dir "          + tmp_dir_        + \
                " --render_pass final" + \
                denoise_arg
            print("")
            print(cmd)
            print("")
            retval = os.system(cmd)
            assert retval == 0

            os.chdir(cwd)
Example #14
0
if args.scene_names is not None:
    scenes = [ s for s in _dataset_config.scenes if fnmatch.fnmatch(s["name"], args.scene_names) ]
else:
    scenes = _dataset_config.scenes



# NOTE: parameters need to match _deadline_post_task_script.py
hypersim_platform_when_submitting_key    = "ExtraInfo0"
hypersim_dataset_dir_when_submitting_key = "ExtraInfo1"
hypersim_scene_name_key                  = "ExtraInfo2"
hypersim_camera_name_key                 = "ExtraInfo3"
hypersim_render_pass_key                 = "ExtraInfo4"
hypersim_output_file_root_key            = "ExtraInfo5"
hypersim_output_file_ext_key             = "ExtraInfo6"
hypersim_post_task_script                = os.path.join(path_utils.get_current_source_file_path(frame=inspect.currentframe()), _system_config.cloud_post_task_script)

if args.render_pass == "geometry": output_file_ext = "vrimg" 
if args.render_pass == "pre":      output_file_ext = "jpg"
if args.render_pass == "final":    output_file_ext = "vrimg"

output_file_root = "frame"
output_file      = output_file_root + "." + output_file_ext



deadline_con = Deadline.DeadlineConnect.DeadlineCon(_system_config.cloud_server_hostname, _system_config.cloud_server_port)
assert deadline_con.Repository.GetDeadlineVersion().startswith("v")


    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_dxnext_expr,     syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_dxnext",     tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ducurrent_expr,  syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ducurrent",  tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )
    # sympy_utils.build_module_autowrap( expr=dgdynamicsti_ddtcurrent_expr, syms=const_and_xcurrent_and_xnext_and_ucurrent_and_dtcurrent_syms, module_name="quadrotor2d_dgdynamicsti_ddtcurrent", tmp_dir="tmp", out_dir=current_source_file_path+"/data/quadrotor2d", build_vectorized=True, verbose=True, request_delete_tmp_dir=True )

    sys_time_end = time.time()
    print "flashlight.quadrotor_2d: Finished building sympy modules (%.03f seconds)." % (sys_time_end - sys_time_begin)



if build_sympy_modules_on_import:
    build_sympy_modules()

print "flashlight.quadrotor_2d: Loading sympy modules..."
sys_time_begin = time.time()

current_source_file_path = path_utils.get_current_source_file_path()

H_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor_2d_H", path=current_source_file_path+"/data/quadrotor_2d" )
C_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor_2d_C", path=current_source_file_path+"/data/quadrotor_2d" )
G_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor_2d_G", path=current_source_file_path+"/data/quadrotor_2d" )
B_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor_2d_B", path=current_source_file_path+"/data/quadrotor_2d" )

x_dot_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor_2d_x_dot", path=current_source_file_path+"/data/quadrotor_2d" )
df_dx_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor_2d_df_dx", path=current_source_file_path+"/data/quadrotor_2d" )
df_du_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor_2d_df_du", path=current_source_file_path+"/data/quadrotor_2d" )

# g_dynamics_ti_autowrap           = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor2d_g_dynamics_ti",           path=current_source_file_path+"/data/quadrotor2d" )
# dgdynamicsti_dxcurrent_autowrap  = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor2d_dgdynamicsti_dxcurrent",  path=current_source_file_path+"/data/quadrotor2d" )
# dgdynamicsti_dxnext_autowrap     = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor2d_dgdynamicsti_dxnext",     path=current_source_file_path+"/data/quadrotor2d" )
# dgdynamicsti_ducurrent_autowrap  = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor2d_dgdynamicsti_ducurrent",  path=current_source_file_path+"/data/quadrotor2d" )
# dgdynamicsti_ddtcurrent_autowrap = sympy_utils.import_anon_func_from_from_module_autowrap( module_name="quadrotor2d_dgdynamicsti_ddtcurrent", path=current_source_file_path+"/data/quadrotor2d" )
Example #16
0
            "VRaySSS2.G",
            "VRaySSS2.B",
            "VRaySelfIllumination.R",
            "VRaySelfIllumination.G",
            "VRaySelfIllumination.B",
            "VRayCaustics.R",
            "VRayCaustics.G",
            "VRayCaustics.B",
            "VRayAtmosphere.R",
            "VRayAtmosphere.G",
            "VRayAtmosphere.B",
            "VRayBackground.R",
            "VRayBackground.G",
            "VRayBackground.B" ]

    current_source_path            = path_utils.get_current_source_file_path(frame=inspect.currentframe())
    generate_hdf5_from_exr_bin     = os.path.abspath(os.path.join(current_source_path, "..", "..", "cpp", "bin", "generate_hdf5_from_exr"))
    input_file                     = os.path.join(args.tmp_dir, "_tmp_frame.exr")
    output_file                    = os.path.join(args.tmp_dir, "_tmp_frame")
    output_channels_whitelist_args = " --o " + " --o ".join(output_channels_whitelist)

    cmd = generate_hdf5_from_exr_bin + \
        " --input_file "  + input_file  + \
        " --output_file " + output_file + \
        output_channels_whitelist_args
    print("")
    print(cmd)
    print("")
    retval = os.system(cmd)
    assert retval == 0
def process_scene(s, args):

    scene_name = s["name"]
    detail_dir = os.path.join(dataset_scenes_dir, scene_name, "_detail")

    metadata_cameras_csv_file = os.path.join(detail_dir,
                                             "metadata_cameras.csv")
    df = pd.read_csv(metadata_cameras_csv_file)

    if args.camera_names is not None:
        cameras = [
            c for c in df.to_records()
            if fnmatch.fnmatch(c["camera_name"], args.camera_names)
        ]
    else:
        cameras = df.to_records()

    for c in cameras:

        camera_name = c["camera_name"]

        print(
            "[HYPERSIM: DATASET_GENERATE_IMAGES_SEMANTIC_SEGMENTATION] For scene "
            + scene_name +
            ", generating semantic instance segmentation images for camera " +
            camera_name + "...")

        scene_dir = os.path.abspath(
            os.path.join(dataset_scenes_dir, scene_name))
        segmentation_type = "semantic_instance"

        current_source_file_path = path_utils.get_current_source_file_path(
            frame=inspect.currentframe())
        cwd = os.getcwd()
        os.chdir(current_source_file_path)

        cmd = \
            _system_config.python_bin + " scene_generate_images_semantic_segmentation.py" + \
            " --scene_dir "         + scene_dir  + \
            " --camera_name "       + camera_name + \
            " --segmentation_type " + segmentation_type
        print("")
        print(cmd)
        print("")
        retval = os.system(cmd)
        assert retval == 0

        os.chdir(cwd)

        print(
            "[HYPERSIM: DATASET_GENERATE_IMAGES_SEMANTIC_SEGMENTATION] For scene "
            + scene_name +
            ", generating semantic segmentation images for camera " +
            camera_name + "...")

        scene_dir = os.path.abspath(
            os.path.join(dataset_scenes_dir, scene_name))
        segmentation_type = "semantic"

        current_source_file_path = path_utils.get_current_source_file_path(
            frame=inspect.currentframe())
        cwd = os.getcwd()
        os.chdir(current_source_file_path)

        cmd = \
            _system_config.python_bin + " scene_generate_images_semantic_segmentation.py" + \
            " --scene_dir "         + scene_dir  + \
            " --camera_name "       + camera_name + \
            " --segmentation_type " + segmentation_type
        print("")
        print(cmd)
        print("")
        retval = os.system(cmd)
        assert retval == 0

        os.chdir(cwd)