beginning to integrate dviid's code
This commit is contained in:
parent
877123a2db
commit
327830a581
@ -27,8 +27,10 @@
|
|||||||
#define ISTATE_TRANSITION 0xCCCC
|
#define ISTATE_TRANSITION 0xCCCC
|
||||||
#define ISTATE_END 0xDDDD
|
#define ISTATE_END 0xDDDD
|
||||||
|
|
||||||
|
|
||||||
int _state = ISTATE_UNDEF;
|
int _state = ISTATE_UNDEF;
|
||||||
|
|
||||||
|
int RefractiveIndex::_mode;
|
||||||
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;
|
||||||
@ -49,7 +51,11 @@ void RefractiveIndex::setup()
|
|||||||
} else {
|
} else {
|
||||||
XML.loadFile("config.refindx");
|
XML.loadFile("config.refindx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <mode>
|
||||||
|
string m = XML.getValue("config:mode", "analysing");
|
||||||
|
_mode = (m == "analysing" ? MODE_ANALYSING : (m == "drawing" ? MODE_DRAWING : MODE_ANALYSING));
|
||||||
|
|
||||||
// <camera>
|
// <camera>
|
||||||
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
|
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
|
||||||
cout << "_vid_id: " << _vid_id << endl;
|
cout << "_vid_id: " << _vid_id << endl;
|
||||||
@ -59,12 +65,12 @@ void RefractiveIndex::setup()
|
|||||||
|
|
||||||
// <display>
|
// <display>
|
||||||
int fps = XML.getValue("config:display:fps", 30);
|
int fps = XML.getValue("config:display:fps", 30);
|
||||||
|
|
||||||
// <location>
|
// <location>
|
||||||
_location = XML.getValue("config:locale:name", LOCATION);
|
_location = XML.getValue("config:locale:name", LOCATION);
|
||||||
|
|
||||||
cout << "Configuring..." << endl;
|
cout << "Configuring..." << endl;
|
||||||
|
|
||||||
// display
|
// display
|
||||||
cout << "> display" << endl;
|
cout << "> display" << endl;
|
||||||
ofSetFrameRate(fps);
|
ofSetFrameRate(fps);
|
||||||
@ -82,13 +88,15 @@ void RefractiveIndex::setup()
|
|||||||
cout << "* cam width = " << _vid_w << endl;
|
cout << "* cam width = " << _vid_w << endl;
|
||||||
cout << "* cam height = " << _vid_h << endl;
|
cout << "* cam height = " << _vid_h << endl;
|
||||||
|
|
||||||
_vid_stream_open = false;
|
if(_mode == MODE_ANALYSING) {
|
||||||
setup_camera();
|
_vid_stream_open = false;
|
||||||
|
setup_camera();
|
||||||
|
}
|
||||||
|
|
||||||
cout << "RRRRRREADY!" << endl;
|
cout << "RRRRRREADY!" << endl;
|
||||||
|
|
||||||
_analysisAdapator = NULL;
|
_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)
|
||||||
_pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR);
|
_pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR);
|
||||||
@ -99,7 +107,7 @@ void RefractiveIndex::setup()
|
|||||||
_analysisVector.push_back(new ShadowScapesAnalysis(V));
|
_analysisVector.push_back(new ShadowScapesAnalysis(V));
|
||||||
_analysisVector.push_back(new ShadowScapesAnalysis(H));
|
_analysisVector.push_back(new ShadowScapesAnalysis(H));
|
||||||
_analysisVector.push_back(new ShadowScapesAnalysis(D));
|
_analysisVector.push_back(new ShadowScapesAnalysis(D));
|
||||||
|
|
||||||
_analysisVector.push_back(new RelaxRateAnalysis());
|
_analysisVector.push_back(new RelaxRateAnalysis());
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +125,7 @@ void RefractiveIndex::setup()
|
|||||||
|
|
||||||
_analysisVector.push_back(new DiffNoiseAnalysis());
|
_analysisVector.push_back(new DiffNoiseAnalysis());
|
||||||
|
|
||||||
|
|
||||||
//_currentAnalysisIndx = 0;
|
//_currentAnalysisIndx = 0;
|
||||||
//_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
//_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||||
//_state = ISTATE_START;
|
//_state = ISTATE_START;
|
||||||
@ -173,10 +181,14 @@ void RefractiveIndex::state_analysis()
|
|||||||
break;
|
break;
|
||||||
case ISTATE_STOP:
|
case ISTATE_STOP:
|
||||||
stop_analysis(); // blocking
|
stop_analysis(); // blocking
|
||||||
_state = ISTATE_TRANSITION;
|
if(_mode == MODE_DRAWING)
|
||||||
|
_state = ISTATE_UNDEF;
|
||||||
|
else
|
||||||
|
_state = ISTATE_TRANSITION;
|
||||||
break;
|
break;
|
||||||
case ISTATE_END:
|
case ISTATE_END:
|
||||||
stop_camera();
|
if(_mode == MODE_ANALYSING)
|
||||||
|
stop_camera();
|
||||||
::exit(1);
|
::exit(1);
|
||||||
break;
|
break;
|
||||||
case ISTATE_UNDEF:
|
case ISTATE_UNDEF:
|
||||||
@ -198,7 +210,7 @@ void RefractiveIndex::draw()
|
|||||||
|
|
||||||
// black
|
// black
|
||||||
ofBackground(0, 0, 0);
|
ofBackground(0, 0, 0);
|
||||||
|
|
||||||
if(_currentAnalysis)
|
if(_currentAnalysis)
|
||||||
_currentAnalysis->draw();
|
_currentAnalysis->draw();
|
||||||
}
|
}
|
||||||
@ -259,7 +271,7 @@ void RefractiveIndex::keyPressed (int key)
|
|||||||
if(!_currentAnalysis)
|
if(!_currentAnalysis)
|
||||||
_state = ISTATE_TRANSITION;
|
_state = ISTATE_TRANSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(key == '2')
|
else if(key == '2')
|
||||||
{
|
{
|
||||||
if(_currentAnalysis)
|
if(_currentAnalysis)
|
||||||
@ -268,7 +280,7 @@ void RefractiveIndex::keyPressed (int key)
|
|||||||
if(!_currentAnalysis)
|
if(!_currentAnalysis)
|
||||||
_state = ISTATE_TRANSITION;
|
_state = ISTATE_TRANSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(key == '3')
|
else if(key == '3')
|
||||||
{
|
{
|
||||||
if(_currentAnalysis)
|
if(_currentAnalysis)
|
||||||
@ -340,7 +352,7 @@ void RefractiveIndex::keyPressed (int key)
|
|||||||
if(!_currentAnalysis)
|
if(!_currentAnalysis)
|
||||||
_state = ISTATE_TRANSITION;
|
_state = ISTATE_TRANSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(key == 'q')
|
else if(key == 'q')
|
||||||
{
|
{
|
||||||
if(_currentAnalysis)
|
if(_currentAnalysis)
|
||||||
@ -354,42 +366,42 @@ void RefractiveIndex::keyPressed (int key)
|
|||||||
TO DO: add a file dialog so we can save images to another hard drive...
|
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
|
e.g.: http://dev.openframeworks.cc/pipermail/of-dev-openframeworks.cc/2011-April/003125.html
|
||||||
|
|
||||||
>> case 's':
|
>> case 's':
|
||||||
>> doSave ^= true;
|
>> doSave ^= true;
|
||||||
>> doLoad = false;
|
>> doLoad = false;
|
||||||
>> if(doSave) {
|
>> if(doSave) {
|
||||||
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to save to", true);
|
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to save to", true);
|
||||||
>> if(r.bSuccess) {
|
>> if(r.bSuccess) {
|
||||||
>> saveCounter = 0;
|
>> saveCounter = 0;
|
||||||
>> savePath = r.getPath();
|
>> savePath = r.getPath();
|
||||||
>> ofDirectory::createDirectory(savePath + "/color/");
|
>> ofDirectory::createDirectory(savePath + "/color/");
|
||||||
>> ofDirectory::createDirectory(savePath + "/depth/");
|
>> ofDirectory::createDirectory(savePath + "/depth/");
|
||||||
>> printf("SAVE %s %s\n", r.getPath().c_str(), r.getName().c_str());
|
>> printf("SAVE %s %s\n", r.getPath().c_str(), r.getName().c_str());
|
||||||
>> } else {
|
>> } else {
|
||||||
>> doSave = false;
|
>> doSave = false;
|
||||||
>> }
|
>> }
|
||||||
>>
|
>>
|
||||||
>> }
|
>> }
|
||||||
>> break;
|
>> break;
|
||||||
>>
|
>>
|
||||||
>> case 'l':
|
>> case 'l':
|
||||||
>> doLoad ^= true;
|
>> doLoad ^= true;
|
||||||
>> doSave = false;
|
>> doSave = false;
|
||||||
>> if(doLoad) {
|
>> if(doLoad) {
|
||||||
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to load from", true);
|
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to load from", true);
|
||||||
>> if(r.bSuccess) {
|
>> if(r.bSuccess) {
|
||||||
>> loadCounter = 0;
|
>> loadCounter = 0;
|
||||||
>> loadPath = r.getPath();
|
>> loadPath = r.getPath();
|
||||||
>> ofDirectory dir;
|
>> ofDirectory dir;
|
||||||
>> loadMaxFiles = MAX(dir.listDir(loadPath + "/color"), dir.listDir(loadPath + "/depth"));
|
>> 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());
|
>> printf("LOAD %i %s %s\n", loadMaxFiles, r.getPath().c_str(), r.getName().c_str());
|
||||||
>> } else {
|
>> } else {
|
||||||
>> doLoad = false;
|
>> doLoad = false;
|
||||||
>> }
|
>> }
|
||||||
>>
|
>>
|
||||||
>> }
|
>> }
|
||||||
>> break;
|
>> break;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,9 @@
|
|||||||
#include "ofxOpenCv.h"
|
#include "ofxOpenCv.h"
|
||||||
#include "ofxXmlSettings.h"
|
#include "ofxXmlSettings.h"
|
||||||
|
|
||||||
|
#define MODE_DRAWING 0xEEFF
|
||||||
|
#define MODE_ANALYSING 0xFFEE
|
||||||
|
|
||||||
class RefractiveIndex : public ofBaseApp
|
class RefractiveIndex : public ofBaseApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -55,6 +58,8 @@ public:
|
|||||||
// acquisition
|
// acquisition
|
||||||
static ofPixels _pixels;
|
static ofPixels _pixels;
|
||||||
static ofVideoGrabber _vidGrabber;
|
static ofVideoGrabber _vidGrabber;
|
||||||
|
static int _mode;
|
||||||
|
|
||||||
vector<string> videoSourceList;
|
vector<string> videoSourceList;
|
||||||
static int _vid_w, _vid_h, _vid_id;
|
static int _vid_w, _vid_h, _vid_id;
|
||||||
static bool _vid_stream_open;
|
static bool _vid_stream_open;
|
||||||
|
|||||||
@ -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);
|
//saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user