Chained analysis

This commit is contained in:
dviid 2012-02-11 18:54:46 +01:00
parent aba336b04d
commit b5a713dcf9
24 changed files with 286 additions and 626 deletions

View File

@ -1,4 +1,8 @@
/*
todo:
(1) Look at warinings about the #define which get over written
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ author: dviid
~ contact: dviid@labs.ciid.dk
@ -16,10 +20,22 @@
#include "LatencyTestAnalysis.h"
#include "DiffNoiseAnalysis.h"
#include "ofxXmlSettings.h"
#define CAMERA_ID 1
#define CAMERA_ACQU_WIDTH 640
#define CAMERA_ACQU_HEIGHT 480
#define LOCATION "MIDDLESBOROUGH"
#define ISTATE_UNDEF 0xEEEE
#define ISTATE_START 0xAAAA
#define ISTATE_STOP 0xBBBB
#define ISTATE_TRANSITION 0xCCCC
#define ISTATE_END 0xDDDD
int _state = ISTATE_UNDEF;
ofPixels RefractiveIndex::_pixels;
ofVideoGrabber RefractiveIndex::_vidGrabber;
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
@ -27,60 +43,136 @@ bool RefractiveIndex::_vid_stream_open;
bool RefractiveIndex::_vid_toggle_on;
string RefractiveIndex::_location;
ofxXmlSettings XML;
void RefractiveIndex::setup()
{
// rate
ofSetFrameRate(30);
bool save_config = false;
cout << "Loading configuration..." << endl;
if(!XML.loadFile("../data/config.refindx")) {
ofLog(OF_LOG_ERROR) << "error loading config - using default.";
save_config = true;
}
// <camera>
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
_vid_w = XML.getValue("config:camera:width", CAMERA_ACQU_WIDTH);
_vid_h = XML.getValue("config:camera:width", CAMERA_ACQU_HEIGHT);
// <display>
int fps = XML.getValue("config:display:fps", 30);
// <location>
_location = XML.getValue("config:locale:name", LOCATION);
cout << "Configuring..." << endl;
// display
cout << "> display" << endl;
ofSetFrameRate(fps);
if(fps > 30) {
ofSetVerticalSync(FALSE);
} else {
ofSetVerticalSync(TRUE);
}
cout << "* fps = " << fps << endl;
// camera
_vid_w = CAMERA_ACQU_WIDTH;
_vid_h = CAMERA_ACQU_HEIGHT;
_vid_id = CAMERA_ID;
cout << "> camera" << endl;
cout << "* cam id = " << _vid_id << endl;
cout << "* cam width = " << _vid_w << endl;
cout << "* cam height = " << _vid_h << endl;
_vid_stream_open = false;
_vid_toggle_on = false;
setup_camera();
// gui
_gui.loadFont("MONACO.TTF", 8);
_gui.setup("REFRACTIVE INDEX", 0, 0, ofGetWidth(), ofGetHeight());
cout << "RRRRRREADY!" << endl;
// -> PANEL #0
_gui.addPanel("configuration", 4, false);
_gui.setWhichPanel(0);
// --> COLUMN #0
_gui.setWhichColumn(0);
//GET THE INPUT NAMES FROM THE QT VIDEO GRABBER
_gui.addToggle("more cam settings", "SETTINGS", 0);
_gui.addToggle("turn on camera", "CAM_IS_GO", 0);
_gui.addButtonSlider("camera width", "CAM_WIDTH", _vid_w, CAMERA_ACQU_WIDTH, 1920, true);
_gui.addButtonSlider("camera height", "CAM_HEIGHT", _vid_h, CAMERA_ACQU_HEIGHT, 1080, true);
_gui.setWhichColumn(1);
_gui.addToggle("run", "RUN", 0);
_gui.setupEvents();
_gui.enableEvents();
// -- this gives you back an ofEvent for all events in this control panel object
ofAddListener(_gui.guiEvent, this, &RefractiveIndex::eventsIn);
_currentAnalysis = NULL;
_analysisAdapator = NULL;
//getting a warning from the OFlog that the pixels aren't allocated
// void ofPixels::allocate(int w, int h, ofImageType type)
//_pixels.allocate(
_location="MIDDLESBOROUGH";
//setup_camera();
// setup analysis
_analysisVector.push_back(new ShadowScapesAnalysis());
_analysisVector.push_back(new StrobeAnalysis());
_analysisVector.push_back(new IResponseAnalysis());
_analysisVector.push_back(new ColorMultiAnalysis());
_analysisVector.push_back(new CamFrameRateAnalysis());
_analysisVector.push_back(new CamNoiseAnalysis());
_analysisVector.push_back(new ColorSingleAnalysis());
_analysisVector.push_back(new LatencyTestAnalysis());
_analysisVector.push_back(new DiffNoiseAnalysis());
_currentAnalysisIndx = 0;
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx);
_state = ISTATE_START;
}
void RefractiveIndex::analysis_cb(string & analysis)
{
assert(analysis == _currentAnalysis->_name);
_state = ISTATE_STOP;
}
void RefractiveIndex::start_analysis()
{
ofAddListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::analysis_cb);
_analysisAdapator = new AnalysisAdaptor(_currentAnalysis);
_currentAnalysis->setup(_vid_w, _vid_h);
_analysisAdapator->start();
}
void RefractiveIndex::stop_analysis()
{
if(_analysisAdapator == NULL) return;
_analysisAdapator->stop(); //blocking
ofRemoveListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::analysis_cb);
_currentAnalysis = NULL;
delete _analysisAdapator;
_analysisAdapator = NULL;
}
void RefractiveIndex::state_analysis()
{
switch (_state) {
case ISTATE_START:
start_analysis();
_state = ISTATE_UNDEF;
break;
case ISTATE_TRANSITION:
if(_currentAnalysisIndx >= _analysisVector.size()) {
_currentAnalysisIndx = 0;
_state = ISTATE_END;
} else {
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
_state = ISTATE_START;
}
break;
case ISTATE_STOP:
stop_analysis(); // blocking
_state = ISTATE_TRANSITION;
break;
case ISTATE_END:
break;
case ISTATE_UNDEF:
break;
default:
break;
}
}
void RefractiveIndex::update()
{
_gui.update();
state_analysis();
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
if (_vidGrabber.isFrameNew())
@ -92,26 +184,8 @@ void RefractiveIndex::update()
void RefractiveIndex::draw()
{
ofBackground(0, 0, 0);
if(_currentAnalysis)
_currentAnalysis->draw();
// i would like to pass the pixels we've just got from the camera into the draw function for the current analysis here
// but the way that 'draw' functino in _currentAnalysis, which is an AbstractAnalysis, is as a "Pure Virtual Function"
// which i think means it can't be passed any arguments or data???
//_currentAnalysis->draw(_pixels);
else
_gui.draw();
// if there is a new frame in the camera
/* if (_vidGrabber.isFrameNew())
{
_vidGrabber.draw(0,0); //get ofPixels from the camera
}*/
}
void RefractiveIndex::setup_camera()
@ -136,80 +210,4 @@ void RefractiveIndex::keyPressed (int key)
{
if( key =='f')
ofToggleFullscreen();
else if( key =='s') {
if(_currentAnalysis && _analysisAdapator) {
_analysisAdapator->stop();
delete _currentAnalysis;
delete _analysisAdapator;
_currentAnalysis = NULL;
_analysisAdapator = NULL;
cout << "bingo!\n\n"; //bingo means 'stop analysis'?
}
}
}
void RefractiveIndex::mouseDragged(int x, int y, int button)
{
_gui.mouseDragged(x, y, button);
}
void RefractiveIndex::mousePressed(int x, int y, int button)
{
_gui.mousePressed(x, y, button);
}
void RefractiveIndex::mouseReleased(int x, int y, int button)
{
_gui.mouseReleased();
}
void RefractiveIndex::eventsIn(guiCallbackData& data)
{
if(data.getDisplayName() == "run"){
ofLog(OF_LOG_VERBOSE) << "run...";
//_currentAnalysis = new ShadowScapesAnalysis(); // create an analysis and give it an adaptor
//_currentAnalysis = new StrobeAnalysis(); // create an analysis and give it an adaptor
//_currentAnalysis = new IResponseAnalysis(); // create an analysis and give it an adaptor
//_currentAnalysis = new ColorMultiAnalysis();
//_currentAnalysis = new CamFrameRateAnalysis();
//_currentAnalysis = new CamNoiseAnalysis();
_currentAnalysis = new ColorSingleAnalysis();
//_currentAnalysis = new LatencyTestAnalysis();
//_currentAnalysis = new DiffNoiseAnalysis();
_analysisAdapator = new AnalysisAdaptor(_currentAnalysis); //Adaptors start and stop
_currentAnalysis->setup(_vid_w, _vid_h);
_analysisAdapator->start();
}
if(data.getDisplayName() == "turn on camera" ){
_vid_toggle_on=!_vid_toggle_on;
if (_vid_toggle_on)
{
setup_camera();
} else if (!_vid_toggle_on) {
_vidGrabber.close();
}
}
//more cam settings", "SETTINGS"
if( data.getDisplayName() == "more cam settings" ){
_vidGrabber.videoSettings();
}
}
void RefractiveIndex::grabBackgroundEvent(guiCallbackData & data)
{
}

