Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ab6c3d5be5 | |||
| daec77d2be | |||
| 6d0f6422bf | |||
| 1728a128e4 | |||
| e43b78cc5a |
@@ -14,6 +14,10 @@ void AbstractAnalysis::do_synthesize() {
|
||||
_saved_filenames_analysis.clear();
|
||||
_saved_filenames_synthesis.clear();
|
||||
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_ALLOCATE;
|
||||
allocate();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_ACQUIRING;
|
||||
acquire();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
@@ -22,9 +26,12 @@ void AbstractAnalysis::do_synthesize() {
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
displayresults();
|
||||
_state = STATE_CLEANUP;
|
||||
cleanup();
|
||||
}
|
||||
|
||||
exit:
|
||||
cleanup();
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
#define ANALYSIS_PATH "analysis/"
|
||||
#define SYNTHESIS_PATH "synthesis/"
|
||||
|
||||
#define STATE_ALLOCATE 0x0010
|
||||
#define STATE_CLEANUP 0x0001
|
||||
#define STATE_ACQUIRING 0x1111
|
||||
#define STATE_SYNTHESISING 0x2222
|
||||
#define STATE_DISPLAY_RESULTS 0x3333
|
||||
#define STATE_STOP 0xDEADBEEF
|
||||
#define STATE_DEF 0x0000
|
||||
|
||||
class AbstractAnalysis {
|
||||
|
||||
@@ -49,6 +52,13 @@ protected:
|
||||
// display the results from disk
|
||||
virtual void displayresults() = 0;
|
||||
|
||||
// allocate all images
|
||||
virtual void allocate() {;}
|
||||
|
||||
// deallocate all images
|
||||
virtual void cleanup() {;}
|
||||
|
||||
|
||||
public:
|
||||
string _name;
|
||||
|
||||
|
||||
@@ -184,7 +184,11 @@ void IResponseAnalysis::synthesise()
|
||||
cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
|
||||
|
||||
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
|
||||
|
||||
_synth_save_cnt++;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+43
-33
@@ -55,49 +55,18 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||
_image_shown = false;
|
||||
|
||||
image1.clear();
|
||||
image2.clear();
|
||||
image3.clear();
|
||||
image4.clear();
|
||||
image5.clear();
|
||||
|
||||
// images use for drawing the synthesized files to the screen ///
|
||||
image1.setUseTexture(false); // the non texture image that is needed to first load the image
|
||||
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
|
||||
|
||||
// images used for re-loading and saving out the synthesized files ///
|
||||
image3.setUseTexture(false);
|
||||
image4.setUseTexture(false);
|
||||
image5.setUseTexture(false);
|
||||
|
||||
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
|
||||
//cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
|
||||
//cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
|
||||
|
||||
// clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
|
||||
// that we're getting in OSX/Windows and is maybe crashing Windows
|
||||
// http://forum.openframeworks.cc/index.php?topic=1867.0
|
||||
cvColorImage1.clear();
|
||||
cvGrayImage1.clear();
|
||||
cvGrayDiff1.clear();
|
||||
|
||||
cvColorImage2.clear();
|
||||
cvGrayImage2.clear();
|
||||
cvGrayDiff2.clear();
|
||||
|
||||
|
||||
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
|
||||
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +104,7 @@ void RelaxRateAnalysis::synthesise()
|
||||
|
||||
cvContourFinderVect.clear();
|
||||
|
||||
|
||||
for(float i=1;i<_saved_filenames_analysis.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
@@ -166,11 +136,16 @@ void RelaxRateAnalysis::synthesise()
|
||||
void RelaxRateAnalysis::displayresults()
|
||||
{
|
||||
|
||||
cvContourFinderVectDisplay.clear();
|
||||
//cvContourFinderVectDisplay.clear();
|
||||
clearcfindervectdisplay();
|
||||
|
||||
for(int i=1;i<cvContourFinderVect.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
if(_state == STATE_STOP){
|
||||
clearcfindervectdisplay();
|
||||
clearcfindervect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
|
||||
@@ -187,6 +162,14 @@ void RelaxRateAnalysis::displayresults()
|
||||
|
||||
}
|
||||
|
||||
clearcfindervectdisplay();
|
||||
clearcfindervect();
|
||||
|
||||
|
||||
//cvContourFinderVectDisplay.clear();
|
||||
//cvContourFinderVect.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +181,7 @@ void RelaxRateAnalysis::draw()
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
|
||||
|
||||
if (_frame_cnt < _frame_cnt_max)
|
||||
{
|
||||
|
||||
@@ -227,6 +211,7 @@ void RelaxRateAnalysis::draw()
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
|
||||
// display animation of something while the synthesis in on-going...
|
||||
|
||||
//cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n";
|
||||
@@ -356,3 +341,28 @@ void RelaxRateAnalysis::save_cb(Timer& timer)
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RelaxRateAnalysis::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RelaxRateAnalysis::clearcfindervect()
|
||||
{
|
||||
for(int i = 0; i < cvContourFinderVect.size(); i++) {
|
||||
rfiCvContourFinder* f = cvContourFinderVect[i];
|
||||
|
||||
// maybe it's erase here? http://forum.openframeworks.cc/index.php/topic,3016.0.html
|
||||
// cvContourFinderVect.erase(i);
|
||||
|
||||
delete f;
|
||||
}
|
||||
cvContourFinderVect.clear();
|
||||
|
||||
}
|
||||
|
||||
void RelaxRateAnalysis::clearcfindervectdisplay()
|
||||
{
|
||||
cvContourFinderVectDisplay.clear();
|
||||
}
|
||||
|
||||
|
||||
+5
-18
@@ -23,6 +23,7 @@ public:
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void displayresults();
|
||||
void cleanup();
|
||||
|
||||
void draw();
|
||||
|
||||
@@ -30,6 +31,9 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void clearcfindervect();
|
||||
void clearcfindervectdisplay();
|
||||
|
||||
bool _RUN_DONE;
|
||||
float _flip, _level;
|
||||
int _run_cnt, _save_cnt, _synth_save_cnt, _anim_cnt;
|
||||
@@ -39,27 +43,10 @@ protected:
|
||||
int _maxblobs;
|
||||
|
||||
bool _show_image, _image_shown;
|
||||
|
||||
ofImage image1;
|
||||
ofImage image2;
|
||||
ofImage image3;
|
||||
ofImage image4;
|
||||
ofImage image5;
|
||||
ofImage image6;
|
||||
|
||||
ofxCvColorImage cvColorImage1;
|
||||
ofxCvColorImage cvColorImage2;
|
||||
ofxCvColorImage cvColorImage3;
|
||||
ofxCvColorImage cvColorImage4;
|
||||
ofxCvColorImage cvColorImage5;
|
||||
ofxCvColorImage cvColorImage6;
|
||||
|
||||
ofxCvGrayscaleImage cvGrayDiff1;
|
||||
ofxCvGrayscaleImage cvGrayDiff2;
|
||||
|
||||
ofxCvGrayscaleImage cvGrayImage1;
|
||||
ofxCvGrayscaleImage cvGrayImage2;
|
||||
ofxCvGrayscaleImage cvGrayImage3;
|
||||
ofxCvGrayscaleImage cvGrayImage4;
|
||||
|
||||
vector<rfiCvContourFinder*> cvContourFinderVect;
|
||||
vector<rfiCvContourFinder*> cvContourFinderVectDisplay;
|
||||
|
||||
@@ -51,6 +51,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||
_show_image = false;
|
||||
_image_shown = false;
|
||||
|
||||
/*
|
||||
image1.clear();
|
||||
image2.clear();
|
||||
image3.clear();
|
||||
@@ -97,6 +98,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
|
||||
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -224,24 +226,116 @@ void ShadowScapesAnalysis::displayresults()
|
||||
if(!image3.loadImage(_saved_filenames_synthesis[i])){
|
||||
//couldn't load image
|
||||
cout << "didn't load image" << endl;
|
||||
}
|
||||
} else {
|
||||
_show_image = true;
|
||||
_image_shown = false;
|
||||
|
||||
}
|
||||
/*
|
||||
if(image3.loadImage(_saved_filenames_synthesis[i])){
|
||||
image3.loadImage(_saved_filenames_synthesis[i]);
|
||||
//image3.loadImage(_saved_filenames_synthesis[i]);
|
||||
//cout << "_show_image = true;" << endl;
|
||||
_show_image = true;
|
||||
_image_shown = false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ShadowScapesAnalysis::allocate()
|
||||
{
|
||||
_RUN_DONE = false;
|
||||
|
||||
image1.clear();
|
||||
image3.clear();
|
||||
image4.clear();
|
||||
image5.clear();
|
||||
|
||||
image1.setUseTexture(false);
|
||||
image3.setUseTexture(false);
|
||||
image4.setUseTexture(false);
|
||||
image5.setUseTexture(false);
|
||||
|
||||
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
|
||||
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
void ShadowScapesAnalysis::cleanup()
|
||||
{
|
||||
_RUN_DONE = false;
|
||||
|
||||
image1.clear();
|
||||
image3.clear();
|
||||
image4.clear();
|
||||
image5.clear();
|
||||
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// the animation draw - and the output draw
|
||||
void ShadowScapesAnalysis::draw()
|
||||
{
|
||||
|
||||
switch (_state) {
|
||||
case STATE_ALLOCATE:
|
||||
{
|
||||
image2.clear();
|
||||
image2.setUseTexture(true);
|
||||
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
|
||||
cvColorImage1.clear();
|
||||
cvGrayImage1.clear();
|
||||
cvGrayDiff1.clear();
|
||||
|
||||
cvColorImage2.clear();
|
||||
cvGrayImage2.clear();
|
||||
cvGrayDiff2.clear();
|
||||
|
||||
cvConvertorImage.clear();
|
||||
|
||||
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
|
||||
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
|
||||
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
|
||||
_state = STATE_DEF;
|
||||
|
||||
_RUN_DONE = true;
|
||||
break;
|
||||
}
|
||||
case STATE_CLEANUP:
|
||||
{
|
||||
image2.clear();
|
||||
|
||||
cvColorImage1.clear();
|
||||
cvGrayImage1.clear();
|
||||
cvGrayDiff1.clear();
|
||||
|
||||
cvColorImage2.clear();
|
||||
cvGrayImage2.clear();
|
||||
cvGrayDiff2.clear();
|
||||
|
||||
_state = STATE_DEF;
|
||||
|
||||
_RUN_DONE = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
_line += _step;
|
||||
@@ -439,6 +533,9 @@ void ShadowScapesAnalysis::draw()
|
||||
|
||||
// display results of the synthesis
|
||||
_RUN_DONE = true;
|
||||
|
||||
// clear allocated memory...?
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ public:
|
||||
void synthesise();
|
||||
void displayresults();
|
||||
|
||||
void allocate();
|
||||
void cleanup();
|
||||
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
|
||||
Reference in New Issue
Block a user