none
Handling of Frame Arrived Events in C++ (VisualGestureBuilderFrame, BodyFrame) RRS feed

  • Question

  • Hello,

    I have a problem concerning the handling of frame arrived events using the VisualGestureBuilder. I am using C++ so I found some examples where the function waitForMultipleObjects() is used. in my application I wait for an body event and 6 VisualGestureBuilder events (one for every possible person which is tracked). Everything seems to work fine until a person leaves the scene. Then the function waitForMultipleObjects() blocks and nothing happens anymore. A strange thing is, that if I do a cout directly after waitForMultipleObjects(), it works.

    So I tried to handle the trackingIDLost Event for every VisualGestureBuilderSource, but that does not work. One time I received a trackingIDLost Event, maybe it was luck. Is it a problem waiting for 13 handles? I read that only the event with the lowest number is returned by the function. Although MAXIMUM_WAIT_OBJECTS is 64....

    I thought about a pointer problem, but I think I fixed some forgotten pointer releases. My question first of all: Is the following code ok or do I use the Kinect API or the waitForMultipleObjects function in a false way?

    // for every VisualGestureBuilder frame/source (I spare the other 5)
    hr = vgbFrameReader->SubscribeFrameArrived(&vgbh1);
    			hr = vgbFrameSource->SubscribeTrackingIdLost(&lost1);
    
    HANDLE handles[13] = { reinterpret_cast<HANDLE>(hBodyFrameEvent), reinterpret_cast<HANDLE>(vgbh1), reinterpret_cast<HANDLE>(vgbh2), reinterpret_cast<HANDLE>(vgbh3), reinterpret_cast<HANDLE>(vgbh4), reinterpret_cast<HANDLE>(vgbh5), reinterpret_cast<HANDLE>(vgbh6), reinterpret_cast<HANDLE>(lost1), reinterpret_cast<HANDLE>(lost2), reinterpret_cast<HANDLE>(lost3), reinterpret_cast<HANDLE>(lost4), reinterpret_cast<HANDLE>(lost5), reinterpret_cast<HANDLE>(lost6) };
    	
    	int idx;
    	IVisualGestureBuilderFrameArrivedEventArgs *vgbFrameArgs = nullptr;
    	IBodyFrameArrivedEventArgs *bodyArgs = nullptr;
    	bool quit = false;
    	while (!quit) {
    		// Wait for any of the events to be signalled
    		//cout << "before"<< endl;
    		idx = WaitForMultipleObjects(_countof(handles), handles, FALSE, 1000);
    		
    //with this cout it seems to work
    //cout << "after" << endl;
    		
    		switch (idx) {
    		case WAIT_TIMEOUT:
    			std::cout << "WAIT_TIMEOUT" << std::endl;
    			continue;
    		case WAIT_FAILED:
    			std::cout << "WAIT_FAILED" << std::endl;
    			continue;
    		
    		case WAIT_OBJECT_0:
    			
    			hr = bodyFrameReader->GetFrameArrivedEventData(hBodyFrameEvent, &bodyArgs);
    			BodyFrameArrived(bodyArgs);
    			bodyArgs->Release();
    			break;
    		case WAIT_OBJECT_0+1:
    			hr = vgbFrameReaders[0]->GetFrameArrivedEventData(vgbh1, &vgbFrameArgs);
    			VGBFrameArrived(vgbFrameArgs);
    			vgbFrameArgs->Release();
    			break;
    		case WAIT_OBJECT_0 + 2:
    			hr = vgbFrameReaders[1]->GetFrameArrivedEventData(vgbh2, &vgbFrameArgs);
    			VGBFrameArrived(vgbFrameArgs);
    			vgbFrameArgs->Release();
    			break;
    		case WAIT_OBJECT_0 + 3:
    			hr = vgbFrameReaders[2]->GetFrameArrivedEventData(vgbh3, &vgbFrameArgs);
    			VGBFrameArrived(vgbFrameArgs);
    			vgbFrameArgs->Release();
    			break;
    		case WAIT_OBJECT_0 + 4:
    			hr = vgbFrameReaders[3]->GetFrameArrivedEventData(vgbh4, &vgbFrameArgs);
    			VGBFrameArrived(vgbFrameArgs);
    			vgbFrameArgs->Release();
    			break;
    		case WAIT_OBJECT_0 + 5:
    			hr = vgbFrameReaders[4]->GetFrameArrivedEventData(vgbh5, &vgbFrameArgs);
    			VGBFrameArrived(vgbFrameArgs);
    			vgbFrameArgs->Release();
    			break;
    		case WAIT_OBJECT_0 + 6:
    			hr = vgbFrameReaders[5]->GetFrameArrivedEventData(vgbh6, &vgbFrameArgs);
    			VGBFrameArrived(vgbFrameArgs);
    			vgbFrameArgs->Release();
    			break;
    		case WAIT_OBJECT_0 + 7:
    			cout << "lost" << endl;
    			break;
    		case WAIT_OBJECT_0 + 8:
    			cout << "lost" << endl;
    			break;
    		case WAIT_OBJECT_0 + 9:
    			cout << "lost" << endl;
    			break;
    		case WAIT_OBJECT_0 + 10:
    			cout << "lost" << endl;
    			break;
    		case WAIT_OBJECT_0 + 11:
    			cout << "lost" << endl;
    			break;
    		case WAIT_OBJECT_0 + 12:
    			cout << "lost" << endl;
    			break;
    		}

    Thank you for answering! Regards



    • Edited by nyuki00 Monday, June 1, 2015 10:47 AM
    Monday, June 1, 2015 10:46 AM

Answers

All replies