Ejemplo n.º 1
0
        public void InitializeStream(int resolutionWidth, int resolutionHeight, float framesPerSecond)
        {
            // Creating a SDK session
            Session = PXCMSession.CreateInstance();

            // Creating the SenseManager
            SenseManager = Session.CreateSenseManager();
            if (SenseManager == null)
            {
                Status_pipeline = "Failed to create an SDK pipeline object";
                //Console.WriteLine("Failed to create the SenseManager object.");
                return;
            }
            else
            {
                Status_pipeline = "Pipeline created";
            }

            foreach (var stream in StreamType)
            {
                // Enabling the stream
                pxcmStatus enableStreamStatus = SenseManager.EnableStream(stream, resolutionWidth, resolutionHeight, framesPerSecond);

                if (enableStreamStatus != pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    throw new InvalidRealSenseStatusException(enableStreamStatus, string.Format("Failed to enable the {0} stream. Return code: {1}", StreamType, enableStreamStatus));
                }
            }
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        private static ToolStripMenuItem m_moduleMenuItem;                           // ModuleメニューのItemリスト

        public MainForm(PXCMSession session)
        {
            InitializeComponent();

            m_faceTextOrganizer = new FaceTextOrganizer();         // インスタンス生成
            m_deviceMenuItem    = new ToolStripMenuItem("Device"); // Deviceメニューのインスタンス生成
            m_moduleMenuItem    = new ToolStripMenuItem("Module"); // Moduleメニューのインスタンス生成
            Session             = session;

            CreateResolutionMap();
            PopulateDeviceMenu();
            PopulateModuleMenu();
            PopulateProfileMenu();

            InitializeUserSettings();
            InitializeCheckboxes();
            DisableUnsupportedAlgos();

            FormClosing += MainForm_FormClosing;
            Panel.Paint += Panel_Paint;

            // deviceが一つの時は自動スタート
            if (m_deviceMenuItem.DropDownItems.Count == 1)
            {
                Start_Click(null, null); // 起動時にカメラをonにする
            }// else if(m_deviceMenuItem.DropDownItems.Count == 0)
             //{
             //    UpdateStatus("カメラを接続\nしてください。", Label.SmileLabel);
             //} else
             //{
             //    UpdateStatus("Deviceから\nカメラを選択\nしてください。", Label.SmileLabel);
             //}
        }
Ejemplo n.º 4
0
        static void Main()
        {
            mouseDriven myMouse = new mouseDriven();
            Webdriver   selen   = new Webdriver("http://www.reddit.com");

            bool mode = true;

            Camera cam = new Camera(myMouse, selen, mode, 1);

            bool setup = true;

            cam.aTimer           = new System.Timers.Timer(Camera.timer);
            cam.aTimer.Elapsed  += cam.OnTimedEvent;
            cam.aTimer.AutoReset = true;
            Console.WriteLine("The timer should fire every {0} milliseconds.",
                              cam.aTimer.Interval);
            cam.aTimer.Enabled = true;

            if (setup)    //for debugging/keyboard, set this to false before compiling
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                PXCMSession session;
                pxcmStatus  sts = PXCMSession.CreateInstance(out session);
                if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    Application.Run(new MainForm(session));
                    session.Dispose();
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        // テキストを渡すスクリプトの参照
        textMesh   = GameObject.Find("Word");
        controller = textMesh.GetComponent <TextController>();

        // 音声認識セッションの初期化
        session = PXCMSession.CreateInstance();
        source  = session.CreateAudioSource();

        PXCMAudioSource.DeviceInfo dinfo = null;

        source.QueryDeviceInfo(1, out dinfo);
        source.SetDevice(dinfo);
        Debug.Log(dinfo.name);

        session.CreateImpl <PXCMSpeechRecognition>(out sr);

        PXCMSpeechRecognition.ProfileInfo pinfo;
        sr.QueryProfile(out pinfo);
        pinfo.language = PXCMSpeechRecognition.LanguageType.LANGUAGE_JP_JAPANESE;
        sr.SetProfile(pinfo);

        handler = new PXCMSpeechRecognition.Handler();
        handler.onRecognition = (x) => controller.SetText(x.scores[0].sentence);
        sr.SetDictation();
        sr.StartRec(source, handler);
    }
Ejemplo n.º 6
0
 public void EnableRecognition(SupportedLanguage language)
 {
     _language = language;
     _session = PXCMSession.CreateInstance();
     var audioSource = FindAudioSource();
     _session.CreateImpl(out _speechRecognition);
     for (int i = 0; ; i++) {
         PXCMSpeechRecognition.ProfileInfo profile;
         if (_speechRecognition.QueryProfile(i, out profile) != RealSenseCamera.NoError) {
             break;
         }
         var languageLabel = profile.language.ToString();
         SupportedLanguage sdkLanguage = SupportedLanguageMapper.FromString(languageLabel);
         if (sdkLanguage != SupportedLanguage.NotSpecified) {
             _recognitionProfiles.Add(sdkLanguage, profile);
         }
     }
     if (language == SupportedLanguage.NotSpecified) {
         language = _recognitionProfiles.Keys.First();
     }
     if (!_recognitionProfiles.ContainsKey(language)) {
         throw new LanguageNotSupportedException(language);
     }
     _speechRecognition.SetProfile(_recognitionProfiles[language]);
     _speechRecognition.SetDictation();
     _speechRecognition.StartRec(audioSource, _speechRecognitionHandler);
 }
Ejemplo n.º 7
0
    public void Start()
    {
        filePath = Application.dataPath + @"\LogData.txt";
        File.CreateText(filePath);

        //インスタンスの生成
        session = PXCMSession.CreateInstance();
        //音声データの入力
        source = session.CreateAudioSource();

        PXCMAudioSource.DeviceInfo dinfo = null;

        //デバイスを検出して出力
        source.QueryDeviceInfo(0, out dinfo);
        source.SetDevice(dinfo);
        Debug.Log(dinfo.name);

        //音声認識
        session.CreateImpl <PXCMSpeechRecognition>(out sr);

        //音声認識の初期設定
        PXCMSpeechRecognition.ProfileInfo pinfo;
        sr.QueryProfile(out pinfo);
        pinfo.language = PXCMSpeechRecognition.LanguageType.LANGUAGE_JP_JAPANESE;
        sr.SetProfile(pinfo);

        //handlerにメソッドを渡す工程
        handler = new PXCMSpeechRecognition.Handler();
        handler.onRecognition = (x) => Dataoutput(x.scores[0].sentence, x.duration);
        sr.SetDictation();
    }
Ejemplo n.º 8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            PXCMSession session = null;

            session = PXCMSession.CreateInstance();
            if (session != null)
            {
                // Optional steps to send feedback to Intel Corporation to understand how often each SDK sample is used.
                PXCMMetadata md = session.QueryInstance <PXCMMetadata>();
                if (md != null)
                {
                    string sample_name = "Hands Viewer CS";
                    md.AttachBuffer(1297303632, System.Text.Encoding.Unicode.GetBytes(sample_name));
                }
                Form splash = new Form1();
                splash.Show();
                Thread.Sleep(3000);
                splash.Close();
                Application.Run(new MainForm(session));
                session.Dispose();
            }
        }
