From 7123b1b386a5d0d1ca6ad06bd637e573ca666771 Mon Sep 17 00:00:00 2001 From: dviid Date: Tue, 24 Jan 2012 15:13:07 +0100 Subject: [PATCH] haha commit! --- README | 6 ++ example/RefractiveIndex.cpp | 164 +++++++++++++++++++++++++++++++++++ example/RefractiveIndex.h | 79 +++++++++++++++++ example/main.cpp | 12 +++ src/AbstractAnalysis.cpp | 7 ++ src/AbstractAnalysis.h | 59 +++++++++++++ src/AnalysisAdaptor.h | 39 +++++++++ src/CamFrameRateAnalysis.cpp | 133 ++++++++++++++++++++++++++++ src/CamFrameRateAnalysis.h | 44 ++++++++++ src/CamNoiseAnalysis.cpp | 138 +++++++++++++++++++++++++++++ src/CamNoiseAnalysis.h | 42 +++++++++ src/ColorMultiAnalysis.cpp | 154 ++++++++++++++++++++++++++++++++ src/ColorMultiAnalysis.h | 34 ++++++++ src/ColorSingleAnalysis.cpp | 137 +++++++++++++++++++++++++++++ src/ColorSingleAnalysis.h | 42 +++++++++ src/DiffNoiseAnalysis.cpp | 137 +++++++++++++++++++++++++++++ src/DiffNoiseAnalysis.h | 42 +++++++++ src/IResponseAnalysis.cpp | 130 +++++++++++++++++++++++++++ src/IResponseAnalysis.h | 42 +++++++++ src/LatencyTestAnalysis.cpp | 148 +++++++++++++++++++++++++++++++ src/LatencyTestAnalysis.h | 42 +++++++++ src/ShadowScapesAnalysis.cpp | 154 ++++++++++++++++++++++++++++++++ src/ShadowScapesAnalysis.h | 69 +++++++++++++++ src/StrobeAnalysis.cpp | 142 ++++++++++++++++++++++++++++++ src/StrobeAnalysis.h | 61 +++++++++++++ 25 files changed, 2057 insertions(+) create mode 100644 README create mode 100644 example/RefractiveIndex.cpp create mode 100644 example/RefractiveIndex.h create mode 100755 example/main.cpp create mode 100755 src/AbstractAnalysis.cpp create mode 100755 src/AbstractAnalysis.h create mode 100755 src/AnalysisAdaptor.h create mode 100755 src/CamFrameRateAnalysis.cpp create mode 100755 src/CamFrameRateAnalysis.h create mode 100755 src/CamNoiseAnalysis.cpp create mode 100755 src/CamNoiseAnalysis.h create mode 100755 src/ColorMultiAnalysis.cpp create mode 100755 src/ColorMultiAnalysis.h create mode 100755 src/ColorSingleAnalysis.cpp create mode 100755 src/ColorSingleAnalysis.h create mode 100755 src/DiffNoiseAnalysis.cpp create mode 100755 src/DiffNoiseAnalysis.h create mode 100755 src/IResponseAnalysis.cpp create mode 100755 src/IResponseAnalysis.h create mode 100755 src/LatencyTestAnalysis.cpp create mode 100755 src/LatencyTestAnalysis.h create mode 100755 src/ShadowScapesAnalysis.cpp create mode 100755 src/ShadowScapesAnalysis.h create mode 100755 src/StrobeAnalysis.cpp create mode 100755 src/StrobeAnalysis.h diff --git a/README b/README new file mode 100644 index 0000000..06da3fd --- /dev/null +++ b/README @@ -0,0 +1,6 @@ +WARNING: WORK IN PROGRESS... + +configuring OpenFrameworks +----------------- + + diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp new file mode 100644 index 0000000..28390f0 --- /dev/null +++ b/example/RefractiveIndex.cpp @@ -0,0 +1,164 @@ +/* + - 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 "RefractiveIndex.h" + +#include "IResponseAnalysis.h" +#include "StrobeAnalysis.h" +#include "ShadowScapesAnalysis.h" + +#define CAMERA_ID 1 +#define CAMERA_ACQU_WIDTH 640 +#define CAMERA_ACQU_HEIGHT 480 + +void RefractiveIndex::setup() +{ + // rate + ofSetFrameRate(30); + ofSetVerticalSync(TRUE); + + // camera + _vid_w = CAMERA_ACQU_WIDTH; + _vid_h = CAMERA_ACQU_HEIGHT; + _vid_id = CAMERA_ID; + _vid_stream_open = false; + //setup_camera(); + + // gui + _gui.loadFont("MONACO.TTF", 8); + _gui.setup("REFRACTIVE INDEX", 0, 0, ofGetWidth(), ofGetHeight()); + + // -> PANEL #0 + _gui.addPanel("configuration", 4, false); + _gui.setWhichPanel(0); + // --> COLUMN #0 + _gui.setWhichColumn(0); + _gui.addToggle("open 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; + + +} + +void RefractiveIndex::update() +{ + _gui.update(); +} + +void RefractiveIndex::draw() +{ + ofBackground(0, 0, 0); + + if(_currentAnalysis) + _currentAnalysis->draw(); + else + _gui.draw(); +} + +void RefractiveIndex::setup_camera() +{ + if(_vid_stream_open) { + _vidGrabber.close(); + _vid_stream_open = false; + } + + if(!_vidGrabber.initGrabber(_vid_w, _vid_h)) { + ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber"; + return; + } + _vidGrabber.setDeviceID(_vid_id); + _vidGrabber.setVerbose(true); + _vid_stream_open = true; +} + +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"; + } + } + +} + +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 IResponseAnalysis(); + _analysisAdapator = new AnalysisAdaptor(_currentAnalysis); + _currentAnalysis->setup(_vid_w, _vid_h); + _analysisAdapator->start(); + } +} + +void RefractiveIndex::grabBackgroundEvent(guiCallbackData & data) +{ + +} + + diff --git a/example/RefractiveIndex.h b/example/RefractiveIndex.h new file mode 100644 index 0000000..884db29 --- /dev/null +++ b/example/RefractiveIndex.h @@ -0,0 +1,79 @@ +/* + - 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 + */ + +#pragma once + +#include "ofMain.h" +#include "ofxControlPanel.h" + +#include "AbstractAnalysis.h" +#include "AnalysisAdaptor.h" + + +class RefractiveIndex : public ofBaseApp +{ +public: + + // ofx + void setup(); + void update(); + void draw(); + + // refindx + void setup_camera(); + + // ofx + void keyPressed (int key); + void keyReleased(int key){;} + void mouseMoved(int x, int y ){;} + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h){;} + +protected: + + void eventsIn(guiCallbackData & data); + void grabBackgroundEvent(guiCallbackData & data); + + // gui + ofxControlPanel _gui; + + // acquisition + ofVideoGrabber _vidGrabber; + int _vid_w, _vid_h, _vid_id; + bool _vid_stream_open; + + AbstractAnalysis* _currentAnalysis; + AnalysisAdaptor* _analysisAdapator; + +}; \ No newline at end of file diff --git a/example/main.cpp b/example/main.cpp new file mode 100755 index 0000000..efab296 --- /dev/null +++ b/example/main.cpp @@ -0,0 +1,12 @@ +#include "ofAppGlutWindow.h" +#include "testApp.h" +#include "RefractiveIndex.h" + +int main() { + ofAppGlutWindow window; + //window.setGlutDisplayString("rgba double samples >= 8"); + ofSetupOpenGL(&window, 1024, 768, OF_WINDOW); + ofRunApp(new RefractiveIndex()); + //ofRunApp(new testApp()); + +} diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp new file mode 100755 index 0000000..298b554 --- /dev/null +++ b/src/AbstractAnalysis.cpp @@ -0,0 +1,7 @@ +/* + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#include "AbstractAnalysis.h" diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h new file mode 100755 index 0000000..5f0123d --- /dev/null +++ b/src/AbstractAnalysis.h @@ -0,0 +1,59 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "ofxControlPanel.h" +#include + +//#define ANALYSIS_PATH "data/analysis/" +#define ANALYSIS_PATH "analysis/" + +#define STATE_STOP 0xDEADBEEF + +class AbstractAnalysis { + +public: + AbstractAnalysis(string name) : _name(name) {;} + virtual ~AbstractAnalysis(){;} + + // 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 + + // ofx + virtual void draw() = 0; + + // this is what's called a Pure Virtual Function - not sure if you can pass ofPixels through this? + + /* + 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(?) + */ + + +public: + string _name; + +protected: + ofxControlPanel* _gui; + int _cam_w, _cam_h; + + int _state; + + friend class AnalysisAdaptor; +}; \ No newline at end of file diff --git a/src/AnalysisAdaptor.h b/src/AnalysisAdaptor.h new file mode 100755 index 0000000..69d3136 --- /dev/null +++ b/src/AnalysisAdaptor.h @@ -0,0 +1,39 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Thread.h" +#include "Poco/RunnableAdapter.h" + +using Poco::Thread; +using Poco::RunnableAdapter; + +class AnalysisAdaptor +{ +public: + AnalysisAdaptor(AbstractAnalysis* analysis) : _analysis(analysis) {;} + virtual ~AnalysisAdaptor(){ delete _runnable; } + + void start() + { + _runnable = new RunnableAdapter(*_analysis, &AbstractAnalysis::synthesize); + _worker.start(*_runnable); + } + + void stop() + { + _analysis->_state = STATE_STOP; + _worker.join(); + } + +protected: + AbstractAnalysis* _analysis; + Thread _worker; // + RunnableAdapter* _runnable; +}; + diff --git a/src/CamFrameRateAnalysis.cpp b/src/CamFrameRateAnalysis.cpp new file mode 100755 index 0000000..245ce4f --- /dev/null +++ b/src/CamFrameRateAnalysis.cpp @@ -0,0 +1,133 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#include "CamFrameRateAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" + +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + + +void CamFrameRateAnalysis::setup(int camWidth, int camHeight) +{ + // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< save_callback(*this, &CamFrameRateAnalysis::save_cb); + + // 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); + _RUN_DONE = false; + _frame_cnt = 0; _save_cnt = 0; + + while(!_RUN_DONE) + Thread::sleep(3); + + 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 + + +// 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 + /// *** TODO *** /// + float totalTime=_frame_cnt_max/2; + + float numSteps=10; + + vectorstepLengths; + + + //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()); + c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max); + cout<<_frame_cnt<= NUM_SAVE_PER_RUN) + _RUN_DONE = true; + +} \ No newline at end of file diff --git a/src/CamFrameRateAnalysis.h b/src/CamFrameRateAnalysis.h new file mode 100755 index 0000000..aae0c40 --- /dev/null +++ b/src/CamFrameRateAnalysis.h @@ -0,0 +1,44 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +#define DELTA_T_SAVE 1000/30 //timer call back needs to be at main app frame rate ie 1000/30 +#define NUM_PHASE 1 +//#define TIME_PER_RUN 3*1000 +#define NUM_RUN 1 +//#define SYNTH_TIME TIME_PER_RUN *NUM_RUN //the number of millis it takes for the whole sequence +#define NUM_SAVE_PER_RUN 100 //this must be equal to the number of frames it takes for the whole analysis to draw - ie _frame_cnt_max + + +class CamFrameRateAnalysis : public AbstractAnalysis +{ +public: + CamFrameRateAnalysis(): AbstractAnalysis("CAM_NOISE"){;} + virtual ~CamFrameRateAnalysis(){;} + +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); + +protected: + + bool _RUN_DONE; + int _run_cnt, _save_cnt; + float c, _frame_cnt, _frame_cnt_max; + string _whole_file_path; + +}; diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp new file mode 100755 index 0000000..4fa0349 --- /dev/null +++ b/src/CamNoiseAnalysis.cpp @@ -0,0 +1,138 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#include "CamNoiseAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" + +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + + +void CamNoiseAnalysis::setup(int camWidth, int camHeight) +{ + // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< save_callback(*this, &CamNoiseAnalysis::save_cb); + + // 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); + _RUN_DONE = false; + _frame_cnt = 0; _save_cnt = 0; + + while(!_RUN_DONE) + Thread::sleep(3); + + 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 + + +// 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 + /// *** 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()); + } + + + + _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); + + if(_save_cnt >= NUM_SAVE_PER_RUN) + _RUN_DONE = true; + +} \ No newline at end of file diff --git a/src/CamNoiseAnalysis.h b/src/CamNoiseAnalysis.h new file mode 100755 index 0000000..bff2b63 --- /dev/null +++ b/src/CamNoiseAnalysis.h @@ -0,0 +1,42 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +#define DELTA_T_SAVE 100 //the milisecond timing +#define NUM_PHASE 1 +#define NUM_RUN 1 +#define NUM_SAVE_PER_RUN 100 + + +class CamNoiseAnalysis : public AbstractAnalysis +{ +public: + CamNoiseAnalysis(): AbstractAnalysis("CAM_NOISE"){;} + virtual ~CamNoiseAnalysis(){;} + +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); + +protected: + + bool _RUN_DONE; + int _run_cnt, _save_cnt; + float c, _frame_cnt, _frame_cnt_max; + string _whole_file_path; + +}; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp new file mode 100755 index 0000000..ce0b4fc --- /dev/null +++ b/src/ColorMultiAnalysis.cpp @@ -0,0 +1,154 @@ +/* + - 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 "ColorMultiAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + + + +void ColorMultiAnalysis::setup(int camWidth, int camHeight) +{ + // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< save_callback(*this, &ColorMultiAnalysis::save_cb); + + // 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); + _RUN_DONE = false; + _frame_cnt = 0; _save_cnt = 0; + + while(!_RUN_DONE) + Thread::sleep(3); + + save_timer->stop(); + } + +} + +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() +{ + + + if (_frame_cnt < _frame_cnt_max) + { + ofColor aColor; + aColor.setHsb(c, 255, 255); + ofSetColor(aColor); + 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++; + + +} + + +// this runs at save_cb timer rate = DELTA_T_SAVE +void ColorMultiAnalysis::save_cb(Timer& timer) +{ + _save_cnt++; + + // UPDATE THE COLOR ON THE SCREEN + //float c_last = c; + + cout << "COLORMULTIANALYSIS::saving...\n"; + cout << "c_last... " << c << endl; + string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; + + cout<<_whole_file_path<= NUM_SAVE_PER_RUN){ + _RUN_DONE = true; + } + +} diff --git a/src/ColorMultiAnalysis.h b/src/ColorMultiAnalysis.h new file mode 100755 index 0000000..d84be9a --- /dev/null +++ b/src/ColorMultiAnalysis.h @@ -0,0 +1,34 @@ +#define DELTA_T_SAVE 100 //the milisecond timing +#define NUM_PHASE 1 +#define NUM_RUN 1 +#define NUM_SAVE_PER_RUN 100 +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +class ColorMultiAnalysis : public AbstractAnalysis +{ +public: + ColorMultiAnalysis(): AbstractAnalysis("COLOR_MULTI"){;} + virtual ~ColorMultiAnalysis(){;} + +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); + +protected: + + bool _RUN_DONE; + int _run_cnt, _save_cnt; + float c, _frame_cnt, _frame_cnt_max; + string _whole_file_path; +}; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp new file mode 100755 index 0000000..1f6c037 --- /dev/null +++ b/src/ColorSingleAnalysis.cpp @@ -0,0 +1,137 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#include "ColorSingleAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" + +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + + +void ColorSingleAnalysis::setup(int camWidth, int camHeight) +{ + // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES + + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< save_callback(*this, &ColorSingleAnalysis::save_cb); + + // 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); + _RUN_DONE = false; + _frame_cnt = 0; _save_cnt = 0; + + while(!_RUN_DONE) + Thread::sleep(3); + + save_timer->stop(); + } +} + +void ColorSingleAnalysis::gui_attach(ofxControlPanel* gui) +{ + +} + +void ColorSingleAnalysis::gui_detach() +{ + +} + + +void ColorSingleAnalysis::draw() +{ + + float one_third_of_frame_count_max=_frame_cnt_max/3; + if (_frame_cnt < one_third_of_frame_count_max){ + r=255.0; + g=0.0; + b=0.0; + ofSetColor(r,g,b); + 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()); + } + 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()); + } + + _frame_cnt++; + + +} + +// this runs at save_cb timer rate = DELTA_T_SAVE +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); + cout<<_whole_file_path+"/"+file_name<= NUM_SAVE_PER_RUN) + _RUN_DONE = true; + +} \ No newline at end of file diff --git a/src/ColorSingleAnalysis.h b/src/ColorSingleAnalysis.h new file mode 100755 index 0000000..53c2b10 --- /dev/null +++ b/src/ColorSingleAnalysis.h @@ -0,0 +1,42 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +#define DELTA_T_SAVE 100 //the milisecond timing +#define NUM_PHASE 1 +#define NUM_RUN 1 +#define NUM_SAVE_PER_RUN 100 + + +class ColorSingleAnalysis : public AbstractAnalysis +{ +public: + ColorSingleAnalysis(): AbstractAnalysis("COLOR_SINGLE"){;} + virtual ~ColorSingleAnalysis(){;} + +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); + +protected: + + bool _RUN_DONE; + int _run_cnt, _save_cnt; + float r,g,b, _frame_cnt, _frame_cnt_max; + string _whole_file_path; + +}; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp new file mode 100755 index 0000000..2994ea7 --- /dev/null +++ b/src/DiffNoiseAnalysis.cpp @@ -0,0 +1,137 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#include "DiffNoiseAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" + +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + + +void DiffNoiseAnalysis::setup(int camWidth, int camHeight) +{ + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< save_callback(*this, &DiffNoiseAnalysis::save_cb); + + // 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); + _RUN_DONE = false; + _frame_cnt = 0; _save_cnt = 0; + + while(!_RUN_DONE) + Thread::sleep(3); + + 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 + + +// 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 + /// *** TODO *** /// + ofColor aColour; + + c = ofRandom(0,255); + aColour.setHsb(c, 255, 255); + if (_frame_cnt < _frame_cnt_max) + { + ofSetColor(aColour); + 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<<"rand10... " <= NUM_SAVE_PER_RUN) + _RUN_DONE = true; + +} \ No newline at end of file diff --git a/src/DiffNoiseAnalysis.h b/src/DiffNoiseAnalysis.h new file mode 100755 index 0000000..929cf50 --- /dev/null +++ b/src/DiffNoiseAnalysis.h @@ -0,0 +1,42 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +#define DELTA_T_SAVE 1000/30 //timer call back needs to be at main app frame rate ie 1000/30 +#define NUM_PHASE 1 +#define NUM_RUN 1 +#define NUM_SAVE_PER_RUN 100 //this analysis actually necessarily saves a random quantity of frames = about half this number + + +class DiffNoiseAnalysis : public AbstractAnalysis +{ +public: + DiffNoiseAnalysis(): AbstractAnalysis("DIFF_NOISE"){;} + virtual ~DiffNoiseAnalysis(){;} + +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); + +protected: + + bool _RUN_DONE; + int _run_cnt, _save_cnt; + float c, _frame_cnt, _frame_cnt_max; + string _whole_file_path; + +}; diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp new file mode 100755 index 0000000..4d1a03d --- /dev/null +++ b/src/IResponseAnalysis.cpp @@ -0,0 +1,130 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#include "IResponseAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" + +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + + +void IResponseAnalysis::setup(int camWidth, int camHeight) +{ + // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< save_callback(*this, &IResponseAnalysis::save_cb); + + // 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); + _RUN_DONE = false; + _frame_cnt = 0; _save_cnt = 0; + + while(!_RUN_DONE) + Thread::sleep(3); + + 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 + + +// 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 + /// *** TODO *** /// + + if (_frame_cnt < _frame_cnt_max) + { + ofSetColor(c, c, c); + 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; + + cout << "IResponseAnalysis::saving...\n"; + 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 + // 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); + + if(_save_cnt >= NUM_SAVE_PER_RUN) + _RUN_DONE = true; + +} \ No newline at end of file diff --git a/src/IResponseAnalysis.h b/src/IResponseAnalysis.h new file mode 100755 index 0000000..06f4bd7 --- /dev/null +++ b/src/IResponseAnalysis.h @@ -0,0 +1,42 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +#define DELTA_T_SAVE 100 //the milisecond timing +#define NUM_PHASE 1 +#define NUM_RUN 1 +#define NUM_SAVE_PER_RUN 100 + + +class IResponseAnalysis : public AbstractAnalysis +{ +public: + IResponseAnalysis(): AbstractAnalysis("I_RESPONSE"){;} + virtual ~IResponseAnalysis(){;} + +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); + +protected: + + bool _RUN_DONE; + int _run_cnt, _save_cnt; + float c, _frame_cnt, _frame_cnt_max; + string _whole_file_path; + +}; diff --git a/src/LatencyTestAnalysis.cpp b/src/LatencyTestAnalysis.cpp new file mode 100755 index 0000000..cf1ad29 --- /dev/null +++ b/src/LatencyTestAnalysis.cpp @@ -0,0 +1,148 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#include "LatencyTestAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" + +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + + +void LatencyTestAnalysis::setup(int camWidth, int camHeight) +{ + // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< save_callback(*this, &LatencyTestAnalysis::save_cb); + + // 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); + _RUN_DONE = false; + _frame_cnt = 0; _save_cnt = 0; + + while(!_RUN_DONE) + Thread::sleep(3); + + 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 + + +// 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 + /// *** TODO *** /// + + if (_frame_cnt < _frame_cnt_max/3) + { + c = 0; + + ofSetColor(c, c, c); + cout<<"1st third"<= _frame_cnt_max/3 && _frame_cnt < 2*( _frame_cnt_max/3)) + { + c = 255; + cout<<"2nd third"<= 2*( _frame_cnt_max/3) && _frame_cnt < _frame_cnt_max) + { + c = 0; + cout<<"3rd third"<= NUM_SAVE_PER_RUN) + _RUN_DONE = true; + +} \ No newline at end of file diff --git a/src/LatencyTestAnalysis.h b/src/LatencyTestAnalysis.h new file mode 100755 index 0000000..417493f --- /dev/null +++ b/src/LatencyTestAnalysis.h @@ -0,0 +1,42 @@ +/* + ~ author: dviid + ~ contact: dviid@labs.ciid.dk + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +#define DELTA_T_SAVE 100 //the milisecond timing +#define NUM_PHASE 1 +#define NUM_RUN 1 +#define NUM_SAVE_PER_RUN 100 + + +class LatencyTestAnalysis : public AbstractAnalysis +{ +public: + LatencyTestAnalysis(): AbstractAnalysis("LATENCY_TEST"){;} + virtual ~LatencyTestAnalysis(){;} + +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); + +protected: + + bool _RUN_DONE; + int _run_cnt, _save_cnt; + float c, _frame_cnt, _frame_cnt_max; + string _whole_file_path; + +}; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp new file mode 100755 index 0000000..d0f5b10 --- /dev/null +++ b/src/ShadowScapesAnalysis.cpp @@ -0,0 +1,154 @@ +/* + - 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 "ShadowScapesAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" +#include "RefractiveIndex.h" + +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + +#define STATE_SCAN 0 +#define STATE_ANALYSIS 1 + +void ShadowScapesAnalysis::setup(int camWidth, int camHeight) +{ + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< 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 - + + 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() +{ + + static int _pos; + + if(_state == STATE_ANALYSIS) { + 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); + + 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())) { + _state = STATE_ANALYSIS; + } + + +} diff --git a/src/ShadowScapesAnalysis.h b/src/ShadowScapesAnalysis.h new file mode 100755 index 0000000..8b38d4d --- /dev/null +++ b/src/ShadowScapesAnalysis.h @@ -0,0 +1,69 @@ +/* + - 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 + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +enum shadow_type { + H, V, D, +}; + +class ShadowScapesAnalysis : public AbstractAnalysis +{ +public: + ShadowScapesAnalysis(shadow_type dir): AbstractAnalysis("SHADOWSCAPE"), _dir(dir){;} + 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); + +protected: + + int _line; + int _speed; // pix per second + int _step; + shadow_type _dir; + + string _whole_file_path; + +}; \ No newline at end of file diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp new file mode 100755 index 0000000..d850fda --- /dev/null +++ b/src/StrobeAnalysis.cpp @@ -0,0 +1,142 @@ +/* + - 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 "StrobeAnalysis.h" +#include "ofMain.h" + +#include "Poco/Timer.h" +#include "Poco/Thread.h" +#include "RefractiveIndex.h" +using Poco::Timer; +using Poco::TimerCallback; +using Poco::Thread; + +#define STATE_STROBE 0 +#define STATE_ANALYSIS 1 + +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 + + time_t rawtime; + struct tm * timeinfo; + + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + string time = asctime(timeinfo); + + cout<<"time"< strobe_callback(*this, &StrobeAnalysis::strobe_cb); + + _state = STATE_STROBE; + _darkness = true; + _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); +} + +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() +{ + if(_state == STATE_ANALYSIS) { + ofSetColor(0, 200, 0); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + return; + } + + if(_darkness) { + ofSetColor(0, 0, 0); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + } else { + ofSetColor(255, 255, 255); + ofRect(0, 0, ofGetWidth(), ofGetHeight()); + } + +} + + +void StrobeAnalysis::strobe_cb(Timer& timer) +{ + cout << "IResponseAnalysis::saving...\n"; + _strobe_cnt++; + + _darkness = !_darkness; + + if(_strobe_cnt >= 20) { + _state = STATE_ANALYSIS; + } + + +} diff --git a/src/StrobeAnalysis.h b/src/StrobeAnalysis.h new file mode 100755 index 0000000..b6358b7 --- /dev/null +++ b/src/StrobeAnalysis.h @@ -0,0 +1,61 @@ +/* + - 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 + */ + +#pragma once + +#include "AbstractAnalysis.h" + +#include "Poco/Timer.h" + +class StrobeAnalysis : public AbstractAnalysis +{ +public: + StrobeAnalysis(): AbstractAnalysis("STROBE"){;} + virtual ~StrobeAnalysis(){;} + +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); + +protected: + + int _strobe_cnt; + bool _darkness; + string _whole_file_path; +};