2012-02-22 02:09:19 +01:00
|
|
|
/* */
|
2012-01-24 15:13:07 +01:00
|
|
|
|
|
|
|
|
#include "AbstractAnalysis.h"
|
2012-02-11 18:54:46 +01:00
|
|
|
#include "RefractiveIndex.h"
|
2012-02-18 20:37:22 +01:00
|
|
|
#include "ofxFileHelper.h"
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-02-15 08:43:43 +01:00
|
|
|
// this is the main threaded loop for a given analysis
|
2012-02-11 18:54:46 +01:00
|
|
|
void AbstractAnalysis::do_synthesize() {
|
2012-02-22 15:36:22 +01:00
|
|
|
|
|
|
|
|
for(int i = 0; i < NUM_RUN; i++) {
|
|
|
|
|
|
|
|
|
|
cout << "i NUM_RUN" << i << endl;
|
|
|
|
|
|
|
|
|
|
_saved_filenames_analysis.clear();
|
|
|
|
|
_state = STATE_ACQUIRING;
|
|
|
|
|
acquire();
|
|
|
|
|
if(_state == STATE_STOP) goto exit;
|
|
|
|
|
_state = STATE_SYNTHESISING;
|
|
|
|
|
synthesise();
|
|
|
|
|
if(_state == STATE_STOP) goto exit;
|
|
|
|
|
_state = STATE_DISPLAY_RESULTS;
|
|
|
|
|
displayresults();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 02:09:19 +01:00
|
|
|
exit:
|
2012-02-11 18:54:46 +01:00
|
|
|
ofNotifyEvent(_synthesize_cb, _name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractAnalysis::create_dir()
|
|
|
|
|
{
|
|
|
|
|
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
|
|
|
|
|
|
|
|
|
|
//FOR WINDOWS i HAVE HAD TO REPLACE SPACES WITH UNDERSCORES AND REDUCE THE LENGTH OF THE FOLDER NAME
|
|
|
|
|
time_t rawtime;
|
|
|
|
|
struct tm * timeinfo;
|
|
|
|
|
|
|
|
|
|
time ( &rawtime );
|
|
|
|
|
timeinfo = localtime ( &rawtime );
|
|
|
|
|
string time = asctime(timeinfo);
|
|
|
|
|
string replaceTime = "";
|
|
|
|
|
|
|
|
|
|
//DON'T INCLUDE THE DAY IN WORDS EG 'TUE' OR THE YEAR EG 2012 THIS MAKES THE DIRECTORY NAME TOO LONG AND CAUSES DIR CREATION TO FAIL
|
|
|
|
|
for(int i=4;i<time.size()-4;i++){
|
|
|
|
|
if(time.at(i)==' '||time.at(i)==':'){
|
|
|
|
|
replaceTime+="_";
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
replaceTime+=time.at(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-18 20:37:22 +01:00
|
|
|
|
2012-02-22 02:09:19 +01:00
|
|
|
ofxFileHelper fileHelperAnalysis;
|
|
|
|
|
ofxFileHelper fileHelperSynthesis;
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-02-22 02:09:19 +01:00
|
|
|
_whole_file_path_analysis = ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ;
|
|
|
|
|
|
|
|
|
|
//cout << "_whole_file_path_analysis = " << _whole_file_path_analysis << endl;
|
|
|
|
|
|
|
|
|
|
if(!fileHelperAnalysis.doesDirectoryExist(_whole_file_path_analysis)){
|
|
|
|
|
fileHelperAnalysis.makeDirectory(ANALYSIS_PATH);
|
|
|
|
|
fileHelperAnalysis.makeDirectory(ANALYSIS_PATH+RefractiveIndex::_location);
|
|
|
|
|
fileHelperAnalysis.makeDirectory(ANALYSIS_PATH+RefractiveIndex::_location+"/"+_name);
|
|
|
|
|
fileHelperAnalysis.makeDirectory(ANALYSIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_whole_file_path_synthesis = SYNTHESIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime;
|
|
|
|
|
|
|
|
|
|
if(!fileHelperSynthesis.doesDirectoryExist(_whole_file_path_synthesis)){
|
|
|
|
|
fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH);
|
|
|
|
|
fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location);
|
|
|
|
|
fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name);
|
|
|
|
|
fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime);
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
|
|
|
|
|
}
|
|
|
|
|
|