fixed fades and added the animation for ShadowScapesAnalysis (which will be the same for all analyses - just havne't copied it over yet)

also tried to add a key-press trigger for each analysis but wasn't able to turn off prior analyses without hanging the whole programme
This commit is contained in:
Jamie Allen 2012-02-20 01:47:46 +01:00
parent f2593aed49
commit b045f44bf1
7 changed files with 108 additions and 32 deletions

View File

@ -118,7 +118,6 @@ void RefractiveIndex::setup()
_analysisVector.push_back(new DiffNoiseAnalysis());
_currentAnalysisIndx = 0;
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx);

View File

@ -109,7 +109,7 @@ void CamNoiseAnalysis::draw()
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
aColour.set(0, 0, 0, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
aColour.set(0, 0, 0, 255-ofMap(_frame_cnt-(_frame_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
// cout << "FADE OUT STROBE TIME " << endl;

View File

@ -18,7 +18,7 @@ using Poco::Thread;
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
{
DELTA_T_SAVE = 300; //300 is the right number here
DELTA_T_SAVE = 100; //300 is the right number here
NUM_PHASE = 1;
NUM_RUN = 1;
NUM_SAVE_PER_RUN = 100;
@ -116,8 +116,8 @@ void ColorSingleAnalysis::draw()
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max){
ofSetColor(0, 0, 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255));
cout << "255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255)"<< 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255) << endl;
int fade = ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255);
ofSetColor(0, 0, 255-fade);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_fade_cnt++;

View File

@ -18,13 +18,13 @@ using Poco::Thread;
void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
{
DELTA_T_SAVE = 600; // right number is about 450
DELTA_T_SAVE = 100; // right number is about 600
NUM_PHASE = 1;
NUM_RUN = 1;
NUM_SAVE_PER_RUN = 50;
create_dir();
_fade_cnt=0;
//_fade_cnt=0;
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@ -92,12 +92,12 @@ void DiffNoiseAnalysis::draw()
}
}
cout << "FADING IN..." << endl;
//cout << "FADING IN..." << endl;
}
if (_frame_cnt >= _fade_in_frames && _frame_cnt < (_frame_cnt_max-_fade_in_frames)){
if (_frame_cnt >= _fade_in_frames && _frame_cnt <= (_frame_cnt_max-_fade_in_frames)){
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
{
@ -113,25 +113,23 @@ void DiffNoiseAnalysis::draw()
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt <= _frame_cnt_max) {
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
{
for (int j=1; j < ofGetWidth(); j=j+rectSize)
{
c = ofRandom(0,255);
aColour.set(c, c, c, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
aColour.set(c, c, c, 255-ofMap(_frame_cnt-(_frame_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(j, i, rectSize, rectSize);
}
}
_fade_cnt++;
cout << "FADING OUT..." << endl;
//_fade_cnt++;
//cout << "FADING OUT..." << endl;
}
ofDisableAlphaBlending();
} else {

View File

@ -58,6 +58,9 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
_scanLineWidth = 100.0;
_run_cnt = 0;
_save_cnt = 0;
int anim_time = 5; // 5 seconds
_anim_cnt_max = 5*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames
}
void ShadowScapesAnalysis::acquire()
@ -70,6 +73,7 @@ void ShadowScapesAnalysis::acquire()
_step = ((screenSpan/_speed) * 1000.0) / 500.0;
_line = 0;
// RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) {
@ -77,7 +81,7 @@ void ShadowScapesAnalysis::acquire()
TimerCallback<ShadowScapesAnalysis> save_callback(*this, &ShadowScapesAnalysis::save_cb);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
save_timer.start(save_callback);
@ -165,25 +169,22 @@ void ShadowScapesAnalysis::draw()
}
if(_dir == V && int(_line) >= (ofGetHeight()+4*_scanLineWidth)){
cout << "VERTICAL IS DONE - _line >= (ofGetHeight()+4*_scanLineWidth) is TRUE" << endl;
//_state = STATE_SYNTHESISING;
_RUN_DONE = true;
//cout << "VERTICAL IS DONE - _line >= (ofGetHeight()+4*_scanLineWidth) is TRUE" << endl;
_state = STATE_SYNTHESISING;
}
if(_dir == H && int(_line) >= (ofGetWidth()+4*_scanLineWidth)) {
//cout << "HORIZONTAL IS DONE - _line >= (ofGetWidth()+4*_scanLineWidth)) is TRUE" << endl;
//_state = STATE_SYNTHESISING;
_RUN_DONE = true;
_state = STATE_SYNTHESISING;
}
if(_dir == D && int(_line) >= (1.5*ofGetHeight()+4*_scanLineWidth)) {
//cout << "DIAGONAL IS DONE - _line >= (1.5*ofGetHeight()+4*_scanLineWidth)) is TRUE" << endl;
//_state = STATE_SYNTHESISING;
_RUN_DONE = true;
_state = STATE_SYNTHESISING;
}
break;
@ -191,15 +192,93 @@ void ShadowScapesAnalysis::draw()
case STATE_SYNTHESISING:
{
// display animation of something while the synthesis in on-going...
cout << "ShadowScapesAnalysis = STATE_SYNTHESISING...\n";
_state = STATE_DISPLAY_RESULTS;
// display animation of something while the synthesis in on-going...
ofEnableAlphaBlending();
ofSetRectMode(OF_RECTMODE_CENTER);
if(_anim_cnt < _anim_cnt_max){
ofColor aColour;
int rectSizeW = ofGetWidth()/4;
int rectSizeH = ofGetWidth()/4;
int _fade_in_frames = _anim_cnt_max/10;
int c_anim = 10;
int fade;
if (_anim_cnt < _fade_in_frames) {
cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n";
fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255);
cout << "fade up = " << fade << endl;
for (int i=0; i < ofGetHeight() ; i=i+rectSizeH)
{
for (int j=0; j < ofGetWidth(); j=j+rectSizeW)
{
c_anim = ofRandom(150,255);
aColour.set(c_anim, c_anim, c_anim, fade);
ofSetColor(aColour);
ofRect(ofGetWidth()/2, ofGetHeight()/2, rectSizeW, rectSizeH);
}
}
}
if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){
for (int i=0; i < ofGetHeight() ; i=i+rectSizeH)
{
for (int j=0; j < ofGetWidth(); j=j+rectSizeW)
{
c_anim = ofRandom(150,255);
//c = ofRandom(0,255);
aColour.set(c_anim, c_anim, c_anim, 255);
ofSetColor(aColour);
ofRect(ofGetWidth()/2, ofGetHeight()/2, rectSizeW, rectSizeH);
}
}
}
if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _frame_cnt <= _anim_cnt_max) {
cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl;
fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255);
cout << "fade down = " << fade << endl;
for (int i=0; i < ofGetHeight() ; i=i+rectSizeH)
{
for (int j=0; j < ofGetWidth(); j=j+rectSizeW)
{
c_anim = ofRandom(150,255);
//c = ofRandom(0,255);
aColour.set(c_anim, c_anim, c_anim, 255-fade);
ofSetColor(aColour);
ofRect(ofGetWidth()/2, ofGetHeight()/2, rectSizeW, rectSizeH);
}
}
}
_anim_cnt++;
} else {
_state = STATE_DISPLAY_RESULTS;
_anim_cnt=0;
}
ofSetRectMode(OF_RECTMODE_CORNER);
ofDisableAlphaBlending();
break;
}
case STATE_DISPLAY_RESULTS:
{
// display results of the synthesis
cout << "ShadowScapesAnalysis = STATE_DISPLAY_RESULTS...\n";
_RUN_DONE = true;
break;
}

