Giter Club home page Giter Club logo

mixedreality-sceneunderstanding-samples's Introduction

page_type name description languages products
sample
Scene Understanding samples for Unity
A Unity-based sample application that showcases Scene Understanding on HoloLens 2.
csharp
windows-mixed-reality
hololens

Microsoft.MixedReality.SceneUnderstanding.Samples - UnitySample

License

Supported Unity versions Built with XR configuration
Unity 2020.3.12f1 Windows XR

A Unity-based sample application that showcases Scene Understanding on HoloLens 2. When this sample is deployed on a HoloLens, it will show the virtual representation of your real environment. For PC deployment, the sample will load a serialized scene (included under Assets\SceneUnderstanding\StandardAssets\SUScenes) and display it. A help menu is presented on launch, which provides information about all the input commands available in the application.

To learn more about Scene Understanding, visit our Scene Understanding and Scene Understanding SDK documentation.

Contents

File/folder Description
Assets Unity assets, scenes, prefabs, and scripts.
Packages Project manifest and packages list.
ProjectSettings Unity asset setting files.
UIElementsSchema UIElements schema files from the Unity editor.
.gitignore Define what to ignore at commit time.
LICENSE The license for the sample.
README.md This README file.

Prerequisites

  • Unity 2020.3.12f1 or higher
  • Up-to-date version of Unity Hub
  • Visual Studio 2017 or 2019 with Universal Windows Platform components
  • Windows SDK version 10.0.18362.0 or higher

Setup

  1. Clone or download this sample repository.
  2. Open Unity Hub, select 'Add' and choose the project folder where you extracted the cloned sample.
  3. After the project loads, navigate to Windows > Package Manager and check that you have the required packages installed:
    • Mixed Reality Scene Understanding
    • Mixed Reality WinRT Projections
  4. If they're missing, download them using the Mixed Reality Feature Tool

Running the sample

Before trying to build the project, go to File > Build Settings and make sure all samples scenes in the SceneUnderstanding/Examples folder appear in the list.

[!IMPORTANT] The Home-Examples scene is not a SceneUnderstanding Scene per se, but rather a Menu Scene from which you can load the other example scenes. You can load any of the other example scenes using voice commands.

Running on HoloLens 2

To run this sample on a HoloLens 2:

  1. Open the SceneUnderstanding Sample Scenes under Assets\SceneUnderstanding\Examples - Scenes are in the Placement, NavMesh and Understanding folders
  2. Select the SceneUnderstandingManager game object and make sure that Query Scene From Device is selected on the SceneUnderstandingManager Component in all Scenes
  3. Go to File > Build Settings and select Build > UWP. Once the build completes successfully, a log indicating this will show up in the output console.
  4. Navigate to the UWP folder under root and open 'Scene Understanding.sln' in Visual Studio.
  5. Right-click on the 'Scene Understanding (Universal Windows)' project and click on 'Publish' --> 'Create App Packages'.
  6. Run through the wizard and wait for building and packaging to complete.
  7. The built app package should be at UWP\AppPackages\Scene Understanding\Scene Understanding_\Scene Understanding_.[appx|msix|appxbundle|msixbundle]
  8. Deploy the package to a HoloLens 2. Ensure you build your application using ARM64, see the topic Unity 2019.3 and HoloLens for further details.
  9. Launch the 'Scene Understanding' app from the 'All Apps' list on the HoloLens 2!

Running on PC

To run this sample on a PC:

  1. Open the SceneUnderstanding Sample Scenes under Assets\SceneUnderstanding\Examples - Scenes are in the Placement, NavMesh and Understanding folders
  2. Select the SceneUnderstandingManager game object and uncheck the Query Scene From Device checkbox on the SceneUnderstandingManager Component
  3. Ensure SU Serialized Scene Paths on the Scene Understanding component is referring to a serialized Scene Understanding scene, examples scenes are provided under the examples folder
  4. Click Play in the Editor!

Common Issues - Troubleshooting

Problem:

Multiple errors occur in SceneUnderstandingManager.cs
Line 571.
System.Numerics.Matrix4x4 converted4x4LocationMatrix = ConvertRightHandedMatrix4x4ToLeftHanded(suObject.GetLocationAsMatrix());
error CS7069: Reference to type 'Matrix4x4' claims it is defined in 'System.Numerics', but it could not be found

Solution:

  • Go to Build Settings > Player Settings > Other Settings > Api Compatibility Level and select .Net 4.x
  • This setting might revert when upgrading Unity versions

Additional Notes

[!NOTE] When running on your Hololens, all the interactive commands are voice commands. You're require to speak to interact with the scene when running on Hololens. Say Scene Objects Wireframe, Load NavMesh, Toggle Auto Refresh and so on.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

