diff --git a/config.refindx b/config.refindx index 3d20749..9dd552e 100644 --- a/config.refindx +++ b/config.refindx @@ -14,26 +14,26 @@ - 5 - 2 + 3 + 3 3 - 4 + 3 5 - 1 + 5 5 5 - 2 + 3 - 25 - 22 - 23 - 24 - 25 - 20 - 25 - 35 - 20 + 30 + 30 + 30 + 30 + 30 + 30 + 40 + 40 + 30 \ No newline at end of file diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index 69532f8..17b4118 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -100,7 +100,6 @@ void RefractiveIndex::setup() _analysisVector.push_back(new ShadowScapesAnalysis(H)); _analysisVector.push_back(new ShadowScapesAnalysis(D)); - _analysisVector.push_back(new RelaxRateAnalysis()); _analysisVector.push_back(new IResponseAnalysis()); @@ -116,7 +115,7 @@ void RefractiveIndex::setup() _analysisVector.push_back(new ColorMultiAnalysis()); _analysisVector.push_back(new DiffNoiseAnalysis()); - + //_currentAnalysisIndx = 0; //_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++); diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index ec4638f..a63e6fa 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -12,8 +12,8 @@ void AbstractAnalysis::do_synthesize() { cout << "NUM_RUN: " << i << endl; _saved_filenames_analysis.clear(); - _saved_filenames_synthesis.clear(); - + _saved_filenames_synthesis.clear(); + _state = STATE_ACQUIRING; acquire(); if(_state == STATE_STOP) goto exit; @@ -28,7 +28,7 @@ void AbstractAnalysis::do_synthesize() { ofNotifyEvent(_synthesize_cb, _name); } -void AbstractAnalysis::create_dir() +void AbstractAnalysis::create_dir_allocate_images() { // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES @@ -92,11 +92,28 @@ void AbstractAnalysis::create_dir() fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime); } + //////////////////////////////END DIRECTORY CREATION ////////////////////////////////////////////////// - //////////////////////////////END DIRECTORY CREATION ////////////////////////////////////////////////// + + //////////////////////////////ALLOCATE IMAGES ////////////////////////////////////////////////// + + ofImage myColorImage1; + myColorImage1.setUseTexture(false); + myColorImage1.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_COLOR); + + ofImage myGrayImage1; + myGrayImage1.setUseTexture(false); + myGrayImage1.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_GRAYSCALE); + + ofImage myColorImage2; + myColorImage2.setUseTexture(false); + myColorImage2.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_COLOR); + + //////////////////////////////END ALLOCATE IMAGES ////////////////////////////////////////////////// + } -void AbstractAnalysis::saveimage(string filename) +void AbstractAnalysis::saveImageAnalysis(string filename) { RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera @@ -120,14 +137,10 @@ void AbstractAnalysis::saveimage(string filename) //somePixels = new unsigned char [appPix.getWidth()*appPix.getHeight()*3]; somePixels = appPix.getPixels(); - ofImage myImage; - //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); - //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - myImage.setUseTexture(false); - - myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); - myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+filename); + myColorImage1.setUseTexture(false); + myColorImage1.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myColorImage1.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+filename); #endif @@ -135,3 +148,37 @@ void AbstractAnalysis::saveimage(string filename) } + +void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType) +{ + +#ifdef TARGET_OSX + + ofSaveImage(newPixels->getPixelsRef(), _whole_file_path_analysis+"/"+filename, OF_IMAGE_QUALITY_BEST); + +#elif defined(TARGET_WIN32) + + if (newType == OF_IMAGE_COLOR){ + myColorImage2.setFromPixels(newPixels.getPixels(), newPixels.width, newPixels.width, OF_IMAGE_COLOR); + } + + if (newType == OF_IMAGE_GRAYSCALE){ + myGrayImage1.setFromPixels(newPixels.getPixels(), newPixels.width, newPixels.width, OF_IMAGE_GRAYSCALE); + } + + myColorImage2.saveImage(_whole_file_path_synthesis+"/"+thisfilename); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + //unsigned char * somePixels; + //ofPixels appPix = RefractiveIndex::_pixels; + //somePixels = new unsigned char [appPix.getWidth()*appPix.getHeight()*3]; + //somePixels = appPix.getPixels(); + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + +#endif + + _saved_filenames_synthesis.push_back(_whole_file_path_analysis+"/"+filename); + +} + diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index b56be00..84b688f 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -7,6 +7,7 @@ #include "ofMain.h" #include "ofEvents.h" +#include "ofxOpenCv.h" #include #define ANALYSIS_PATH "analysis/" @@ -34,9 +35,10 @@ public: protected: - virtual void create_dir(); + virtual void create_dir_allocate_images(); - virtual void saveimage(string filename); + virtual void saveImageAnalysis(string filename); + virtual void saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType); // acquire images - all the children (see - do_synthesize) virtual void acquire() = 0; @@ -61,6 +63,9 @@ protected: int _state; + ofImage myColorImage; + ofImage myBlackWhiteImage; + //int _run_cnt; float DELTA_T_SAVE; diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index d771a27..e9e24ae 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -40,7 +40,7 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight) int anim_time = 10; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames - //create_dir(); + //create_dir_allocate_images(); _show_image = false; _image_shown = false; @@ -77,7 +77,7 @@ void CamNoiseAnalysis::acquire() _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _run_cnt++; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); // RUN ROUTINE // for(int i = 0; i < NUM_RUN; i++) { @@ -144,18 +144,22 @@ void CamNoiseAnalysis::synthesise() //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); - image.setFromPixels(cvGrayImage1.getPixels(), cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setFromPixels(cvGrayImage1.getPixels(), cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvGrayImage1, OF_IMAGE_GRAYSCALE); _synth_save_cnt++; + //} } } @@ -389,5 +393,5 @@ void CamNoiseAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 2ac192a..6fc6130 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -29,7 +29,7 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight) _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames - //create_dir(); + //create_dir_allocate_images(); _frame_cnt = 0; _run_cnt = 0; @@ -76,7 +76,7 @@ void ColorMultiAnalysis::acquire() _run_cnt++; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); // RUN ROUTINE //for(int i = 0; i < NUM_RUN; i++) { @@ -145,17 +145,19 @@ void ColorMultiAnalysis::synthesise() //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); - image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR); _synth_save_cnt++; // } @@ -386,5 +388,5 @@ void ColorMultiAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 7379a26..1abdea6 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -30,7 +30,7 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames - //create_dir(); + //create_dir_allocate_images(); _run_cnt = 0; _frame_cnt = 0; @@ -81,7 +81,7 @@ void ColorSingleAnalysis::acquire() _run_cnt++; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); // RUN ROUTINE //for(int i = 0; i < NUM_RUN; i++) { @@ -159,18 +159,21 @@ void ColorSingleAnalysis::synthesise() //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); - image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); - _synth_save_cnt++; + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR); + _synth_save_cnt++; + // } } } @@ -407,5 +410,5 @@ void ColorSingleAnalysis::save_cb(Timer& timer) string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index a9654c5..ac3b2ab 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -30,7 +30,7 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight) _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames - //create_dir(); + //create_dir_allocate_images(); _run_cnt = 0; _frame_cnt = 0; @@ -76,7 +76,7 @@ void DiffNoiseAnalysis::acquire() _run_cnt++; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); // RUN ROUTINE //for(int i = 0; i < NUM_RUN; i++) { @@ -143,16 +143,19 @@ void DiffNoiseAnalysis::synthesise() //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvColorImage1.width, cvGrayImage1.height, OF_IMAGE_COLOR); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); - image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR); _synth_save_cnt++; // } @@ -404,5 +407,5 @@ void DiffNoiseAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index b907c7c..9a32868 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -31,7 +31,7 @@ void IResponseAnalysis::setup(int camWidth, int camHeight) _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames - //create_dir(); + //create_dir_allocate_images(); _synth_save_cnt = 0; _run_cnt = 0; _frame_cnt = 0; @@ -76,7 +76,7 @@ void IResponseAnalysis::acquire() _run_cnt++; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); // RUN ROUTINE //for(int i = 0; i < NUM_RUN; i++) { @@ -144,17 +144,18 @@ void IResponseAnalysis::synthesise() //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); - - image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setUseTexture(false); + //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); _synth_save_cnt++; } @@ -371,5 +372,5 @@ void IResponseAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 0b09bac..e85b220 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -30,7 +30,7 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight) _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames - //create_dir(); + //create_dir_allocate_images(); _run_cnt = 0; _level = 0; @@ -77,7 +77,7 @@ void RelaxRateAnalysis::acquire() _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); // RUN ROUTINE //for(int i = 0; i < NUM_RUN; i++) { @@ -141,17 +141,19 @@ void RelaxRateAnalysis::synthesise() //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); + //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); - image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); - - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); _synth_save_cnt++; } } @@ -364,7 +366,7 @@ void RelaxRateAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index 2b9227b..d7f1b10 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -83,7 +83,7 @@ void ShadowScapesAnalysis::acquire() _line = 0; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); save_timer.start(save_callback); @@ -145,24 +145,26 @@ void ShadowScapesAnalysis::synthesise() } + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); - - image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); _synth_save_cnt++; - } } } @@ -198,41 +200,6 @@ void ShadowScapesAnalysis::displayresults() _image_shown = false; } } - - - // THE OLD SHIT /// -/* - for(float i=1;i<_saved_filenames_synthesis.size()-1;i++){ - - // cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl; - - if(_state == STATE_STOP) return; - - while(!_image_shown){ - Thread::sleep(2); - //cout << "!_image_shown" << endl; - } - - if(!image1.loadImage(_saved_filenames_synthesis[i])){ - //couldn't load image - cout << "didn't load image" << endl; - } - - - if(image1.loadImage(_saved_filenames_analysis[i])){ - - image1.loadImage(_saved_filenames_analysis[i]); - cout << "loaded filenames[i] - " << _saved_filenames_analysis[i] << endl; - - image2.setFromPixels(image1.getPixels(),image1.width,image1.height, OF_IMAGE_COLOR); - - //cout << "_show_image = true;" << endl; - _show_image = true; - _image_shown = false; - - } - } -*/ } @@ -467,6 +434,6 @@ void ShadowScapesAnalysis::save_cb(Timer& timer) file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 2)+"_"+ofToString(_run_cnt,2)+".jpg"; } - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index f49650f..82f0998 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -31,7 +31,7 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames - //create_dir(); + //create_dir_allocate_images(); _synth_save_cnt = 0; _run_cnt = 0; _frame_cnt = 0; @@ -77,7 +77,7 @@ void ShapeFromShadingAnalysis::acquire() _run_cnt++; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); _animation_cnt1 = 0; _animation_cnt2 = 0; @@ -161,19 +161,22 @@ void ShapeFromShadingAnalysis::synthesise() //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); - - + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); - image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + + + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); _synth_save_cnt++; } @@ -563,5 +566,5 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); } diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 8b9cf2f..346f6e3 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -34,7 +34,7 @@ void StrobeAnalysis::setup(int camWidth, int camHeight) // The British Health and Safety Executive recommend that a net flash rate for a bank of strobe lights does not exceed 5 flashes per second, at which only 5% of photosensitive epileptics are at risk. It also recommends that no strobing effect continue for more than 30 seconds, due to the potential for discomfort and disorientation. - //create_dir(); + //create_dir_allocate_images(); _synth_save_cnt = 0; _run_cnt = 0; @@ -76,7 +76,7 @@ void StrobeAnalysis::acquire() _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _strobe_cnt = 0, _synth_save_cnt = 0; _run_cnt++; _RUN_DONE = false; - create_dir(); + create_dir_allocate_images(); // RUN ROUTINE //for(int i = 0; i < NUM_RUN; i++) { @@ -143,18 +143,24 @@ void StrobeAnalysis::synthesise() //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - ofImage image; + //ofImage image; //image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - image.setUseTexture(false); + //image.setUseTexture(false); - image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height,OF_IMAGE_GRAYSCALE); - image.saveImage(_whole_file_path_synthesis+"/"+file_name); + //image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height,OF_IMAGE_GRAYSCALE); + //image.saveImage(_whole_file_path_synthesis+"/"+file_name); - _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); + + + + // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> /// + saveImageSynthesis(file_name, &cvGrayDiff1, OF_IMAGE_GRAYSCALE); _synth_save_cnt++; + } } } @@ -388,5 +394,5 @@ void StrobeAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg"; - saveimage(file_name); + saveImageAnalysis(file_name); }