void testApp::calibrationDone(ofPolyline &_surface){
    ofLog(OF_LOG_NOTICE, "Calibration done");
    
    if ( bStart )
        killGame();
    
    if (activeGameName == "simon"){
        game = new Simon();
    } else if (activeGameName == "pong"){
        game = new Pong();
    } else if (activeGameName == "shadows"){
        game = new Shadows();
    } else if (activeGameName == "oca"){
        game = new Oca();
    } else if (activeGameName == "communitas"){
        game = new Communitas();
    } else if (activeGameName == "kaleido"){
        game = new Kaleido();
    }
    
    if (game != NULL){
        ofLog(OF_LOG_NOTICE, "Game " + activeGameName + " loaded");
        game->init( _surface.getBoundingBox() );
        iSurface.setTrackMode( game->getTrackMode() );
        bStart = true;
    } else {
        ofLog(OF_LOG_ERROR, "Game " + activeGameName + " not loaded.");
        bStart = false;
    }
}
Example #2
0
void scanner_faces::draw_featEnMarco(ofPolyline feat, int gap, bool uu, bool rr) {
	
	ofRectangle featRect;
	featRect = feat.getBoundingBox();
	featRect.x-=gap;
	featRect.y-=gap;
	featRect.width+=2*gap;
	featRect.height+=2*gap;
	
	ofSetLineWidth(1);
	if(rr) {
		ofLine(marco.rect.x-marco.gap, featRect.y, featRect.x, featRect.y);
		ofLine(marco.rect.x-marco.gap, featRect.y+featRect.height, featRect.x, featRect.y+featRect.height);
	}
	else {
		ofLine(marco.rect.x+marco.rect.width+marco.gap, featRect.y, featRect.x, featRect.y);
		ofLine(marco.rect.x+marco.rect.width+marco.gap, featRect.y+featRect.height, featRect.x, featRect.y+featRect.height);
	}
	
	if(uu) {
		ofLine(featRect.x, featRect.y, featRect.x, marco.rect.y-marco.gap);
		ofLine(featRect.x+marco.rect.width, featRect.y, featRect.x+marco.rect.width+marco.gap, featRect.y);
	}
	else {
		ofLine(featRect.x, featRect.y, featRect.x, marco.rect.y+marco.rect.height+marco.gap);
		ofLine(featRect.x+featRect.width, featRect.y, 
			   featRect.x+featRect.width, marco.rect.y+marco.rect.height+marco.gap);
	}
	
	ofSetLineWidth(2.5);
	ofRect(featRect);
	
}
Example #3
0
void testApp::oscSendContour(int label, const ofPolyline &polyline){
    ofxOscMessage m;
    stringstream ss;
    ss<<"/contour";
    m.setAddress(ss.str());
    
    int size = polyline.size();
    m.addIntArg(label);
    m.addIntArg(size);
    cout<<"contour: "<<label<<" size: "<<size<<endl;
    const ofRectangle& rect = polyline.getBoundingBox();
    m.addIntArg(rect.getTopLeft().x);
    m.addIntArg(rect.getTopLeft().y);
    m.addIntArg(rect.getBottomRight().x);
    m.addIntArg(rect.getBottomRight().y);
    ofPolyline newLine = polyline.getResampledByCount(100);
    cout<<"resized to "<<newLine.size()<<endl;
//    newLine.draw();
    
    if(bSendContours){
        const vector<ofPoint> points = newLine.getVertices();
        for(int i=0; i< newLine.size(); i++){
            m.addFloatArg(points[i].x);
            m.addFloatArg(points[i].y);
        }
    }
    sender.sendMessage(m);
}
/*
 * This function takes a polyline and checks whether its bounding box (along the x-axis) is within that of the face's.
 * This is more reliable than simply checking whether that polyline's centroid lies within the face's bounding box because we
 * get rid of ancilliary polylines that might cover huge regions of the image plane (and thus have valid centroids) but aren't
 * necessarily part of the facial features.
 */
bool FaceScanner::compareBoundingBox(ofPolyline &other, float distThreshold)
{
    ofRectangle otherRect = other.getBoundingBox();
    if ( otherRect.x > (m_faceBoundingBox.x - MIN_HORZ_DISTANCE_TO_FACE) &&
        (otherRect.x + otherRect.width) < (m_faceBoundingBox.x + m_faceBoundingBox.width + MIN_HORZ_DISTANCE_TO_FACE) &&
         otherRect.y > (m_faceBoundingBox.y - MIN_VERT_DISTANCE_TO_FACE) &&
        (otherRect.y + otherRect.height) < (m_faceBoundingBox.y + m_faceBoundingBox.height + MIN_VERT_DISTANCE_TO_FACE))
    {
        return true;
    }
    
    return false;
}