From 7109c65d63dcd836ee1990b946c0707cae6364fd Mon Sep 17 00:00:00 2001 From: dviid Date: Wed, 15 Feb 2012 08:43:43 +0100 Subject: [PATCH] new arch > sequence: acquire -> synthesise -> display results --- example/RefractiveIndex.cpp | 2 - src/AbstractAnalysis.cpp | 7 ++- src/AbstractAnalysis.h | 33 +++++++---- src/CamFrameRateAnalysis.cpp | 78 +++++++++++++++++-------- src/CamFrameRateAnalysis.h | 3 +- src/CamNoiseAnalysis.cpp | 78 +++++++++++++++++-------- src/CamNoiseAnalysis.h | 3 +- src/ColorMultiAnalysis.cpp | 55 ++++++++++++++---- src/ColorMultiAnalysis.h | 3 +- src/ColorSingleAnalysis.cpp | 85 ++++++++++++++++++--------- src/ColorSingleAnalysis.h | 3 +- src/DiffNoiseAnalysis.cpp | 62 +++++++++++++++----- src/DiffNoiseAnalysis.h | 3 +- src/IResponseAnalysis.cpp | 58 +++++++++++++++---- src/IResponseAnalysis.h | 3 +- src/LatencyTestAnalysis.cpp | 95 ++++++++++++++++++++---------- src/LatencyTestAnalysis.h | 3 +- src/ShadowScapesAnalysis.cpp | 70 ++++++++++++++++------- src/ShadowScapesAnalysis.h | 3 +- src/StrobeAnalysis.cpp | 108 ----------------------------------- src/StrobeAnalysis.h | 57 ------------------ 21 files changed, 462 insertions(+), 350 deletions(-) delete mode 100755 src/StrobeAnalysis.cpp delete mode 100755 src/StrobeAnalysis.h diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index 822a942..4957be5 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -11,7 +11,6 @@ #include "RefractiveIndex.h" #include "IResponseAnalysis.h" -#include "StrobeAnalysis.h" #include "ShadowScapesAnalysis.h" #include "ColorMultiAnalysis.h" #include "ColorSingleAnalysis.h" @@ -98,7 +97,6 @@ void RefractiveIndex::setup() // setup analysis _analysisVector.push_back(new ShadowScapesAnalysis()); - _analysisVector.push_back(new StrobeAnalysis()); _analysisVector.push_back(new IResponseAnalysis()); _analysisVector.push_back(new ColorMultiAnalysis()); _analysisVector.push_back(new CamFrameRateAnalysis()); diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 751109a..41132a8 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -33,8 +33,13 @@ #include "AbstractAnalysis.h" #include "RefractiveIndex.h" +// this is the main threaded loop for a given analysis void AbstractAnalysis::do_synthesize() { - synthesize(); + _state = STATE_ACQUIRING; + acquire(); + _state = STATE_SYNTHESISING; + synthesise(); + _state = STATE_DISPLAY_RESULTS; ofNotifyEvent(_synthesize_cb, _name); } diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index 45317cc..d53940d 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -11,7 +11,10 @@ #define ANALYSIS_PATH "analysis/" -#define STATE_STOP 0xDEADBEEF +#define STATE_ACQUIRING 0x1111 +#define STATE_SYNTHESISING 0x2222 +#define STATE_DISPLAY_RESULTS 0x3333 +#define STATE_STOP 0xDEADBEEF class AbstractAnalysis { @@ -20,7 +23,8 @@ public: virtual ~AbstractAnalysis(){;} // generic function to set up the camera - virtual void setup(int camWidth, int camHeight){_cam_w = camWidth; _cam_h = camHeight;} + virtual void setup(int camWidth, int camHeight){_cam_w = camWidth; _cam_h = camHeight;} + // this is the main threaded loop for a given analysis void do_synthesize(); // ofx @@ -30,9 +34,12 @@ protected: virtual void create_dir(); - // the runnable function in the thread - virtual void synthesize() = 0; - // this means that this function needs to be overwritten by children that inherit this class + // acquire images - all the children (see - do_synthesize) + virtual void acquire() = 0; + + // analysis + synthesize images - all the children (see - do_synthesize) + virtual void synthesise() = 0; + public: string _name; @@ -41,14 +48,16 @@ public: ofEvent _synthesize_cb; protected: - int _cam_w, _cam_h; - int _state; - string _whole_file_path; + int _cam_w, _cam_h; + string _whole_file_path; + vector _saved_filenames; - float DELTA_T_SAVE; - int NUM_PHASE; - int NUM_RUN; - int NUM_SAVE_PER_RUN; + int _state; + + float DELTA_T_SAVE; + int NUM_PHASE; + int NUM_RUN; + int NUM_SAVE_PER_RUN; friend class AnalysisAdaptor; }; \ No newline at end of file diff --git a/src/CamFrameRateAnalysis.cpp b/src/CamFrameRateAnalysis.cpp index 3db72f3..ebc22ab 100755 --- a/src/CamFrameRateAnalysis.cpp +++ b/src/CamFrameRateAnalysis.cpp @@ -31,7 +31,7 @@ void CamFrameRateAnalysis::setup(int camWidth, int camHeight) } -void CamFrameRateAnalysis::synthesize() +void CamFrameRateAnalysis::acquire() { Timer* save_timer; @@ -57,30 +57,59 @@ void CamFrameRateAnalysis::synthesize() } } +void CamFrameRateAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + // this runs at frame rate = 33 ms for 30 FPS void CamFrameRateAnalysis::draw() { - /// *** TODO *** /// - // still need to deal with latency frames here - i.e.: there are frames - /// *** TODO *** /// - float totalTime=_frame_cnt_max/2; - - float numSteps=10; - - vectorstepLengths; - - - //c must increase until frame_cnt_max * 0.5 and then decrease afterwards - - - if (_frame_cnt < _frame_cnt_max) - { - ofSetColor(c, c, c); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max); - cout<<_frame_cnt<stepLengths; + + + //c must increase until frame_cnt_max * 0.5 and then decrease afterwards + + + if (_frame_cnt < _frame_cnt_max) + { + ofSetColor(c, c, c); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max); + cout<<_frame_cnt<= NUM_SAVE_PER_RUN) _RUN_DONE = true; diff --git a/src/CamFrameRateAnalysis.h b/src/CamFrameRateAnalysis.h index d3d72d6..d137f00 100755 --- a/src/CamFrameRateAnalysis.h +++ b/src/CamFrameRateAnalysis.h @@ -19,7 +19,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void save_cb(Poco::Timer& timer); diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index 8b8a31c..67fa8fd 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -31,7 +31,7 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight) } -void CamNoiseAnalysis::synthesize() +void CamNoiseAnalysis::acquire() { Timer* save_timer; @@ -57,34 +57,61 @@ void CamNoiseAnalysis::synthesize() } } +void CamNoiseAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + + // this runs at frame rate = 33 ms for 30 FPS void CamNoiseAnalysis::draw() { - /// *** TODO *** /// - // still need to deal with latency frames here - i.e.: there are frames - /// *** TODO *** /// - - float _number_of_grey_levels=5; - - float _frames_per_level = _frame_cnt_max / _number_of_grey_levels; - ofColor someColor; - - for(int i=0;i<=_number_of_grey_levels;i++){ - if (_frame_cnt>= _frames_per_level *( i-1) && +_frame_cnt < _frames_per_level * (i) ) { - //set colour to current grey level - c=255-( 255.0 * ( i /_number_of_grey_levels)); - someColor.set(c); - + + switch (_state) { + case STATE_ACQUIRING: + { + /// *** TODO *** /// + // still need to deal with latency frames here - i.e.: there are frames + /// *** TODO *** /// + + float _number_of_grey_levels=5; + + float _frames_per_level = _frame_cnt_max / _number_of_grey_levels; + ofColor someColor; + + for(int i=0;i<=_number_of_grey_levels;i++){ + if (_frame_cnt>= _frames_per_level *( i-1) && +_frame_cnt < _frames_per_level * (i) ) { + //set colour to current grey level + c=255-( 255.0 * ( i /_number_of_grey_levels)); + someColor.set(c); + + } + ofSetColor(someColor); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + } + _frame_cnt++; + + break; } - ofSetColor(someColor); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); + + case STATE_SYNTHESISING: + { + // display animation of something while the synthesis in on-going... + break; + } + + case STATE_DISPLAY_RESULTS: + { + // display results of the synthesis + break; + } + + + default: + break; } - - - - _frame_cnt++; - + } @@ -95,9 +122,12 @@ void CamNoiseAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; string thisLocation = RefractiveIndex::_location; - + + string file = _whole_file_path+"/"+file_name; ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + _saved_filenames.push_back(file); if(_save_cnt >= NUM_SAVE_PER_RUN) _RUN_DONE = true; diff --git a/src/CamNoiseAnalysis.h b/src/CamNoiseAnalysis.h index 85d6924..ed50f1e 100755 --- a/src/CamNoiseAnalysis.h +++ b/src/CamNoiseAnalysis.h @@ -18,7 +18,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void save_cb(Poco::Timer& timer); diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 8b14ade..32e3caa 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -56,7 +56,7 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight) c = 0; } -void ColorMultiAnalysis::synthesize() +void ColorMultiAnalysis::acquire() { Timer* save_timer; @@ -83,18 +83,48 @@ void ColorMultiAnalysis::synthesize() } +void ColorMultiAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + + void ColorMultiAnalysis::draw() { - - if (_frame_cnt < _frame_cnt_max) { - ofColor aColor; - aColor.setHsb(c, 255, 255); - ofSetColor(aColor); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - //how far are we as a percent of _frame_count_max - c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max); + + switch (_state) { + case STATE_ACQUIRING: + { + if (_frame_cnt < _frame_cnt_max) { + ofColor aColor; + aColor.setHsb(c, 255, 255); + ofSetColor(aColor); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + //how far are we as a percent of _frame_count_max + c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max); + } + _frame_cnt++; + + break; + } + + case STATE_SYNTHESISING: + { + // display animation of something while the synthesis in on-going... + break; + } + + case STATE_DISPLAY_RESULTS: + { + // display results of the synthesis + break; + } + + + default: + break; } - _frame_cnt++; + } @@ -109,9 +139,12 @@ void ColorMultiAnalysis::save_cb(Timer& timer) cout << "COLORMULTIANALYSIS::saving...\n"; cout << "c_last... " << c << endl; string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; + + string file = _whole_file_path+"/"+file_name; - cout<<_whole_file_path<= NUM_SAVE_PER_RUN){ _RUN_DONE = true; diff --git a/src/ColorMultiAnalysis.h b/src/ColorMultiAnalysis.h index f540e01..39f2591 100755 --- a/src/ColorMultiAnalysis.h +++ b/src/ColorMultiAnalysis.h @@ -13,7 +13,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void save_cb(Poco::Timer& timer); diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 9d8a7fb..4d7641e 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -32,7 +32,7 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) } -void ColorSingleAnalysis::synthesize() +void ColorSingleAnalysis::acquire() { Timer* save_timer; @@ -58,34 +58,63 @@ void ColorSingleAnalysis::synthesize() } } +void ColorSingleAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + + void ColorSingleAnalysis::draw() { - - float one_third_of_frame_count_max=_frame_cnt_max/3; - if (_frame_cnt < one_third_of_frame_count_max){ - r=255.0; - g=0.0; - b=0.0; - ofSetColor(r,g,b); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); + + switch (_state) { + case STATE_ACQUIRING: + { + float one_third_of_frame_count_max=_frame_cnt_max/3; + if (_frame_cnt < one_third_of_frame_count_max){ + r=255.0; + g=0.0; + b=0.0; + ofSetColor(r,g,b); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + } + if (_frame_cnt >= one_third_of_frame_count_max && _frame_cnt < 2*one_third_of_frame_count_max){ + r=0.0; + g=255.0; + b=0.0; + ofSetColor(r,g,b); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + } + if (_frame_cnt >= 2*one_third_of_frame_count_max && _frame_cnt < _frame_cnt_max){ + r=0.0; + g=0.0; + b=255.0; + ofSetColor(r,g,b); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + } + + _frame_cnt++; + + break; + } + + case STATE_SYNTHESISING: + { + // display animation of something while the synthesis in on-going... + break; + } + + case STATE_DISPLAY_RESULTS: + { + // display results of the synthesis + break; + } + + + default: + break; } - if (_frame_cnt >= one_third_of_frame_count_max && _frame_cnt < 2*one_third_of_frame_count_max){ - r=0.0; - g=255.0; - b=0.0; - ofSetColor(r,g,b); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - } - if (_frame_cnt >= 2*one_third_of_frame_count_max && _frame_cnt < _frame_cnt_max){ - r=0.0; - g=0.0; - b=255.0; - ofSetColor(r,g,b); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - } - - _frame_cnt++; - + } @@ -98,8 +127,12 @@ void ColorSingleAnalysis::save_cb(Timer& timer) cout << "ColorSingleAnalysis::saving...\n"; string file_name =ofToString(_frame_cnt,2)+"_"+ofToString((int)r,2)+"_"+ofToString((int)g,2)+"_"+ofToString((int)b,2)+"_"+ofToString(_run_cnt,2)+".jpg"; + string file = _whole_file_path+"/"+file_name; ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + _saved_filenames.push_back(file); + cout<<_whole_file_path+"/"+file_name<= NUM_SAVE_PER_RUN) diff --git a/src/ColorSingleAnalysis.h b/src/ColorSingleAnalysis.h index 968c46a..f2c3614 100755 --- a/src/ColorSingleAnalysis.h +++ b/src/ColorSingleAnalysis.h @@ -18,7 +18,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void save_cb(Poco::Timer& timer); diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index 8c063d0..f157030 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -30,7 +30,7 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight) } -void DiffNoiseAnalysis::synthesize() +void DiffNoiseAnalysis::acquire() { Timer* save_timer; @@ -56,24 +56,52 @@ void DiffNoiseAnalysis::synthesize() } } +void DiffNoiseAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + + // this runs at frame rate = 33 ms for 30 FPS void DiffNoiseAnalysis::draw() { - /// *** TODO *** /// - // still need to deal with latency frames here - i.e.: there are frames - /// *** TODO *** /// - ofColor aColour; - - c = ofRandom(0,255); - aColour.setHsb(c, 255, 255); - if (_frame_cnt < _frame_cnt_max) - { - ofSetColor(aColour); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - + switch (_state) { + case STATE_ACQUIRING: + { + /// *** TODO *** /// + // still need to deal with latency frames here - i.e.: there are frames + /// *** TODO *** /// + ofColor aColour; + + c = ofRandom(0,255); + aColour.setHsb(c, 255, 255); + if (_frame_cnt < _frame_cnt_max) + { + ofSetColor(aColour); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + + } + _frame_cnt++; + + break; + } + + case STATE_SYNTHESISING: + { + // display animation of something while the synthesis in on-going... + break; + } + + case STATE_DISPLAY_RESULTS: + { + // display results of the synthesis + break; + } + + + default: + break; } - _frame_cnt++; - } @@ -96,8 +124,12 @@ void DiffNoiseAnalysis::save_cb(Timer& timer) //RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera // fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg"; //ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST); + + string file = _whole_file_path+"/"+file_name; ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + _saved_filenames.push_back(file); } _save_cnt++; diff --git a/src/DiffNoiseAnalysis.h b/src/DiffNoiseAnalysis.h index da07b69..90164ab 100755 --- a/src/DiffNoiseAnalysis.h +++ b/src/DiffNoiseAnalysis.h @@ -18,7 +18,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void save_cb(Poco::Timer& timer); diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 33f295f..bf18312 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -29,7 +29,7 @@ void IResponseAnalysis::setup(int camWidth, int camHeight) } -void IResponseAnalysis::synthesize() +void IResponseAnalysis::acquire() { Timer* save_timer; @@ -55,22 +55,52 @@ void IResponseAnalysis::synthesize() } } +void IResponseAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + + // this runs at frame rate = 33 ms for 30 FPS void IResponseAnalysis::draw() { - /// *** TODO *** /// - // still need to deal with latency frames here - i.e.: there are frames - /// *** TODO *** /// - - if (_frame_cnt < _frame_cnt_max) - { - ofSetColor(c, c, c); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max); + + switch (_state) { + case STATE_ACQUIRING: + { + /// *** TODO *** /// + // still need to deal with latency frames here - i.e.: there are frames + /// *** TODO *** /// + + if (_frame_cnt < _frame_cnt_max) + { + ofSetColor(c, c, c); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max); + } + + _frame_cnt++; + + break; + } + + case STATE_SYNTHESISING: + { + // display animation of something while the synthesis in on-going... + break; + } + + case STATE_DISPLAY_RESULTS: + { + // display results of the synthesis + break; + } + + + default: + break; } - _frame_cnt++; - } @@ -90,8 +120,12 @@ void IResponseAnalysis::save_cb(Timer& timer) //RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera // fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg"; //ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST); + + string file = _whole_file_path+"/"+file_name; ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + _saved_filenames.push_back(file); if(_save_cnt >= NUM_SAVE_PER_RUN) _RUN_DONE = true; diff --git a/src/IResponseAnalysis.h b/src/IResponseAnalysis.h index 44addbc..3a61a5f 100755 --- a/src/IResponseAnalysis.h +++ b/src/IResponseAnalysis.h @@ -18,7 +18,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void save_cb(Poco::Timer& timer); diff --git a/src/LatencyTestAnalysis.cpp b/src/LatencyTestAnalysis.cpp index 9556816..a397f58 100755 --- a/src/LatencyTestAnalysis.cpp +++ b/src/LatencyTestAnalysis.cpp @@ -30,7 +30,7 @@ void LatencyTestAnalysis::setup(int camWidth, int camHeight) } -void LatencyTestAnalysis::synthesize() +void LatencyTestAnalysis::acquire() { Timer* save_timer; @@ -56,39 +56,68 @@ void LatencyTestAnalysis::synthesize() } } +void LatencyTestAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + + // this runs at frame rate = 33 ms for 30 FPS void LatencyTestAnalysis::draw() { - /// *** TODO *** /// - // still need to deal with latency frames here - i.e.: there are frames - /// *** TODO *** /// - - if (_frame_cnt < _frame_cnt_max/3) - { - c = 0; - - ofSetColor(c, c, c); - cout<<"1st third"<= _frame_cnt_max/3 && _frame_cnt < 2*( _frame_cnt_max/3)) - { - c = 255; - cout<<"2nd third"<= 2*( _frame_cnt_max/3) && _frame_cnt < _frame_cnt_max) - { - c = 0; - cout<<"3rd third"<= _frame_cnt_max/3 && _frame_cnt < 2*( _frame_cnt_max/3)) + { + c = 255; + cout<<"2nd third"<= 2*( _frame_cnt_max/3) && _frame_cnt < _frame_cnt_max) + { + c = 0; + cout<<"3rd third"<= NUM_SAVE_PER_RUN) _RUN_DONE = true; diff --git a/src/LatencyTestAnalysis.h b/src/LatencyTestAnalysis.h index 6ffeaf3..b52b223 100755 --- a/src/LatencyTestAnalysis.h +++ b/src/LatencyTestAnalysis.h @@ -18,7 +18,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void save_cb(Poco::Timer& timer); diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index 56055d4..bde7fb6 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -50,7 +50,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight) _speed = 300; } -void ShadowScapesAnalysis::synthesize() +void ShadowScapesAnalysis::acquire() { int w; if(_dir == H) w = ofGetWidth(); @@ -79,29 +79,59 @@ void ShadowScapesAnalysis::synthesize() } +void ShadowScapesAnalysis::synthesise() +{ + // _saved_filenames has all the file names of all the saved images +} + + // the animation draw - and the output draw void ShadowScapesAnalysis::draw() { - - static int _pos; - - if(_state == STATE_ANALYSIS) { - ofSetColor(0, 200, 0); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - return; - } - - if(_state == STATE_SCAN) { - if(_pos != _line) { - //take snap?? - _pos = _line; + + switch (_state) { + case STATE_ACQUIRING: + { + static int _pos; + + if(_state == STATE_ANALYSIS) { + ofSetColor(0, 200, 0); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + return; + } + + if(_state == STATE_SCAN) { + if(_pos != _line) { + //take snap?? + _pos = _line; + } + ofSetColor(255, 255, 255); + + if(_dir == H) ofRect(_pos, 0, 50, ofGetHeight()); + else if(_dir == V) ofRect(0, _pos, ofGetWidth(), 50); + + } + + + break; } - ofSetColor(255, 255, 255); - - if(_dir == H) ofRect(_pos, 0, 50, ofGetHeight()); - else if(_dir == V) ofRect(0, _pos, ofGetWidth(), 50); - - } + + case STATE_SYNTHESISING: + { + // display animation of something while the synthesis in on-going... + break; + } + + case STATE_DISPLAY_RESULTS: + { + // display results of the synthesis + break; + } + + + default: + break; + } } diff --git a/src/ShadowScapesAnalysis.h b/src/ShadowScapesAnalysis.h index 59004a2..9519898 100755 --- a/src/ShadowScapesAnalysis.h +++ b/src/ShadowScapesAnalysis.h @@ -50,7 +50,8 @@ public: public: void setup(int camWidth, int camHeight); - void synthesize(); + void acquire(); + void synthesise(); void draw(); void scan_cb(Poco::Timer& timer); diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp deleted file mode 100755 index c48971b..0000000 --- a/src/StrobeAnalysis.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - - 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 - */ - -#include "StrobeAnalysis.h" -#include "ofMain.h" - -#include "Poco/Timer.h" -#include "Poco/Thread.h" -#include "RefractiveIndex.h" -using Poco::Timer; -using Poco::TimerCallback; -using Poco::Thread; - -#define STATE_STROBE 0 -#define STATE_ANALYSIS 1 - -void StrobeAnalysis::setup(int camWidth, int camHeight) -{ - create_dir(); -} - -void StrobeAnalysis::synthesize() -{ - Timer strobe_timer(0, 70); - - TimerCallback strobe_callback(*this, &StrobeAnalysis::strobe_cb); - - _state = STATE_STROBE; - _darkness = true; - _strobe_cnt = 0; - - strobe_timer.start(strobe_callback); - - while(_state != STATE_ANALYSIS) - Thread::sleep(5); - - strobe_timer.stop(); - - // do analysis here - - -/* - while(_state != STATE_STOP) - Thread::sleep(100); - */ -} - -void StrobeAnalysis::draw() -{ - if(_state == STATE_ANALYSIS) { - ofSetColor(0, 200, 0); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - return; - } - - if(_darkness) { - ofSetColor(0, 0, 0); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - } else { - ofSetColor(255, 255, 255); - ofRect(0, 0, ofGetWidth(), ofGetHeight()); - } - -} - - -void StrobeAnalysis::strobe_cb(Timer& timer) -{ - cout << "IResponseAnalysis::saving...\n"; - _strobe_cnt++; - - _darkness = !_darkness; - - if(_strobe_cnt >= 20) { - _state = STATE_ANALYSIS; - } - - -} diff --git a/src/StrobeAnalysis.h b/src/StrobeAnalysis.h deleted file mode 100755 index a4e456e..0000000 --- a/src/StrobeAnalysis.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - - 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 - -#include "AbstractAnalysis.h" - -#include "Poco/Timer.h" - -class StrobeAnalysis : public AbstractAnalysis -{ -public: - StrobeAnalysis(): AbstractAnalysis("STROBE"){;} - virtual ~StrobeAnalysis(){;} - -public: - - void setup(int camWidth, int camHeight); - void synthesize(); - void draw(); - - void strobe_cb(Poco::Timer& timer); - -protected: - - int _strobe_cnt; - bool _darkness; -};