Ejemplo n.º 9
0
        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;
        }
Ejemplo n.º 10
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();

            this.session = session;
            PopulateDeviceMenu();
            FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            pictureBox1.Paint += new PaintEventHandler(pictureBitmap_Paint);

            this.comboBoxQualityEstimator.Items.AddRange(
                new object[] {"ColorClusters"
                });

            this.comboBoxColoringMethod.Items.AddRange(
                new object[] {"None"
                        , "ByScore"
                        , "ByClusterMeanColor"
                        , "ByClusterMaxColor"
                        , "ByClusterDepth"
                });

            this.cameraSettingsTrackBars = new TrackBar[]
            {
                this.trackBarCamDepthCofidenceThreshold,
                this.trackBarCamIvcamAccuracy,
                this.trackBarCamIVCAMFilterOption,
                this.trackBarCamIVCAMLaserPower,
                this.trackBarCamIVCAMMotionRangeTradeOff
            };

            this.resetAllParams();
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 12
0
        /**
         * Initialise View and start updater Thread
         */
        public CameraView(Model model)
        {
            this.model = model;

            session = PXCMSession.CreateInstance();

            if (session == null) // Something went wrong, session could not be initialised
            {
                Console.WriteLine("F**k!");
                Application.Exit();
                return;
            }

            iv = session.QueryVersion();
            String versionString = "v" + iv.major + "." + iv.minor;

            Console.WriteLine(versionString);
            Text = versionString;


            pb = new PictureBox();
            // Set size
            pb.Bounds = new Rectangle(0, 0, model.Width, model.Height);
            // init UI
            this.Bounds = new Rectangle(0, 0, model.Width, model.Height);
            this.Controls.Add(pb);
            FormClosed += new FormClosedEventHandler(Quit);
            this.Show();
            // Start Updater Thread
            updaterThread = new Thread(this.update);
            updaterThread.Start();
        }
Ejemplo n.º 13
0
        void OnLoaded(object sender, RoutedEventArgs e)
        {
            // Create our 'session' with the camera.
            this.session = PXCMSession.CreateInstance();

            // The SenseManager is really our main object for all our config
            // and functionality.
            this.senseManager = this.session.CreateSenseManager();

            // Switch on the COLOR stream.
            var status = this.senseManager.EnableStream(
                PXCMCapture.StreamType.STREAM_TYPE_COLOR, 0, 0);

            // Switch on and configure face data.
            this.ConfigureFace();

            if (status == pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                // We can either poll for frames or we can have them pushed at
                // us. Here we take the latter approach and have the frames
                // delivered to us.
                status = this.senseManager.Init(
                    new PXCMSenseManager.Handler()
                {
                    onNewSample            = this.OnNewSample,
                    onModuleProcessedFrame = this.OnModuleProcessedFrame
                });

                if (status == pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    // Set it going - false here means "don't block"
                    this.senseManager.StreamFrames(false);
                }
            }
        }
Ejemplo n.º 14
0
        public Senz3DIntel()
        {
            UpdateAdaptiveSensingMaskCommand = new RelayCommand(OnUpdateAdaptiveSensingMask);

            PXCMSession session;
            var         sts = PXCMSession.CreateInstance(out session);

            Debug.Assert(sts >= pxcmStatus.PXCM_STATUS_NO_ERROR, "could not create session instance");

            PropertyChanged += (s, e) =>
            {
                switch (e.PropertyName)
                {
                case DepthConfidenceThresholdPropertyName:
                    if (_device != null)
                    {
                        _device.SetProperty(PXCMCapture.Device.Property.PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, DepthConfidenceThreshold);
                    }
                    break;

                case ColorImageProfilePropertyName:
                    //Stop();
                    _rgbInDepthROI = new Rectangle(0, 0, 0, 0);
                    //Thread.Sleep(2000);
                    //Start();
                    break;
                }
            };
        }
Ejemplo n.º 15
0
        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");
            }
        }
Ejemplo n.º 16
0
        public override void OnImage(PXCMImage image)
        {
            #region 攝影機影像顯示
            //Debug.WriteLine("收到影像,格式 : " + image.imageInfo.format);
            PXCMSession session = QuerySession();
            Bitmap      bitmapimage;
            image.QueryBitmap(session, out bitmapimage);
            BitmapSource source = ToWpfBitmap(bitmapimage);
            if (image.imageInfo.format == PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH)
            {
                MainWindow.mainwin.ProcessDepthImage(source);
            }
            else if (image.imageInfo.format == PXCMImage.ColorFormat.COLOR_FORMAT_RGB24)
            {
                MainWindow.mainwin.ProcessColorImage(source);
            }
            image.Dispose();
            #endregion

            PXCMGesture gesture = QueryGesture();
            if (gesture != null)
            {
                PXCMGesture.GeoNode node;
                //PXCMGesture.GeoNode[] nodes = new PXCMGesture.GeoNode[11];
                gesture.QueryNodeData(0, NeedNode(), out node);
                //gesture.QueryNodeData(0, NeedNodes(), nodes);
                ProcessNode(node);
                //ProcessNodes(nodes);
            }
        }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            // URLを受け取る
            Console.WriteLine("args.length:" + args.Length);
            if (args.Length > 0)
            {
                string arg1  = args[0];                                        // URL全体を取得
                string param = Regex.Match(arg1, @"\+?:(.*)").Groups[1].Value; //パラメータの取り出し
                if (Regex.IsMatch(arg1, "[&=]"))
                {
                    arg1 = HttpUtility.UrlDecode(arg1); // URLデコードする
                    Console.WriteLine(arg1);
                }
                string[] argwork = arg1.Split(':');
                argData = argwork[1];
            }
            //argData = "s1234"; // LocalTest用
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            PXCMSession session = PXCMSession.CreateInstance();

            if (session != null)
            {
                Application.Run(new MainForm(session));
                session.Dispose();
            }
        }
Ejemplo n.º 18
0
        /// <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();
        }
Ejemplo n.º 19
0
        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();
        }
        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");
            }
        }
Ejemplo n.º 21
0
    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();
    }
 public MainForm(PXCMSession session)
 {
     this.session = session;
     PopulateSource();
     PopulateModule();
     PopulateLanguage();
 }
Ejemplo n.º 23
0
        public void EnableRecognition(SupportedLanguage language)
        {
            _session = PXCMSession.CreateInstance();
            var audioSource = FindAudioSource();

            _session.CreateImpl(out _speechRecognition);
            for (int i = 0; ; i++)
            {
                PXCMSpeechRecognition.ProfileInfo profile;
                if (_speechRecognition.QueryProfile(i, out profile) != Errors.NoError)
                {
                    break;
                }
                var languageLabel             = profile.language.ToString();
                SupportedLanguage sdkLanguage = SupportedLanguageMapper.FromString(languageLabel);
                if (sdkLanguage != SupportedLanguage.NotSpecified)
                {
                    _recognitionProfiles.Add(sdkLanguage, profile);
                }
            }
            if (language == SupportedLanguage.NotSpecified)
            {
                language = _recognitionProfiles.Keys.First();
            }
            if (!_recognitionProfiles.ContainsKey(language))
            {
                throw new LanguageNotSupportedException(language);
            }
            _speechRecognition.SetProfile(_recognitionProfiles[language]);
            _speechRecognition.SetDictation();
            _speechRecognition.StartRec(audioSource, _speechRecognitionHandler);
        }
Ejemplo n.º 24
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            session = PXCMSession.CreateInstance();

            if (session != null)
            {
                // Optional steps to send feedback to Intel Corporation to understand how often each SDK sample is used.
                PXCMMetadata md = session.QueryInstance<PXCMMetadata>();
                if (md != null)
                {
                    string sample_name = "Hands Viewer CS";
                    md.AttachBuffer(1297303632, System.Text.Encoding.Unicode.GetBytes(sample_name));
                }
                Monitor first = new Monitor();
                Console.WriteLine("Start monitor\n");
                Console.WriteLine("Choose instrument:\n0 for piano\n1 for drum");
                int mode = Int32.Parse(Console.ReadLine());

                first.Start(mode);
                session.Dispose();
            }
        }
 public AudioRecorder(PXCMSession session, string timestamp)
 {
     this.session         = session;
     this.isRecording     = false;
     this.recordingThread = new Thread(recording);
     this.timestamp       = timestamp;
 }
