diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index ea0ea5a..779c61a 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -117,7 +117,6 @@ void RefractiveIndex::setup() _analysisVector.push_back(new ColorMultiAnalysis()); _analysisVector.push_back(new DiffNoiseAnalysis()); - _currentAnalysisIndx = 0; _currentAnalysis = _analysisVector.at(_currentAnalysisIndx); diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index ee69b48..3a0273f 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -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; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 51f795d..322ae90 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -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; @@ -115,10 +115,10 @@ 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++; fileNameTag = "FADING"; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index 152a993..873678c 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -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 { diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index 2956e6e..caf53a6 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -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() @@ -69,6 +72,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 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: { + cout << "ShadowScapesAnalysis = STATE_SYNTHESISING...\n"; + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); - _state = STATE_DISPLAY_RESULTS; + 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; } diff --git a/src/ShadowScapesAnalysis.h b/src/ShadowScapesAnalysis.h index f30258b..b919720 100755 --- a/src/ShadowScapesAnalysis.h +++ b/src/ShadowScapesAnalysis.h @@ -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; }; \ No newline at end of file diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 9ee14e0..960df87 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -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;