View File

@ -7,7 +7,8 @@
#pragma once
#include "ofMain.h"
#include "ofxControlPanel.h"
#include "ofEvents.h"
//#include "ofxControlPanel.h"
#include "AbstractAnalysis.h"
#include "AnalysisAdaptor.h"
@ -24,6 +25,10 @@ public:
// refindx
void setup_camera();
void analysis_cb(string & analysis);
void start_analysis();
void stop_analysis();
void state_analysis();
// ofx
void keyPressed (int key);
@ -36,14 +41,16 @@ public:
protected:
void eventsIn(guiCallbackData & data);
void grabBackgroundEvent(guiCallbackData & data);
//void eventsIn(guiCallbackData & data);
//void grabBackgroundEvent(guiCallbackData & data);
// gui
ofxControlPanel _gui;
//ofxControlPanel _gui;
AbstractAnalysis* _currentAnalysis;
int _currentAnalysisIndx;
AnalysisAdaptor* _analysisAdapator;
vector<AbstractAnalysis*> _analysisVector;
public:
// acquisition
@ -53,6 +60,8 @@ public:
static int _vid_w, _vid_h, _vid_id;
static bool _vid_stream_open;
static bool _vid_toggle_on;
// this should be in xml
static string _location;

View File

@ -1,10 +1,27 @@
#include "ofAppGlutWindow.h"
#include "RefractiveIndex.h"
#include "ofxXmlSettings.h"
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
int main() {
ofAppGlutWindow window;
//window.setGlutDisplayString("rgba double samples >= 8");
ofSetupOpenGL(&window, 1024, 768, OF_WINDOW);
ofxXmlSettings XML;
XML.loadFile("../data/config.refindx");
bool fullscreen = (XML.getValue("config:display:fullscreen", "false") == "true" ? true : false);
int screen_w = XML.getValue("config:display:width", SCREEN_WIDTH);
int screen_h = XML.getValue("config:display:height", SCREEN_HEIGHT);
cout << "> display configuration" << endl;
cout << "* fullscreen: " << (fullscreen ? "yes" : "no") << endl;
if(!fullscreen) {
cout << "* screen width: " << screen_w << endl;
cout << "* screen height: " << screen_h << endl;
}
ofSetupOpenGL(&window, screen_w, screen_h, (fullscreen ? OF_FULLSCREEN : OF_WINDOW));
ofRunApp(new RefractiveIndex());
}

