-1

I have created two threads. 1 for speech and 1 for speech.

DWORD WINAPI ThreadSpeech(LPVOID temp){
speechRecog obj;
obj.start();
return 0;}
DWORD WINAPI ThreadGesture(LPVOID temp){
m_pMR2GestureRec->mainGestureRec();
return 0;
}

I am using both codes from other developers. I want to use both of them at a time. whenever I run threads then only Gesture works and speech kinect can't initialize and generates error of kinect initialization for speech only.

I need help.

Mustansar Fiaz
  • 769
  • 1
  • 5
  • 7
  • Provide the kinect iniialization code – Manu343726 Apr 02 '14 at 07:24
  • //speech initialization HRESULT hr = NuiInitialize(NUI_INITIALIZE_FLAG_USES_AUDIO ); if ( FAILED(hr)) {....} hr = InitializeAudioStream(); if (FAILED(hr)) { ....} hr = CreateSpeechRecognizer(); if (FAILED(hr)) {...} hr = LoadSpeechGrammar(); if (FAILED(hr)) {...} hr = StartSpeechRecognition(); {...} – Mustansar Fiaz Apr 02 '14 at 09:01
  • //Gesture initialization HRESULT hr; hr= NuiCreateSensorByIndex(i, &g_hKinectSensor[i]); g_hKinectSensor[i]->NuiInitialize( NUI_INITIALIZE_FLAG_USES_COLOR | NUI_INITIALIZE_FLAG_USES_SKELETON ); if(FAILED(hr)) {...} g_hNextColorFrameEvent[i] = CreateEvent(NULL, TRUE, FALSE, NULL); hr= g_hKinectSensor[i]->NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR, NUI_IMAGE_RESOLUTION_640x480, 0, 2, g_hNextColorFrameEvent[i], &g_hColorStreamHandle[i]); if(FAILED(hr)) {...} – Mustansar Fiaz Apr 02 '14 at 09:02
  • Given the code you have here, the speech recognition object is local to ThreadSpeech, and will disappear at the end of the function. You also need to call ::CoInitialize at the start of *each* thread function. – Eric Brown Apr 02 '14 at 19:01
  • done both actions suggested by @EricBrown. still, gesture code works fine but speech don't work – Mustansar Fiaz Apr 03 '14 at 06:05
  • Please edit your question to show *all* the relevant code. In particular, please show **which line fails, and with what error**. – Eric Brown Apr 03 '14 at 16:10

2 Answers2

0

Well, you get the HRESULT values which tell you what step failed and why. Use them; we can't guess.

MSalters
  • 173,980
  • 10
  • 155
  • 350
0

The MSDN docs for NuiInitialize includes the following note:

If your application supports multiple sensors, use the INuiSensor interface to initialize the sensors instead.

Since you're using both speech and gestures, you'll need to use INuiSensor::Initialize to separately initialize the speech and gesture engine.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71