private IEnumerator _ExportModel(System.Action <int> UpdatePercentage = null, System.Action done = null) { ViveSR_RigidReconstruction.ExportAdaptiveMesh = true; ViveSR_RigidReconstruction.ExportModel(MeshName); int percentage = 0; if (CheckModelLoaded()) { Destroy(collisionMesh); Destroy(texturedMesh); collisionMesh = null; texturedMesh = null; } ViveSR_RigidReconstruction.GetExportProgress(ref percentage); while (percentage < 100) { int error = ViveSR_RigidReconstruction.GetExportProgress(ref percentage); if (error != (int)Error.WORK) { GPUMemoryFull(); break; } if (UpdatePercentage != null) { UpdatePercentage(percentage); } yield return(new WaitForEndOfFrame()); } ViveSR_DualCameraImageCapture.EnableDepthProcess(false); if (done != null) { done(); } }
private IEnumerator _ExportModel(System.Action <int> UpdatePercentage = null, System.Action done = null) { ViveSR_RigidReconstruction.ExportAdaptiveMesh = true; ViveSR_RigidReconstruction.ExportModel(MeshName); int percentage = 0; int lastPercentage = 0; if (CheckModelLoaded()) { Destroy(collisionMesh); Destroy(texturedMesh); collisionMesh = null; texturedMesh = null; } while (percentage < 100) { ViveSR_RigidReconstruction.GetExportProgress(ref percentage); if (UpdatePercentage != null) { UpdatePercentage(percentage); } // wait until saving is really processing then we disable depth if (lastPercentage == 0 && percentage > 0) { ViveSR_DualCameraImageCapture.EnableDepthProcess(false); } lastPercentage = percentage; yield return(new WaitForEndOfFrame()); } if (done != null) { done(); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (!Application.isPlaying) { return; } EditorGUILayout.Separator(); EditorGUILayout.Separator(); GUIStyle style = new GUIStyle(); style.fontStyle = FontStyle.Bold; GUILayout.Label(new GUIContent("[Runtime Command]"), style); EditorGUILayout.Separator(); // start / stop GUILayout.Label(new GUIContent("--Start/Stop--"), style); if (!ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh) { if (GUILayout.Button("Start Reconstruction")) { ViveSR_RigidReconstruction.StartScanning(); } } if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh) { if (GUILayout.Button("Stop Reconstruction")) { ViveSR_RigidReconstruction.StopScanning(); } // live extraction mode EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Live Extraction--"), style); int curMode = (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode; GUILayout.BeginHorizontal(); GUILayout.Label("Display Mode:"); curMode = EditorGUILayout.Popup(curMode, displayMode); GUILayout.EndHorizontal(); bool enableSector = GUILayout.Toggle(ViveSR_RigidReconstructionRenderer.EnableSector, "Enable Sectioned Mesh"); if (enableSector != ViveSR_RigidReconstructionRenderer.EnableSector) { ViveSR_RigidReconstructionRenderer.EnableSector = enableSector; } int sectorGroupNum = EditorGUILayout.IntSlider("Sectioned Mesh Limit", ViveSR_RigidReconstructionRenderer.MaxActiveGO, 50, 500); if (sectorGroupNum != ViveSR_RigidReconstructionRenderer.MaxActiveGO) { ViveSR_RigidReconstructionRenderer.MaxActiveGO = sectorGroupNum; } if (curMode != (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode) { ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode = (ReconstructionDisplayMode)curMode; } // adaptive tunning if (curMode == (int)ReconstructionDisplayMode.ADAPTIVE_MESH) { EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Live Adaptive Mesh Tuning--"), style); DrawAdaptiveParamUI(ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize, ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize, ViveSR_RigidReconstruction.LiveAdaptiveErrorThres); ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize = adaptiveLevel[maxSelectID]; ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize = adaptiveLevel[minSelectID]; ViveSR_RigidReconstruction.LiveAdaptiveErrorThres = errorThres; } } // export EditorGUILayout.Separator(); if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh) { GUILayout.Label(new GUIContent("--Export--"), style); bool exportAdaptive = ViveSR_RigidReconstruction.ExportAdaptiveMesh; ViveSR_RigidReconstruction.ExportAdaptiveMesh = GUILayout.Toggle(exportAdaptive, "Export Adaptive Model"); if (ViveSR_RigidReconstruction.ExportAdaptiveMesh) { // live extraction mode EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Export Adaptive Mesh Tuning--"), style); DrawAdaptiveParamUI(ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize, ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize, ViveSR_RigidReconstruction.ExportAdaptiveErrorThres); ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize = adaptiveLevel[maxSelectID]; ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize = adaptiveLevel[minSelectID]; ViveSR_RigidReconstruction.ExportAdaptiveErrorThres = errorThres; } if (GUILayout.Button("Start Export Model")) { ViveSR_RigidReconstruction.ExportModel("Model"); } } // Scene Understanding // output surrounding objects of interest and their attributes EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Scene Understanding--"), style); if (ViveSR_RigidReconstruction.IsScanning) { bool isSemanticEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding, "Enable Scene Understanding"); if (isSemanticEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding) { ViveSR_SceneUnderstanding.EnableSceneUnderstanding(isSemanticEnabled); } } if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning) { bool isSemanticRefinementEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement, "Enable Scene Understanding Refinement"); if (isSemanticRefinementEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement) { ViveSR_SceneUnderstanding.EnableSceneUnderstandingRefinement(isSemanticRefinementEnabled); } bool isSemanticPreviewEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView, "Enable Preview"); if (isSemanticPreviewEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView) { ViveSR_SceneUnderstanding.EnableSceneUnderstandingView(isSemanticPreviewEnabled); } int index = 0; foreach (bool toggle in SceneObjectToggle) { bool _toggle = GUILayout.Toggle(toggle, "View/Export " + SceneObjectName[index]); if (_toggle != toggle) { SceneObjectToggle[index] = _toggle; switch (SceneObjectName[index]) { case "Bed": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.BED, 5, _toggle); break; case "Ceiling": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.CEILING, 5, _toggle); break; case "Chair": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.CHAIR, 5, _toggle); break; case "Floor": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.FLOOR, 5, _toggle); break; case "Table": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.TABLE, 5, _toggle); break; case "Wall": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig((int)SceneUnderstandingObjectType.WALL, 5, _toggle); break; } } index++; } } if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning) { if (GUILayout.Button("Export SceneObjects (.xml)")) { ViveSR_SceneUnderstanding.ExportSceneUnderstandingInfo(SemanticObjDir); } } if (GUILayout.Button("Load & Show SceneObjects BoundingBox")) { ViveSR_SceneUnderstanding.ImportSceneObjects(ReconsSceneDir + SemanticObjDir); //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.CHAIR); //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.CEILING); //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.FLOOR); //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.WALL); //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.BED); //ViveSR_SceneUnderstanding.GetSemanticBoundingBox(ReconsSceneDir + SemanticObjDir, (int)SceneUnderstandingObjectType.TABLE); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.CHAIR, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.CEILING, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.FLOOR, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.WALL, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.BED, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType((int)SceneUnderstandingObjectType.TABLE, true, false); //ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxWithId((int)SceneUnderstandingObjectType.CHAIR, 0, false, true); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (!Application.isPlaying) { return; } EditorGUILayout.Separator(); EditorGUILayout.Separator(); GUIStyle style = new GUIStyle(); style.fontStyle = FontStyle.Bold; GUILayout.Label(new GUIContent("[Runtime Command]"), style); EditorGUILayout.Separator(); string btnStrEnableReconstructionProcess = ViveSR_RigidReconstruction.ReconstructionProcessing ? "Disable Reconstruction Processing" : "Enable Reconstruction Processing"; if (GUILayout.Button(btnStrEnableReconstructionProcess)) { ViveSR_RigidReconstruction.EnableReconstructionProcess(!ViveSR_RigidReconstruction.ReconstructionProcessing); } if (ViveSR_RigidReconstruction.ReconstructionProcessing) { GUILayout.Label(new GUIContent("[FPS Setting]"), style); SetReconstructionFPS = GUILayout.Toggle(SetReconstructionFPS, "Set reconstruction FPS"); if (SetReconstructionFPS) { GUILayout.Box("Value: " + (int)Mathf.Round(ReconstructionFPS)); float NewReconstructionFPS = GUILayout.HorizontalSlider(ReconstructionFPS, 1.0f, 60.0f); if (NewReconstructionFPS != ReconstructionFPS) { SRWorkModule_API.SetReconstructionMaxFps((int)Mathf.Round(NewReconstructionFPS)); ReconstructionFPS = NewReconstructionFPS; } } // start / stop GUILayout.Label(new GUIContent("--Start/Stop--"), style); if (!ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview || ViveSR_RigidReconstruction.IsScannedMeshPreviewCompleted) { if (GUILayout.Button("Start Reconstruction")) { ViveSR_RigidReconstruction.StartScanning(); } } if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview) { if (GUILayout.Button("Stop Reconstruction")) { ViveSR_RigidReconstruction.StopScanning(); } // live extraction mode EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Live Extraction--"), style); int curMode = (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode; GUILayout.BeginHorizontal(); GUILayout.Label("Display Mode:"); curMode = EditorGUILayout.Popup(curMode, displayMode); GUILayout.EndHorizontal(); bool enableSector = GUILayout.Toggle(ViveSR_RigidReconstructionRenderer.EnableSector, "Enable Sectioned Mesh"); if (enableSector != ViveSR_RigidReconstructionRenderer.EnableSector) { ViveSR_RigidReconstructionRenderer.EnableSector = enableSector; } int sectorGroupNum = EditorGUILayout.IntSlider("Sectioned Mesh Limit", ViveSR_RigidReconstructionRenderer.MaxActiveGO, 50, 500); if (sectorGroupNum != ViveSR_RigidReconstructionRenderer.MaxActiveGO) { ViveSR_RigidReconstructionRenderer.MaxActiveGO = sectorGroupNum; } if (curMode != (int)ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode) { ViveSR_RigidReconstructionRenderer.LiveMeshDisplayMode = (ReconstructionDisplayMode)curMode; } // adaptive tunning if (curMode == (int)ReconstructionDisplayMode.ADAPTIVE_MESH) { EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Live Adaptive Mesh Tuning--"), style); DrawAdaptiveParamUI(ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize, ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize, ViveSR_RigidReconstruction.LiveAdaptiveErrorThres); ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize = adaptiveLevel[maxSelectID]; ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize = adaptiveLevel[minSelectID]; ViveSR_RigidReconstruction.LiveAdaptiveErrorThres = errorThres; } } // export EditorGUILayout.Separator(); if (ViveSR_RigidReconstruction.IsScanning && !ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview) { GUILayout.Label(new GUIContent("--Export--"), style); bool exportAdaptive = ViveSR_RigidReconstruction.ExportAdaptiveMesh; ViveSR_RigidReconstruction.ExportAdaptiveMesh = GUILayout.Toggle(exportAdaptive, "Export Adaptive Model"); if (ViveSR_RigidReconstruction.ExportAdaptiveMesh) { // live extraction mode EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Export Adaptive Mesh Tuning--"), style); DrawAdaptiveParamUI(ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize, ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize, ViveSR_RigidReconstruction.ExportAdaptiveErrorThres); ViveSR_RigidReconstruction.ExportAdaptiveMaxGridSize = adaptiveLevel[maxSelectID]; ViveSR_RigidReconstruction.ExportAdaptiveMinGridSize = adaptiveLevel[minSelectID]; ViveSR_RigidReconstruction.ExportAdaptiveErrorThres = errorThres; } // only support adaptive mesh now if (GUILayout.Button("Preview Scanned Model")) { ViveSR_RigidReconstruction.ExtractModelPreviewData(); } } if (!ViveSR_RigidReconstruction.IsExportingMesh && !ViveSR_RigidReconstruction.IsDuringScannedMeshPreview && (ViveSR_RigidReconstruction.IsScanning != ViveSR_RigidReconstruction.IsScannedMeshPreviewCompleted)) { if (GUILayout.Button("Start Export Model")) { ViveSR_RigidReconstruction.StopScanning(); ViveSR_RigidReconstruction.ExportModel("Model"); } } // Scene Understanding // output surrounding objects of interest and their attributes #region Scene Understanding EditorGUILayout.Separator(); GUILayout.Label(new GUIContent("--Scene Understanding--"), style); if (ViveSR_RigidReconstruction.IsScanning) { bool isSemanticEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding, "Enable Scene Understanding"); if (isSemanticEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding) { ViveSR_SceneUnderstanding.EnableSceneUnderstanding(isSemanticEnabled); } } if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning) { bool isSemanticRefinementEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement, "Enable Scene Understanding Refinement"); if (isSemanticRefinementEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingRefinement) { ViveSR_SceneUnderstanding.EnableSceneUnderstandingRefinement(isSemanticRefinementEnabled); } bool isSemanticPreviewEnabled = GUILayout.Toggle(ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView, "Enable Preview"); if (isSemanticPreviewEnabled != ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView) { ViveSR_SceneUnderstanding.EnableSceneUnderstandingView(isSemanticPreviewEnabled); } int index = 0; foreach (bool toggle in SceneObjectToggle) { bool _toggle = GUILayout.Toggle(toggle, "View/Export " + SceneObjectName[index] + " (" + ObjectColor[index] + ")"); if (_toggle != toggle) { SceneObjectToggle[index] = _toggle; switch (SceneObjectName[index]) { case "Bed": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.BED, 10, _toggle); break; case "Ceiling": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CEILING, 10, _toggle); break; case "Chair": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.CHAIR, 10, _toggle); break; case "Floor": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.FLOOR, 10, _toggle); break; case "Table": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.TABLE, 10, _toggle); break; case "Wall": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.WALL, 10, _toggle); break; case "Window": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.WINDOW, 10, _toggle); break; case "Monitor": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.MONITOR, 10, _toggle); break; case "Furniture": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.FURNITURE, 10, _toggle); break; case "Door": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.DOOR, 10, _toggle); break; case "Picture": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PICTURE, 10, _toggle); break; case "Person": ViveSR_SceneUnderstanding.SetCustomSceneUnderstandingConfig(SceneUnderstandingObjectType.PERSON, 10, _toggle); break; } } index++; } } if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstanding && ViveSR_RigidReconstruction.IsScanning) { if (GUILayout.Button("Export SceneObjects (.xml)")) { ViveSR_SceneUnderstanding.ExportSceneUnderstandingInfo(SemanticObjDir); } } if (GUILayout.Button("Load & Show SceneObjects BoundingBox")) { ViveSR_SceneUnderstanding.ImportSceneObjects(ReconstructionResultDir + ReconsSceneDir + SemanticObjDir); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.CHAIR, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.CEILING, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.FLOOR, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.WALL, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.BED, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.TABLE, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.MONITOR, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.WINDOW, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.FURNITURE, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.DOOR, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PICTURE, true, false); ViveSR_SceneUnderstanding.ShowSemanticBoundingBoxAndIconWithType(SceneUnderstandingObjectType.PERSON, true, false); } if (GUILayout.Button("Destroy All SceneObjects BoundingBox")) { ViveSR_SceneUnderstanding.DestroySceneObjects(); } } #endregion }