Trigger iSight to take photo every minute.

I am using a macbook pro. I need to take a photo with the built in iSight camera every 60 seconds but without drawing the camera image on the app. Is there a relatively simple way to do this.

Thanks.

The iSight just comes up as one of the available sources for ofVideoGrabber, IIRC. Try listDevices() and you’ll be sure. Then do some time-checking and save a frame, something like this:

  
  
  
if(ofGetElapsedTimef() - lastEventTime >= 60.0f){  
     lastEventTime = ofGetElapsedTimef();  
     videoGrabber.grabFrame();  
     image.setFromPixels(videoGrabber.getPixels());  
     images.saveImage(ofToString(lastEventTime, 0));  
}  
  

Good luck!

Thank you for this. I think this will work however, I am getting this error:

class ofxCvColorImage’ has no member named ‘saveImage’.

Do you know how to fix this.

Thank you.

Don’t use ofxCvColorImage, that is part of the openCV addon. Use ofImage, that class has a method saveImage().

Ok, I have got it compiling with no errors. Although there is no image being saved within the data folder.

The code I am using is:

in testapp.h

  
ofImage 			image;  
ofVideoGrabber 		videoGrabber;  

in testapp.cc
in setup()

  
  
#ifdef _USE_LIVE_VIDEO  
	videoGrabber.setVerbose(true);  
	videoGrabber.initGrabber(1024,768);  
#else  
	vidPlayer.loadMovie("test.mov");  
	vidPlayer.play();  
#endif  
	  
	image.allocate(1024, 768, OF_IMAGE_COLOR);  
  

in update()

  
  
	bool bNewFrame = false;  
	  
#ifdef _USE_LIVE_VIDEO  
	videoGrabber.grabFrame();  
	bNewFrame = videoGrabber.isFrameNew();  
#else  
	vidPlayer.idleMovie();  
	bNewFrame = vidPlayer.isFrameNew();  
#endif  
	  
	if (bNewFrame){  
		  
#ifdef _USE_LIVE_VIDEO  
		//image.setFromPixels(videoGrabber.getPixels());  
		image.setFromPixels(videoGrabber.getPixels(), 1024, 768, OF_IMAGE_COLOR);   
#else  
		//colorImg.setFromPixels(vidPlayer.getPixels(), 240,180);  
#endif  
  

in draw()

  
  
if(ofGetElapsedTimef() - lastEventTime >= 10.0f){    
		lastEventTime = ofGetElapsedTimef();    
		videoGrabber.grabFrame();    
		image.setFromPixels(videoGrabber.getPixels(), 1024, 768, OF_IMAGE_COLOR);  
		image.saveImage(ofToString(lastEventTime, 0));  
		ofSetColor(255,255,255);  
		ofRect(0, 0, 1024, 768);  
		}   
	  
  

Thank you.

try with:

  
image.saveImage(ofToString(lastEventTime, 0)+".jpg");   

freeimage guesses the format from the extension so if you use none it won’t know how to save the image

Yeah works like a dream. Thank you.