public DeviceInfo GetDeviceFromFileMenu(string fileName) { ImplDesc desc = new ImplDesc() { group = ImplGroup.IMPL_GROUP_SENSOR, subgroup = ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE }; ImplDesc desc1; DeviceInfo dinfo; SenseManager pp = SenseManager.CreateInstance(); if (pp == null) { return(null); } try { desc1 = session.QueryImpl(desc, 0); if (desc1 == null) { throw null; } if (pp.CaptureManager == null) { throw null; } if (pp.CaptureManager.SetFileName(fileName, false) < Status.STATUS_NO_ERROR) { throw null; } if (pp.CaptureManager.LocateStreams() < Status.STATUS_NO_ERROR) { throw null; } if (pp.CaptureManager.Device != null) { pp.CaptureManager.Device.QueryDeviceInfo(out dinfo); } else { throw null; } } catch { pp.Dispose(); return(null); } pp.Close(); pp.Dispose(); StatusLabel.Text = "Ok"; return(dinfo); }
/// <summary> /// 機能の初期化 /// </summary> private void Initialize() { try { //SenseManagerを生成 senseManager = SenseManager.CreateInstance(); SampleReader reader = SampleReader.Activate(senseManager); //カラーストリームを有効にする reader.EnableStream(StreamType.STREAM_TYPE_COLOR, COLOR_WIDTH, COLOR_HEIGHT, COLOR_FPS); //パイプラインを初期化する //(インスタンスはInit()が正常終了した後作成されるので,機能に対する各種設定はInit()呼び出し後となる) var sts = senseManager.Init(); if (sts < Status.STATUS_NO_ERROR) { throw new Exception("パイプラインの初期化に失敗しました"); } //デバイスを取得する device = senseManager.CaptureManager.Device; //ミラー表示にする device.MirrorMode = MirrorMode.MIRROR_MODE_HORIZONTAL; //座標変換オブジェクトを作成 projection = device.CreateProjection(); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } }
/// <summary> /// 音声入力デバイス選択待機 /// </summary> protected void Init() { // コマンドライン引数 DeviceName = CommandLineArgs.AudioInputDevice; if (DeviceName != null) { if (DeviceName == "" || Microphone.devices.Contains(DeviceName)) { StartRecording(); } else { Canvas.DisplayMessage($"Device named “{DeviceName}” do not exists."); DeviceName = null; } } else if (CommandLineArgs.HideTextDefault) { return; } if (DeviceName == null) { StartCoroutine("SelectMicrophone"); } // 平滑化初期化 // 参考:https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?doc_utils_the_smoother_utility.html SenseManager = SenseManager.CreateInstance(); Smoother = Smoother.CreateInstance(SenseManager.Session); SmoothMouth = Smoother.Create1DWeighted(5); MonitorMicrophone(); }
protected void Init() { try { // RealSense初期化 // 参考:https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?doc_face_general_procedure.html // 参考:.\Intel\RSSDK\sample\core\RawStreams.unity SenseManager = SenseManager.CreateInstance(); FaceModule = FaceModule.Activate(SenseManager); FaceModule.FrameProcessed += FaceModule_FrameProcessed; FaceData = FaceModule.CreateOutput(); FaceConfig = FaceModule.CreateActiveConfiguration(); FaceConfig.TrackingMode = TrackingModeType.FACE_MODE_COLOR; FaceConfig.Expressions.Properties.Enabled = true; FaceConfig.ApplyChanges(); SampleReader = SampleReader.Activate(SenseManager); SampleReader.EnableStream(StreamType.STREAM_TYPE_COLOR, 640, 480, 30); SampleReader.SampleArrived += SampleReader_SampleArrived; SenseManager.Init(); SenseManager.StreamFrames(false); // RawStreams Texture = NativeTexturePlugin.Activate(); Material.mainTexture = new Texture2D(640, 480, TextureFormat.BGRA32, false); Material.mainTextureScale = new Vector2(-1, -1); TexPtr = Material.mainTexture.GetNativeTexturePtr(); // 解像度取得 StreamProfileSet profile; SenseManager.CaptureManager.Device.QueryStreamProfileSet(out profile); Resolution = profile.color.imageInfo; // 平滑化初期化 // 参考:https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?doc_utils_the_smoother_utility.html Smoother = Smoother.CreateInstance(SenseManager.Session); SmoothBody = Smoother.Create3DWeighted(BodyPosSmoothWeight); SmoothHead = Smoother.Create3DWeighted(HeadAngSmoothWeight); SmoothEyes = Smoother.Create2DWeighted(EyesPosSmoothWeight); SmoothEyesClose = Smoother.Create1DWeighted(EyesCloseSmoothWeight); SmoothBrowRai = Smoother.Create1DWeighted(FaceSmoothWeight); SmoothBrowLow = Smoother.Create1DWeighted(FaceSmoothWeight); SmoothSmile = Smoother.Create1DWeighted(FaceSmoothWeight); SmoothKiss = Smoother.Create1DWeighted(FaceSmoothWeight); SmoothMouth = Smoother.Create1DWeighted(FaceSmoothWeight); SmoothTongue = Smoother.Create1DWeighted(FaceSmoothWeight); } catch (Exception e) { ErrorLog.text = "RealSense Error\n"; ErrorLog.text += e.Message; } }
// Use this for initialization void Start() { /* Create SenseManager Instance */ sm = SenseManager.CreateInstance(); sm.CaptureManager.Realtime = false; // Selecting a higher resolution profile StreamProfileSet profiles = new StreamProfileSet(); profiles.color.imageInfo.width = 1280; profiles.color.imageInfo.height = 720; RangeF32 f_rate = new RangeF32(30, 30); profiles.color.frameRate = f_rate; profiles.depth.imageInfo.width = 640; profiles.depth.imageInfo.height = 480; RangeF32 f_drate = new RangeF32(30, 30); profiles.depth.frameRate = f_drate; // Setting the resolution profile sm.CaptureManager.FilterByStreamProfiles(profiles); sampleReader = SampleReader.Activate(sm); sampleReader2 = SampleReader.Activate(sm); sampleReader2.EnableStream(StreamType.STREAM_TYPE_DEPTH, depthWidth, depthHeight, colorFPS); // Enable and Get a segmentation instance here for configuration seg = Seg3D.Activate(sm); // Initialize seg.FrameProcessed += OnFrameProcessed; seg.OnAlert += Seg_OnAlert; sampleReader2.SampleArrived += SampleArrived; /* Initialize pipeline */ sm.Init(); // Flip the image horizontally sm.CaptureManager.Device.IVCAMAccuracy = IVCAMAccuracy.IVCAM_ACCURACY_FINEST; sm.CaptureManager.Device.MirrorMode = MirrorMode.MIRROR_MODE_HORIZONTAL; /* Create NativeTexturePlugin to render Texture2D natively */ texPlugin = NativeTexturePlugin.Activate(); // Configuring the material and its texture RGBMaterial.mainTexture = new Texture2D(colorWidth, colorHeight, TextureFormat.BGRA32, false); // Update material's Texture2D with enabled image size. RGBMaterial.mainTextureScale = new Vector2(-1, -1); // Flip the image colorTex2DPtr = RGBMaterial.mainTexture.GetNativeTexturePtr(); // Retrieve native Texture2D Pointer /* Start Streaming */ sm.StreamFrames(false); }
// Use this for initialization void Start() { /* Create SenseManager Instance */ sm = SenseManager.CreateInstance(); /* Selecting a higher resolution profile*/ StreamProfileSet profiles = new StreamProfileSet(); profiles.color.imageInfo.width = 1280; profiles.color.imageInfo.height = 720; RangeF32 f_rate = new RangeF32(30, 30); profiles.color.frameRate = f_rate; profiles.depth.imageInfo.width = 640; profiles.depth.imageInfo.height = 480; RangeF32 f_drate = new RangeF32(30, 30); profiles.depth.frameRate = f_drate; /* Setting the resolution profile */ sm.CaptureManager.FilterByStreamProfiles(profiles); /* Enable and Get a segmentation instance here for configuration */ seg = Seg3D.Activate(sm); /* Subscribe to seg arrived event */ seg.FrameProcessed += OnFrameProcessed; /* Initialize pipeline */ sm.Init(); /* Create NativeTexturePlugin to render Texture2D natively */ texPlugin = NativeTexturePlugin.Activate(); SegMaterial.mainTexture = new Texture2D(segWidth, segHeight, TextureFormat.BGRA32, false); // Update material's Texture2D with enabled image size. SegMaterial.mainTextureScale = new Vector2(-1, -1); // Flip the image segTex2DPtr = SegMaterial.mainTexture.GetNativeTexturePtr(); // Retrieve native Texture2D Pointer /* Start Streaming */ sm.StreamFrames(false); }
// Use this for initialization void Start() { /* Create SenseManager Instance */ sm = SenseManager.CreateInstance(); /* Create a SampleReader Instance */ sampleReader = SampleReader.Activate(sm); /* Enable Color & Depth Stream */ sampleReader.EnableStream(StreamType.STREAM_TYPE_COLOR, colorWidth, colorHeight, colorFPS); sampleReader.EnableStream(StreamType.STREAM_TYPE_DEPTH, depthWidth, depthHeight, depthFPS); /* Subscribe to sample arrived event */ sampleReader.SampleArrived += SampleArrived; /////////////////////////////////////////////////////// terry add start faceModule = FaceModule.Activate(sm); if (faceModule == null) { Debug.LogError("FaceModule Initialization Failed"); } //faceModule.FrameProcessed += FaceModule_FrameProcessed; FaceConfiguration moduleConfiguration = faceModule.CreateActiveConfiguration(); if (moduleConfiguration == null) { Debug.LogError("FaceConfiguration Initialization Failed"); } moduleConfiguration.TrackingMode = TrackingModeType.FACE_MODE_COLOR; moduleConfiguration.Strategy = TrackingStrategyType.STRATEGY_RIGHT_TO_LEFT; moduleConfiguration.Detection.maxTrackedFaces = 1; moduleConfiguration.Landmarks.maxTrackedFaces = 1; moduleConfiguration.Detection.isEnabled = true; moduleConfiguration.Landmarks.isEnabled = true; moduleConfiguration.Pose.isEnabled = false; moduleConfiguration.EnableAllAlerts(); //moduleConfiguration.AlertFired += OnFiredAlert; Status applyChangesStatus = moduleConfiguration.ApplyChanges(); Debug.Log(applyChangesStatus.ToString()); ////////////////////////////////////////////////////// terry add end /* Initialize pipeline */ sm.Init(); /* Create NativeTexturePlugin to render Texture2D natively */ texPlugin = NativeTexturePlugin.Activate(); RGBMaterial.mainTexture = new Texture2D(colorWidth, colorHeight, TextureFormat.BGRA32, false); // Update material's Texture2D with enabled image size. RGBMaterial.mainTextureScale = new Vector2(-1, -1); // Flip the image colorTex2DPtr = RGBMaterial.mainTexture.GetNativeTexturePtr(); // Retrieve native Texture2D Pointer DepthMaterial.mainTexture = new Texture2D(depthWidth, depthHeight, TextureFormat.BGRA32, false); // Update material's Texture2D with enabled image size. DepthMaterial.mainTextureScale = new Vector2(-1, -1); // Flip the image depthTex2DPtr = DepthMaterial.mainTexture.GetNativeTexturePtr(); // Retrieve native Texture2D Pointer /* Start Streaming */ sm.StreamFrames(false); }