diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index a46037c..c32cb39 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -52,6 +52,8 @@ void RefractiveIndex::setup() // _vid_id = XML.getValue("config:camera:id", CAMERA_ID); + cout << "_vid_id: " << _vid_id << endl; + _vid_w = XML.getValue("config:camera:width", CAMERA_ACQU_WIDTH); _vid_h = XML.getValue("config:camera:height", CAMERA_ACQU_HEIGHT); @@ -116,7 +118,6 @@ void RefractiveIndex::setup() //_currentAnalysisIndx = 0; //_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++); - //_state = ISTATE_START; _currentAnalysis = NULL; @@ -190,22 +191,11 @@ void RefractiveIndex::update() void RefractiveIndex::draw() { - // refractive mauve + // refractive mauve - this doesn't work... looks weird in various places. //ofBackground(113, 110, 136); // black ofBackground(0, 0, 0); - - //TODO: Needs to return to a black screen - not to exit... - - // i.e.: operational sequence - // 1) starts in a black screen - // 2) we 'start' with keypress "s" the entire set of analyses - // 3) at any point we need to be able to restart / stop-return-to-black / trigger each analysis individually - // 4) should end in black screen as well - // 5) final kill button - - //ofRect(0,0,ofGetWidth(), ofGetHeight()); if(_currentAnalysis) _currentAnalysis->draw(); @@ -215,8 +205,9 @@ void RefractiveIndex::setup_camera() { stop_camera(); + // THIS IS LOADED IN FROM THE XML FILE SETTINGS _vidGrabber.setDeviceID(_vid_id); - _vidGrabber.listDevices(); + _vidGrabber.listDevices(); if(!_vidGrabber.initGrabber(_vid_w, _vid_h)) { ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber"; @@ -357,6 +348,47 @@ void RefractiveIndex::keyPressed (int key) _state = ISTATE_TRANSITION; } + /* + 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 + +>> case 's': +>> doSave ^= true; +>> doLoad = false; +>> if(doSave) { +>> ofFileDialogResult r = ofSystemLoadDialog("Select path to save to", true); +>> if(r.bSuccess) { +>> saveCounter = 0; +>> savePath = r.getPath(); +>> ofDirectory::createDirectory(savePath + "/color/"); +>> ofDirectory::createDirectory(savePath + "/depth/"); +>> printf("SAVE %s %s\n", r.getPath().c_str(), r.getName().c_str()); +>> } else { +>> doSave = false; +>> } +>> +>> } +>> break; +>> +>> case 'l': +>> doLoad ^= true; +>> doSave = false; +>> if(doLoad) { +>> ofFileDialogResult r = ofSystemLoadDialog("Select path to load from", true); +>> if(r.bSuccess) { +>> loadCounter = 0; +>> loadPath = r.getPath(); +>> ofDirectory dir; +>> 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()); +>> } else { +>> doLoad = false; +>> } +>> +>> } +>> break; + */ + } diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 02e15f9..da1ba7b 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -11,7 +11,9 @@ void AbstractAnalysis::do_synthesize() { cout << "i NUM_RUN" << i << endl; - _saved_filenames_analysis.clear(); + _saved_filenames_analysis.clear(); + _saved_filenames_synthesis.clear(); + _state = STATE_ACQUIRING; acquire(); if(_state == STATE_STOP) goto exit; @@ -57,19 +59,38 @@ void AbstractAnalysis::create_dir() //cout << "_whole_file_path_analysis = " << _whole_file_path_analysis << endl; if(!fileHelperAnalysis.doesDirectoryExist(_whole_file_path_analysis)){ + + if(!fileHelperAnalysis.doesDirectoryExist(ANALYSIS_PATH)) fileHelperAnalysis.makeDirectory(ANALYSIS_PATH); + + if(!fileHelperAnalysis.doesDirectoryExist(ANALYSIS_PATH+RefractiveIndex::_location)) fileHelperAnalysis.makeDirectory(ANALYSIS_PATH+RefractiveIndex::_location); + + if(!fileHelperAnalysis.doesDirectoryExist(ANALYSIS_PATH+RefractiveIndex::_location+"/"+_name)) fileHelperAnalysis.makeDirectory(ANALYSIS_PATH+RefractiveIndex::_location+"/"+_name); + + if(!fileHelperAnalysis.doesDirectoryExist(ANALYSIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime)) fileHelperAnalysis.makeDirectory(ANALYSIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime); + + } _whole_file_path_synthesis = SYNTHESIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime; if(!fileHelperSynthesis.doesDirectoryExist(_whole_file_path_synthesis)){ + + if(!fileHelperAnalysis.doesDirectoryExist(SYNTHESIS_PATH)) fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH); + + if(!fileHelperAnalysis.doesDirectoryExist(SYNTHESIS_PATH+RefractiveIndex::_location)) fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location); + + if(!fileHelperAnalysis.doesDirectoryExist(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name)) fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name); + + if(!fileHelperAnalysis.doesDirectoryExist(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime)) fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime); + } //////////////////////////////END DIRECTORY CREATION ////////////////////////////////////////////////// diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index e3e71b8..0ba5127 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -11,6 +11,7 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 20 void CamNoiseAnalysis::setup(int camWidth, int camHeight) { @@ -19,7 +20,11 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight) //NUM_RUN = 5; - int acq_run_time = 20; // 20 seconds of acquiring per run + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_camnoise", ACQUIRE_TIME); + cout << "ACQUIRE_TIME CamNoiseAnalysis " << acq_run_time << endl; + + //int acq_run_time = 20; // 20 seconds of acquiring per run DELTA_T_SAVE = 2*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files // or 5 times per second = every 200 ms @@ -116,32 +121,38 @@ void CamNoiseAnalysis::synthesise() ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES ////////////////////////// cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); - cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); + //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); cvGrayImage1 = cvColorImage1; //cvGrayImage2 = cvColorImage2; //cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); - //cvGrayDiff1.erode(); - //cvGrayDiff1.contrastStretch(); - //cvGrayDiff1.blur(5); - //cvGrayDiff1.dilate(); - //cvGrayDiff1.contrastStretch(); - - cvGrayImage1.threshold(255.0*i/_saved_filenames_analysis.size()); //random threshold for the moment - cvGrayImage1.blur(10); + cvGrayImage1.erode(); + cvGrayImage1.erode(); + cvGrayImage1.erode(); + cvGrayImage1.blur(); cvGrayImage1.contrastStretch(); - cvGrayImage1.blur(10); /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER //////////////////////////////// string file_name; file_name = ofToString(_synth_save_cnt, 2)+"_CamNoiseAnalysis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); - //ofSaveImage(cvGrayDiff1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + image.setFromPixels(cvGrayImage1.getPixels(), cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; @@ -389,7 +400,26 @@ void CamNoiseAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); + _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); } diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index dc4ae93..0e659a8 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -10,6 +10,7 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 20 void ColorMultiAnalysis::setup(int camWidth, int camHeight) { @@ -18,7 +19,11 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight) //NUM_RUN = 5; - int acq_run_time = 35; + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_colormulti", ACQUIRE_TIME); + cout << "ACQUIRE_TIME ColorMultiAnalysis " << acq_run_time << endl; + + //int acq_run_time = 35; DELTA_T_SAVE = 1*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files // or 10 times per second = every 100 ms @@ -120,17 +125,6 @@ void ColorMultiAnalysis::synthesise() cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); - //cvGrayImage1 = cvColorImage1; - //cvGrayImage2 = cvColorImage2; - - //cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); - //cvGrayDiff1.erode(); - //cvGrayDiff1.contrastStretch(); - //cvGrayDiff1.blur(5); - //cvGrayDiff1.dilate(); - //cvGrayDiff1.contrastStretch(); - - cvColorImage1.contrastStretch(); cvColorImage1.blur(5); cvColorImage1.erode(); cvColorImage1.erode(); @@ -146,9 +140,22 @@ void ColorMultiAnalysis::synthesise() file_name = ofToString(_synth_save_cnt, 2)+"_ColorMultiAnalysis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvColorImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; @@ -354,7 +361,6 @@ void ColorMultiAnalysis::draw() ofSetColor(255, 255, 255); image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR); - //image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_GRAYSCALE); image2.draw(0,0, ofGetWidth(), ofGetHeight()); ofDisableAlphaBlending(); @@ -392,10 +398,27 @@ void ColorMultiAnalysis::save_cb(Timer& timer) //cout << "ColorMultiAnalysis::saving...\n"; string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; + + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); - - + } diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index d8b3c6b..b1f062e 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -11,6 +11,7 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 20 void ColorSingleAnalysis::setup(int camWidth, int camHeight) { @@ -19,7 +20,11 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) //NUM_RUN = 5; - int acq_run_time = 25; // 20 seconds of acquiring per run + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_colorsingle", ACQUIRE_TIME); + cout << "ACQUIRE_TIME ColorSingleAnalysis " << acq_run_time << endl; + + //int acq_run_time = 25; // 20 seconds of acquiring per run DELTA_T_SAVE = 1*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files // or 10 times per second = every 100 ms @@ -134,7 +139,6 @@ void ColorSingleAnalysis::synthesise() //cvGrayDiff1.dilate(); //cvGrayDiff1.contrastStretch(); - cvColorImage1.contrastStretch(); cvColorImage1.blur(5); cvColorImage1.erode(); cvColorImage1.erode(); @@ -150,9 +154,21 @@ void ColorSingleAnalysis::synthesise() file_name = ofToString(_synth_save_cnt, 2)+"_ColorSingleAnalysis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvColorImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; @@ -367,7 +383,6 @@ void ColorSingleAnalysis::draw() ofSetColor(255, 255, 255); image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR); - //image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_GRAYSCALE); image2.draw(0,0, ofGetWidth(), ofGetHeight()); ofDisableAlphaBlending(); @@ -404,8 +419,26 @@ void ColorSingleAnalysis::save_cb(Timer& timer) string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); + _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index b8aff20..ecde3a8 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -11,6 +11,7 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 20 void DiffNoiseAnalysis::setup(int camWidth, int camHeight) { @@ -19,7 +20,11 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight) //NUM_RUN = 5; - int acq_run_time = 20; // 20 seconds of acquiring per run + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:diffnoise_shadow", ACQUIRE_TIME); + cout << "ACQUIRE_TIME DiffNoiseAnalysis " << acq_run_time << endl; + + //int acq_run_time = 20; // 20 seconds of acquiring per run DELTA_T_SAVE = 1*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files // or 10 times per second = every 100 ms @@ -119,33 +124,35 @@ void DiffNoiseAnalysis::synthesise() cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); - - //cvGrayImage1 = cvColorImage1; - //cvGrayImage2 = cvColorImage2; - - //cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); - //cvGrayDiff1.erode(); - //cvGrayDiff1.contrastStretch(); - //cvGrayDiff1.blur(5); - //cvGrayDiff1.dilate(); - //cvGrayDiff1.contrastStretch(); - - cvColorImage1.contrastStretch(); + cvColorImage1.invert(); cvColorImage1.blur(5); cvColorImage1.erode(); + cvColorImage1.erode(); cvColorImage1.blur(5); cvColorImage1.erode(); - cvColorImage1.contrastStretch(); + cvColorImage1.erode(); //////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER //////////////////////////////// string file_name; file_name = ofToString(_synth_save_cnt, 2)+"_DiffNoiseAnalysis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvColorImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvColorImage1.width, cvGrayImage1.height, OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; @@ -409,10 +416,26 @@ void DiffNoiseAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); - - _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); - _save_cnt++; + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); + + _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); } diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index 4a23b2e..8b33db9 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -11,15 +11,20 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 20 void IResponseAnalysis::setup(int camWidth, int camHeight) { NUM_RUN = RefractiveIndex::XML.getValue("config:analysis:NUM_RUN", NUMBER_RUNS); cout << "NUM_RUN IResponseAnalysis " << NUM_RUN << endl; -// NUM_RUN = 5; + //NUM_RUN = 5; - int acq_run_time = 20; // 20 seconds of acquiring per run + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_iresponse", ACQUIRE_TIME); + cout << "ACQUIRE_TIME IResponseAnalysis " << acq_run_time << endl; + + //int acq_run_time = 20; // 20 seconds of acquiring per run DELTA_T_SAVE = 2*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files // or 10 times per second = every 100 ms @@ -133,9 +138,22 @@ void IResponseAnalysis::synthesise() file_name = ofToString(_synth_save_cnt, 2)+"_IResponseSynthesis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvGrayDiff1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; @@ -364,6 +382,25 @@ void IResponseAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); + _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); } diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index d329d9b..4982610 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -11,7 +11,7 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 - +#define ACQUIRE_TIME 20 void RelaxRateAnalysis::setup(int camWidth, int camHeight) { @@ -19,8 +19,12 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight) cout << "NUM_RUN RelaxRateAnalysis " << NUM_RUN << endl; //NUM_RUN = 5; + + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_relaxrate", ACQUIRE_TIME); + cout << "ACQUIRE_TIME RelaxRateAnalysis " << acq_run_time << endl; - int acq_run_time = 20; // 20 seconds of acquiring per run + //int acq_run_time = 20; // 20 seconds of acquiring per run DELTA_T_SAVE = 2*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files // or 10 times per second = every 100 ms @@ -132,9 +136,22 @@ void RelaxRateAnalysis::synthesise() file_name = ofToString(_synth_save_cnt, 2)+"_RelaxRateAnalysis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvGrayDiff1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + + image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; } @@ -358,7 +375,25 @@ void RelaxRateAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); } diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index d7cd511..819f5db 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -15,6 +15,7 @@ using Poco::Thread; #define STATE_SCAN 0 #define STATE_ANALYSIS 1 #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 20 void ShadowScapesAnalysis::setup(int camWidth, int camHeight) { @@ -22,7 +23,9 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight) cout << "NUM_RUN ShadowScapesAnalysis " << NUM_RUN << endl; //NUM_RUN = 5; - int acq_run_time = 15; // 10 seconds of acquiring per run + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_shadowscapes", ACQUIRE_TIME); + cout << "ACQUIRE_TIME ShadowScapesAnalysis " << acq_run_time << endl; int screenSpan; if (_dir == V) screenSpan = ofGetHeight(); @@ -131,7 +134,6 @@ void ShadowScapesAnalysis::synthesise() cvGrayDiff1.contrastStretch(); cvGrayDiff1.blur(5); cvGrayDiff1.dilate(); - cvGrayDiff1.contrastStretch(); /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER //////////////////////////////// string file_name; @@ -148,9 +150,22 @@ void ShadowScapesAnalysis::synthesise() file_name = ofToString(_synth_save_cnt, 2)+"_D_ShadowScapesSynthesis_"+ofToString(_run_cnt,2)+".jpg"; } - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvGrayDiff1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + + image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; @@ -372,9 +387,9 @@ void ShadowScapesAnalysis::draw() if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { - cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + //cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); - cout << "fade down = " << fade << endl; + //cout << "fade down = " << fade << endl; for (int i=0; i <= 15; i++){ @@ -425,33 +440,6 @@ void ShadowScapesAnalysis::draw() ofDisableAlphaBlending(); - //cvGrayDiff1.draw(0,0, ofGetWidth(), ofGetHeight()); - - - // THE OLD SHIT - /* - ofEnableAlphaBlending(); - - ofSetColor(255, 255, 255, 200); - image3.setFromPixels(image1.getPixels(),image1.width,image1.height, OF_IMAGE_COLOR); - image4.setFromPixels(image2.getPixels(),image2.width,image2.height, OF_IMAGE_COLOR); - - cvColorImage1.setFromPixels(image3.getPixels(), image3.width, image3.height); - cvColorImage2.setFromPixels(image4.getPixels(), image4.width, image4.height); - - cvGrayImage1 = cvColorImage1; - cvGrayImage2 = cvColorImage2; - - cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); - cvGrayDiff1.contrastStretch(); - cvGrayDiff1.dilate(); - - cvGrayDiff1.draw(0,0, ofGetWidth(), ofGetHeight()); - - ofDisableAlphaBlending(); - */ - - //image2.draw(0,0, ofGetWidth(), ofGetHeight()); } @@ -497,8 +485,26 @@ void ShadowScapesAnalysis::save_cb(Timer& timer) file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 2)+"_"+ofToString(_run_cnt,2)+".jpg"; } - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); - + } diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index f7858f2..6ff860b 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -11,6 +11,7 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 20 void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) { @@ -20,7 +21,11 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) // NUM_RUN = 5; - int acq_run_time = 20; // 20 seconds of acquiring per run + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_shapefromshading", ACQUIRE_TIME); + cout << "ACQUIRE_TIME ShapeFromShadingAnalysis " << acq_run_time << endl; + + //int acq_run_time = 20; // 20 seconds of acquiring per run DELTA_T_SAVE = 2*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files // or 10 times per second = every 100 ms @@ -154,9 +159,21 @@ void ShapeFromShadingAnalysis::synthesise() file_name = ofToString(_synth_save_cnt, 2)+"_ShapeFromShadingSynthesis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); - ofSaveImage(cvGrayDiff1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); + _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; @@ -558,7 +575,26 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg"; - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); + _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); } diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 4213709..7ed4794 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -11,6 +11,7 @@ using Poco::TimerCallback; using Poco::Thread; #define NUMBER_RUNS 1 +#define ACQUIRE_TIME 30 void StrobeAnalysis::setup(int camWidth, int camHeight) { @@ -19,14 +20,18 @@ void StrobeAnalysis::setup(int camWidth, int camHeight) //NUM_RUN = 5; - int acq_run_time = 25; // 20 seconds of acquiring per run + int acq_run_time; // 10 seconds of acquiring per run + acq_run_time = RefractiveIndex::XML.getValue("config:analysis:acquiretime_strobe", ACQUIRE_TIME); + cout << "ACQUIRE_TIME StrobeAnalysis " << acq_run_time << endl; + + //int acq_run_time = 25; // 20 seconds of acquiring per run DELTA_T_SAVE = 2*(10*acq_run_time/2); // for 20 seconds, we want this to be around 100 files // or 5 times per second = every 200 ms _frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames - _strobe_interval = 1750; //every 1 seconds, or every thirty frames 30 frames + _strobe_interval = 2000; //every 1 seconds, or every thirty frames 30 frames // The British Health and Safety Executive recommend that a net flash rate for a bank of strobe lights does not exceed 5 flashes per second, at which only 5% of photosensitive epileptics are at risk. It also recommends that no strobing effect continue for more than 30 seconds, due to the potential for discomfort and disorientation. @@ -113,40 +118,45 @@ void StrobeAnalysis::synthesise() if(image1.loadImage(_saved_filenames_analysis[i])){ // cout << "LOADED image1!!!" << endl; - //if(image5.loadImage(_saved_filenames_analysis[i+1])){ + if(image5.loadImage(_saved_filenames_analysis[i+1])){ ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES ////////////////////////// cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); - + cvGrayImage1 = cvColorImage1; - //cvGrayImage2 = cvColorImage2; - - //cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); - //cvGrayDiff1.erode(); - //cvGrayDiff1.contrastStretch(); - //cvGrayDiff1.blur(5); - //cvGrayDiff1.dilate(); - //cvGrayDiff1.contrastStretch(); - - cvGrayImage1.contrastStretch(); - cvGrayImage1.blur(10); - cvGrayImage1.dilate(); + cvGrayImage2 = cvColorImage2; + + cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); + cvGrayDiff1.dilate(); + cvGrayDiff1.dilate(); + cvGrayDiff1.contrastStretch(); /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER //////////////////////////////// string file_name; file_name = ofToString(_synth_save_cnt, 2)+"_StrobeAnalysis_"+ofToString(_run_cnt,2)+".jpg"; - //image4.setFromPixels(cvColorImage1.getPixelsRef(),image3.width, image3.height, OF_IMAGE_COLOR); + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> + ofImage image; + //image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + image.setUseTexture(false); + + image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height,OF_IMAGE_GRAYSCALE); + image.saveImage(_whole_file_path_synthesis+"/"+file_name); - ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); - //ofSaveImage(cvGrayDiff1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST); _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name); _synth_save_cnt++; - //} + } } } @@ -390,7 +400,26 @@ void StrobeAnalysis::save_cb(Timer& timer) string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg"; - ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + //<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ----> + //ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+file_name, OF_IMAGE_QUALITY_BEST); + + + //<---- 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(); + + ofImage myImage; + //myImage.allocate(appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + + //*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***// + myImage.setUseTexture(false); + + myImage.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); + myImage.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+file_name); + _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+file_name); }