From 7a7614d02ddf18e92868d80fa266f25034e2d921 Mon Sep 17 00:00:00 2001 From: Jamie Allen Date: Mon, 27 Feb 2012 02:41:25 +0100 Subject: [PATCH] put in image.clear() and ofCvImage.clear() statements before allocation and after use of these trying to solve windows (mostly) crash, which seems to stem from "OF_WARNING: in allocate, reallocating a ofxCvImage" - hopefully this is the one! --- src/AbstractAnalysis.cpp | 41 ++++++++++++++------------------ src/AbstractAnalysis.h | 5 +++- src/CamNoiseAnalysis.cpp | 23 ++++++++++++++++++ src/ColorMultiAnalysis.cpp | 26 +++++++++++++++++--- src/ColorSingleAnalysis.cpp | 23 ++++++++++++++++++ src/DiffNoiseAnalysis.cpp | 24 +++++++++++++++++-- src/IResponseAnalysis.cpp | 23 ++++++++++++++++++ src/RelaxRateAnalysis.cpp | 26 +++++++++++++++++++- src/ShadowScapesAnalysis.cpp | 23 ++++++++++++++++++ src/ShapeFromShadingAnalysis.cpp | 24 ++++++++++++++++++- src/StrobeAnalysis.cpp | 23 ++++++++++++++++++ 11 files changed, 230 insertions(+), 31 deletions(-) diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index a63e6fa..a1e768c 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -98,16 +98,19 @@ void AbstractAnalysis::create_dir_allocate_images() //////////////////////////////ALLOCATE IMAGES ////////////////////////////////////////////////// ofImage myColorImage1; + myColorImage1.clear(); myColorImage1.setUseTexture(false); myColorImage1.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_COLOR); - ofImage myGrayImage1; - myGrayImage1.setUseTexture(false); - myGrayImage1.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_GRAYSCALE); - - ofImage myColorImage2; - myColorImage2.setUseTexture(false); - myColorImage2.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, OF_IMAGE_COLOR); + //ofxCvImage myColorCvImage2; + myColorCvImage2.clear(); + myColorCvImage2.setUseTexture(false); + myColorCvImage2.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + + //ofxCvImage myGrayCvImage1; + myGrayCvImage1.clear(); + myGrayCvImage1.setUseTexture(false); + myGrayCvImage1.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); //////////////////////////////END ALLOCATE IMAGES ////////////////////////////////////////////////// @@ -134,13 +137,11 @@ void AbstractAnalysis::saveImageAnalysis(string filename) //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> unsigned char * somePixels; ofPixels appPix = RefractiveIndex::_pixels; - //somePixels = new unsigned char [appPix.getWidth()*appPix.getHeight()*3]; somePixels = appPix.getPixels(); - //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// - myColorImage1.setUseTexture(false); myColorImage1.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); myColorImage1.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+filename); + myColorImage1.clear(); #endif @@ -159,25 +160,19 @@ void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels #elif defined(TARGET_WIN32) if (newType == OF_IMAGE_COLOR){ - myColorImage2.setFromPixels(newPixels.getPixels(), newPixels.width, newPixels.width, OF_IMAGE_COLOR); + myColorCvImage2.setFromPixels(newPixels.getPixels(), newPixels.width, newPixels.width, OF_IMAGE_COLOR); + myColorCvImage2.saveImage(_whole_file_path_synthesis+"/"+thisfilename); + myColorCvImage2.clear(); } if (newType == OF_IMAGE_GRAYSCALE){ - myGrayImage1.setFromPixels(newPixels.getPixels(), newPixels.width, newPixels.width, OF_IMAGE_GRAYSCALE); + myGrayCvImage1.setFromPixels(newPixels.getPixels(), newPixels.width, newPixels.width, OF_IMAGE_GRAYSCALE); + myGrayCvImage1.saveImage(_whole_file_path_synthesis+"/"+thisfilename); + myGrayCvImage1.clear(); } - - myColorImage2.saveImage(_whole_file_path_synthesis+"/"+thisfilename); - - //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> - //unsigned char * somePixels; - //ofPixels appPix = RefractiveIndex::_pixels; - //somePixels = new unsigned char [appPix.getWidth()*appPix.getHeight()*3]; - //somePixels = appPix.getPixels(); - //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); - #endif - + _saved_filenames_synthesis.push_back(_whole_file_path_analysis+"/"+filename); } diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index 84b688f..da49978 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -65,7 +65,10 @@ protected: ofImage myColorImage; ofImage myBlackWhiteImage; - + + ofxCvColorImage myColorCvImage2; + ofxCvColorImage myGrayCvImage1; + //int _run_cnt; float DELTA_T_SAVE; diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index e9e24ae..265050e 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -45,6 +45,12 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight) _show_image = false; _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 @@ -54,9 +60,26 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight) 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); diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 6fc6130..650f043 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -39,12 +39,15 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight) int anim_time = 10; // 10 seconds _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames - //for an ofxOpenCv.h image i would like to use..." - //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); - _show_image = false; _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 @@ -54,9 +57,26 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight) 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); diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 1abdea6..76aa678 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -49,6 +49,12 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) _show_image = false; _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 @@ -58,9 +64,26 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) 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); diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index ac3b2ab..55701c0 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -43,8 +43,11 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight) _show_image = false; _image_shown = false; - //for an ofxOpenCv.h image i would like to use..." - //image3.allocate(RefractiveIndex::_vid_w, RefractiveIndex::_vid_h); + 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 @@ -55,9 +58,26 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight) 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); diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 9a32868..e9d7211 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -43,6 +43,12 @@ void IResponseAnalysis::setup(int camWidth, int camHeight) _show_image = false; _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 @@ -52,9 +58,26 @@ void IResponseAnalysis::setup(int camWidth, int camHeight) 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); diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index e85b220..ff61509 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -45,6 +45,12 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight) _show_image = false; _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 @@ -54,9 +60,27 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight) 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); @@ -288,7 +312,7 @@ void RelaxRateAnalysis::draw() } } - cout << "_anim_cnt = " << _anim_cnt << endl; + //cout << "_anim_cnt = " << _anim_cnt << endl; if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index d7f1b10..3197cb3 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -51,6 +51,12 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight) _show_image = false; _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 @@ -60,9 +66,26 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight) 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); diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index 82f0998..d34bbd0 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -40,10 +40,15 @@ 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; + 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 @@ -53,9 +58,26 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) 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); diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 346f6e3..e2b81b6 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -44,6 +44,12 @@ void StrobeAnalysis::setup(int camWidth, int camHeight) _show_image = false; _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 @@ -53,9 +59,26 @@ void StrobeAnalysis::setup(int camWidth, int camHeight) 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);