Skip to content

Commit

Permalink
-- [Part 1 of 2] Semantic Attributes Metadata : Support for Semantic …
Browse files Browse the repository at this point in the history
…Regions - Add attributes/config support (#2299)

* --initial commit; Add semantic attributes class &SemanticAttributesManager
* --support semantic attributes referencing current semantic desc files
* --add semantic attributes configs and attributes managers tests.
* --support ssd filename and semantic asset filename in semantic attributes
* --map stage semantics into semantic attributes if they exist.; fix tests.
* --expand init handling of semantic attributes to also accept filepath wildcards
* --preserve scene dataset JSON load order
* --stub out semantic attributes init built-from-config code
* --add manager bindings  TODO : need to add template bindings when format has been firmed up.
* --support semantic attributes tag based on scene instance name wildcard
* --improve naming convention for wildcard-based filename lookups
* --set semantic attributes handle tag based on wildcard
* --add retrieval function to managed containers for first matching substring; also adds binding
* --improve semantic attributes retrieval; Added substring-search based retrieval.
* --update load and test to properly add/check for paths
  • Loading branch information
jturner65 authored Jan 22, 2024
1 parent 7819c6f commit a5b0db3
Show file tree
Hide file tree
Showing 31 changed files with 2,227 additions and 414 deletions.
280 changes: 280 additions & 0 deletions data/test_assets/semantic/test_regions.semantic_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
{
"region_annotations": [
{
"name": "bedroom",
"label": "bedroom",
"poly_loop": [
[
-18.876018524169922,
0.0,
-10.983560562133789
],
[
-15.061599731445312,
0.0,
-10.983560562133789
],
[
-15.061599731445312,
0.0,
-8.543549537658691
],
[
-18.876018524169922,
0.0,
-8.543549537658691
]
],
"floor_height": 0.0,
"extrusion_height": 4.0,
"min_bounds": [
-18.876018524169922,
0.0,
-10.983560562133789
],
"max_bounds": [
-15.061599731445312,
4.0,
-8.543549537658691
]
},
{
"name": "kitchen",
"label": "kitchen",
"poly_loop": [
[
-18.876018524169922,
0.0,
-8.393549919128418
],
[
-15.316800117492676,
0.0,
-8.393549919128418
],
[
-18.876018524169922,
0.0,
-5.939759731292725
],
[
-15.316800117492676,
0.0,
-5.939759731292725
]
],
"floor_height": 0.0,
"extrusion_height": 4.0,
"min_bounds": [
-18.876018524169922,
0.0,
-8.393549919128418
],
"max_bounds": [
-15.316800117492676,
4.0,
-5.939759731292725
]
},
{
"name": "living room",
"label": "living room",
"poly_loop": [
[
-18.876018524169922,
0.0,
-5.789760112762451
],
[
-13.965399742126465,
0.0,
-5.789760112762451
],
[
-18.876018524169922,
0.0,
-2.040019989013672
],
[
-13.965399742126465,
0.0,
-2.040019989013672
]
],
"floor_height": 0.0,
"extrusion_height": 4.0,
"min_bounds": [
-18.876018524169922,
0.0,
-5.789760112762451
],
"max_bounds": [
-13.965399742126465,
4.0,
-2.040019989013672
]
},
{
"name": "rec/game",
"label": "rec/game",
"poly_loop": [
[
-15.166800498962402,
0.0,
-8.393549919128418
],
[
-10.796329498291016,
0.0,
-8.393549919128418
],
[
-15.166800498962402,
0.0,
-6.908959865570068
],
[
-13.815400123596191,
0.0,
-6.908959865570068
],
[
-13.815400123596191,
0.0,
-2.040019989013672
],
[
-10.796329498291016,
0.0,
-2.040019989013672
]
],
"floor_height": 0.0,
"extrusion_height": 4.0,
"min_bounds": [
-15.166800498962402,
0.0,
-8.393549919128418
],
"max_bounds": [
-10.796329498291016,
4.0,
-2.040019989013672
]
},
{
"name": "bathroom",
"label": "bathroom",
"poly_loop": [
[
-15.166800498962402,
0.0,
-6.758960247039795
],
[
-13.965399742126465,
0.0,
-6.758960247039795
],
[
-15.166800498962402,
0.0,
-5.939759731292725
],
[
-13.965399742126465,
0.0,
-5.939759731292725
]
],
"floor_height": 0.0,
"extrusion_height": 4.0,
"min_bounds": [
-15.166800498962402,
0.0,
-6.758960247039795
],
"max_bounds": [
-13.965399742126465,
4.0,
-5.939759731292725
]
},
{
"name": "tv",
"label": "tv",
"poly_loop": [
[
-14.911600112915039,
0.0,
-10.983560562133789
],
[
-11.86514949798584,
0.0,
-10.983560562133789
],
[
-14.911600112915039,
0.0,
-8.543549537658691
],
[
-11.86514949798584,
0.0,
-8.543549537658691
]
],
"floor_height": 0.0,
"extrusion_height": 4.0,
"min_bounds": [
-14.911600112915039,
0.0,
-10.983560562133789
],
"max_bounds": [
-11.86514949798584,
4.0,
-8.543549537658691
]
},
{
"name": "bathroom.001",
"label": "bathroom",
"poly_loop": [
[
-11.715149879455566,
0.0,
-10.983560562133789
],
[
-10.796329498291016,
0.0,
-10.983560562133789
],
[
-11.715149879455566,
0.0,
-8.543549537658691
],
[
-10.796329498291016,
0.0,
-8.543549537658691
]
],
"floor_height": 0.0,
"extrusion_height": 4.0,
"min_bounds": [
-11.715149879455566,
0.0,
-10.983560562133789
],
"max_bounds": [
-10.796329498291016,
4.0,
-8.543549537658691
]
}
]
}
22 changes: 22 additions & 0 deletions src/esp/bindings/AttributesManagersBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "esp/metadata/managers/ObjectAttributesManager.h"
#include "esp/metadata/managers/PbrShaderAttributesManager.h"
#include "esp/metadata/managers/PhysicsAttributesManager.h"
#include "esp/metadata/managers/SemanticAttributesManager.h"
#include "esp/metadata/managers/StageAttributesManager.h"

namespace py = pybind11;
Expand All @@ -33,6 +34,7 @@ using Attrs::LightLayoutAttributes;
using Attrs::ObjectAttributes;
using Attrs::PbrShaderAttributes;
using Attrs::PhysicsManagerAttributes;
using Attrs::SemanticAttributes;
using Attrs::StageAttributes;
using esp::core::managedContainers::ManagedObjectAccess;

Expand Down Expand Up @@ -237,6 +239,15 @@ void declareBaseAttributesManager(py::module& m,
"if it does not.")
.c_str(),
"handle"_a)
.def("get_first_matching_template_by_handle",
static_cast<AttribsPtr (MgrClass::*)(const std::string&)>(
&MgrClass::getFirstMatchingObjectOrCopyByHandle),
("This returns a copy of the first " + attrType +
" template containing the passed handle substring if any exist, "
"and NULL "
"if none could be found.")
.c_str(),
"handle_substr"_a)
.def("get_templates_by_handle_substring",
static_cast<std::unordered_map<std::string, AttribsPtr> (
MgrClass::*)(const std::string&, bool)>(
Expand Down Expand Up @@ -472,6 +483,17 @@ void initAttributesManagersBindings(py::module& m) {
R"(Manages PbrShaderAttributess which define PBR shader calculation control values, such as
enabling IBL or specifying direct and indirect lighting balance. Can import .pbr_config.json files.)");

// ==== Semantic Attributes Template manager ====
declareBaseAttributesManager<SemanticAttributes, ManagedObjectAccess::Copy>(
m, "SemanticAttributes", "BaseSemantic");
// NOLINTNEXTLINE(bugprone-unused-raii)
py::class_<SemanticAttributesManager,
AttributesManager<SemanticAttributes, ManagedObjectAccess::Copy>,
SemanticAttributesManager::ptr>(
m, "SemanticAttributesManager",
R"(Manages SemanticAttributes which define semantic mappings and files applicable to a scene instance,
such as semantic screen descriptor files and semantic regions. Can import .semantic_config.json files.)");

} // initAttributesManagersBindings
} // namespace managers
} // namespace metadata
Expand Down
Loading

0 comments on commit a5b0db3

Please sign in to comment.