/**
			@brief	Wait until all the kinect handler updated
		*/
		void Kinect::WaitAndUpdateAll()
		{
			std::vector< HANDLE >   handle;
			if ( VideoStream().hStream_ != NULL ) {
				handle.push_back( VideoStream().event_.get() );
			}

			if ( DepthStream().hStream_ != NULL ) {
				handle.push_back( DepthStream().event_.get() );
			}

			if( AudioStream().hStream_ != NULL ) {
				handle.push_back( AudioStream().event_.get() );
			}

			if ( Skeleton().IsEnabled() ) {
				handle.push_back( Skeleton().event_.get() );
			}

			if ( handle.size() == 0 ) {
				return;
			}

			DWORD ret = ::WaitForMultipleObjects( handle.size(), &handle[0], TRUE, INFINITE );
			if ( ret == WAIT_FAILED ) {
				return;
			}
		}
Exemple #2
0
		/**
			@brief	Get color pixels coodinates from depth pixels
		*/
		LONG Kinect::GetColorPixelCoordinatesFromDepthPixel(LONG lDepthPixel, USHORT usDepthValue)
		{
			LONG lDepthX, lDepthY;
			if(lDepthPixel == 0 || DepthStream().Width() == 0){
				return -1;
			}

			lDepthX = (LONG)(lDepthPixel % DepthStream().Width());
			lDepthY = (LONG)(lDepthPixel / DepthStream().Width());
			LONG plColorX = 0, plColorY = 0;

			HRESULT ret = sensor_->NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution(
				VideoStream().Resolution(), 
				DepthStream().Resolution(), 
				NULL,
				lDepthX, 
				lDepthY, 
				usDepthValue, 
				&plColorX, 
				&plColorY
				);
			if(FAILED(ret)) {
				return -1;
			}

			LONG plColorPixel = plColorY * VideoStream().Width() + plColorX;
			return plColorPixel;
		}
Exemple #3
0
		/**
			@brief	Wait until the kinect handler updated
		*/
		void Kinect::WaitAndUpdate(UINT flag)
		{
			std::vector< HANDLE >   handle;
			
			if ( VideoStream().hStream_ != NULL && (flag & UPDATE_FLAG_VIDEO)) {
				handle.push_back( VideoStream().event_.get() );
			}

			if ( DepthStream().hStream_ != NULL && (flag & UPDATE_FLAG_DEPTH)) {
				handle.push_back( DepthStream().event_.get() );
			}

			if( AudioStream().hStream_ != NULL && (flag & UPDATE_FLAG_AUDIO)) {
				handle.push_back( AudioStream().event_.get() );
			}

			if ( Skeleton().IsEnabled() && (flag & UPDATE_FLAG_SKELETON)) {
				handle.push_back( Skeleton().event_.get() );
			}

			if ( handle.size() == 0 ) {
				return;
			}

			DWORD ret = ::WaitForMultipleObjects( handle.size(), &handle[0], TRUE, INFINITE );
			if ( ret == WAIT_FAILED ) {
				return;
			}
		}
Exemple #4
0
		bool Kinect::GetColorFrameCoordinatesFromDepthFrame(USHORT* pDepthValues, LONG* pColorCoordinates){
			HRESULT ret = sensor_->NuiImageGetColorPixelCoordinateFrameFromDepthPixelFrameAtResolution(
				VideoStream().Resolution(), 
				DepthStream().Resolution(), 
				DepthStream().Width() * DepthStream().Height(),
				pDepthValues,
				DepthStream().Width() * DepthStream().Height() * 2,
				pColorCoordinates);

			if(FAILED(ret)){
				return false;
			}

			return true;
		}
Exemple #5
0
bool  IHomeSession::DealRequest(Request *req,int sock)
{

    if(!authOK && req->cmdNo != AUTH_REQ)
    {
         log.Log("SES",DEBUG,"Req: cmdNo:%u,login failed auth false",req->cmdNo);
        return false;
    }
    document = new  TiXmlDocument;
    if(req->bodyLen > 0)
    {
    document->Parse((char *)req->body);
    root = document->RootElement();
    }
    switch(req->cmdNo)
    {
    case AUTH_REQ :     //认证请求
         log.Log("SES",DEBUG,"Req: cmdNo:%u,start login %d",req->cmdNo,sock);
        Auth(req,sock);
        break;
    case VIDEO_REQ:         //视频请求
         log.Log("SES",DEBUG,"Req: cmdNo:%u,start video %d",req->cmdNo,sock);
        Video(req,sock);
        break;
    case VIDEO_END_REQ:         //结束视频请求
        VideoEnd(req,sock);
        break;
    case VIDEO_STM:             //视频流请求
        VideoStream(req,sock);
        break;
    case  QUIT_REQ:             //退出请求
        Quit(req,sock);
        break;
    default:
        break;
    }
    return true;
}