69
src/AbstractAnalysis.cpp Executable file → Normal file
View File

@ -1,7 +1,76 @@
/*
- 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:
+ > redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ > redistributions in binary form must reproduce the above copyright
+ 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
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ 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
*/
#include "AbstractAnalysis.h"
#include "RefractiveIndex.h"
void AbstractAnalysis::do_synthesize() {
synthesize();
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);
}
}
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
}

View File

@ -5,7 +5,9 @@
#pragma once
#include "ofxControlPanel.h"
#include "ofMain.h"
#include "ofEvents.h"
#include <string>
//#define ANALYSIS_PATH "data/analysis/"
@ -21,39 +23,30 @@ public:
// generic function to set up the camera
virtual void setup(int camWidth, int camHeight){_cam_w = camWidth; _cam_h = camHeight;}
// the runnable function in the thread
virtual void synthesize() = 0; // this means that this function needs to be overwritten by children that inherit this class
// throwing the
virtual void gui_attach(ofxControlPanel* gui){_gui = gui;}
virtual void gui_detach(){;}
// virtual void draw(ofPixels _pixels) = 0;
// virtual void draw(ofPixels)=0;
// how to get the pixels into the analysis classes?!? -j
void do_synthesize();
// ofx
virtual void draw() = 0;
// this is what's called a Pure Virtual Function - not sure if you can pass ofPixels through this?
protected:
/*
When a virtual function is called, the implementation is chosen based not on the static type of the pointer
or reference, but on the type of the object being pointed to, which can vary at run time
So this Pure Virtual Function will be called based on the kind of object or class that instantiated it(?)
*/
virtual void create_dir();
// the runnable function in the thread
virtual void synthesize() = 0;
// this means that this function needs to be overwritten by children that inherit this class
public:
string _name;
protected:
ofxControlPanel* _gui;
int _cam_w, _cam_h;
// event
ofEvent<string> _synthesize_cb;
protected:
int _cam_w, _cam_h;
int _state;
string _whole_file_path;
friend class AnalysisAdaptor;
};

