Skip to content

Completing Our Plex

We now have

  • Two components
  • A spatial constraint connecting them
  • A temporal constraint syncing them

Completed plex

We now have a complete Plex: a virtual, fully descriptive copy of our system that can be used throughout the Tangram Vision Platform. We're ready to write it out to JSON.

With the Rust API, we can use the PlexBuilder. This processes the components and constraints, validates the data, and constructs the Plex.

In other languages, we will rely on the generated and validated JSON.

let mut builder = PlexBuilder::new();
builder.add_component(camera_a)?.add_component(camera_b)?;
builder.add_spatial_constraint(space)?;
builder.add_temporal_constraint(time)?;
let plex = builder.build();

// Generate our Plex JSON
let json_string = serde_json::to_string(&plex).unwrap();
println!("{}", json_string);
components = [camera_a, camera_b]
creation_timestamp = time.time()
new_plex = plex.Plex(components, creation_timestamp, [spatial_constraint], [
    temporal_constraint], uuid.uuid4())

# Clean the empty and None values out of the final dictionary.
# See generate_plex.py in Tangram Vision Basic for example code.
formatted_plex_dict = clean_nones(plex.plex_to_dict(new_plex))

# Generate our Plex JSON
plex_file = open("plexpy.json", "w")
plex_file.write(json.dumps(formatted_plex_dict))
std::vector<tangviz::Component> components{camera_a, camera_b};
double creation_timestamp = time(NULL);
tangviz::Plex plex{
    components, creation_timestamp,
    std::vector<tangviz::SpatialConstraint>{spatial_constraint},
    std::vector<tangviz::TemporalConstraint>{temporal_constraint},
    uuids::to_string<char>(generate_uuid_v4())};

nlohmann::json j;
nlohmann::to_json(j, plex);

// Clean the empty and None values out of the final dictionary.
// See generate_plex.cpp in Tangram Vision Basic for example code.
recurseAndFilterNullValues(j);

// Generate the plex file into our build folder
std::ofstream plex_file;
plex_file.open("plexcpp.json");
plex_file << j.dump();
plex_file.close();

Next Steps

There's a lot more to a Plex! Get to know them better, as well as other core concepts in the Tangram Vision Platform, here in the docs.

Core Concepts

If you're eager to start calibrating, don't let us stop you! Check out TVCal.

TVCal