new arch
> sequence: acquire -> synthesise -> display results
This commit is contained in:
parent
65c625ad1e
commit
7109c65d63
@ -11,7 +11,6 @@
|
||||
#include "RefractiveIndex.h"
|
||||
|
||||
#include "IResponseAnalysis.h"
|
||||
#include "StrobeAnalysis.h"
|
||||
#include "ShadowScapesAnalysis.h"
|
||||
#include "ColorMultiAnalysis.h"
|
||||
#include "ColorSingleAnalysis.h"
|
||||
@ -98,7 +97,6 @@ void RefractiveIndex::setup()
|
||||
// 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());
|
||||
|
||||
@ -33,8 +33,13 @@
|
||||
#include "AbstractAnalysis.h"
|
||||
#include "RefractiveIndex.h"
|
||||
|
||||
// this is the main threaded loop for a given analysis
|
||||
void AbstractAnalysis::do_synthesize() {
|
||||
synthesize();
|
||||
_state = STATE_ACQUIRING;
|
||||
acquire();
|
||||
_state = STATE_SYNTHESISING;
|
||||
synthesise();
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,10 @@
|
||||
|
||||
#define ANALYSIS_PATH "analysis/"
|
||||
|
||||
#define STATE_STOP 0xDEADBEEF
|
||||
#define STATE_ACQUIRING 0x1111
|
||||
#define STATE_SYNTHESISING 0x2222
|
||||
#define STATE_DISPLAY_RESULTS 0x3333
|
||||
#define STATE_STOP 0xDEADBEEF
|
||||
|
||||
class AbstractAnalysis {
|
||||
|
||||
@ -21,6 +24,7 @@ public:
|
||||
|
||||
// generic function to set up the camera
|
||||
virtual void setup(int camWidth, int camHeight){_cam_w = camWidth; _cam_h = camHeight;}
|
||||
// this is the main threaded loop for a given analysis
|
||||
void do_synthesize();
|
||||
|
||||
// ofx
|
||||
@ -30,9 +34,12 @@ protected:
|
||||
|
||||
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
|
||||
// acquire images - all the children (see - do_synthesize)
|
||||
virtual void acquire() = 0;
|
||||
|
||||
// analysis + synthesize images - all the children (see - do_synthesize)
|
||||
virtual void synthesise() = 0;
|
||||
|
||||
|
||||
public:
|
||||
string _name;
|
||||
@ -41,14 +48,16 @@ public:
|
||||
ofEvent<string> _synthesize_cb;
|
||||
|
||||
protected:
|
||||
int _cam_w, _cam_h;
|
||||
int _state;
|
||||
string _whole_file_path;
|
||||
int _cam_w, _cam_h;
|
||||
string _whole_file_path;
|
||||
vector<string> _saved_filenames;
|
||||
|
||||
float DELTA_T_SAVE;
|
||||
int NUM_PHASE;
|
||||
int NUM_RUN;
|
||||
int NUM_SAVE_PER_RUN;
|
||||
int _state;
|
||||
|
||||
float DELTA_T_SAVE;
|
||||
int NUM_PHASE;
|
||||
int NUM_RUN;
|
||||
int NUM_SAVE_PER_RUN;
|
||||
|
||||
friend class AnalysisAdaptor;
|
||||
};
|
||||
@ -31,7 +31,7 @@ void CamFrameRateAnalysis::setup(int camWidth, int camHeight)
|
||||
}
|
||||
|
||||
|
||||
void CamFrameRateAnalysis::synthesize()
|
||||
void CamFrameRateAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
@ -57,30 +57,59 @@ void CamFrameRateAnalysis::synthesize()
|
||||
}
|
||||
}
|
||||
|
||||
void CamFrameRateAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
// 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;
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
/// *** TODO *** ///
|
||||
// still need to deal with latency frames here - i.e.: there are frames
|
||||
/// *** TODO *** ///
|
||||
float totalTime=_frame_cnt_max/2;
|
||||
|
||||
vector<float>stepLengths;
|
||||
float numSteps=10;
|
||||
|
||||
vector<float>stepLengths;
|
||||
|
||||
|
||||
//c must increase until frame_cnt_max * 0.5 and then decrease afterwards
|
||||
//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<<endl;
|
||||
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<<endl;
|
||||
}
|
||||
_frame_cnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_frame_cnt++;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -94,8 +123,11 @@ void CamFrameRateAnalysis::save_cb(Timer& timer)
|
||||
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
|
||||
string thisLocation = RefractiveIndex::_location;
|
||||
|
||||
string file = _whole_file_path+"/"+file_name;
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
_saved_filenames.push_back(file);
|
||||
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
||||
_RUN_DONE = true;
|
||||
|
||||
@ -19,7 +19,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
@ -31,7 +31,7 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight)
|
||||
}
|
||||
|
||||
|
||||
void CamNoiseAnalysis::synthesize()
|
||||
void CamNoiseAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
@ -57,35 +57,62 @@ void CamNoiseAnalysis::synthesize()
|
||||
}
|
||||
}
|
||||
|
||||
void CamNoiseAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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;
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
/// *** TODO *** ///
|
||||
// still need to deal with latency frames here - i.e.: there are frames
|
||||
/// *** TODO *** ///
|
||||
|
||||
float _frames_per_level = _frame_cnt_max / _number_of_grey_levels;
|
||||
ofColor someColor;
|
||||
float _number_of_grey_levels=5;
|
||||
|
||||
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);
|
||||
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++;
|
||||
|
||||
break;
|
||||
}
|
||||
ofSetColor(someColor);
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
_frame_cnt++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// this runs at save_cb timer rate = DELTA_T_SAVE
|
||||
@ -96,9 +123,12 @@ void CamNoiseAnalysis::save_cb(Timer& timer)
|
||||
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
|
||||
string thisLocation = RefractiveIndex::_location;
|
||||
|
||||
string file = _whole_file_path+"/"+file_name;
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
_saved_filenames.push_back(file);
|
||||
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
||||
_RUN_DONE = true;
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
@ -56,7 +56,7 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
||||
c = 0;
|
||||
}
|
||||
|
||||
void ColorMultiAnalysis::synthesize()
|
||||
void ColorMultiAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
@ -83,18 +83,48 @@ void ColorMultiAnalysis::synthesize()
|
||||
|
||||
}
|
||||
|
||||
void ColorMultiAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
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++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_frame_cnt++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -110,9 +140,12 @@ void ColorMultiAnalysis::save_cb(Timer& timer)
|
||||
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;
|
||||
string file = _whole_file_path+"/"+file_name;
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
_saved_filenames.push_back(file);
|
||||
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN){
|
||||
_RUN_DONE = true;
|
||||
}
|
||||
|
||||
@ -13,7 +13,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
@ -32,7 +32,7 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
||||
}
|
||||
|
||||
|
||||
void ColorSingleAnalysis::synthesize()
|
||||
void ColorSingleAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
@ -58,33 +58,62 @@ void ColorSingleAnalysis::synthesize()
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSingleAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
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++;
|
||||
_frame_cnt++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -98,8 +127,12 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
|
||||
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";
|
||||
|
||||
string file = _whole_file_path+"/"+file_name;
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
_saved_filenames.push_back(file);
|
||||
|
||||
cout<<_whole_file_path+"/"+file_name<<endl;
|
||||
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
||||
|
||||
@ -18,7 +18,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
@ -30,7 +30,7 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
|
||||
}
|
||||
|
||||
|
||||
void DiffNoiseAnalysis::synthesize()
|
||||
void DiffNoiseAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
@ -56,24 +56,52 @@ void DiffNoiseAnalysis::synthesize()
|
||||
}
|
||||
}
|
||||
|
||||
void DiffNoiseAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
/// *** 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());
|
||||
c = ofRandom(0,255);
|
||||
aColour.setHsb(c, 255, 255);
|
||||
if (_frame_cnt < _frame_cnt_max)
|
||||
{
|
||||
ofSetColor(aColour);
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
|
||||
}
|
||||
_frame_cnt++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_frame_cnt++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -97,8 +125,12 @@ void DiffNoiseAnalysis::save_cb(Timer& timer)
|
||||
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
|
||||
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
string file = _whole_file_path+"/"+file_name;
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
_saved_filenames.push_back(file);
|
||||
|
||||
}
|
||||
_save_cnt++;
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
||||
|
||||
@ -18,7 +18,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
@ -29,7 +29,7 @@ void IResponseAnalysis::setup(int camWidth, int camHeight)
|
||||
}
|
||||
|
||||
|
||||
void IResponseAnalysis::synthesize()
|
||||
void IResponseAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
@ -55,22 +55,52 @@ void IResponseAnalysis::synthesize()
|
||||
}
|
||||
}
|
||||
|
||||
void IResponseAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
/// *** 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++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_frame_cnt++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -91,8 +121,12 @@ void IResponseAnalysis::save_cb(Timer& timer)
|
||||
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
|
||||
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
string file = _whole_file_path+"/"+file_name;
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
_saved_filenames.push_back(file);
|
||||
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
||||
_RUN_DONE = true;
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
@ -30,7 +30,7 @@ void LatencyTestAnalysis::setup(int camWidth, int camHeight)
|
||||
}
|
||||
|
||||
|
||||
void LatencyTestAnalysis::synthesize()
|
||||
void LatencyTestAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
@ -56,39 +56,68 @@ void LatencyTestAnalysis::synthesize()
|
||||
}
|
||||
}
|
||||
|
||||
void LatencyTestAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
/// *** TODO *** ///
|
||||
// still need to deal with latency frames here - i.e.: there are frames
|
||||
/// *** TODO *** ///
|
||||
|
||||
ofSetColor(c, c, c);
|
||||
cout<<"1st third"<<endl;
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
if (_frame_cnt < _frame_cnt_max/3)
|
||||
{
|
||||
c = 0;
|
||||
|
||||
ofSetColor(c, c, c);
|
||||
cout<<"1st third"<<endl;
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
}
|
||||
if (_frame_cnt >= _frame_cnt_max/3 && _frame_cnt < 2*( _frame_cnt_max/3))
|
||||
{
|
||||
c = 255;
|
||||
cout<<"2nd third"<<endl;
|
||||
|
||||
ofSetColor(c, c, c);
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
}
|
||||
if (_frame_cnt >= 2*( _frame_cnt_max/3) && _frame_cnt < _frame_cnt_max)
|
||||
{
|
||||
c = 0;
|
||||
cout<<"3rd third"<<endl;
|
||||
|
||||
ofSetColor(c, c, c);
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
}
|
||||
_frame_cnt++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (_frame_cnt >= _frame_cnt_max/3 && _frame_cnt < 2*( _frame_cnt_max/3))
|
||||
{
|
||||
c = 255;
|
||||
cout<<"2nd third"<<endl;
|
||||
|
||||
ofSetColor(c, c, c);
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
}
|
||||
if (_frame_cnt >= 2*( _frame_cnt_max/3) && _frame_cnt < _frame_cnt_max)
|
||||
{
|
||||
c = 0;
|
||||
cout<<"3rd third"<<endl;
|
||||
|
||||
ofSetColor(c, c, c);
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
}
|
||||
_frame_cnt++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -109,8 +138,12 @@ void LatencyTestAnalysis::save_cb(Timer& timer)
|
||||
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
|
||||
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
string file = _whole_file_path+"/"+file_name;
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
_saved_filenames.push_back(file);
|
||||
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
||||
_RUN_DONE = true;
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
@ -50,7 +50,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||
_speed = 300;
|
||||
}
|
||||
|
||||
void ShadowScapesAnalysis::synthesize()
|
||||
void ShadowScapesAnalysis::acquire()
|
||||
{
|
||||
int w;
|
||||
if(_dir == H) w = ofGetWidth();
|
||||
@ -79,28 +79,58 @@ void ShadowScapesAnalysis::synthesize()
|
||||
|
||||
}
|
||||
|
||||
void ShadowScapesAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
}
|
||||
|
||||
|
||||
// the animation draw - and the output draw
|
||||
void ShadowScapesAnalysis::draw()
|
||||
{
|
||||
|
||||
static int _pos;
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
static int _pos;
|
||||
|
||||
if(_state == STATE_ANALYSIS) {
|
||||
ofSetColor(0, 200, 0);
|
||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||
return;
|
||||
}
|
||||
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;
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
ofSetColor(255, 255, 255);
|
||||
|
||||
if(_dir == H) ofRect(_pos, 0, 50, ofGetHeight());
|
||||
else if(_dir == V) ofRect(0, _pos, ofGetWidth(), 50);
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -50,7 +50,8 @@ public:
|
||||
public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void synthesize();
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void draw();
|
||||
|
||||
void scan_cb(Poco::Timer& timer);
|
||||
|
||||
@ -1,108 +0,0 @@
|
||||
/*
|
||||
- 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)
|
||||
{
|
||||
create_dir();
|
||||
}
|
||||
|
||||
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_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::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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
/*
|
||||
- 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 draw();
|
||||
|
||||
void strobe_cb(Poco::Timer& timer);
|
||||
|
||||
protected:
|
||||
|
||||
int _strobe_cnt;
|
||||
bool _darkness;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user