added proper looping structure - fixed up some un-initialised variables

the looping structure for RUN_NUM now occurs in AbstractAnalysis, so
that the sequencing is correct - a few related variables were not reset
- so those are fixed now too.
This commit is contained in:
Jamie Allen 2012-02-22 15:36:22 +01:00
parent 24ddd694c7
commit 2f2b38019e
12 changed files with 319 additions and 235 deletions

View File

@ -6,6 +6,11 @@
// this is the main threaded loop for a given analysis // this is the main threaded loop for a given analysis
void AbstractAnalysis::do_synthesize() { void AbstractAnalysis::do_synthesize() {
for(int i = 0; i < NUM_RUN; i++) {
cout << "i NUM_RUN" << i << endl;
_saved_filenames_analysis.clear(); _saved_filenames_analysis.clear();
_state = STATE_ACQUIRING; _state = STATE_ACQUIRING;
acquire(); acquire();
@ -15,6 +20,8 @@ void AbstractAnalysis::do_synthesize() {
if(_state == STATE_STOP) goto exit; if(_state == STATE_STOP) goto exit;
_state = STATE_DISPLAY_RESULTS; _state = STATE_DISPLAY_RESULTS;
displayresults(); displayresults();
}
exit: exit:
ofNotifyEvent(_synthesize_cb, _name); ofNotifyEvent(_synthesize_cb, _name);
} }

View File

@ -59,6 +59,8 @@ protected:
int _state; int _state;
//int _run_cnt;
float DELTA_T_SAVE; float DELTA_T_SAVE;
int NUM_PHASE; int NUM_PHASE;
int NUM_RUN; int NUM_RUN;

View File

@ -14,7 +14,7 @@ using Poco::Thread;
void CamNoiseAnalysis::setup(int camWidth, int camHeight) void CamNoiseAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 20; // 20 seconds of acquiring per run int acq_run_time = 20; // 20 seconds of acquiring per run
@ -23,16 +23,15 @@ void CamNoiseAnalysis::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();
_frame_cnt = 0; _frame_cnt = 0;
_run_cnt = 0;
c = 0; c = 0;
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();
_show_image = false; _show_image = false;
_image_shown = false; _image_shown = false;
@ -64,29 +63,28 @@ void CamNoiseAnalysis::acquire()
{ {
Timer* save_timer; Timer* save_timer;
TimerCallback<CamNoiseAnalysis> save_callback(*this, &CamNoiseAnalysis::save_cb); TimerCallback<CamNoiseAnalysis> save_callback(*this, &CamNoiseAnalysis::save_cb);
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_run_cnt++;
_RUN_DONE = false;
create_dir();
// RUN ROUTINE // RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) { // for(int i = 0; i < NUM_RUN; i++) {
// _run_cnt = i;
_run_cnt = i;
//cout << "RUN NUM = " << i; //cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback); save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
_RUN_DONE = false;
} // }
} }
void CamNoiseAnalysis::synthesise() void CamNoiseAnalysis::synthesise()

View File

@ -13,7 +13,7 @@ using Poco::Thread;
void ColorMultiAnalysis::setup(int camWidth, int camHeight) void ColorMultiAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 35; int acq_run_time = 35;
@ -22,19 +22,15 @@ 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();
_frame_cnt = 0; _frame_cnt = 0;
_run_cnt = 0;
c = 0; c = 0;
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();
_show_image = false;
_image_shown = false;
//for an ofxOpenCv.h image i would like to use..." //for an ofxOpenCv.h image i would like to use..."
//image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h);
@ -67,29 +63,29 @@ void ColorMultiAnalysis::acquire()
{ {
Timer* save_timer; Timer* save_timer;
TimerCallback<ColorMultiAnalysis> save_callback(*this, &ColorMultiAnalysis::save_cb); TimerCallback<ColorMultiAnalysis> save_callback(*this, &ColorMultiAnalysis::save_cb);
// RUN ROUTINE _run_cnt++;
for(int i = 0; i < NUM_RUN; i++) { _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_RUN_DONE = false;
create_dir();
_run_cnt = i; // RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) {
// _run_cnt = i;
//cout << "RUN NUM = " << i; //cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback); save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
_RUN_DONE = false;
} //}
} }
void ColorMultiAnalysis::synthesise() void ColorMultiAnalysis::synthesise()

View File

@ -14,7 +14,7 @@ using Poco::Thread;
void ColorSingleAnalysis::setup(int camWidth, int camHeight) void ColorSingleAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 25; // 20 seconds of acquiring per run int acq_run_time = 25; // 20 seconds of acquiring per run
@ -23,19 +23,15 @@ 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();
_run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
c = 0; c = 0;
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();
NUM_RUN = 1;
r = 0; r = 0;
g = 0; g = 0;
b = 0; b = 0;
@ -74,25 +70,26 @@ void ColorSingleAnalysis::acquire()
TimerCallback<ColorSingleAnalysis> save_callback(*this, &ColorSingleAnalysis::save_cb); TimerCallback<ColorSingleAnalysis> save_callback(*this, &ColorSingleAnalysis::save_cb);
_run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_RUN_DONE = false;
create_dir();
// RUN ROUTINE // RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) { //for(int i = 0; i < NUM_RUN; i++) {
// _run_cnt = i;
_run_cnt = i;
//cout << "RUN NUM = " << i; //cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback); save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
_RUN_DONE = false;
}
// }
} }
void ColorSingleAnalysis::synthesise() void ColorSingleAnalysis::synthesise()

View File

@ -14,7 +14,7 @@ using Poco::Thread;
void DiffNoiseAnalysis::setup(int camWidth, int camHeight) void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 20; // 20 seconds of acquiring per run int acq_run_time = 20; // 20 seconds of acquiring per run
@ -23,25 +23,21 @@ 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();
_run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
c = 0; c = 0;
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();
_show_image = false; _show_image = false;
_image_shown = false; _image_shown = false;
//for an ofxOpenCv.h image i would like to use..." //for an ofxOpenCv.h image i would like to use..."
//image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h);
_show_image = false;
_image_shown = false;
// images use for drawing the synthesized files to the screen /// // images use for drawing the synthesized files to the screen ///
image1.setUseTexture(false); // the non texture image that is needed to first load the image image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1 image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
@ -68,29 +64,30 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
void DiffNoiseAnalysis::acquire() void DiffNoiseAnalysis::acquire()
{ {
Timer* save_timer; Timer* save_timer;
TimerCallback<DiffNoiseAnalysis> save_callback(*this, &DiffNoiseAnalysis::save_cb); TimerCallback<DiffNoiseAnalysis> save_callback(*this, &DiffNoiseAnalysis::save_cb);
_run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_RUN_DONE = false;
create_dir();
// RUN ROUTINE // RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) { //for(int i = 0; i < NUM_RUN; i++) {
_run_cnt = i;
// _run_cnt = i;
//cout << "RUN NUM = " << i; //cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; save_timer->start(save_callback);
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
}
//}
} }
void DiffNoiseAnalysis::synthesise() void DiffNoiseAnalysis::synthesise()

View File

@ -13,7 +13,7 @@ using Poco::Thread;
void IResponseAnalysis::setup(int camWidth, int camHeight) void IResponseAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 20; // 20 seconds of acquiring per run int acq_run_time = 20; // 20 seconds of acquiring per run
@ -22,8 +22,9 @@ 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();
_run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
c = 0; c = 0;
@ -61,29 +62,28 @@ void IResponseAnalysis::acquire()
{ {
Timer* save_timer; Timer* save_timer;
TimerCallback<IResponseAnalysis> save_callback(*this, &IResponseAnalysis::save_cb); TimerCallback<IResponseAnalysis> save_callback(*this, &IResponseAnalysis::save_cb);
_run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_RUN_DONE = false;
create_dir();
// RUN ROUTINE // RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) { //for(int i = 0; i < NUM_RUN; i++) {
//_run_cnt = i;
_run_cnt = i;
//cout << "RUN NUM = " << i; //cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback);
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; save_timer->start(save_callback);
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
_RUN_DONE = false; //}
}
} }
void IResponseAnalysis::synthesise() void IResponseAnalysis::synthesise()
@ -309,7 +309,6 @@ void IResponseAnalysis::draw()
{ {
//cout << "STATE_DISPLAY_RESULTS...\n" << endl; //cout << "STATE_DISPLAY_RESULTS...\n" << endl;
if (_frame_cnt > 2) if (_frame_cnt > 2)
{ {
_image_shown = true; _image_shown = true;

View File

@ -13,7 +13,7 @@ using Poco::Thread;
void RelaxRateAnalysis::setup(int camWidth, int camHeight) void RelaxRateAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 20; // 20 seconds of acquiring per run int acq_run_time = 20; // 20 seconds of acquiring per run
@ -22,8 +22,9 @@ 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();
_run_cnt = 0;
_level = 0; _level = 0;
_flip = 1; _flip = 1;
_frame_cnt = 0; _frame_cnt = 0;
@ -35,45 +36,108 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
_show_image = false; _show_image = false;
_image_shown = false; _image_shown = false;
//for an ofxOpenCv.h image i would like to use..." // images use for drawing the synthesized files to the screen ///
//image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
// images used for re-loading and saving out the synthesized files ///
image3.setUseTexture(false);
image4.setUseTexture(false);
image5.setUseTexture(false);
//cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
//cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
image1.setUseTexture(false);
image2.setUseTexture(true);
} }
void RelaxRateAnalysis::acquire() void RelaxRateAnalysis::acquire()
{ {
Timer* save_timer; Timer* save_timer;
TimerCallback<RelaxRateAnalysis> save_callback(*this, &RelaxRateAnalysis::save_cb); TimerCallback<RelaxRateAnalysis> save_callback(*this, &RelaxRateAnalysis::save_cb);
_run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_RUN_DONE = false;
create_dir();
// RUN ROUTINE // RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) { //for(int i = 0; i < NUM_RUN; i++) {
//_run_cnt = i;
_run_cnt = i;
//cout << "RUN NUM = " << i; //cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback); save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
_RUN_DONE = false;
}
} }
void RelaxRateAnalysis::synthesise() void RelaxRateAnalysis::synthesise()
{ {
//cout << "IResponseAnalysis::saving synthesis...\n";
if(_state == STATE_STOP) return;
// _saved_filenames_analysis has all the file names of all the saved images for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
//cout << "IResponseAnalysis::synthesis FOR LOOP...\n";
//cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
if(_state == STATE_STOP) return;
if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
cout << "didn't load image" << endl;
}
if(image1.loadImage(_saved_filenames_analysis[i])){
//cout << "LOADED image1!!!" << endl;
if(image5.loadImage(_saved_filenames_analysis[i+1])){
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvGrayImage1 = cvColorImage1;
cvGrayImage2 = cvColorImage2;
//cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
cvGrayDiff1.erode();
cvGrayDiff1.contrastStretch();
cvGrayDiff1.blur(5);
//cvGrayDiff1.dilate();
//cvGrayDiff1.contrastStretch();
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
string file_name;
file_name = ofToString(_synth_save_cnt, 2)+"_RelaxRateAnalysis_"+ofToString(_run_cnt,2)+".jpg";
//image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR);
ofSaveImage(cvGrayDiff1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
_synth_save_cnt++;
}
}
}
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
@ -82,31 +146,31 @@ void RelaxRateAnalysis::synthesise()
void RelaxRateAnalysis::displayresults() void RelaxRateAnalysis::displayresults()
{ {
for(float i=1;i<_saved_filenames_analysis.size();i++){ for(float i=1;i<_saved_filenames_synthesis.size();i++){
if(_state == STATE_STOP) return; if(_state == STATE_STOP) return;
// cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl; //cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
while(!_image_shown){ while(!_image_shown){
Thread::sleep(2); Thread::sleep(2);
//cout << "!_image_shown" << endl; //cout << "!_image_shown" << endl;
} }
if(!image3.loadImage(_saved_filenames_synthesis[i])){
if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image //couldn't load image
cout << "didn't load image" << endl; // cout << "didn't load image" << endl;
} }
if(image3.loadImage(_saved_filenames_synthesis[i])){
if(image1.loadImage(_saved_filenames_analysis[i])){ image3.loadImage(_saved_filenames_synthesis[i]);
image1.loadImage(_saved_filenames_analysis[i]);
//cout << "_show_image = true;" << endl; //cout << "_show_image = true;" << endl;
_show_image = true; _show_image = true;
_image_shown = false; _image_shown = false;
} }
} }
} }
@ -250,11 +314,12 @@ void RelaxRateAnalysis::draw()
if (_show_image) if (_show_image)
{ {
//cout << "_show_image...\n" << endl;
ofEnableAlphaBlending(); ofEnableAlphaBlending();
ofSetColor(255, 255, 255, 255); ofSetColor(255, 255, 255);
image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_GRAYSCALE);
image2.setFromPixels(image1.getPixels(),image1.width,image1.height, OF_IMAGE_COLOR);
image2.draw(0,0, ofGetWidth(), ofGetHeight()); image2.draw(0,0, ofGetWidth(), ofGetHeight());
ofDisableAlphaBlending(); ofDisableAlphaBlending();
@ -263,6 +328,7 @@ void RelaxRateAnalysis::draw()
// display results of the synthesis // display results of the synthesis
_RUN_DONE = true; _RUN_DONE = true;
break; break;
} }
default: default:

View File

@ -28,11 +28,32 @@ protected:
bool _RUN_DONE; bool _RUN_DONE;
float _flip, _level; float _flip, _level;
int _run_cnt, _save_cnt, _anim_cnt; int _run_cnt, _save_cnt, _synth_save_cnt, _anim_cnt;
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
bool _show_image, _image_shown; bool _show_image, _image_shown;
ofImage image1; ofImage image1;
ofImage image2; ofImage image2;
ofImage image3;
ofImage image4;
ofImage image5;
ofImage image6;
ofxCvColorImage cvColorImage1;
ofxCvColorImage cvColorImage2;
ofxCvColorImage cvColorImage3;
ofxCvColorImage cvColorImage4;
ofxCvColorImage cvColorImage5;
ofxCvColorImage cvColorImage6;
ofxCvGrayscaleImage cvGrayDiff1;
ofxCvGrayscaleImage cvGrayDiff2;
ofxCvGrayscaleImage cvGrayImage1;
ofxCvGrayscaleImage cvGrayImage2;
ofxCvGrayscaleImage cvGrayImage3;
ofxCvGrayscaleImage cvGrayImage4;
ofxCvContourFinder cvContourFinder1;
}; };

View File

@ -16,7 +16,7 @@ using Poco::Thread;
void ShadowScapesAnalysis::setup(int camWidth, int camHeight) void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 15; // 10 seconds of acquiring per run int acq_run_time = 15; // 10 seconds of acquiring per run
@ -33,7 +33,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
DELTA_T_SAVE = 3*(10*acq_run_time/2); // for 20 seconds, we want this to be around 100 files DELTA_T_SAVE = 3*(10*acq_run_time/2); // for 20 seconds, we want this to be around 100 files
// or 5 times per second = every 200 ms // or 5 times per second = every 200 ms
create_dir(); // this makes both synth and analysis folder structures //create_dir(); // this makes both synth and analysis folder structures
_scanLineWidth = 100.0; _scanLineWidth = 100.0;
_run_cnt = 0; _run_cnt = 0;
@ -65,21 +65,22 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h); cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
} }
void ShadowScapesAnalysis::acquire() void ShadowScapesAnalysis::acquire()
{ {
_line = 0;
// RUN ROUTINE
for(int i = 0; i < NUM_RUN; i++) {
Timer save_timer(0, DELTA_T_SAVE); Timer save_timer(0, DELTA_T_SAVE);
TimerCallback<ShadowScapesAnalysis> save_callback(*this, &ShadowScapesAnalysis::save_cb); TimerCallback<ShadowScapesAnalysis> save_callback(*this, &ShadowScapesAnalysis::save_cb);
_RUN_DONE = false; _run_cnt++;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_line = 0;
_RUN_DONE = false;
create_dir();
//cout << "RUN NUM = " << i;
save_timer.start(save_callback); save_timer.start(save_callback);
@ -88,8 +89,7 @@ void ShadowScapesAnalysis::acquire()
save_timer.stop(); save_timer.stop();
_RUN_DONE = false; //}
}
} }

View File

@ -12,7 +12,7 @@ using Poco::Thread;
void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 20; // 20 seconds of acquiring per run int acq_run_time = 20; // 20 seconds of acquiring per run
@ -21,8 +21,8 @@ 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();
_run_cnt = 0;
_frame_cnt = 0; _frame_cnt = 0;
c = 0; c = 0;
@ -61,20 +61,12 @@ void ShapeFromShadingAnalysis::acquire()
{ {
Timer* save_timer; Timer* save_timer;
TimerCallback<ShapeFromShadingAnalysis> save_callback(*this, &ShapeFromShadingAnalysis::save_cb); TimerCallback<ShapeFromShadingAnalysis> save_callback(*this, &ShapeFromShadingAnalysis::save_cb);
// RUN ROUTINE _run_cnt++;
for(int i = 0; i < NUM_RUN; i++) {
_run_cnt = i;
//cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
_RUN_DONE = false;
create_dir();
_animation_cnt1 = 0; _animation_cnt1 = 0;
_animation_cnt2 = 0; _animation_cnt2 = 0;
@ -94,14 +86,23 @@ void ShapeFromShadingAnalysis::acquire()
_animation_cnt16 = 0; _animation_cnt16 = 0;
_animation_reset = false; // coundn't get this to work - so using seperate counters - shitty! _animation_reset = false; // coundn't get this to work - so using seperate counters - shitty!
// RUN ROUTINE
//for(int i = 0; i < NUM_RUN; i++) {
// _run_cnt = i;
//cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback);
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
_RUN_DONE = false; // }
}
} }
void ShapeFromShadingAnalysis::synthesise() void ShapeFromShadingAnalysis::synthesise()

View File

@ -12,7 +12,7 @@ using Poco::Thread;
void StrobeAnalysis::setup(int camWidth, int camHeight) void StrobeAnalysis::setup(int camWidth, int camHeight)
{ {
NUM_RUN = 1; NUM_RUN = 5;
int acq_run_time = 25; // 20 seconds of acquiring per run int acq_run_time = 25; // 20 seconds of acquiring per run
@ -25,12 +25,13 @@ 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();
_run_cnt = 0;
int anim_time = 5; // 5 seconds for the animation int anim_time = 5; // 5 seconds for the animation
_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
_show_image = false; _show_image = false;
_image_shown = false; _image_shown = false;
@ -61,31 +62,30 @@ void StrobeAnalysis::acquire()
{ {
Timer* save_timer; Timer* save_timer;
TimerCallback<StrobeAnalysis> save_callback(*this, &StrobeAnalysis::save_cb); TimerCallback<StrobeAnalysis> save_callback(*this, &StrobeAnalysis::save_cb);
// RUN ROUTINE _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _strobe_cnt = 0;
for(int i = 0; i < NUM_RUN; i++) { _run_cnt++;
_RUN_DONE = false;
create_dir();
_run_cnt = i; // RUN ROUTINE
_save_cnt = 0; //for(int i = 0; i < NUM_RUN; i++) {
_frame_cnt = 0;
//_run_cnt = i;
//cout << "RUN NUM = " << i; //cout << "RUN NUM = " << i;
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
save_timer->start(save_callback); save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _strobe_cnt = 0;
while(!_RUN_DONE && _state != STATE_STOP) while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3); Thread::sleep(3);
save_timer->stop(); save_timer->stop();
_RUN_DONE = false;
} //}
} }
void StrobeAnalysis::synthesise() void StrobeAnalysis::synthesise()