Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[esp/scene] Added support of object's centers and bounding boxes to Gibson semantic scenes #407

Merged
merged 8 commits into from
Jan 18, 2020

Conversation

mathfac
Copy link
Contributor

@mathfac mathfac commented Dec 28, 2019

Motivation and Context

To leverage 3dscenegraph semantic annotation spatial information added support of object's bounding boxes to Gibson semantic scenes. Related to issue #374 and depends on PR #406.

How Has This Been Tested

Added the integration test and run it locally with *.scn data:

Running main() from /private/home/maksymets/habitat-sim/src/deps/googletest/googletest/src/gtest_main.cc
[==========] Running 2 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 1 test from GibsonSceneTest
[ RUN      ] GibsonSceneTest.Basic
[       OK ] GibsonSceneTest.Basic (2 ms)
[----------] 1 test from GibsonSceneTest (2 ms total)

[----------] 1 test from GibsonSemanticSimTest
[ RUN      ] GibsonSemanticSimTest.Basic
[       OK ] GibsonSemanticSimTest.Basic (5451 ms)
[----------] 1 test from GibsonSemanticSimTest (5451 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 2 test cases ran. (5453 ms total)
[  PASSED  ] 2 tests.

Types of changes

  • New feature (non-breaking change which adds functionality)

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Dec 28, 2019
@mathfac mathfac changed the title [esp/scene] Added support of object's bounding boxes to Gibson semantic scenes [esp/scene] Added support of object's centers and bounding boxes to Gibson semantic scenes Dec 28, 2019
Copy link
Contributor

@aclegg3 aclegg3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Minor comment on placement of json parsing function.

src/esp/scene/GibsonSemanticScene.cpp Outdated Show resolved Hide resolved
@@ -57,6 +57,10 @@ void Simulator::reconfigure(const SimulatorConfiguration& cfg) {
houseFilename = cfg.scene.filepaths.at("house");
}

if (!io::exists(houseFilename)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid this by adding a "house" entry to your configuration in cfg.scene.filepaths (see line 56)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, missed that logic.

@msbaines
Copy link
Contributor

The .obj mesh used for main gibson (what 3Dscenegraph is built from) has a rotated coordinate system when compared to the gibson gltf meshes we are using for rgb in Habitat. My utility rotates the coordinate system to match habitat and outputs to .ply semantic mesh. I transformed the bounding box info from the 3Dscenegraph .npz dataset in the same way. My goal was to have a consistent coordinated system. I verified the semantic meshes using the mesh highlighting logic we have in WebGL but did not have time before holidays to verify the bounding boxes were correct.

We have coordinate flipping logic in Asset.cpp that may be relevant here:

AssetInfo AssetInfo::fromPath(const std::string& path) {
  using Corrade::Utility::String::endsWith;
  AssetInfo info{AssetType::UNKNOWN, path};

  if (endsWith(path, "_semantic.ply")) {
    info.type = AssetType::INSTANCE_MESH;
  } else if (endsWith(path, "mesh.ply")) {
    info.type = AssetType::FRL_PTEX_MESH;
    info.frame = {quatf::FromTwoVectors(geo::ESP_GRAVITY, -vec3f::UnitZ())};
  } else if (endsWith(path, "house.json")) {
    info.type = AssetType::SUNCG_SCENE;
  } else if (endsWith(path, ".glb")) {
    // assumes MP3D glb with gravity = -Z
    info.type = AssetType::MP3D_MESH;
    // Create a coordinate for the mesh by rotating the default ESP
    // coordinate frame to -Z gravity
    info.frame = {quatf::FromTwoVectors(geo::ESP_GRAVITY, -vec3f::UnitZ())};
  }

  return info;
}

I have not studied the above code so don't know exactly what it does.

@codecov-io
Copy link

codecov-io commented Jan 17, 2020

Codecov Report

Merging #407 into master will increase coverage by 1.37%.
The diff coverage is 95.54%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #407      +/-   ##
=========================================
+ Coverage   56.02%   57.4%   +1.37%     
=========================================
  Files         171     175       +4     
  Lines        7994    8170     +176     
  Branches       84      84              
=========================================
+ Hits         4479    4690     +211     
+ Misses       3515    3480      -35
Flag Coverage Δ
#CPP 53.44% <89.32%> (+0.95%) ⬆️
#JavaScript 10% <ø> (ø) ⬆️
#Python 78.82% <100%> (+1.4%) ⬆️
Impacted Files Coverage Δ
src/esp/assets/GltfMeshData.h 60% <ø> (ø) ⬆️
src/esp/assets/CollisionMeshData.h 100% <ø> (ø) ⬆️
src/esp/scene/SemanticScene.h 16.32% <ø> (ø) ⬆️
src/esp/bindings/GfxBindings.cpp 93.65% <ø> (-0.2%) ⬇️
src/esp/assets/ResourceManager.h 100% <ø> (ø) ⬆️
src/esp/assets/MeshMetaData.h 81.81% <ø> (ø) ⬆️
src/esp/assets/BaseMesh.h 57.14% <ø> (ø) ⬆️
src/esp/physics/PhysicsManager.h 51.85% <ø> (ø) ⬆️
src/esp/scene/Mp3dSemanticScene.cpp 0.85% <0%> (ø) ⬆️
src/esp/scene/test/GibsonSceneTest.cpp 60.6% <0%> (-1.16%) ⬇️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c79a854...1ec7f68. Read the comment docs.

@@ -19,6 +19,18 @@ namespace scene {

constexpr int kMaxIds = 10000; /* We shouldn't every need more than this. */

namespace {
vec3f jsonToVec3f(const esp::io::JsonGenericValue& jsonObject) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed?

// TODO(msb) add support for aabb

const auto& jsonCenter = jsonObject["location"];
if (!jsonCenter.IsNull()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code might be simpler if you checked center AND size at the top.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to create OBB only if at least center is available, while size can be optional.

src/esp/gfx/Simulator.cpp Outdated Show resolved Hide resolved
@@ -7,6 +7,7 @@
#include <cstdint>
#define RAPIDJSON_NO_INT64DEFINE
#include <rapidjson/document.h>
#include "esp/core/esp.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this include needed?

@@ -53,6 +53,9 @@ void Simulator::reconfigure(const SimulatorConfiguration& cfg) {
}

std::string houseFilename = io::changeExtension(sceneFilename, ".house");
if (!io::exists(houseFilename)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed? You can avoid this by adding a "house" entry to your configuration in cfg.scene.filepaths

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msbaines by default, we are not filling a "house" entry in cfg.scene.filepaths. To support same behavior for `".house" (line 55) and ".scn" that make sense to leave it. Otherwise, wider refactoring needed and there will be no that seamless experience loading MP3D with semantic scenes.

Copy link
Contributor

@msbaines msbaines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compile issue and one nit. Otherwise, LGTM.

@@ -26,6 +27,9 @@ JsonDocument parseJsonString(const std::string& jsonString);
//! Return string representation of given JsonDocument
std::string jsonToString(const JsonDocument& d);

//! Return Vec3f coordinates representation of given JsonObject of array type
esp::vec3f jsonToVec3f(const JsonGenericValue& jsonArray);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you need to include esp/core/esp.h for esp::vec3f

scene::SemanticScene::loadGibsonHouse(
houseFilename, *semanticScene_,
// Default World rotation for Gibson semantic data
quatf::FromTwoVectors(geo::ESP_GRAVITY, -vec3f::UnitZ()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mp3d does this as a default argument in the header file. Not sure which is better but we should try to be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msbaines, that's great suggestion, thank you!

@mathfac mathfac merged commit a008cde into master Jan 18, 2020
@mathfac mathfac deleted the obb_gibson_support branch January 18, 2020 23:10
eundersander pushed a commit to eundersander/habitat-sim that referenced this pull request Aug 6, 2020
…arch#407)

Fixed path to data directory for DDPPO objectnav config
Ram81 pushed a commit to Ram81/habitat-web-sim that referenced this pull request Dec 10, 2020
…ibson semantic scenes (facebookresearch#407)

To leverage 3dscenegraph semantic annotation spatial information added support of object's bounding boxes to Gibson semantic scenes. Related to issue facebookresearch#374 and depends on PR facebookresearch#406.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants