2012-02-21 01:34:24 +01:00
|
|
|
|
2012-02-20 19:48:43 +01:00
|
|
|
////also the new shit////
|
|
|
|
|
|
2012-01-24 15:13:07 +01:00
|
|
|
#include "RefractiveIndex.h"
|
|
|
|
|
|
|
|
|
|
#include "ShadowScapesAnalysis.h"
|
2012-02-18 20:37:22 +01:00
|
|
|
#include "RelaxRateAnalysis.h"
|
|
|
|
|
#include "IResponseAnalysis.h"
|
|
|
|
|
#include "ShapeFromShadingAnalysis.h"
|
|
|
|
|
#include "StrobeAnalysis.h"
|
2012-01-24 16:52:22 +01:00
|
|
|
#include "CamNoiseAnalysis.h"
|
2012-02-18 20:37:22 +01:00
|
|
|
#include "ColorSingleAnalysis.h"
|
|
|
|
|
#include "ColorMultiAnalysis.h"
|
2012-01-24 16:52:22 +01:00
|
|
|
#include "DiffNoiseAnalysis.h"
|
2012-01-24 15:13:07 +01:00
|
|
|
|
2012-02-11 18:54:46 +01:00
|
|
|
#include "ofxXmlSettings.h"
|
2012-02-21 01:34:24 +01:00
|
|
|
|
2012-02-28 20:13:08 +01:00
|
|
|
#define CAMERA_ID 0
|
2012-01-24 15:13:07 +01:00
|
|
|
#define CAMERA_ACQU_WIDTH 640
|
|
|
|
|
#define CAMERA_ACQU_HEIGHT 480
|
|
|
|
|
|
2012-04-12 10:21:37 +01:00
|
|
|
#define LOCATION "BRADFORD"
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
#define ISTATE_UNDEF 0xEEEE
|
|
|
|
|
#define ISTATE_START 0xAAAA
|
|
|
|
|
#define ISTATE_STOP 0xBBBB
|
|
|
|
|
#define ISTATE_TRANSITION 0xCCCC
|
|
|
|
|
#define ISTATE_END 0xDDDD
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-04-06 18:46:38 +02:00
|
|
|
|
2012-02-11 18:54:46 +01:00
|
|
|
int _state = ISTATE_UNDEF;
|
|
|
|
|
|
2012-04-06 18:46:38 +02:00
|
|
|
int RefractiveIndex::_mode;
|
2012-01-24 16:52:22 +01:00
|
|
|
ofPixels RefractiveIndex::_pixels;
|
|
|
|
|
ofVideoGrabber RefractiveIndex::_vidGrabber;
|
|
|
|
|
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
|
|
|
|
|
bool RefractiveIndex::_vid_stream_open;
|
|
|
|
|
bool RefractiveIndex::_vid_toggle_on;
|
|
|
|
|
string RefractiveIndex::_location;
|
|
|
|
|
|
2012-02-22 19:41:16 +01:00
|
|
|
ofxXmlSettings RefractiveIndex::XML;
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-01-24 15:13:07 +01:00
|
|
|
void RefractiveIndex::setup()
|
|
|
|
|
{
|
2012-02-11 18:54:46 +01:00
|
|
|
bool save_config = false;
|
|
|
|
|
|
|
|
|
|
cout << "Loading configuration..." << endl;
|
2012-02-21 01:01:49 +01:00
|
|
|
if(XML.loadFile("config.refindx") == false) {
|
2012-02-11 18:54:46 +01:00
|
|
|
ofLog(OF_LOG_ERROR) << "error loading config - using default.";
|
|
|
|
|
save_config = true;
|
2012-02-21 01:01:49 +01:00
|
|
|
} else {
|
|
|
|
|
XML.loadFile("config.refindx");
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|
2012-04-06 18:46:38 +02:00
|
|
|
|
|
|
|
|
// <mode>
|
|
|
|
|
string m = XML.getValue("config:mode", "analysing");
|
|
|
|
|
_mode = (m == "analysing" ? MODE_ANALYSING : (m == "drawing" ? MODE_DRAWING : MODE_ANALYSING));
|
2012-02-11 18:54:46 +01:00
|
|
|
|
|
|
|
|
// <camera>
|
|
|
|
|
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
|
2012-02-23 01:22:14 +00:00
|
|
|
cout << "_vid_id: " << _vid_id << endl;
|
|
|
|
|
|
2012-02-21 01:01:49 +01:00
|
|
|
_vid_w = XML.getValue("config:camera:width", CAMERA_ACQU_WIDTH);
|
|
|
|
|
_vid_h = XML.getValue("config:camera:height", CAMERA_ACQU_HEIGHT);
|
2012-02-11 18:54:46 +01:00
|
|
|
|
|
|
|
|
// <display>
|
|
|
|
|
int fps = XML.getValue("config:display:fps", 30);
|
|
|
|
|
|
|
|
|
|
// <location>
|
|
|
|
|
_location = XML.getValue("config:locale:name", LOCATION);
|
|
|
|
|
|
|
|
|
|
cout << "Configuring..." << endl;
|
|
|
|
|
|
|
|
|
|
// display
|
|
|
|
|
cout << "> display" << endl;
|
|
|
|
|
ofSetFrameRate(fps);
|
2012-02-19 23:34:48 +01:00
|
|
|
|
2012-02-11 18:54:46 +01:00
|
|
|
if(fps > 30) {
|
|
|
|
|
ofSetVerticalSync(FALSE);
|
|
|
|
|
} else {
|
|
|
|
|
ofSetVerticalSync(TRUE);
|
|
|
|
|
}
|
|
|
|
|
cout << "* fps = " << fps << endl;
|
|
|
|
|
|
2012-01-24 15:13:07 +01:00
|
|
|
// camera
|
2012-02-11 18:54:46 +01:00
|
|
|
cout << "> camera" << endl;
|
|
|
|
|
cout << "* cam id = " << _vid_id << endl;
|
|
|
|
|
cout << "* cam width = " << _vid_w << endl;
|
|
|
|
|
cout << "* cam height = " << _vid_h << endl;
|
|
|
|
|
|
2012-04-06 18:46:38 +02:00
|
|
|
if(_mode == MODE_ANALYSING) {
|
|
|
|
|
_vid_stream_open = false;
|
|
|
|
|
setup_camera();
|
|
|
|
|
}
|
2012-02-11 18:54:46 +01:00
|
|
|
|
|
|
|
|
cout << "RRRRRREADY!" << endl;
|
2012-01-24 15:13:07 +01:00
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
_analysisAdapator = NULL;
|
|
|
|
|
|
2012-02-11 18:54:46 +01:00
|
|
|
//getting a warning from the OFlog that the pixels aren't allocated
|
2012-02-12 09:39:36 +01:00
|
|
|
//void ofPixels::allocate(int w, int h, ofImageType type)
|
2012-02-20 19:48:43 +01:00
|
|
|
_pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR);
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-04-12 10:21:37 +01:00
|
|
|
|
2012-02-18 20:37:22 +01:00
|
|
|
//TODO: whichever one of these is first - it always runs twice ?
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-02-21 21:45:18 +01:00
|
|
|
_analysisVector.push_back(new ShadowScapesAnalysis(V));
|
|
|
|
|
_analysisVector.push_back(new ShadowScapesAnalysis(H));
|
|
|
|
|
_analysisVector.push_back(new ShadowScapesAnalysis(D));
|
2012-02-28 20:13:08 +01:00
|
|
|
|
2012-02-21 01:39:27 +01:00
|
|
|
_analysisVector.push_back(new RelaxRateAnalysis());
|
2012-02-18 20:37:22 +01:00
|
|
|
|
2012-02-28 20:13:08 +01:00
|
|
|
|
2012-02-21 01:39:27 +01:00
|
|
|
_analysisVector.push_back(new IResponseAnalysis());
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-02-18 20:37:22 +01:00
|
|
|
_analysisVector.push_back(new ShapeFromShadingAnalysis());
|
|
|
|
|
|
2012-02-21 01:39:27 +01:00
|
|
|
_analysisVector.push_back(new StrobeAnalysis());
|
2012-02-18 20:37:22 +01:00
|
|
|
|
2012-02-21 01:39:27 +01:00
|
|
|
_analysisVector.push_back(new CamNoiseAnalysis());
|
2012-02-18 20:37:22 +01:00
|
|
|
|
2012-02-21 01:39:27 +01:00
|
|
|
_analysisVector.push_back(new ColorSingleAnalysis());
|
2012-02-18 20:37:22 +01:00
|
|
|
|
2012-02-21 01:39:27 +01:00
|
|
|
_analysisVector.push_back(new ColorMultiAnalysis());
|
2012-02-18 20:37:22 +01:00
|
|
|
|
2012-02-28 20:13:08 +01:00
|
|
|
_analysisVector.push_back(new DiffNoiseAnalysis());
|
2012-02-26 19:12:34 +01:00
|
|
|
|
2012-02-26 16:58:18 +01:00
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
//_currentAnalysisIndx = 0;
|
|
|
|
|
//_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
|
|
|
|
//_state = ISTATE_START;
|
|
|
|
|
|
|
|
|
|
_currentAnalysis = NULL;
|
|
|
|
|
_state = ISTATE_UNDEF;
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-04-12 10:21:37 +01:00
|
|
|
fbo.allocate(_vid_w,_vid_h);
|
|
|
|
|
_meshRotation=0;
|
|
|
|
|
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|
2012-01-24 15:13:07 +01:00
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
void RefractiveIndex::analysis_cb(string & analysis)
|
2012-02-11 18:54:46 +01:00
|
|
|
{
|
2012-02-15 07:58:30 +01:00
|
|
|
assert(analysis == _currentAnalysis->_name);
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
_state = ISTATE_STOP;
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|
2012-01-24 15:13:07 +01:00
|
|
|
|
2012-02-11 18:54:46 +01:00
|
|
|
void RefractiveIndex::start_analysis()
|
|
|
|
|
{
|
2012-02-15 07:58:30 +01:00
|
|
|
ofAddListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::analysis_cb);
|
|
|
|
|
_analysisAdapator = new AnalysisAdaptor(_currentAnalysis);
|
2012-02-11 18:54:46 +01:00
|
|
|
_currentAnalysis->setup(_vid_w, _vid_h);
|
2012-02-15 07:58:30 +01:00
|
|
|
_analysisAdapator->start();
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|
2012-01-24 16:52:22 +01:00
|
|
|
|
2012-02-11 18:54:46 +01:00
|
|
|
void RefractiveIndex::stop_analysis()
|
|
|
|
|
{
|
2012-02-15 07:58:30 +01:00
|
|
|
if(_analysisAdapator == NULL) return;
|
2012-02-11 18:54:46 +01:00
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
_analysisAdapator->stop(); //blocking
|
|
|
|
|
ofRemoveListener(_currentAnalysis->_synthesize_cb, this, &RefractiveIndex::analysis_cb);
|
2012-01-24 15:13:07 +01:00
|
|
|
_currentAnalysis = NULL;
|
2012-02-15 07:58:30 +01:00
|
|
|
delete _analysisAdapator;
|
|
|
|
|
_analysisAdapator = NULL;
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|
2012-01-24 16:52:22 +01:00
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
void RefractiveIndex::state_analysis()
|
2012-02-11 18:54:46 +01:00
|
|
|
{
|
|
|
|
|
switch (_state) {
|
2012-02-15 07:58:30 +01:00
|
|
|
case ISTATE_START:
|
2012-02-11 18:54:46 +01:00
|
|
|
start_analysis();
|
|
|
|
|
_state = ISTATE_UNDEF;
|
|
|
|
|
break;
|
2012-02-15 07:58:30 +01:00
|
|
|
case ISTATE_TRANSITION:
|
|
|
|
|
if(_currentAnalysisIndx >= _analysisVector.size()) {
|
|
|
|
|
_currentAnalysisIndx = 0;
|
2012-02-21 21:18:25 +01:00
|
|
|
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
|
|
|
|
_state = ISTATE_START;
|
|
|
|
|
//_state = ISTATE_END;
|
2012-02-11 18:54:46 +01:00
|
|
|
} else {
|
2012-02-15 07:58:30 +01:00
|
|
|
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
|
|
|
|
_state = ISTATE_START;
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|
2012-02-15 07:58:30 +01:00
|
|
|
break;
|
|
|
|
|
case ISTATE_STOP:
|
|
|
|
|
stop_analysis(); // blocking
|
2012-04-06 18:46:38 +02:00
|
|
|
if(_mode == MODE_DRAWING)
|
|
|
|
|
_state = ISTATE_UNDEF;
|
|
|
|
|
else
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-15 07:58:30 +01:00
|
|
|
break;
|
2012-02-11 18:54:46 +01:00
|
|
|
case ISTATE_END:
|
2012-04-06 18:46:38 +02:00
|
|
|
if(_mode == MODE_ANALYSING)
|
|
|
|
|
stop_camera();
|
2012-02-12 09:39:36 +01:00
|
|
|
::exit(1);
|
2012-02-11 18:54:46 +01:00
|
|
|
break;
|
|
|
|
|
case ISTATE_UNDEF:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-01-24 15:13:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RefractiveIndex::update()
|
2012-02-21 21:18:25 +01:00
|
|
|
{
|
2012-02-15 07:58:30 +01:00
|
|
|
state_analysis();
|
2012-01-24 15:13:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RefractiveIndex::draw()
|
|
|
|
|
{
|
2012-02-23 01:22:14 +00:00
|
|
|
// refractive mauve - this doesn't work... looks weird in various places.
|
2012-02-21 21:18:25 +01:00
|
|
|
//ofBackground(113, 110, 136);
|
|
|
|
|
|
|
|
|
|
// black
|
2012-01-24 16:52:22 +01:00
|
|
|
ofBackground(0, 0, 0);
|
2012-02-21 01:50:47 +01:00
|
|
|
|
2012-04-12 10:21:37 +01:00
|
|
|
if(_currentAnalysis){
|
2012-01-24 15:13:07 +01:00
|
|
|
_currentAnalysis->draw();
|
2012-04-12 10:21:37 +01:00
|
|
|
cout<<_currentAnalysis->meshIsComplete<<endl;
|
|
|
|
|
if(_currentAnalysis->meshIsComplete){
|
|
|
|
|
fbo.begin();
|
|
|
|
|
|
|
|
|
|
ofSetColor(0, 0, 0);
|
|
|
|
|
ofRect(0, 0, fbo.getWidth(), fbo.getHeight());
|
|
|
|
|
ofPushMatrix();
|
|
|
|
|
ofTranslate(fbo.getWidth()/2, fbo.getHeight()/2);
|
|
|
|
|
ofRotateY(_meshRotation );
|
|
|
|
|
ofTranslate(-fbo.getWidth()/2, -fbo.getHeight()/2);
|
|
|
|
|
_meshRotation+=0.5;
|
|
|
|
|
_currentAnalysis->aMesh.draw();
|
|
|
|
|
fbo.end();
|
|
|
|
|
ofPixels pixels;
|
|
|
|
|
fbo.readToPixels(pixels);
|
|
|
|
|
cout<<_currentAnalysis->meshFileName<<endl;
|
|
|
|
|
|
|
|
|
|
ofSaveImage(pixels,_currentAnalysis->meshFileName, OF_IMAGE_QUALITY_BEST);
|
|
|
|
|
//saving jpgs doesn't work maybe because of of_image_quality
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-01-24 15:13:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RefractiveIndex::setup_camera()
|
|
|
|
|
{
|
2012-02-12 09:39:36 +01:00
|
|
|
stop_camera();
|
2012-02-21 19:31:58 +01:00
|
|
|
|
2012-02-23 01:22:14 +00:00
|
|
|
// THIS IS LOADED IN FROM THE XML FILE SETTINGS
|
2012-02-21 19:31:58 +01:00
|
|
|
_vidGrabber.setDeviceID(_vid_id);
|
2012-02-23 01:22:14 +00:00
|
|
|
_vidGrabber.listDevices();
|
2012-02-21 19:31:58 +01:00
|
|
|
|
|
|
|
|
if(!_vidGrabber.initGrabber(_vid_w, _vid_h)) {
|
2012-01-24 15:13:07 +01:00
|
|
|
ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber";
|
|
|
|
|
return;
|
2012-01-24 16:52:22 +01:00
|
|
|
}
|
2012-02-21 19:31:58 +01:00
|
|
|
|
|
|
|
|
_vidGrabber.setVerbose(true);
|
2012-02-20 20:24:25 +01:00
|
|
|
_vidGrabber.setUseTexture(false);
|
2012-01-24 15:13:07 +01:00
|
|
|
_vid_stream_open = true;
|
2012-02-21 19:31:58 +01:00
|
|
|
cout << "CAMERA SETUP " << endl;
|
|
|
|
|
return;
|
|
|
|
|
|
2012-01-24 15:13:07 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-12 09:39:36 +01:00
|
|
|
void RefractiveIndex::stop_camera()
|
|
|
|
|
{
|
|
|
|
|
if(_vid_stream_open) {
|
|
|
|
|
_vidGrabber.close();
|
|
|
|
|
_vid_stream_open = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-24 15:13:07 +01:00
|
|
|
void RefractiveIndex::keyPressed (int key)
|
|
|
|
|
{
|
|
|
|
|
if( key =='f')
|
2012-01-24 16:52:22 +01:00
|
|
|
ofToggleFullscreen();
|
2012-02-19 23:34:48 +01:00
|
|
|
|
|
|
|
|
/* TODO: complete the below... would be good to trigger the Analysis from keypresses if needed... */
|
|
|
|
|
// currently this doesn't work... the save_cb's in the individual
|
|
|
|
|
// tried to add a stop_analysis(); call but it blocks the whole programme
|
|
|
|
|
|
|
|
|
|
// i.e.: ask david how to shut off the prior Analysis if it's not finished running from here?
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
if(key == 'x')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysis = NULL;
|
|
|
|
|
_state = ISTATE_UNDEF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(key == '1')
|
|
|
|
|
{
|
|
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 0;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '2')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 1;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '3')
|
|
|
|
|
{
|
|
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 2;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '4')
|
|
|
|
|
{
|
|
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 3;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(key == '5')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 4;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '6')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 5;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '7')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 6;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '8')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 7;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '9')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 8;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 21:18:25 +01:00
|
|
|
else if(key == '0')
|
|
|
|
|
{
|
|
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 9;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(key == 'q')
|
2012-02-19 23:34:48 +01:00
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
|
|
|
|
_currentAnalysisIndx = 10;
|
|
|
|
|
if(!_currentAnalysis)
|
|
|
|
|
_state = ISTATE_TRANSITION;
|
2012-02-19 23:34:48 +01:00
|
|
|
}
|
2012-02-21 01:50:47 +01:00
|
|
|
|
2012-02-23 01:22:14 +00:00
|
|
|
/*
|
|
|
|
|
TO DO: add a file dialog so we can save images to another hard drive...
|
|
|
|
|
e.g.: http://dev.openframeworks.cc/pipermail/of-dev-openframeworks.cc/2011-April/003125.html
|
|
|
|
|
|
|
|
|
|
>> case 's':
|
|
|
|
|
>> doSave ^= true;
|
|
|
|
|
>> doLoad = false;
|
|
|
|
|
>> if(doSave) {
|
|
|
|
|
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to save to", true);
|
|
|
|
|
>> if(r.bSuccess) {
|
|
|
|
|
>> saveCounter = 0;
|
|
|
|
|
>> savePath = r.getPath();
|
|
|
|
|
>> ofDirectory::createDirectory(savePath + "/color/");
|
|
|
|
|
>> ofDirectory::createDirectory(savePath + "/depth/");
|
|
|
|
|
>> printf("SAVE %s %s\n", r.getPath().c_str(), r.getName().c_str());
|
|
|
|
|
>> } else {
|
|
|
|
|
>> doSave = false;
|
|
|
|
|
>> }
|
|
|
|
|
>>
|
|
|
|
|
>> }
|
|
|
|
|
>> break;
|
|
|
|
|
>>
|
|
|
|
|
>> case 'l':
|
|
|
|
|
>> doLoad ^= true;
|
|
|
|
|
>> doSave = false;
|
|
|
|
|
>> if(doLoad) {
|
|
|
|
|
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to load from", true);
|
|
|
|
|
>> if(r.bSuccess) {
|
|
|
|
|
>> loadCounter = 0;
|
|
|
|
|
>> loadPath = r.getPath();
|
|
|
|
|
>> ofDirectory dir;
|
|
|
|
|
>> loadMaxFiles = MAX(dir.listDir(loadPath + "/color"), dir.listDir(loadPath + "/depth"));
|
|
|
|
|
>> printf("LOAD %i %s %s\n", loadMaxFiles, r.getPath().c_str(), r.getName().c_str());
|
|
|
|
|
>> } else {
|
|
|
|
|
>> doLoad = false;
|
|
|
|
|
>> }
|
|
|
|
|
>>
|
|
|
|
|
>> }
|
|
|
|
|
>> break;
|
|
|
|
|
*/
|
|
|
|
|
|
2012-02-21 01:50:47 +01:00
|
|
|
|
2012-02-12 09:39:36 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
void RefractiveIndex::exit()
|
2012-02-12 09:39:36 +01:00
|
|
|
{
|
2012-02-27 19:39:35 +01:00
|
|
|
if(_currentAnalysis)
|
|
|
|
|
_analysisAdapator->stop();
|
2012-02-12 09:39:36 +01:00
|
|
|
stop_camera();
|
2012-02-11 18:54:46 +01:00
|
|
|
}
|