Пример #1
0
int parse_gesture(const unsigned char *raw) {

    Packet *p = init_packet(raw);

    printf("%s\n", get_gesture(p));
    destroy_packet(p);

    return 0;

}
Пример #2
0
int parse_packet(const unsigned char *raw) {

    Packet *p = init_packet(raw);

    printf("x=%f\ty=%f\tz=%f\tval=%f\n", p->acc_x, p->acc_y, p->acc_z, p->w);

    printf("gesture=%s\narm=%s\n", get_gesture(p), get_arm(p));
    destroy_packet(p);

    return 0;

}
void Cinderactor::draw() const
{
    // Loading message
    if( !init_ok )
    {
        gl::color( ColorA( 0.0,0.0,0.0,0.5));
        Rectf rect(0, 0, 300, 100);
        rect.offsetCenterTo(ci::app::getWindowCenter());
        gl::drawSolidRoundedRect(rect, 10);
        gl::drawStringCentered(	"Loading models... please wait...", ci::app::getWindowCenter() );
        gl::color(1.0,1.0, 1.0, 1.0);
        return;
    }

    draw_hand_representation( get_hands().first,   Vec2f(200, 70 ) );
    draw_hand_representation( get_hands().second,  Vec2f(70,  70 ) );
   
       std::stringstream ss;
        ss<<"Static : "<<get_gesture().id <<std::endl;
        gl::drawStringCentered(	ss.str(), Vec2f( 330, 30), Color(0.7, 0.8, 0.9) );
    
}
Пример #4
0
void ExampleWorker::do_work(ExampleWindow* caller)
{
  {
    Glib::Threads::Mutex::Lock lock(m_Mutex);
    m_has_stopped = false;
    m_text_done = "";
    m_message = "";
  } // The mutex is unlocked here by lock's destructor.

  // Simulate a long calculation.
  /* Start sign to speech conversion. */
    while( true ){
        Glib::Threads::Mutex::Lock lock(m_Mutex);
        /* Check if sensor data is available. */
        if( file_exists(fName) ){
	    /* Collect next set of data and store it as a gesture. */ 
  	    scrText.SetStatus( "Reading:\t" + string(fName) + "\n" ) ;
   	    output_to_display( scrText, true ) ;
            /* Add delay to make sure file has finished being written to before attempting to read. */
  	    nanosleep( &t1, &t2 ) ;
            if( rename(fName, intfName) != 0 ){
       	        scrText.SetStatus( "Unable to rename file:\t" + string(fName) + "\n" ) ;
	    }
            if( get_gesture( nextHand, intfName, scrText, doc, sensorStatus, xmlVersion, convert ) ){
                /* Store the next gesture set of data. */
                nextGesture = Gesture( nextHand[0], nextHand[1] ) ;     
                /* Update display for the next set of sensor values. */
  	        scrText.SetGestureData( nextGesture.AsString() ) ;
                /* Indicate file was successfully read. */
		scrText.SetStatus( "Successfully read:\t" + string(fName) + "\n" ) ;
                /* Rename the file so as not to re-read it. */
                if( rename(intfName, newfName) != 0 ){
  	   	    scrText.SetStatus( "Unable to rename file:\t" + string(intfName) + "\n" ) ;
		}
   	        output_to_display( scrText, true ) ;
	    }
	    else{
  	        scrText.SetStatus( "*** Error reading file. Attempting to continue ***\n" ) ;
        	output_to_display( scrText, true ) ;
		continue ;
	    }
            /* Convert the gesture to text. */
            if( gesture_to_text(nextGesture, db, m_text_done, scrText, motion, added_text) ){
		motion = false ;
  	        if( motion_gesture( m_text_done, j_motion, invalid_j, completed_j, NUM_J_MOTION, "J" ) || 
                    motion_gesture( m_text_done, z_motion, invalid_z, completed_z, NUM_Z_MOTION, "Z" ) ){
  	  	    motion = true ;
  	        }
                /* Output the text to display */
  	        scrText.SetGestureConv( m_text_done + "\n" ) ;
		if( added_text ){
		    nanosleep( &t3, &t4 ) ;
		}
            	lock.release();
    		caller->notify();
                output_to_display( scrText, true ) ;
	    }
	    else{
	        /* Gesture to text error. */
	        scrText.SetStatus( "*** Unable to convert gesture to text. Attempting to continue ***\n" ) ;
                output_to_display( scrText, true ) ;
		continue ;
	    }
  	    scrText.SetStatus( "Wrote:\t" + string(outfName) + "\n" ) ;
            /* Update XML file. */
            if( !output_xml(outfName, m_text_done, nextGesture, sensorStatus, xmlVersion) ){
  	        scrText.SetStatus( "Error while writing:\t" + string(outfName) + "\n" ) ;
	    }
   	    output_to_display( scrText, true ) ;
	}

    }
  Glib::Threads::Mutex::Lock lock(m_Mutex);
  m_shall_stop = false;
  m_has_stopped = true;
  lock.release();
  caller->notify();
}