Ejemplo n.º 1
0
def main(save_main_dir, pixel_dim, clip, num_random, plane):
    #Setup
    app = inviwopy.app
    network = app.network
    cam = network.EntryExitPoints.camera
    cam.nearPlane = 6.0
    cam.farPlane = 1000.0
    canvases = inviwopy.app.network.canvases
    for canvas in canvases:
        canvas.inputSize.dimensions.value = ivec2(pixel_dim, pixel_dim)
    inviwo_utils.update()
    if not os.path.isdir(save_main_dir):
        pathlib.Path(save_main_dir).mkdir(parents=True, exist_ok=True)

    #Save a number of random light fields
    random_lfs = create_random_lf_cameras(num_random, (180, 35),
                                          1,
                                          interspatial_distance=0.5,
                                          look_up=vec3(0, 1, 0))

    for lf in random_lfs:
        if clip:
            _, clip_type = random_clip_lf(network, lf)
        elif plane:
            random_plane_clip(network, lf)
        save_lf(lf, save_main_dir)
        if clip:
            restore_clip(network, clip_type)
def main(pixel_dim, clip, num_random, plane):
    #Setup
    app = inviwopy.app
    network = app.network
    cam = network.EntryExitPoints.camera
    cam.nearPlane = 6.0
    cam.farPlane = 1000.0
    canvases = inviwopy.app.network.canvases
    for canvas in canvases:
        canvas.inputSize.dimensions.value = ivec2(pixel_dim, pixel_dim)
    inviwo_utils.update()

    random_lfs = create_random_lf_cameras(
                     num_random,
                     (180, 35), 1,
                     interspatial_distance=0.5,
                     look_up = vec3(0, 1, 0))

    time_accumulator = (0.0, 0.0, 0.0)
    for lf in random_lfs:
        if clip:
            _, clip_type = random_clip_lf(network, lf)
        elif plane:
            random_plane_clip(network, lf)
        time_taken = lf.view_array(cam, save=False, should_time=True)
        time_accumulator = welford.update(
            time_accumulator, time_taken)
        if clip:
            restore_clip(network, clip_type)
    mean, variance, _ = welford.finalize(time_accumulator)
    print("Time taken per grid, average {:4f}, std_dev {:4f}".format(
        mean, math.sqrt(variance)))
Ejemplo n.º 3
0
def capture_lf_samples(hdf5_file, set_type, config, network, count):
    spatial_rows = config["spatial_rows"]
    spatial_cols = config["spatial_cols"]

    colour = hdf5_file[set_type]
    random_cams = []
    for _ in range(config["num_samples"][set_type]):
        radii = (config["max_look_from"], config["min_look_from"])
        random_cam = create_random_camera(
                        radii,
                        max_look_to_origin=0,
                        look_up=config["look_up"],
                        random_look_up=True)
        random_cams.append(random_cam)
    
    for camera in random_cams:
        if config["clip"]:
            _, clip_type = random_clip_look_from(network, camera[0])
        elif config["plane"]:
            random_plane_clip_cam(network, camera)
        save_looking_to_hdf5_group(
            sample_index=count[set_type],
            h5_canvas_list=[(colour, "LF", "Warp")],
            camera=camera, config=config)
        count[set_type] += 1
        if config["clip"]:
            restore_clip(network, clip_type)
        elif config["plane"]:
            mesh_clip = network.MeshClipping
            mesh_clip.getPropertyByIdentifier(
                "clippingEnabled").value = False
    return count