View File

@ -64,7 +64,7 @@ protected:
float _scanLineWidth; // pix per second
float _step;
shadow_type _dir;
int _run_cnt, _save_cnt;
float c, _frame_cnt, _frame_cnt_max;
int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt;
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
};

View File

@ -22,7 +22,7 @@ void StrobeAnalysis::setup(int camWidth, int camHeight)
_strobe_cnt = 0;
_strobe_cnt_max = 20; // 40 x 500 ms = 20000 ms = 20 seconds run time
_strobe_interval = 1000; //every 0.5seconds = 15 frames
_strobe_interval = 1500; //every 0.5seconds = 15 frames
_frame_cnt_max = _strobe_cnt_max * _strobe_interval * ofGetFrameRate()/1000;
// The British Health and Safety Executive recommend that a net flash rate for a bank of strobe lights does not exceed 5 flashes per second, at which only 5% of photosensitive epileptics are at risk. It also recommends that no strobing effect continue for more than 30 seconds, due to the potential for discomfort and disorientation.
@ -114,7 +114,7 @@ void StrobeAnalysis::draw()
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
aColour.set(255, 255, 255, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
aColour.set(255, 255, 255, 255-ofMap(_frame_cnt-(_frame_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
// cout << "FADE OUT STROBE TIME " << endl;