Esempio n. 1
0
        private void PropogateLanguage()
        {
            ToolStripMenuItem lm = new ToolStripMenuItem("Language");

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0]     = PXCMSpeechSynthesis.CUID;
            desc.friendlyName = GetCheckedModule();
            PXCMSpeechSynthesis vsynth;

            if (session.CreateImpl <PXCMSpeechSynthesis>(desc, out vsynth) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                for (int i = 0; ; i++)
                {
                    PXCMSpeechSynthesis.ProfileInfo pinfo;
                    if (vsynth.QueryProfile(i, out pinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }

                    ToolStripMenuItem tsmi = new ToolStripMenuItem(LanguageToString(pinfo.language), null, new EventHandler(Language_Item_Click));
                    if (i == 0)
                    {
                        tsmi.Checked = true;
                    }
                    lm.DropDownItems.Add(tsmi);
                }
                vsynth.Dispose();
            }

            MainMenu.Items.RemoveAt(1);
            MainMenu.Items.Insert(1, lm);
        }
        public static void Find() {
            PXCMSession session;
            PXCMSession.CreateInstance(out session);
            Debug.WriteLine("SDK Version {0}.{1}", session.version.major, session.version.minor);
            
            // session is a PXCMSession instance
            PXCMSession.ImplDesc desc1 = new PXCMSession.ImplDesc();
            desc1.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc1.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            for (uint m = 0; ; m++) {
                PXCMSession.ImplDesc desc2;
                if (session.QueryImpl(ref desc1, m, out desc2) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                Debug.WriteLine("Module[{0}]: {1}", m, desc2.friendlyName.get());

                PXCMCapture capture;
                session.CreateImpl<PXCMCapture>(ref desc2, PXCMCapture.CUID, out capture);

                for (uint d = 0; ; d++) {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDevice(d, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                    Debug.WriteLine("    Device[{0}]: {1}", d, dinfo.name.get());
                }
                capture.Dispose();
            }
            session.Dispose();
        }
Esempio n. 3
0
        public List <string> GetAudioCaptureDevices()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_AUDIO_CAPTURE;

            var deviceList = new List <string>();

            for (uint i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (session.QueryImpl(ref desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                PXCMCapture capture;
                if (session.CreateImpl <PXCMCapture>(ref desc1, PXCMCapture.CUID, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }
                for (uint j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDevice(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    deviceList.Add(dinfo.name.get());
                }
                capture.Dispose();
            }

            return(deviceList);
        }
Esempio n. 4
0
        private void ScanForCameras()
        {
            deviceInfo.Clear();
            devicesUIDs.Clear();

            PXCMSession.ImplDesc   desc1;
            PXCMCapture.DeviceInfo dinfo = null;

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            for (int i = 0; ; i++)
            {
                if (session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                PXCMCapture capture;
                if (session.CreateImpl <PXCMCapture>(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    deviceInfo.Add(dinfo);
                    devicesUIDs.Add(desc1.iuid);
                }
                capture.Dispose();
            }
        }
        private IEnumerable <PXCMCapture.DeviceInfo> GetDevices()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            List <PXCMCapture.DeviceInfo> result = new List <PXCMCapture.DeviceInfo>();

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (_session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                PXCMCapture capture;
                if (_session.CreateImpl <PXCMCapture>(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }

                    result.Add(dinfo);
                    //                    devices_iuid[sm1] = desc1.iuid;
                }
                capture.Dispose();
            }
            return(result);
        }
Esempio n. 6
0
        private void PopulateLanguage()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMSpeechRecognition.CUID;
            desc.iuid     = GetCheckedModule();

            PXCMSpeechRecognition vrec;

            if (session.CreateImpl <PXCMSpeechRecognition>(desc, out vrec) < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                return;
            }

            ToolStripMenuItem lm = new ToolStripMenuItem("Language");

            for (int i = 0; ; i++)
            {
                PXCMSpeechRecognition.ProfileInfo pinfo;
                if (vrec.QueryProfile(i, out pinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                ToolStripMenuItem lm1 = new ToolStripMenuItem(LanguageToString(pinfo.language), null, new EventHandler(Language_Item_Click));
                lm.DropDownItems.Add(lm1);
            }
            vrec.Dispose();

            if (lm.DropDownItems.Count > 0)
            {
                (lm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            }
            MainMenu.Items.RemoveAt(2);
            MainMenu.Items.Insert(2, lm);
        }
Esempio n. 7
0
        //Moduleメニュー関連
        private void PopulateModuleMenu()
        {
            var desc = new PXCMSession.ImplDesc();

            desc.cuids[0] = PXCMFaceModule.CUID;

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                var mm1 = new ToolStripMenuItem(desc1.friendlyName, null, Module_Item_Click);
                m_moduleMenuItem.DropDownItems.Add(mm1);
            }
            if (m_moduleMenuItem.DropDownItems.Count > 0)
            {
                ((ToolStripMenuItem)m_moduleMenuItem.DropDownItems[0]).Checked = true;
            }
            try
            {
                MainMenu.Items.RemoveAt(2);
            }
            catch (NotSupportedException)
            {
                m_moduleMenuItem.Dispose();
                throw;
            }
            MainMenu.Items.Insert(2, m_moduleMenuItem);
        }
        private void PopulateModule()
        {
            ToolStripMenuItem mm = new ToolStripMenuItem("モジュール");

            modules.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMSpeechRecognition.CUID;
            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                ToolStripMenuItem mm1 = new ToolStripMenuItem(desc1.friendlyName, null, new EventHandler(Module_Item_Click));
                modules[mm1] = desc1.iuid;
                mm.DropDownItems.Add(mm1);
            }

            if (mm.DropDownItems.Count > 0)
            {
                (mm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            }
            MainMenu.Items.RemoveAt(1);
            MainMenu.Items.Insert(1, mm);
        }
Esempio n. 9
0
        private void CheckDevices()
        {
            devices.Clear();
            devices_iuid.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            devicesToolStripMenuItem.DropDownItems.Clear();

            for (int i = 0; ; i++)
            {
                if (imageStream.Session.QueryImpl(desc, i, out PXCMSession.ImplDesc desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                if (imageStream.Session.CreateImpl <PXCMCapture>(desc1, out PXCMCapture capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    if (capture.QueryDeviceInfo(j, out PXCMCapture.DeviceInfo dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
                    devices[sm1]      = dinfo;
                    devices_iuid[sm1] = desc1.iuid;
                    devicesToolStripMenuItem.DropDownItems.Add(sm1);
                }
                capture.Dispose();
            }
        }
Esempio n. 10
0
        private void PopulateModuleMenu()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMEmotion.CUID;
            ToolStripMenuItem mm = new ToolStripMenuItem("Module");

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                ToolStripMenuItem mm1 = new ToolStripMenuItem(desc1.friendlyName, null, new EventHandler(Module_Item_Click));
                mm.DropDownItems.Add(mm1);
            }
            if (mm.DropDownItems.Count > 0)
            {
                (mm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            }
            try
            {
                MainMenu.Items.RemoveAt(1);
            }
            catch
            {
                mm.Dispose();
            }
            MainMenu.Items.Insert(1, mm);
        }
Esempio n. 11
0
        private void PopulateProfileMenu()
        {
            ToolStripMenuItem pm = new ToolStripMenuItem("Landmark");

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMFaceAnalysis.CUID;
            desc.friendlyName.set(GetCheckedModule());
            PXCMBase ft_t = null;

            if (session.CreateImpl(ref desc, PXCMFaceAnalysis.CUID, out ft_t) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                PXCMFaceAnalysis.Landmark ftl = ft_t.DynamicCast <PXCMFaceAnalysis.Landmark>(PXCMFaceAnalysis.Landmark.CUID);
                for (uint i = 0; ; i++)
                {
                    PXCMFaceAnalysis.Landmark.ProfileInfo pinfo;
                    if (ftl.QueryProfile(i, out pinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    ToolStripMenuItem pm1 = new ToolStripMenuItem((pinfo.labels & PXCMFaceAnalysis.Landmark.Label.LABEL_SIZE_MASK).ToString() + " Points", null, new EventHandler(Profile_Item_Click));
                    pm.DropDownItems.Add(pm1);
                }
                ft_t.Dispose();
            }

            if (pm.DropDownItems.Count > 0)
            {
                (pm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            }
            MainMenu.Items.RemoveAt(3);
            MainMenu.Items.Insert(3, pm);
        }
Esempio n. 12
0
        public List <string> GetVoiceLanguages()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMVoiceRecognition.CUID;
            desc.friendlyName.set(this.VoiceModule);

            PXCMVoiceRecognition vrec;

            if (session.CreateImpl <PXCMVoiceRecognition>(ref desc, PXCMVoiceRecognition.CUID, out vrec) < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                return(null);
            }

            var languageList = new List <string>();

            for (uint i = 0; ; i++)
            {
                PXCMVoiceRecognition.ProfileInfo pinfo;
                if (vrec.QueryProfile(i, out pinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                languageList.Add(GetLanguageName(pinfo.language));
            }
            vrec.Dispose();

            return(languageList);
        }
        public void OnImportsSatisfied()
        {
            FLogger.Log(LogType.Debug, "OnImport");
            this.descs = new List <PXCMSession.ImplDesc>();

            this.GetSessionAndSenseManager();

            pxcmStatus sts = pxcmStatus.PXCM_STATUS_NO_ERROR;

            PXCMAudioSource audio = this.session.CreateAudioSource();

            if (audio == null)
            {
                throw new Exception("Could not create audio source.");
            }

            // enumrate audio source
            // scan available devices
            this.deviceInfos = new List <PXCMAudioSource.DeviceInfo>();
            audio.ScanDevices();

            int deviceNum = audio.QueryDeviceNum();

            string[] deviceNames = new string[deviceNum];
            for (int i = 0; i < deviceNum; ++i)
            {
                PXCMAudioSource.DeviceInfo tmpDeviceInfo;
                sts = audio.QueryDeviceInfo(i, out tmpDeviceInfo);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    throw new Exception("Could not get audio device.");
                }

                FLogger.Log(LogType.Debug, "audio device info: " + tmpDeviceInfo.name);
                deviceNames[i] = tmpDeviceInfo.name;
                this.deviceInfos.Add(tmpDeviceInfo);
            }

            EnumManager.UpdateEnum("AudioDevice", deviceNames[0], deviceNames);
            audio.Dispose();


            PXCMSession.ImplDesc inDesc = new PXCMSession.ImplDesc();
            inDesc.cuids[0] = PXCMSpeechRecognition.CUID;

            for (int i = 0; ; ++i)
            {
                // get speech recognition engine
                PXCMSession.ImplDesc outDesc = null;
                sts = this.session.QueryImpl(inDesc, i, out outDesc);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                FLogger.Log(LogType.Debug, "speech recognition engine: " + outDesc.friendlyName);
                this.descs.Add(outDesc);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Enumerates the resolutions.
        /// </summary>
        /// <exception cref="System.Exception">PXCMCapture.Device null</exception>
        public void EnumerateResolutions()
        {
            ColorResolutions = new Dictionary <string, IEnumerable <Tuple <PXCMImage.ImageInfo, PXCMRangeF32> > >();
            var desc = new PXCMSession.ImplDesc
            {
                group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                PXCMCapture capture;
                if (Session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo info;
                    if (capture.QueryDeviceInfo(j, out info) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }

                    PXCMCapture.Device device = capture.CreateDevice(j);
                    if (device == null)
                    {
                        throw new Exception("PXCMCapture.Device null");
                    }

                    var deviceResolutions = new List <Tuple <PXCMImage.ImageInfo, PXCMRangeF32> >();

                    for (int k = 0; k < device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_COLOR); k++)
                    {
                        PXCMCapture.Device.StreamProfileSet profileSet;
                        device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_COLOR, k, out profileSet);
                        var currentRes = new Tuple <PXCMImage.ImageInfo, PXCMRangeF32>(profileSet.color.imageInfo,
                                                                                       profileSet.color.frameRate);

                        if (SupportedColorResolutions.Contains(new Tuple <int, int>(currentRes.Item1.width, currentRes.Item1.height)))
                        {
                            deviceResolutions.Add(currentRes);
                        }
                    }
                    ColorResolutions.Add(info.name, deviceResolutions);
                    device.Dispose();
                }

                capture.Dispose();
            }
        }
Esempio n. 15
0
        public void PopulateDeviceMenu()
        {
            Devices = new Dictionary <string, PXCMCapture.DeviceInfo>();
            var desc = new PXCMSession.ImplDesc
            {
                group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                PXCMCapture capture;
                if (Session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    if (!Devices.ContainsKey(dinfo.name))
                    {
                        Devices.Add(dinfo.name, dinfo);
                    }
                    var sm1 = new ToolStripMenuItem(dinfo.name, null, Device_Item_Click);
                    m_deviceMenuItem.DropDownItems.Add(sm1);
                }

                capture.Dispose();
            }

            if (m_deviceMenuItem.DropDownItems.Count > 0)
            {
                ((ToolStripMenuItem)m_deviceMenuItem.DropDownItems[0]).Checked = true;
                PopulateColorResolutionMenu(m_deviceMenuItem.DropDownItems[0].ToString());
            }

            try
            {
                MainMenu.Items.RemoveAt(0);
            }
            catch (NotSupportedException)
            {
                m_deviceMenuItem.Dispose();
                throw;
            }
            MainMenu.Items.Insert(0, m_deviceMenuItem);
        }
Esempio n. 16
0
        private void PopulateDeviceMenu()
        {
            devices.Clear();
            devices_iuid.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            DeviceMenu.DropDownItems.Clear();

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                PXCMCapture capture;
                if (session.CreateImpl <PXCMCapture>(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }

                    ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
                    devices[sm1]      = dinfo;
                    devices_iuid[sm1] = desc1.iuid;
                    DeviceMenu.DropDownItems.Add(sm1);
                }
                capture.Dispose();
            }
            if (DeviceMenu.DropDownItems.Count > 0)
            {
                (DeviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                PopulateColorDepthMenus(DeviceMenu.DropDownItems[0] as ToolStripMenuItem);
            }
            else
            {
                ModeLive.Visible   = false;
                ModeRecord.Visible = false;
                Start.Enabled      = false;
                for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                {
                    if (streamMenus[s] != null)
                    {
                        streamMenus[s].Visible   = false;
                        streamButtons[s].Visible = false;
                    }
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Configures the speech recognition.
        /// </summary>
        private bool ConfigureSpeechRecognition()
        {
            /* Create the AudioSource instance */
            source = session.CreateAudioSource();

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

            /* Set Audio Source */
            source.SetDevice(sourceDeviceInfo[_activeSource]);

            /* Set Module */
            PXCMSession.ImplDesc mdesc = new PXCMSession.ImplDesc();
            mdesc.iuid = modulesIuID[_activeModule];

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

            if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                /* Configure */
                PXCMSpeechRecognition.ProfileInfo pinfo;
                sr.QueryProfile(_activeLanguage, out pinfo);
                sr.SetProfile(pinfo);

                /* Set Command/Control or Dictation */
                if (SpeechModuleMode == SpeechModuleModeType.CommandControl)
                {
                    string[] cmds = Commands;
                    if (cmds != null && cmds.GetLength(0) != 0)
                    {
                        // voice commands available, use them
                        sr.BuildGrammarFromStringList(1, cmds, null);
                        sr.SetGrammar(1);
                    }
                    else
                    {
                        Debug.Log("Speech Command List Empty!");
                        SetError(SpeechManagerErrorType.VoiceThreadError_CommandsListEmpty);

                        //Switch to dictaction mode
                        //SpeechModuleMode = SpeechModuleModeType.Dictation;
                        //sr.SetDictation();
                    }
                }
                else
                {
                    sr.SetDictation();
                }
            }
            else
            {
                Debug.Log("VoiceThreadError - InitFailed - CreateImpl!");
                SetError(SpeechManagerErrorType.VoiceThreadError_InitFailed_CreateImpl);
                return(false);
            }
            return(true);
        }
Esempio n. 18
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);
        }
    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");
        }
    }
        //public System.Drawing.Bitmap GetBitmap()
        //{
        //TODO: julian, vorher muss aber noch die Camera gestartet werden, dann erst sollte die funktion funktionieren
        //TODO: Project FaceTracking DisplayPicture und dann ganz viel Code :-)
        //    return null;
        //}
        #endregion

        #region Functions
        public void LoadCameras()
        {
            Cameras = new Dictionary <string, Camera>();
            PXCMSession session = SdkCommonHelper.Session;

            var groupDescribtion = new PXCMSession.ImplDesc
            {
                group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;

                if (session.QueryImpl(groupDescribtion, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                PXCMCapture capture;
                if (session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo deviceInfo;
                    if (capture.QueryDeviceInfo(j, out deviceInfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }

                    PXCMCapture.Device device = capture.CreateDevice(j);
                    if (device == null)
                    {
                        throw new Exception("PXCMCapture.Device null");
                    }

                    string name = deviceInfo.name;
                    if (Cameras.ContainsKey(name))
                    {
                        name += j;
                    }

                    Cameras.Add(name, new Camera(
                                    name,
                                    device,
                                    GetResolution_ColorDepth_FrameRate_Combinations(device).OrderBy(x => x.Width).ToList()));
                }

                capture.Dispose();
            }
        }
Esempio n. 21
0
        private void CheckSelection()
        {
            PXCMCapture.Device.StreamProfile dprofile = GetDepthConfiguration();
            //?DepthNone.Enabled = (cprofile.imageInfo.format != 0 || irprofile.imageInfo.format != 0);

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid     = current_device_iuid;
            desc.cuids[0] = PXCMCapture.CUID;
            PXCMCapture capture;

            PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
            if (session.CreateImpl <PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                using (capture)
                {
                    using (PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx))
                    {
                        if (device != null)
                        {
                            PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
                            PXCMCapture.Device.StreamProfileSet test    = new PXCMCapture.Device.StreamProfileSet();

                            /* Loop over all stream types and profiles and enable only compatible in menu */
                            for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                            {
                                PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                                if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_COLOR) != 0)
                                {
                                    //?test[PXCMCapture.StreamType.STREAM_TYPE_COLOR] = cprofile;
                                    test[PXCMCapture.StreamType.STREAM_TYPE_DEPTH] = dprofile;
                                    //?test[PXCMCapture.StreamType.STREAM_TYPE_IR] = irprofile;
                                    int num = device.QueryStreamProfileSetNum(st);
                                    for (int p = 0; p < num; p++)
                                    {
                                        if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                        {
                                            break;
                                        }
                                        PXCMCapture.Device.StreamProfile sprofile = profile[st];
                                        ToolStripMenuItem sm1 = GetMenuItem(sprofile);
                                        if (sm1 != null)
                                        {
                                            test[st]    = sprofile;
                                            sm1.Enabled = device.IsStreamProfileSetValid(test);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 22
0
        private void Device_Item_Click(object sender, EventArgs e)
        {
            foreach (ToolStripMenuItem e1 in DeviceMenu.DropDownItems)
            {
                e1.Checked = (sender == e1);
            }
            PopulateColorMenus(sender as ToolStripMenuItem);
            PopulateDepthMenus(sender as ToolStripMenuItem);

            PXCMSession.ImplDesc   desc     = new PXCMSession.ImplDesc();
            PXCMCapture.DeviceInfo dev_info = devices[(sender as ToolStripMenuItem)];
        }
Esempio n. 23
0
        private void PopulateDeviceMenu()
        {
            devices.Clear();
            devices_iuid.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            DeviceMenu.DropDownItems.Clear();

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                PXCMCapture capture;
                if (session.CreateImpl <PXCMCapture>(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    if (dinfo.model == PXCMCapture.DeviceModel.DEVICE_MODEL_GENERIC)
                    {
                        continue;
                    }

                    ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
                    devices[sm1]      = dinfo;
                    devices_iuid[sm1] = desc1.iuid;
                    DeviceMenu.DropDownItems.Add(sm1);
                }
                capture.Dispose();
            }
            if (DeviceMenu.DropDownItems.Count > 0)
            {
                (DeviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                PopulateColorMenus(DeviceMenu.DropDownItems[0] as ToolStripMenuItem);
                PopulateDepthMenus(DeviceMenu.DropDownItems[0] as ToolStripMenuItem);
            }
        }
Esempio n. 24
0
        private void PopulateDepthMenu(ToolStripMenuItem device_item)
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group          = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup       = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid           = devices_iuid[device_item];
            current_device_iuid = desc.iuid;
            desc.cuids[0]       = PXCMCapture.CUID;

            profiles.Clear();
            DepthMenu.DropDownItems.Clear();
            PXCMCapture capture;

            PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
            if (session.CreateImpl <PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                using (capture)
                {
                    using (PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx))
                    {
                        if (device != null)
                        {
                            PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
                            if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_DEPTH) != 0)
                            {
                                int num = device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_DEPTH);
                                for (int p = 0; p < num; p++)
                                {
                                    if (device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                    {
                                        break;
                                    }
                                    PXCMCapture.Device.StreamProfile sprofile = profile[PXCMCapture.StreamType.STREAM_TYPE_DEPTH];
                                    ToolStripMenuItem sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Depth_Item_Click));
                                    profiles[sm1] = sprofile;
                                    DepthMenu.DropDownItems.Add(sm1);
                                }
                            }
                        }
                    }
                }
            }
            DepthNone           = new ToolStripMenuItem("None", null, new EventHandler(Depth_Item_Click));
            profiles[DepthNone] = new PXCMCapture.Device.StreamProfile();
            DepthMenu.DropDownItems.Add(DepthNone);
            (DepthMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;

            CheckSelection();
        }
Esempio n. 25
0
        private void PopulateDeviceMenu()
        {
            Devices = new Dictionary <string, PXCMCapture.DeviceInfo>();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            ToolStripMenuItem sm = new ToolStripMenuItem("Device");

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (g_session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                PXCMCapture capture;
                if (g_session.CreateImpl <PXCMCapture>(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }
                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    string name = dinfo.name;
                    if (Devices.ContainsKey(dinfo.name))
                    {
                        name += j;
                    }
                    Devices.Add(name, dinfo);
                    ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
                    sm.DropDownItems.Add(sm1);
                }
                capture.Dispose();
            }
            if (sm.DropDownItems.Count > 0)
            {
                (sm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            }
            MainMenu.Items.RemoveAt(0);
            MainMenu.Items.Insert(0, sm);
        }
        public void PopulateDevice()
        {
            var desc = new PXCMSession.ImplDesc
            {
                group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            var session = senseManager.QuerySession();

            for (int i = 0; ; i++)
            {
                // デバイスのディスクリプタを取得する
                PXCMSession.ImplDesc desc1;
                var ret = session.QueryImpl(desc, i, out desc1);
                if (ret < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                // キャプチャーを作成する
                PXCMCapture capture;
                ret = session.CreateImpl(desc1, out capture);
                if (ret < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }

                // デバイスを列挙する
                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }

                    // R200 : Intel(R) RealSense(TM) 3D Camera R200
                    // F200 : Intel(R) RealSense(TM) 3D Camera
                    Trace.WriteLine(dinfo.name);
                }

                capture.Dispose();
            }
        }
        public static string Speak(string module, int language, string sentence, int curr_volume, int curr_pitch, int curr_speech_rate )
        {
            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;
        }
Esempio n. 28
0
        static void enumDevice()
        {
            // セッションを取得する
            var session = senseManager.QuerySession();

            if (session == null)
            {
                throw new Exception("セッションの取得に失敗しました");
            }

            // 取得するグループを設定する
            PXCMSession.ImplDesc mdesc = new PXCMSession.ImplDesc();
            mdesc.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            mdesc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            for (int i = 0; ; ++i)
            {
                // センサーグループを取得する
                PXCMSession.ImplDesc desc1;
                var sts = session.QueryImpl(mdesc, i, out desc1);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                // センサーグループ名を表示する
                Console.WriteLine(desc1.friendlyName);

                // キャプチャーオブジェクトを作成する
                PXCMCapture capture = null;
                sts = session.CreateImpl <PXCMCapture>(desc1, out capture);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }

                // デバイスを列挙する
                enumDevice(capture);

                // キャプチャーオブジェクトを解放する
                capture.Dispose();
            }
        }
Esempio n. 29
0
        public List <string> GetVoiceModules()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMVoiceRecognition.CUID;

            var moduleList = new List <string>();

            for (uint i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (session.QueryImpl(ref desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }
                moduleList.Add(desc1.friendlyName.get());
            }

            return(moduleList);
        }
        public void PopulateDevice()
        {
            var desc = new PXCMSession.ImplDesc
            {
                group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            var session = senseManager.QuerySession();

            for ( int i = 0; ; i++ ) {
                // デバイスのディスクリプタを取得する
                PXCMSession.ImplDesc desc1;
                var ret = session.QueryImpl( desc, i, out desc1 );
                if ( ret < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                    break;
                }

                // キャプチャーを作成する
                PXCMCapture capture;
                ret = session.CreateImpl( desc1, out capture );
                if ( ret < pxcmStatus.PXCM_STATUS_NO_ERROR ){
                    continue;
                }

                // デバイスを列挙する
                for ( int j = 0; ; j++ ) {
                    PXCMCapture.DeviceInfo dinfo;
                    if ( capture.QueryDeviceInfo( j, out dinfo ) < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                        break;
                    }

                    // R200 : Intel(R) RealSense(TM) 3D Camera R200
                    // F200 : Intel(R) RealSense(TM) 3D Camera
                    Trace.WriteLine( dinfo.name );
                }

                capture.Dispose();
            }
        }
Esempio n. 31
0
        //////////////////////////////////////////////////
        #region Static Methods
        /// <summary>
        /// Get device names.
        /// Devices' group is restricted to sensor type.
        /// Devices' subgroup is restricted to video capture type.
        /// </summary>
        /// <returns>Device names</returns>
        public static string[] GetDeviceNames()
        {
            var session = GestureCameraUtil.GetSession();

            var descOriginal = new PXCMSession.ImplDesc();

            descOriginal.group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            descOriginal.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            var list = new List <string>();

            for (uint i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc;
                if (GestureCameraUtil.HasError(session.QueryImpl(ref descOriginal, i, out desc)))
                {
                    break;
                }

                PXCMCapture capture;
                if (GestureCameraUtil.HasError(session.CreateImpl <PXCMCapture>(ref desc, PXCMCapture.CUID, out capture)))
                {
                    continue;
                }

                for (uint j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo info;
                    if (GestureCameraUtil.HasError(capture.QueryDevice(j, out info)))
                    {
                        break;
                    }
                    list.Add(info.name.get());
                }

                capture.Dispose();
            }

            return(list.ToArray());
        }
Esempio n. 32
0
        /// <summary>
        /// Enumerates the camera devices.
        /// </summary>
        public void EnumerateDevices()
        {
            Devices = new Dictionary <string, PXCMCapture.DeviceInfo>();
            var desc = new PXCMSession.ImplDesc
            {
                group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    break;
                }

                PXCMCapture capture;
                if (Session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    continue;
                }

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    {
                        break;
                    }
                    if (!Devices.ContainsKey(dinfo.name))
                    {
                        Devices.Add(dinfo.name, dinfo);
                    }
                }

                capture.Dispose();
            }
        }
Esempio n. 33
0
        /// <summary>
        /// 取得所有裝置資訊
        /// </summary>
        /// <returns>裝置資訊陣列</returns>
        private PXCMCapture.DeviceInfo[] GetDeviceInfos()
        {
            List <PXCMCapture.DeviceInfo> result = new List <PXCMCapture.DeviceInfo>();

            var desc = new PXCMSession.ImplDesc {
                group    = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (RealSenseObjects.Session.QueryImpl(desc, i, out desc1).IsError())
                {
                    break;
                }

                PXCMCapture capture;
                if (RealSenseObjects.Session.CreateImpl(desc1, out capture).IsError())
                {
                    continue;
                }

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo).IsError())
                    {
                        break;
                    }
                    result.Add(dinfo);
                }

                capture.Dispose();
            }

            return(result.ToArray());
        }
Esempio n. 34
0
        static void enumDevice()
        {
            // セッションを取得する
            var session = senseManager.QuerySession();
            if ( session == null ) {
                throw new Exception( "セッションの取得に失敗しました" );
            }

            // 取得するグループを設定する
            PXCMSession.ImplDesc mdesc = new PXCMSession.ImplDesc();
            mdesc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            mdesc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            for ( int i = 0; ; ++i ) {
                // センサーグループを取得する
                PXCMSession.ImplDesc desc1;
                var sts = session.QueryImpl( mdesc, i, out desc1 );
                if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                    break;
                }

                // センサーグループ名を表示する
                Console.WriteLine( desc1.friendlyName );

                // キャプチャーオブジェクトを作成する
                PXCMCapture capture = null;
                sts = session.CreateImpl<PXCMCapture>( desc1, out capture );
                if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                    continue;
                }

                // デバイスを列挙する
                enumDevice( capture );

                // キャプチャーオブジェクトを解放する
                capture.Dispose();
            }
        }
Esempio n. 35
0
        /// <summary>
        /// Enumerates the camera devices.
        /// </summary>
        public void EnumerateDevices()
        {
            Devices = new Dictionary<string, PXCMCapture.DeviceInfo>();
            var desc = new PXCMSession.ImplDesc
            {
                group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                PXCMCapture capture;
                if (Session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                    if (!Devices.ContainsKey(dinfo.name))
                        Devices.Add(dinfo.name, dinfo);
                }

                capture.Dispose();
            }
        }
Esempio n. 36
0
 private void PopulateModuleMenu()
 {
     PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
     desc.cuids[0] = PXCMHandModule.CUID;
     ToolStripMenuItem mm = new ToolStripMenuItem("Module");
     for (int i = 0; ; i++)
     {
         PXCMSession.ImplDesc desc1;
         if (g_session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
         ToolStripMenuItem mm1 = new ToolStripMenuItem(desc1.friendlyName, null, new EventHandler(Module_Item_Click));
         mm.DropDownItems.Add(mm1);
     }
     if (mm.DropDownItems.Count > 0)
         (mm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
     MainMenu.Items.RemoveAt(1);
     MainMenu.Items.Insert(1, mm);
 }
Esempio n. 37
0
        private void PopulateDepthMenu(ToolStripMenuItem device_item)
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid = devices_iuid[device_item];
            current_device_iuid = desc.iuid;
            desc.cuids[0] = PXCMCapture.CUID;

            profiles.Clear();
            DepthMenu.DropDownItems.Clear();
            PXCMCapture capture;
            PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice(); 
            if (session.CreateImpl<PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                using (capture)
                {
                    using (PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx))
                    {
                        if (device != null)
                        {
                            PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
                            if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_DEPTH) != 0)
                            {
                                int num = device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_DEPTH);
                                for (int p = 0; p < num; p++)
                                {
                                    if (device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                        break;
                                    PXCMCapture.Device.StreamProfile sprofile = profile[PXCMCapture.StreamType.STREAM_TYPE_DEPTH];
                                    ToolStripMenuItem sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Depth_Item_Click));
                                    profiles[sm1] = sprofile;
                                    DepthMenu.DropDownItems.Add(sm1);
                                }
                            }
                        }
                    }
                }
            }
            DepthNone = new ToolStripMenuItem("None", null, new EventHandler(Depth_Item_Click));
            profiles[DepthNone] = new PXCMCapture.Device.StreamProfile();
            DepthMenu.DropDownItems.Add(DepthNone);
            (DepthMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;

            CheckSelection();
        }
Esempio n. 38
0
        public void AdvancedPipeline()
        {
            PXCMSession session;
            pxcmStatus sts = PXCMSession.CreateInstance(out session);
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                form.UpdateStatus("Failed to create an SDK session");
                return;
            }

            /* Set Module */
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.friendlyName.set(form.GetCheckedModule());

            PXCMEmotion emotionDet;
            sts = session.CreateImpl<PXCMEmotion>(ref desc, PXCMEmotion.CUID, out emotionDet);
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                form.UpdateStatus("Failed to create the emotionDet module");
                session.Dispose();
                return;
            }

            UtilMCapture capture = null;
            if (form.GetRecordState())
            {
                capture = new UtilMCaptureFile(session, form.GetFileName(), true);
                capture.SetFilter(form.GetCheckedDevice());
            }
            else if (form.GetPlaybackState())
            {
                capture = new UtilMCaptureFile(session, form.GetFileName(), false);
            }
            else
            {
                capture = new UtilMCapture(session);
                capture.SetFilter(form.GetCheckedDevice());
            }

            form.UpdateStatus("Pair moudle with I/O");
            for (uint i = 0; ; i++)
            {
                PXCMEmotion.ProfileInfo pinfo;
                sts = emotionDet.QueryProfile(i, out pinfo);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                sts = capture.LocateStreams(ref pinfo.inputs);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;
                sts = emotionDet.SetProfile(ref pinfo);
                if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) break;
            }
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                form.UpdateStatus("Failed to pair the emotionDet module with I/O");
                capture.Dispose();
                emotionDet.Dispose();
                session.Dispose();
                return;
            }

            form.UpdateStatus("Streaming");
            PXCMImage[] images = new PXCMImage[PXCMCapture.VideoStream.STREAM_LIMIT];
            PXCMScheduler.SyncPoint[] sps = new PXCMScheduler.SyncPoint[2];
            while (!form.stop)
            {
                PXCMImage.Dispose(images);
                PXCMScheduler.SyncPoint.Dispose(sps);
                sts = capture.ReadStreamAsync(images, out sps[0]);
                if (DisplayDeviceConnection(sts == pxcmStatus.PXCM_STATUS_DEVICE_LOST)) continue;
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                sts = emotionDet.ProcessImageAsync(images, out sps[1]);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                PXCMScheduler.SyncPoint.SynchronizeEx(sps);
                sts=sps[0].Synchronize();
                if (DisplayDeviceConnection(sts==pxcmStatus.PXCM_STATUS_DEVICE_LOST)) continue;
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                /* Display Results */
                DisplayPicture(capture.QueryImage(images,PXCMImage.ImageType.IMAGE_TYPE_COLOR));
                DisplayLocation(emotionDet);
                form.UpdatePanel();
            }
            PXCMImage.Dispose(images);
            PXCMScheduler.SyncPoint.Dispose(sps);

            capture.Dispose();
            emotionDet.Dispose();
            session.Dispose();
            form.UpdateStatus("Stopped");
        }
Esempio n. 39
0
 /**
     @brief	Enable the face module in the pipeline.
     @param[in] name		The optional module name.
     @param[in] mid					The module identifier. This is usually the interface identifier.
     @return PXCM_STATUS_NO_ERROR	Successful execution.
 */
 public pxcmStatus EnableModule(Int32 mid, String name)
 {
     PXCMSession.ImplDesc mdesc = null;
     if (name != null)
     {
         mdesc = new PXCMSession.ImplDesc();
         mdesc.cuids[0] = mid;
         mdesc.friendlyName = name;
     }
     return EnableModule(mid, mdesc);
 }
Esempio n. 40
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");
        }
    }
Esempio n. 41
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 
        foreach (var device in SpeechRecognizer.devices)
        {
            if (device.name == "マイク配列 (Creative VF0800)")
            {
                source.SetDevice(device);
                Debug.Log("Using device: " + device.name);
            }
        }

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

        var status = session.CreateImpl<PXCMSpeechRecognition>(out this.recognizer);

        if (status >= pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            // Configure 
            PXCMSpeechRecognition.ProfileInfo pinfo;
            // Language
            this.recognizer.QueryProfile(this.languageIndex, out pinfo);
            Debug.Log(pinfo.language);
            this.recognizer.SetProfile(pinfo);

            // Set Command/Control or Dictation 
            this.recognizer.SetDictation();

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

            status = this.recognizer.StartRec(source, handler);

            if (status >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Debug.Log("Voice Rec Started");
            }
            else
            {
                Debug.Log("Voice Rec Start Failed");
            }
        }
        else
        {
            Debug.Log("Voice Rec Session Failed");
        }
    }
        public void RunEmotionRecognition()
        {
            PXCMSession session;
            pxcmStatus sts = PXCMSession.CreateInstance(out session);
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Console.WriteLine("Failed to create an SDK session");
                return;
            }

            // Set Module //
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.friendlyName.set(moduleName);

            PXCMEmotion emotionDet;
            sts = session.CreateImpl<PXCMEmotion>(ref desc, PXCMEmotion.CUID, out emotionDet);
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Console.WriteLine("Failed to create the emotionDet module");
                session.Dispose();
                return;
            }

            UtilMCapture capture = null;
            capture = new UtilMCapture(session);
            capture.SetFilter(captureDeviceName);

            Console.WriteLine("Pair moudle with I/O");
            for (uint i = 0; ; i++)
            {
                PXCMEmotion.ProfileInfo pinfo;
                sts = emotionDet.QueryProfile(i, out pinfo);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                sts = capture.LocateStreams(ref pinfo.inputs);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;
                sts = emotionDet.SetProfile(ref pinfo);
                if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) break;
            }
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Console.WriteLine("Failed to pair the emotionDet module with I/O");
                capture.Dispose();
                emotionDet.Dispose();
                session.Dispose();
                return;
            }

            Console.WriteLine("Streaming");
            PXCMImage[] images = new PXCMImage[PXCMCapture.VideoStream.STREAM_LIMIT];
            PXCMScheduler.SyncPoint[] sps = new PXCMScheduler.SyncPoint[2];
            while (!_shouldStop)
            {
                PXCMImage.Dispose(images);
                PXCMScheduler.SyncPoint.Dispose(sps);
                sts = capture.ReadStreamAsync(images, out sps[0]);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                sts = emotionDet.ProcessImageAsync(images, out sps[1]);
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                PXCMScheduler.SyncPoint.SynchronizeEx(sps);
                sts = sps[0].Synchronize();
                if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                // Display Results //
                GetEmoData(emotionDet);
                Thread.Sleep(500);
            }
            PXCMImage.Dispose(images);
            PXCMScheduler.SyncPoint.Dispose(sps);

            capture.Dispose();
            emotionDet.Dispose();
            session.Dispose();
            Console.WriteLine("Stopped");
        }
        private void SelectCaptureDevice()
        {
            PXCMSession session;
            pxcmStatus sts = PXCMSession.CreateInstance(out session);
            if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                Console.WriteLine("Failed to create an SDK session");
                return;
            }

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            for (uint i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (session.QueryImpl(ref desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                PXCMCapture capture;
                if (session.CreateImpl<PXCMCapture>(ref desc1, PXCMCapture.CUID, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;
                for (uint j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDevice(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                    captureDeviceName = dinfo.name.get();
                }
                capture.Dispose();
            }
            session.Dispose();
        }
Esempio n. 44
0
        private void PopulateDeviceMenu()
        {
            devices.Clear();
            devices_iuid.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            DeviceMenu.DropDownItems.Clear();

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                pxcmStatus rc = session.QueryImpl(desc, i, out desc1);
                if (rc < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    break;
                PXCMCapture capture;
                rc = session.CreateImpl<PXCMCapture>(desc1, out capture);
                if (rc < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    continue;
                using (capture)
                {
                    for (int j = 0; ; j++)
                    {
                        PXCMCapture.DeviceInfo dinfo;
                        rc = capture.QueryDeviceInfo(j, out dinfo);
                        if (rc < pxcmStatus.PXCM_STATUS_NO_ERROR)
                            break;

                        ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
                        devices[sm1] = dinfo;
                        devices_iuid[sm1] = desc1.iuid;
                        DeviceMenu.DropDownItems.Add(sm1);
                    }
                }
            }
            if (DeviceMenu.DropDownItems.Count > 0)
            {
                (DeviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;
                PopulateDepthMenu(DeviceMenu.DropDownItems[0] as ToolStripMenuItem);
            }
        }
Esempio n. 45
0
 /** 
     @brief Return the module descriptor
     @param[in]  module  The module instance
     @param[out] desc	The module descriptor, to be returned.
     @return PXCM_STATUS_NO_ERROR         Successful execution.
     @return PXCM_STATUS_ITEM_UNAVAILABLE Failed to identify the module instance.
 */
 public pxcmStatus QueryModuleDesc(PXCMBase module, out PXCMSession.ImplDesc desc)
 {
     desc = new PXCMSession.ImplDesc();
     return PXCMSession_QueryModuleDesc(instance, module.instance, desc);
 }
Esempio n. 46
0
        private bool PopulateDeviceFromFileMenu()
        {
            Devices.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            PXCMSession.ImplDesc desc1;
            PXCMCapture.DeviceInfo dinfo;
            PXCMSenseManager pp = PXCMSenseManager.CreateInstance();
            if (pp == null)
            {
                UpdateStatus("Init Failed");
                return false;
            }
            try
            {
                if (g_session.QueryImpl(desc, 0, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) throw null;
                if (pp.captureManager.SetFileName(filename, false) < pxcmStatus.PXCM_STATUS_NO_ERROR) throw null;
                if (pp.QueryCaptureManager().LocateStreams() < pxcmStatus.PXCM_STATUS_NO_ERROR) throw null;
                pp.QueryCaptureManager().QueryDevice().QueryDeviceInfo(out dinfo);
            }
            catch
            {
                pp.Dispose();
                UpdateStatus("Init Failed");
                return false;
            }

            ToolStripMenuItem sm = new ToolStripMenuItem("Device");
            ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
            sm.DropDownItems.Add(sm1);
            if (sm.DropDownItems.Count > 0)
                (sm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            MainMenu.Items.RemoveAt(0);
            MainMenu.Items.Insert(0, sm);

            if (!Devices.Any())
            {
                if (dinfo.model == PXCMCapture.DeviceModel.DEVICE_MODEL_R200)
                {
                    txtMaxDepth.Text = "3000";
                    worldFacingCamera = true;
                }
                else
                {
                    txtMaxDepth.Text = "550";
                    worldFacingCamera = false;
                }
            }

            PXCMCapture.Device device = pp.QueryCaptureManager().QueryDevice();
            if (device == null)
            {
                pp.Dispose();
                UpdateStatus("Init Failed");
                return false;
            }

            pp.Close();
            pp.Dispose();

            StatusLabel.Text = "Ok";
            return true;
        }
Esempio n. 47
0
        internal pxcmStatus SetupCaptureDevice(PXCMCapture.DeviceInfo devinfo)
        {
            if(SenseSession == null)
            {
                this.SenseSession = new RSSDKContext();
            }

            if(SenseSession.sm.QueryCaptureManager().QueryCapture() != null)
            {
                SenseSession.capture = SenseSession.sm.QueryCaptureManager().capture;
                SenseSession.Status = pxcmStatus.PXCM_STATUS_NO_ERROR;
            }
            else
            {
                PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
                desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
                desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
                desc.iuid = devinfo.duid;
                desc.cuids[0] = PXCMCapture.CUID;
                SenseSession.Status = SenseSession.Session.CreateImpl<PXCMCapture>(desc, out SenseSession.capture);
            }

            if (SenseSession.Status == pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                FLogger.Log(LogType.Debug, "RSSDK: Capture created.");

                if(SenseSession.cm.QueryDevice() != null)
                {
                    SenseSession.device = SenseSession.cm.QueryDevice();
                }
                else
                {
                    SenseSession.device = SenseSession.capture.CreateDevice(FDeviceInfo[0].didx);

                    if(SenseSession.device == null) return pxcmStatus.PXCM_STATUS_INIT_FAILED;
                    else FLogger.Log(LogType.Debug, "RSSDK: Device created.");
                }

                //if(!this.SenseSession.StreamProfilesInitialized)
                {
                    this.SenseSession.StreamProfilesInitialized = InitStreamProfiles(this.SenseSession.device);

                    if(!this.SenseSession.StreamProfilesInitialized) return pxcmStatus.PXCM_STATUS_DATA_NOT_INITIALIZED;
                    else FLogger.Log(LogType.Debug, "RSSDK: Device profiles Initialized.");
                }

                this.SenseSession.cm.FilterByDeviceInfo(FDeviceInfo[0]);

                FLogger.Log(LogType.Debug, "RSSDK: Device ready for configuration.");
                return pxcmStatus.PXCM_STATUS_NO_ERROR;
            }
            else
            {
                FLogger.Log(LogType.Debug, "RSSDK: Can not create capture.");
                return pxcmStatus.PXCM_STATUS_INIT_FAILED;
            }
        }
Esempio n. 48
0
        public void PopulateDeviceMenu()
        {
            Devices = new Dictionary<string, PXCMCapture.DeviceInfo>();
            var desc = new PXCMSession.ImplDesc
            {
                group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };
                        
            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                PXCMCapture capture;
                if (Session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                    if (!Devices.ContainsKey(dinfo.name))
                        Devices.Add(dinfo.name, dinfo);

                    var sm1 = new ToolStripMenuItem(dinfo.name, null, Device_Item_Click);
                    m_deviceMenuItem.DropDownItems.Add(sm1);
                }

                capture.Dispose();
            }

            if (m_deviceMenuItem.DropDownItems.Count > 0)
            {
                ((ToolStripMenuItem)m_deviceMenuItem.DropDownItems[0]).Checked = true;
                PopulateColorResolutionMenu(m_deviceMenuItem.DropDownItems[0].ToString());
            }

            try
            {
                MainMenu.Items.RemoveAt(0);
            }
            catch (NotSupportedException)
            {
                m_deviceMenuItem.Dispose();
                throw;
            }
            MainMenu.Items.Insert(0, m_deviceMenuItem);
        }
Esempio n. 49
0
        private IEnumerable<PXCMCapture.DeviceInfo> GetDevices()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            List<PXCMCapture.DeviceInfo> result = new List<PXCMCapture.DeviceInfo>();

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (_session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                PXCMCapture capture;
                if (_session.CreateImpl<PXCMCapture>(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;
                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                    result.Add(dinfo);
                    //                    devices_iuid[sm1] = desc1.iuid;
                }
                capture.Dispose();
            }
            return result;
        }
Esempio n. 50
0
        private bool PopulateDeviceFromFileMenu()
        {
            devices.Clear();
            devices_iuid.Clear();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;

            PXCMSession.ImplDesc desc1;
            PXCMCapture.DeviceInfo dinfo;
            PXCMSenseManager pp = PXCMSenseManager.CreateInstance();
            if (pp == null)
            {
                UpdateStatus("Init Failed");
                return false;
            }
            try
            {
                if (session.QueryImpl(desc, 0, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    throw null;
                if (pp.captureManager.SetFileName(filename, false) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    throw null;
                if (pp.QueryCaptureManager().LocateStreams() < pxcmStatus.PXCM_STATUS_NO_ERROR)
                    throw null;
                pp.QueryCaptureManager().QueryDevice().QueryDeviceInfo(out dinfo);
            }
            catch
            {
                pp.Dispose();
                UpdateStatus("Init Failed");
                return false;
            }
            DeviceMenu.DropDownItems.Clear();
            ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
            devices[sm1] = dinfo;
            devices_iuid[sm1] = desc1.iuid;
            DeviceMenu.DropDownItems.Add(sm1);

            sm1 = new ToolStripMenuItem("playback from the file : ", null);
            sm1.Enabled = false;
            DeviceMenu.DropDownItems.Add(sm1);
            sm1 = new ToolStripMenuItem(filename, null);
            sm1.Enabled = false;
            DeviceMenu.DropDownItems.Add(sm1);
            if (DeviceMenu.DropDownItems.Count > 0)
                (DeviceMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;

            // populate depth menu from the file
            profiles.Clear();
            DepthMenu.DropDownItems.Clear();
            PXCMCapture.Device device = pp.QueryCaptureManager().QueryDevice(); 
            
            PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet(); 
            if (((int)dinfo.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_DEPTH) != 0)
            {
                int num = device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_DEPTH);
                for (int p = 0; p < num; p++)
                {
                    if (device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                        break;
                    PXCMCapture.Device.StreamProfile sprofile = profile[PXCMCapture.StreamType.STREAM_TYPE_DEPTH];
                    sm1 = new ToolStripMenuItem(ProfileToString(sprofile), null, new EventHandler(Depth_Item_Click));
                    profiles[sm1] = sprofile;
                    DepthMenu.DropDownItems.Add(sm1);
                }
            }

            DepthNone = new ToolStripMenuItem("None", null, new EventHandler(Depth_Item_Click));
            profiles[DepthNone] = new PXCMCapture.Device.StreamProfile();
            DepthMenu.DropDownItems.Add(DepthNone);
            (DepthMenu.DropDownItems[0] as ToolStripMenuItem).Checked = true;

            CheckSelection();
            pp.Close();
            pp.Dispose();

            StatusLabel.Text = "Ok";
            return true;
        }
Esempio n. 51
0
 private void PopulateModuleMenu()
 {
     var desc = new PXCMSession.ImplDesc();
     desc.cuids[0] = PXCMFaceModule.CUID;
     
     for (int i = 0; ; i++)
     {
         PXCMSession.ImplDesc desc1;
         if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
         var mm1 = new ToolStripMenuItem(desc1.friendlyName, null, Module_Item_Click);
         m_moduleMenuItem.DropDownItems.Add(mm1);
     }
     if (m_moduleMenuItem.DropDownItems.Count > 0)
         ((ToolStripMenuItem)m_moduleMenuItem.DropDownItems[0]).Checked = true;
     try
     {
         MainMenu.Items.RemoveAt(2);
     }
     catch (NotSupportedException)
     {
         m_moduleMenuItem.Dispose();
         throw;
     }
     MainMenu.Items.Insert(2, m_moduleMenuItem);
     
 }
        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");
        }
Esempio n. 53
0
        private void PopulateDeviceMenu()
        {
            Devices = new Dictionary<string, PXCMCapture.DeviceInfo>();

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            ToolStripMenuItem sm = new ToolStripMenuItem("Device");
            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (g_session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                PXCMCapture capture;
                if (g_session.CreateImpl<PXCMCapture>(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;
                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo dinfo;
                    if (capture.QueryDeviceInfo(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                    string name = dinfo.name;
                    if (Devices.ContainsKey(dinfo.name))
                    {
                        name += j;
                    }
                    Devices.Add(name,dinfo);
                    ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name, null, new EventHandler(Device_Item_Click));
                    sm.DropDownItems.Add(sm1);
                }
                capture.Dispose();
            }
            if (sm.DropDownItems.Count > 0)
                (sm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            MainMenu.Items.RemoveAt(0);
            MainMenu.Items.Insert(0, sm);
        }
Esempio n. 54
0
 private void PopulateSource()
 {
     PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
     desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
     desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_AUDIO_CAPTURE;
     ToolStripMenuItem sm = new ToolStripMenuItem("Source");
     for (uint i = 0; ; i++)
     {
         PXCMSession.ImplDesc desc1;
         if (session.QueryImpl(ref desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
         PXCMCapture capture;
         if (session.CreateImpl<PXCMCapture>(ref desc1, PXCMCapture.CUID, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;
         for (uint j = 0; ; j++)
         {
             PXCMCapture.DeviceInfo dinfo;
             if (capture.QueryDevice(j, out dinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
             ToolStripMenuItem sm1 = new ToolStripMenuItem(dinfo.name.get(), null, new EventHandler(Source_Item_Click));
             sm.DropDownItems.Add(sm1);
         }
         capture.Dispose();
     }
     if (sm.DropDownItems.Count > 0)
         (sm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
     MainMenu.Items.RemoveAt(0);
     MainMenu.Items.Insert(0, sm);
 }
        // 音声認識を初期化する
        private void InitializeSpeechRecognition()
        {
            pxcmStatus sts;
            var session = senseManager.QuerySession();

            // 音声入力デバイスを作成する
            audioSource = session.CreateAudioSource();
            if ( audioSource == null ){
                throw new Exception( "音声入力デバイスの作成に失敗しました" );
            }

            // 音声入力デバイスを列挙する
            TextDesc.Text = "";
            TextDesc.Text += "音声入力デバイス\n";

            PXCMAudioSource.DeviceInfo device = null;

            audioSource.ScanDevices();
            for ( int i = 0;; ++i ) {
                PXCMAudioSource.DeviceInfo dinfo;
                sts = audioSource.QueryDeviceInfo( i, out dinfo );
                if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                    break;
                }

                // 音声入力デバイス名を表示する
                TextDesc.Text += "\t" + dinfo.name + "\n";

                // 最初のデバイスを使う
                if ( i == 0 ){
                    device = dinfo;
                }
            }

            // 音声入力デバイスを設定する
            sts = audioSource.SetDevice( device );
            if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                throw new Exception( "音声入力デバイスの設定に失敗しました" );
            }

            // 音声認識エンジンを列挙する
            TextDesc.Text += "音声認識エンジン\n";

            PXCMSession.ImplDesc inDesc = new PXCMSession.ImplDesc();
            PXCMSession.ImplDesc outDesc = null;
            PXCMSession.ImplDesc desc = null;
            inDesc.cuids[0] = PXCMSpeechRecognition.CUID;

            for ( int i = 0; ; ++i ) {
                // 音声認識エンジンを取得する
                sts = session.QueryImpl( inDesc, i, out outDesc );
                if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                    break;
                }

                // 音声認識エンジン名称を表示する
                TextDesc.Text += "\t" + outDesc.friendlyName + "\n";

                // 最初の音声認識エンジンを使う
                if( i== 0 ){
                    desc = outDesc;
                }
            }

            // 音声認識エンジンオブジェクトを作成する
            sts = session.CreateImpl<PXCMSpeechRecognition>( desc, out recognition );
            if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                throw new Exception( "音声認識エンジンオブジェクトの作成に失敗しました" );
            }

            // 対応言語を列挙する
            PXCMSpeechRecognition.ProfileInfo profile = null;

            for ( int j = 0;; ++j ) {
                // 音声認識エンジンが持っているプロファイルを取得する
                PXCMSpeechRecognition.ProfileInfo pinfo;
                sts = recognition.QueryProfile( j, out pinfo );
                if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                    break;
                }

                // 対応言語を表示する
                TextDesc.Text += "\t\t" + LanguageToString( pinfo.language ) + "\n";

                // 英語のエンジンを使う(日本語対応時には日本語に変更する)
                if ( pinfo.language == PXCMSpeechRecognition.LanguageType.LANGUAGE_US_ENGLISH ){
                    profile = pinfo;
                }
            }

            if ( profile == null ){
                throw new Exception( "選択した音声認識エンジンが見つかりませんでした" );
            }

            // 使用する言語を設定する
            sts = recognition.SetProfile( profile );
            if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                throw new Exception( "音声認識エンジンオブジェクトの設定に失敗しました" );
            }

            // コマンドモードを設定する
            SetCommandMode();

            // 音声認識の通知ハンドラを作成する
            PXCMSpeechRecognition.Handler handler = new PXCMSpeechRecognition.Handler();
            handler.onRecognition = OnRecognition;

            // 音声認識を開始する
            sts = recognition.StartRec( audioSource, handler );
            if ( sts < pxcmStatus.PXCM_STATUS_NO_ERROR ) {
                throw new Exception( "音声認識の開始に失敗しました" );
            }
        }
Esempio n. 56
0
        private void PopulateLanguage()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMVoiceRecognition.CUID;
            desc.friendlyName.set(GetCheckedModule());

            PXCMVoiceRecognition vrec;
            if (session.CreateImpl<PXCMVoiceRecognition>(ref desc, PXCMVoiceRecognition.CUID, out vrec) < pxcmStatus.PXCM_STATUS_NO_ERROR) return;

            ToolStripMenuItem lm = new ToolStripMenuItem("Language");
            for (uint i = 0; ; i++)
            {
                PXCMVoiceRecognition.ProfileInfo pinfo;
                if (vrec.QueryProfile(i, out pinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                ToolStripMenuItem lm1 = new ToolStripMenuItem(LanguageToString(pinfo.language), null, new EventHandler(Language_Item_Click));
                lm.DropDownItems.Add(lm1);
            }
            vrec.Dispose();

            if (lm.DropDownItems.Count > 0)
                (lm.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            MainMenu.Items.RemoveAt(2);
            MainMenu.Items.Insert(2, lm);
        }
Esempio n. 57
0
        /// <summary>
        /// Enumerates the resolutions.
        /// </summary>
        /// <exception cref="System.Exception">PXCMCapture.Device null</exception>
        public void EnumerateResolutions()
        {
            ColorResolutions = new Dictionary<string, IEnumerable<Tuple<PXCMImage.ImageInfo, PXCMRangeF32>>>();
            var desc = new PXCMSession.ImplDesc
            {
                group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR,
                subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE
            };

            for (int i = 0; ; i++)
            {
                PXCMSession.ImplDesc desc1;
                if (Session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                PXCMCapture capture;
                if (Session.CreateImpl(desc1, out capture) < pxcmStatus.PXCM_STATUS_NO_ERROR) continue;

                for (int j = 0; ; j++)
                {
                    PXCMCapture.DeviceInfo info;
                    if (capture.QueryDeviceInfo(j, out info) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;

                    PXCMCapture.Device device = capture.CreateDevice(j);
                    if (device == null)
                        throw new Exception("PXCMCapture.Device null");

                    var deviceResolutions = new List<Tuple<PXCMImage.ImageInfo, PXCMRangeF32>>();

                    for (int k = 0; k < device.QueryStreamProfileSetNum(PXCMCapture.StreamType.STREAM_TYPE_COLOR); k++)
                    {
                        PXCMCapture.Device.StreamProfileSet profileSet;
                        device.QueryStreamProfileSet(PXCMCapture.StreamType.STREAM_TYPE_COLOR, k, out profileSet);
                        var currentRes = new Tuple<PXCMImage.ImageInfo, PXCMRangeF32>(profileSet.color.imageInfo,
                            profileSet.color.frameRate);

                        if (SupportedColorResolutions.Contains(new Tuple<int, int>(currentRes.Item1.width, currentRes.Item1.height)))
                            deviceResolutions.Add(currentRes);
                    }
                    ColorResolutions.Add(info.name, deviceResolutions);
                    device.Dispose();
                }

                capture.Dispose();
            }
        }
 private void PopulateModule()
 {
     modules.Clear();
     PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
     desc.cuids[0] = PXCMSpeechRecognition.CUID;
     for (int i = 0; ; i++)
     {
         PXCMSession.ImplDesc desc1;
         if (session.QueryImpl(desc, i, out desc1) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
         modules[i] = desc1.iuid;
     }
 }
        private void PopulateLanguage()
        {
            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.cuids[0] = PXCMSpeechRecognition.CUID;
            desc.iuid=GetCheckedModule();

            PXCMSpeechRecognition vrec;
            if (session.CreateImpl<PXCMSpeechRecognition>(desc, out vrec) < pxcmStatus.PXCM_STATUS_NO_ERROR) return;

            for (int i = 0; ; i++)
            {
                PXCMSpeechRecognition.ProfileInfo pinfo;
                if (vrec.QueryProfile(i,out pinfo) < pxcmStatus.PXCM_STATUS_NO_ERROR) break;
                langs[i] = pinfo;
            }
            vrec.Dispose();

            langList = new string[langs.Count];
            for (int i = 0; i < langs.Count; i++)
            {
                langList[i] = langs[i].language.ToString();
            }
        }
Esempio n. 60
0
        private void CheckSelection()
        {
            PXCMCapture.Device.StreamProfile dprofile = GetDepthConfiguration();
            //?DepthNone.Enabled = (cprofile.imageInfo.format != 0 || irprofile.imageInfo.format != 0);

            PXCMSession.ImplDesc desc = new PXCMSession.ImplDesc();
            desc.group = PXCMSession.ImplGroup.IMPL_GROUP_SENSOR;
            desc.subgroup = PXCMSession.ImplSubgroup.IMPL_SUBGROUP_VIDEO_CAPTURE;
            desc.iuid = current_device_iuid;
            desc.cuids[0] = PXCMCapture.CUID;
            PXCMCapture capture;
            PXCMCapture.DeviceInfo dinfo2 = GetCheckedDevice();
            if (session.CreateImpl<PXCMCapture>(desc, out capture) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                using (capture)
                {
                    using (PXCMCapture.Device device = capture.CreateDevice(dinfo2.didx))
                    {
                        if (device != null)
                        {
                            PXCMCapture.Device.StreamProfileSet profile = new PXCMCapture.Device.StreamProfileSet();
                            PXCMCapture.Device.StreamProfileSet test = new PXCMCapture.Device.StreamProfileSet();

                            /* Loop over all stream types and profiles and enable only compatible in menu */
                            for (int s = 0; s < PXCMCapture.STREAM_LIMIT; s++)
                            {
                                PXCMCapture.StreamType st = PXCMCapture.StreamTypeFromIndex(s);
                                if (((int)dinfo2.streams & (int)PXCMCapture.StreamType.STREAM_TYPE_COLOR) != 0)
                                {
                                    //?test[PXCMCapture.StreamType.STREAM_TYPE_COLOR] = cprofile;
                                    test[PXCMCapture.StreamType.STREAM_TYPE_DEPTH] = dprofile;
                                    //?test[PXCMCapture.StreamType.STREAM_TYPE_IR] = irprofile;
                                    int num = device.QueryStreamProfileSetNum(st);
                                    for (int p = 0; p < num; p++)
                                    {
                                        if (device.QueryStreamProfileSet(st, p, out profile) < pxcmStatus.PXCM_STATUS_NO_ERROR)
                                            break;
                                        PXCMCapture.Device.StreamProfile sprofile = profile[st];
                                        ToolStripMenuItem sm1 = GetMenuItem(sprofile);
                                        if (sm1 != null)
                                        {
                                            test[st] = sprofile;
                                            sm1.Enabled = device.IsStreamProfileSetValid(test);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }