merge Tom files

This commit is contained in:
dviid
2012-01-24 16:52:22 +01:00
parent 7123b1b386
commit b3e8415fcd
13 changed files with 631 additions and 528 deletions
+60 -52
View File
@@ -1,6 +1,6 @@
/*
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "CamFrameRateAnalysis.h"
@@ -17,31 +17,39 @@ using Poco::Thread;
void CamFrameRateAnalysis::setup(int camWidth, int camHeight)
{
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
{
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@@ -50,84 +58,84 @@ void CamFrameRateAnalysis::setup(int camWidth, int camHeight)
void CamFrameRateAnalysis::synthesize()
{
Timer* save_timer;
TimerCallback<CamFrameRateAnalysis> save_callback(*this, &CamFrameRateAnalysis::save_cb);
// RUN ROUTINE
// 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);
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
while(!_RUN_DONE)
Thread::sleep(3);
save_timer->stop();
save_timer->stop();
}
}
void CamFrameRateAnalysis::gui_attach(ofxControlPanel* gui)
{
}
void CamFrameRateAnalysis::gui_detach()
{
}
//void CamFrameRateAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
//void CamFrameRateAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
// this runs at frame rate = 33 ms for 30 FPS
void CamFrameRateAnalysis::draw()
{
/// *** TODO *** ///
// still need to deal with latency frames here - i.e.: there are frames
// still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** ///
float totalTime=_frame_cnt_max/2;
float numSteps=10;
vector<float>stepLengths;
//c must increase until frame_cnt_max * 0.5 and then decrease afterwards
if (_frame_cnt < _frame_cnt_max)
{
ofSetColor(c, c, c);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max);
cout<<_frame_cnt<<endl;
}
_frame_cnt++;
}
// this runs at save_cb timer rate = DELTA_T_SAVE
void CamFrameRateAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
//cout << "c_last... " << c << endl;
//cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
}
+59 -54
View File
@@ -1,6 +1,6 @@
/*
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "CamNoiseAnalysis.h"
@@ -17,35 +17,40 @@ using Poco::Thread;
void CamNoiseAnalysis::setup(int camWidth, int camHeight)
{
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
{
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
else{
cout<<"dir exists"<<endl;
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@@ -54,85 +59,85 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight)
void CamNoiseAnalysis::synthesize()
{
Timer* save_timer;
TimerCallback<CamNoiseAnalysis> save_callback(*this, &CamNoiseAnalysis::save_cb);
// RUN ROUTINE
// 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);
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
while(!_RUN_DONE)
Thread::sleep(3);
save_timer->stop();
save_timer->stop();
}
}
void CamNoiseAnalysis::gui_attach(ofxControlPanel* gui)
{
}
void CamNoiseAnalysis::gui_detach()
{
}
//void CamNoiseAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
//void CamNoiseAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
// this runs at frame rate = 33 ms for 30 FPS
void CamNoiseAnalysis::draw()
{
/// *** TODO *** ///
// still need to deal with latency frames here - i.e.: there are frames
// still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** ///
float _number_of_grey_levels=5;
float _frames_per_level = _frame_cnt_max / _number_of_grey_levels;
ofColor someColor;
for(int i=0;i<=_number_of_grey_levels;i++){
if (_frame_cnt>= _frames_per_level *( i-1) && +_frame_cnt < _frames_per_level * (i) ) {
//set colour to current grey level
c=255-( 255.0 * ( i /_number_of_grey_levels));
someColor.set(c);
}
ofSetColor(someColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
_frame_cnt++;
}
// this runs at save_cb timer rate = DELTA_T_SAVE
void CamNoiseAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
}
+54 -45
View File
@@ -1,7 +1,7 @@
/*
- copyright (c) 2011 Copenhagen Institute of Interaction Design (CIID)
- all rights reserved.
+ redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
@@ -11,7 +11,7 @@
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -24,10 +24,10 @@
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "ColorMultiAnalysis.h"
@@ -45,58 +45,67 @@ using Poco::Thread;
void ColorMultiAnalysis::setup(int camWidth, int camHeight)
{
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
}
void ColorMultiAnalysis::synthesize()
{
Timer* save_timer;
TimerCallback<ColorMultiAnalysis> save_callback(*this, &ColorMultiAnalysis::save_cb);
// RUN ROUTINE
// 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);
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
while(!_RUN_DONE)
Thread::sleep(3);
save_timer->stop();
save_timer->stop();
}
}
@@ -104,30 +113,30 @@ void ColorMultiAnalysis::synthesize()
void ColorMultiAnalysis::gui_attach(ofxControlPanel* gui)
{
gui->addToggle("GO", "GO", 0);
gui->addButtonSlider("animation time limit", "ANIMATION_TIME_LIMIT", 10, 1, 3000, TRUE);
gui->addButtonSlider("animation time limit", "ANIMATION_TIME_LIMIT", 10, 1, 3000, TRUE);
}
void ColorMultiAnalysis::gui_detach()
{
}
void ColorMultiAnalysis::draw()
{
if (_frame_cnt < _frame_cnt_max)
{
ofColor aColor;
aColor.setHsb(c, 255, 255);
ofSetColor(aColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
//how far are we as a percent of _frame_count_max
c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max);
}
_frame_cnt++;
}
@@ -136,19 +145,19 @@ void ColorMultiAnalysis::draw()
void ColorMultiAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
// UPDATE THE COLOR ON THE SCREEN
//float c_last = c;
//float c_last = c;
cout << "COLORMULTIANALYSIS::saving...\n";
cout << "c_last... " << c << endl;
cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
cout<<_whole_file_path<<endl;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
if(_save_cnt >= NUM_SAVE_PER_RUN){
_RUN_DONE = true;
}
}
+53 -45
View File
@@ -1,6 +1,6 @@
/*
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "ColorSingleAnalysis.h"
@@ -17,31 +17,39 @@ using Poco::Thread;
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
{
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
{
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
r = 0;
@@ -52,38 +60,38 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
void ColorSingleAnalysis::synthesize()
{
Timer* save_timer;
TimerCallback<ColorSingleAnalysis> save_callback(*this, &ColorSingleAnalysis::save_cb);
// RUN ROUTINE
// 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);
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
while(!_RUN_DONE)
Thread::sleep(3);
save_timer->stop();
save_timer->stop();
}
}
void ColorSingleAnalysis::gui_attach(ofxControlPanel* gui)
{
}
void ColorSingleAnalysis::gui_detach()
{
}
@@ -96,26 +104,26 @@ void ColorSingleAnalysis::draw()
g=0.0;
b=0.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
if (_frame_cnt >= one_third_of_frame_count_max && _frame_cnt < 2*one_third_of_frame_count_max){
r=0.0;
g=255.0;
b=0.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
if (_frame_cnt >= 2*one_third_of_frame_count_max && _frame_cnt < _frame_cnt_max){
r=0.0;
g=0.0;
b=255.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
_frame_cnt++;
}
// this runs at save_cb timer rate = DELTA_T_SAVE
@@ -123,15 +131,15 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
cout << "ColorSingleAnalysis::saving...\n";
string file_name =ofToString(_frame_cnt,2)+"_"+ofToString((int)r,2)+"_"+ofToString((int)g,2)+"_"+ofToString((int)b,2)+"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
cout<<_whole_file_path+"/"+file_name<<endl;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
}
+62 -53
View File
@@ -1,6 +1,6 @@
/*
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "DiffNoiseAnalysis.h"
@@ -17,30 +17,39 @@ using Poco::Thread;
void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
{
{
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@@ -49,89 +58,89 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
void DiffNoiseAnalysis::synthesize()
{
Timer* save_timer;
TimerCallback<DiffNoiseAnalysis> save_callback(*this, &DiffNoiseAnalysis::save_cb);
// RUN ROUTINE
// 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);
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
while(!_RUN_DONE)
Thread::sleep(3);
save_timer->stop();
save_timer->stop();
}
}
void DiffNoiseAnalysis::gui_attach(ofxControlPanel* gui)
{
}
void DiffNoiseAnalysis::gui_detach()
{
}
//void DiffNoiseAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
//void DiffNoiseAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
// this runs at frame rate = 33 ms for 30 FPS
void DiffNoiseAnalysis::draw()
{
/// *** TODO *** ///
// still need to deal with latency frames here - i.e.: there are frames
// still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** ///
ofColor aColour;
c = ofRandom(0,255);
aColour.setHsb(c, 255, 255);
aColour.setHsb(c, 255, 255);
if (_frame_cnt < _frame_cnt_max)
{
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
_frame_cnt++;
}
// this runs at save_cb timer rate = DELTA_T_SAVE
void DiffNoiseAnalysis::save_cb(Timer& timer)
{
float rand10 = ofRandom(0,10);
if (rand10 > 5.0) {
cout << "DiffNoiseAnalysis::saving...\n";
cout << "c_last... " << c << endl;
cout << "c_last... " << c << endl;
cout<<"rand10... " <<rand10<<endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
//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);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
}
_save_cnt++;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
}
+58 -50
View File
@@ -1,6 +1,6 @@
/*
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "IResponseAnalysis.h"
@@ -17,31 +17,39 @@ using Poco::Thread;
void IResponseAnalysis::setup(int camWidth, int camHeight)
{
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
{
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@@ -50,81 +58,81 @@ void IResponseAnalysis::setup(int camWidth, int camHeight)
void IResponseAnalysis::synthesize()
{
Timer* save_timer;
TimerCallback<IResponseAnalysis> save_callback(*this, &IResponseAnalysis::save_cb);
// RUN ROUTINE
// 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);
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
while(!_RUN_DONE)
Thread::sleep(3);
save_timer->stop();
save_timer->stop();
}
}
void IResponseAnalysis::gui_attach(ofxControlPanel* gui)
{
}
void IResponseAnalysis::gui_detach()
{
}
//void IResponseAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
//void IResponseAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
// this runs at frame rate = 33 ms for 30 FPS
void IResponseAnalysis::draw()
{
/// *** TODO *** ///
// still need to deal with latency frames here - i.e.: there are frames
// still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** ///
if (_frame_cnt < _frame_cnt_max)
{
ofSetColor(c, c, c);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max);
}
_frame_cnt++;
}
// this runs at save_cb timer rate = DELTA_T_SAVE
void IResponseAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
// UPDATE THE COLOR ON THE SCREEN
//float c_last = c;
//float c_last = c;
cout << "IResponseAnalysis::saving...\n";
cout << "c_last... " << c << endl;
cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
//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);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
}
+60 -52
View File
@@ -1,6 +1,6 @@
/*
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "LatencyTestAnalysis.h"
@@ -17,31 +17,39 @@ using Poco::Thread;
void LatencyTestAnalysis::setup(int camWidth, int camHeight)
{
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
{
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@@ -50,57 +58,57 @@ void LatencyTestAnalysis::setup(int camWidth, int camHeight)
void LatencyTestAnalysis::synthesize()
{
Timer* save_timer;
TimerCallback<LatencyTestAnalysis> save_callback(*this, &LatencyTestAnalysis::save_cb);
// RUN ROUTINE
// 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);
save_timer->start(save_callback);
_RUN_DONE = false;
_frame_cnt = 0; _save_cnt = 0;
while(!_RUN_DONE)
Thread::sleep(3);
save_timer->stop();
save_timer->stop();
}
}
void LatencyTestAnalysis::gui_attach(ofxControlPanel* gui)
{
}
void LatencyTestAnalysis::gui_detach()
{
}
//void LatencyTestAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
//void LatencyTestAnalysis::draw(ofPixels _pixels) //trying to figure out how to get pixels from the RefractiveIndex.cpp
// this runs at frame rate = 33 ms for 30 FPS
void LatencyTestAnalysis::draw()
{
/// *** TODO *** ///
// still need to deal with latency frames here - i.e.: there are frames
// still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** ///
if (_frame_cnt < _frame_cnt_max/3)
{
c = 0;
ofSetColor(c, c, c);
cout<<"1st third"<<endl;
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
if (_frame_cnt >= _frame_cnt_max/3 && _frame_cnt < 2*( _frame_cnt_max/3))
{
@@ -108,7 +116,7 @@ void LatencyTestAnalysis::draw()
cout<<"2nd third"<<endl;
ofSetColor(c, c, c);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
if (_frame_cnt >= 2*( _frame_cnt_max/3) && _frame_cnt < _frame_cnt_max)
{
@@ -116,33 +124,33 @@ void LatencyTestAnalysis::draw()
cout<<"3rd third"<<endl;
ofSetColor(c, c, c);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
_frame_cnt++;
}
// this runs at save_cb timer rate = DELTA_T_SAVE
void LatencyTestAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
// UPDATE THE COLOR ON THE SCREEN
//float c_last = c;
//float c_last = c;
cout << "LatencyTestAnalysis::saving...\n";
cout << "c_last... " << c << endl;
cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
//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);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
}
+58 -47
View File
@@ -1,7 +1,7 @@
/*
- copyright (c) 2011 Copenhagen Institute of Interaction Design (CIID)
- all rights reserved.
+ redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
@@ -11,7 +11,7 @@
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -24,10 +24,10 @@
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "ShadowScapesAnalysis.h"
@@ -46,27 +46,38 @@ using Poco::Thread;
void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
{
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
_speed = 300;
}
@@ -78,77 +89,77 @@ void ShadowScapesAnalysis::synthesize()
_step = ((w / _speed) * 1000) / 50;
_line = 0;
Timer scan_timer(0, 50);
TimerCallback<ShadowScapesAnalysis> strobe_callback(*this, &ShadowScapesAnalysis::scan_cb);
_state = STATE_SCAN;
scan_timer.start(strobe_callback);
while(_state != STATE_ANALYSIS)
Thread::sleep(5);
scan_timer.stop();
// do analysis here
// go back to the files i've saved and do the math here -
// go back to the files i've saved and do the math here -
while(_state != STATE_STOP)
Thread::sleep(100);
}
void ShadowScapesAnalysis::gui_attach(ofxControlPanel* gui)
{
gui->addToggle("GO", "GO", 0);
gui->addButtonSlider("animation time limit", "ANIMATION_TIME_LIMIT", 10, 1, 3000, TRUE);
gui->addButtonSlider("animation time limit", "ANIMATION_TIME_LIMIT", 10, 1, 3000, TRUE);
}
void ShadowScapesAnalysis::gui_detach()
{
}
// the animation draw - and the output draw
// the animation draw - and the output draw
void ShadowScapesAnalysis::draw()
{
static int _pos;
if(_state == STATE_ANALYSIS) {
ofSetColor(0, 200, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(0, 200, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
return;
}
if(_state == STATE_SCAN) {
if(_pos != _line) {
//take snap??
_pos = _line;
}
ofSetColor(255, 255, 255);
ofSetColor(255, 255, 255);
if(_dir == H) ofRect(_pos, 0, 50, ofGetHeight());
else if(_dir == V) ofRect(0, _pos, ofGetWidth(), 50);
}
}
void ShadowScapesAnalysis::scan_cb(Timer& timer)
{
cout << "ShadowScapesAnalysis::scan_cb\n";
_line += _step;
if((_dir == H && _line >= ofGetWidth()) ||
(_dir == V && _line >= ofGetHeight())) {
if((_dir == H && _line >= ofGetWidth()) ||
(_dir == V && _line >= ofGetHeight())) {
_state = STATE_ANALYSIS;
}
}
+50 -44
View File
@@ -1,7 +1,7 @@
/*
- copyright (c) 2011 Copenhagen Institute of Interaction Design (CIID)
- all rights reserved.
+ redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
@@ -11,7 +11,7 @@
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -24,10 +24,10 @@
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ author: dviid
~ contact: dviid@labs.ciid.dk
~ contact: dviid@labs.ciid.dk
*/
#include "StrobeAnalysis.h"
@@ -45,53 +45,59 @@ using Poco::Thread;
void StrobeAnalysis::setup(int camWidth, int camHeight)
{
//AbstractAnalysis::setup(camWidth, camHeight);
//_lastTime = ofGetElapsedTimeMillis();
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
// 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);
cout<<"time"<<time<<endl;
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+time;
//directories have to be created one level at a time hence repeated calls
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);
}
}
ofDirectory dir;
_whole_file_path= string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime ;
//directories have to be created one level at a time hence repeated calls
if(!dir.doesDirectoryExist(_whole_file_path)){
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(_whole_file_path, true,false);
}
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/", true,false);
dir.createDirectory(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
}
void StrobeAnalysis::synthesize()
{
Timer strobe_timer(0, 70);
TimerCallback<StrobeAnalysis> strobe_callback(*this, &StrobeAnalysis::strobe_cb);
_state = STATE_STROBE;
_darkness = true;
_strobe_cnt = 0;
_strobe_cnt = 0;
strobe_timer.start(strobe_callback);
while(_state != STATE_ANALYSIS)
Thread::sleep(5);
strobe_timer.stop();
// do analysis here
while(_state != STATE_STOP)
Thread::sleep(100);
}
@@ -99,29 +105,29 @@ void StrobeAnalysis::synthesize()
void StrobeAnalysis::gui_attach(ofxControlPanel* gui)
{
gui->addToggle("GO", "GO", 0);
gui->addButtonSlider("animation time limit", "ANIMATION_TIME_LIMIT", 10, 1, 3000, TRUE);
gui->addButtonSlider("animation time limit", "ANIMATION_TIME_LIMIT", 10, 1, 3000, TRUE);
}
void StrobeAnalysis::gui_detach()
{
}
void StrobeAnalysis::draw()
{
if(_state == STATE_ANALYSIS) {
ofSetColor(0, 200, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(0, 200, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
return;
}
if(_darkness) {
ofSetColor(0, 0, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(0, 0, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
} else {
ofSetColor(255, 255, 255);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
}
@@ -131,10 +137,10 @@ void StrobeAnalysis::strobe_cb(Timer& timer)
{
cout << "IResponseAnalysis::saving...\n";
_strobe_cnt++;
_darkness = !_darkness;
if(_strobe_cnt >= 20) {
if(_strobe_cnt >= 20) {
_state = STATE_ANALYSIS;
}