key input controls
This commit is contained in:
parent
2903c7a969
commit
3c13d95bc4
@ -94,9 +94,9 @@ void RefractiveIndex::setup()
|
||||
|
||||
//TODO: whichever one of these is first - it always runs twice ?
|
||||
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(V));
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(H));
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(D));
|
||||
//_analysisVector.push_back(new ShadowScapesAnalysis(V));
|
||||
//_analysisVector.push_back(new ShadowScapesAnalysis(H));
|
||||
//_analysisVector.push_back(new ShadowScapesAnalysis(D));
|
||||
|
||||
_analysisVector.push_back(new RelaxRateAnalysis());
|
||||
|
||||
@ -114,10 +114,13 @@ void RefractiveIndex::setup()
|
||||
|
||||
_analysisVector.push_back(new DiffNoiseAnalysis());
|
||||
|
||||
_currentAnalysisIndx = 0;
|
||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
//_currentAnalysisIndx = 0;
|
||||
//_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
|
||||
_state = ISTATE_START;
|
||||
//_state = ISTATE_START;
|
||||
|
||||
_currentAnalysis = NULL;
|
||||
_state = ISTATE_UNDEF;
|
||||
|
||||
}
|
||||
|
||||
@ -157,7 +160,9 @@ void RefractiveIndex::state_analysis()
|
||||
case ISTATE_TRANSITION:
|
||||
if(_currentAnalysisIndx >= _analysisVector.size()) {
|
||||
_currentAnalysisIndx = 0;
|
||||
_state = ISTATE_END;
|
||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
_state = ISTATE_START;
|
||||
//_state = ISTATE_END;
|
||||
} else {
|
||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
_state = ISTATE_START;
|
||||
@ -181,21 +186,14 @@ void RefractiveIndex::state_analysis()
|
||||
void RefractiveIndex::update()
|
||||
{
|
||||
state_analysis();
|
||||
|
||||
// this has been moved to each class
|
||||
/*
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (_vidGrabber.isFrameNew())
|
||||
{
|
||||
_pixels = _vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void RefractiveIndex::draw()
|
||||
{
|
||||
// refractive mauve
|
||||
//ofBackground(113, 110, 136);
|
||||
|
||||
// black
|
||||
ofBackground(0, 0, 0);
|
||||
|
||||
//TODO: Needs to return to a black screen - not to exit...
|
||||
@ -252,78 +250,112 @@ void RefractiveIndex::keyPressed (int key)
|
||||
|
||||
// i.e.: ask david how to shut off the prior Analysis if it's not finished running from here?
|
||||
|
||||
/*
|
||||
if(key == '1')
|
||||
if(key == 'x')
|
||||
{
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(0);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysis = NULL;
|
||||
_state = ISTATE_UNDEF;
|
||||
}
|
||||
|
||||
if(key == '2')
|
||||
else if(key == '1')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(1);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 0;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
if(key == '3')
|
||||
else if(key == '2')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(2);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 1;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
if(key == '4')
|
||||
else if(key == '3')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(3);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 2;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
if(key == '5')
|
||||
else if(key == '4')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(4);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 3;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
if(key == '6')
|
||||
else if(key == '5')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(5);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 4;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
if(key == '7')
|
||||
else if(key == '6')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(6);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 5;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
if(key == '8')
|
||||
else if(key == '7')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(7);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 6;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
if(key == '9')
|
||||
else if(key == '8')
|
||||
{
|
||||
|
||||
// something needs to go here to cancel the prior analysis
|
||||
_currentAnalysis = _analysisVector.at(8);
|
||||
_state = ISTATE_START;
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 7;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
else if(key == '9')
|
||||
{
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 8;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
else if(key == '0')
|
||||
{
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 9;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
|
||||
else if(key == 'q')
|
||||
{
|
||||
if(_currentAnalysis)
|
||||
_analysisAdapator->stop();
|
||||
_currentAnalysisIndx = 10;
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -36,13 +36,16 @@
|
||||
|
||||
// this is the main threaded loop for a given analysis
|
||||
void AbstractAnalysis::do_synthesize() {
|
||||
_saved_filenames.clear();
|
||||
_state = STATE_ACQUIRING;
|
||||
acquire();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_SYNTHESISING;
|
||||
synthesise();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
displayresults();
|
||||
|
||||
exit:
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
}
|
||||
|
||||
|
||||
@ -21,12 +21,15 @@ public:
|
||||
|
||||
void start()
|
||||
{
|
||||
_stopping = false;
|
||||
_runnable = new RunnableAdapter<AbstractAnalysis>(*_analysis, &AbstractAnalysis::do_synthesize);
|
||||
_worker.start(*_runnable);
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
if(_stopping) return;
|
||||
_stopping = true;
|
||||
_analysis->_state = STATE_STOP;
|
||||
_worker.join();
|
||||
}
|
||||
@ -35,5 +38,6 @@ protected:
|
||||
AbstractAnalysis* _analysis;
|
||||
Thread _worker; //
|
||||
RunnableAdapter<AbstractAnalysis>* _runnable;
|
||||
bool _stopping;
|
||||
};
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ void CamNoiseAnalysis::acquire()
|
||||
|
||||
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -77,7 +77,7 @@ void CamNoiseAnalysis::acquire()
|
||||
void CamNoiseAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ void ColorMultiAnalysis::acquire()
|
||||
|
||||
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -77,6 +77,8 @@ void ColorMultiAnalysis::acquire()
|
||||
void ColorMultiAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
void ColorMultiAnalysis::displayresults()
|
||||
@ -84,6 +86,8 @@ void ColorMultiAnalysis::displayresults()
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
|
||||
@ -73,7 +73,7 @@ void ColorSingleAnalysis::acquire()
|
||||
|
||||
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -84,7 +84,7 @@ void ColorSingleAnalysis::acquire()
|
||||
void ColorSingleAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
@ -93,6 +93,8 @@ void ColorSingleAnalysis::displayresults()
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
|
||||
@ -65,7 +65,7 @@ void DiffNoiseAnalysis::acquire()
|
||||
|
||||
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -75,7 +75,7 @@ void DiffNoiseAnalysis::acquire()
|
||||
void DiffNoiseAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
}
|
||||
@ -85,6 +85,8 @@ void DiffNoiseAnalysis::displayresults()
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
|
||||
@ -61,7 +61,7 @@ void IResponseAnalysis::acquire()
|
||||
_RUN_DONE = false;
|
||||
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -74,7 +74,7 @@ void IResponseAnalysis::acquire()
|
||||
void IResponseAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
@ -84,6 +84,8 @@ void IResponseAnalysis::displayresults()
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
|
||||
@ -61,7 +61,7 @@ void RelaxRateAnalysis::acquire()
|
||||
_RUN_DONE = false;
|
||||
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -74,7 +74,7 @@ void RelaxRateAnalysis::synthesise()
|
||||
{
|
||||
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
}
|
||||
@ -84,6 +84,8 @@ void RelaxRateAnalysis::displayresults()
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
|
||||
@ -78,7 +78,7 @@ void ShapeFromShadingAnalysis::acquire()
|
||||
_animation_cnt16 = 0;
|
||||
_animation_reset = false; // coundn't get this to work - so using seperate counters - shitty!
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -90,7 +90,7 @@ void ShapeFromShadingAnalysis::acquire()
|
||||
|
||||
void ShapeFromShadingAnalysis::synthesise()
|
||||
{
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
@ -99,6 +99,8 @@ void ShapeFromShadingAnalysis::displayresults()
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
|
||||
@ -64,7 +64,7 @@ void StrobeAnalysis::acquire()
|
||||
|
||||
_frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; _strobe_cnt = 0;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer->stop();
|
||||
@ -76,7 +76,7 @@ void StrobeAnalysis::acquire()
|
||||
void StrobeAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
@ -85,6 +85,8 @@ void StrobeAnalysis::displayresults()
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user