mixedreality-sceneunderstanding-samples's People

Contributors

aheaney avatar hferrone avatar jorgonz avatar microsoft-github-policy-service[bot] avatar mukapasi-ms avatar robertyoung2 avatar sceneunderstanding-microsoft avatar szymonsps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mixedreality-sceneunderstanding-samples's Issues

crash on launch when built and deployed directly to HoloLens 2 using Visual Studio 2019

I am trying to deploy and test the updated SceneUnderstanding-Samples release on HoloLens 2, OS 20348.1438. The earlier (prior to August 10 2021) example code ran on the HoloLens 2 just fine, but now I am experiencing an application crash on launch. The app gets as far as showing the generic scene object preview that displays during load, but then shuts down.

I should mention that I am not creating an app package as described in the README, but am building and deploying directly to the HoloLens 2 (with Developer Mode turned on) from Visual Studio 2019. Not sure whether that should make any difference. Otherwise I believe I'm following all the instructions correctly.

Attached is a screenshot of the error being generated at the point when the app crashes, which I got by running in debug mode in Visual Studio. If I select Continue from the Visual Studio debug menu, the application starts and seems to run correctly.
2021-12-01_SUSamples_debug-1
I'm fairly new to debugging with the HoloLens, so if there is additional output or logging I need to provide, let me know.

Using SceneUnderstandingManager in Unity 2020.3 Project

I'm working on a project built using the following tools:
OS: Windows 10
Unity version: 2020.3.2f1
VIsual Studio Community version: 2019[16.10.4]

My work is for an existing project that I'm contributing some Scene Understanding capabilities to, and it is not possible to downgrade to an earlier version of Unity.

I'm relatively new to Unity, MRTK and HoloLens development, and was hoping to use the sample code in this repo as a springboard. Specifically, I've added SceneUnderstandingManager.cs to the project and want to modify it to periodically save Scene Object OBJs to storage on the HoloLens; the OBJs have to be correctly aligned to the coordinate system being used by the project. In Unity, I get the error:
The type or namespace name 'WorldAnchor' does not exist in the namespace 'UnityEngine.XR.WSA' (are you missing an assembly reference?)
on compiling the project when this script is included. However, if I comment out the reference to WorldAnchor (lines 599-604) it compiles just fine.

These are the questions I have:

  1. Is there a timeline for getting these samples updated to work with Unity 2020?
  2. If not, is there any guidance on how to replace the lines I commented out?
  3. Should I be using DemoSceneUnderstandingController.cs as base code instead? This Scene Understanding observer documentation makes it seem like the MRTK example is more current, but the Scene Understanding SDK Overview brings me here (via the deprecated version).

x64 build results in -> DLLNotFoundException: Unable to Load DLL 'Microsoft.MixedReality.SceneUnderstanding.dll': The specified module could not be found.

This is NOT the same as this issue: https://github.com/microsoft/MixedReality-SceneUnderstanding-Samples/issues/28j which has a very similar title.

I am able to build and run my project just fine in the Unity Editor (2021.3.6f1).

However, our project requires the use of the SceneUnderstanding module to run in an 'AppRemoting' x64 build on a desktop.

These are my build settings in Unity (2021.3.6f1)
image

Build settings in Visual Studio (VS Community 2019 Version 16.11.19)
image

The Visual Studio build works just fine! No errors, however, when I attempt to run it. I get the following error:

image

I expected it to be compatible with a desktop build if it could build in Unity and run just fine?

Here's what I have done to attempt to fix it

copied the file '\myProject\Library\PackageCache\com.microsoft.mixedreality.sceneunderstanding@7bfd3a8ea18c\Editor\Plugins\x64\Microsoft.MixedReality.SceneUnderstanding.dll'

To:
\myProject\build\build\bin\x64\Release\AppX\

When I do this, the SceneUnderstanding.dll is found, but then I get the following error:
image

I will also add that the documentation says its compatible with UWP build: https://learn.microsoft.com/en-us/windows/mixed-reality/develop/unity/scene-understanding-sdk#where-do-i-get-the-sdk

Any help is greatly appreciated :D Is there a way around this?

Impossible To use the application on real Environment while running on Hololens2

It is for different days that i try to run the application on Hololens but simply it does not work.
I work in Unity 2019.4.11.f1 with MRTK 2.5.4.
I use Built-in XR with the box Virtual Reality Supported checked.
In Virtual Reality SDKs i have Winodows Mixed Reality correctly configured.
I Have configured the sample scene with Mixed Reality Toolkit and imported the sample scene Nav Mesh, Understanding and Placement as Described in the page.
When i build the application to deploy it oh Hololens i check the box Query Data From Device.
The application is correctly built and deployed on the Hololens but when i launch it I see the first menu where it is asked to load a scene.
I select the desired scene with voice commands but the the app start to glitch, the menu become head locked and simply it does anything. I tried with also the new repository with unity 2020.4 and MRTK 2.7.3. Also there nothing. The app correctly display the second menu with the voice commands. It takes the vocie command inputs because i'm able to toggle the Menu but nothing else.
Please Help.

