beginning to integrate dviid's code

This commit is contained in:
Jamie Allen 2012-04-08 20:18:44 +02:00
parent 877123a2db
commit 327830a581
3 changed files with 70 additions and 52 deletions

View File

@ -27,8 +27,10 @@
#define ISTATE_TRANSITION 0xCCCC
#define ISTATE_END 0xDDDD
int _state = ISTATE_UNDEF;
int RefractiveIndex::_mode;
ofPixels RefractiveIndex::_pixels;
ofVideoGrabber RefractiveIndex::_vidGrabber;
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
@ -50,6 +52,10 @@ void RefractiveIndex::setup()
XML.loadFile("config.refindx");
}
// <mode>
string m = XML.getValue("config:mode", "analysing");
_mode = (m == "analysing" ? MODE_ANALYSING : (m == "drawing" ? MODE_DRAWING : MODE_ANALYSING));
// <camera>
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
cout << "_vid_id: " << _vid_id << endl;
@ -82,8 +88,10 @@ void RefractiveIndex::setup()
cout << "* cam width = " << _vid_w << endl;
cout << "* cam height = " << _vid_h << endl;
_vid_stream_open = false;
setup_camera();
if(_mode == MODE_ANALYSING) {
_vid_stream_open = false;
setup_camera();
}
cout << "RRRRRREADY!" << endl;
@ -173,10 +181,14 @@ void RefractiveIndex::state_analysis()
break;
case ISTATE_STOP:
stop_analysis(); // blocking
_state = ISTATE_TRANSITION;
if(_mode == MODE_DRAWING)
_state = ISTATE_UNDEF;
else
_state = ISTATE_TRANSITION;
break;
case ISTATE_END:
stop_camera();
if(_mode == MODE_ANALYSING)
stop_camera();
::exit(1);
break;
case ISTATE_UNDEF:
@ -354,42 +366,42 @@ void RefractiveIndex::keyPressed (int key)
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;
*/
>> 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;
*/
}

View File

@ -11,6 +11,9 @@
#include "ofxOpenCv.h"
#include "ofxXmlSettings.h"
#define MODE_DRAWING 0xEEFF
#define MODE_ANALYSING 0xFFEE
class RefractiveIndex : public ofBaseApp
{
public:
@ -55,6 +58,8 @@ public:
// acquisition
static ofPixels _pixels;
static ofVideoGrabber _vidGrabber;
static int _mode;
vector<string> videoSourceList;
static int _vid_w, _vid_h, _vid_id;
static bool _vid_stream_open;

View File

@ -525,6 +525,7 @@ void ColorSingleAnalysis::draw()
}
}
//this is where we save the full-frame software output to file... after the vectors, etc. are rendered...
//saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
}