public void Initialise(PXCMSenseManager senseManager) { this.senseManager = senseManager; this.senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480); }
private void Uninitialize() { if (senseManager != null) { senseManager.Dispose(); senseManager = null; } if (projection != null) { projection.Dispose(); projection = null; } if (handData != null) { handData.Dispose(); handData = null; } if (handAnalyzer != null) { handAnalyzer.Dispose(); handAnalyzer = null; } }
private void Initialize() { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); if (senseManager == null) { throw new Exception("SenseManagerを生成できませんでした。"); } // 利用可能なデバイスを列挙する PopulateDevice(); // Depthストリームを有効にする pxcmStatus sts = senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 0, 0, 0); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("Depthストリームの有効化に失敗しました"); } // パイプラインを初期化する sts = senseManager.Init(); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("初期化に失敗しました"); } // デバイス情報を取得する GetDeviceInfo(); }
/// <summary> 終了処理 </summary> private void Uninitialize() { if (senseManager != null) { senseManager.Dispose(); senseManager = null; } if (projection != null) { projection.Dispose(); projection = null; } if (handData != null) { handData.Dispose(); handData = null; } if (handAnalyzer != null) { handAnalyzer.Dispose(); handAnalyzer = null; } if (config != null) { config.UnsubscribeGesture(OnFiredGesture); config.Dispose(); } }
private bool ConfigureRealSense() { try { // Create a session instance session = PXCMSession.CreateInstance(); // Create a SenseManager instance from the Session instance senseManager = session.CreateSenseManager(); // Activate user segmentation senseManager.Enable3DSeg(); // Specify image width and height of color stream senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, WIDTH, HEIGHT, 30); // Initialize the pipeline senseManager.Init(); // Mirror the image horizontally senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); return(true); } catch (Exception) { return(false); } }
static void Main(string[] args) { try { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); if (senseManager == null) { throw new Exception("SenseManagerの生成に失敗しました"); } // 何かしら有効にしないとInitが失敗するので適当に有効にする senseManager.EnableFace(); // パイプラインを初期化する var sts = senseManager.Init(); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("パイプラインの初期化に失敗しました"); } // 使用可能なデバイスを列挙する enumDevice(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void Uninitialize() { if (senseManager != null) { senseManager.Dispose(); senseManager = null; } if (handConfig != null) { handConfig.Dispose(); handConfig = null; } if (handData != null) { handData.Dispose(); handData = null; } if (handAnalyzer != null) { handAnalyzer.Dispose(); handAnalyzer = null; } }
//Close any ongoing Session void OnDisable() { if (smoother3D != null) { for (int i = 0; i < MaxHands; i++) { if (smoother3D[i] != null) { for (int j = 0; j < MaxJoints; j++) { smoother3D[i][j].Dispose(); smoother3D[i][j] = null; } } } smoother3D = null; } if (smoother != null) { smoother.Dispose(); smoother = null; } if (sm != null) { sm.Close(); sm.Dispose(); sm = null; } }
public void Initialise(PXCMSenseManager senseManager) { this.senseManager = senseManager; // We configure by switching on the face module. this.senseManager.EnableFace(); // Now, grab that module. this.faceModule = this.senseManager.QueryFace(); // Configure it... using (var config = faceModule.CreateActiveConfiguration()) { // We want face detection. Only doing 1 face for now. config.detection.isEnabled = true; config.detection.maxTrackedFaces = 1; // We want face landmarks. Only doing 1 face for now. config.landmarks.isEnabled = true; config.landmarks.maxTrackedFaces = 1; // We want pulse data. Only doing 1 face for now. var pulseConfig = config.QueryPulse(); pulseConfig.properties.maxTrackedFaces = 1; pulseConfig.Enable(); // We want expressions. Only doing 1 face for now. var expressionConfig = config.QueryExpressions(); expressionConfig.EnableAllExpressions(); expressionConfig.Enable(); config.ApplyChanges().ThrowOnFail(); } this.faceData = this.faceModule.CreateOutput(); }
private void InitializeHandTracking(PXCMSenseManager senseManager) { // 手の検出器を取得する this.handAnalyzer = senseManager.QueryHand(); if (this.handAnalyzer == null) { throw new Exception("手の検出器の取得に失敗しました"); } // 手のデータを作成する this.handData = this.handAnalyzer.CreateOutput(); if (this.handData == null) { throw new Exception("手のデータの作成に失敗しました。"); } // RealSense カメラであればプロパティを設定する PXCMCapture.DeviceInfo dinfo; this.device.QueryDeviceInfo(out dinfo); if (dinfo.model == PXCMCapture.DeviceModel.DEVICE_MODEL_IVCAM) // = Intel RealSense 3D Camera (F200) { // 手を検出しやすいパラメータを設定 // RealSense開発チームが設定した一番検出しやすい設定(感覚値)とのこと...(from Intel RealSense SDK センサープログラミング p.135) device.SetDepthConfidenceThreshold(1); device.SetIVCAMFilterOption(6); } // 手の検出の設定 var config = this.handAnalyzer.CreateActiveConfiguration(); config.EnableSegmentationImage(true); config.ApplyChanges(); config.Update(); }
private void Initialize() { try { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); // カラーストリームを有効にする senseManager.EnableStream( PXCMCapture.StreamType.STREAM_TYPE_COLOR, COLOR_WIDTH, COLOR_HEIGHT, COLOR_FPS ); // パイプラインを初期化する pxcmStatus ret = senseManager.Init(); if ( ret < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "初期化に失敗しました" ); } // ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL ); // 音声認識を初期化する InitializeSpeechRecognition(); } catch ( Exception ex ) { MessageBox.Show( ex.Message ); Close(); } }
public MainWindow() { InitializeComponent(); _senseManager = PXCMSenseManager.CreateInstance(); _senseManager.EnableHand(); var handManager = _senseManager.QueryHand(); _handConfig = handManager.CreateActiveConfiguration(); _handConfig.EnableGesture("thumb_up"); _handConfig.EnableGesture("thumb_down"); //_handConfig.EnableGesture("fist"); //_handConfig.EnableGesture("spreadfingers"); _handConfig.EnableAllAlerts(); _handConfig.ApplyChanges(); var status = _senseManager.Init(); if (status >= pxcmStatus.PXCM_STATUS_NO_ERROR) { _cancellationTokenSource = new CancellationTokenSource(); _task = Task.Factory.StartNew(x => ProcessInput(_cancellationTokenSource.Token), TaskCreationOptions.LongRunning, _cancellationTokenSource.Token); } }
/// <summary> /// コンストラクタ /// /// カメラ画像表示用のWritableBitmapを準備してImageに割り当て /// カメラ制御用のオブジェクトを取得して /// Colorカメラストリームを有効にしてカメラのフレーム取得を開始する /// カメラキャプチャーするためのTaskを準備して開始 /// </summary> public MainWindow() { // 画面コンポーネントを初期化 InitializeComponent(); // カメラ画像書き込み用のWriteableBitmapを準備してImageコントローラーにセット m_ColorWBitmap = new WriteableBitmap(1920, 1080, 96.0, 96.0, PixelFormats.Bgr32, null); ColorCameraImage.Source = m_ColorWBitmap; // カメラ制御のオブジェクトを取得 m_Session = PXCMSession.CreateInstance(); m_Cm = m_Session.CreateSenseManager(); // Colorカメラストリームを有効にする m_Cm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 1920, 1080, 30); // カメラのフレーム取得開始 pxcmStatus initState = m_Cm.Init(); if (initState < pxcmStatus.PXCM_STATUS_NO_ERROR) { // エラー発生 MessageBox.Show(initState + "\nカメラ初期化に失敗しました。"); return; } // カメラ取得画像をミラーモードにする m_Cm.captureManager.device.SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); // カメラキャプチャーをするためのタスクを準備して起動 m_CameraCaptureTask = new Task(() => CaptureCameraProcess()); m_CameraCaptureTask.Start(); }
public void ConfigureRealSense() { // Create an instance of the SenseManager sm = PXCMSenseManager.CreateInstance(); // Enable cursor tracking sm.EnableHandCursor(); // Create a session of the RealSense session = PXCMSession.CreateInstance(); // Get an instance of the hand cursor module cursorModule = sm.QueryHandCursor(); // Get an instance of the cursor configuration cursorConfig = cursorModule.CreateActiveConfiguration(); // Make configuration changes and apply them cursorConfig.EnableEngagement(true); cursorConfig.EnableAllGestures(); cursorConfig.EnableAllAlerts(); cursorConfig.ApplyChanges(); // Initialize the SenseManager pipeline sm.Init(); }
protected virtual void Uninitialize() { if (this.initializing) { return; } if (this.image != null) { this.image.Dispose(); this.image = null; } if (this.device != null) { this.device.Dispose(); this.device = null; } if (this.session != null) { this.session.Dispose(); this.session = null; } if (this.senseManager != null) { this.senseManager.Close(); this.senseManager.Dispose(); this.senseManager = null; } this.initialized = false; }
private void Uninitialize() { if (this.controller != null) { this.controller.UnsubscribeEvent(OnTouchlessControllerUXEvent); this.controller.Dispose(); this.controller = null; } if (this.session != null) { this.session.Dispose(); this.session = null; } if (this.senseManager != null) { this.senseManager.Close(); this.senseManager.Dispose(); this.senseManager = null; } this.initialized = false; }
private void Uninitialize() { if ( senseManager != null ) { senseManager.Dispose(); senseManager = null; } }
private void Initialize() { try { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); // カラーストリームを有効にする senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, COLOR_WIDTH, COLOR_HEIGHT, COLOR_FPS); // パイプラインを初期化する pxcmStatus ret = senseManager.Init(); if (ret < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("初期化に失敗しました"); } // ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); // 音声認識を初期化する InitializeSpeechRecognition(); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } }
private void Initialize() { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); // カラーストリームを有効にする pxcmStatus sts = senseManager.EnableStream( PXCMCapture.StreamType.STREAM_TYPE_DEPTH, DEPTH_WIDTH, DEPTH_HEIGHT, DEPTH_FPS); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("Depthストリームの有効化に失敗しました"); } // パイプラインを初期化する sts = senseManager.Init(); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("初期化に失敗しました"); } // ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); }
public FrameReader(ObjectPool <MemoryFrame> pool, SmithersLogger logger) { #if DSAPI _dsAPI = new DSAPIManaged(); _dsAPI.initializeDevice(); #else _pool = pool; _logger = logger; //Directory.SetCurrentDirectory("") // TODO Inject this instead of creating it _session = PXCMSession.CreateInstance(); if (_session == null) { throw new Smithers.Reading.FrameData.ScannerNotFoundException("No valid plugged-in DS4 sensor found."); } _senseManager = PXCMSenseManager.CreateInstance(); if (_senseManager == null) { throw new Smithers.Reading.FrameData.ScannerNotFoundException("Failed to create an SDK pipeline object"); } _session.SetCoordinateSystem(PXCMSession.CoordinateSystem.COORDINATE_SYSTEM_REAR_OPENCV); #endif this.Synced = true; this.Mirrored = false; this.Record = false; this.Playback = false; this.RealTime = true; }
private int weightsNum = 15; //smoothing factor // Use this for initialization void Start () { hands = new HandsModel (); MaxHands = hands.MaxHands; MaxJoints = hands.MaxJoints; handList = new Hashtable (); senseManager = PXCMSenseManager.CreateInstance (); if (senseManager == null) Debug.LogError ("SenseManager Initialization Failed"); /* Enable hand tracking and retrieve an hand module instance to configure */ status = senseManager.EnableHand (); handAnalyzer = senseManager.QueryHand (); if (status != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError ("PXCSenseManager.EnableHand: " + status); /* Initialize the execution pipeline */ status = senseManager.Init (); if (status != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError ("PXCSenseManager.Init: " + status); /* Retrieve the the DataSmoothing instance */ senseManager.QuerySession ().CreateImpl<PXCMDataSmoothing> (out dataSmoothing); smoother3D = new PXCMDataSmoothing.Smoother3D[MaxHands][]; /* Configure a hand - Enable Gestures and Alerts */ PXCMHandConfiguration hcfg = handAnalyzer.CreateActiveConfiguration (); hcfg.EnableAllGestures (); hcfg.EnableAlert (PXCMHandData.AlertType.ALERT_HAND_NOT_DETECTED); hcfg.ApplyChanges (); hcfg.Dispose (); InitObject (); }
public RealSenseEngine() { m_session = PXCMSession.CreateInstance(); if (m_session == null) { throw new RealSenseEngineException("Failed to create a Session"); } m_senseManager = m_session.CreateSenseManager(); if (m_senseManager == null) { throw new RealSenseEngineException("Failed to create a SenseManager"); } pxcmStatus res = m_senseManager.EnableTouchlessController(); if (res != pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new RealSenseEngineException("Failed to Enable Touchless Controller"); } var handler = new PXCMSenseManager.Handler(); res = m_senseManager.Init(handler); if (res != pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new RealSenseEngineException("Failed to Init Handler"); } // getting touchless controller m_touchlessController = m_senseManager.QueryTouchlessController(); if (m_touchlessController == null) { throw new RealSenseEngineException("Failed to Query Touchless Controller"); } }
// Use this for initialization void Start() { rotationType = RotationType.Pinch; //sm = PXCMSession.CreateInstance(); /* Initialize a PXCMSenseManager instance */ sm = PXCMSenseManager.CreateInstance(); if (sm != null) { /* Enable hand tracking and configure the hand module */ pxcmStatus sts = sm.EnableHand(); if (sts == pxcmStatus.PXCM_STATUS_NO_ERROR) { /* Hand module interface instance */ hand = sm.QueryHand(); /* Hand data interface instance */ hand_data = hand.CreateOutput(); // Create hand configuration instance and configure hcfg = hand.CreateActiveConfiguration(); hcfg.EnableAllAlerts(); hcfg.SubscribeAlert(OnFiredAlert); hcfg.EnableNormalizedJoints(true); hcfg.ApplyChanges(); hcfg.Dispose(); /* Initialize the execution pipeline */ if (sm.Init() != pxcmStatus.PXCM_STATUS_NO_ERROR) { OnDisable(); } } } }
private bool InitializeRealSense() { senseManager = PXCMSenseManager.CreateInstance(); if (senseManager == null) { Debug.LogError("Unable to create SenseManager."); return false; } if (senseManager.Enable3DSeg().IsError()) { Debug.LogError("Couldn't enable the Face Module."); return false; } segmentationModule = senseManager.Query3DSeg(); if (segmentationModule == null) { Debug.LogError("Couldn't query the Face Module."); return false; } if (senseManager.Init().IsError()) { Debug.LogError("Unable to initialize SenseManager."); return false; } return true; }
private void InitVideoStream() { senseManager = PXCMSenseManager.CreateInstance(); senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 320, 240, 30); pxcmStatus initStatus = senseManager.Init(); if (initStatus == pxcmStatus.PXCM_STATUS_ITEM_UNAVAILABLE) { // No camera, load data from file... OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "RSSDK clip|*.rssdk|All files|*.*"; ofd.CheckFileExists = true; ofd.CheckPathExists = true; bool?result = ofd.ShowDialog(); if (result == true) { senseManager.captureManager.SetFileName(ofd.FileName, false); initStatus = senseManager.Init(); } } if (initStatus < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception(String.Format("Init failed: {0}", initStatus)); } }
private void startButton_Click(object sender, RoutedEventArgs e) { CurrentIpAdress = ipTextBox.Text; currentPort = portTextBox.Text; senseManager = PXCMSenseManager.CreateInstance(); senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 60); senseManager.EnableFace(); senseManager.Init(); faceModule = senseManager.QueryFace(); faceConfiguration = faceModule.CreateActiveConfiguration(); faceConfiguration.detection.isEnabled = true; expressionConfiguration = faceConfiguration.QueryExpressions(); expressionConfiguration.Enable(); expressionConfiguration.EnableAllExpressions(); faceConfiguration.landmarks.isEnabled = true; faceConfiguration.landmarks.numLandmarks = 78; faceConfiguration.EnableAllAlerts(); faceConfiguration.ApplyChanges(); captureProcess = new Thread(new ThreadStart(CaptureProcess)); captureProcess.Start(); }
private void startCamera() { session = PXCMSession.CreateInstance(); manager = session.CreateSenseManager(); if (manager == null) { Console.WriteLine("Failed"); } manager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 1920, 1080, 30); manager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480, 60); manager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_IR, 640, 480, 60); manager.EnableHand(); PXCMHandConfiguration config = manager.QueryHand().CreateActiveConfiguration(); config.EnableAllAlerts(); config.EnableSegmentationImage(true); config.EnableTrackedJoints(true); config.LoadGesturePack("navigation"); config.EnableAllGestures(true); config.ApplyChanges(); config.Dispose(); manager.Init(); thread = new Thread(new ThreadStart(updateThread)); thread.Start(); }
public MainWindow() { InitializeComponent(); handWaving = false; handTrigger = false; msgTimer = 0; //Instantiate and initialize the SenseManager senseManager = PXCMSenseManager.CreateInstance(); senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30); senseManager.EnableHand(); senseManager.Init(); //Configure the Hand Module hand = senseManager.QueryHand(); handConfig = hand.CreateActiveConfiguration(); handConfig.EnableGesture("v_sign"); handConfig.EnableAllAlerts(); handConfig.ApplyChanges(); // Start the worker thread processingThread = new Thread(new ThreadStart(ProcessingThread)); processingThread.Start(); }
public RealSenseEngine() { m_session = PXCMSession.CreateInstance(); if (m_session == null) { throw new RealSenseEngineException("Failed to create a Session"); } m_senseManager = m_session.CreateSenseManager(); if (m_senseManager == null) { throw new RealSenseEngineException("Failed to create a SenseManager"); } pxcmStatus res = m_senseManager.EnableTouchlessController(); if (res != pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new RealSenseEngineException("Failed to Enable Touchless Controller"); } var handler = new PXCMSenseManager.Handler(); res = m_senseManager.Init(handler); if (res != pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new RealSenseEngineException("Failed to Init Handler"); } // getting touchless controller m_touchlessController = m_senseManager.QueryTouchlessController(); if (m_touchlessController == null) { throw new RealSenseEngineException("Failed to Query Touchless Controller"); } }
private void Initialize() { try { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); // Blobを有効にする var sts = senseManager.EnableBlob(); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("Blobの有効化に失敗しました"); } // パイプラインを初期化する sts = senseManager.Init(); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("初期化に失敗しました"); } // ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); // Blobを初期化する InitializeBlob(); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } }
/** * Constructor of the model * It does all the important stuff to use our camera. Its so FANCY ! * Like enabling all important tracker(Hand, Face), the stream and builds up the configuration. * blib blub */ public Model() { emotions["Anger"] = 0; emotions["Fear"] = 0; emotions["Disgust"] = 0; emotions["Surprise"] = 0; emotions["Joy"] = 0; emotions["Sadness"] = 0; emotions["Contempt"] = 0; width = 1920; height = 1080; framerate = 30; senseManager = PXCMSenseManager.CreateInstance(); senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, width, height, framerate); // Enable Face detection senseManager.EnableFace(); senseManager.Init(); face = senseManager.QueryFace(); faceConfig = face.CreateActiveConfiguration(); faceConfig.SetTrackingMode(PXCMFaceConfiguration.TrackingModeType.FACE_MODE_COLOR_PLUS_DEPTH); faceConfig.detection.isEnabled = true; faceConfig.pose.isEnabled = true; faceConfig.ApplyChanges(); faceConfig.Update(); modules = new List <RSModule>(); }
public static void Start() { // Create an instance of the SenseManager PXCMSession session = PXCMSession.CreateInstance(); if (session == null) { present = false; return; } senseManager = session.CreateSenseManager(); if (senseManager == null) { present = false; return; } //if (bodyTrackingEnabled) // StartBodyTracking(); //if (handTrackingEnabled) // StartHandTracking(); if (faceTrackingEnabled) { StartFace(); } present = true; thread = new System.Threading.Thread(Fetcher); thread.Start(); }
/// <summary> /// Device-specific implementation of Connect. /// Connects the camera. /// </summary> /// <remarks>This method is implicitely called by <see cref="Camera.Connect"/> inside a camera lock.</remarks> /// <seealso cref="Camera.Connect"/> protected override void ConnectImpl() { if (deviceInfo.Count == 0) { ScanForCameras(); } if (deviceInfo.Count == 0) { log.Error(Name + "No device found."); return; } int deviceIndex = 0; ScanForProfiles(deviceIndex); /* Create an instance of the PXCSenseManager interface */ pp = PXCMSenseManager.CreateInstance(); if (pp == null) { log.Error(Name + "Failed to create an SDK pipeline object"); return; } pp.captureManager.FilterByDeviceInfo(deviceInfo[deviceIndex]); //TODO: change this to work with properties currentColorProfile = "YUY2 1920x1080x30"; currentDepthProfile = "DEPTH 640x480x60"; currentIRProfile = "Y8 640x480x60"; PXCMCapture.Device.StreamProfileSet currentProfileSet = new PXCMCapture.Device.StreamProfileSet(); currentProfileSet[PXCMCapture.StreamType.STREAM_TYPE_COLOR] = profiles[currentColorProfile]; currentProfileSet[PXCMCapture.StreamType.STREAM_TYPE_DEPTH] = profiles[currentDepthProfile]; currentProfileSet[PXCMCapture.StreamType.STREAM_TYPE_IR] = profiles[currentIRProfile]; /* Set Color & Depth Resolution */ for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++) { PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s); PXCMCapture.Device.StreamProfile info = currentProfileSet[st]; if (info.imageInfo.format != 0) { Single fps = info.frameRate.max; pp.EnableStream(st, info.imageInfo.width, info.imageInfo.height, fps); } } if (pp.Init() >= pxcmStatus.PXCM_STATUS_NO_ERROR) { } else { log.Error(Name + "An error occured."); } ActivateChannel(ChannelNames.Intensity); ActivateChannel(ChannelNames.ZImage); }
//RealSenseメソッド------------------------------------------------------------------- /// <summary> 機能の初期化 </summary> private bool InitializeRealSense() { try { //SenseManagerを生成 senseManager = PXCMSenseManager.CreateInstance(); //カラーストリームの有効 var sts = senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, COLOR_WIDTH, COLOR_HEIGHT, COLOR_FPS); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("Colorストリームの有効化に失敗しました"); } // Depthストリームを有効にする sts = senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, DEPTH_WIDTH, DEPTH_HEIGHT, DEPTH_FPS); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("Depthストリームの有効化に失敗しました"); } // 手の検出を有効にする sts = senseManager.EnableHand(); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("手の検出の有効化に失敗しました"); } //パイプラインを初期化する //(インスタンスはInit()が正常終了した後作成されるので,機能に対する各種設定はInit()呼び出し後となる) sts = senseManager.Init(); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("パイプラインの初期化に失敗しました"); } //ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); //デバイスを取得する device = senseManager.captureManager.device; //座標変換オブジェクトを作成 projection = device.CreateProjection(); // 手の検出の初期化 InitializeHandTracking(); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } }
/// <summary> /// Starts this instance. /// </summary> public void Start() { if (_sm != null) { throw new ResearchException("Camera is already started."); } _sm = PXCMSenseManager.CreateInstance(); // Configure face detection. if (EnableFace) { _sm.EnableFace(); var faceModule = _sm.QueryFace(); using (PXCMFaceConfiguration faceConfig = faceModule.CreateActiveConfiguration()) { faceConfig.EnableAllAlerts(); faceConfig.pose.isEnabled = true; faceConfig.pose.maxTrackedFaces = 4; if (EnableExpression) { PXCMFaceConfiguration.ExpressionsConfiguration expression = faceConfig.QueryExpressions(); expression.Enable(); expression.EnableAllExpressions(); faceConfig.ApplyChanges(); } } } if (EnableEmotion) { // Configure emotion detection. _sm.EnableEmotion(); } if (EnableStreaming) { // Configure streaming. _sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480); // _sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480); // _sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_IR, 640, 480); } // Event handler for data callbacks. var handler = new PXCMSenseManager.Handler { onModuleProcessedFrame = OnModuleProcessedFrame }; _sm.Init(handler); // GO. Debug.WriteLine("{0} Starting streaming.", Time()); _sm.StreamFrames(false); //Debug.WriteLine("{0} End streaming.", Time()); }
private void Uninitialize() { if (senseManager != null) { senseManager.Dispose(); senseManager = null; } }
// Use this for initialization void Start() { if (!InitializeRealSense()) { senseManager = null; Destroy(gameObject.transform.parent.gameObject); } }
/// <summary> /// コンストラクタ /// /// カメラ画像表示用のWritableBitmapを準備してImageに割り当て /// カメラ制御用のオブジェクトを取得して /// Colorカメラストリームを有効にしてカメラのフレーム取得を開始する /// カメラキャプチャーするためのTaskを準備して開始 /// </summary> public MainWindow() { // 画面コンポーネントを初期化 InitializeComponent(); // ジェスチャー画像表示用Imageを非表示にする HiddenGestureImage(); // カメラ画像書き込み用のWriteableBitmapを準備してImageコントローラーにセット m_ColorWBitmap = new WriteableBitmap(1920, 1080, 96.0, 96.0, PixelFormats.Bgr32, null); ColorCameraImage.Source = m_ColorWBitmap; m_HandSegmentWBitmap = new WriteableBitmap(640, 480, 96.0, 96.0, PixelFormats.Gray8, null); HandSegmentImage.Source = m_HandSegmentWBitmap; m_HandJointWBitmap = new WriteableBitmap(640, 480, 96.0, 96.0, PixelFormats.Bgra32, null); HandJointtImage.Source = m_HandJointWBitmap; // カメラ制御のオブジェクトを取得 m_Session = PXCMSession.CreateInstance(); m_Cm = m_Session.CreateSenseManager(); // Color,Depth,Irストリームを有効にする m_Cm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 1920, 1080, 30); m_Cm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480, 30); m_Cm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_IR, 640, 480, 30); // Hand Trackingを有効化と設定 m_Cm.EnableHand(); PXCMHandModule handModule = m_Cm.QueryHand(); PXCMHandConfiguration handConfig = handModule.CreateActiveConfiguration(); handConfig.SetTrackingMode(PXCMHandData.TrackingModeType.TRACKING_MODE_FULL_HAND); // FULL_HANDモード handConfig.EnableSegmentationImage(true); // SegmentationImageの有効化 handConfig.EnableAllGestures(); // すべてのジェスチャーを補足 handConfig.SubscribeGesture(OnFiredGesture); // ジェスチャー発生時のコールバック関数をセット handConfig.ApplyChanges(); // HandDataのインスタンスを作成 m_HandData = handModule.CreateOutput(); // カメラのフレーム取得開始 pxcmStatus initState = m_Cm.Init(); if (initState < pxcmStatus.PXCM_STATUS_NO_ERROR) { // エラー発生 MessageBox.Show(initState + "\nカメラ初期化に失敗しました。"); return; } // カメラ取得画像をミラーモードにする m_Cm.captureManager.device.SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); // 座標変換のためのProjectionインスタンスを取得 m_Projection = m_Cm.QueryCaptureManager().QueryDevice().CreateProjection(); // カメラキャプチャーをするためのタスクを準備して起動 m_CameraCaptureTask = new Task(() => CaptureCameraProcess()); m_CameraCaptureTask.Start(); }
private void Initialize() { try { // SenseManagerを生成する senceManager = PXCMSenseManager.CreateInstance(); if (senceManager == null) { throw new Exception("SenseManagerの生成に失敗しました"); } // カラーストリームを有効にする pxcmStatus sts = senceManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, COLOR_WIDTH, COLOR_HEIGHT, COLOR_FPS); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) { throw new Exception("カラーストリームの取得に失敗しました"); } InitializeFace(); //描画用の長方形の初期化 rect = new Rectangle[DETECTION_MAXFACES]; for (int i = 0; i < DETECTION_MAXFACES; i++) { rect[i] = new Rectangle(); TranslateTransform transform = new TranslateTransform(COLOR_WIDTH, COLOR_HEIGHT); rect[i].Width = 10; rect[i].Height = 10; rect[i].Stroke = Brushes.Blue; rect[i].StrokeThickness = 3; rect[i].RenderTransform = transform; CanvasForRect.Children.Add(rect[i]); } //追加:表情表示のための初期化 tb = new TextBlock[EXPRESSION_MAXFACES,3]; for (int i = 0; i < EXPRESSION_MAXFACES;i++) { for (int j = 0; j < 3; j++) { tb[i,j] = new TextBlock(); tb[i, j].Width = 200; tb[i, j].Height = 27; tb[i, j].Foreground = new SolidColorBrush(Colors.Red); tb[i, j].FontSize = 20; CanvasPoint.Children.Add(tb[i, j]); } } } catch (Exception ex) { MessageBox.Show(ex.StackTrace); MessageBox.Show("Init:" + ex.Message); Close(); } }
// Use this for initialization void Start() { // Creates an instance of the sense manager to be called later session = PXCMSenseManager.CreateInstance(); //Output an error if there is no instance of the sense manager if (session == null) { Debug.LogError("SenseManager Init Failed!"); } // Enables hand tracking sts = session.EnableHand(); handAnalyzer = session.QueryHand(); sts2 = session.EnableFace(); faceAnalyzer = session.QueryFace(); if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError("PXCSenseManager.EnableHand: " + sts); if (sts2 != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError("PXCSenseManager.EnableFace: " + sts2); // Creates the session sts = session.Init(); sts2 = session.Init(); if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError("PXCSenseManager.Init: " + sts); if (sts2 != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError("PXCSenseManager.Init: " + sts2); // Creates a hand config for future data PXCMHandConfiguration handconfig = handAnalyzer.CreateActiveConfiguration(); PXCMFaceConfiguration faceconfig = faceAnalyzer.CreateActiveConfiguration(); //If there is handconfig instance if (handconfig != null) { handconfig.EnableAllAlerts(); handconfig.ApplyChanges(); handconfig.Dispose(); } if (faceconfig != null) { faceconfig.EnableAllAlerts(); faceconfig.ApplyChanges(); faceconfig.Dispose(); } }
public MovementController(PXCMSenseManager.Handler handler, PXCMHandConfiguration.OnFiredGestureDelegate handGestureHandler, PXCMHandConfiguration.OnFiredAlertDelegate handAlertHandler) { // register event handlers this._handler = handler; _handGestureHandler = handGestureHandler; _handAlertHandler = handAlertHandler; Session = PXCMSession.CreateInstance(); }
public void Init() { var session = PXCMSession.CreateInstance(); _manager = session.CreateSenseManager(); _manager.EnableHand(); var status = _manager.Init(); if (status != NoError) { throw new Exception(status.ToString()); } Task.Factory.StartNew(Loop, TaskCreationOptions.LongRunning); }
public RealSenseSensor() { session = PXCMSession.CreateInstance(); this.manager = session.CreateSenseManager(); ; this.isColorStreamEnabled = false; this.isDepthStreamEnabled = false; this.isGestureRecognitionEnabled = false; this.isHandsStreamEnabled = false; this.is3DSegEnabled = false; this.isEmotionEnabled = false; parentContext = SynchronizationContext.Current; }
public RealSenseCamera() { Session = PXCMSession.CreateInstance(); _manager = Session.CreateSenseManager(); ConfigurePoses(); ConfigureGestures(); _speech = new Speech(); _eyesThresholds = new Dictionary<Direction, double> { { Direction.Up, 10}, { Direction.Down, 10}, { Direction.Left, 10}, { Direction.Right, 10} }; Debug.WriteLine("SDK Version {0}.{1}", Session.QueryVersion().major, Session.QueryVersion().minor); }
public HandsRecognition(int mod) { try { session = PXCMSession.CreateInstance(); mode = mod; if (mod == 0) { rightcp = new checkPiano(); leftcp = new checkPiano(); } else if (mod == 1) { rightcp = new checkDrum(); leftcp = new checkDrum(); } _disconnected = false; instance = session.CreateSenseManager(); if (instance == null) { MessageBox.Show("Failed creating SenseManager", "OnAlert"); return; } /* Set Module */ pxcmStatus status = instance.EnableHand();//form.GetCheckedModule()); handAnalysis = instance.QueryHand(); if (status != pxcmStatus.PXCM_STATUS_NO_ERROR || handAnalysis == null) { MessageBox.Show("Failed Loading Module", "OnAlert"); return; } handler = new PXCMSenseManager.Handler(); handler.onModuleProcessedFrame = new PXCMSenseManager.Handler.OnModuleProcessedFrameDelegate(OnNewFrame); handData = handAnalysis.CreateOutput(); } catch { MessageBox.Show("Init Failed."); Environment.Exit(0); } }
public Camera(params PXCMHandConfiguration.OnFiredGestureDelegate[] dlgts) { // Create the manager this._session = PXCMSession.CreateInstance(); this._mngr = this._session.CreateSenseManager(); // streammmm PXCMVideoModule.DataDesc desc = new PXCMVideoModule.DataDesc(); desc.deviceInfo.streams = PXCMCapture.StreamType.STREAM_TYPE_COLOR | PXCMCapture.StreamType.STREAM_TYPE_DEPTH; this._mngr.EnableStreams(desc); //this._mngr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, Camera.WIDTH, Camera.HEIGHT, 30); //this._mngr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, Camera.WIDTH, Camera.HEIGHT, 30); // Hands this._mngr.EnableHand(); this._hand = this._mngr.QueryHand(); this._handData = this._hand.CreateOutput(); // Hands config PXCMHandConfiguration conf = this._hand.CreateActiveConfiguration(); conf.EnableGesture("spreadfingers", false); conf.EnableGesture("thumb_up", false); // Subscribe hands alerts conf.EnableAllAlerts(); conf.SubscribeAlert(this.onFiredAlert); // Subscribe all gestures foreach (PXCMHandConfiguration.OnFiredGestureDelegate subscriber in dlgts) { conf.SubscribeGesture(subscriber); } // and the private one for debug conf.SubscribeGesture(this.onFiredGesture); // Apply it all conf.ApplyChanges(); // Set events this._handler = new PXCMSenseManager.Handler(); this._handler.onModuleProcessedFrame = this.onModuleProcessedFrame; this._mngr.Init(this._handler); }
public Form1() { InitializeComponent(); vol = new float[6] { 1F, 1F, 0F, 1F, 0.5F, 0F }; textVolume.Text = vol[3].ToString(); textSpeed.Text = vol[0].ToString(); textPanorama.Text = vol[4].ToString(); thread = new System.Threading.Thread(DoRecognition); flag = 0; oscManager1 = new OscManager(); oscManager1.DestIP = "127.0.0.1"; // Create the SenseManager instance sm = PXCMSenseManager.CreateInstance(); // Enable hand tracking sm.EnableHand(); // Get a hand instance here for configuration PXCMHandModule hand = sm.QueryHand(); // Initialize and stream data. PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler { onModuleProcessedFrame = OnModuleProcessedFrame }; sm.Init(handler); PXCMHandConfiguration handConfiguration = sm.QueryHand().CreateActiveConfiguration(); handConfiguration.EnableGesture("thumb_down"); handConfiguration.EnableGesture("thumb_up"); handConfiguration.EnableGesture("v_sign"); handConfiguration.EnableGesture("spreadfingers"); handConfiguration.EnableGesture("fist"); handConfiguration.EnableGesture("full_pinch"); handConfiguration.ApplyChanges(); if (handConfiguration == null) { Console.WriteLine("Failed Create Configuration"); Console.WriteLine("That`s all..."); Console.ReadKey(); } logTextBox.Text = DateTime.Now.ToString("hh:mm:ss") + " Started" + "\n" + logTextBox.Text; }
public Form1(PXCMSession session) { InitializeComponent(); //_timer = null; thread = new MyBeautifulThread(DoRecognition); flagThread = 0; LightState = 0; flagLight = 0; WindState = 0; flagWind = 0; SendState = 0; sm = PXCMSenseManager.CreateInstance(); sm.EnableHand(); PXCMHandModule hand = sm.QueryHand(); sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 320, 240, 60); PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler { onModuleProcessedFrame = OnModuleProcessedFrame }; sm.Init(handler); PXCMHandConfiguration handConfiguration = sm.QueryHand().CreateActiveConfiguration(); handConfiguration.EnableGesture("wave"); handConfiguration.EnableGesture("swipe_up"); handConfiguration.EnableGesture("thumb_up"); handConfiguration.EnableGesture("tap"); handConfiguration.ApplyChanges(); if (handConfiguration == null) { Console.WriteLine("Failed Create Configuration"); Console.WriteLine("That`s all..."); Console.ReadKey(); } logTextBox.Text = DateTime.Now.ToString("hh:mm:ss") + " Started" + "\n" + logTextBox.Text; }
public override void Listen() { // attach the controller to the PXCM sensor _senseManager = Session.CreateSenseManager(); _senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30); _senseManager.EnableHand(); _handModule = _senseManager.QueryHand(); _handData = _handModule.CreateOutput(); _handConfiguration = _handModule.CreateActiveConfiguration(); _handConfiguration.SubscribeGesture(_handGestureHandler); _handConfiguration.SubscribeAlert(_handAlertHandler); _handConfiguration.EnableAlert(PXCMHandData.AlertType.ALERT_HAND_TRACKED); _handConfiguration.EnableAlert(PXCMHandData.AlertType.ALERT_HAND_CALIBRATED); _handConfiguration.EnableGesture("full_pinch"); _handConfiguration.EnableGesture("thumb_up"); _handConfiguration.ApplyChanges(); _senseManager.Init(_handler); sensorActive = true; _senseManager.StreamFrames(true); _senseManager.Close(); }
private void Initialize() { try { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); // カラーストリームを有効にする var sts = senseManager.EnableStream( PXCMCapture.StreamType.STREAM_TYPE_COLOR, COLOR_WIDTH, COLOR_HEIGHT, COLOR_FPS ); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "カラーストリームの有効化にしました" ); } // セグメンテーションを有効にする sts = senseManager.Enable3DSeg(); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "セグメンテーションの有効化にしました" ); } // パイプラインを初期化する sts = senseManager.Init(); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "初期化に失敗しました" ); } // ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL ); // セグメンテーションオブジェクトを取得する segmentation = senseManager.Query3DSeg(); if ( segmentation == null ) { throw new Exception( "セグメンテーションの取得に失敗しました" ); } } catch ( Exception ex ) { MessageBox.Show( ex.Message ); Close(); } }
private void Initialize() { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); // カラーストリームを有効にする pxcmStatus sts = senseManager.EnableStream( PXCMCapture.StreamType.STREAM_TYPE_DEPTH, DEPTH_WIDTH, DEPTH_HEIGHT, DEPTH_FPS ); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "Depthストリームの有効化に失敗しました" ); } // パイプラインを初期化する sts = senseManager.Init(); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "初期化に失敗しました" ); } // ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL ); }
private void Initialize() { try { // SenseManagerを生成する senseManager = PXCMSenseManager.CreateInstance(); // Depthストリームを有効にする var sts = senseManager.EnableStream( PXCMCapture.StreamType.STREAM_TYPE_DEPTH, DEPTH_WIDTH, DEPTH_HEIGHT, DEPTH_FPS ); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "Depthストリームの有効化に失敗しました" ); } // 手の検出を有効にする sts = senseManager.EnableHand(); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "手の検出の有効化に失敗しました" ); } // パイプラインを初期化する sts = senseManager.Init(); if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) { throw new Exception( "初期化に失敗しました" ); } // ミラー表示にする senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode( PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL ); // 手の検出の初期化 InitializeHandTracking(); } catch ( Exception ex ) { MessageBox.Show( ex.Message ); Close(); } }
// RS private void STButton_Click(object sender, RoutedEventArgs e) { EXButton.IsEnabled = true; STButton.IsEnabled = false; // init the sense manager _senseManager = PXCMSenseManager.CreateInstance(); // enable hand analysis in the multimodal pipeline _senseManager.EnableTouchlessController(); // init the pipeline if (_senseManager.Init() < pxcmStatus.PXCM_STATUS_NO_ERROR) { MessageBox.Show("RealSense Camera init failed"); } // get an instance of the touchless control _touchlessController = _senseManager.QueryTouchlessController(); // register fo ux event _touchlessController.SubscribeEvent(OnTouchlessControllerUXEventHandler); //event _touchlessController.SubscribeAlert(OnFiredAlertEventHandler); //alert // configuration pxcmStatus rc; PXCMTouchlessController.ProfileInfo pInfo; rc = _touchlessController.QueryProfile(out pInfo); pInfo.config = PXCMTouchlessController.ProfileInfo.Configuration.Configuration_Allow_Zoom | PXCMTouchlessController.ProfileInfo.Configuration.Configuration_Allow_Selection | PXCMTouchlessController.ProfileInfo.Configuration.Configuration_Allow_Back; rc = _touchlessController.SetProfile(pInfo); // configure hand module _hand = _senseManager.QueryHand(); _handConfig = _hand.CreateActiveConfiguration(); _handConfig.EnableGesture("thumb_up", true); // true is importment _handConfig.EnableGesture("v_sign", true); _handConfig.SubscribeGesture(OnFiredGestureEventHandler); _handConfig.ApplyChanges(); // processing loop _processingThread = new Thread(new ThreadStart(ProcessingThread)); _processingThread.Start(); }
public FaceTrackerThread() { running = true; senseManager = PXCMSenseManager.CreateInstance(); senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 60); senseManager.EnableFace(); senseManager.Init(); face = senseManager.QueryFace(); faceConfiguration = face.CreateActiveConfiguration(); faceConfiguration.detection.isEnabled = true; expressionConfiguration = faceConfiguration.QueryExpressions(); expressionConfiguration.Enable(); expressionConfiguration.EnableAllExpressions(); //Gaze detection gazec = faceConfiguration.QueryGaze(); gazec.isEnabled = true; faceConfiguration.ApplyChanges(); faceConfiguration.EnableAllAlerts(); faceConfiguration.ApplyChanges(); }
public MainWindow() { InitializeComponent(); _senseManager = PXCMSenseManager.CreateInstance(); _senseManager.EnableHand(); var handManager = _senseManager.QueryHand(); _handConfig = handManager.CreateActiveConfiguration(); _handConfig.EnableGesture("thumb_up"); _handConfig.EnableGesture("thumb_down"); _handConfig.EnableAllAlerts(); _handConfig.ApplyChanges(); var status = _senseManager.Init(); if (status >= pxcmStatus.PXCM_STATUS_NO_ERROR) { _cancellationTokenSource = new CancellationTokenSource(); _task = Task.Factory.StartNew(x => ProcessInput(_cancellationTokenSource.Token), TaskCreationOptions.LongRunning, _cancellationTokenSource.Token); } }
private void ConfigureRealSense() { PXCMFaceModule faceModule; PXCMFaceConfiguration faceConfig; // Start the SenseManager and session senseManager = PXCMSenseManager.CreateInstance(); captureManager = senseManager.captureManager; // Enable the color stream senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 60); //senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480, 0); // Enable the face module senseManager.EnableFace(); faceModule = senseManager.QueryFace(); faceConfig = faceModule.CreateActiveConfiguration(); // Configure for 3D face tracking (if camera cannot support depth it will revert to 2D tracking) faceConfig.SetTrackingMode(PXCMFaceConfiguration.TrackingModeType.FACE_MODE_COLOR_PLUS_DEPTH); // Enable facial recognition recognitionConfig = faceConfig.QueryRecognition(); recognitionConfig.Enable(); //Enable Landmark Detection faceConfig.landmarks.isEnabled = true; // Create a recognition database PXCMFaceConfiguration.RecognitionConfiguration.RecognitionStorageDesc recognitionDesc = new PXCMFaceConfiguration.RecognitionConfiguration.RecognitionStorageDesc(); recognitionDesc.maxUsers = DatabaseUsers; //recognitionConfig.CreateStorage(DatabaseName, out recognitionDesc); //recognitionConfig.UseStorage(DatabaseName); LoadDatabaseFromFile(); recognitionConfig.SetRegistrationMode(PXCMFaceConfiguration.RecognitionConfiguration.RecognitionRegistrationMode.REGISTRATION_MODE_CONTINUOUS); // Apply changes and initialize faceConfig.ApplyChanges(); senseManager.Init(); faceData = faceModule.CreateOutput(); // Mirror image senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL); // Release resources faceConfig.Dispose(); faceModule.Dispose(); }
/// <summary> /// Stops to stop the camera. /// </summary> public void Stop() { if (_sm != null) { _sm.Close(); _sm.Dispose(); _sm = null; } }
/// <summary> /// Starts this instance. /// </summary> public void Start() { if (_sm != null) throw new ResearchException("Camera is already started."); _sm = PXCMSenseManager.CreateInstance(); // Configure face detection. if (EnableFace) { _sm.EnableFace(); var faceModule = _sm.QueryFace(); using (PXCMFaceConfiguration faceConfig = faceModule.CreateActiveConfiguration()) { faceConfig.EnableAllAlerts(); faceConfig.pose.isEnabled = true; faceConfig.pose.maxTrackedFaces = 4; if (EnableExpression) { PXCMFaceConfiguration.ExpressionsConfiguration expression = faceConfig.QueryExpressions(); expression.Enable(); expression.EnableAllExpressions(); faceConfig.ApplyChanges(); } } } if (EnableEmotion) { // Configure emotion detection. _sm.EnableEmotion(); } if (EnableStreaming) { // Configure streaming. _sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480); // _sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480); // _sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_IR, 640, 480); } // Event handler for data callbacks. var handler = new PXCMSenseManager.Handler { onModuleProcessedFrame=OnModuleProcessedFrame }; _sm.Init(handler); // GO. Debug.WriteLine("{0} Starting streaming.", Time()); _sm.StreamFrames(false); //Debug.WriteLine("{0} End streaming.", Time()); }
//Close any ongoing Session void OnDisable() { if (smoother3D != null) { for (int i = 0; i < MaxHands; i++) { if (smoother3D[i] != null) { for (int j = 0; j < MaxJoints; j++) { smoother3D[i][j].Dispose(); smoother3D[i][j] = null; } } } smoother3D = null; } if (smoother != null) { smoother.Dispose(); smoother = null; } if (sm != null) { sm.Close(); sm.Dispose(); sm = null; } }
public void SetManualMode() { // REALSENSE /* Initialize a PXCMSenseManager instance */ sm = PXCMSenseManager.CreateInstance(); if (sm == null) Debug.LogError("SenseManager Initialization Failed"); /* Enable hand tracking and retrieve an hand module instance to configure */ sts = sm.EnableHand(); handAnalyzer = sm.QueryHand(); if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError("PXCSenseManager.EnableHand: " + sts); /* Initialize the execution pipeline */ sts = sm.Init(); if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) Debug.LogError("PXCSenseManager.Init: " + sts); /* Retrieve the the DataSmoothing instance */ sm.QuerySession().CreateImpl<PXCMSmoother>(out smoother); /* Create a 3D Weighted algorithm */ smoother3D = new PXCMSmoother.Smoother3D[MaxHands][]; /* Configure a hand - Enable Gestures and Alerts */ PXCMHandConfiguration hcfg = handAnalyzer.CreateActiveConfiguration(); if (hcfg != null) { hcfg.EnableAllGestures(); hcfg.EnableAlert(PXCMHandData.AlertType.ALERT_HAND_NOT_DETECTED); hcfg.SubscribeGesture(OnFiredGesture); hcfg.ApplyChanges(); hcfg.Dispose(); } // handAnalyzer = sm.QueryHand(); ////// curMode = userMode = DroneMode.Manual; targetBehavior = targetDirectBehavior; EnterFreeMovementState(); }