本文介绍了结合音频流和彩色流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嘿,希望有人可以帮助我。我试图使用Kinect的音频和颜色流在c ++中进行图像检测和语音识别。唯一的问题是我一次只能运行一个......当Color流开启时,它不是识别语音,反之亦然。它可能与我的Update()函数有关,但我不知道该怎么做。  以下是相关的示例函数:  int CColorBasics :: Run(HINSTANCE hInstance,int nCmdShow) { MSG msg = {0}; WNDCLASS wc; //对话框自定义窗口类 ZeroMemory(& wc,sizeof(wc)); wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hInstance = hInstance; wc.hCursor = LoadCursorW(NULL,IDC_ARROW); wc.hIcon = LoadIconW(hInstance,MAKEINTRESOURCE(IDI_APP)); wc.lpfnWndProc = DefDlgProcW; wc.lpszClassName = L" ColorBasicsAppDlgWndClass" ;; if(!RegisterClassW(& wc)) { return 0; } //创建主应用程序窗口 HWND hWndApp = CreateDialogParamW( hInstance, MAKEINTRESOURCE(IDD_APP), NULL,(DLGPROC)CColorBasics :: MessageRouter, reinterpret_cast< LPARAM>(this)); //显示窗口 ShowWindow(hWndApp,nCmdShow); while(WM_QUIT!= msg.message) { //检查我们是否有消息(通过传入QS_ALLINPUT) //或者一个Kinect事件(事件) // Update()将单独检查Kinect事件,以防多个信号通知 MsgWaitForMultipleObjects(2,events,FALSE,INFINITE,QS_ALLINPUT); //显式检查Kinect帧事件,因为MsgWaitForMultipleObjects //可以出于其他原因返回,即使它已发出信号。 Update(); while(PeekMessageW(& msg,NULL,0,0,PM_REMOVE)) { //如果对话框proc $将对话消息进行处理b $ b if((hWndApp!= NULL)&& IsDialogMessageW(hWndApp,& msg)) { continue; } TranslateMessage(& msg); DispatchMessageW(& msg); } } 返回static_cast< int>(msg.wParam); } void CColorBasics :: Update(){ HANDLE events [] = {m_hNextColorFrameEvent,m_hSpeechEvent}; DWORD ret = WaitForMultipleObjects(2,events,FALSE,INFINITE); if(WAIT_OBJECT_0 == ret) ProcessColor() else if((WAIT_OBJECT_0 + 1)== ret) ProcessSpeech()} 问题是我不认为曾经调用ProcessSpeech()函数,如果我翻转订单,从不调用ProcessColor()。它们都是单独工作,而不是在我的实现中。任何帮助将不胜感激!解决方案 Hey, hopefully someone can help me out here. Im trying to use the Kinect's audio and color stream for image detection and speech recognition in c++. The only problem is I can only get one working at a time... When the Color stream is on it's not recognizing speech, and vice versa. It probably has something to do with my Update() functions, but I just have no idea what to do. Here are the relevant sample functions: int CColorBasics::Run(HINSTANCE hInstance, int nCmdShow){MSG msg = { 0 };WNDCLASS wc;// Dialog custom window classZeroMemory(&wc, sizeof(wc));wc.style = CS_HREDRAW | CS_VREDRAW;wc.cbWndExtra = DLGWINDOWEXTRA;wc.hInstance = hInstance;wc.hCursor = LoadCursorW(NULL, IDC_ARROW);wc.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));wc.lpfnWndProc = DefDlgProcW;wc.lpszClassName = L"ColorBasicsAppDlgWndClass";if (!RegisterClassW(&wc)){return 0;}// Create main application windowHWND hWndApp = CreateDialogParamW(hInstance,MAKEINTRESOURCE(IDD_APP),NULL,(DLGPROC)CColorBasics::MessageRouter,reinterpret_cast<LPARAM>(this));// Show windowShowWindow(hWndApp, nCmdShow);while (WM_QUIT != msg.message){// Check to see if we have either a message (by passing in QS_ALLINPUT)// Or a Kinect event (events)// Update() will check for Kinect events individually, in case more than one are signalledMsgWaitForMultipleObjects(2, events, FALSE, INFINITE, QS_ALLINPUT);// Explicitly check the Kinect frame event since MsgWaitForMultipleObjects// can return for other reasons even though it is signaled.Update();while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)){// If a dialog message will be taken care of by the dialog procif ((hWndApp != NULL) && IsDialogMessageW(hWndApp, &msg)){continue;}TranslateMessage(&msg);DispatchMessageW(&msg);}}return static_cast<int>(msg.wParam);}void CColorBasics::Update() {HANDLE events[] = { m_hNextColorFrameEvent, m_hSpeechEvent };DWORD ret = WaitForMultipleObjects(2, events, FALSE, INFINITE);if (WAIT_OBJECT_0 == ret)ProcessColor()else if ((WAIT_OBJECT_0 + 1) == ret) ProcessSpeech()}The problem is I don't think the ProcessSpeech() function is ever called, and if I flip the order, the ProcessColor() is never called. They both work individually, just not together in my implementation. Any help would be appreciated! 解决方案 这篇关于结合音频流和彩色流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 00:57