예제 #1
0
void CHydraHmdLatest::DebugRequest( const char * pchRequest, char * pchResponseBuffer, uint32_t unResponseBufferSize )
{
	std::istringstream ss( pchRequest );
	std::string strCmd;

	ss >> strCmd;
	if ( strCmd == "hydra:realign_coordinates" )
	{
		// hydra_monitor is calling us back with HMD tracking information so we can
		// finish realigning our coordinate system to the HMD's
		float m[3][3], v[3];
		for ( int i = 0; i < 3; ++i )
		{
			for ( int j = 0; j < 3; ++j )
			{
				// Note the transpose, because sixenseMath::Matrix3 and vr::HmdMatrix34_t disagree on row/col major
				ss >> m[j][i];
			}
			ss >> v[i];
		}
		sixenseMath::Matrix3 matRot( m );
		sixenseMath::Vector3 matPos( v );

		FinishRealignCoordinates( matRot, matPos );
	}
예제 #2
0
	////////////////// Shadow Suppression ////////////////////////
	void ForegroundProcessor::suppressShadows(Frame & frame, double minArea, double minDist)
	{
		
		//Create "most probable background"
		if (shadowModel.empty())
			shadowModel =  Mat::zeros(frame.image.size(), CV_8UC3);
		frameCounter++;
		if (frameCounter < 10)
		{
			shadowModel += (frame.image / 10);
			return;
		}

		vector<vector<Point>> contours;
		findContours( frame.foreground.clone(), contours, CV_RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);

		Mat lastImage = frame.image.clone();
		cvtColor(lastImage, lastImage, CV_BGR2HSV_FULL);
		
		double objArea;
		Rect objRect;
		double dist = 0;
		
		for(unsigned int i = 0; i < contours.size(); i++)
		{	
			objArea = contourArea(contours[i]);
			objRect = boundingRect(contours[i]);
			vector<Point> contour = contours[i];

			for( int j = objRect.x; j < objRect.x + objRect.width; j++)
			{ 
				for( int k = objRect.y; k < objRect.y + objRect.height; k++) 
				{ 
					Point matPos(j,k);
					//If object is not outside the contour
					if (pointPolygonTest(contour, matPos, false) >= 0) 
					{
						// Parameters for shadow detection
						if (  ((abs((double)lastImage.at<Vec3b>(matPos)[0] - (double)shadowModel.at<Vec3b>(matPos)[0])/255 < tau_H) )		// HUE
							&& ( ((double)lastImage.at<Vec3b>(matPos)[1] - (double)shadowModel.at<Vec3b>(matPos)[1])/255 < tau_S)			// SATURATION
							&& ( (double)lastImage.at<Vec3b>(matPos)[2] / ((double)shadowModel.at<Vec3b>(matPos)[2] + 0.0001) > alpha)	// VALUE (ALPHA)
							&& ( (double)lastImage.at<Vec3b>(matPos)[2] / ((double)shadowModel.at<Vec3b>(matPos)[2] + 0.0001) < beta)	// VALUE (BETA)
							)
						{
							//Color gray for visualisation
							frame.foreground.at<uchar>(matPos) = 128;
						}
					} 
				}		
			}
		}
	}
예제 #3
0
void S3D_MASTER::Render( bool aIsRenderingJustNonTransparentObjects,
                         bool aIsRenderingJustTransparentObjects )
{
    if( m_parser == NULL )
        return;
    
    double aVrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;

    glScalef( aVrmlunits_to_3Dunits, aVrmlunits_to_3Dunits, aVrmlunits_to_3Dunits );

    glm::vec3 matScale( m_MatScale.x,
                        m_MatScale.y,
                        m_MatScale.z );

    glm::vec3 matRot( m_MatRotation.x,
                      m_MatRotation.y,
                      m_MatRotation.z );

    glm::vec3 matPos( m_MatPosition.x,
                      m_MatPosition.y,
                      m_MatPosition.z );

    glTranslatef( matPos.x * SCALE_3D_CONV,
                  matPos.y * SCALE_3D_CONV,
                  matPos.z * SCALE_3D_CONV );

    glRotatef( -matRot.z, 0.0f, 0.0f, 1.0f );
    glRotatef( -matRot.y, 0.0f, 1.0f, 0.0f );
    glRotatef( -matRot.x, 1.0f, 0.0f, 0.0f );

    glScalef( matScale.x, matScale.y, matScale.z );

    for( unsigned int idx = 0; idx < m_parser->childs.size(); idx++ )
    {
        m_parser->childs[idx]->openGL_RenderAllChilds( aIsRenderingJustNonTransparentObjects,
                                                       aIsRenderingJustTransparentObjects );
    }
}