windows compatibility for saving images

* the save functions for image should work on both windows and osx now
(although we might want to move the creation of these images outside
the thread later)
* params for each analysis timing in the XML config
* minor warning / bug fixes in AbstractAnalysis.cpp and
RefractiveIndex.cpp
* cleaned up the use of OF_IMAGE_COLOR/OF_IMAGE_GRAYSCALE in all
analysis classes
This commit is contained in:
Jamie Allen 2012-02-23 01:22:14 +00:00
parent 5564329916
commit 51c0098d27
11 changed files with 449 additions and 144 deletions

View File

@ -52,6 +52,8 @@ void RefractiveIndex::setup()
// <camera>
_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,23 +191,12 @@ 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,6 +205,7 @@ void RefractiveIndex::setup_camera()
{
stop_camera();
// THIS IS LOADED IN FROM THE XML FILE SETTINGS
_vidGrabber.setDeviceID(_vid_id);
_vidGrabber.listDevices();
@ -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;
*/
}

View File

@ -12,6 +12,8 @@ void AbstractAnalysis::do_synthesize() {
cout << "i NUM_RUN" << i << endl;
_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 //////////////////////////////////////////////////

View File

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

View File

@ -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();
@ -393,9 +399,26 @@ void ColorMultiAnalysis::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);
}

View File

@ -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,7 +419,25 @@ 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);

View File

@ -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
@ -120,32 +125,34 @@ 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);
//<---- 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);
_save_cnt++;
}

View File

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

View File

@ -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)
{
@ -20,7 +20,11 @@ void RelaxRateAnalysis::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_relaxrate", ACQUIRE_TIME);
cout << "ACQUIRE_TIME RelaxRateAnalysis " << 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
@ -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);
}

View File

@ -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,7 +485,25 @@ 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);

View File

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

View File

@ -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,7 +118,7 @@ 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 //////////////////////////
@ -121,32 +126,37 @@ void StrobeAnalysis::synthesise()
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvGrayImage1 = cvColorImage1;
//cvGrayImage2 = cvColorImage2;
cvGrayImage2 = cvColorImage2;
//cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
//cvGrayDiff1.erode();
//cvGrayDiff1.contrastStretch();
//cvGrayDiff1.blur(5);
//cvGrayDiff1.dilate();
//cvGrayDiff1.contrastStretch();
cvGrayImage1.contrastStretch();
cvGrayImage1.blur(10);
cvGrayImage1.dilate();
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);
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(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++;
//}
}
}
}
@ -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);
}