Ejemplo n.º 26
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();

            this.session = session;
            PopulateDeviceMenu();
            FormClosing       += new FormClosingEventHandler(MainForm_FormClosing);
            pictureBox1.Paint += new PaintEventHandler(pictureBitmap_Paint);

            this.comboBoxQualityEstimator.Items.AddRange(
                new object[] { "ColorClusters" });

            this.comboBoxColoringMethod.Items.AddRange(
                new object[] { "None"
                               , "ByScore"
                               , "ByClusterMeanColor"
                               , "ByClusterMaxColor"
                               , "ByClusterDepth" });

            this.cameraSettingsTrackBars = new TrackBar[]
            {
                this.trackBarCamDepthCofidenceThreshold,
                this.trackBarCamIvcamAccuracy,
                this.trackBarCamIVCAMFilterOption,
                this.trackBarCamIVCAMLaserPower,
                this.trackBarCamIVCAMMotionRangeTradeOff
            };

            this.resetAllParams();
        }
Ejemplo n.º 27
0
        public MainFormGR(PXCMSession session, MainScreen mainScreen)
        {
            InitializeComponent();
            this.mainScreen = mainScreen;
            this.session = session;
            PopulateDeviceMenu();
            PopulateModuleMenu();
            FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            Panel2.Paint += new PaintEventHandler(Panel_Paint);

            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 2000;
            timer.Start();

            pictures = new Hashtable();
            pictures[PXCMGesture.Gesture.Label.LABEL_HAND_CIRCLE] = Properties.Resources.circle;
            pictures[PXCMGesture.Gesture.Label.LABEL_HAND_WAVE] = Properties.Resources.wave;
            pictures[PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN] = Properties.Resources.swipe_down;
            pictures[PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_LEFT] = Properties.Resources.swipe_left;
            pictures[PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_RIGHT] = Properties.Resources.swipe_right;
            pictures[PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP] = Properties.Resources.swipe_up;
            pictures[PXCMGesture.Gesture.Label.LABEL_POSE_BIG5] = Properties.Resources.big5;
            pictures[PXCMGesture.Gesture.Label.LABEL_POSE_PEACE] = Properties.Resources.peace;
            pictures[PXCMGesture.Gesture.Label.LABEL_POSE_THUMB_DOWN] = Properties.Resources.thumb_down;
            pictures[PXCMGesture.Gesture.Label.LABEL_POSE_THUMB_UP] = Properties.Resources.thumb_up;
        }
Ejemplo n.º 28
0
        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();
        }
Ejemplo n.º 29
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            #region RealSense SDK Init
            RealSenseObjects.Session = PXCMSession.CreateInstance();
            if (RealSenseObjects.Session == null)
            {
                MessageBox.Show(
                    "RealSense Session初始化失敗,請確認您有安裝SDK。",
                    "初始化失敗",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            #endregion

            MainForm form = new MainForm();
            Application.Run(form);
            if (!form.IsDisposed)  //尚未釋放資源就關閉
            {
                form.realSenseProgram.moduleConfiguration.Dispose();
                form.realSenseProgram.realSenseManager.Close();
                form.realSenseProgram.realSenseManager.Dispose();
            }
            RealSenseObjects.Session.Dispose();//釋放資源
        }
Ejemplo n.º 30
0
        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);
            }
        }
Ejemplo n.º 31
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();
            /* Put stream menu items to array */
            streamMenus[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_COLOR)] = ColorMenu;
            streamMenus[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_DEPTH)] = DepthMenu;
            streamMenus[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_IR)]    = IRMenu;
            streamMenus[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_LEFT)]  = LeftMenu;
            streamMenus[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_RIGHT)] = RightMenu;
            /* Put stream buttons to array */
            streamButtons[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_COLOR)] = Color;
            streamButtons[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_DEPTH)] = Depth;
            streamButtons[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_IR)]    = IR;
            streamButtons[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_LEFT)]  = IRLeft;
            streamButtons[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_RIGHT)] = IRRight;

            /* Put panels buttons to array */
            streamPanels[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_COLOR)] = ColorPanel;
            streamPanels[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_DEPTH)] = DepthPanel;
            streamPanels[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_IR)]    = IRPanel;
            streamPanels[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_LEFT)]  = IRLeftPanel;
            streamPanels[PXCMCapture.StreamTypeToIndex(PXCMCapture.StreamType.STREAM_TYPE_RIGHT)] = IRRightPanel;

            this.session            = session;
            streaming.UpdateStatus += new EventHandler <UpdateStatusEventArgs>(UpdateStatusHandler);
            streaming.RenderFrame  += new EventHandler <RenderFrameEventArgs>(RenderFrameHandler);
            FormClosing            += new FormClosingEventHandler(FormClosingHandler);

            ColorPanel.Paint    += new PaintEventHandler(PaintHandler);
            DepthPanel.Paint    += new PaintEventHandler(PaintHandler);
            IRPanel.Paint       += new PaintEventHandler(PaintHandler);
            IRLeftPanel.Paint   += new PaintEventHandler(PaintHandler);
            IRRightPanel.Paint  += new PaintEventHandler(PaintHandler);
            ColorPanel.Resize   += new EventHandler(ResizeHandler);
            DepthPanel.Resize   += new EventHandler(ResizeHandler);
            IRPanel.Resize      += new EventHandler(ResizeHandler);
            IRLeftPanel.Resize  += new EventHandler(ResizeHandler);
            IRRightPanel.Resize += new EventHandler(ResizeHandler);

            ResetStreamTypes();
            PopulateDeviceMenu();

            Scale2.CheckedChanged += new EventHandler(Scale_Checked);
            Mirror.CheckedChanged += new EventHandler(Mirror_Checked);

            foreach (RadioButton button in streamButtons)
            {
                if (button != null)
                {
                    button.Click += new EventHandler(Stream_Click);
                }
            }

            renders[0].SetHWND(ColorPanel);
            renders[1].SetHWND(DepthPanel);
            renders[2].SetHWND(IRPanel);
            renders[3].SetHWND(IRLeftPanel);
            renders[4].SetHWND(IRRightPanel);
        }
