moved save functionality to AbstractAnalysis
This commit is contained in:
parent
51c0098d27
commit
44c900e060
@ -100,6 +100,7 @@ void RefractiveIndex::setup()
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(H));
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(D));
|
||||
|
||||
/*
|
||||
_analysisVector.push_back(new RelaxRateAnalysis());
|
||||
|
||||
_analysisVector.push_back(new IResponseAnalysis());
|
||||
@ -116,6 +117,7 @@ void RefractiveIndex::setup()
|
||||
|
||||
_analysisVector.push_back(new DiffNoiseAnalysis());
|
||||
|
||||
*/
|
||||
//_currentAnalysisIndx = 0;
|
||||
//_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
//_state = ISTATE_START;
|
||||
|
||||
@ -9,7 +9,7 @@ void AbstractAnalysis::do_synthesize() {
|
||||
|
||||
for(int i = 0; i < NUM_RUN; i++) {
|
||||
|
||||
cout << "i NUM_RUN" << i << endl;
|
||||
cout << "NUM_RUN: " << i << endl;
|
||||
|
||||
_saved_filenames_analysis.clear();
|
||||
_saved_filenames_synthesis.clear();
|
||||
@ -96,3 +96,42 @@ void AbstractAnalysis::create_dir()
|
||||
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
void AbstractAnalysis::saveimage(string filename)
|
||||
{
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef TARGET_OSX
|
||||
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path_analysis+"/"+filename, OF_IMAGE_QUALITY_BEST);
|
||||
|
||||
#elif defined(TARGET_WIN32)
|
||||
|
||||
//<---- 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+"/"+filename);
|
||||
|
||||
#endif
|
||||
|
||||
_saved_filenames_analysis.push_back(_whole_file_path_analysis+"/"+filename);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -36,6 +36,8 @@ protected:
|
||||
|
||||
virtual void create_dir();
|
||||
|
||||
virtual void saveimage(string filename);
|
||||
|
||||
// acquire images - all the children (see - do_synthesize)
|
||||
virtual void acquire() = 0;
|
||||
|
||||
|
||||
@ -387,39 +387,7 @@ void CamNoiseAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//cout << "CamNoiseAnalysis::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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
saveimage(file_name);
|
||||
}
|
||||
|
||||
@ -383,42 +383,9 @@ void ColorMultiAnalysis::draw()
|
||||
// this runs at save_cb timer rate = DELTA_T_SAVE
|
||||
void ColorMultiAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
saveimage(file_name);
|
||||
}
|
||||
|
||||
@ -406,40 +406,7 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//cout << "ColorSingleAnalysis::saving...\n";
|
||||
|
||||
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
|
||||
saveimage(file_name);
|
||||
}
|
||||
|
||||
@ -403,39 +403,7 @@ void DiffNoiseAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//cout << "DiffNoiseAnalysis::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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
saveimage(file_name);
|
||||
}
|
||||
|
||||
@ -369,38 +369,7 @@ void IResponseAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//cout << "IResponseAnalysis::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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
saveimage(file_name);
|
||||
}
|
||||
|
||||
@ -363,37 +363,9 @@ void RelaxRateAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
//cout << "RelaxRateAnalysis::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);
|
||||
saveimage(file_name);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
}
|
||||
|
||||
@ -40,8 +40,6 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||
DELTA_T_SAVE = 3*(10*acq_run_time/2); // for 20 seconds, we want this to be around 100 files
|
||||
// or 5 times per second = every 200 ms
|
||||
|
||||
//create_dir(); // this makes both synth and analysis folder structures
|
||||
|
||||
_scanLineWidth = 100.0;
|
||||
_run_cnt = 0;
|
||||
_save_cnt = 0;
|
||||
@ -87,24 +85,20 @@ void ShadowScapesAnalysis::acquire()
|
||||
|
||||
create_dir();
|
||||
|
||||
//cout << "RUN NUM = " << i;
|
||||
|
||||
save_timer.start(save_callback);
|
||||
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
save_timer.stop();
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
void ShadowScapesAnalysis::synthesise()
|
||||
{
|
||||
//cout << "ShadowScapesAnalysis::saving synthesis...\n";
|
||||
|
||||
for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
|
||||
for(float i=1;i<_saved_filenames_analysis.size()-1; i++){
|
||||
|
||||
// cout << "ShadowScapesAnalysis::synthesis FOR LOOP...\n";
|
||||
|
||||
@ -460,17 +454,6 @@ void ShadowScapesAnalysis::save_cb(Timer& timer)
|
||||
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//cout << "ShadowScapesAnalysis::saving analysis...\n";
|
||||
|
||||
string file_name;
|
||||
|
||||
if(_dir == H) {
|
||||
@ -485,26 +468,6 @@ void ShadowScapesAnalysis::save_cb(Timer& timer)
|
||||
file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
saveimage(file_name);
|
||||
|
||||
}
|
||||
|
||||
@ -562,39 +562,7 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//cout << "ShapeFromShadingAnalysis::saving...\n";
|
||||
|
||||
string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
saveimage(file_name);
|
||||
}
|
||||
|
||||
@ -387,39 +387,7 @@ void StrobeAnalysis::save_cb(Timer& timer)
|
||||
{
|
||||
_save_cnt++;
|
||||
|
||||
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
|
||||
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//cout << "StrobeAnalysis::saving...\n";
|
||||
|
||||
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+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);
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
saveimage(file_name);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user