diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index decf166..92f03f9 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -24,6 +24,7 @@ #include "DiffNoiseAnalysis.h" #include "ofxXmlSettings.h" +#include "ofxOpenCv.h" #define CAMERA_ID 1 #define CAMERA_ACQU_WIDTH 640 @@ -53,15 +54,17 @@ void RefractiveIndex::setup() bool save_config = false; cout << "Loading configuration..." << endl; - if(!XML.loadFile("../data/config.refindx")) { + if(XML.loadFile("config.refindx") == false) { ofLog(OF_LOG_ERROR) << "error loading config - using default."; save_config = true; + } else { + XML.loadFile("config.refindx"); } // _vid_id = XML.getValue("config:camera:id", CAMERA_ID); - _vid_w = XML.getValue("config:camera:width", CAMERA_ACQU_WIDTH); - _vid_h = XML.getValue("config:camera:height", CAMERA_ACQU_HEIGHT); + _vid_w = XML.getValue("config:camera:width", CAMERA_ACQU_WIDTH); + _vid_h = XML.getValue("config:camera:height", CAMERA_ACQU_HEIGHT); // int fps = XML.getValue("config:display:fps", 30); @@ -102,25 +105,25 @@ void RefractiveIndex::setup() //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()); + // _analysisVector.push_back(new RelaxRateAnalysis()); - _analysisVector.push_back(new IResponseAnalysis()); + // _analysisVector.push_back(new IResponseAnalysis()); _analysisVector.push_back(new ShapeFromShadingAnalysis()); - _analysisVector.push_back(new StrobeAnalysis()); + // _analysisVector.push_back(new StrobeAnalysis()); - _analysisVector.push_back(new CamNoiseAnalysis()); + // _analysisVector.push_back(new CamNoiseAnalysis()); - _analysisVector.push_back(new ColorSingleAnalysis()); + // _analysisVector.push_back(new ColorSingleAnalysis()); - _analysisVector.push_back(new ColorMultiAnalysis()); + // _analysisVector.push_back(new ColorMultiAnalysis()); - _analysisVector.push_back(new DiffNoiseAnalysis()); + // _analysisVector.push_back(new DiffNoiseAnalysis()); _currentAnalysisIndx = 0; _currentAnalysis = _analysisVector.at(_currentAnalysisIndx); diff --git a/example/main.cpp b/example/main.cpp index 847eef7..2732dc3 100755 --- a/example/main.cpp +++ b/example/main.cpp @@ -11,8 +11,10 @@ int main() { ofAppGlutWindow window; ofxXmlSettings XML; + XML.loadFile("../data/config.refindx"); - bool fullscreen = (XML.getValue("config:display:fullscreen", "true") == "true" ? true : false); + + bool fullscreen = (XML.getValue("config:display:fullscreen", "false") == "true" ? true : false); int screen_w = XML.getValue("config:display:width", SCREEN_WIDTH); int screen_h = XML.getValue("config:display:height", SCREEN_HEIGHT); @@ -25,5 +27,4 @@ int main() { ofSetupOpenGL(&window, screen_w, screen_h, (fullscreen ? OF_FULLSCREEN : OF_WINDOW)); ofRunApp(new RefractiveIndex()); - } diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index bffc774..34de6e1 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -41,8 +41,7 @@ void AbstractAnalysis::do_synthesize() { _state = STATE_SYNTHESISING; synthesise(); _state = STATE_DISPLAY_RESULTS; - - //displayresults(); + displayresults(); ofNotifyEvent(_synthesize_cb, _name); } diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index d53940d..d6a29b1 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -39,6 +39,7 @@ protected: // analysis + synthesize images - all the children (see - do_synthesize) virtual void synthesise() = 0; + virtual void displayresults() = 0; public: diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 86964f2..9a16019 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -31,13 +31,11 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight) int anim_time = 5; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames - } void RelaxRateAnalysis::acquire() { - Timer* save_timer; TimerCallback save_callback(*this, &RelaxRateAnalysis::save_cb); diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index 6749a7f..9c8f28b 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -10,11 +10,8 @@ using Poco::Timer; using Poco::TimerCallback; using Poco::Thread; - void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) -{ - - +{ NUM_RUN = 1; int acq_run_time = 20; // 20 seconds of acquiring per run @@ -32,6 +29,13 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) int anim_time = 5; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + _show_image = false; + _image_shown = false; + + image2.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } @@ -85,11 +89,36 @@ void ShapeFromShadingAnalysis::acquire() void ShapeFromShadingAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images while(!_RUN_DONE) Thread::sleep(3); } +void ShapeFromShadingAnalysis::displayresults() +{ + + for(float i=1;i<_saved_filenames.size();i++){ + + cout << "_saved_filenames[i]" << _saved_filenames[i] << endl; + + while(!_image_shown){ + Thread::sleep(2); + //cout << "!_image_shown" << endl; + } + + if(!image1.loadImage(_saved_filenames[i])){ + //couldn't load image + cout << "didn't load image" << endl; + } + + if(image1.loadImage(_saved_filenames[i])){ + image1.loadImage(_saved_filenames[i]); + //cout << "_show_image = true;" << endl; + _show_image = true; + _image_shown = false; + } + } +} + // this runs at frame rate = 33 ms for 30 FPS void ShapeFromShadingAnalysis::draw() { @@ -102,23 +131,10 @@ void ShapeFromShadingAnalysis::draw() ofEnableAlphaBlending(); - int _quarter_frame_cnt_max = _frame_cnt_max/4; int _half_frame_cnt_max = _frame_cnt_max/2; int _threequarters_frame_cnt_max = 3*_frame_cnt_max/4; - //TODO: put in CROSS FADES, ETC§E - - /* - if (_animation_reset == true) - { - _animation_cnt1 = 0; - _animation_cnt2 = 0; - _animation_cnt3 = 0; - _animation_cnt4 = 0; - } - */ - if(_frame_cnt < _quarter_frame_cnt_max) { quad = "QUAD1"; @@ -208,7 +224,7 @@ void ShapeFromShadingAnalysis::draw() } - + } @@ -258,11 +274,7 @@ void ShapeFromShadingAnalysis::draw() //ofRect(2.75*ofGetWidth()/4, 0, ofGetWidth()/2, ofGetHeight()); _animation_cnt12++; } - - - - - + } @@ -316,6 +328,7 @@ void ShapeFromShadingAnalysis::draw() ofDisableAlphaBlending(); } else { //_state = STATE_SYNTHESISING; + _frame_cnt = 0; _RUN_DONE = true; } @@ -408,8 +421,31 @@ void ShapeFromShadingAnalysis::draw() break; } + + case STATE_DISPLAY_RESULTS: - { + { + if (_frame_cnt > 2) + { + _image_shown = true; + _frame_cnt=0; + } + + _frame_cnt++; + + if (_show_image) + { + ofEnableAlphaBlending(); + + ofSetColor(255, 255, 255, 255); + image2.setFromPixels(image1.getPixels(),image1.width,image1.height, OF_IMAGE_COLOR); + image2.draw(0,0, ofGetWidth(), ofGetHeight()); + + ofDisableAlphaBlending(); + + } + + // display results of the synthesis _RUN_DONE = true; break; diff --git a/src/ShapeFromShadingAnalysis.h b/src/ShapeFromShadingAnalysis.h index f63b649..10922b6 100755 --- a/src/ShapeFromShadingAnalysis.h +++ b/src/ShapeFromShadingAnalysis.h @@ -21,6 +21,7 @@ public: void setup(int camWidth, int camHeight); void acquire(); void synthesise(); + void displayresults(); void draw(); void save_cb(Poco::Timer& timer); @@ -50,4 +51,10 @@ protected: int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; + bool _show_image, _image_shown; + + + ofImage image1; + ofxCvImage image2; + };