Ejemplo n.º 32
0
 public RealSenseCamera()
 {
     Session = PXCMSession.CreateInstance();
     Manager = Session.CreateSenseManager();
     ConfigurePoses();
     Speech = new SpeechManager();
     Debug.WriteLine("SDK Version {0}.{1}", Session.QueryVersion().major, Session.QueryVersion().minor);
 }
Ejemplo n.º 33
0
        public MainWindow()
        {
            InitializeComponent();
            session = PXCMSession.CreateInstance();
            var version = session.QueryVersion();

            Console.WriteLine("SDK Version {0}.{1}", version.major, version.minor);
        }
Ejemplo n.º 34
0
    void Start()
    {
        gameController = AppUtis.Controller;

        this.session = PXCMSession.CreateInstance();
        this.AudioSourceCheck();
        this.InitSession(session);
    }
Ejemplo n.º 35
0
        /// <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();
        }
Ejemplo n.º 36
0
        public HeadTracking()
        {
            UserHeadPose    = new UserHeadPose();
            UserExpressions = new UserExpressions();
            //UserLandmarks = new UserLandmarks();

            Session       = PXCMSession.CreateInstance();
            CameraService = new CameraService(Session);
        }
Ejemplo n.º 37
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Get instance of SenseManager
            PXCMSession session = PXCMSession.CreateInstance();

            // Get RS version
            PXCMSession.ImplVersion version = session.QueryVersion();
            textBox1.Text = version.major.ToString() + "." + version.minor.ToString();

            // setup Pipeline
            PXCMSenseManager sm = session.CreateSenseManager();

            // Get streams ready
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480);
            sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480);

            // Init Pipeline
            sm.Init();

            // Get samples
            pxcmStatus status = sm.AcquireFrame(true); // Synchronous capturing

            PXCMCapture.Sample sample = sm.QuerySample();

            // Convert samples to image
            PXCMImage image  = sample.color;
            PXCMImage dimage = sample.depth;

            PXCMImage.ImageData data;
            image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out data);
            WriteableBitmap wbm = data.ToWritableBitmap(0,
                                                        image.info.width,
                                                        image.info.height,
                                                        96.0, 96.0);

            PXCMImage.ImageData data2;
            dimage.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH_RAW, out data2);
            WriteableBitmap wbm2 = data2.ToWritableBitmap(
                0,
                dimage.info.width,
                dimage.info.height,
                96.0, 96.0);

            // Display image
            imageRGB.Source   = wbm;
            imageDepth.Source = wbm2;


            // Clean up
            image.ReleaseAccess(data);
            image.ReleaseAccess(data2);
            sm.ReleaseFrame();


            sm.Close();
            session.Dispose();
        }
Ejemplo n.º 38
0
        public void Initialize()
        {
            pxcmStatus status = PXCMSession.CreateInstance(out session);

            if (status < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                MessageBox.Show("Unable to create Session for VoiceTracking.");
            }
        }
Ejemplo n.º 39
0
        public static string Speak(string sentence, int curr_volume, int curr_pitch, int curr_speech_rate)
        {
            string      module   = "";
            int         language = 0;
            PXCMSession session  = PXCMSession.CreateInstance();

            if (session == null)
            {
                return("Failed to create an SDK session");
            }

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.friendlyName = module;
            desc.cuids[0]     = PXCMSpeechSynthesis.CUID;
            PXCMSpeechSynthesis vsynth;
            pxcmStatus          sts = session.CreateImpl <PXCMSpeechSynthesis>(desc, out vsynth);

            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                session.Dispose();
                return("Failed to create the synthesis module");
            }

            PXCMSpeechSynthesis.ProfileInfo pinfo;
            vsynth.QueryProfile(language, out pinfo);
            pinfo.volume = curr_volume;
            pinfo.rate   = curr_speech_rate;
            pinfo.pitch  = curr_pitch;
            sts          = vsynth.SetProfile(pinfo);
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                vsynth.Dispose();
                session.Dispose();
                return("Failed to initialize the synthesis module");
            }

            sts = vsynth.BuildSentence(1, sentence);
            if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                VoiceOut vo = new VoiceOut(pinfo.outputs);
                for (int i = 0;; i++)
                {
                    PXCMAudio sample = vsynth.QueryBuffer(1, i);
                    if (sample == null)
                    {
                        break;
                    }
                    vo.RenderAudio(sample);
                }
                vo.Close();
            }

            vsynth.Dispose();
            session.Dispose();
            return(null);
        }
Ejemplo n.º 40
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();

            this.g_session = session;
            PopulateDeviceMenu();
              //  PopulateModuleMenu();
            FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            Panel2.Paint += new PaintEventHandler(Panel_Paint);
        }
Ejemplo n.º 41
0
        public Projection(PXCMSession session, PXCMCapture.Device device, PXCMImage.ImageInfo dinfo, PXCMImage.ImageInfo cinfo)
        {
            /* retrieve the invalid depth pixel values */
            invalid_value = device.QueryDepthLowConfidenceValue();

            /* Create the projection instance */
            projection = device.CreateProjection();

            uvmap = new PXCMPointF32[dinfo.width * dinfo.height];
            invuvmap = new PXCMPointF32[cinfo.width * cinfo.height];
        }
Ejemplo n.º 42
0
 public MovementController(PXCMSenseManager.Handler handler,
     PXCMHandConfiguration.OnFiredGestureDelegate handGestureHandler,
     PXCMHandConfiguration.OnFiredAlertDelegate handAlertHandler)
 {
     
     // register event handlers
     this._handler = handler;
     _handGestureHandler = handGestureHandler;
     _handAlertHandler = handAlertHandler;
     Session = PXCMSession.CreateInstance();
 
 }
Ejemplo n.º 43
0
        public MainForm(Main main, PXCMSession session)
        {
            this.main = main;

            InitializeComponent();

            this.session = session;
            PopulateDeviceMenu();
            PopulateModuleMenu();

            FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            Panel2.Paint += new PaintEventHandler(Panel_Paint);
            personListBox.SelectedIndex = 0;
        }
Ejemplo n.º 44
0
        public override void Dispose()
        {
            lock (this)
            {
                depthFrame.CloseAllOpenStreams();
                colorFrame.CloseAllOpenStreams();
                textureFrame.CloseAllOpenStreams();

                capture.Dispose();
                session.Dispose();
                capture = null;
                session = null;
            }
        }
Ejemplo n.º 45
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();

            this.g_session = session;
            PopulateDeviceMenu();
            PopulateModuleMenu();
            cmbGesturesList.Enabled = false;
            FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            Panel2.Paint += new PaintEventHandler(Panel_Paint);
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 2000;
            timer.Start();
        }
Ejemplo n.º 46
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();
            
            m_faceTextOrganizer = new FaceTextOrganizer();
            m_deviceMenuItem = new ToolStripMenuItem("Device");
            m_moduleMenuItem = new ToolStripMenuItem("Module");
            Session = session;
            CreateResolutionMap();
            PopulateDeviceMenu();
            PopulateModuleMenu();
            PopulateProfileMenu();
            PopulateUnitMenu();

            FormClosing += MainForm_FormClosing;
            Panel2.Paint += Panel_Paint;
            yawningTimer = new System.Timers.Timer();
            yawningTimer.Elapsed += new ElapsedEventHandler(OnYawnTimedEvent);
            yawningTimer.Interval = 3000;
            yawningTimer.Enabled = true;

            speakTimer = new System.Timers.Timer();
            speakTimer.Elapsed += new ElapsedEventHandler(OnSpeakEvent);
            speakTimer.Interval = 2500;
            speakTimer.Enabled = true;


            var thread = new Thread(DoTracking);
            thread.Start();


            eyeCloseTimer = new System.Timers.Timer();
            eyeCloseTimer.Elapsed += new ElapsedEventHandler(OnEyeCloseTimedEvent);
            eyeCloseTimer.Interval = 1000;
            eyeCloseTimer.Enabled = true;
            
            currentPort = new SerialPort();
            currentPort.PortName = "COM16"; //Serial port Edison is connected to
            currentPort.BaudRate = 9600;
            currentPort.ReadTimeout = 500;
            currentPort.WriteTimeout = 500;
            try
            {
                currentPort.Open();
            }
            catch(System.IO.IOException ex)
            {
                MessageBox.Show("Edison Unit not detected, please set it to COM16.");
            }
        }
Ejemplo n.º 47
0
        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;
        }
Ejemplo n.º 48
0
        public Projection(PXCMSession session, PXCMCapture.Device device, PXCMImage.ImageInfo dinfo)
        {
            //: start ros serial node:
//            rosPublisher.start("192.168.0.10");

            /* Create the projection instance */
            projection = device.CreateProjection();

            height = dinfo.height;
            width = dinfo.width;
            numOfPixels = dinfo.width * dinfo.height;
            UInt16 invalid_value = device.QueryDepthLowConfidenceValue();
            obj_detector = new managed_obj_detector.ObjDetector(dinfo.width, dinfo.height, invalid_value);
            coords = new PXCMPoint3DF32[numOfPixels];
            rgb_ir_d_xyz_points = new managed_obj_detector.RgbIrDXyzPoint[numOfPixels];
        }
Ejemplo n.º 49
0
        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);
			}
        }
Ejemplo n.º 50
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);
        }
Ejemplo n.º 51
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();
            InitializeCheckboxes();
            InitializeTextBoxes();

            m_faceTextOrganizer = new FaceTextOrganizer();
            m_deviceMenuItem = new ToolStripMenuItem("Device");
            m_moduleMenuItem = new ToolStripMenuItem("Module");
            Session = session;
            CreateResolutionMap();
            PopulateDeviceMenu();
            PopulateModuleMenu();
            PopulateProfileMenu();

            FormClosing += MainForm_FormClosing;
            Panel2.Paint += Panel_Paint;
        }
