void ofxSpriteRenderer::Update()
{
	float delta_time = 0.0f;
	
	if(ofGetFrameRate() > 1)
		delta_time = 1.0/ofGetFrameRate();
#ifdef _DEBUG
	unsigned long long time_start_update = ofGetSystemTime();
#endif
	float width = m_RenderRect.width;
	float height = m_RenderRect.height*2.0;
	m_WorldRect.x = m_Camera->getPosition().x - width*0.5;
	m_WorldRect.y = m_Camera->getPosition().z - height*0.5;
	m_WorldRect.width = width;
	m_WorldRect.height = height;
	m_ExpandedWorldRect = ofRectangle(
		m_WorldRect.x - FAR_SCREEN_DISTANCE_THRESHOLD, 
		m_WorldRect.y - FAR_SCREEN_DISTANCE_THRESHOLD, 
		m_WorldRect.width + FAR_SCREEN_DISTANCE_THRESHOLD*2, 
		m_WorldRect.height + FAR_SCREEN_DISTANCE_THRESHOLD*2);
	ofxBaseSprites::iterator it = m_Sprites.begin();
	for(;it != m_Sprites.end();it++)
	{
		ofxBaseSprite* item = *it;
		item->Update(delta_time);
		item->SubmitChanges();
	}
	m_CameraMove = false;
	m_CameraForce = false;
#ifdef _DEBUG
	unsigned long long time_finish_update = ofGetSystemTime();
	m_UpdateTimeMilisecond = time_finish_update - time_start_update;
#endif
}
Пример #2
0
void recompileAndReload() {
	printf("File is modified, reloading\n");    
    long t = ofGetSystemTime();
	system("make live");
	reload();
	
	printf("Reload took %ldms\n", ofGetSystemTime() - t);
}
Пример #3
0
//--------------------------------------------------------------
void testApp::update(){
    switch (demo) {
        case OSCILLATIONS:{
            ildaFrame.getPolys().clear();
            ildaFrame.addPoly(ofFloatColor(
                                           (int)ofGetElapsedTimef()%3,
                                           (int)ofGetElapsedTimef()%5,
                                           (int)ofGetElapsedTimef()%7,
                                           1));
            ofxIlda::Poly& p = ildaFrame.getLastPoly();
            p.clear();
            for (int i = 0 ; i < 35 ; i ++){
                float t = (ofGetElapsedTimef() + i * 0.5);
                float scale = sqrt(abs(sin(ofGetElapsedTimef())));
                ofPoint pnt = (ofPoint(0.5,0.5) + scale * ofPoint(0.5*cos(t*1.1), 0.5*sin(t)));
                p.lineTo(pnt);
            }
            break;
        }
        case MILKYWAY:{
            ildaFrame.getPolys().clear();
            ildaFrame.addPoly(ofFloatColor(
                                           (int)ofGetElapsedTimef()%11,
                                           (int)ofGetElapsedTimef()%5,
                                           (int)ofGetElapsedTimef()%7,
                                           1));
            
            ofxIlda::Poly& q = ildaFrame.getLastPoly();
            q.clear();
            
            for (int i = 0 ; i < 150 ; i ++){
                float t = (ofGetElapsedTimef() + i*0.5);
                float scale  = sqrt(i/150.0);
                ofPoint pnt = (ofPoint(0.5,0.5) + scale * ofPoint(0.5*cos(t*1.1), 0.5*sin(t)));
                q.lineTo(pnt);
            }
            
            break;
        }
        default:
            ildaFrame.clear();
            break;
    }
    
//    drawSomething(EYE, ofPoint(0.5,0.5), 0.2, ofFloatColor(0,1,1,1));
    
    drawSomething(TRIANGLE, ofPoint(0.5,0.5), 0.05*(sqrt(ofGetSystemTime()%53)), ofFloatColor(1,0,0,1));
    drawSomething(TRIANGLE, ofPoint(0.5,0.5), 0.05*(sqrt(ofGetSystemTime()%73)), ofFloatColor(0,0,1,1));
    drawSomething(TRIANGLE, ofPoint(0.5,0.5), 0.05*(sqrt(ofGetSystemTime()%101)), ofFloatColor(1,1,0,1));

}
Пример #4
0
//--------------------------------------------------------------
void ofApp::update() {
    grabber.update();
    if(grabber.isFrameNew()) {
        frames_one_sec++;
        if( ofGetSystemTime() - one_second_time >= 1000) {
            camera_fps = frames_one_sec;
            frames_one_sec = 0;
            one_second_time = ofGetSystemTime();
        }
        colorCv = grabber.getPixels();
        colorCvSmall.scaleIntoMe(colorCv, CV_INTER_NN);
        grayCv = colorCvSmall;
        faceFinder.findHaarObjects(grayCv);
        faces = faceFinder.blobs;
    }
}
Пример #5
0
void ofxGuiGrid::selectedColor() {
	mNowTime = ofGetSystemTime();
	//printf( "old: %ld\n now: %ld\n", oldTime, now );
	if ( mNowTime - mOldTime >= mInterval ) {
		mOldTime = mNowTime;
		if ( mRising ) {
			mColorR += mOffset;
			mColorG += mOffset;
			mColorB += mOffset;
		} else {
			mColorR -= mOffset;
			mColorG -= mOffset;
			mColorB -= mOffset;
		}

		if ( mColorR >= 1 ) {
			mRising = false;
		} else if ( mColorR <= 0 ) {
			mRising = true;
		}

		// printf( "\nR: %f\n", mColorR );
	}


}
Пример #6
0
void ofxMarsyasNetwork::threadedFunction()
{
  while( isThreadRunning() )
  {
    if (priority != targetPriority)
    {
      run();
      priority = targetPriority;
    }

    // cout << "ofxMarsyasNetwork trying to lock" << endl;
    if (lock())
    {
      // cout << "ofxMarsyasNetwork in lock" << endl;

      tick();
      thisTick = ofGetSystemTime();
      rate = ofLerp(rate, 1000.0/(thisTick-lastTick), 0.001);
      lastTick = thisTick;

      update();
      unlock();
      // cout << "ofxMarsyasNetwork after unlock()" << endl;

    }
    else {
      // cout << "ofxMarsyasNetwork sleeping" << endl;
      ofSleepMillis(20);
    }

    if (targetRate>0)
      ofSleepMillis(1000.0/targetRate);
  }
}
Пример #7
0
//--------------------------------------------------------------
void testApp::update(){
	unsigned long long cur_time = ofGetSystemTime();
	
	// grid needs to be regenerated every draw due to random noise 
	// TODO maybe we can use a separate buffer for noise and do displacement in shader
	generateGrid();

	//rotate and zoom camera
	double tick_double = double(cur_time % 2000)/2000;
	
	double scale = abs(tick_double - 0.5) * 3;
	if (move_camera)
	{
		theCamera.position.x = cos(tick_double * 2 * PI) * scale;
		theCamera.position.y = 0.35f;
		theCamera.position.z = sin(tick_double * 2 * PI) * scale ;
	}
	else
	{
		theCamera.position.x = 0;
		theCamera.position.y = 0.35f;
		theCamera.position.z = -1.1f ;
	}

	theCamera.target.x = 0;
	theCamera.target.y = 0;
	theCamera.target.z = 0;
	theCamera.roll = 0.0;

}
Пример #8
0
ofxGuiGrid::ofxGuiGrid() {
	mParamType = kofxGui_Object_Grid;

	mWidthScale = GRID_WIDTH_SCALE;
	mHeightScale = GRID_HEIGHT_SCALE;

	mSelectedId = -1;

	mIndexOffset = 0;

	mOldTime = ofGetSystemTime();
	mInterval = 50;		// 50 ms
	mOffset = 0.05f;	// color changing offset
	mRising = true;

	mIsSelectable = false;
	mValidSelection = false;
	mDraggingRawIndex = -1;

	mIsActive = true;	// default: active

	bDrawSelectedText = false;

	bShowResetBtn = false;
	bShowSettingBtn = false;

	bDblClickMode = false;
	bCanDblClickMode = false;
	mPrevClickTime = 0;
	dblClickImage = new ofxGuiImage();
}
Пример #9
0
//----------------------------------------
void ofxOpenNITracker::setUserState(unsigned int nID, ofxOpenNIUser::TrackingState userState)
{
//  if (users.find(nID) != users.end())
  {
    users[nID].state = userState;
    users[nID].stateChangedTimestamp = ofGetSystemTime();
  }
}
Пример #10
0
void testApp::update() {
	videoGrabber.update();
	if (videoGrabber.isFrameNew()) {
		if (ofGetSystemTime() - previousCaptureTime > captureInterval) {
			capture();
		}
	}
}
Пример #11
0
void idle(void) {
	long t = ofGetSystemTime();
	// check update time on the file
	if(t>lastTimeChecked+100) { // check every 300ms
		checkAndUpdate();
		lastTimeChecked = t;
	}
}
//--------------------------------------------------------------
void CloudsVHXAuth::update(ofEventArgs& args)
{
    if (bNotifyComplete) {
        
        //Wait to ensure the thread has stopped
        //JG Added this... Elie please advise
        waitForThread(true);
        
        Mode completedMode = mode;
        mode = WAITING;
        if (completedMode == REQUEST_TOKEN) {
            ofNotifyEvent(requestTokenComplete, completeArgs);
        }
        else if (completedMode == REFRESH_TOKEN) {
            ofNotifyEvent(refreshTokenComplete, completeArgs);
        }
        else if (completedMode == REQUEST_CODE) {
            ofNotifyEvent(requestCodeComplete, completeArgs);
        }
        else if (completedMode == LINK_CODE) {
            ofNotifyEvent(linkCodeComplete, completeArgs);
        }
        else if (completedMode == VERIFY_PACKAGE) {
            ofNotifyEvent(verifyPackageComplete, completeArgs);
        }

        bNotifyComplete = false;
    }
    
    time_t nowTime = (ofGetSystemTime() / 1000.f);
    
    // Refresh token if it's expired.
    if (mode == WAITING && _tokenExpiry && nowTime > _tokenExpiry) {
        if (_refreshToken.empty()) {
            requestToken();
        }
        else {
            refreshToken();
        }
    }
    
    // Reset code if it's expired.
    if (_codeExpiry && nowTime > _codeExpiry) {
        _code = "";
        _codeExpiry = 0;
        
        CloudsVHXEventArgs args;
        ofNotifyEvent(codeExpired, args);
    }
    
    // Update state if package expired.
    if (state == RENTAL && _packageExpiry && nowTime > _packageExpiry) {
        state = EXPIRED;

        CloudsVHXEventArgs args;
        ofNotifyEvent(packageExpired, args);
    }
}
Пример #13
0
//------------------------------------------------------------------
void xmlParty::setFileNameSave(string iOSDocumentsDirectory, ofxXmlSettings& _XMLOne, ofxXmlSettings& _XMLTwo, button& _mathButton, vector <drawing>& _drawThese, vector<flagState>& _theFlagStates, string& theText) {
    
    
    //    welcomeButton.thisString = "welcome "+_setUserName+"!";
    //float stringSize = welcomeButton.thisString.size();
    
    //    welcomeButton.offSet.set(415, 35);
    
    
    //ASSIGN ALL THE BUTTON INFO HERE
    
    
    _mathButton.XMLFileOne = ofToString(ofGetSystemTime()) + "_" + _mathButton.myCreateProbRefresh;
    _mathButton.XMLFileTwo = ofToString(ofGetSystemTime()) + "_" + _mathButton.myReflectProbRefresh;
    xmlSetupThang(iOSDocumentsDirectory, _XMLOne, _XMLTwo, _mathButton);
    saveXML(iOSDocumentsDirectory, _XMLOne, _XMLTwo, _mathButton, _drawThese, _theFlagStates, theText);

//    mathTwoButton.XMLFileOne = ofToString(ofGetSystemTime()) + "_myCreateProbTwo.xml";
//    mathTwoButton.XMLFileTwo = ofToString(ofGetSystemTime()) + "_myReflectProbTwo.xml";
//    xmlSetupThang(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathTwoButton.XMLFileOne, mathTwoButton.XMLFileTwo);
//    saveXML(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathTwoButton.XMLFileOne, mathTwoButton.XMLFileTwo, mathTwoButton.problemText);
//    
//    mathThreeButton.XMLFileOne = ofToString(ofGetSystemTime()) + "_myCreateProbThree.xml";
//    mathThreeButton.XMLFileTwo = ofToString(ofGetSystemTime()) + "_myReflectProbThree.xml";
//    xmlSetupThang(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathThreeButton.XMLFileOne, mathThreeButton.XMLFileTwo);
//    saveXML(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathThreeButton.XMLFileOne, mathThreeButton.XMLFileTwo, mathThreeButton.problemText);
//    
//    mathFourButton.XMLFileOne = ofToString(ofGetSystemTime()) + "_myCreateProbFour.xml";
//    mathFourButton.XMLFileTwo = ofToString(ofGetSystemTime()) + "_myReflectProbFour.xml";
//    xmlSetupThang(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathFourButton.XMLFileOne, mathFourButton.XMLFileTwo);
//    saveXML(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathFourButton.XMLFileOne, mathFourButton.XMLFileTwo, mathFourButton.problemText);
//    
//    mathFiveButton.XMLFileOne = ofToString(ofGetSystemTime()) + "_myCreateProbFive.xml";
//    mathFiveButton.XMLFileTwo = ofToString(ofGetSystemTime()) + "_myReflectProbFive.xml";
//    xmlSetupThang(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathFiveButton.XMLFileOne, mathFiveButton.XMLFileTwo);
//    saveXML(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathFiveButton.XMLFileOne, mathFiveButton.XMLFileTwo, mathFiveButton.problemText);
//    
//    mathSixButton.XMLFileOne = ofToString(ofGetSystemTime()) + "_myCreateProbSix.xml";
//    mathSixButton.XMLFileTwo = ofToString(ofGetSystemTime()) + "_myReflectProbSix.xml";
//    xmlSetupThang(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathSixButton.XMLFileOne, mathSixButton.XMLFileTwo);
//    saveXML(iOSDocumentsDirectory, _XMLOne, _XMLTwo, mathSixButton.XMLFileOne, mathSixButton.XMLFileTwo, mathSixButton.problemText);
//    
    
    
}
Пример #14
0
bool timer::isFinished() {
        // Check how much time has passed
        passedTime = ofGetSystemTime();
        if (passedTime - savedTime > totalTime) {
            return true;
        } else {
            return false;
        }
}
Пример #15
0
TBlob::TBlob (const ABlob * b) {
	
	TBlob::TBlob();	
	
//	id = ImageBlobs::idnumbers++;
	id = ImageBlobs::idnumbers;
	pixelcount = b->pixelcount;	
	boxminx = b->boxminx;
	boxminy = b->boxminy;
	boxmaxx = b->boxmaxx;
	boxmaxy = b->boxmaxy;
	boxcenterx = b->boxcenterx;
	boxcentery = b->boxcentery;
	boxdimx = b->boxdimx;
	boxdimy = b->boxdimy;
	pboxcenterx = boxcenterx;
	pboxcentery = boxcentery;
	//		ivelx = b->ivelx;
	//		ively = b->ively;
	
	cx = b->cx;
	cy = b->cy;
	bx = b->bx;
	by = b->by;
	dimx = b->dimx;
	dimy = b->dimy;
	
	armleftx = b->armleftx;
	armlefty = b->armlefty;
	armrightx = b->armrightx;
	armrighty = b->armrighty;
	headx = b->headx;
	heady = b->heady;
	bottomx = b->bottomx;
	bottomy = b->bottomy;
	footleftx = b->footleftx;
	footlefty = b->footlefty;
	footrightx = b->footrightx;
	footrighty = b->footrighty;
	
	
	// TBlob specific
	
	newblob=true;
	birthtime=ofGetSystemTime();//System.currentTimeMillis();
	lifetime = ofxFlob::TBlobLifeTime;
	presencetime = 1;
	linked=false;
	
	pcx = cx;
	pcy = cy;
	prevelx=prevely=velx=vely=0.0f;
	maxdist2 = ofxFlob::TBlobMaxDistSquared;//2555f;//1000;//~31px//100;
	calcrad();
	
}
Пример #16
0
Score testApp::recordMiss() {
	Score score;
	score.difficulty = difficulty;
	score.time = ofGetSystemTime() - startTime;
	
	misses.push_back(score);
	latestScore = score;
	
	return score;
}
KinectMarkerTracker::KinectMarkerTracker() {
  _hasResult = false;

  contourFinder.setTargetColor(ofColor(64, 153, 33), ofxCv::TRACK_COLOR_RGB);
  contourFinder.setMinAreaRadius(1);
  contourFinder.setMaxAreaRadius(10);
  contourFinder.setThreshold(50);

  foundTime = ofGetSystemTime();
}
Пример #18
0
void smlWriter::saveFile(){
    float stopTime = ofGetElapsedTimef();
    if(scratchMLfile.getNumTags("sml")>0){
        while(scratchMLfile.getPushLevel() > 0){
            scratchMLfile.popTag();
        }
        scratchMLfile.addValue("sml:performance:time:duration", stopTime-startTime);
        scratchMLfile.saveFile(fileName);
        scratchMLfile.clear();
        fileName = "session-"+ofToString(ofGetSystemTime())+".xml";
        newFile(fileName);
    }
}
Пример #19
0
void testApp::updateParticles() {
    // cycle through hue every minute
    long systemTime = ofGetSystemTime();
    ofColor particleColor = getParticleColor();
    for(int i = 0; i < PARTICLE_COUNT; i++) {
        Particle::particle_state oldState = particles[i].state;
        particles[i].update(systemTime);
        
        particles[i].baseColor = particleColor;
        Particle::particle_state newState = particles[i].state;
        if(particles[i].state == Particle::INACTIVE && oldState == Particle::FALLING)
            inactiveParticles.push_back(i);
    }
}
//--------------------------------------------------------------
bool CloudsVHXAuth::setup()
{
    _keysPath = GetCloudsDataPath(true) + "vhx/client.bin";
    _tokensPath = GetCloudsDataPath(true) + "vhx/tokens.bin";
    
    // Load and decrypt the info from files on disk.
    //string path = GetCloudsDataPath() + "vhx/client.bin";
    if (CloudsCryptoLoadKeys(_clientId, _clientSecret, _packageId, _keysPath)) {
        ofLogNotice("CloudsVHXAuth::setup") << "Loaded keys successfully:\n"
        << "\tClient ID: " << _clientId << "\n"
        << "\tClient Secret: " << _clientSecret << "\n"
        << "\tPackage ID: " << _packageId;
    }
    else {
        ofLogError("CloudsVHXAuth::setup") << "Cannot open file at " << _keysPath;
    }
    
    if (CloudsCryptoLoadTokens(_accessToken, _refreshToken, _tokenExpiry, _tokensPath)) {
        ofLogNotice("CloudsVHXAuth::setup") << "Loaded tokens successfully:\n"
        << "\tAccess Token: " << _accessToken << "\n"
        << "\tRefresh Token: " << _refreshToken << "\n"
        << "\tToken Expiry: " << _tokenExpiry;
    }
    else {
        ofLogError("CloudsVHXAuth::setup") << "Cannot open file at " << _tokensPath;
        
        _tokenExpiry = 0;
    }
    
    state = INACTIVE;
    mode = WAITING;
    bNotifyComplete = false;
    ofAddListener(ofEvents().update, this, &CloudsVHXAuth::update);
    
    if (_packageId.size() && _accessToken.size()) {
        time_t nowTime = (ofGetSystemTime() / 1000.f);
        if (_tokenExpiry > nowTime) {
            // Try to verify the package immediately.
            verifyPackage();
        }
        else {
            // Refresh the token first, it's expired.
            refreshToken();
        }
        
        return true;
    }
    
    return false;
}
Пример #21
0
void testApp::makeParticleAt(const ofVec3f &pt, ofColor c) {
    if(inactiveParticles.size() == 0) {
        return;
    }
    int idx = inactiveParticles.front();
    Particle *p = &particles[idx];
    p->location.x = pt.x + ofRandom( -100, 100);
    p->location.y = pt.y + ofRandom( -100, 100);
    p->location.z = pt.z + ofRandom( -100, 100);
    p->velocity = ofVec3f(0);
    p->acceleration = ofVec3f(0);
    p->state = Particle::BORN;
    p->bornTime = ofGetSystemTime();
    p->baseColor = c;
    inactiveParticles.pop_front();
}
Пример #22
0
void testApp::drawParticles() {
	ofMesh mesh;
	mesh.setMode(OF_PRIMITIVE_POINTS);
    auto systemTime = ofGetSystemTime();
    for(int i = 0; i < PARTICLE_COUNT; i++) {
        particles[i].addToMesh(mesh, systemTime);
    }
	glPointSize(2);
	ofPushMatrix();
    // TODO: clean these up.
	// the projected points are 'upside down' and 'backwards'
	ofTranslate(0, 0, 0); // center the points a bit
	ofEnableDepthTest();
	mesh.drawVertices();
	ofDisableDepthTest();
	ofPopMatrix();
}
Пример #23
0
//--------------------------------------------------------------
void testApp::draw(){
	

	unsigned long long cur_time = ofGetSystemTime();

	update_p_matrix(proj_mat, screen_width, screen_height);
	update_mv_matrix(mv_mat, 0);
	glMatrixMode(GL_PROJECTION);
	glLoadMatrixf(proj_mat);
	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf(mv_mat);

	if (!use_easycam) look();
	else easycam.begin();

	glVertexPointer(3,GL_FLOAT,sizeof(GLfloat)*3,(void*)0);
	glEnableClientState(GL_VERTEX_ARRAY);
    
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer);
    glDrawElements(
		GL_QUADS,
		e_buffer_size, /* count */
		GL_UNSIGNED_INT,
        (void*)0            /* element array buffer offset */
    );
	glDisableClientState(GL_VERTEX_ARRAY);

	// print framerate to stdout every second
	static unsigned long long last_fps_tick = 0;	
	if (cur_time > last_fps_tick + 1000)
	{
		last_fps_tick = cur_time;
		cout <<  ofToString(ofGetFrameRate(), 2) << " fps" << endl;
	}

	GLenum err = glGetError();
	if (err)
	{
		//breakpoint?
		if (false)
		cout << "error" << endl;
	}
	last_time = cur_time;

	if (use_easycam) easycam.end();
}
Пример #24
0
//------------------------------------------------------------------
void pointRecorder::addPoint(ofPoint pt) {
	
	
	// on the first point, grab the start time
	if (pts.size() == 0){
		//startTime = ofGetSystemTime();
	} 
	
	
	// combine the position and the time here: 
	timePt	myPoint;
	myPoint.pos			= pt;
	myPoint.time		= (ofGetSystemTime() - startTime)/1000.0;
	
	pts.push_back(myPoint);
	if (pts.size() > maxNumPts){
		pts.erase(pts.begin());
	}
}
Пример #25
0
void testApp::setup() {
	deviceId = 0;
	captureId = 0;
	
	// Increment by 1000 until we find a good filename.
	ofFile file;
	file.open(captureFilename(captureId));
	while (file.exists()) {
		captureId += 1000;
		file.open(captureFilename(captureId));
	}

	videoGrabber.setVerbose(true);
	videoGrabber.setDeviceID(deviceId);
	videoGrabber.initGrabber(640, 480);

	captureInterval = 60 * 1000;
	previousCaptureTime = ofGetSystemTime();
}
//--------------------------------------------------------------
void currentColor::update() {

    transSpeed = (float) colorTime / colorDuration;
    currentTime = ofGetSystemTime() - startTime;//how long the sketch has been running in m

    for ( int i = 0; i < nBars; i ++ ) {
        currentColors[ i ] = fromColors[ i ].getLerped( toColors[ i ], transSpeed );
    }
    
    if ( colorTime >= colorDuration ) {
        cycles ++;
        lastColors = nextColors;
        
        for ( int i = 0; i < nBars; i ++ ) {
            nextColors[ i ] ++;
            
            if ( nextColors[ i ] > imgWidth - 1 ) {
                nextColors[ i ] = 0;
            }
            
            fromColors[ i ] = colorPalettePixels.getColor( lastColors[ i ], 0 );
            toColors[ i ] = colorPalettePixels.getColor( nextColors[ i ], 0 );

        }
        
        colorPosition ++;
        
        if ( colorPosition > imgWidth ) {
            colorPosition = 0;
        }
        
    }

    
     if ( cycles > 1 ) {
         colorTime = currentTime - ((cycles - 1 ) * colorDuration );
     }
    
     else {
         colorTime = currentTime;
     }
 
}
Пример #27
0
void VideoGrabber::update() {
    if(!isMainThread()) {
        // Textures must be loaded in main thread.
        cerr << "update() may not be called from outside the main "
             << "thread.  Returning.";
        return;
    }
    if (connected_) {
        bool wasNewFrame = false;
        unsigned long now = ofGetSystemTime();
        //
        // BEGIN CRITICAL SECTION
        //
        mutex.lock();

        elapsedTime_ = (initTime_ == 0) ? 0 : (now - initTime_);
        if (backBufferReady_) {
            ++framesRendered_;
            swap(pixelsFront_, pixelsBack_);
            backBufferReady_ = false;
            wasNewFrame = true;
        }

        mutex.unlock();
        //
        // END CRITICAL SECTION
        //

        if (wasNewFrame) {
            texture_.loadData(pixelsFront_);
            if(elapsedTime_ > 0) {
                currentFrameRate_ = (float(framesRendered_) /
                                     (elapsedTime_ / (1000.0f)));
                currentBitRate_ = (float(bytesReceived_) * 8.0f /
                                   (elapsedTime_ / (1000.0f)));
            } else {
                currentFrameRate_ = 0.0;
                currentBitRate_   = 0.0;
            }
        }
    }
}
Пример #28
0
// resets all values
void basicEffect::reset(){
	ofScopedLock lock(effectMutex);
	
	// todo: do this in _reset() which then calls reset();
	aliveSince=0;
	startTime=ofGetSystemTime();

	shapes.clear();
	shapes.resize(0);
	
	bInitialised = true;
	bHasError = false;
	bEnabled = false;
	bIsLoading = false;
	bShowGuiWindow = false;
	effectName = effectType;
	bUsePingpong = false;
	
	overallBoundingBox = ofRectangle(0,0,0,0);
}
Пример #29
0
//--------------------------------------------------------------
void ofApp::setup() {
    ofBackground(255,255,255);
    ofSetLogLevel(OF_LOG_NOTICE);
    ofSetOrientation(OF_ORIENTATION_90_LEFT);

    int grabberWidth = 320;
    int grabberHeight = 240;
    grabber.setup(grabberWidth,grabberHeight);

    colorCv.allocate(grabberWidth, grabberHeight);
    colorCvSmall.allocate(grabberWidth/4, grabberHeight/4);
    grayCv.allocate(grabberWidth/4, grabberHeight/4);

    faceFinder.setup("haarcascade_frontalface_default.xml");
    faceFinder.setNeighbors(1);
    faceFinder.setScaleHaar(1.5);

    one_second_time = ofGetSystemTime();
    camera_fps = 0;
    frames_one_sec = 0;
}
void KinectMarkerTracker::update() {
  _hasResult = false;
  result = ofVec3f();

  depthImage.setFromPixels(kinect->getPixelsRef());
  contourFinder.findContours(depthImage);

  long now = ofGetSystemTime();
  if (now > foundTime + 5000) {
    if (contourFinder.size() > 0 && contourFinder.getContourArea(0) > 0) {
      ofVec3f pScreen = ofxCv::toOf(contourFinder.getCentroid(0));
      ofVec3f pWorld = kinect->getWorldCoordinateAt(pScreen.x, pScreen.y);

      if (pWorld.x != 0 && pWorld.y != 0 && pWorld.z != 0) {
        _hasResult = true;
        result = pWorld;
        foundTime = now;
      }
    }
  }
}