From 3eef15a14b7868e7efa7848df5663ff53d4c3277 Mon Sep 17 00:00:00 2001 From: Jamie Allen Date: Tue, 21 Feb 2012 01:34:24 +0100 Subject: [PATCH] added image playout for all classes --- example/RefractiveIndex.cpp | 11 ++---- example/RefractiveIndex.h | 1 + src/CamNoiseAnalysis.cpp | 56 ++++++++++++++++++++++++++++++ src/CamNoiseAnalysis.h | 7 ++++ src/ColorMultiAnalysis.cpp | 58 +++++++++++++++++++++++++++++++ src/ColorMultiAnalysis.h | 8 ++++- src/ColorSingleAnalysis.cpp | 57 ++++++++++++++++++++++++++++++ src/ColorSingleAnalysis.h | 8 ++++- src/DiffNoiseAnalysis.cpp | 58 +++++++++++++++++++++++++++++++ src/DiffNoiseAnalysis.h | 8 ++++- src/IResponseAnalysis.cpp | 59 ++++++++++++++++++++++++++++++++ src/IResponseAnalysis.h | 10 ++++-- src/RelaxRateAnalysis.cpp | 59 +++++++++++++++++++++++++++++++- src/RelaxRateAnalysis.h | 9 ++++- src/ShadowScapesAnalysis.cpp | 59 +++++++++++++++++++++++++++++++- src/ShadowScapesAnalysis.h | 9 ++++- src/ShapeFromShadingAnalysis.cpp | 7 ++-- src/ShapeFromShadingAnalysis.h | 6 ++-- src/StrobeAnalysis.cpp | 59 ++++++++++++++++++++++++++++++++ src/StrobeAnalysis.h | 9 ++++- 20 files changed, 532 insertions(+), 26 deletions(-) diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index 92f03f9..384b02d 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -1,12 +1,4 @@ -/* - - todo: - (1) Look at warinings about the #define which get over written - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ + ////also the new shit//// @@ -26,6 +18,7 @@ #include "ofxXmlSettings.h" #include "ofxOpenCv.h" + #define CAMERA_ID 1 #define CAMERA_ACQU_WIDTH 640 #define CAMERA_ACQU_HEIGHT 480 diff --git a/example/RefractiveIndex.h b/example/RefractiveIndex.h index aa96c2c..049ca3c 100644 --- a/example/RefractiveIndex.h +++ b/example/RefractiveIndex.h @@ -9,6 +9,7 @@ #include "AnalysisAdaptor.h" + class RefractiveIndex : public ofBaseApp { public: diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index d561d1a..6853eb7 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -33,6 +33,14 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight) create_dir(); + _show_image = false; + _image_shown = false; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } @@ -73,6 +81,33 @@ void CamNoiseAnalysis::synthesise() } +void CamNoiseAnalysis::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 @@ -224,9 +259,30 @@ void CamNoiseAnalysis::draw() 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/CamNoiseAnalysis.h b/src/CamNoiseAnalysis.h index ae94617..1320067 100755 --- a/src/CamNoiseAnalysis.h +++ b/src/CamNoiseAnalysis.h @@ -20,6 +20,8 @@ public: void setup(int camWidth, int camHeight); void acquire(); void synthesise(); + void displayresults(); + void draw(); void save_cb(Poco::Timer& timer); @@ -30,4 +32,9 @@ 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; + ofImage image2; + }; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 50e645e..73db99b 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -33,6 +33,15 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight) _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames create_dir(); + + _show_image = false; + _image_shown = false; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } @@ -70,6 +79,34 @@ void ColorMultiAnalysis::synthesise() // _saved_filenames has all the file names of all the saved images } +void ColorMultiAnalysis::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; + } + } +} + void ColorMultiAnalysis::draw() { @@ -216,9 +253,30 @@ void ColorMultiAnalysis::draw() 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/ColorMultiAnalysis.h b/src/ColorMultiAnalysis.h index c7ae204..86cbf92 100755 --- a/src/ColorMultiAnalysis.h +++ b/src/ColorMultiAnalysis.h @@ -14,7 +14,8 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void displayresults(); void draw(); void save_cb(Poco::Timer& timer); @@ -25,4 +26,9 @@ protected: int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; + + bool _show_image, _image_shown; + ofImage image1; + ofImage image2; + }; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 6716def..cb2c7c8 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -42,6 +42,14 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) fileNameTag = ""; + _show_image = false; + _image_shown = false; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } @@ -80,6 +88,34 @@ void ColorSingleAnalysis::synthesise() Thread::sleep(3); } +void ColorSingleAnalysis::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; + } + } +} + void ColorSingleAnalysis::draw() { @@ -233,9 +269,30 @@ void ColorSingleAnalysis::draw() 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; + } default: diff --git a/src/ColorSingleAnalysis.h b/src/ColorSingleAnalysis.h index 4d29533..1a43cbb 100755 --- a/src/ColorSingleAnalysis.h +++ b/src/ColorSingleAnalysis.h @@ -19,7 +19,8 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void displayresults(); void draw(); void save_cb(Poco::Timer& timer); @@ -32,4 +33,9 @@ protected: int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; + + bool _show_image, _image_shown; + ofImage image1; + ofImage image2; + }; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index 7b3681c..190300b 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -32,6 +32,15 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight) _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames create_dir(); + + _show_image = false; + _image_shown = false; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } @@ -71,6 +80,34 @@ void DiffNoiseAnalysis::synthesise() } +void DiffNoiseAnalysis::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 DiffNoiseAnalysis::draw() @@ -238,9 +275,30 @@ void DiffNoiseAnalysis::draw() 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; + } default: diff --git a/src/DiffNoiseAnalysis.h b/src/DiffNoiseAnalysis.h index a507e70..cfb5288 100755 --- a/src/DiffNoiseAnalysis.h +++ b/src/DiffNoiseAnalysis.h @@ -19,7 +19,8 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void displayresults(); void draw(); void save_cb(Poco::Timer& timer); @@ -30,4 +31,9 @@ protected: int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; + + bool _show_image, _image_shown; + ofImage image1; + ofImage image2; + }; diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 571685a..4d47604 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -30,6 +30,15 @@ void IResponseAnalysis::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; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); + } @@ -70,6 +79,35 @@ void IResponseAnalysis::synthesise() } +void IResponseAnalysis::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 IResponseAnalysis::draw() @@ -184,9 +222,30 @@ void IResponseAnalysis::draw() 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; + } default: diff --git a/src/IResponseAnalysis.h b/src/IResponseAnalysis.h index 78dc16a..4d428ec 100755 --- a/src/IResponseAnalysis.h +++ b/src/IResponseAnalysis.h @@ -19,7 +19,9 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void displayresults(); + void draw(); void save_cb(Poco::Timer& timer); @@ -29,5 +31,9 @@ protected: bool _RUN_DONE; int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; - + + bool _show_image, _image_shown; + ofImage image1; + ofImage image2; + }; diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 9a16019..817431b 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -31,6 +31,15 @@ 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 + + _show_image = false; + _image_shown = false; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } @@ -69,6 +78,35 @@ void RelaxRateAnalysis::synthesise() } +void RelaxRateAnalysis::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 RelaxRateAnalysis::draw() { @@ -198,9 +236,28 @@ void RelaxRateAnalysis::draw() 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; - cout << "RELAXRATE RUN COMPLETED" << endl; break; } diff --git a/src/RelaxRateAnalysis.h b/src/RelaxRateAnalysis.h index e36eeea..07185f0 100755 --- a/src/RelaxRateAnalysis.h +++ b/src/RelaxRateAnalysis.h @@ -16,7 +16,9 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void displayresults(); + void draw(); void save_cb(Poco::Timer& timer); @@ -27,4 +29,9 @@ protected: float _flip, _level; int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; + + bool _show_image, _image_shown; + ofImage image1; + ofImage image2; + }; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index b1410fb..f10698a 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -39,6 +39,15 @@ void ShadowScapesAnalysis::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; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } void ShadowScapesAnalysis::acquire() @@ -75,6 +84,35 @@ void ShadowScapesAnalysis::synthesise() } +void ShadowScapesAnalysis::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; + } + } +} + + // the animation draw - and the output draw void ShadowScapesAnalysis::draw() { @@ -253,8 +291,27 @@ void ShadowScapesAnalysis::draw() 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 - cout << "ShadowScapesAnalysis = STATE_DISPLAY_RESULTS...\n"; _RUN_DONE = true; break; } diff --git a/src/ShadowScapesAnalysis.h b/src/ShadowScapesAnalysis.h index 7a058c6..b649ab0 100755 --- a/src/ShadowScapesAnalysis.h +++ b/src/ShadowScapesAnalysis.h @@ -21,7 +21,9 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void displayresults(); + void draw(); void save_cb(Poco::Timer& timer); @@ -37,4 +39,9 @@ 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; + ofImage image2; + + }; \ No newline at end of file diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index 9c8f28b..f8f562b 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -32,7 +32,8 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) _show_image = false; _image_shown = false; - image2.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); image1.setUseTexture(false); image2.setUseTexture(true); @@ -105,11 +106,13 @@ void ShapeFromShadingAnalysis::displayresults() //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; @@ -442,10 +445,8 @@ void ShapeFromShadingAnalysis::draw() 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 10922b6..3a11aa4 100755 --- a/src/ShapeFromShadingAnalysis.h +++ b/src/ShapeFromShadingAnalysis.h @@ -6,7 +6,6 @@ #pragma once #include "AbstractAnalysis.h" - #include "Poco/Timer.h" @@ -51,10 +50,9 @@ protected: int _run_cnt, _save_cnt, _anim_cnt; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; - bool _show_image, _image_shown; - + bool _show_image, _image_shown; ofImage image1; - ofxCvImage image2; + ofImage image2; }; diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 0f887bb..25a76ea 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -29,6 +29,15 @@ void StrobeAnalysis::setup(int camWidth, int camHeight) int anim_time = 5; // 5 seconds for the animation _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + + _show_image = false; + _image_shown = false; + + //for an ofxOpenCv.h image i would like to use..." + //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + image1.setUseTexture(false); + image2.setUseTexture(true); } @@ -71,6 +80,35 @@ void StrobeAnalysis::synthesise() Thread::sleep(3); } +void StrobeAnalysis::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 StrobeAnalysis::draw() { @@ -220,9 +258,30 @@ void StrobeAnalysis::draw() 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/StrobeAnalysis.h b/src/StrobeAnalysis.h index 9661fb4..d45a92c 100755 --- a/src/StrobeAnalysis.h +++ b/src/StrobeAnalysis.h @@ -20,7 +20,9 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void displayresults(); + void draw(); void save_cb(Poco::Timer& timer); @@ -35,4 +37,9 @@ 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; + ofImage image2; + };