View File

@ -21,7 +21,7 @@ public:
void start()
{
_runnable = new RunnableAdapter<AbstractAnalysis>(*_analysis, &AbstractAnalysis::synthesize);
_runnable = new RunnableAdapter<AbstractAnalysis>(*_analysis, &AbstractAnalysis::do_synthesize);
_worker.start(*_runnable);
}

View File

@ -18,38 +18,8 @@ using Poco::Thread;
void CamFrameRateAnalysis::setup(int camWidth, int camHeight)
{
// HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES
create_dir();
//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);
}
}
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(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;
@ -82,19 +52,6 @@ void CamFrameRateAnalysis::synthesize()
}
}
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
// this runs at frame rate = 33 ms for 30 FPS
void CamFrameRateAnalysis::draw()
{

View File

@ -27,9 +27,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void save_cb(Poco::Timer& timer);
@ -39,6 +36,5 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt;
float c, _frame_cnt, _frame_cnt_max;
string _whole_file_path;
};

View File

@ -18,38 +18,7 @@ using Poco::Thread;
void CamNoiseAnalysis::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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
@ -83,18 +52,6 @@ void CamNoiseAnalysis::synthesize()
}
}
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
// this runs at frame rate = 33 ms for 30 FPS
void CamNoiseAnalysis::draw()

View File

@ -25,9 +25,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void save_cb(Poco::Timer& timer);
@ -37,6 +34,5 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt;
float c, _frame_cnt, _frame_cnt_max;
string _whole_file_path;
};

View File

@ -45,41 +45,9 @@ using Poco::Thread;
void ColorMultiAnalysis::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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
}
@ -110,18 +78,6 @@ 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);
}
void ColorMultiAnalysis::gui_detach()
{
}
void ColorMultiAnalysis::draw()
{

View File

@ -18,9 +18,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void save_cb(Poco::Timer& timer);
@ -30,5 +27,4 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt;
float c, _frame_cnt, _frame_cnt_max;
string _whole_file_path;
};

View File

@ -18,38 +18,7 @@ using Poco::Thread;
void ColorSingleAnalysis::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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
r = 0;
@ -84,17 +53,6 @@ void ColorSingleAnalysis::synthesize()
}
}
void ColorSingleAnalysis::gui_attach(ofxControlPanel* gui)
{
}
void ColorSingleAnalysis::gui_detach()
{
}
void ColorSingleAnalysis::draw()
{

View File

@ -25,9 +25,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void save_cb(Poco::Timer& timer);
@ -37,6 +34,5 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt;
float r,g,b, _frame_cnt, _frame_cnt_max;
string _whole_file_path;
};

View File

