From f2593aed499adf885e262625fc6987ef082525eb Mon Sep 17 00:00:00 2001 From: Jamie Allen Date: Sun, 19 Feb 2012 23:34:48 +0100 Subject: [PATCH] tried to add a keypress function - got almost there... need to figure out how to turn off the Analyses from RefractiveIndex.cpp... without blocking --- example/RefractiveIndex.cpp | 80 ++++++++++++++++++++++++++++++++ src/CamNoiseAnalysis.cpp | 4 +- src/ColorSingleAnalysis.cpp | 2 +- src/RelaxRateAnalysis.cpp | 6 +-- src/ShadowScapesAnalysis.cpp | 14 +++--- src/ShapeFromShadingAnalysis.cpp | 2 +- src/StrobeAnalysis.cpp | 2 +- 7 files changed, 96 insertions(+), 14 deletions(-) diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index d831ee9..ea0ea5a 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -71,6 +71,7 @@ void RefractiveIndex::setup() // display cout << "> display" << endl; ofSetFrameRate(fps); + if(fps > 30) { ofSetVerticalSync(FALSE); } else { @@ -228,6 +229,85 @@ void RefractiveIndex::keyPressed (int key) { if( key =='f') ofToggleFullscreen(); + + /* TODO: complete the below... would be good to trigger the Analysis from keypresses if needed... */ + // currently this doesn't work... the save_cb's in the individual + // tried to add a stop_analysis(); call but it blocks the whole programme + + // i.e.: ask david how to shut off the prior Analysis if it's not finished running from here? + + /* + if(key == '1') + { + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(0); + _state = ISTATE_START; + } + + if(key == '2') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(1); + _state = ISTATE_START; + } + + if(key == '3') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(2); + _state = ISTATE_START; + } + + if(key == '4') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(3); + _state = ISTATE_START; + } + + if(key == '5') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(4); + _state = ISTATE_START; + } + + if(key == '6') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(5); + _state = ISTATE_START; + } + + if(key == '7') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(6); + _state = ISTATE_START; + } + + if(key == '8') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(7); + _state = ISTATE_START; + } + + if(key == '9') + { + + // something needs to go here to cancel the prior analysis + _currentAnalysis = _analysisVector.at(8); + _state = ISTATE_START; + } + */ } void RefractiveIndex::exit() diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index b710995..ee69b48 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -18,7 +18,7 @@ using Poco::Thread; void CamNoiseAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 200; + DELTA_T_SAVE = 200; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -153,7 +153,7 @@ void CamNoiseAnalysis::save_cb(Timer& timer) _save_cnt++; - cout << "ColorSingleAnalysis::saving...\n"; + cout << "CamNoiseAnalysis::saving...\n"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index ae711db..51f795d 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; + DELTA_T_SAVE = 300; //300 is the right number here NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 0db9a01..4f82029 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -18,9 +18,9 @@ using Poco::Thread; void RelaxRateAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 300; + DELTA_T_SAVE = 100; //300 is the correct number NUM_PHASE = 1; - NUM_RUN = 3; + NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; create_dir(); @@ -98,7 +98,7 @@ void RelaxRateAnalysis::draw() } _frame_cnt++; - cout << "_frame_cnt:" << _frame_cnt << endl; + //cout << "_frame_cnt:" << _frame_cnt << endl; break; } diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index b2a4b21..2956e6e 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -46,13 +46,15 @@ using Poco::Thread; void ShadowScapesAnalysis::setup(int camWidth, int camHeight) { + + DELTA_T_SAVE = 100; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; create_dir(); - _speed = 900.0; // 900.0 is the correct number + _speed = 100.0; // 900.0 is the correct number _scanLineWidth = 100.0; _run_cnt = 0; _save_cnt = 0; @@ -60,12 +62,12 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight) void ShadowScapesAnalysis::acquire() { - int w; - if (_dir == V) w = ofGetHeight(); - if (_dir == H) w = ofGetWidth(); - if (_dir == D) w = ofGetHeight(); + int screenSpan; + if (_dir == V) screenSpan = ofGetHeight(); + if (_dir == H) screenSpan = ofGetWidth(); + if (_dir == D) screenSpan = ofGetHeight(); - _step = ((w/_speed) * 1000.0) / 500.0; + _step = ((screenSpan/_speed) * 1000.0) / 500.0; _line = 0; // RUN ROUTINE diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index 3bc8200..a23c199 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -18,7 +18,7 @@ using Poco::Thread; void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 300; + DELTA_T_SAVE = 300; //300 is about the right number NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index ebbd4dd..9ee14e0 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -48,7 +48,7 @@ void StrobeAnalysis::acquire() _save_cnt = 0; _frame_cnt = 0; - cout << "RUN NUM = " << i; + //cout << "RUN NUM = " << i; save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback);