mid-commit wrong architecture...
AAArrrgghh... NOTE - code not work
This commit is contained in:
parent
060dee771a
commit
dc99776508
5
README
5
README
@ -6,5 +6,6 @@ configuring OpenFrameworks
|
|||||||
these files are configured according to OpenFrameworks addons - http://ofxaddons.com/howto
|
these files are configured according to OpenFrameworks addons - http://ofxaddons.com/howto
|
||||||
|
|
||||||
(1) drag-drop "ReflectiveIndex" folder into your OpenFrameworks project
|
(1) drag-drop "ReflectiveIndex" folder into your OpenFrameworks project
|
||||||
(2) Install depedencies: {ofxDirList, ofxControlPanel, ofxXmlSettings};
|
(2) Install depedencies: {ofxDirList, ofxXmlSettings};
|
||||||
(3) Press Play!
|
(3) Make sure that the config file config/config.refindx is in your "data" folder
|
||||||
|
(4) Press Play!
|
||||||
|
|||||||
@ -26,16 +26,21 @@
|
|||||||
#define CAMERA_ACQU_WIDTH 640
|
#define CAMERA_ACQU_WIDTH 640
|
||||||
#define CAMERA_ACQU_HEIGHT 480
|
#define CAMERA_ACQU_HEIGHT 480
|
||||||
|
|
||||||
#define LOCATION "MIDDLESBOROUGH"
|
#define LOCATION "????-not-config-???"
|
||||||
|
|
||||||
#define ISTATE_UNDEF 0xEEEE
|
#define ISTATE_ACQU_START 0xAAAA
|
||||||
#define ISTATE_START 0xAAAA
|
#define ISTATE_ACQU_STOP 0xBBBB
|
||||||
#define ISTATE_STOP 0xBBBB
|
#define ISTATE_SYNTH_START 0xCCCC
|
||||||
#define ISTATE_TRANSITION 0xCCCC
|
#define ISTATE_SYNTH_STOP 0xDDDD
|
||||||
#define ISTATE_END 0xDDDD
|
|
||||||
|
#define ISTATE_TRANSITION 0xFFFF
|
||||||
|
#define ISTATE_UNDEF 0xEEEE
|
||||||
|
#define ISTATE_END 0x1111
|
||||||
|
|
||||||
int _state = ISTATE_UNDEF;
|
int _state = ISTATE_UNDEF;
|
||||||
|
|
||||||
|
bool _in_acquisition = true;
|
||||||
|
|
||||||
ofPixels RefractiveIndex::_pixels;
|
ofPixels RefractiveIndex::_pixels;
|
||||||
ofVideoGrabber RefractiveIndex::_vidGrabber;
|
ofVideoGrabber RefractiveIndex::_vidGrabber;
|
||||||
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
|
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
|
||||||
@ -89,77 +94,119 @@ void RefractiveIndex::setup()
|
|||||||
|
|
||||||
cout << "RRRRRREADY!" << endl;
|
cout << "RRRRRREADY!" << endl;
|
||||||
|
|
||||||
_analysisAdapator = NULL;
|
|
||||||
|
|
||||||
//getting a warning from the OFlog that the pixels aren't allocated
|
//getting a warning from the OFlog that the pixels aren't allocated
|
||||||
//void ofPixels::allocate(int w, int h, ofImageType type)
|
//void ofPixels::allocate(int w, int h, ofImageType type)
|
||||||
|
|
||||||
|
|
||||||
// setup analysis
|
// setup analysis
|
||||||
|
AnalysisAdaptor* adpt;
|
||||||
|
|
||||||
_analysisVector.push_back(new ShadowScapesAnalysis());
|
adpt = new AnalysisAdaptor(new ShadowScapesAnalysis());
|
||||||
_analysisVector.push_back(new StrobeAnalysis());
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
_analysisVector.push_back(new IResponseAnalysis());
|
adpt = new AnalysisAdaptor(new StrobeAnalysis());
|
||||||
_analysisVector.push_back(new ColorMultiAnalysis());
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
_analysisVector.push_back(new CamFrameRateAnalysis());
|
adpt = new AnalysisAdaptor(new IResponseAnalysis());
|
||||||
_analysisVector.push_back(new CamNoiseAnalysis());
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
_analysisVector.push_back(new ColorSingleAnalysis());
|
adpt = new AnalysisAdaptor(new ColorMultiAnalysis());
|
||||||
_analysisVector.push_back(new LatencyTestAnalysis());
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
_analysisVector.push_back(new DiffNoiseAnalysis());
|
adpt = new AnalysisAdaptor(new CamFrameRateAnalysis());
|
||||||
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
|
adpt = new AnalysisAdaptor(new CamNoiseAnalysis());
|
||||||
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
|
adpt = new AnalysisAdaptor(new ColorSingleAnalysis());
|
||||||
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
|
adpt = new AnalysisAdaptor(new LatencyTestAnalysis());
|
||||||
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
|
adpt = new AnalysisAdaptor(new DiffNoiseAnalysis());
|
||||||
|
_acquisitionMap[adpt->_analysis->_name];
|
||||||
|
|
||||||
_currentAnalysisIndx = 0;
|
_currentAnalysisIndx = _acquisitionMap.begin();
|
||||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx);
|
_currentAnalysisAdaptor = _currentAnalysisIndx->second;
|
||||||
|
_currentAnalysis = _currentAnalysisAdaptor->_analysis;
|
||||||
|
|
||||||
_state = ISTATE_START;
|
_state = ISTATE_ACQU_START;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefractiveIndex::analysis_cb(string & analysis)
|
void RefractiveIndex::acquire_cb(string & analysis)
|
||||||
{
|
{
|
||||||
assert(analysis == _currentAnalysis->_name);
|
assert(analysis == _currentAnalysis->_name);
|
||||||
|
_state = ISTATE_ACQU_STOP;
|
||||||
_state = ISTATE_STOP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RefractiveIndex::synthesize_cb(string & analysis)
|
||||||
|
{
|
||||||
|
TAnalysisMap::iterator it = _synthesisMap.find(analysis);
|
||||||
|
if(it != _synthesisMap.end()) {
|
||||||
|
AnalysisAdaptor* adpt = it->second;
|
||||||
|
AbstractAnalysis* a = adpt->_analysis;
|
||||||
|
adpt->stop();
|
||||||
|
ofRemoveListener(a->_acquire_cb, this, &RefractiveIndex::acquire_cb);
|
||||||
|
ofRemoveListener(a->_synthesize_cb, this, &RefractiveIndex::synthesize_cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
//_state = ISTATE_SYNTH_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RefractiveIndex::start_analysis()
|
void RefractiveIndex::start_analysis()
|
||||||
{
|
{
|
||||||
ofAddListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::analysis_cb);
|
ofAddListener(_currentAnalysis->_acquire_cb, this, &RefractiveIndex::acquire_cb);
|
||||||
_analysisAdapator = new AnalysisAdaptor(_currentAnalysis);
|
ofAddListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::synthesize_cb);
|
||||||
_currentAnalysis->setup(_vid_w, _vid_h);
|
_currentAnalysis->setup(_vid_w, _vid_h);
|
||||||
_analysisAdapator->start();
|
_currentAnalysisAdaptor->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefractiveIndex::stop_analysis()
|
void RefractiveIndex::stop_analysis()
|
||||||
{
|
{
|
||||||
if(_analysisAdapator == NULL) return;
|
if(_currentAnalysisAdaptor == NULL) return;
|
||||||
|
|
||||||
_analysisAdapator->stop(); //blocking
|
_currentAnalysisAdaptor->stop(); //blocking
|
||||||
ofRemoveListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::analysis_cb);
|
ofRemoveListener(_currentAnalysis->_acquire_cb, this, &RefractiveIndex::acquire_cb);
|
||||||
|
ofRemoveListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::synthesize_cb);
|
||||||
_currentAnalysis = NULL;
|
_currentAnalysis = NULL;
|
||||||
delete _analysisAdapator;
|
_currentAnalysisAdaptor = NULL;
|
||||||
_analysisAdapator = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefractiveIndex::state_analysis()
|
void RefractiveIndex::state_machine_analysis()
|
||||||
{
|
{
|
||||||
|
static int synth_cnt = 0;
|
||||||
|
|
||||||
switch (_state) {
|
switch (_state) {
|
||||||
case ISTATE_START:
|
case ISTATE_ACQU_START:
|
||||||
start_analysis();
|
start_analysis();
|
||||||
_state = ISTATE_UNDEF;
|
_state = ISTATE_UNDEF;
|
||||||
break;
|
break;
|
||||||
case ISTATE_TRANSITION:
|
case ISTATE_ACQU_STOP:
|
||||||
if(_currentAnalysisIndx >= _analysisVector.size()) {
|
// continue to synthesis
|
||||||
_currentAnalysisIndx = 0;
|
_acquisitionMap.erase(_currentAnalysisIndx);
|
||||||
_state = ISTATE_END;
|
_synthesisMap[_currentAnalysis->_name] = _currentAnalysisAdaptor;
|
||||||
} else {
|
|
||||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
|
||||||
_state = ISTATE_START;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ISTATE_STOP:
|
|
||||||
stop_analysis(); // blocking
|
|
||||||
_state = ISTATE_TRANSITION;
|
_state = ISTATE_TRANSITION;
|
||||||
break;
|
break;
|
||||||
|
case ISTATE_TRANSITION:
|
||||||
|
if(_currentAnalysisIndx != _acquisitionMap.end()) {
|
||||||
|
_currentAnalysisIndx++;
|
||||||
|
_currentAnalysisAdaptor = _currentAnalysisIndx->second;
|
||||||
|
_currentAnalysis = _currentAnalysisAdaptor->_analysis;
|
||||||
|
} else {
|
||||||
|
if(_synthesisMap.size() > 0) {
|
||||||
|
if(_in_acquisition) {
|
||||||
|
_currentAnalysisIndx = _synthesisMap.begin();
|
||||||
|
_in_acquisition = false;
|
||||||
|
}
|
||||||
|
if(!_acquisitionMap.empty() && _currentAnalysisIndx != _synthesisMap.end()) {
|
||||||
|
_currentAnalysisIndx++;
|
||||||
|
_currentAnalysisAdaptor = _currentAnalysisIndx->second;
|
||||||
|
_currentAnalysis = _currentAnalysisAdaptor->_analysis;
|
||||||
|
_state = ISTATE_UNDEF;
|
||||||
|
} else if(_acquisitionMap.empty()) {
|
||||||
|
_state = ISTATE_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ISTATE_SYNTH_STOP:
|
||||||
|
|
||||||
case ISTATE_END:
|
case ISTATE_END:
|
||||||
stop_camera();
|
stop_camera();
|
||||||
::exit(1);
|
::exit(1);
|
||||||
@ -173,7 +220,7 @@ void RefractiveIndex::state_analysis()
|
|||||||
|
|
||||||
void RefractiveIndex::update()
|
void RefractiveIndex::update()
|
||||||
{
|
{
|
||||||
state_analysis();
|
state_machine_analysis();
|
||||||
|
|
||||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||||
|
|
||||||
|
|||||||
@ -8,12 +8,14 @@
|
|||||||
|
|
||||||
#include "ofMain.h"
|
#include "ofMain.h"
|
||||||
#include "ofEvents.h"
|
#include "ofEvents.h"
|
||||||
//#include "ofxControlPanel.h"
|
|
||||||
|
|
||||||
#include "AbstractAnalysis.h"
|
#include "AbstractAnalysis.h"
|
||||||
#include "AnalysisAdaptor.h"
|
#include "AnalysisAdaptor.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef map<string, AnalysisAdaptor*> TAnalysisMap;
|
||||||
|
typedef vector<AnalysisAdaptor*> TAnalysisVec;
|
||||||
|
|
||||||
class RefractiveIndex : public ofBaseApp
|
class RefractiveIndex : public ofBaseApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -24,13 +26,22 @@ public:
|
|||||||
void draw();
|
void draw();
|
||||||
void exit();
|
void exit();
|
||||||
|
|
||||||
// refindx
|
// camera
|
||||||
void setup_camera();
|
void setup_camera();
|
||||||
void stop_camera();
|
void stop_camera();
|
||||||
void analysis_cb(string & analysis);
|
|
||||||
|
// starts the whole process
|
||||||
void start_analysis();
|
void start_analysis();
|
||||||
|
|
||||||
|
// stops the whole process
|
||||||
void stop_analysis();
|
void stop_analysis();
|
||||||
void state_analysis();
|
|
||||||
|
// callbacks
|
||||||
|
void acquire_cb(string & analysis);
|
||||||
|
void synthesize_cb(string & analysis);
|
||||||
|
|
||||||
|
// state machine
|
||||||
|
void state_machine_analysis();
|
||||||
|
|
||||||
// ofx
|
// ofx
|
||||||
void keyPressed (int key);
|
void keyPressed (int key);
|
||||||
@ -43,16 +54,16 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//void eventsIn(guiCallbackData & data);
|
|
||||||
//void grabBackgroundEvent(guiCallbackData & data);
|
|
||||||
|
|
||||||
// gui
|
|
||||||
//ofxControlPanel _gui;
|
|
||||||
|
|
||||||
AbstractAnalysis* _currentAnalysis;
|
AbstractAnalysis* _currentAnalysis;
|
||||||
int _currentAnalysisIndx;
|
AnalysisAdaptor* _currentAnalysisAdaptor;
|
||||||
AnalysisAdaptor* _analysisAdapator;
|
AnalysisAdaptor* _currentSynthesisAdaptor;
|
||||||
vector<AbstractAnalysis*> _analysisVector;
|
TAnalysisMap::iterator _currentAnalysisIndx;
|
||||||
|
|
||||||
|
TAnalysisMap _acquisitionMap;
|
||||||
|
TAnalysisMap _synthesisMap;
|
||||||
|
|
||||||
|
TAnalysisVec _display_results_vector;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// acquisition
|
// acquisition
|
||||||
@ -66,5 +77,4 @@ public:
|
|||||||
// this should be in xml
|
// this should be in xml
|
||||||
static string _location;
|
static string _location;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -34,7 +34,13 @@
|
|||||||
#include "RefractiveIndex.h"
|
#include "RefractiveIndex.h"
|
||||||
|
|
||||||
void AbstractAnalysis::do_synthesize() {
|
void AbstractAnalysis::do_synthesize() {
|
||||||
|
// acquire images + pattern on display
|
||||||
|
pattern_acquire();
|
||||||
|
// acquire notify obeservers
|
||||||
|
ofNotifyEvent(_acquire_cb, _name);
|
||||||
|
// analysis and synthesis of acquired images
|
||||||
synthesize();
|
synthesize();
|
||||||
|
// synthesize notify obeservers
|
||||||
ofNotifyEvent(_synthesize_cb, _name);
|
ofNotifyEvent(_synthesize_cb, _name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,16 +28,20 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
// creates working directory
|
||||||
virtual void create_dir();
|
virtual void create_dir();
|
||||||
|
|
||||||
// the runnable function in the thread
|
// acquire images from camera and display patters on screen
|
||||||
|
virtual void pattern_acquire() = 0;
|
||||||
|
|
||||||
|
// analyses and sythesizes images acquired
|
||||||
virtual void synthesize() = 0;
|
virtual void synthesize() = 0;
|
||||||
// this means that this function needs to be overwritten by children that inherit this class
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string _name;
|
string _name;
|
||||||
|
|
||||||
// event
|
// event notification / callbacks
|
||||||
|
ofEvent<string> _acquire_cb;
|
||||||
ofEvent<string> _synthesize_cb;
|
ofEvent<string> _synthesize_cb;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -31,8 +31,10 @@ public:
|
|||||||
_worker.join();
|
_worker.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
AbstractAnalysis* _analysis;
|
AbstractAnalysis* _analysis;
|
||||||
|
|
||||||
|
protected:
|
||||||
Thread _worker; //
|
Thread _worker; //
|
||||||
RunnableAdapter<AbstractAnalysis>* _runnable;
|
RunnableAdapter<AbstractAnalysis>* _runnable;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user