From 5c5581f16e12c02ea53a2ff08447600451d7b7b4 Mon Sep 17 00:00:00 2001 From: dviid Date: Tue, 21 Feb 2012 18:06:58 +0100 Subject: [PATCH] mid-backed commit - master is dead --- example/RefractiveIndex.cpp | 23 ++++++++++++----------- src/AbstractAnalysis.cpp | 18 +++++++++++++----- src/CamNoiseAnalysis.cpp | 8 +------- src/ColorMultiAnalysis.cpp | 26 +++----------------------- src/ColorSingleAnalysis.cpp | 17 ++++++----------- src/DiffNoiseAnalysis.cpp | 22 +++++++--------------- src/IResponseAnalysis.cpp | 15 ++++----------- src/RelaxRateAnalysis.cpp | 18 +++++++++++------- src/ShadowScapesAnalysis.cpp | 25 ++++++++++++++++++++++--- src/StrobeAnalysis.cpp | 5 ++--- 10 files changed, 81 insertions(+), 96 deletions(-) diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index d831ee9..2195d55 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -97,29 +97,29 @@ void RefractiveIndex::setup() //TODO: whichever one of these is first - it always runs twice ? - _analysisVector.push_back(new ShadowScapesAnalysis(V)); - _analysisVector.push_back(new ShadowScapesAnalysis(H)); - _analysisVector.push_back(new ShadowScapesAnalysis(D)); + //_analysisVector.push_back(new ShadowScapesAnalysis(V)); + //_analysisVector.push_back(new ShadowScapesAnalysis(H)); + //_analysisVector.push_back(new ShadowScapesAnalysis(D)); _analysisVector.push_back(new RelaxRateAnalysis()); - _analysisVector.push_back(new IResponseAnalysis()); + //_analysisVector.push_back(new IResponseAnalysis()); - _analysisVector.push_back(new ShapeFromShadingAnalysis()); + //_analysisVector.push_back(new ShapeFromShadingAnalysis()); - _analysisVector.push_back(new StrobeAnalysis()); + //_analysisVector.push_back(new StrobeAnalysis()); - _analysisVector.push_back(new CamNoiseAnalysis()); + //_analysisVector.push_back(new CamNoiseAnalysis()); - _analysisVector.push_back(new ColorSingleAnalysis()); + //_analysisVector.push_back(new ColorSingleAnalysis()); - _analysisVector.push_back(new ColorMultiAnalysis()); + //_analysisVector.push_back(new ColorMultiAnalysis()); - _analysisVector.push_back(new DiffNoiseAnalysis()); + //_analysisVector.push_back(new DiffNoiseAnalysis()); _currentAnalysisIndx = 0; - _currentAnalysis = _analysisVector.at(_currentAnalysisIndx); + _currentAnalysis = _analysisVector.at(_currentAnalysisIndx++); _state = ISTATE_START; @@ -209,6 +209,7 @@ void RefractiveIndex::setup_camera() ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber"; return; } + _vidGrabber.setUseTexture(false); _vidGrabber.listDevices(); _vidGrabber.setVerbose(true); _vid_stream_open = true; diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index aa556a0..e81fe7b 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -72,8 +72,8 @@ void AbstractAnalysis::create_dir() } ofxFileHelper fileHelper; - _whole_file_path = ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ; - //cout << "_whole_file_path = " << _whole_file_path << endl; + _whole_file_path = ofToDataPath("") + ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ; + cout << "_whole_file_path = " << _whole_file_path << endl; if(!fileHelper.doesDirectoryExist(_whole_file_path)){ fileHelper.makeDirectory(ANALYSIS_PATH); @@ -163,7 +163,8 @@ ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2 int y=0; //for each pixel... - for(int i=0;i= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 29482bb..bd65800 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -247,34 +247,14 @@ void ColorMultiAnalysis::draw() // this runs at save_cb timer rate = DELTA_T_SAVE void ColorMultiAnalysis::save_cb(Timer& timer) { - _save_cnt++; - - // UPDATE THE COLOR ON THE SCREEN - //float c_last = c; // cout << "COLORMULTIANALYSIS::saving...\n"; - // cout << "c_last... " << c << endl; + string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; + saveimage(file_name); - // cout<<_whole_file_path<>>>>>> tom - if(_save_cnt >= NUM_SAVE_PER_RUN){ - _RUN_DONE = true; - } -======= - - //if(_save_cnt >= NUM_SAVE_PER_RUN){ - // _RUN_DONE = true; - //} ->>>>>>> 88fa0375934e9ad87053542e88a0f9fe61af0a66 } void ColorMultiAnalysis::display_results_cb(Timer& timer){ diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 49a2f07..f332d78 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -236,19 +236,14 @@ void ColorSingleAnalysis::draw() // this runs at save_cb timer rate = DELTA_T_SAVE void ColorSingleAnalysis::save_cb(Timer& timer) { + + //cout << "ColorSingleAnalysis::saving...\n"; + + string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; + saveimage(file_name); + _save_cnt++; - - // cout << "ColorSingleAnalysis::saving...\n"; - - string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; - - //cout<= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index 7a13e62..3f9759b 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -252,25 +252,17 @@ void DiffNoiseAnalysis::save_cb(Timer& timer) 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 0ae3ca7..85a88eb 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -191,20 +191,13 @@ 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 << "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; + saveimage(file_name); - //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); + _save_cnt++; //if(_save_cnt >= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 759176f..e12d457 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -61,6 +61,7 @@ void RelaxRateAnalysis::acquire() void RelaxRateAnalysis::synthesise() { + /* //incrementer to whichMesh speed=0.2; //whichMesh is the index in the vector of meshes @@ -100,10 +101,13 @@ void RelaxRateAnalysis::synthesise() index++; } } + */ } void RelaxRateAnalysis::display_results(){ + /* + Timer* display_results_timer; TimerCallback display_results_callback(*this, &RelaxRateAnalysis::display_results_cb); @@ -119,6 +123,7 @@ void RelaxRateAnalysis::display_results(){ Thread::sleep(3); display_results_timer->stop(); + */ } @@ -170,6 +175,7 @@ void RelaxRateAnalysis::draw() case STATE_DISPLAY_RESULTS: { + /* // display results of the synthesis // display results of the synthesis int imageWidth=640; @@ -191,6 +197,7 @@ void RelaxRateAnalysis::draw() whichMesh+=speed; } + */ break; } @@ -207,17 +214,14 @@ void RelaxRateAnalysis::draw() // this runs at save_cb timer rate = DELTA_T_SAVE void RelaxRateAnalysis::save_cb(Timer& timer) { - _save_cnt++; - cout << "RelaxRateAnalysis::saving...\n"; + //cout << "RelaxRateAnalysis::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; - - string file = _whole_file_path+"/"+file_name; - ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST); + saveimage(file_name); + + _save_cnt++; - _saved_filenames.push_back(ofToDataPath("")+file); //if(_save_cnt >= NUM_SAVE_PER_RUN) // _RUN_DONE = true; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index 3da5f7e..434aa18 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -119,6 +119,14 @@ void ShadowScapesAnalysis::synthesise() //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); + + string fnamei = _saved_filenames[i]; + string fnameii = _saved_filenames[i + 1]; + + bool l1 = image1.loadImage(_saved_filenames[i]); + bool l2 = image2.loadImage(_saved_filenames[i+1]); + + //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()); @@ -126,6 +134,9 @@ void ShadowScapesAnalysis::synthesise() setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS), image2, &meshes[index]); index++; } + + image1.clear(); + image2.clear(); } } @@ -288,6 +299,14 @@ void ShadowScapesAnalysis::draw() void ShadowScapesAnalysis::save_cb(Timer& timer) { + RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera + + if (RefractiveIndex::_vidGrabber.isFrameNew()) + { + RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera + } + + cout << "ShadowScapesAnalysis::saving...\n"; string file_name; @@ -302,9 +321,9 @@ 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); + + saveimage(file_name); + _save_cnt++; } diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index a4f81c2..4589945 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -232,9 +232,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); + saveimage(file_name); + _save_cnt++; cout << "_save_cnt" << _save_cnt << endl;