Grabframe every minute

Hi,

Should be quite simple but I can’t figure out how to use a timer in order to grab a frame from the webcam every minute while keeping the former frame so it’ll eventually be quite a few still frames underneath the video.

  
 bTimerReached = false;  
    time = ofGetElapsedTimeMillis();  
     endtime = (int)60000;  
      
  

  
float timer = ofGetElapsedTimeMillis() -time;  
    if(timer >= endtime ) {  
        bTimerReached = true;  
          
        
    }  
      
    if(bTimerReached) {  
    
         
        ofDrawBitmapString("Timer Reached!", (ofGetWidth()-100)/2, (ofGetHeight()/2)+70);  
        movie.update();  
         bTimerReached = false;   
        time=ofGetElapsedTimeMillis();  
       // timer=0;  
    }  
      
      
  

ofGetElapsedTimeMillis() isn’t a float, so that might be part of your problem. It’s a little weird comparing things that have decimals (floats) and things that don’t (ints). Other than that, you’re taking the right approach. I don’t see any code for grabbing from a camera but maybe you’re just working this part out first?

movie.update(); should call grab frame at least that was my understanding from the documentation?

ofVideoPlayer update() is for working with video files. You would want the update() method of ofVideoGrabber:

  
  
	vidGrabber.update();  
	  
	if (vidGrabber.isFrameNew()){  
		ofPixels pixels = vidGrabber.getPixelsRef();  
	}  
  

movie is an instance of video grabber but I’m still having a bit of trouble. I’ve tried:

  
(movie.isFrameNew());  
            colorImg.setFromPixels(movie.getPixelsRef());  

Thanks for the help!