now able to show images in the analysis classes!!
wooo hooo!!!
This commit is contained in:
parent
51c71bdc15
commit
e17a3a0d91
@ -24,6 +24,7 @@
|
||||
#include "DiffNoiseAnalysis.h"
|
||||
|
||||
#include "ofxXmlSettings.h"
|
||||
#include "ofxOpenCv.h"
|
||||
|
||||
#define CAMERA_ID 1
|
||||
#define CAMERA_ACQU_WIDTH 640
|
||||
@ -53,9 +54,11 @@ void RefractiveIndex::setup()
|
||||
bool save_config = false;
|
||||
|
||||
cout << "Loading configuration..." << endl;
|
||||
if(!XML.loadFile("../data/config.refindx")) {
|
||||
if(XML.loadFile("config.refindx") == false) {
|
||||
ofLog(OF_LOG_ERROR) << "error loading config - using default.";
|
||||
save_config = true;
|
||||
} else {
|
||||
XML.loadFile("config.refindx");
|
||||
}
|
||||
|
||||
// <camera>
|
||||
@ -102,25 +105,25 @@ 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());
|
||||
// _analysisVector.push_back(new RelaxRateAnalysis());
|
||||
|
||||
_analysisVector.push_back(new IResponseAnalysis());
|
||||
// _analysisVector.push_back(new IResponseAnalysis());
|
||||
|
||||
_analysisVector.push_back(new ShapeFromShadingAnalysis());
|
||||
|
||||
_analysisVector.push_back(new StrobeAnalysis());
|
||||
// _analysisVector.push_back(new StrobeAnalysis());
|
||||
|
||||
_analysisVector.push_back(new CamNoiseAnalysis());
|
||||
// _analysisVector.push_back(new CamNoiseAnalysis());
|
||||
|
||||
_analysisVector.push_back(new ColorSingleAnalysis());
|
||||
// _analysisVector.push_back(new ColorSingleAnalysis());
|
||||
|
||||
_analysisVector.push_back(new ColorMultiAnalysis());
|
||||
// _analysisVector.push_back(new ColorMultiAnalysis());
|
||||
|
||||
_analysisVector.push_back(new DiffNoiseAnalysis());
|
||||
// _analysisVector.push_back(new DiffNoiseAnalysis());
|
||||
|
||||
_currentAnalysisIndx = 0;
|
||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx);
|
||||
|
||||
@ -11,8 +11,10 @@ int main() {
|
||||
ofAppGlutWindow window;
|
||||
|
||||
ofxXmlSettings XML;
|
||||
|
||||
XML.loadFile("../data/config.refindx");
|
||||
bool fullscreen = (XML.getValue("config:display:fullscreen", "true") == "true" ? true : false);
|
||||
|
||||
bool fullscreen = (XML.getValue("config:display:fullscreen", "false") == "true" ? true : false);
|
||||
int screen_w = XML.getValue("config:display:width", SCREEN_WIDTH);
|
||||
int screen_h = XML.getValue("config:display:height", SCREEN_HEIGHT);
|
||||
|
||||
@ -25,5 +27,4 @@ int main() {
|
||||
|
||||
ofSetupOpenGL(&window, screen_w, screen_h, (fullscreen ? OF_FULLSCREEN : OF_WINDOW));
|
||||
ofRunApp(new RefractiveIndex());
|
||||
|
||||
}
|
||||
|
||||
@ -41,8 +41,7 @@ void AbstractAnalysis::do_synthesize() {
|
||||
_state = STATE_SYNTHESISING;
|
||||
synthesise();
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
|
||||
//displayresults();
|
||||
displayresults();
|
||||
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ protected:
|
||||
|
||||
// analysis + synthesize images - all the children (see - do_synthesize)
|
||||
virtual void synthesise() = 0;
|
||||
virtual void displayresults() = 0;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -31,13 +31,11 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||
|
||||
int anim_time = 5; // 10 seconds
|
||||
_anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RelaxRateAnalysis::acquire()
|
||||
{
|
||||
|
||||
Timer* save_timer;
|
||||
|
||||
TimerCallback<RelaxRateAnalysis> save_callback(*this, &RelaxRateAnalysis::save_cb);
|
||||
|
||||
@ -10,11 +10,8 @@ using Poco::Timer;
|
||||
using Poco::TimerCallback;
|
||||
using Poco::Thread;
|
||||
|
||||
|
||||
void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
|
||||
{
|
||||
|
||||
|
||||
NUM_RUN = 1;
|
||||
|
||||
int acq_run_time = 20; // 20 seconds of acquiring per run
|
||||
@ -32,6 +29,13 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
|
||||
int anim_time = 5; // 10 seconds
|
||||
_anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames
|
||||
|
||||
_show_image = false;
|
||||
_image_shown = false;
|
||||
|
||||
image2.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h);
|
||||
|
||||
image1.setUseTexture(false);
|
||||
image2.setUseTexture(true);
|
||||
}
|
||||
|
||||
|
||||
@ -85,11 +89,36 @@ void ShapeFromShadingAnalysis::acquire()
|
||||
|
||||
void ShapeFromShadingAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
while(!_RUN_DONE)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
void ShapeFromShadingAnalysis::displayresults()
|
||||
{
|
||||
|
||||
for(float i=1;i<_saved_filenames.size();i++){
|
||||
|
||||
cout << "_saved_filenames[i]" << _saved_filenames[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
Thread::sleep(2);
|
||||
//cout << "!_image_shown" << endl;
|
||||
}
|
||||
|
||||
if(!image1.loadImage(_saved_filenames[i])){
|
||||
//couldn't load image
|
||||
cout << "didn't load image" << endl;
|
||||
}
|
||||
|
||||
if(image1.loadImage(_saved_filenames[i])){
|
||||
image1.loadImage(_saved_filenames[i]);
|
||||
//cout << "_show_image = true;" << endl;
|
||||
_show_image = true;
|
||||
_image_shown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this runs at frame rate = 33 ms for 30 FPS
|
||||
void ShapeFromShadingAnalysis::draw()
|
||||
{
|
||||
@ -102,23 +131,10 @@ void ShapeFromShadingAnalysis::draw()
|
||||
|
||||
ofEnableAlphaBlending();
|
||||
|
||||
|
||||
int _quarter_frame_cnt_max = _frame_cnt_max/4;
|
||||
int _half_frame_cnt_max = _frame_cnt_max/2;
|
||||
int _threequarters_frame_cnt_max = 3*_frame_cnt_max/4;
|
||||
|
||||
//TODO: put in CROSS FADES, ETC§E
|
||||
|
||||
/*
|
||||
if (_animation_reset == true)
|
||||
{
|
||||
_animation_cnt1 = 0;
|
||||
_animation_cnt2 = 0;
|
||||
_animation_cnt3 = 0;
|
||||
_animation_cnt4 = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if(_frame_cnt < _quarter_frame_cnt_max) {
|
||||
|
||||
quad = "QUAD1";
|
||||
@ -259,10 +275,6 @@ void ShapeFromShadingAnalysis::draw()
|
||||
_animation_cnt12++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -316,6 +328,7 @@ void ShapeFromShadingAnalysis::draw()
|
||||
ofDisableAlphaBlending();
|
||||
} else {
|
||||
//_state = STATE_SYNTHESISING;
|
||||
_frame_cnt = 0;
|
||||
_RUN_DONE = true;
|
||||
}
|
||||
|
||||
@ -408,8 +421,31 @@ void ShapeFromShadingAnalysis::draw()
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
if (_frame_cnt > 2)
|
||||
{
|
||||
_image_shown = true;
|
||||
_frame_cnt=0;
|
||||
}
|
||||
|
||||
_frame_cnt++;
|
||||
|
||||
if (_show_image)
|
||||
{
|
||||
ofEnableAlphaBlending();
|
||||
|
||||
ofSetColor(255, 255, 255, 255);
|
||||
image2.setFromPixels(image1.getPixels(),image1.width,image1.height, OF_IMAGE_COLOR);
|
||||
image2.draw(0,0, ofGetWidth(), ofGetHeight());
|
||||
|
||||
ofDisableAlphaBlending();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// display results of the synthesis
|
||||
_RUN_DONE = true;
|
||||
break;
|
||||
|
||||
@ -21,6 +21,7 @@ public:
|
||||
void setup(int camWidth, int camHeight);
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void displayresults();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
@ -50,4 +51,10 @@ protected:
|
||||
|
||||
int _run_cnt, _save_cnt, _anim_cnt;
|
||||
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
|
||||
bool _show_image, _image_shown;
|
||||
|
||||
|
||||
ofImage image1;
|
||||
ofxCvImage image2;
|
||||
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user