diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index 1d11061..57df9c2 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -8,6 +8,9 @@ ~ contact: dviid@labs.ciid.dk */ +////also the new shit//// + + #include "RefractiveIndex.h" #include "ShadowScapesAnalysis.h" @@ -94,13 +97,14 @@ void RefractiveIndex::setup() //getting a warning from the OFlog that the pixels aren't allocated //void ofPixels::allocate(int w, int h, ofImageType type) + _pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR); //TODO: whichever one of these is first - it always runs twice ? - // _analysisVector.push_back(new ShadowScapesAnalysis(V)); - // _analysisVector.push_back(new ShadowScapesAnalysis(H)); - // _analysisVector.push_back(new ShadowScapesAnalysis(D)); + _analysisVector.push_back(new ShadowScapesAnalysis(V)); + _analysisVector.push_back(new ShadowScapesAnalysis(H)); + _analysisVector.push_back(new ShadowScapesAnalysis(D)); _analysisVector.push_back(new RelaxRateAnalysis()); @@ -205,10 +209,11 @@ void RefractiveIndex::setup_camera() { stop_camera(); - if(!_vidGrabber.initGrabber(_vid_w, _vid_h)) { + if(!_vidGrabber.initGrabber(_vid_w, _vid_h)) { ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber"; return; } + _vidGrabber.listDevices(); _vidGrabber.setVerbose(true); _vid_stream_open = true; diff --git a/example/RefractiveIndex.h b/example/RefractiveIndex.h index 278974c..aa96c2c 100644 --- a/example/RefractiveIndex.h +++ b/example/RefractiveIndex.h @@ -1,8 +1,3 @@ -/* - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ #pragma once diff --git a/example/main.cpp b/example/main.cpp index cea5f27..847eef7 100755 --- a/example/main.cpp +++ b/example/main.cpp @@ -4,21 +4,15 @@ #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 -/////////////////////////dis is the new shit/////////// - -/////////////////////////dis is the new shit/////////// - -/////////////////////////dis is the new shit/////////// - -/////////////////////////dis is the new shit/////////// +////also the new shit//// int main() { ofAppGlutWindow window; ofxXmlSettings XML; XML.loadFile("../data/config.refindx"); - bool fullscreen = (XML.getValue("config:display:fullscreen", "false") == "true" ? true : false); + bool fullscreen = (XML.getValue("config:display:fullscreen", "true") == "true" ? true : false); int screen_w = XML.getValue("config:display:width", SCREEN_WIDTH); int screen_h = XML.getValue("config:display:height", SCREEN_HEIGHT); diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 4d8b78d..bffc774 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -41,6 +41,9 @@ void AbstractAnalysis::do_synthesize() { _state = STATE_SYNTHESISING; synthesise(); _state = STATE_DISPLAY_RESULTS; + + //displayresults(); + ofNotifyEvent(_synthesize_cb, _name); } diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index d689039..c6f9584 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -13,19 +13,25 @@ using Poco::Thread; void CamNoiseAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 200; - NUM_PHASE = 1; + NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + + int acq_run_time = 20; // 20 seconds of acquiring per run + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames create_dir(); - + _frame_cnt = 0; - _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; - int anim_time = 10; // 10 seconds + int anim_time = 5; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + + create_dir(); } @@ -54,12 +60,17 @@ void CamNoiseAnalysis::acquire() Thread::sleep(3); save_timer->stop(); + + _RUN_DONE = false; } } void CamNoiseAnalysis::synthesise() -{ +{ // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); + } @@ -81,7 +92,7 @@ void CamNoiseAnalysis::draw() ofColor aColour; int _fade_in_frames = _frame_cnt_max/10; - float _number_of_grey_levels=10; + float _number_of_grey_levels=5; float _frames_per_level = _frame_cnt_max / _number_of_grey_levels; ofColor someColor; @@ -119,8 +130,8 @@ void CamNoiseAnalysis::draw() } else { - _state = STATE_SYNTHESISING; - // _RUN_DONE = true; + // _state = STATE_SYNTHESISING; + _RUN_DONE = true; } _frame_cnt++; @@ -200,7 +211,8 @@ void CamNoiseAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + _RUN_DONE = true; + //_state = STATE_DISPLAY_RESULTS; _anim_cnt=0; } ofPopMatrix(); @@ -214,7 +226,6 @@ void CamNoiseAnalysis::draw() { // display results of the synthesis _RUN_DONE = true; - break; } diff --git a/src/CamNoiseAnalysis.h b/src/CamNoiseAnalysis.h index 1a98100..ae94617 100755 --- a/src/CamNoiseAnalysis.h +++ b/src/CamNoiseAnalysis.h @@ -28,6 +28,6 @@ protected: bool _RUN_DONE; - int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 9ac780a..de3ba4d 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -13,19 +13,26 @@ using Poco::Thread; void ColorMultiAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 150; // the right number is about 300 - NUM_PHASE = 1; + + NUM_RUN = 1; - NUM_SAVE_PER_RUN = 300; + + int acq_run_time = 35; + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames create_dir(); + _frame_cnt = 0; - _fade_cnt=0; - _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; - int anim_time = 10; // 10 seconds + int anim_time = 5; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + + create_dir(); } @@ -53,8 +60,9 @@ void ColorMultiAnalysis::acquire() Thread::sleep(3); save_timer->stop(); + _RUN_DONE = false; + } - } void ColorMultiAnalysis::synthesise() @@ -69,15 +77,16 @@ void ColorMultiAnalysis::draw() switch (_state) { case STATE_ACQUIRING: { + ofEnableAlphaBlending(); if (_frame_cnt < _frame_cnt_max) { - int _fade_in_frames = _frame_cnt_max/50; + ofColor aColor; if (_frame_cnt < _fade_in_frames) { - ofColor aColor; + aColor.setHsb(c, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255), ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255)); @@ -87,9 +96,10 @@ void ColorMultiAnalysis::draw() cout << "FADING IN..." << endl; } + + if (_frame_cnt >= _fade_in_frames && _frame_cnt < _frame_cnt_max-_fade_in_frames){ - ofColor aColor; aColor.setHsb(c, 255, 255); ofSetColor(aColor); @@ -99,29 +109,26 @@ void ColorMultiAnalysis::draw() ofRect(0, 0, ofGetWidth(), ofGetHeight()); } - 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) { - ofColor aColor; + aColor.set(c, c, c, 255-int(ofMap(_frame_cnt-(_frame_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255))); - aColor.setHsb(c, 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255), 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255)); + //aColor.setHsb(c, 255-ofMap(_fade_cnt- (_frame_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255), 255-(ofMap(_fade_cnt-(_frame_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255))); ofSetColor(aColor); ofRect(0, 0, ofGetWidth(), ofGetHeight()); - - _fade_cnt++; cout << "FADING OUT..." << endl; } + } else { - _state = STATE_SYNTHESISING; - - //_RUN_DONE = true; - + //_state = STATE_SYNTHESISING; + _RUN_DONE = true; } _frame_cnt++; - + ofDisableAlphaBlending(); break; } diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index b3c1d5d..2756d81 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -13,24 +13,34 @@ using Poco::Thread; void ColorSingleAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 100; //300 is the right number here - NUM_PHASE = 1; + NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + + int acq_run_time = 20; // 20 seconds of acquiring per run + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames create_dir(); + _frame_cnt = 0; - _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); + c = 0; + + int anim_time = 5; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + + create_dir(); + + + NUM_RUN = 1; + r = 0; g = 0; b = 0; - _fade_cnt=0; fileNameTag = ""; - - - int anim_time = 10; // 10 seconds - _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames } @@ -59,12 +69,15 @@ void ColorSingleAnalysis::acquire() Thread::sleep(3); save_timer->stop(); + _RUN_DONE = false; } } void ColorSingleAnalysis::synthesise() { // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); } @@ -126,8 +139,8 @@ void ColorSingleAnalysis::draw() } } else { - _state = STATE_SYNTHESISING; - //_RUN_DONE = true; + //_state = STATE_SYNTHESISING; + _RUN_DONE = true; } _frame_cnt++; @@ -207,7 +220,8 @@ void ColorSingleAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + _RUN_DONE = true; + //_state = STATE_DISPLAY_RESULTS; _anim_cnt=0; } ofPopMatrix(); diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index c76b84f..6932280 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -13,19 +13,25 @@ using Poco::Thread; void DiffNoiseAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 100; // right number is about 600 - NUM_PHASE = 1; + NUM_RUN = 1; - NUM_SAVE_PER_RUN = 50; + + int acq_run_time = 20; // 20 seconds of acquiring per run + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames create_dir(); - //_fade_cnt=0; + _frame_cnt = 0; - _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; - int anim_time = 10; // 10 seconds + int anim_time = 5; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + + create_dir(); } @@ -58,8 +64,11 @@ void DiffNoiseAnalysis::acquire() } void DiffNoiseAnalysis::synthesise() -{ +{ // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); + } @@ -133,7 +142,7 @@ void DiffNoiseAnalysis::draw() ofDisableAlphaBlending(); } else { - _state = STATE_SYNTHESISING; + // _state = STATE_SYNTHESISING; _RUN_DONE = true; } @@ -215,7 +224,9 @@ void DiffNoiseAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + + _RUN_DONE = true; + //_state = STATE_DISPLAY_RESULTS; _anim_cnt=0; } ofPopMatrix(); @@ -232,7 +243,6 @@ void DiffNoiseAnalysis::draw() break; } - default: break; } @@ -242,15 +252,14 @@ void DiffNoiseAnalysis::draw() // this runs at save_cb timer rate = DELTA_T_SAVE void DiffNoiseAnalysis::save_cb(Timer& timer) { - _save_cnt++; cout << "DiffNoiseAnalysis::saving...\n"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - + ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - + _saved_filenames.push_back(_whole_file_path+"/"+file_name); _save_cnt++; diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 0625953..b56f847 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -12,14 +12,19 @@ using Poco::Thread; void IResponseAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 50; //150 is about right - NUM_PHASE = 1; + NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + + int acq_run_time = 20; // 20 seconds of acquiring per run + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames create_dir(); + _frame_cnt = 0; - _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; int anim_time = 5; // 10 seconds @@ -51,12 +56,17 @@ void IResponseAnalysis::acquire() Thread::sleep(3); save_timer->stop(); + + _RUN_DONE = false; + } } void IResponseAnalysis::synthesise() { // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); } @@ -79,9 +89,8 @@ void IResponseAnalysis::draw() ofRect(0, 0, ofGetWidth(), ofGetHeight()); c = 255.0 * (_frame_cnt_max*_frame_cnt_max - _frame_cnt*_frame_cnt)/(_frame_cnt_max*_frame_cnt_max); } else { - _state = STATE_SYNTHESISING; - //_RUN_DONE = true; + _RUN_DONE = true; } _frame_cnt++; @@ -161,7 +170,8 @@ void IResponseAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + + _RUN_DONE = true; _anim_cnt=0; } ofPopMatrix(); @@ -170,6 +180,7 @@ void IResponseAnalysis::draw() break; } + case STATE_DISPLAY_RESULTS: { @@ -177,8 +188,7 @@ void IResponseAnalysis::draw() _RUN_DONE = true; break; } - - + default: break; } diff --git a/src/IResponseAnalysis.h b/src/IResponseAnalysis.h index 08137a4..78dc16a 100755 --- a/src/IResponseAnalysis.h +++ b/src/IResponseAnalysis.h @@ -27,7 +27,7 @@ public: protected: bool _RUN_DONE; - int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 6942e2e..d8d0254 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -13,17 +13,20 @@ using Poco::Thread; void RelaxRateAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 50; //300 is the correct number - NUM_PHASE = 1; NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + + int acq_run_time = 20; // 20 seconds of acquiring per run + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames create_dir(); _level = 0; _flip = 1; _frame_cnt = 0; - _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; int anim_time = 5; // 10 seconds @@ -55,12 +58,17 @@ void RelaxRateAnalysis::acquire() Thread::sleep(3); save_timer->stop(); + + _RUN_DONE = false; } } void RelaxRateAnalysis::synthesise() { // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); + } // this runs at frame rate = 33 ms for 30 FPS @@ -92,9 +100,7 @@ void RelaxRateAnalysis::draw() } else { - _state = STATE_SYNTHESISING; - - //_RUN_DONE = true; + _RUN_DONE = true; } _frame_cnt++; @@ -182,7 +188,7 @@ void RelaxRateAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + _RUN_DONE = true; _anim_cnt=0; } ofPopMatrix(); diff --git a/src/RelaxRateAnalysis.h b/src/RelaxRateAnalysis.h index b804491..e36eeea 100755 --- a/src/RelaxRateAnalysis.h +++ b/src/RelaxRateAnalysis.h @@ -1,7 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ #pragma once @@ -29,6 +25,6 @@ protected: bool _RUN_DONE; float _flip, _level; - int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index f572604..953bfad 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -14,16 +14,26 @@ using Poco::Thread; void ShadowScapesAnalysis::setup(int camWidth, int camHeight) { - - DELTA_T_SAVE = 50; - NUM_PHASE = 1; NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + int acq_run_time = 15; // 10 seconds of acquiring per run + + int screenSpan; + if (_dir == V) screenSpan = ofGetHeight(); + if (_dir == H) screenSpan = ofGetWidth(); + if (_dir == D) screenSpan = ofGetHeight(); + + _step = (screenSpan/acq_run_time)/(ofGetFrameRate()); + // pixel per frame = (pixels / sec) / (frame / sec) + + + // 40 pixels per second should give us a 20 second scan at 800 pixels wide + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + create_dir(); - - _speed = 100.0; // 900.0 is the correct number _scanLineWidth = 100.0; _run_cnt = 0; _save_cnt = 0; @@ -34,14 +44,8 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight) void ShadowScapesAnalysis::acquire() { - int screenSpan; - if (_dir == V) screenSpan = ofGetHeight(); - if (_dir == H) screenSpan = ofGetWidth(); - if (_dir == D) screenSpan = ofGetHeight(); - - _step = ((screenSpan/_speed) * 1000.0) / 500.0; - _line = 0; + _line = 0; // RUN ROUTINE for(int i = 0; i < NUM_RUN; i++) { @@ -58,6 +62,8 @@ void ShadowScapesAnalysis::acquire() Thread::sleep(3); save_timer.stop(); + + _RUN_DONE = false; } } @@ -65,6 +71,8 @@ void ShadowScapesAnalysis::acquire() void ShadowScapesAnalysis::synthesise() { // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); } @@ -140,20 +148,23 @@ 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; + //_state = STATE_SYNTHESISING; + _RUN_DONE = true; } if(_dir == H && int(_line) >= (ofGetWidth()+4*_scanLineWidth)) { //cout << "HORIZONTAL IS DONE - _line >= (ofGetWidth()+4*_scanLineWidth)) is TRUE" << endl; - _state = STATE_SYNTHESISING; + //_state = STATE_SYNTHESISING; + _RUN_DONE = true; } 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; + //_state = STATE_SYNTHESISING; + _RUN_DONE = true; } break; @@ -229,7 +240,9 @@ void ShadowScapesAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + + _RUN_DONE = true; + //_state = STATE_DISPLAY_RESULTS; _anim_cnt=0; } ofPopMatrix(); diff --git a/src/ShadowScapesAnalysis.h b/src/ShadowScapesAnalysis.h index b919720..7a058c6 100755 --- a/src/ShadowScapesAnalysis.h +++ b/src/ShadowScapesAnalysis.h @@ -1,34 +1,4 @@ -/* - - copyright (c) 2011 Copenhagen Institute of Interaction Design (CIID) - - all rights reserved. - - + redistribution and use in source and binary forms, with or without - + modification, are permitted provided that the following conditions - + are met: - + > redistributions of source code must retain the above copyright - + notice, this list of conditions and the following disclaimer. - + > redistributions in binary form must reproduce the above copyright - + notice, this list of conditions and the following disclaimer in - + the documentation and/or other materials provided with the - + distribution. - - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - + SUCH DAMAGE. - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ +/* */ #pragma once @@ -64,7 +34,7 @@ protected: float _scanLineWidth; // pix per second float _step; shadow_type _dir; - int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; \ No newline at end of file diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index 04d1f23..8dc57b6 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -13,23 +13,25 @@ using Poco::Thread; void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 50; //300 is about the right number - NUM_PHASE = 1; + + NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + + int acq_run_time = 20; // 20 seconds of acquiring per run + + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames create_dir(); - _level = 0; - _flip = 1; _frame_cnt = 0; - - _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; - int anim_time = 10; // 10 seconds + int anim_time = 5; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames - + } @@ -75,12 +77,17 @@ void ShapeFromShadingAnalysis::acquire() Thread::sleep(3); save_timer->stop(); + + _RUN_DONE = false; + } } void ShapeFromShadingAnalysis::synthesise() { // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); } // this runs at frame rate = 33 ms for 30 FPS @@ -308,8 +315,8 @@ void ShapeFromShadingAnalysis::draw() ofDisableAlphaBlending(); } else { - _state = STATE_SYNTHESISING; - //_RUN_DONE = true; + //_state = STATE_SYNTHESISING; + _RUN_DONE = true; } _frame_cnt++; @@ -390,7 +397,8 @@ void ShapeFromShadingAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + _RUN_DONE = true; + //_state = STATE_DISPLAY_RESULTS; _anim_cnt=0; } ofPopMatrix(); diff --git a/src/ShapeFromShadingAnalysis.h b/src/ShapeFromShadingAnalysis.h index 3fbf877..f63b649 100755 --- a/src/ShapeFromShadingAnalysis.h +++ b/src/ShapeFromShadingAnalysis.h @@ -48,6 +48,6 @@ protected: int _animation_cnt16; int _animation_reset; // this reset part didn't get working - so using 16 different counters! yay! - int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index ebb76e7..db05c0a 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -12,20 +12,22 @@ using Poco::Thread; void StrobeAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 100; NUM_RUN = 1; - _strobe_cnt = 0; - _strobe_cnt_max = 20; // 40 x 500 ms = 20000 ms = 20 seconds run time - _strobe_interval = 1500; //every 0.5seconds = 15 frames - _frame_cnt_max = _strobe_cnt_max * _strobe_interval * ofGetFrameRate()/1000; + int acq_run_time = 20; // 20 seconds of acquiring per run + DELTA_T_SAVE = 10*acq_run_time/2; // for 20 seconds, we want this to be around 200 files + // or 10 times per second = every 100 ms + + _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames + + _strobe_interval = 1500; //every 1 seconds, or every thirty frames 30 frames + // 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. create_dir(); - - int anim_time = 10; // 10 seconds + int anim_time = 5; // 5 seconds for the animation _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames } @@ -51,18 +53,22 @@ void StrobeAnalysis::acquire() save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _strobe_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); save_timer->stop(); + + _RUN_DONE = false; } } void StrobeAnalysis::synthesise() { // _saved_filenames has all the file names of all the saved images + while(!_RUN_DONE) + Thread::sleep(3); } // this runs at frame rate = 33 ms for 30 FPS @@ -120,8 +126,8 @@ void StrobeAnalysis::draw() ofDisableAlphaBlending(); } else { - _state = STATE_SYNTHESISING; - //_RUN_DONE = true; + //_state = STATE_SYNTHESISING; + _RUN_DONE = true; } _frame_cnt++; @@ -201,7 +207,8 @@ void StrobeAnalysis::draw() _anim_cnt++; } else { - _state = STATE_DISPLAY_RESULTS; + _RUN_DONE = true; + //_state = STATE_DISPLAY_RESULTS; _anim_cnt=0; } ofPopMatrix(); diff --git a/src/StrobeAnalysis.h b/src/StrobeAnalysis.h index 88830e8..9661fb4 100755 --- a/src/StrobeAnalysis.h +++ b/src/StrobeAnalysis.h @@ -33,6 +33,6 @@ protected: int _strobe_interval; bool _strobe_on; - int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; };