@ -18,38 +18,7 @@ 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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@ -82,19 +51,6 @@ void DiffNoiseAnalysis::synthesize()
}
}
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
// this runs at frame rate = 33 ms for 30 FPS
void DiffNoiseAnalysis::draw()
{

View File

@ -25,9 +25,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void save_cb(Poco::Timer& timer);
@ -37,6 +34,5 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt;
float c, _frame_cnt, _frame_cnt_max;
string _whole_file_path;
};

View File

@ -18,38 +18,7 @@ using Poco::Thread;
void IResponseAnalysis::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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@ -82,18 +51,6 @@ void IResponseAnalysis::synthesize()
}
}
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
// this runs at frame rate = 33 ms for 30 FPS
void IResponseAnalysis::draw()

View File

@ -25,9 +25,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void save_cb(Poco::Timer& timer);
@ -37,6 +34,5 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt;
float c, _frame_cnt, _frame_cnt_max;
string _whole_file_path;
};

View File

@ -18,38 +18,7 @@ using Poco::Thread;
void LatencyTestAnalysis::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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
_frame_cnt = 0;
_frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000);
c = 0;
@ -82,19 +51,6 @@ void LatencyTestAnalysis::synthesize()
}
}
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
// this runs at frame rate = 33 ms for 30 FPS
void LatencyTestAnalysis::draw()
{

View File

@ -25,9 +25,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void save_cb(Poco::Timer& timer);
@ -37,6 +34,5 @@ protected:
bool _RUN_DONE;
int _run_cnt, _save_cnt;
float c, _frame_cnt, _frame_cnt_max;
string _whole_file_path;
};

View File

@ -46,38 +46,7 @@ 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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
_speed = 300;
}
@ -103,25 +72,13 @@ void ShadowScapesAnalysis::synthesize()
// do analysis 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);
}
void ShadowScapesAnalysis::gui_detach()
{
}
// the animation draw - and the output draw
void ShadowScapesAnalysis::draw()
{
@ -152,14 +109,10 @@ void ShadowScapesAnalysis::draw()
void ShadowScapesAnalysis::scan_cb(Timer& timer)
{
cout << "ShadowScapesAnalysis::scan_cb\n";
_line += _step;
if((_dir == H && _line >= ofGetWidth()) ||
(_dir == V && _line >= ofGetHeight())) {
_state = STATE_ANALYSIS;
}
}

View File

@ -44,15 +44,13 @@ class ShadowScapesAnalysis : public AbstractAnalysis
{
public:
ShadowScapesAnalysis(shadow_type dir): AbstractAnalysis("SHADOWSCAPE"), _dir(dir){;}
ShadowScapesAnalysis(): AbstractAnalysis("SHADOWSCAPE"), _dir(H){;}
virtual ~ShadowScapesAnalysis(){;}
public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void scan_cb(Poco::Timer& timer);
@ -64,6 +62,4 @@ protected:
int _step;
shadow_type _dir;
string _whole_file_path;
};

View File

@ -45,38 +45,7 @@ using Poco::Thread;
void StrobeAnalysis::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);
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(string(ANALYSIS_PATH)+RefractiveIndex::_location+"/"+ _name+"/"+replaceTime+"/", true,false);
}
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
create_dir();
}
void StrobeAnalysis::synthesize()
@ -98,20 +67,11 @@ void StrobeAnalysis::synthesize()
// do analysis here
/*
while(_state != STATE_STOP)
Thread::sleep(100);
}
void StrobeAnalysis::gui_attach(ofxControlPanel* gui)
{
gui->addToggle("GO", "GO", 0);
gui->addButtonSlider("animation time limit", "ANIMATION_TIME_LIMIT", 10, 1, 3000, TRUE);
}
void StrobeAnalysis::gui_detach()
{
*/
}
void StrobeAnalysis::draw()

View File

@ -46,9 +46,6 @@ public:
void setup(int camWidth, int camHeight);
void synthesize();
void gui_attach(ofxControlPanel* gui);
void gui_detach();
void draw();
void strobe_cb(Poco::Timer& timer);
@ -57,5 +54,4 @@ protected:
int _strobe_cnt;
bool _darkness;
string _whole_file_path;
};