unable to access files referenced by SUSerializedScenePaths in a Threading.Task in SceneUnderstandingManager

Unity version: 2020.3.2f1
Visual Studio version: 16.10.4
OS: Windows 10

I'm trying to modify the SceneUnderstandingManager code so that in addition to updating the scene geometry, some other processing of the resulting meshes occurs. Specifically, I want to generate OBJ files for particular scene object classes and automatically save them on some user-specified interval.

I've gotten this working on the HoloLens by modifying RetrieveDataContinuously to make a call to SaveObjsToDiskAsync (with the addition of a Thread.Sleep command to add a delay to the retrieval and storage cycle). However, when I test the changes using the Unity player and a serialized Scene on PC, any commands that require accessing the serialized scene contents (which are of type TextAsset and set in the public SUSerializedScenePaths variable) seem to silently fail, and no scene data is ever returned. Using the key command L, which I guess is running on the main Unity thread, saves the OBJs just fine. Moving the call to SaveObjsToDiskAsync from the separate thread to the Unity Update function also succeeds.

Is it expected behavior that referencing SUSerializedScenePaths files from a thread other than the main Unity thread fails? Is there any way to access them outside the main thread? I'm not actually displaying any of the Scene Understanding data, just exporting the geometry for other purposes. There is other data being displayed by Update, though, so I'd rather not add to the load on the main thread if I can avoid it.

Is there a sample for SceneObserver.ComputeWithBoundsAsync

I'm trying to construct a SceneBounds to pass to SceneObserver.ComputeWithBoundsAsync. I'm not sure how to create a Microsoft.MixedReality.SceneUnderstanding.SpatialGraph.SpatialOrientedBox to create the SceneBounds. The struct in the metadata appears to have no public fields. I can try to treat the Microsoft.MixedReality.SceneUnderstanding.SpatialGraph.SpatialOrientedBox as a Windows.Perception.Spatial.SpatialOrientedBox , but the compiler complains that I cannot access the fields due to their protection level. Any help here would be appreciated.

Thanks!

Unity 2020.3 with OpenXR , Scene Understanding and MRTK

Scene Understanding runs in the editor but then i check Query Scene from device and deploy to Emulator or Hololens2
and get the following exceptions.

Exception thrown at 0x00007FF9DD52FDCC (KernelBase.dll) in _RobotUnderstanding.exe: WinRT originate error - 0x8000FFFF : 'You must wait for this frame to be ready via HolographicSpace's WaitForNextFrameReady API before presenting.'.
analog\input\mirage\publicapi\holographicframe.cpp(664)\Windows.Mirage.dll!00007FF9D4C23294: (caller: 00007FF9C26D3F5E) ReturnHr(16) tid(918) 8000FFFF Catastrophic failure
Exception thrown at 0x00007FF9DD52FDCC in _RobotUnderstanding.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x000000D5C9B00B00

OpenXR reprojection settings are not supported; missing OpenXR extension XR_MSFT_composition_layer_reprojection

image

image

'WindowsMREnvironment' does not exist in the namespace 'UnityEngine.XR.WindowsMR'

Good morning, I tried to download the code but it gives me this error.

Assets\SceneUnderstanding\Core\Understanding\Scripts\SceneUnderstandingManager.cs(1360,167): error CS0234: The type or namespace name 'WindowsMREnvironment' does not exist in the namespace 'UnityEngine.XR.WindowsMR' (are you missing an assembly reference?)

How can I solve it?

Error at startup(error CS0104: 'Vector3')

I get error that [Assets\SceneUnderstanding\Core\Understanding\Scripts\SceneUnderstandingManager.cs(683,58): error CS0104: 'Vector3' is an ambiguous reference between 'System.Numerics.Vector3' and 'UnityEngine.Vector3'] when setup this sample.

Sparse Visualization/Solved by Changing Minimum Platform Version

Hi,

First of all thank you very much for providing this sample project!

Recently I tried to build and run this project for HoloLens 2, using Unity 2019.4.25f, Visual Studio 2019 and Windows SDK 10.0.18362.0. When 10.0.18362.0 was selected in the "Minimum Platform Version" in Unity Build>UWP settings, I was able to build the project but when I tested it, there was a visualization problem with the overlays, and the segmentation layers were only visible through several sparse points. When I switched to 10.0.10240.0 in Minimum Platform Version, the problem was gone and I was able to obtain the visualizations similar to the ones shown in the demo video. I am taking this note about my solution in case some other people also encounter a similar problem.

