public static void Release() { Texture2D.Destroy(TextureDistortedLeft); Texture2D.Destroy(TextureDistortedRight); Texture2D.Destroy(TextureUndistortedLeft); Texture2D.Destroy(TextureUndistortedRight); Texture2D.Destroy(TextureDepth); for (int i = 0; i < UndistortedTextureDataBuffer.Count; i++) { if (UndistortedTextureDataBuffer[i].Initialized) { Texture2D.Destroy(UndistortedTextureDataBuffer[i].Left); Texture2D.Destroy(UndistortedTextureDataBuffer[i].Right); UndistortedTextureDataBuffer[i].Initialized = false; } } UndistortedTextureDataBuffer.Clear(); SetTextureFromHandleReady = false; SRWorkModule_API.ReleaseCopyD3D11TextureBuffer(); TextureDistortedLeft = null; TextureDistortedRight = null; TextureUndistortedLeft = null; TextureUndistortedRight = null; TextureDepth = null; }
public static void EnableSceneUnderstandingView(bool enable) { int result = 0; if (!ViveSR_RigidReconstruction.IsScanning) { return; } result = SRWorkModule_API.SetReconstructionParameterBool((int)ReconstructionParam.SCENE_UNDERSTANDING_MACHINE_VISION, enable); if (result == (int)Error.WORK) { IsEnabledSceneUnderstandingView = enable; Debug.Log("[ViveSR] [Scene Understanding] Preview " + (enable ? "enabled" : "disabled")); if (IsEnabledSceneUnderstandingView) { ViveSR_RigidReconstructionRenderer.EnableSector = false; ViveSR_RigidReconstructionRenderer.SetWireFrameOpaque = false; } else { // ViveSR_RigidReconstructionRenderer.EnableSector = true; ViveSR_RigidReconstructionRenderer.SetWireFrameOpaque = true; ResetSceneUnderstandingProgress(); } } }
/// <summary> /// Initialize the image capturing tool. /// </summary> /// <returns></returns> public static int Initial() { GetParameters(); SRWorkModule_API.CreateCopyD3D11TextureBuffer(); SetTextureFromHandleReady = false; RingBufferSize = SRWorkModule_API.GetRingBufferSize(); for (int i = 0; i < RingBufferSize; i++) { UndistortedTextureDataBuffer.Add(new UndistortedTextureData()); } if (SeeThrough.SRWork_SeeThrough.b4KImageReady) { TextureDistortedLeft = new Texture2D(DistortedImageWidth, DistortedImageHeight, TextureFormat.BGRA32, false); TextureDistortedRight = new Texture2D(DistortedImageWidth, DistortedImageHeight, TextureFormat.BGRA32, false); TextureUndistortedLeft = new Texture2D(UndistortedImageWidth, UndistortedImageHeight, TextureFormat.RGBA32, false); TextureUndistortedRight = new Texture2D(UndistortedImageWidth, UndistortedImageHeight, TextureFormat.RGBA32, false); } else { TextureDistortedLeft = new Texture2D(DistortedImageWidth, DistortedImageHeight, TextureFormat.RGBA32, false); TextureDistortedRight = new Texture2D(DistortedImageWidth, DistortedImageHeight, TextureFormat.RGBA32, false); TextureUndistortedLeft = new Texture2D(UndistortedImageWidth, UndistortedImageHeight, TextureFormat.RGBA32, false); TextureUndistortedRight = new Texture2D(UndistortedImageWidth, UndistortedImageHeight, TextureFormat.RGBA32, false); } TextureDepth = new Texture2D(DepthImageWidth, DepthImageHeight, TextureFormat.RFloat, false); return((int)Error.WORK); }
public static void ExportModel(string filename) { ExportStage = 0; ExportPercentage = 0; ExportError = (int)Error.WORK; IsExportingMesh = true; IsScannedMeshPreviewCompleted = false; SRWorkModule_API.SetReconstructionParameterBool((int)ReconstructionParam.EXPORT_ADAPTIVE_MODEL, ExportAdaptiveMesh); if (ExportAdaptiveMesh) { SRWorkModule_API.SetReconstructionParameterFloat((int)ReconstructionParam.ADAPTIVE_MAX_GRID, ExportAdaptiveMaxGridSize * 0.01f); // cm to m SRWorkModule_API.SetReconstructionParameterFloat((int)ReconstructionParam.ADAPTIVE_MIN_GRID, ExportAdaptiveMinGridSize * 0.01f); SRWorkModule_API.SetReconstructionParameterFloat((int)ReconstructionParam.ADAPTIVE_ERROR_THRES, ExportAdaptiveErrorThres); } //if ((int)Error.WORK != SRWorkModule_API.RegisterReconstructionCallback(Marshal.GetFunctionPointerForDelegate((ExportProgressCallback)UpdateExportProgress))) // Debug.Log("[ViveSR] [ExportModel] Progress listener failed to register"); //ViveSR_Framework.RegisterCallback(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionCallback.EXPORT_PROGRESS, Marshal.GetFunctionPointerForDelegate((ExportProgressCallback)UpdateExportProgress)); byte[] bytearray = System.Text.Encoding.ASCII.GetBytes(filename); IntPtr parameter = Marshal.AllocCoTaskMem(filename.Length); Marshal.Copy(bytearray, 0, parameter, filename.Length); SRWorkModule_API.SetReconstructionOutputFileName(parameter, filename.Length); }
public static void EnableSceneUnderstanding(bool enable) { int result = SRWorkModule_API.SetReconstructionParameterBool((int)ReconstructionParam.SCENE_UNDERSTANDING_ENABLE, enable); if (result == (int)Error.WORK) { IsEnabledSceneUnderstanding = enable; } else { Debug.Log("[ViveSR] [Scene Understanding] Activation/Deactivation failed"); return; } if (IsEnabledSceneUnderstanding) { //result = ViveSR_Framework.RegisterCallback(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionCallback.SCENE_UNDERSTANDING_PROGRESS, Marshal.GetFunctionPointerForDelegate((ExportProgressCallback)UpdateSceneUnderstandingProgress)); if (result != (int)Error.WORK) { Debug.Log("[ViveSR] [Scene Understanding] Progress listener failed to register"); } } else if (IsEnabledSceneUnderstandingView) { EnableSceneUnderstandingView(false); } }
public void MatchUIWithSRWorksSetting() { Default_Values.Clear(); for (int i = 0; i < sliders.Count; i++) { Default_Values.Add(GetValue((ControlMode)i, ValueToGet.Value)); } int result = SRWorkModule_API.GetDepthParameterBool((int)DepthCmd.ENABLE_REFINEMENT, ref refinement_setting); if (result == (int)Error.WORK) { ViveSR_DualCameraImageCapture.DepthRefinement = refinement_setting; } else { Debug.LogWarning("Depth refinemenet call status: " + (Error)result); } Default_isDepthRefinementOn = ViveSR_DualCameraImageCapture.DepthRefinement; Default_isEdgeEnhanceOn = ViveSR_DualCameraImageCapture.DepthEdgeEnhance; Default_DepthCase = ViveSR_DualCameraImageCapture.DepthCase; for (int i = 0; i < sliders.Count; i++) { sliders[i].value = GetValue((ControlMode)i, ValueToGet.Value); } switches_status[(int)ControlMode.Refinement - sliders.Count].text = Default_isDepthRefinementOn ? "On" : "Off"; switches_status[(int)ControlMode.EdgeEnhance - sliders.Count].text = Default_isEdgeEnhanceOn ? "On" : "Off"; switches_status[(int)ControlMode.DepthCase - sliders.Count].text = Default_DepthCase == DepthCase.DEFAULT ? "Default" : "Close Range"; }
public static int EnableDepthProcess(bool active) { //Todo : Check module link status. //int result = ViveSR_Framework.ChangeModuleLinkStatus(ViveSR_Framework.MODULE_ID_SEETHROUGH, ViveSR_Framework.MODULE_ID_DEPTH, active ? (int)WorkLinkMethod.ACTIVE : (int)WorkLinkMethod.NONE); //if (result == (int)Error.WORK) DepthProcessing = active; //return result; int result = (int)Error.FAILED; if (active) { SRWorkModule_API.SetSkipVGAProcess(false); result = SRWorkModule_API.LinkModule((int)ModuleType.SEETHROUGH, (int)ModuleType.DEPTH); if (result == (int)Error.WORK) { result = SRWorkModule_API.TurnOnUndistortDataToDepth(); DepthProcessing = true; } else { DepthProcessing = false; } } else { result = SRWorkModule_API.UnlinkModule((int)ModuleType.SEETHROUGH, (int)ModuleType.DEPTH); if (result == (int)Error.WORK) { result = SRWorkModule_API.TurnOffUndistortDataToDepth(); DepthProcessing = false; } } return(result); }
/// <summary> /// Update given texture2D with camera image. /// </summary> /// <param name="texture">A texture2D sholud be defined as Texture2D(ImageWidth, ImageHeight, TextureFormat.RGBA32, true/false)</param> /// <returns>true if there is any new data.</returns> /// private static void DistortedDataCallback(IntPtr data) { //update = UpdateData(); //TextureDistortedLeft.LoadRawTextureData(data, 612 * 460 * 4); LastUpdateResult = SRWorkModule_API.GetSeeThroughData(ref see_through_data_); //int offset = sizeof(char) * 612 * 460 * 4 * 2 + sizeof(char) * 1150 * 750 * 4 * 2; //undistorted_left_texture.LoadRawTextureData(data, UndistortedImageWidth * UndistortedImageHeight * UndistortedImageChannel); //offset = offset / sizeof(Int32); ////int size = sizeof(char) * 612 * 460 * 4 * 2 + sizeof(char) * 1150 * 750 * 4 * 2 + //// sizeof(float) * 16 * 2 + sizeof(int) * 12; ////byte[] data_byte = new byte[size]; //IntPtr new_ptr; //new_ptr = new IntPtr(data.ToInt32() + offset); //if (IntPtr.Size == sizeof(Int32)) //{ // Debug.Log("32"); // new_ptr = new IntPtr(data.ToInt32() + offset); //} //else //{ // Debug.Log("64"); // new_ptr = new IntPtr(data.ToInt64() + offset); //} //Marshal.Copy(new_ptr, frame, 0, frame.Length); Debug.Log("here"); }
/* * private static void UpdateExportProgress(int stage, int percentage) * { * // Fixed: The export stage should be saving mesh model first then extracting collider; * if (stage == (int)ReconstructionExportStage.STAGE_EXTRACTING_MODEL) ExportStage = 0; * else if (stage == (int)ReconstructionExportStage.STAGE_COMPACTING_TEXTURE) ExportStage = 1; * else if (stage == (int)ReconstructionExportStage.STAGE_SAVING_MODEL_FILE) ExportStage = 2; * else if (stage == (int)ReconstructionExportStage.STAGE_EXTRACTING_COLLIDER) ExportStage = 3; * ExportPercentage = percentage; * * if (stage == (int)ReconstructionExportStage.STAGE_EXTRACTING_MODEL) * Debug.Log("Extracting Model: " + percentage + "%"); * else if (stage == (int)ReconstructionExportStage.STAGE_COMPACTING_TEXTURE) * Debug.Log("Compacting Textures: " + percentage + "%"); * else if (stage == (int)ReconstructionExportStage.STAGE_EXTRACTING_COLLIDER) * Debug.Log("Extracting Collider: " + percentage + "%"); * else if (stage == (int)ReconstructionExportStage.STAGE_SAVING_MODEL_FILE) * Debug.Log("Saving Model: " + percentage + "%"); * * if (ExportStage == 3 && ExportPercentage == 100) * { * IsExportingMesh = false; * Debug.Log("[ViveSR] [RigidReconstruction] Finish Exporting"); * //if ((int)Error.WORK != SRWorkModule_API.UnregisterReconstructionCallback()) * // Debug.Log("[ViveSR] [ExportModel] Progress listener failed to unregister"); * } * } */ public static void UpdateExportProgress() { ExportError = SRWorkModule_API.GetExportMeshProgress(ref ExportPercentage); if (ExportError != (int)Error.WORK || ExportPercentage == 100) { IsExportingMesh = false; } }
static SRWork_SeeThrough() { SRWorkModule_API.GetSeeThrougParameterBool((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_4K_READY, ref b4KImageReady); SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_DISTORTED_WIDTH, ref DistortedImageWidth); SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_DISTORTED_HEIGHT, ref DistortedImageHeight); SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_DISTORTED_CHANNEL, ref DistortedImageChannel); SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_UNDISTORTED_WIDTH, ref UndistortedImageWidth); SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_UNDISTORTED_HEIGHT, ref UndistortedImageHeight); SRWorkModule_API.GetSeeThrougParameterInt((int)Vive.Plugin.SR.SeeThroughParam.OUTPUT_UNDISTORTED_CHANNEL, ref UndistortedImageChannel); //b4KImageReady = false; SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_DISTORTED_4K_WIDTH, ref Distorted4KImageWidth); SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_DISTORTED_4K_HEIGHT, ref Distorted4KImageHeight); SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_DISTORTED_4K_CHANNEL, ref Distorted4KImageChannel); SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_WIDTH, ref Undistorted4KImageWidth); SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_HEIGHT, ref Undistorted4KImageHeight); SRWorkModule_API.GetSeeThroug4KParameterInt((int)Vive.Plugin.SR.SeeThrough4KParam.OUTPUT_UNDISTORTED_4K_CHANNEL, ref Undistorted4KImageChannel); //IntPtr.Zero; // see_through_data_.distorted_frame_left = IntPtr.Zero; see_through_data_.distorted_frame_right = IntPtr.Zero; see_through_data_.undistorted_frame_left = IntPtr.Zero; see_through_data_.undistorted_frame_right = IntPtr.Zero; SeeThroughDataLeftDistort = Marshal.AllocCoTaskMem(sizeof(char) * DistortedImageWidth * DistortedImageHeight * DistortedImageChannel); SeeThroughDataRighttDistort = Marshal.AllocCoTaskMem(sizeof(char) * DistortedImageWidth * DistortedImageHeight * DistortedImageChannel); see_through_data_.pose_left = Marshal.AllocCoTaskMem(sizeof(float) * 16); see_through_data_.pose_right = Marshal.AllocCoTaskMem(sizeof(float) * 16); see_through_data_.Camera_params = Marshal.AllocCoTaskMem(sizeof(char) * 1032); see_through_data_.d3d11_texture2d_shared_handle_left = Marshal.AllocCoTaskMem(IntPtr.Size); see_through_data_.d3d11_texture2d_shared_handle_right = Marshal.AllocCoTaskMem(IntPtr.Size); see_through_4k_data_.distorted_4k_frame_left = IntPtr.Zero; see_through_4k_data_.distorted_4k_frame_right = IntPtr.Zero; see_through_4k_data_.undistorted_4k_frame_left = IntPtr.Zero; see_through_4k_data_.undistorted_4k_frame_right = IntPtr.Zero; see_through_4k_data_.output4k_pose_left = Marshal.AllocCoTaskMem(sizeof(float) * 16); see_through_4k_data_.output4k_pose_right = Marshal.AllocCoTaskMem(sizeof(float) * 16); see_through_4k_data_.Camera4k_params = Marshal.AllocCoTaskMem(sizeof(char) * 1032); see_through_4k_data_.d3d11_texture2d_shared_handle_left = Marshal.AllocCoTaskMem(IntPtr.Size); see_through_4k_data_.d3d11_texture2d_shared_handle_right = Marshal.AllocCoTaskMem(IntPtr.Size); //RegisterDistortedCallback(); }
public static void UpdateSceneUnderstandingProgress() { SRWorkModule_API.GetSceneUnderstandingProgress(ref ScUndProcessingProgressBar); if (ScUndProcessingProgressBar == 100) { IsExportingSceneUnderstandingInfo = false; ViveSR_RigidReconstructionRenderer.EnableSector = ReconstructionSectorSetting; } }
public static bool UpdateData() { LastUpdateResult = SRWorkModule_API.GetRigidReconstructionData(ref rigid_reconstruction_data_); if (data_error_handler.ContainsKey(LastUpdateResult)) { data_error_handler[LastUpdateResult](); } return(LastUpdateResult == (int)Error.WORK); }
public static bool UpdateData() { LastUpdateResult = SRWorkModule_API.GetControllerPoseData(ref controller_pose_data_); Marshal.Copy(controller_pose_data_.pose_position_left, pos_left, 0, pos_left.Length); Marshal.Copy(controller_pose_data_.pose_rotation_left, rot_left, 0, rot_left.Length); Marshal.Copy(controller_pose_data_.pose_position_right, pos_right, 0, pos_right.Length); Marshal.Copy(controller_pose_data_.pose_rotation_right, rot_right, 0, rot_right.Length); return(LastUpdateResult == (int)Error.WORK); }
private void UpdateWhileWorking() { if (FrameworkStatus != FrameworkStatus.WORKING) { return; } if (EnableSeeThroughModule == true && EnableUnitySeeThrough == false) { Modules[0].Initial(); SRWorkModule_API.TurnOffUndistortDataToDepth(); SRWorkModule_API.UnlinkModule((int)ModuleType.SEETHROUGH, (int)ModuleType.DEPTH); if (SeeThrough.SRWork_SeeThrough.b4KImageReady) { SeeThrough.SRWork_SeeThrough.SkipVGASeeThrough(true); } EnableUnitySeeThrough = true; } if (EnableSeeThroughNon4KDistortDataUse == true && EnableUnitySeeThroughNon4KDistortData == false) { bool result = SeeThrough.SRWork_SeeThrough.TurnOnSeeThroughDistortData(); if (result) { EnableUnitySeeThroughNon4KDistortData = true; } } else if (EnableSeeThroughNon4KDistortDataUse == false && EnableUnitySeeThroughNon4KDistortData == true) { bool result = SeeThrough.SRWork_SeeThrough.TurnOffSeeThroughDistortData(); if (result) { EnableUnitySeeThroughNon4KDistortData = false; } } if (EnableDepthMeshModule == true && EnableUnityDepthMesh == false) { Modules[1].Initial(); //Get refinement setting of engine. int result = SRWorkModule_API.GetDepthParameterBool((int)DepthCmd.ENABLE_REFINEMENT, ref refinement_setting); if (result == (int)SR.Error.WORK) { ViveSR_DualCameraImageCapture.DepthRefinement = refinement_setting; } SRWorkModule_API.UnlinkModule((int)ModuleType.DEPTH, (int)ModuleType.DEPTHMESH); EnableUnityDepthMesh = true; } if (EnableRigidReconstructionModule == true && EnableUnityReconstruction == false) { Modules[2].Initial(); SRWorkModule_API.UnlinkModule((int)ModuleType.DEPTH, (int)ModuleType.RIGIDRECONSTRUCTION); EnableUnityReconstruction = true; } }
public static int ChangeDepthCase(DepthCase depthCase) { int result = SRWorkModule_API.SetDepthParameterInt((int)DepthCmd.CHANGE_DEPTH_CASE, (int)depthCase); if (result == (int)Error.WORK) { DepthCase = depthCase; } return(result); }
public static int EnableDepthEdgeEnhance(bool active) { int result = SRWorkModule_API.SetDepthParameterBool((int)DepthCmd.ENABLE_EDGE_ENHANCE, active); if (result == (int)Error.WORK) { _DepthEdgeEnhance = active; } return(result); }
public static int EnableDepthRefinement(bool active) { int result = SRWorkModule_API.SetDepthParameterBool((int)DepthCmd.ENABLE_REFINEMENT, active); if (result == (int)Error.WORK) { _DepthRefinement = active; } return(result); }
public static int SetDefaultDepthCase(DepthCase depthCase) { int result = SRWorkModule_API.SetDepthParameterInt((int)DepthParam.DEPTH_USING_CASE, (int)depthCase); if (result == (int)Error.WORK) { DepthCase = depthCase; } return(result); }
public static void StopScanning() { if (ReconstructionProcessing) { IsScanning = false; SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionCmd.STOP), true); Debug.Log("stop"); } ViveSR_RigidReconstruction.EnableReconstructionProcess(false); }
private static bool SetColliderRangeEnable(bool value) { int result = SRWorkModule_API.SetDepthMeshParameterBool((int)DepthCmd.ENABLE_SELECT_MESH_DISTANCE_RANGE, value); if (result == (int)Error.WORK) { _UpdateDepthColliderRange = value; return(true); } return(false); }
public static bool SetDepthColliderHoleFillingEnable(bool value) { int result = SRWorkModule_API.SetDepthMeshParameterBool((int)DepthCmd.ENABLE_DEPTH_MESH_HOLE_FILLING, value); if (result == (int)Error.WORK) { _UpdateDepthColliderHoleFilling = value; return(true); } return(false); }
private bool UpdateRuntimeParameter() { bool result = true; int ret = (int)Error.FAILED; // check live mesh display mode if (ViveSR_SceneUnderstanding.IsEnabledSceneUnderstandingView || ViveSR_RigidReconstruction.IsDuringScannedMeshPreview) { LiveMeshDisplayMode = ReconstructionDisplayMode.ADAPTIVE_MESH; //support only in this mode } // update live mesh display mode if ((int)LiveMeshDisplayMode != LastLiveMeshDisplayMode) { HideAllLiveMeshes(); result = SetMeshDisplayMode(LiveMeshDisplayMode) && result; LastLiveMeshDisplayMode = (int)LiveMeshDisplayMode; // refresh rate SRWorkModule_API.SetReconstructionParameterInt((int)ReconstructionParam.MESH_REFRESH_INTERVAL, RefreshIntervalMS); // full scene quality if (LiveMeshDisplayMode == ReconstructionDisplayMode.FULL_SCENE) { ret = SRWorkModule_API.SetReconstructionParameterInt((int)(ReconstructionParam.CONFIG_QUALITY), (int)FullSceneQuality); LiveMeshMaterial.SetFloat("_PointSizeScaler", (FullSceneQuality == ReconstructionQuality.LOW) ? 1.2f : 0.8f); result = result && (ret == (int)Error.WORK); } // update live adaptive param if (LiveMeshDisplayMode == ReconstructionDisplayMode.ADAPTIVE_MESH) { ret = SRWorkModule_API.SetReconstructionParameterFloat((int)ReconstructionParam.ADAPTIVE_MAX_GRID, ViveSR_RigidReconstruction.LiveAdaptiveMaxGridSize * 0.01f); // cm to m result = result && (ret == (int)Error.WORK); ret = SRWorkModule_API.SetReconstructionParameterFloat((int)ReconstructionParam.ADAPTIVE_MIN_GRID, ViveSR_RigidReconstruction.LiveAdaptiveMinGridSize * 0.01f); result = result && (ret == (int)Error.WORK); ret = SRWorkModule_API.SetReconstructionParameterFloat((int)ReconstructionParam.ADAPTIVE_ERROR_THRES, ViveSR_RigidReconstruction.LiveAdaptiveErrorThres); result = result && (ret == (int)Error.WORK); } } if (EnableSector != LastEnableSector) { HideAllLiveMeshes(); SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.ENABLE_FRUSTUM_CULLING), EnableSector); SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.ENABLE_SECTOR_GROUPER), EnableSector); SRWorkModule_API.SetReconstructionParameterFloat((int)(ReconstructionParam.SECTOR_SIZE), SectorSizeInMeter); LastEnableSector = EnableSector; } if (SetWireFrameOpaque != LastSetWireFrameOpaque) { WireframeMaterial.SetFloat("_Opaque", SetWireFrameOpaque ? 1.0f : 0.0f); LastSetWireFrameOpaque = SetWireFrameOpaque; } return(result); }
public static void StartScanning() { ViveSR_RigidReconstruction.EnableReconstructionProcess(true); if (ReconstructionProcessing) { SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionCmd.START), true); IsScanning = true; IsScannedMeshPreviewCompleted = false; Debug.Log("start"); } }
//Comment in ViveSR //public static void InitRigidReconstructionParam() //{ // this function is not called in current version, keep this API on, we can allow user to adjust some default setting // ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_DATA_SOURCE, (int)ViveSR_RigidReconstructionConfig.ReconstructionDataSource); // ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_DATASET_FRAME_NUM, (int)ViveSR_RigidReconstructionConfig.NumDatasetFrame); // ViveSR_Framework.SetParameterString(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_DATASET_PATH, ViveSR_RigidReconstructionConfig.DatasetPath); // ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_EXPORT_COLLIDER, ViveSR_RigidReconstructionConfig.ExportCollider); // ViveSR_Framework.SetParameterBool(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_EXPORT_TEXTURE, true); // ViveSR_Framework.SetParameterInt(ViveSR_Framework.MODULE_ID_RIGID_RECONSTRUCTION, (int)ReconstructionParam.CONFIG_QUALITY, (int)ViveSR_RigidReconstructionConfig.Quality); //} public static int GetRigidReconstructionIntParameter(int type) { int ret = -1; if (SRWorkModule_API.GetReconstructionParameterInt(type, ref ret) != (int)Error.WORK) { Debug.Log("[ViveSR] [RigidReconstruction] GetRigidReconstructionIntParameter Failed"); } return(ret); }
public static bool TurnOnSeeThroughDistortData() { int result = SRWorkModule_API.TurnOnDistortData(); if (result != (int)Error.WORK) { return(false); } see_through_data_.distorted_frame_left = SeeThroughDataLeftDistort; see_through_data_.distorted_frame_right = SeeThroughDataRighttDistort; return(true); }
public static bool TurnOffSeeThroughDistortData() { int result = SRWorkModule_API.TurnOffDistortData(); if (result != (int)Error.WORK) { return(false); } see_through_data_.distorted_frame_left = IntPtr.Zero; see_through_data_.distorted_frame_right = IntPtr.Zero; return(true); }
public static bool SetQualityScale(int value) { int result = SRWorkModule_API.SetDepthMeshParameterInt((int)DepthParam.COLLIDER_QUALITY, value); if (result == (int)Error.WORK) { QualityScale = value; return(true); } else { return(false); } }
public bool SetMeshDisplayMode(ReconstructionDisplayMode displayMode) { ResetData(); int result = (int)Error.FAILED; if (displayMode == ReconstructionDisplayMode.FIELD_OF_VIEW) { SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.ENABLE_FRUSTUM_CULLING), false); SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.ENABLE_SECTOR_GROUPER), false); result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.LITE_POINT_CLOUD_MODE), true); result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.FULL_POINT_CLOUD_MODE), false); result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.LIVE_ADAPTIVE_MODE), false); LiveMeshMaterial.SetFloat("_PointSizeScaler", 1.2f); UsingMaterial = LiveMeshMaterial; ThreadPeriod = 15; BackupSectorValue = EnableSector; EnableSector = false; } else if (displayMode == ReconstructionDisplayMode.FULL_SCENE) { result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.LITE_POINT_CLOUD_MODE), false); result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.FULL_POINT_CLOUD_MODE), true); result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.LIVE_ADAPTIVE_MODE), false); LiveMeshMaterial.SetFloat("_PointSizeScaler", (FullSceneQuality == ReconstructionQuality.LOW) ? 1.3f : 0.8f); UsingMaterial = LiveMeshMaterial; ThreadPeriod = 300; EnableSector = BackupSectorValue; } else if (displayMode == ReconstructionDisplayMode.ADAPTIVE_MESH) { result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.LITE_POINT_CLOUD_MODE), false); result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.FULL_POINT_CLOUD_MODE), false); result = SRWorkModule_API.SetReconstructionParameterBool((int)(ReconstructionParam.LIVE_ADAPTIVE_MODE), true); UsingMaterial = WireframeMaterial; ThreadPeriod = 300; EnableSector = BackupSectorValue; } foreach (KeyValuePair <int, GameObject> go in ShowGameObjs) { go.Value.GetComponent <MeshRenderer>().sharedMaterial = UsingMaterial; } if (result == (int)Error.WORK) { LiveMeshDisplayMode = displayMode; } return(result == (int)Error.WORK); }
private static bool SetDepthColliderFarDistance(double value) { value = (value < _ColliderNearDistance) ? _ColliderNearDistance : value; int result = SRWorkModule_API.SetDepthMeshParameterDouble((int)DepthParam.MESH_FAR_DISTANCE, value); if (result == (int)Error.WORK) { _ColliderFarDistance = value; return(true); } else { return(false); } }
public static bool GetQualityScale(out int value) { int result = SRWorkModule_API.GetDepthMeshParameterInt((int)DepthParam.COLLIDER_QUALITY, ref QualityScale); if (result == (int)Error.WORK) { value = QualityScale; return(true); } else { value = -1; return(false); } }