diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 9623d1b..4d8b78d 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -80,88 +80,4 @@ void AbstractAnalysis::create_dir() //////////////////////////////END DIRECTORY CREATION ////////////////////////////////////////////////// } -ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison){ - //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; - - //get rid of all previous vectors and colours - uncomment if re-setting the mesh on the fly - ie live rather than saving it first - //someMesh->clear(); - - unsigned char * thesePixels =currentSecondImage.getPixels(); - - for(int i=0;iaddVertex(ofVec3f(x,y,- somePixels.getColor(x, y).getBrightness() )); - // add colour from current second image of two - someMesh->addColor( currentSecondImage.getColor(x, y) ); - x++; - if(x>somePixels.getWidth()){ - x=0; - y++; - } - - } - -} diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index a7da748..d53940d 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -40,9 +40,6 @@ protected: // analysis + synthesize images - all the children (see - do_synthesize) virtual void synthesise() = 0; - virtual ofPixels calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison); - - virtual void setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh); public: string _name; @@ -62,12 +59,5 @@ protected: int NUM_RUN; int NUM_SAVE_PER_RUN; - //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; - //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 - float whichMesh; friend class AnalysisAdaptor; }; \ No newline at end of file diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index 8ea2cf6..e7b2355 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -59,7 +59,7 @@ void CamNoiseAnalysis::acquire() void CamNoiseAnalysis::synthesise() { - + // _saved_filenames has all the file names of all the saved images } @@ -152,13 +152,14 @@ void CamNoiseAnalysis::save_cb(Timer& timer) { _save_cnt++; - cout << "ColorSingleAnalysis::saving...\n"; - string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; + string thisLocation = RefractiveIndex::_location; + string file = _whole_file_path+"/"+file_name; + ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - _saved_filenames.push_back(_whole_file_path+"/"+file_name); + _saved_filenames.push_back(file); //if(_save_cnt >= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 38649cc..02a5873 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -41,18 +41,14 @@ 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) { - 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;//; + NUM_SAVE_PER_RUN = 300; create_dir(); _frame_cnt = 0; @@ -70,7 +66,7 @@ void ColorMultiAnalysis::acquire() // RUN ROUTINE for(int i = 0; i < NUM_RUN; i++) { - + _run_cnt = i; cout << "RUN NUM = " << i; @@ -90,31 +86,7 @@ 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]<= NUM_SAVE_PER_RUN){ // _RUN_DONE = true; //} -======= - // _saved_filenames.push_back("/Users/tomschofield/of_preRelease_v007_osx/apps/myApps/refractiveIndexDavidFeb/bin/data/"+_whole_file_path+"/"+file_name); - _saved_filenames.push_back("fish.jpg"); - - if(_save_cnt >= NUM_SAVE_PER_RUN){ - _RUN_DONE = true; - } ->>>>>>> added image loading and display results stuff- changes all commented in code } diff --git a/src/ColorMultiAnalysis.h b/src/ColorMultiAnalysis.h index ef4fc60..eff1c3a 100755 --- a/src/ColorMultiAnalysis.h +++ b/src/ColorMultiAnalysis.h @@ -24,5 +24,4 @@ protected: bool _RUN_DONE; int _run_cnt, _save_cnt, _fade_cnt; float c, _frame_cnt, _frame_cnt_max; - ofImage image1; }; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 464a112..0ee5153 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -156,14 +156,14 @@ void ColorSingleAnalysis::save_cb(Timer& timer) { _save_cnt++; - cout << "ColorSingleAnalysis::saving...\n"; + // cout << "ColorSingleAnalysis::saving...\n"; string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - _saved_filenames.push_back(_whole_file_path+"/"+file_name); - + //cout<<_whole_file_path+"/"+file_name<= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index 0b7df2d..54e635b 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -167,16 +167,30 @@ void DiffNoiseAnalysis::draw() // this runs at save_cb timer rate = DELTA_T_SAVE void DiffNoiseAnalysis::save_cb(Timer& timer) { - _save_cnt++; - - cout << "DiffNoiseAnalysis::saving...\n"; - - string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - - _saved_filenames.push_back(_whole_file_path+"/"+file_name); + + float rand10 = ofRandom(0,10); + + if (rand10 > 5.0) { + + cout << "DiffNoiseAnalysis::saving...\n"; + cout << "c_last... " << c << endl; + cout<<"rand10... " <= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 27ed0c2..efa0e96 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -110,17 +110,19 @@ void IResponseAnalysis::draw() // this runs at save_cb timer rate = DELTA_T_SAVE void IResponseAnalysis::save_cb(Timer& timer) { - _save_cnt++; cout << "IResponseAnalysis::saving...\n"; - + //cout << "c_last... " << c << endl; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; + string thisLocation = RefractiveIndex::_location; + + //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); ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - _saved_filenames.push_back(_whole_file_path+"/"+file_name); - //if(_save_cnt >= NUM_SAVE_PER_RUN) // _RUN_DONE = true; } diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 74be19e..521e049 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -128,15 +128,17 @@ void RelaxRateAnalysis::draw() void RelaxRateAnalysis::save_cb(Timer& timer) { _save_cnt++; - cout << "RelaxRateAnalysis::saving...\n"; - + //cout << "c_last... " << c << endl; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); + string thisLocation = RefractiveIndex::_location; - _saved_filenames.push_back(_whole_file_path+"/"+file_name); + string file = _whole_file_path+"/"+file_name; + + ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST); + _saved_filenames.push_back(file); + //if(_save_cnt >= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index f68a9ef..c39a34f 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -211,10 +211,7 @@ void ShadowScapesAnalysis::draw() void ShadowScapesAnalysis::save_cb(Timer& timer) { - _save_cnt++; - cout << "ShadowScapesAnalysis::saving...\n"; - string file_name; if(_dir == H) { @@ -230,8 +227,6 @@ void ShadowScapesAnalysis::save_cb(Timer& timer) } ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - - _saved_filenames.push_back(_whole_file_path+"/"+file_name); - + _save_cnt++; } diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index a006b75..5bb67dd 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -306,9 +306,7 @@ void ShapeFromShadingAnalysis::draw() } ofDisableAlphaBlending(); - } else { - _RUN_DONE = true; - } + } _frame_cnt++; //cout << "_frame_cnt:" << _frame_cnt << endl; @@ -341,16 +339,10 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer) { //cout << "ShapeFromShadingAnalysis::saving...\n"; - - _save_cnt++; - - cout << "ShapeFromShadingAnalysis::saving...\n"; - string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg"; ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - - _saved_filenames.push_back(_whole_file_path+"/"+file_name); + _save_cnt++; //if(_save_cnt >= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 3944c30..5778165 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -152,17 +152,13 @@ void StrobeAnalysis::draw() // this runs at save_cb timer rate = DELTA_T_SAVE void StrobeAnalysis::save_cb(Timer& timer) { - + string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg"; + ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); _save_cnt++; - cout << "StrobeAnalysis::saving...\n"; + cout << "_save_cnt" << _save_cnt << endl; - string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg"; - - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); - - _saved_filenames.push_back(_whole_file_path+"/"+file_name); - + cout << "_save_cnt_max" << _save_cnt_max << endl; //TODO: something fucked here with my calc of _save_cnt_max - new structure should fix it? //if(_save_cnt >= _save_cnt_max-10) {