/* */ #include "AbstractAnalysis.h" #include "RefractiveIndex.h" #include "ofxFileHelper.h" // this is the main threaded loop for a given analysis void AbstractAnalysis::do_synthesize() { for(int i = 0; i < NUM_RUN; i++) { cout << "NUM_RUN: " << i << endl; _saved_filenames_analysis.clear(); _saved_filenames_synthesis.clear(); _state = STATE_ACQUIRING; acquire(); if(_state == STATE_STOP) goto exit; _state = STATE_SYNTHESISING; synthesise(); if(_state == STATE_STOP) goto exit; _state = STATE_DISPLAY_RESULTS; displayresults(); cleanup(); } exit: cleanup(); ofNotifyEvent(_synthesize_cb, _name); } void AbstractAnalysis::create_dir_allocate_images() { // HERE IS WHERE WE SETUP THE DIRECTORY FOR ALL THE SAVED IMAGES //FOR WINDOWS i HAVE HAD TO REPLACE SPACES WITH UNDERSCORES AND REDUCE THE LENGTH OF THE FOLDER NAME time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); string time = asctime(timeinfo); string replaceTime = ""; //DON'T INCLUDE THE DAY IN WORDS EG 'TUE' OR THE YEAR EG 2012 THIS MAKES THE DIRECTORY NAME TOO LONG AND CAUSES DIR CREATION TO FAIL for(int i=4;i unsigned char * somePixels; ofPixels appPix = RefractiveIndex::_pixels; somePixels = appPix.getPixels(); myColorImage1.setUseTexture(false); myColorImage1.setFromPixels(somePixels,appPix.getWidth(),appPix.getHeight(), OF_IMAGE_COLOR); myColorImage1.saveImage(ofToDataPath("")+ _whole_file_path_analysis+"/"+filename); myColorImage1.clear(); #endif _saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+filename); } void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType) { #ifdef TARGET_OSX ofSaveImage(newPixels->getPixelsRef(), _whole_file_path_synthesis+"/"+filename, OF_IMAGE_QUALITY_BEST); #elif defined(TARGET_WIN32) if (newType == OF_IMAGE_COLOR){ myColorImage2.setUseTexture(false); myColorImage2.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_COLOR); myColorImage2.saveImage(_whole_file_path_synthesis+"/"+filename); } if (newType == OF_IMAGE_GRAYSCALE){ myGrayImage1.setUseTexture(false); // THIS IS HOW YOU HAVE TO SAVE OUT THE GREYSCALE IMAGES on WINDOWS FOR SOME REASON --> i.e.: as an OF_IMAGE_COLOR // But they don't save properly - they're spatially translated and generally f'd up myGrayImage1.setFromPixels(newPixels->getPixels(), newPixels->getWidth(), newPixels->getHeight(), OF_IMAGE_COLOR); myGrayImage1.setImageType(OF_IMAGE_COLOR); myGrayImage1.saveImage(_whole_file_path_synthesis+"/"+filename); //myGrayImage1.clear(); } #endif _saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename); }