Ejemplo n.º 52
0
        public MainForm(PXCMSession session)
        {
            InitializeComponent();

            this.g_session = session;
            PopulateDeviceMenu();
            PopulateModuleMenu();
            cmbGesturesList.Enabled = false;
            FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            Panel2.Paint += new PaintEventHandler(Panel_Paint);
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 2000;
            timer.Start();

            labelSolved.BackColor = Color.Transparent;

            NextKaraoke();

            this.Start_Click(this, null);
        }
Ejemplo n.º 53
0
        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;
        }
Ejemplo n.º 54
0
        /* */

        public MainForm(PXCMSession session)
        {
            InitializeComponent();
            InitializeTextBoxes();

            m_faceTextOrganizer = new FaceTextOrganizer();
            m_deviceMenuItem = new ToolStripMenuItem("Device");
            m_moduleMenuItem = new ToolStripMenuItem("Module");
            Session = session;

            CreateResolutionMap();
            PopulateDeviceMenu();
            PopulateModuleMenu();
            PopulateProfileMenu();

            InitializeUserSettings();
            InitializeCheckboxes();
            DisableUnsupportedAlgos();
            RestoreUserSettings();

            FormClosing += MainForm_FormClosing;
            Panel2.Paint += Panel_Paint;

            m_Util = Util.Instance;
            fetchOperations();

            m_Arduino = new Arduino(new ArduinoManager());
            m_CurrentFaceExpression = new Dictionary<PXCMFaceData.ExpressionsData.FaceExpression, int>();
            m_FaceExpressions = new List<ExpressionOperation>();

            morseInterpeter = new MorseInterpeter(m_Arduino);
            
            eyeState = new EyeState(m_Arduino);
         //   eyeState.EyesClosed += EyeState.eyeState_Closed;

//            eyeState.EyesClosed += EyeState.eyeState_Closed;
         //   eyeState.Closed += new EyeState.MyDelegate(EyeState.eyeState_Closed);

//            eyeState.Open += new EyeState.MyDelegate(EyeState.eyeState_Open);

        }
Ejemplo n.º 55
0
        public MainFormVR(PXCMSession session, MainScreen mainScreen)
        {
            InitializeComponent();
            this.mainScreen = mainScreen;
            this.session = session;

            try
            {
                PopulateSource();
                PopulateModule();
                PopulateLanguage();
                dictationToolStripMenuItem_Click(null, null);
            }
            catch (Exception e)
            {
                //MessageBox.Show("VR INIT NOT SUCCESSFUL");
            }

            Console2.AfterLabelEdit += new NodeLabelEditEventHandler(Console2_AfterLabelEdit);
            Console2.KeyDown += new KeyEventHandler(Console2_KeyDown);
            FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
        }
Ejemplo n.º 56
0
 void Start()
 {
     session = PXCMSession.CreateInstance();
     audioSourceCheck();
     initSession(session);
 }
Ejemplo n.º 57
0
    void initSession(PXCMSession session)
    {
        if (source == null)
        {
            Debug.Log("Source was null!  No audio device?");
            return;
        }

        // Set audio volume to 0.2
        source.SetVolume(setVolume);

        // Set Audio Source
        Debug.Log("Using device: " + device.name);
        source.SetDevice(device);

        // Set Module
        PXCMSession.ImplDesc mdesc = new PXCMSession.ImplDesc();
        mdesc.iuid = 0;

        pxcmStatus sts = session.CreateImpl<PXCMSpeechRecognition>(out sr);

        if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            // Configure
            PXCMSpeechRecognition.ProfileInfo pinfo;
            // Language
            sr.QueryProfile(0, out pinfo);
            Debug.Log(pinfo.language);
            sr.SetProfile(pinfo);

            // Set Command/Control or Dictation
            sr.SetDictation();

            // Initialization
            Debug.Log("Init Started");
            PXCMSpeechRecognition.Handler handler = new PXCMSpeechRecognition.Handler();
            handler.onRecognition = OnRecognition;
            handler.onAlert = OnAlert;

            sts = sr.StartRec(source, handler);

            if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Debug.Log("Voice Rec Started");
            }
            else
            {
                Debug.Log("Voice Rec Start Failed");
            }
        }
        else
        {
            Debug.Log("Voice Rec Session Failed");
        }
    }
Ejemplo n.º 58
0
        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;
        }
