unloading images

This commit is contained in:
dviid 2012-04-06 13:21:44 +02:00
parent daec77d2be
commit ab6c3d5be5
4 changed files with 114 additions and 6 deletions

View File

@ -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,6 +26,7 @@ void AbstractAnalysis::do_synthesize() {
if(_state == STATE_STOP) goto exit;
_state = STATE_DISPLAY_RESULTS;
displayresults();
_state = STATE_CLEANUP;
cleanup();
}

View File

@ -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,7 +52,10 @@ protected:
// display the results from disk
virtual void displayresults() = 0;
// display the results from disk
// allocate all images
virtual void allocate() {;}
// deallocate all images
virtual void cleanup() {;}

View File

@ -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;

View File

@ -26,6 +26,9 @@ public:
void synthesise();
void displayresults();
void allocate();
void cleanup();
void draw();
void save_cb(Poco::Timer& timer);