Camera flash

I want to take a picture every 30 seconds and I am doing this using the following code:

  
if(ofGetElapsedTimef() - lastEventTime >= 30.0f){  
		lastEventTime = ofGetElapsedTimef();    
		videoGrabber.grabFrame();   
		image.setFromPixels(videoGrabber.getPixels(), 1024, 768, OF_IMAGE_COLOR);  
		image.saveImage(ofToString(lastEventTime, 0)+".jpg");  
		loadCounter = loadCounter + 5;  
		cout << "save image now" << endl;  

I want the screen to flash white for the exact time that the image I am saving is grabbed.

If I use this code:

  
if(ofGetElapsedTimef() - lastEventTimeTwo >= 30.0f){  
		lastEventTimeTwo = ofGetElapsedTimef();    
		flash();  
		  
		}  
  
void testApp::flash() {  
	  
	ofSetColor(255,255,255);  
	ofRect(0, 0, 1024, 768);  
	//cout << "screen is white" << endl;  
	bliss.setText("Capturing Image");  
	bliss.drawCenter(ofGetWidth()/2, ofGetHeight()/2);  
}  

The screen turns white for a millisecond around the time that it saves the image, but it is not synced and therefore it does not light up the image. Is there are way to either sync up these two functions, or just make the screen white for longer and make sure the image is grabbed at this time.

If anyone could provide some code for me to try that would be great, I have hit a dead end with this.

Thank you.

Sorry to bug…anyone got any idea on this one?

I needed this for an iPad app and did it like this:

in testApp::update():

  
  
if(shouldSave){  
    saveImage();  
    shouldFlash = true;  
    shouldSave = false;  
}  
  

in testApp::draw():

  
  
if(shouldFlash){  
	flash();  
}  
  

  
  
void testApp::flash(){  
	flashValue -= 10;  
	ofSetColor(255, 255, 255, flashValue);  
	ofRect(0, 0, ofGetWidth(), ofGetHeight());  
	if(flashValue < 1){  
		bFlash = false;  
		flashValue = 255.0f;  
	}  
}  
  

testApp::save() would be your own method for saving the image. Since I’m on iOS, with only one processing core, I can’t do the flashing and the saving at the same time. This means there is a small delay before the flash starts in which the image is actually being saved. For me this is no big deal though. If you’re on a platform capable of multithreading, you could save threaded (there is a threaded image-saver somewhere on this forum) and do the flash at the same time as the saving.