ALLOCATING the saved images

* moved the synthesis saving to an abstract function called
saveImageSynthesis()
* allocating the images we're saving out in a renamed
create_dir_allocate_images()
* MAKE SURE TO PUT THE CONFIG FILE IN /data/
This commit is contained in:
Jamie Allen 2012-02-26 19:12:34 +01:00
parent 8fe367b47b
commit 38ec4da627
13 changed files with 185 additions and 143 deletions

View File

@ -14,26 +14,26 @@
</locale> </locale>
<analysis_NUM_RUN> <analysis_NUM_RUN>
<NUM_RUN_shadowscapes> 5 </NUM_RUN_shadowscapes> <NUM_RUN_shadowscapes> 3 </NUM_RUN_shadowscapes>
<NUM_RUN_relaxrate> 2 </NUM_RUN_relaxrate> <NUM_RUN_relaxrate> 3 </NUM_RUN_relaxrate>
<NUM_RUN_iresponse> 3 </NUM_RUN_iresponse> <NUM_RUN_iresponse> 3 </NUM_RUN_iresponse>
<NUM_RUN_shapefromshading> 4 </NUM_RUN_shapefromshading> <NUM_RUN_shapefromshading> 3 </NUM_RUN_shapefromshading>
<NUM_RUN_strobe> 5 </NUM_RUN_strobe> <NUM_RUN_strobe> 5 </NUM_RUN_strobe>
<NUM_RUN_camnoise> 1 </NUM_RUN_camnoise> <NUM_RUN_camnoise> 5 </NUM_RUN_camnoise>
<NUM_RUN_colorsingle> 5 </NUM_RUN_colorsingle> <NUM_RUN_colorsingle> 5 </NUM_RUN_colorsingle>
<NUM_RUN_colormulti> 5 </NUM_RUN_colormulti> <NUM_RUN_colormulti> 5 </NUM_RUN_colormulti>
<NUM_RUN_diffnoise> 2 </NUM_RUN_diffnoise> <NUM_RUN_diffnoise> 3 </NUM_RUN_diffnoise>
</analysis_NUM_RUN> </analysis_NUM_RUN>
<analysis_time> <analysis_time>
<acquiretime_shadowscapes> 25 </acquiretime_shadowscapes> <acquiretime_shadowscapes> 30 </acquiretime_shadowscapes>
<acquiretime_relaxrate> 22 </acquiretime_relaxrate> <acquiretime_relaxrate> 30 </acquiretime_relaxrate>
<acquiretime_iresponse> 23 </acquiretime_iresponse> <acquiretime_iresponse> 30 </acquiretime_iresponse>
<acquiretime_shapefromshading> 24 </acquiretime_shapefromshading> <acquiretime_shapefromshading> 30 </acquiretime_shapefromshading>
<acquiretime_strobe> 25 </acquiretime_strobe> <acquiretime_strobe> 30 </acquiretime_strobe>
<acquiretime_camnoise> 20 </acquiretime_camnoise> <acquiretime_camnoise> 30 </acquiretime_camnoise>
<acquiretime_colorsingle> 25 </acquiretime_colorsingle> <acquiretime_colorsingle> 40 </acquiretime_colorsingle>
<acquiretime_colormulti> 35 </acquiretime_colormulti> <acquiretime_colormulti> 40 </acquiretime_colormulti>
<acquiretime_diffnoise> 20 </acquiretime_diffnoise> <acquiretime_diffnoise> 30 </acquiretime_diffnoise>
</analysis_time> </analysis_time>
</config> </config>

View File

@ -100,7 +100,6 @@ void RefractiveIndex::setup()
_analysisVector.push_back(new ShadowScapesAnalysis(H)); _analysisVector.push_back(new ShadowScapesAnalysis(H));
_analysisVector.push_back(new ShadowScapesAnalysis(D)); _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());

View File

@ -28,7 +28,7 @@ void AbstractAnalysis::do_synthesize() {
ofNotifyEvent(_synthesize_cb, _name); 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 // 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); 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 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 = new unsigned char [appPix.getWidth()*appPix.getHeight()*3];
somePixels = appPix.getPixels(); 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? ***// //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
myImage.setUseTexture(false); myColorImage1.setUseTexture(false);
myColorImage1.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR);
myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); myColorImage1.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+filename);
myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+filename);
#endif #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);
}

View File

@ -7,6 +7,7 @@
#include "ofMain.h" #include "ofMain.h"
#include "ofEvents.h" #include "ofEvents.h"
#include "ofxOpenCv.h"
#include <string> #include <string>
#define ANALYSIS_PATH "analysis/" #define ANALYSIS_PATH "analysis/"
@ -34,9 +35,10 @@ public:
protected: 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) // acquire images - all the children (see - do_synthesize)
virtual void acquire() = 0; virtual void acquire() = 0;
@ -61,6 +63,9 @@ protected:
int _state; int _state;
ofImage myColorImage;
ofImage myBlackWhiteImage;
//int _run_cnt; //int _run_cnt;
float DELTA_T_SAVE; float DELTA_T_SAVE;

