From 1d5d6abbde2167c458167e7bda6ceeca7ed39d10 Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Sun, 19 Feb 2012 18:17:45 +0000 Subject: [PATCH 1/7] corrected file confusion --- src/ColorMultiAnalysis.cpp | 94 +++++++++++++++++++++++++++--------- src/ColorMultiAnalysis.h | 5 +- src/ColorSingleAnalysis.cpp | 96 +++++++++++++++++++++++++++++++++++-- src/ColorSingleAnalysis.h | 6 ++- 4 files changed, 171 insertions(+), 30 deletions(-) diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index ba21eee..3b2f862 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -90,34 +90,57 @@ void ColorMultiAnalysis::acquire() void ColorMultiAnalysis::synthesise() { - cout<<"SYNTHESISING MULTI"; - // _saved_filenames has all the file names of all the saved images - // _saved_filenames has all the file names of all the saved images //incrementer to whichMesh speed=0.2; //whichMesh is the index in the vector of meshes whichMesh=0; - - cout<<"image loaded "; - //there is a problem with natural vs alphabetical order when loading the files - we need to make a fix for this - int shift=0; - cout<<_saved_filenames.size()<<" image filenames "; + int index=0; - //for(int i=shift;i<_saved_filenames.size()-2;i+=2){ - // cout<<_saved_filenames[i]< display_results_callback(*this, &ColorMultiAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=500; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + +} void ColorMultiAnalysis::draw() { @@ -171,12 +194,31 @@ void ColorMultiAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + break; } case STATE_DISPLAY_RESULTS: - { - // display results of the synthesis + { + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + + if(whichMesh>meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + } + break; } @@ -202,10 +244,16 @@ void ColorMultiAnalysis::save_cb(Timer& timer) // cout<<_whole_file_path<= NUM_SAVE_PER_RUN){ _RUN_DONE = true; } } + +void ColorMultiAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + diff --git a/src/ColorMultiAnalysis.h b/src/ColorMultiAnalysis.h index ef4fc60..55bf291 100755 --- a/src/ColorMultiAnalysis.h +++ b/src/ColorMultiAnalysis.h @@ -15,14 +15,15 @@ public: void setup(int camWidth, int camHeight); void acquire(); void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: bool _RUN_DONE; int _run_cnt, _save_cnt, _fade_cnt; - float c, _frame_cnt, _frame_cnt_max; - ofImage image1; + float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max; }; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index ec99afa..6779da9 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -15,10 +15,15 @@ using Poco::Timer; using Poco::TimerCallback; using Poco::Thread; +#define COMPARE_RED 1 +#define COMPARE_BLUE 2 +#define COMPARE_GREEN 3 +#define COMPARE_HUE 4 +#define COMPARE_BRIGHTNESS 5 void ColorSingleAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 300; + DELTA_T_SAVE = 100;//300; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -64,9 +69,65 @@ void ColorSingleAnalysis::acquire() void ColorSingleAnalysis::synthesise() { // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=false; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + + for(int i=1;i<_saved_filenames.size()-2;i+=2){ + + meshes.push_back(ofMesh()); + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[1]) && image2.loadImage(_saved_filenames[i+1])){ + + if(i<_saved_filenames.size()/3){ + setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_RED), image2, &meshes[index]); + } + if(i>=_saved_filenames.size()/3 && i<2* _saved_filenames.size()/3){ + setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_GREEN), image2, &meshes[index]); + } + if(i>= 2* _saved_filenames.size()/3 && i<_saved_filenames.size()){ + setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BLUE), image2, &meshes[index]); + } + index++; + } + } } - +void ColorSingleAnalysis::display_results(){ + + Timer* display_results_timer; + + TimerCallback display_results_callback(*this, &ColorSingleAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=500; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + +} void ColorSingleAnalysis::draw() { @@ -134,6 +195,25 @@ void ColorSingleAnalysis::draw() case STATE_DISPLAY_RESULTS: { // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + + if(whichMesh>meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + } + break; } @@ -152,11 +232,21 @@ void ColorSingleAnalysis::save_cb(Timer& timer) string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; + //cout<= NUM_SAVE_PER_RUN) _RUN_DONE = true; } +void ColorSingleAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + diff --git a/src/ColorSingleAnalysis.h b/src/ColorSingleAnalysis.h index 0772c43..2719ecd 100755 --- a/src/ColorSingleAnalysis.h +++ b/src/ColorSingleAnalysis.h @@ -19,15 +19,17 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: bool _RUN_DONE; string fileNameTag; int _run_cnt, _save_cnt, _fade_cnt; - float r,g,b, _frame_cnt, _frame_cnt_max; + float r,g,b, _frame_cnt, _frame_cnt_max , _results_cnt, _results_cnt_max; }; From c53eb2eb6c48b9cf7154885c2b7bcdc1f5932dc3 Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Sun, 19 Feb 2012 18:25:37 +0000 Subject: [PATCH 2/7] corrected file confusion AGAIN --- src/AbstractAnalysis.cpp | 118 +++++++++++++++++++++++++++++++++++- src/AbstractAnalysis.h | 10 ++- src/ColorSingleAnalysis.cpp | 2 +- 3 files changed, 127 insertions(+), 3 deletions(-) diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 9623d1b..e5432e1 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -41,6 +41,7 @@ void AbstractAnalysis::do_synthesize() { _state = STATE_SYNTHESISING; synthesise(); _state = STATE_DISPLAY_RESULTS; + display_results(); ofNotifyEvent(_synthesize_cb, _name); } @@ -143,7 +144,70 @@ ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2 } -void AbstractAnalysis:: setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh){ +ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison, int colourValue){ + //zScale is the mapping factor from pixel difference to shift on the zPlane + int zScale=200; + + ofPixels imagePixels1 = image1.getPixelsRef(); + ofPixels imagePixels2 = image2.getPixelsRef(); + + ofPixels difference; + //this unsigned char should be unnecessary - I would have thought - can't you just address the pixel locations in ofPixels directly? + unsigned char * thesePixels = new unsigned char[ imagePixels1.getWidth()*imagePixels1.getHeight()*3]; + + //where are we in the image pixel array + int x=0; + int y=0; + + //for each pixel... + for(int i=0;iimagePixels1.getWidth()){ + x=0; + y++; + + } + } + + difference.setFromPixels(thesePixels,imagePixels1.getWidth(),imagePixels1.getHeight(), 3); + + return difference; + +} + +void AbstractAnalysis::setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh){ int x=0; int y=0; @@ -165,3 +229,55 @@ void AbstractAnalysis:: setMeshFromPixels(ofPixels somePixels, ofImage currentSe } } + +vectorAbstractAnalysis:: getListOfImageFilePaths(string location, string whichAnalysis){ + + string path = ofToDataPath("")+"debug_analysis/"+location+"/"+whichAnalysis; + ofxDirList dirList; + + int numDirs = dirList.listDir(path); + + vectordirectoryNames; + + //get the last folder alphabetically - this should probably change to do something fancy with date to find most recent but don't want to code that until we are sure + string dirName=dirList.getName(numDirs-1); + + + const char *results=dirName.c_str(); + + ofFile file=ofFile(path+"/"+dirName); + vectorfileNamesToReturn; + + + // get + if(file.isDirectory()){ + dirList.listDir(path+"/"+dirName); + //if there are no files, exit here + if(dirList.size()==0){ + //if it's empty return an error warning + fileNamesToReturn.push_back("NO FILE HERE!"); + cout<<"NO FILE HERE!"; + return fileNamesToReturn; + } + for (int i=0; i getListOfImageFilePaths(string location, string whichAnalysis); public: string _name; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 6779da9..8ed26df 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -77,7 +77,7 @@ void ColorSingleAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=false; + bool debug=true; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); From 3fd26c1eb483d8a8b15405d2b5d11398f3eed34a Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Sun, 19 Feb 2012 18:51:25 +0000 Subject: [PATCH 3/7] fixed bug in color single --- src/ColorSingleAnalysis.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 8ed26df..d8a9efb 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -77,7 +77,7 @@ void ColorSingleAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=true; + bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); @@ -93,7 +93,7 @@ void ColorSingleAnalysis::synthesise() image1.setUseTexture(false); image2.setUseTexture(false); //some of the textures are not loading correctly so only make mesh if both the images load - if(image1.loadImage(_saved_filenames[1]) && image2.loadImage(_saved_filenames[i+1])){ + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ if(i<_saved_filenames.size()/3){ setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_RED), image2, &meshes[index]); From 6b401b8424d76d7d53c1bed4c63013ddd6b52ba2 Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Mon, 20 Feb 2012 11:25:55 +0000 Subject: [PATCH 4/7] added synthesise and display results to all analysis classes --- src/AbstractAnalysis.cpp | 36 ++++++++++++- src/AbstractAnalysis.h | 14 ++++- src/CamNoiseAnalysis.cpp | 86 +++++++++++++++++++++++++++-- src/CamNoiseAnalysis.h | 6 ++- src/ColorMultiAnalysis.cpp | 13 ++--- src/ColorSingleAnalysis.cpp | 16 +++--- src/DiffNoiseAnalysis.cpp | 90 +++++++++++++++++++++++++++++-- src/DiffNoiseAnalysis.h | 6 ++- src/IResponseAnalysis.cpp | 92 ++++++++++++++++++++++++++++++-- src/IResponseAnalysis.h | 8 +-- src/RelaxRateAnalysis.cpp | 90 +++++++++++++++++++++++++++++-- src/RelaxRateAnalysis.h | 6 ++- src/ShadowScapesAnalysis.cpp | 88 ++++++++++++++++++++++++++++-- src/ShadowScapesAnalysis.h | 6 ++- src/ShapeFromShadingAnalysis.cpp | 88 +++++++++++++++++++++++++++++- src/ShapeFromShadingAnalysis.h | 6 ++- src/StrobeAnalysis.cpp | 87 +++++++++++++++++++++++++++++- src/StrobeAnalysis.h | 6 ++- 18 files changed, 688 insertions(+), 56 deletions(-) diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index e5432e1..9e4009f 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -233,8 +233,8 @@ void AbstractAnalysis::setMeshFromPixels(ofPixels somePixels, ofImage currentSec vectorAbstractAnalysis:: getListOfImageFilePaths(string location, string whichAnalysis){ string path = ofToDataPath("")+"debug_analysis/"+location+"/"+whichAnalysis; - ofxDirList dirList; - + //ofxDirList dirList; + ofDirectory dirList; int numDirs = dirList.listDir(path); vectordirectoryNames; @@ -281,3 +281,35 @@ vectorAbstractAnalysis:: getListOfImageFilePaths(string location, string return fileNamesToReturn; } +int AbstractAnalysis::getRecordedValueFromFileName(string str){ + //split filename by underscore - there HAS to be a quicker way of doing things - its ONE LINE in java :( + char * cstr, *p; + vectortokens; + //string str ("Please split this phrase into tokens"); + + //make char pointer array + cstr = new char [str.size()+1]; + //copy string to char pointer array + strcpy (cstr, str.c_str()); + + //tokenise char p array and put first results into pointer? + p=strtok (cstr,"_"); + + while (p!=NULL) + { + p=strtok(NULL,"_"); + //push tokenised char into vector + tokens.push_back(p); + + } + delete[] cstr; + char *p1; + //cstr = new char [str.size()+1]; + //strcpy (cstr, str.c_str()); + + p1=strtok (tokens[tokens.size()-2],"."); + + return ofToInt(p1); +} + + diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index a759f17..1b79490 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -16,6 +16,12 @@ #define STATE_DISPLAY_RESULTS 0x3333 #define STATE_STOP 0xDEADBEEF +#define COMPARE_RED 1 +#define COMPARE_BLUE 2 +#define COMPARE_GREEN 3 +#define COMPARE_HUE 4 +#define COMPARE_BRIGHTNESS 5 + class AbstractAnalysis { public: @@ -49,9 +55,15 @@ protected: //uses the returned pixels from make3DZmap to make a mesh of points whose Z positions are set by the brightness values in ofPixels - ofPixels is being used as a convenient container for a bunch of z coordinates virtual void setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh); + //HELPER FUNCTIONS - //this is purely for debug purposes and loads old images from middlesborough test + //this is purely for debug/viewing purposes and loads old images from middlesborough test virtual vector getListOfImageFilePaths(string location, string whichAnalysis); + + //splits up the filename and returns the recorded value eg brightness + //EG FILENAME : DIFF_NOISE_7_85.7322.jpg RETURNS : 85.7322 + virtual int getRecordedValueFromFileName(string str); + public: string _name; diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index da1b400..b78677c 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 = 100;//200; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -59,9 +59,62 @@ void CamNoiseAnalysis::acquire() void CamNoiseAnalysis::synthesise() { - + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=true; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + //clear vector so we don't add to it on successive runs + meshes.clear(); + + for(int i=0;i<_saved_filenames.size()-1;i++){ + + + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ + meshes.push_back(ofMesh()); + cout<<"setting mesh"< display_results_callback(*this, &CamNoiseAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, 20); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=300; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + +} // this runs at frame rate = 33 ms for 30 FPS @@ -128,6 +181,27 @@ void CamNoiseAnalysis::draw() case STATE_DISPLAY_RESULTS: { // display results of the synthesis + // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + cout<meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + + } + break; } @@ -151,9 +225,15 @@ void CamNoiseAnalysis::save_cb(Timer& timer) ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - _saved_filenames.push_back(file); + _saved_filenames.push_back(ofToDataPath("")+file); if(_save_cnt >= NUM_SAVE_PER_RUN) _RUN_DONE = true; } +void CamNoiseAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} \ No newline at end of file diff --git a/src/CamNoiseAnalysis.h b/src/CamNoiseAnalysis.h index 79b1ff3..fd33821 100755 --- a/src/CamNoiseAnalysis.h +++ b/src/CamNoiseAnalysis.h @@ -19,16 +19,18 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: bool _RUN_DONE; int _run_cnt, _save_cnt; - float c, _frame_cnt, _frame_cnt_max,_save_cnt_max ; + float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max; }; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 3b2f862..a2f4f9e 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -41,11 +41,7 @@ using Poco::Timer; using Poco::TimerCallback; using Poco::Thread; -#define COMPARE_RED 1 -#define COMPARE_BLUE 2 -#define COMPARE_GREEN 3 -#define COMPARE_HUE 4 -#define COMPARE_BRIGHTNESS 5 + void ColorMultiAnalysis::setup(int camWidth, int camHeight) { @@ -98,15 +94,15 @@ void ColorMultiAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=true; + bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); } - + //clear vector so we don't add to it on successive runs + meshes.clear(); for(int i=0;i<_saved_filenames.size()-2;i+=2){ - meshes.push_back(ofMesh()); ofImage image1; ofImage image2; @@ -116,6 +112,7 @@ void ColorMultiAnalysis::synthesise() //some of the textures are not loading correctly so only make mesh if both the images load if(image1.loadImage(_saved_filenames[0]) && image2.loadImage(_saved_filenames[i+1])){ cout<<"setting mesh"< display_results_callback(*this, &ColorSingleAnalysis::display_results_cb); // display results of the synthesis - display_results_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files + display_results_timer = new Timer(0, 20); // timing interval for saving files display_results_timer->start(display_results_callback); _RUN_DONE = false; _results_cnt=0; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index a2a32cf..fb6587f 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -18,7 +18,7 @@ using Poco::Thread; void DiffNoiseAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 600; // right number is about 450 + DELTA_T_SAVE = 100;//600; // right number is about 450 NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 50; @@ -59,11 +59,63 @@ void DiffNoiseAnalysis::acquire() void DiffNoiseAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=true; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + //clear vector so we don't add to it on successive runs + meshes.clear(); + + for(int i=0;i<_saved_filenames.size()-1;i++){ + + + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ + meshes.push_back(ofMesh()); + cout<<"setting mesh"< display_results_callback(*this, &DiffNoiseAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, 20); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=300; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + +}// this runs at frame rate = 33 ms for 30 FPS -// this runs at frame rate = 33 ms for 30 FPS void DiffNoiseAnalysis::draw() { switch (_state) { @@ -144,6 +196,28 @@ void DiffNoiseAnalysis::draw() case STATE_DISPLAY_RESULTS: { // display results of the synthesis + // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + cout<meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + + } + + break; } @@ -178,7 +252,7 @@ void DiffNoiseAnalysis::save_cb(Timer& timer) ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - _saved_filenames.push_back(file); + _saved_filenames.push_back(ofToDataPath("")+file); } _save_cnt++; @@ -186,3 +260,11 @@ void DiffNoiseAnalysis::save_cb(Timer& timer) _RUN_DONE = true; } +void DiffNoiseAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + + diff --git a/src/DiffNoiseAnalysis.h b/src/DiffNoiseAnalysis.h index 93d57ae..17c9ab2 100755 --- a/src/DiffNoiseAnalysis.h +++ b/src/DiffNoiseAnalysis.h @@ -19,15 +19,17 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: bool _RUN_DONE; int _run_cnt, _save_cnt, _fade_cnt; - float c, _frame_cnt, _frame_cnt_max; + float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max; }; diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 624f78e..8ba948b 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -15,12 +15,14 @@ using Poco::Timer; using Poco::TimerCallback; using Poco::Thread; + + void IResponseAnalysis::setup(int camWidth, int camHeight) { DELTA_T_SAVE = 100; NUM_PHASE = 1; NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + NUM_SAVE_PER_RUN = 50;//100; create_dir(); _frame_cnt = 0; @@ -55,11 +57,65 @@ void IResponseAnalysis::acquire() } } + void IResponseAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=true; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + //clear vector so we don't add to it on successive runs + meshes.clear(); + + for(int i=0;i<_saved_filenames.size()-1;i++){ + + + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ + meshes.push_back(ofMesh()); + cout<<"setting mesh"< display_results_callback(*this, &IResponseAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, 20); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=300; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + +} // this runs at frame rate = 33 ms for 30 FPS @@ -88,6 +144,7 @@ void IResponseAnalysis::draw() case STATE_SYNTHESISING: { + // display animation of something while the synthesis in on-going... break; } @@ -95,6 +152,26 @@ void IResponseAnalysis::draw() case STATE_DISPLAY_RESULTS: { // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + cout<meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + + } + break; } @@ -118,9 +195,18 @@ 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); - + _saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name); + ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); if(_save_cnt >= NUM_SAVE_PER_RUN) _RUN_DONE = true; } +void IResponseAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + + diff --git a/src/IResponseAnalysis.h b/src/IResponseAnalysis.h index 07e2c95..b4fb710 100755 --- a/src/IResponseAnalysis.h +++ b/src/IResponseAnalysis.h @@ -19,16 +19,18 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); - + void display_results_cb(Poco::Timer& timer); + protected: bool _RUN_DONE; int _run_cnt, _save_cnt; - float c, _frame_cnt, _frame_cnt_max; + float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max; }; diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index bc210e8..273ccbb 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -18,10 +18,10 @@ using Poco::Thread; void RelaxRateAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 300; + DELTA_T_SAVE = 100;//300; NUM_PHASE = 1; NUM_RUN = 1; - NUM_SAVE_PER_RUN = 100; + NUM_SAVE_PER_RUN = 50;//100; create_dir(); @@ -61,8 +61,62 @@ void RelaxRateAnalysis::acquire() void RelaxRateAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=true; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + //clear vector so we don't add to it on successive runs + meshes.clear(); + + for(int i=0;i<_saved_filenames.size()-1;i++){ + + + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ + meshes.push_back(ofMesh()); + cout<<"setting mesh"< display_results_callback(*this, &RelaxRateAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, 20); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=300; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + +} + // this runs at frame rate = 33 ms for 30 FPS void RelaxRateAnalysis::draw() @@ -111,6 +165,27 @@ void RelaxRateAnalysis::draw() case STATE_DISPLAY_RESULTS: { // display results of the synthesis + // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + cout<meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + + } + break; } @@ -136,9 +211,16 @@ void RelaxRateAnalysis::save_cb(Timer& timer) ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST); - _saved_filenames.push_back(file); + _saved_filenames.push_back(ofToDataPath("")+file); if(_save_cnt >= NUM_SAVE_PER_RUN) _RUN_DONE = true; } +void RelaxRateAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + diff --git a/src/RelaxRateAnalysis.h b/src/RelaxRateAnalysis.h index 0a38e5c..cd89eac 100755 --- a/src/RelaxRateAnalysis.h +++ b/src/RelaxRateAnalysis.h @@ -20,16 +20,18 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: bool _RUN_DONE; float _flip, _level; int _run_cnt, _save_cnt; - float c, _frame_cnt, _frame_cnt_max; + float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max; }; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index f3b64a5..52f3e9b 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -89,10 +89,62 @@ void ShadowScapesAnalysis::acquire() void ShadowScapesAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=false; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + //clear vector so we don't add to it on successive runs + meshes.clear(); + + for(int i=0;i<_saved_filenames.size()-1;i++){ + + + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ + meshes.push_back(ofMesh()); + cout<<"setting mesh"< display_results_callback(*this, &ShadowScapesAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, 20); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=300; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + +} // the animation draw - and the output draw void ShadowScapesAnalysis::draw() { @@ -191,13 +243,33 @@ void ShadowScapesAnalysis::draw() { // display animation of something while the synthesis in on-going... - _state = STATE_DISPLAY_RESULTS; break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + cout<meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + + } + break; } @@ -225,8 +297,16 @@ void ShadowScapesAnalysis::save_cb(Timer& timer) if(_dir == D) { file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 2)+"_"+ofToString(_run_cnt,2)+".jpg"; } - + _saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name); + ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); _save_cnt++; - + } +void ShadowScapesAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + diff --git a/src/ShadowScapesAnalysis.h b/src/ShadowScapesAnalysis.h index f30258b..eb6f62a 100755 --- a/src/ShadowScapesAnalysis.h +++ b/src/ShadowScapesAnalysis.h @@ -51,10 +51,12 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: @@ -65,6 +67,6 @@ protected: float _step; shadow_type _dir; int _run_cnt, _save_cnt; - float c, _frame_cnt, _frame_cnt_max; + float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max; }; \ No newline at end of file diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index 4736499..010c40a 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -77,9 +77,64 @@ void ShapeFromShadingAnalysis::acquire() } } + void ShapeFromShadingAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=false; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + //clear vector so we don't add to it on successive runs + meshes.clear(); + + for(int i=0;i<_saved_filenames.size()-1;i++){ + + + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ + meshes.push_back(ofMesh()); + cout<<"setting mesh"< display_results_callback(*this, &ShapeFromShadingAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, 20); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=300; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + } // this runs at frame rate = 33 ms for 30 FPS @@ -323,6 +378,26 @@ void ShapeFromShadingAnalysis::draw() case STATE_DISPLAY_RESULTS: { // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + cout<meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + + } + break; } @@ -340,7 +415,8 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer) //cout << "ShapeFromShadingAnalysis::saving...\n"; string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg"; - + _saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name); + ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); _save_cnt++; @@ -348,3 +424,11 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer) _RUN_DONE = true; } +void ShapeFromShadingAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + + diff --git a/src/ShapeFromShadingAnalysis.h b/src/ShapeFromShadingAnalysis.h index e1c4b0c..811b66b 100755 --- a/src/ShapeFromShadingAnalysis.h +++ b/src/ShapeFromShadingAnalysis.h @@ -20,10 +20,12 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: @@ -48,6 +50,6 @@ protected: int _animation_cnt15; int _animation_cnt16; int _animation_reset; // this reset part didn't get working - so using 16 different counters! yay! - float c, _frame_cnt, _frame_cnt_max; + float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max; }; diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 4680699..42a3edb 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -64,7 +64,61 @@ void StrobeAnalysis::acquire() void StrobeAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + int index=0; + + //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + bool debug=false; + if(debug){ + _saved_filenames.clear(); + _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + } + //clear vector so we don't add to it on successive runs + meshes.clear(); + + for(int i=0;i<_saved_filenames.size()-1;i++){ + + + ofImage image1; + ofImage image2; + + //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) + image1.setUseTexture(false); + image2.setUseTexture(false); + //some of the textures are not loading correctly so only make mesh if both the images load + if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ + meshes.push_back(ofMesh()); + cout<<"setting mesh"< display_results_callback(*this, &StrobeAnalysis::display_results_cb); + // display results of the synthesis + + display_results_timer = new Timer(0, 20); // timing interval for saving files + display_results_timer->start(display_results_callback); + _RUN_DONE = false; + _results_cnt=0; + _results_cnt_max=300; + + while(!_RUN_DONE) + Thread::sleep(3); + + display_results_timer->stop(); + } // this runs at frame rate = 33 ms for 30 FPS @@ -132,6 +186,26 @@ void StrobeAnalysis::draw() case STATE_DISPLAY_RESULTS: { // display results of the synthesis + int imageWidth=640; + int imageHeight =480; + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + ofRotateY(_results_cnt*0.3); + //ofRotateX(90); + //ofRotateZ(whichMesh); + ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400; + ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 ); + + meshes[whichMesh].drawVertices(); + ofPopMatrix(); + whichMesh+=speed; + cout<meshes.size() -1 || whichMesh<0){ + speed*=-1; + whichMesh+=speed; + + } + break; } @@ -146,6 +220,8 @@ void StrobeAnalysis::draw() void StrobeAnalysis::save_cb(Timer& timer) { string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg"; + _saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name); + ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); _save_cnt++; @@ -159,3 +235,12 @@ void StrobeAnalysis::save_cb(Timer& timer) } } + +void StrobeAnalysis::display_results_cb(Timer& timer){ + _results_cnt++; + if (_results_cnt>_results_cnt_max) { + _RUN_DONE=true; + } +} + + diff --git a/src/StrobeAnalysis.h b/src/StrobeAnalysis.h index ca1cf93..b453c11 100755 --- a/src/StrobeAnalysis.h +++ b/src/StrobeAnalysis.h @@ -20,10 +20,12 @@ public: void setup(int camWidth, int camHeight); void acquire(); - void synthesise(); + void synthesise(); + void display_results(); void draw(); void save_cb(Poco::Timer& timer); + void display_results_cb(Poco::Timer& timer); protected: @@ -32,6 +34,8 @@ protected: int _save_cnt; int _frame_cnt, _frame_cnt_max, _save_cnt_max ; + float _results_cnt, _results_cnt_max; + int _strobe_interval; bool _strobe_on; }; From 935d6414b5c50821ef4be33f6eec0fecc75cffba Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Mon, 20 Feb 2012 11:33:26 +0000 Subject: [PATCH 5/7] tidy up --- src/CamNoiseAnalysis.cpp | 4 ++-- src/ColorMultiAnalysis.cpp | 2 +- src/ColorSingleAnalysis.cpp | 4 ++-- src/DiffNoiseAnalysis.cpp | 4 ++-- src/IResponseAnalysis.cpp | 4 ++-- src/RelaxRateAnalysis.cpp | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index b78677c..ce5bb85 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 = 100;//200; + DELTA_T_SAVE = 200; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -67,7 +67,7 @@ void CamNoiseAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=true; + bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index a2f4f9e..e342752 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -45,7 +45,7 @@ using Poco::Thread; void ColorMultiAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 50;//150; // the right number is about 300 + DELTA_T_SAVE = 150; // the right number is about 300 NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100;//; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index a06857a..4e27392 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 = 100;//300; + DELTA_T_SAVE = 300; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -72,7 +72,7 @@ void ColorSingleAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=true; + bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index fb6587f..a85df19 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -18,7 +18,7 @@ using Poco::Thread; void DiffNoiseAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 100;//600; // right number is about 450 + DELTA_T_SAVE = 600; // right number is about 450 NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 50; @@ -67,7 +67,7 @@ void DiffNoiseAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=true; + bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 8ba948b..6376173 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -22,7 +22,7 @@ void IResponseAnalysis::setup(int camWidth, int camHeight) DELTA_T_SAVE = 100; NUM_PHASE = 1; NUM_RUN = 1; - NUM_SAVE_PER_RUN = 50;//100; + NUM_SAVE_PER_RUN = 100; create_dir(); _frame_cnt = 0; @@ -68,7 +68,7 @@ void IResponseAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=true; + bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 273ccbb..bddc6ec 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -18,10 +18,10 @@ using Poco::Thread; void RelaxRateAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 100;//300; + DELTA_T_SAVE = 1300; NUM_PHASE = 1; NUM_RUN = 1; - NUM_SAVE_PER_RUN = 50;//100; + NUM_SAVE_PER_RUN = 100; create_dir(); @@ -69,7 +69,7 @@ void RelaxRateAnalysis::synthesise() int index=0; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=true; + bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); From bf8c630add8ee731c2f82ec95c6e54d36d2a6f21 Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Mon, 20 Feb 2012 12:00:18 +0000 Subject: [PATCH 6/7] make vector of meshes static since we only ever want to display one at a time --- src/AbstractAnalysis.cpp | 3 +++ src/AbstractAnalysis.h | 5 ++++- src/ColorMultiAnalysis.cpp | 2 +- src/ColorSingleAnalysis.cpp | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 9e4009f..16f8144 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -34,6 +34,9 @@ #include "RefractiveIndex.h" #include "ofxFileHelper.h" + +vector AbstractAnalysis::meshes; + // this is the main threaded loop for a given analysis void AbstractAnalysis::do_synthesize() { _state = STATE_ACQUIRING; diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index 1b79490..5131112 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -64,6 +64,9 @@ protected: //EG FILENAME : DIFF_NOISE_7_85.7322.jpg RETURNS : 85.7322 virtual int getRecordedValueFromFileName(string str); + static vectormeshes; + + public: string _name; @@ -84,7 +87,7 @@ protected: //added Tom S 19/2/12 //each mesh in the vector is a seperate 3D point cloud which is coloured with pixel data and shifted in the z plane according to the specified type of colour difference eg red value or hue - vectormeshes; + //make this vector were static //how fast to move from one mesh to the next float speed; //the index (inside the vector of meshes) of the current mesh being displayed diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index e342752..6c57f22 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -45,7 +45,7 @@ using Poco::Thread; void ColorMultiAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 150; // the right number is about 300 + DELTA_T_SAVE = 100;//150; // the right number is about 300 NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100;//; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 4e27392..f4845e4 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 = 100;//300; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; From d798394793cc04c8a1c9b77316124b7e3b54180e Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Mon, 20 Feb 2012 12:33:13 +0000 Subject: [PATCH 7/7] final check and commit before merge with master --- example/RefractiveIndex.cpp | 10 +++++----- src/CamNoiseAnalysis.cpp | 12 +++++++++--- src/ColorMultiAnalysis.cpp | 12 +++++++++--- src/ColorSingleAnalysis.cpp | 12 +++++++++--- src/DiffNoiseAnalysis.cpp | 11 ++++++++--- src/IResponseAnalysis.cpp | 11 ++++++++--- src/RelaxRateAnalysis.cpp | 13 +++++++++---- src/ShadowScapesAnalysis.cpp | 11 ++++++++--- src/ShapeFromShadingAnalysis.cpp | 11 ++++++++--- src/StrobeAnalysis.cpp | 11 ++++++++--- 10 files changed, 81 insertions(+), 33 deletions(-) diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index 03e38f9..d8242dc 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -101,19 +101,19 @@ void RefractiveIndex::setup() // _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 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()); diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index ce5bb85..e597b0e 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -65,17 +65,23 @@ void CamNoiseAnalysis::synthesise() whichMesh=0; int index=0; - + float iterator=1; //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. - bool debug=false; + bool debug=true; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-1;i++){ + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 6c57f22..42de749 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -92,16 +92,22 @@ void ColorMultiAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-2;i+=2){ + + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; ofImage image2; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index f4845e4..02210ad 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -70,16 +70,22 @@ void ColorSingleAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=1;i<_saved_filenames.size()-2;i+=2){ + + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; ofImage image2; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index a85df19..f278a4e 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -65,17 +65,22 @@ void DiffNoiseAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-1;i++){ + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 6376173..028a91a 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -66,17 +66,22 @@ void IResponseAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-1;i++){ + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index bddc6ec..af2fc93 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -18,7 +18,7 @@ using Poco::Thread; void RelaxRateAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 1300; + DELTA_T_SAVE = 130; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -67,17 +67,22 @@ void RelaxRateAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-1;i++){ + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index 52f3e9b..8c48dd4 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -95,17 +95,22 @@ void ShadowScapesAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-1;i++){ + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index 010c40a..de92f70 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -86,17 +86,22 @@ void ShapeFromShadingAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-1;i++){ + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1; diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 42a3edb..5152284 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -70,17 +70,22 @@ void StrobeAnalysis::synthesise() whichMesh=0; int index=0; - - //if you want to see what this looks like with real data ignore the new filenames and load teh old ones. + float iterator=1; bool debug=false; if(debug){ _saved_filenames.clear(); _saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name); + + //hack to limit number of meshes. + if(_saved_filenames.size()>100){ + iterator= _saved_filenames.size() /100; + } + } //clear vector so we don't add to it on successive runs meshes.clear(); - for(int i=0;i<_saved_filenames.size()-1;i++){ + for(float i=0;i<_saved_filenames.size()-1;i+=iterator){ ofImage image1;