Best,
Ayca

[Question] Mesh Resolution

Hello,
I'm quite new to MRTK Hololens. I was navigated to use Scene Understanding to get higher mesh resolution (microsoft/MixedRealityToolkit-Unity#10354 (comment))
So, what is the highest resolution could I get from SceneUnderstanding? Could it reach 1cm resolution? Could I use Hololens 2 to get 3D Object by scanning an object e.g a small machine, machine part in multiple times (to get a dense point cloud, which is supposed to provide more detail for mesh generation)?

Is it possible to load .obj file from storage localfolder?

The .obj file saved successfully after room scanning in WindowsStorage localfolder. I need to display saved obj file in runtime. But I could not access the hololens localfolder. So I tried another way, I uploaded the file to server. But my problem is I could not load obj file in app. Please give me a solution.

question about function ConvertRightHandedMatrix4x4ToLeftHanded

I dont understand what is this for and how it works..

do i need to study video game math? geometry?

im new at unity development.
are they doing this because right handed coordinate system is used inside the circuits to render..
but unity the software that we use to build apps is a left handed coordinate system?
is that the purpose of this code? and why do the skip matrix.M33?
e.g. they didnt do matrix.M33 = -matrix.M33

`        /// <summary>
        /// Converts a right handed tranformation matrix into a left handed one
        /// </summary>
        /// <param name="matrix"> Matrix to convert </param>
        private System.Numerics.Matrix4x4 ConvertRightHandedMatrix4x4ToLeftHanded(System.Numerics.Matrix4x4 matrix)
        {
            matrix.M13 = -matrix.M13;
            matrix.M23 = -matrix.M23;
            matrix.M43 = -matrix.M43;

            matrix.M31 = -matrix.M31;
            matrix.M32 = -matrix.M32;
            matrix.M34 = -matrix.M34;

            return matrix;
        }
`

OBJs saved by Scene Understanding SDK change coordinate system alignment when HoloLens moves

I am using a time series of scene object OBJs saved to the HoloLens 2 internal storage by the Scene Understanding example code for dynamically building maps of interior spaces. However, while the objects are aligned to one another when they are saved together, groups of objects from different calls to SaveObjsToDiskAsync have different orientations. Presumably this is due to the relative orientation of the headset; if the headset doesn't move, objects remain aligned. See screenshot below for a 3D visualization of two sets of (Wall, Floor, CompletelyInferred) objects created about 2 minutes apart in the same space.

SU_updated_obj_sets_visualized

Is there a reason that having the saved OBJ orientation in 3D space aligned to the HoloLens rather than a fixed coordinate system is desirable? If this behavior is intended, is there any guidance on how to maintain object alignment when the HoloLens is moving? I am not displaying these objects in a Unity scene of any kind, but am automatically offloading the OBJs generated by SaveObjsToDiskAsync for processing and visual rendering on an external compute node. I would like to display a map that grows as the HoloLens wearer moves around but maintains a fixed position and orientation.

Sample app crashes right away on HoloLens 2

I cloned the repo and followed the documentation steps:
https://learn.microsoft.com/en-us/samples/microsoft/mixedreality-sceneunderstanding-samples/microsoftmixedrealitysceneunderstandingsamples---unitysample/

I'm able to build and sideload the app package without issue or error, but it displays an odd image of a room before crashing

I took a video and put it on my YouTube:
https://youtu.be/ZKlBIe1FhJU

Any help is appreciated! I'd love to get this working in my app

Build errors in Unity

Hi.

I'm having problems with the build of this project.
I'm not familiar with Unity, so I might be asking a rudimentary question.

Build Environment

  • Unity2019.4.19f1
  • Visual Studio Community 2019 16.8.5
  • MixedReality-SceneUnderstanding-Samples main branch

Problem
Multiple errors occur in SceneUnderstandingManager.cs
Line 571.
System.Numerics.Matrix4x4 converted4x4LocationMatrix = ConvertRightHandedMatrix4x4ToLeftHanded(suObject.GetLocationAsMatrix());
error CS7069: Reference to type 'Matrix4x4' claims it is defined in 'System.Numerics', but it could not be found

Similar errors have occurred in 11 places.

How can I prevent the error from occurring?

Sample not working when work with MRTK spatial awareness

Hi,

I want to add the occlusion of spatial awareness to this scene understanding sample in order to get a natural experience, but when I imported the MRTK toolkit, enable spatial awareness then add OpenXR spatial mesh observer, I did see occlusion on Hololens2 in the real environment, but all the scene understanding game objects(the quads represent the scene objects) are gone, and no matter how I debug, I can no longer let the results(the quads represent the scene objects) of the scene understanding display in the real scene, this really troubled me. If you know any solutions please tell me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.