View File

@ -40,7 +40,7 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight)
int anim_time = 10; // 10 seconds int anim_time = 10; // 10 seconds
_anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames
//create_dir(); //create_dir_allocate_images();
_show_image = false; _show_image = false;
_image_shown = false; _image_shown = false;
@ -77,7 +77,7 @@ void CamNoiseAnalysis::acquire()
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0;
_run_cnt++; _run_cnt++;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
// RUN ROUTINE // RUN ROUTINE
// for(int i = 0; i < NUM_RUN; i++) { // 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 ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); //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? ***// //*** 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.setFromPixels(cvGrayImage1.getPixels(), cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE);
image.saveImage(_whole_file_path_synthesis+"/"+file_name); //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++; _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"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -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 _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; _frame_cnt = 0;
_run_cnt = 0; _run_cnt = 0;
@ -76,7 +76,7 @@ void ColorMultiAnalysis::acquire()
_run_cnt++; _run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
// RUN ROUTINE // RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) { //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 ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); //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? ***// //*** 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.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR);
image.saveImage(_whole_file_path_synthesis+"/"+file_name); //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++; _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"; string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -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 _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; _run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
@ -81,7 +81,7 @@ void ColorSingleAnalysis::acquire()
_run_cnt++; _run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
// RUN ROUTINE // RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) { //for(int i = 0; i < NUM_RUN; i++) {
@ -159,16 +159,19 @@ void ColorSingleAnalysis::synthesise()
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); //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? ***// //*** 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.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR);
image.saveImage(_whole_file_path_synthesis+"/"+file_name); //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++; _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"; string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -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 _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; _run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
@ -76,7 +76,7 @@ void DiffNoiseAnalysis::acquire()
_run_cnt++; _run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
// RUN ROUTINE // RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) { //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 ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvColorImage1.width, cvGrayImage1.height, OF_IMAGE_COLOR); //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? ***// //*** 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.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR);
image.saveImage(_whole_file_path_synthesis+"/"+file_name); //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++; _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"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -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 _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; _synth_save_cnt = 0;
_run_cnt = 0; _run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
@ -76,7 +76,7 @@ void IResponseAnalysis::acquire()
_run_cnt++; _run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
// RUN ROUTINE // RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) { //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 ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //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? ***// //*** 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.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
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++; _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"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -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 _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; _run_cnt = 0;
_level = 0; _level = 0;
@ -77,7 +77,7 @@ void RelaxRateAnalysis::acquire()
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
// RUN ROUTINE // RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) { //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 ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //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? ***// //*** 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); //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
image.saveImage(_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++; _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"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -83,7 +83,7 @@ void ShadowScapesAnalysis::acquire()
_line = 0; _line = 0;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
save_timer.start(save_callback); 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 ----> //<---- 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); // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //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? ***// //*** 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); //_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
image.saveImage(_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++; _synth_save_cnt++;
} }
} }
} }
@ -199,41 +201,6 @@ void ShadowScapesAnalysis::displayresults()
} }
} }
// 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"; file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 2)+"_"+ofToString(_run_cnt,2)+".jpg";
} }
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -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 _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; _synth_save_cnt = 0;
_run_cnt = 0; _run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
@ -77,7 +77,7 @@ void ShapeFromShadingAnalysis::acquire()
_run_cnt++; _run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0, _synth_save_cnt = 0;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
_animation_cnt1 = 0; _animation_cnt1 = 0;
_animation_cnt2 = 0; _animation_cnt2 = 0;
@ -162,18 +162,21 @@ void ShapeFromShadingAnalysis::synthesise()
//<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> //<---- 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); // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); //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? ***// //*** 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.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE);
image.saveImage(_whole_file_path_synthesis+"/"+file_name); //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++; _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"; string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }

View File

@ -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. // 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; _synth_save_cnt = 0;
_run_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; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _strobe_cnt = 0, _synth_save_cnt = 0;
_run_cnt++; _run_cnt++;
_RUN_DONE = false; _RUN_DONE = false;
create_dir(); create_dir_allocate_images();
// RUN ROUTINE // RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) { //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 ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
ofImage image; //ofImage image;
//image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); //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? ***// //*** 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.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height,OF_IMAGE_GRAYSCALE);
image.saveImage(_whole_file_path_synthesis+"/"+file_name); //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++; _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"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name); saveImageAnalysis(file_name);
} }