Ejemplo n.º 59
0
        public MainWindow()
        {
            InitializeComponent();

            #region Hand
            nodes = new PXCMHandData.JointData[][] { new PXCMHandData.JointData[0x20], new PXCMHandData.JointData[0x20] };
            xValues = new float[arraySize];
            yValues = new float[arraySize];
            zValues = new float[arraySize];
            #endregion Hand

            // Setto la modalita' test per la guida del drone ON/OFF
            TestModeCheck.IsChecked = true;

            genericItems = new ObservableCollection<GenericItem>();

            se = PXCMSession.CreateInstance();

            if (se != null)
            {
                //processingThread = new Thread(new ThreadStart(ProcessingHandThread));
                //senseManager = PXCMSenseManager.CreateInstance();
                //senseManager.EnableHand();
                //senseManager.Init();
                //ConfigureHandModule();
                //processingThread.Start();



                // session is a PXCMSession instance.
                audiosource = se.CreateAudioSource();
                // Scan and Enumerate audio devices
                audiosource.ScanDevices();

                PXCMAudioSource.DeviceInfo dinfo = null;

                for (int d = audiosource.QueryDeviceNum() - 1; d >= 0; d--)
                {
                    audiosource.QueryDeviceInfo(d, out dinfo);
                }
                audiosource.SetDevice(dinfo);

                se.CreateImpl<PXCMSpeechRecognition>(out sr);
              

                PXCMSpeechRecognition.ProfileInfo pinfo;
                sr.QueryProfile(0, out pinfo);
                sr.SetProfile(pinfo);

                // sr is a PXCMSpeechRecognition instance.
                String[] cmds = new String[] { "Takeoff", "Land", "Rotate Left", "Rotate Right", "Advance",
                    "Back", "Up", "Down", "Left", "Right", "Stop" , "Dance"};
                int[] labels = new int[] { 1, 2, 4, 5, 8, 16, 32, 64, 128, 256, 512, 1024 };
                // Build the grammar.
                sr.BuildGrammarFromStringList(1, cmds, labels);
                // Set the active grammar.
                sr.SetGrammar(1);
                // Set handler

                RecognitionHandler = new PXCMSpeechRecognition.Handler();

                RecognitionHandler.onRecognition = OnRecognition;

                Legenda.Items.Add("------ Available Commands ------");
                foreach (var cmd in cmds)
                {
                    Legenda.Items.Add(cmd);
                }
            }
        }
        public void DoIt(MainForm form1, PXCMSession session, PXCMAudioSource s)
        {
            Debug.Log("DoIt");
            form = form1;
            Debug.Log("DoIt:01");
            /* Create the AudioSource instance */
            //source = s;
            source =session.CreateAudioSource();
            Debug.Log("DoIt:02");
            if (source == null) {
                CleanUp();
                form.PrintStatus("Stopped");
                return;
            }
            Debug.Log("DoIt:03");
            /* Set audio volume to 0.2 */
            source.SetVolume(0.2f);
            Debug.Log("DoIt:04");
            /* Set Audio Source */
            source.SetDevice(form.GetCheckedSource());
            Debug.Log("DoIt:05");
            /* Set Module */
            PXCMSession.ImplDesc mdesc = new PXCMSession.ImplDesc();
            mdesc.iuid = form.GetCheckedModule();
            Debug.Log("DoIt:06");
            pxcmStatus sts = session.CreateImpl<PXCMSpeechRecognition>(out sr);
            Debug.Log("DoIt:07");

            if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Debug.Log("DoIt:10");
                PXCMSpeechRecognition.ProfileInfo pinfo;
                sr.QueryProfile(form.GetCheckedLanguage(), out pinfo);
                sr.SetProfile(pinfo);

                if (form.IsCommandControl())
                {
                    Debug.Log("DoIt:20");
                    string[] cmds = form.GetCommands();
                    if (form.g_file != null && form.g_file.Length != 0)
                    {
                        Debug.Log("DoIt:30");
                        if (form.g_file.EndsWith(".list")){
                            Debug.Log("DoIt:40");
                            form.FillCommandListConsole(form.g_file);
                            cmds = form.GetCommands();
                            if (cmds.GetLength(0) == 0)
                                form.PrintStatus("Command List Load Errors");
                        }

                        // input Command/Control grammar file available, use it
                        if (!SetGrammarFromFile(form.g_file))
                        {
                            Debug.Log("DoIt:41");
                            form.PrintStatus("Can not set Grammar From File.");
                            CleanUp();
                            return;
                        };
                    }
                    else if (cmds != null && cmds.GetLength(0) != 0)
                    {
                        Debug.Log("DoIt:31");
                        // voice commands available, use them
                        sts = sr.BuildGrammarFromStringList(1, cmds, null);
                        sts = sr.SetGrammar(1);
                    } else {
                        Debug.Log("DoIt:32");
                        form.PrintStatus("No Command List. Dictation instead.");
                        if (form.v_file != null && form.v_file.Length != 0) SetVocabularyFromFile(form.v_file);
                        sts = sr.SetDictation();
                    }
                }
                else
                {
                    Debug.Log("DoIt:21");
                    if (form.v_file != null && form.v_file.Length != 0) SetVocabularyFromFile(form.v_file);
                    sts = sr.SetDictation();
                }

                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    form.PrintStatus("Can't start recognition.");
                    CleanUp();
                    return;
                }

                form.PrintStatus("Init Started");
                PXCMSpeechRecognition.Handler handler = new PXCMSpeechRecognition.Handler();
                handler.onRecognition=OnRecognition;
                handler.onAlert=OnAlert;

                sts=sr.StartRec(source, handler);
                if (sts>=pxcmStatus.PXCM_STATUS_NO_ERROR) {
                    form.PrintStatus("Init OK");

                    // Wait until the stop button is clicked
                    while (!form.IsStop()) {
                        System.Threading.Thread.Sleep(5);
                    }

                    sr.StopRec();
                } else {
                    form.PrintStatus("Failed to initialize");
                }
            } else {
                form.PrintStatus("Init Failed");
            }

            Debug.Log("DoIt:98");
            CleanUp();
            form.PrintStatus("Stopped");
            Debug.Log("DoIt:99");
        }