Compare commits

...

7 Commits
tom ... master

Author SHA1 Message Date
gauthiier
42d048ca04 ... 2023-09-08 08:20:39 +02:00
dviid
5c5581f16e mid-backed commit - master is dead 2012-02-21 18:06:58 +01:00
dviid
b5cebe9304 mid-commit AbstractAnalysis::saveimage 2012-02-20 14:10:20 +01:00
Tom Schofield
3649211943 merged with tom 2012-02-20 13:00:05 +00:00
Tom Schofield
bc19757de2 merge local master 2012-02-20 12:37:44 +00:00
Jamie Allen
88fa037593 removed the saving maximum condition from each analysis class
if(_save_cnt >= NUM_SAVE_PER_RUN)  _RUN_DONE = true;
and using max_frame_cnt as the end condition for the run being finished...
not sure if this is working the way it should... need to think through the math of the frameRate/timing calculations in the setup for each class
2012-02-19 16:13:09 +01:00
Jamie Allen
2e7888f071 test commit for re-newed jamie branch on sunday 19th of feb 2012-02-19 12:55:51 +01:00
15 changed files with 376 additions and 320 deletions

10
README
View File

@ -1,10 +0,0 @@
WARNING: WORK IN PROGRESS...
configuring OpenFrameworks
-----------------
these files are configured according to OpenFrameworks addons - http://ofxaddons.com/howto
(1) drag-drop "ReflectiveIndex" folder into your OpenFrameworks project
(2) Install depedencies: {ofxDirList, ofxControlPanel, ofxXmlSettings};
(3) Press Play!

2
README.md Normal file
View File

@ -0,0 +1,2 @@
<img src="https://davidgauthier.info/rfi/img-resize/rfi3.jpg" width="100%">
<img src="https://davidgauthier.info/rfi/img-resize/rfi4.jpg" width="100%">

View File

@ -97,29 +97,29 @@ void RefractiveIndex::setup()
//TODO: whichever one of these is first - it always runs twice ? //TODO: whichever one of these is first - it always runs twice ?
// _analysisVector.push_back(new ShadowScapesAnalysis(V)); //_analysisVector.push_back(new ShadowScapesAnalysis(V));
// _analysisVector.push_back(new ShadowScapesAnalysis(H)); //_analysisVector.push_back(new ShadowScapesAnalysis(H));
// _analysisVector.push_back(new ShadowScapesAnalysis(D)); //_analysisVector.push_back(new ShadowScapesAnalysis(D));
_analysisVector.push_back(new RelaxRateAnalysis()); _analysisVector.push_back(new RelaxRateAnalysis());
_analysisVector.push_back(new IResponseAnalysis()); //_analysisVector.push_back(new IResponseAnalysis());
_analysisVector.push_back(new ShapeFromShadingAnalysis()); //_analysisVector.push_back(new ShapeFromShadingAnalysis());
// _analysisVector.push_back(new StrobeAnalysis()); //_analysisVector.push_back(new StrobeAnalysis());
_analysisVector.push_back(new CamNoiseAnalysis()); //_analysisVector.push_back(new CamNoiseAnalysis());
_analysisVector.push_back(new ColorSingleAnalysis()); //_analysisVector.push_back(new ColorSingleAnalysis());
_analysisVector.push_back(new ColorMultiAnalysis()); //_analysisVector.push_back(new ColorMultiAnalysis());
_analysisVector.push_back(new DiffNoiseAnalysis()); //_analysisVector.push_back(new DiffNoiseAnalysis());
_currentAnalysisIndx = 0; _currentAnalysisIndx = 0;
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx); _currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
_state = ISTATE_START; _state = ISTATE_START;
@ -209,6 +209,7 @@ void RefractiveIndex::setup_camera()
ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber"; ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber";
return; return;
} }
_vidGrabber.setUseTexture(false);
_vidGrabber.listDevices(); _vidGrabber.listDevices();
_vidGrabber.setVerbose(true); _vidGrabber.setVerbose(true);
_vid_stream_open = true; _vid_stream_open = true;

View File

@ -4,6 +4,14 @@
#define SCREEN_WIDTH 800 #define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600 #define SCREEN_HEIGHT 600
/////////////////////////dis is the new shit///////////
/////////////////////////dis is the new shit///////////
/////////////////////////dis is the new shit///////////
/////////////////////////dis is the new shit///////////
int main() { int main() {
ofAppGlutWindow window; ofAppGlutWindow window;

View File

@ -72,8 +72,8 @@ void AbstractAnalysis::create_dir()
} }
ofxFileHelper fileHelper; ofxFileHelper fileHelper;
_whole_file_path = ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ; _whole_file_path = ofToDataPath("") + ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ;
//cout << "_whole_file_path = " << _whole_file_path << endl; cout << "_whole_file_path = " << _whole_file_path << endl;
if(!fileHelper.doesDirectoryExist(_whole_file_path)){ if(!fileHelper.doesDirectoryExist(_whole_file_path)){
fileHelper.makeDirectory(ANALYSIS_PATH); fileHelper.makeDirectory(ANALYSIS_PATH);
@ -163,7 +163,8 @@ ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2
int y=0; int y=0;
//for each pixel... //for each pixel...
for(int i=0;i<imagePixels1.size();i+=3){ //for(int i=0;i<imagePixels1.size();i+=3){
for(int i=0;i<20;i+=3){
//get the colour of each image at this x y location - we will use these colours for comparison according to the below criteria //get the colour of each image at this x y location - we will use these colours for comparison according to the below criteria
ofColor colourImage1 = imagePixels1.getColor(x, y); ofColor colourImage1 = imagePixels1.getColor(x, y);
@ -316,3 +317,20 @@ int AbstractAnalysis::getRecordedValueFromFileName(string str){
} }
void AbstractAnalysis::saveimage(string filename)
{
if(RefractiveIndex::_pixels.isAllocated()) {
string fname = _whole_file_path + "/" + filename;
cout << "saving - " << fname << endl;
ofSaveImage(RefractiveIndex::_pixels, fname, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(fname);
} else {
ofLog(OF_LOG_ERROR) << "RefractiveIndex::_pixels NOT allocated...";
}
}

View File

@ -39,6 +39,7 @@ public:
protected: protected:
virtual void create_dir(); virtual void create_dir();
virtual void saveimage(string filename);
// acquire images - all the children (see - do_synthesize) // acquire images - all the children (see - do_synthesize)
virtual void acquire() = 0; virtual void acquire() = 0;

View File

@ -133,6 +133,9 @@ void CamNoiseAnalysis::draw()
// still need to deal with latency frames here - i.e.: there are frames // still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** /// /// *** TODO *** ///
if (_frame_cnt < _frame_cnt_max)
{
ofEnableAlphaBlending(); ofEnableAlphaBlending();
ofColor aColour; ofColor aColour;
@ -171,11 +174,16 @@ void CamNoiseAnalysis::draw()
// cout << "FADE OUT STROBE TIME " << endl; // cout << "FADE OUT STROBE TIME " << endl;
} }
_frame_cnt++;
ofDisableAlphaBlending(); ofDisableAlphaBlending();
} else {
_RUN_DONE = true;
}
_frame_cnt++;
break; break;
} }
case STATE_SYNTHESISING: case STATE_SYNTHESISING:
@ -225,16 +233,10 @@ void CamNoiseAnalysis::save_cb(Timer& timer)
_save_cnt++; _save_cnt++;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location; saveimage(file_name);
string file = _whole_file_path+"/"+file_name; //if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+file);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
} }
void CamNoiseAnalysis::display_results_cb(Timer& timer){ void CamNoiseAnalysis::display_results_cb(Timer& timer){

View File

@ -150,6 +150,11 @@ void ColorMultiAnalysis::draw()
switch (_state) { switch (_state) {
case STATE_ACQUIRING: case STATE_ACQUIRING:
{ {
if (_frame_cnt < _frame_cnt_max)
{
int _fade_in_frames = _frame_cnt_max/50; int _fade_in_frames = _frame_cnt_max/50;
if (_frame_cnt < _fade_in_frames) { if (_frame_cnt < _fade_in_frames) {
@ -189,6 +194,12 @@ void ColorMultiAnalysis::draw()
} }
} else {
_RUN_DONE = true;
}
_frame_cnt++; _frame_cnt++;
break; break;
@ -236,21 +247,14 @@ void ColorMultiAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE // this runs at save_cb timer rate = DELTA_T_SAVE
void ColorMultiAnalysis::save_cb(Timer& timer) void ColorMultiAnalysis::save_cb(Timer& timer)
{ {
_save_cnt++;
// UPDATE THE COLOR ON THE SCREEN
//float c_last = c;
// cout << "COLORMULTIANALYSIS::saving...\n"; // cout << "COLORMULTIANALYSIS::saving...\n";
// cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
// cout<<_whole_file_path<<endl; string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); saveimage(file_name);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
if(_save_cnt >= NUM_SAVE_PER_RUN){ _save_cnt++;
_RUN_DONE = true;
}
} }
void ColorMultiAnalysis::display_results_cb(Timer& timer){ void ColorMultiAnalysis::display_results_cb(Timer& timer){

View File

@ -136,8 +136,12 @@ void ColorSingleAnalysis::draw()
switch (_state) { switch (_state) {
case STATE_ACQUIRING: case STATE_ACQUIRING:
{ {
float one_third_of_frame_count_max=_frame_cnt_max/3;
if (_frame_cnt < _frame_cnt_max)
{
float one_third_of_frame_count_max=_frame_cnt_max/3;
int _fade_in_frames = one_third_of_frame_count_max/10; int _fade_in_frames = one_third_of_frame_count_max/10;
if (_frame_cnt < _fade_in_frames){ if (_frame_cnt < _fade_in_frames){
@ -183,6 +187,10 @@ void ColorSingleAnalysis::draw()
fileNameTag = "FADING"; fileNameTag = "FADING";
} }
} else {
_RUN_DONE = true;
}
_frame_cnt++; _frame_cnt++;
break; break;
@ -228,21 +236,16 @@ void ColorSingleAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE // this runs at save_cb timer rate = DELTA_T_SAVE
void ColorSingleAnalysis::save_cb(Timer& timer) void ColorSingleAnalysis::save_cb(Timer& timer)
{ {
_save_cnt++;
// cout << "ColorSingleAnalysis::saving...\n"; //cout << "ColorSingleAnalysis::saving...\n";
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
//cout<<ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg"; _save_cnt++;
cout<<file_name<<endl;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
//cout<<_whole_file_path+"/"+file_name<<endl; //if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
} }
void ColorSingleAnalysis::display_results_cb(Timer& timer){ void ColorSingleAnalysis::display_results_cb(Timer& timer){

View File

@ -126,6 +126,10 @@ void DiffNoiseAnalysis::draw()
switch (_state) { switch (_state) {
case STATE_ACQUIRING: case STATE_ACQUIRING:
{ {
if (_frame_cnt < _frame_cnt_max)
{
ofColor aColour; ofColor aColour;
int rectSize = 5; int rectSize = 5;
ofEnableAlphaBlending(); ofEnableAlphaBlending();
@ -187,6 +191,12 @@ void DiffNoiseAnalysis::draw()
ofDisableAlphaBlending(); ofDisableAlphaBlending();
} else {
_RUN_DONE = true;
}
_frame_cnt++; _frame_cnt++;
break; break;
@ -247,22 +257,14 @@ void DiffNoiseAnalysis::save_cb(Timer& timer)
cout<<"rand10... " <<rand10<<endl; cout<<"rand10... " <<rand10<<endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location; saveimage(file_name);
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
string file = _whole_file_path+"/"+file_name;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+file);
} }
_save_cnt++; _save_cnt++;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true; //if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
} }
void DiffNoiseAnalysis::display_results_cb(Timer& timer){ void DiffNoiseAnalysis::display_results_cb(Timer& timer){

View File

@ -140,6 +140,8 @@ void IResponseAnalysis::draw()
ofSetColor(c, c, c); ofSetColor(c, c, c);
ofRect(0, 0, ofGetWidth(), ofGetHeight()); ofRect(0, 0, ofGetWidth(), ofGetHeight());
c = 255.0 * (_frame_cnt_max*_frame_cnt_max - _frame_cnt*_frame_cnt)/(_frame_cnt_max*_frame_cnt_max); c = 255.0 * (_frame_cnt_max*_frame_cnt_max - _frame_cnt*_frame_cnt)/(_frame_cnt_max*_frame_cnt_max);
} else {
_RUN_DONE = true;
} }
_frame_cnt++; _frame_cnt++;
@ -190,22 +192,15 @@ void IResponseAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE // this runs at save_cb timer rate = DELTA_T_SAVE
void IResponseAnalysis::save_cb(Timer& timer) void IResponseAnalysis::save_cb(Timer& timer)
{ {
_save_cnt++; //cout << "IResponseAnalysis::saving...\n";
cout << "IResponseAnalysis::saving...\n";
//cout << "c_last... " << c << endl; //cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location; saveimage(file_name);
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera _save_cnt++;
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); //if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
} }
void IResponseAnalysis::display_results_cb(Timer& timer){ void IResponseAnalysis::display_results_cb(Timer& timer){
_results_cnt++; _results_cnt++;

View File

@ -20,7 +20,7 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
{ {
DELTA_T_SAVE = 130; DELTA_T_SAVE = 130;
NUM_PHASE = 1; NUM_PHASE = 1;
NUM_RUN = 1; NUM_RUN = 3;
NUM_SAVE_PER_RUN = 100; NUM_SAVE_PER_RUN = 100;
create_dir(); create_dir();
@ -61,6 +61,7 @@ void RelaxRateAnalysis::acquire()
void RelaxRateAnalysis::synthesise() void RelaxRateAnalysis::synthesise()
{ {
/*
//incrementer to whichMesh //incrementer to whichMesh
speed=0.2; speed=0.2;
//whichMesh is the index in the vector of meshes //whichMesh is the index in the vector of meshes
@ -100,10 +101,13 @@ void RelaxRateAnalysis::synthesise()
index++; index++;
} }
} }
*/
} }
void RelaxRateAnalysis::display_results(){ void RelaxRateAnalysis::display_results(){
/*
Timer* display_results_timer; Timer* display_results_timer;
TimerCallback<RelaxRateAnalysis> display_results_callback(*this, &RelaxRateAnalysis::display_results_cb); TimerCallback<RelaxRateAnalysis> display_results_callback(*this, &RelaxRateAnalysis::display_results_cb);
@ -119,6 +123,7 @@ void RelaxRateAnalysis::display_results(){
Thread::sleep(3); Thread::sleep(3);
display_results_timer->stop(); display_results_timer->stop();
*/
} }
@ -134,7 +139,7 @@ void RelaxRateAnalysis::draw()
// still need to deal with latency frames here - i.e.: there are frames // still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** /// /// *** TODO *** ///
if (_frame_cnt <= _frame_cnt_max) if (_frame_cnt < _frame_cnt_max)
{ {
float lightLevel=pow(_level,2); float lightLevel=pow(_level,2);
@ -152,7 +157,8 @@ void RelaxRateAnalysis::draw()
} else { } else {
cout << "RELAXRATE RUN COMPLETED" << endl; cout << "RELAXRATE RUN COMPLETED" << endl;
_state = STATE_SYNTHESISING; //_state = STATE_SYNTHESISING;
_RUN_DONE = true;
} }
_frame_cnt++; _frame_cnt++;
@ -169,6 +175,7 @@ void RelaxRateAnalysis::draw()
case STATE_DISPLAY_RESULTS: case STATE_DISPLAY_RESULTS:
{ {
/*
// display results of the synthesis // display results of the synthesis
// display results of the synthesis // display results of the synthesis
int imageWidth=640; int imageWidth=640;
@ -190,6 +197,7 @@ void RelaxRateAnalysis::draw()
whichMesh+=speed; whichMesh+=speed;
} }
*/
break; break;
} }
@ -206,20 +214,17 @@ void RelaxRateAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE // this runs at save_cb timer rate = DELTA_T_SAVE
void RelaxRateAnalysis::save_cb(Timer& timer) void RelaxRateAnalysis::save_cb(Timer& timer)
{ {
_save_cnt++; //cout << "RelaxRateAnalysis::saving...\n";
cout << "RelaxRateAnalysis::saving...\n";
//cout << "c_last... " << c << endl; //cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
string file = _whole_file_path+"/"+file_name; saveimage(file_name);
ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST); _save_cnt++;
_saved_filenames.push_back(ofToDataPath("")+file);
if(_save_cnt >= NUM_SAVE_PER_RUN) //if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true; // _RUN_DONE = true;
} }
void RelaxRateAnalysis::display_results_cb(Timer& timer){ void RelaxRateAnalysis::display_results_cb(Timer& timer){

View File

@ -119,6 +119,14 @@ void ShadowScapesAnalysis::synthesise()
//there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false) //there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false)
image1.setUseTexture(false); image1.setUseTexture(false);
image2.setUseTexture(false); image2.setUseTexture(false);
string fnamei = _saved_filenames[i];
string fnameii = _saved_filenames[i + 1];
bool l1 = image1.loadImage(_saved_filenames[i]);
bool l2 = image2.loadImage(_saved_filenames[i+1]);
//some of the textures are not loading correctly so only make mesh if both the images load //some of the textures are not loading correctly so only make mesh if both the images load
if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){ if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){
meshes.push_back(ofMesh()); meshes.push_back(ofMesh());
@ -126,6 +134,9 @@ void ShadowScapesAnalysis::synthesise()
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS), image2, &meshes[index]); setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS), image2, &meshes[index]);
index++; index++;
} }
image1.clear();
image2.clear();
} }
} }
@ -223,21 +234,21 @@ void ShadowScapesAnalysis::draw()
if(_dir == V && int(_line) >= (ofGetHeight()+4*_scanLineWidth)){ if(_dir == V && int(_line) >= (ofGetHeight()+4*_scanLineWidth)){
cout << "VERTICAL IS DONE - _line >= (ofGetHeight()+4*_scanLineWidth) is TRUE" << endl; cout << "VERTICAL IS DONE - _line >= (ofGetHeight()+4*_scanLineWidth) is TRUE" << endl;
_state = STATE_SYNTHESISING; //_state = STATE_SYNTHESISING;
_RUN_DONE = true; _RUN_DONE = true;
} }
if(_dir == H && int(_line) >= (ofGetWidth()+4*_scanLineWidth)) { if(_dir == H && int(_line) >= (ofGetWidth()+4*_scanLineWidth)) {
//cout << "HORIZONTAL IS DONE - _line >= (ofGetWidth()+4*_scanLineWidth)) is TRUE" << endl; //cout << "HORIZONTAL IS DONE - _line >= (ofGetWidth()+4*_scanLineWidth)) is TRUE" << endl;
_state = STATE_SYNTHESISING; //_state = STATE_SYNTHESISING;
_RUN_DONE = true; _RUN_DONE = true;
} }
if(_dir == D && int(_line) >= (1.5*ofGetHeight()+4*_scanLineWidth)) { if(_dir == D && int(_line) >= (1.5*ofGetHeight()+4*_scanLineWidth)) {
//cout << "DIAGONAL IS DONE - _line >= (1.5*ofGetHeight()+4*_scanLineWidth)) is TRUE" << endl; //cout << "DIAGONAL IS DONE - _line >= (1.5*ofGetHeight()+4*_scanLineWidth)) is TRUE" << endl;
_state = STATE_SYNTHESISING; //_state = STATE_SYNTHESISING;
_RUN_DONE = true; _RUN_DONE = true;
} }
@ -288,6 +299,14 @@ void ShadowScapesAnalysis::draw()
void ShadowScapesAnalysis::save_cb(Timer& timer) void ShadowScapesAnalysis::save_cb(Timer& timer)
{ {
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
if (RefractiveIndex::_vidGrabber.isFrameNew())
{
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
}
cout << "ShadowScapesAnalysis::saving...\n"; cout << "ShadowScapesAnalysis::saving...\n";
string file_name; string file_name;
@ -302,9 +321,9 @@ void ShadowScapesAnalysis::save_cb(Timer& timer)
if(_dir == D) { if(_dir == D) {
file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 2)+"_"+ofToString(_run_cnt,2)+".jpg"; file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 2)+"_"+ofToString(_run_cnt,2)+".jpg";
} }
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); saveimage(file_name);
_save_cnt++; _save_cnt++;
} }

View File

@ -149,7 +149,7 @@ void ShapeFromShadingAnalysis::draw()
switch (_state) { switch (_state) {
case STATE_ACQUIRING: case STATE_ACQUIRING:
{ {
if (_frame_cnt <= _frame_cnt_max) if (_frame_cnt < _frame_cnt_max)
{ {
ofEnableAlphaBlending(); ofEnableAlphaBlending();
@ -420,13 +420,13 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer)
//cout << "ShapeFromShadingAnalysis::saving...\n"; //cout << "ShapeFromShadingAnalysis::saving...\n";
string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg"; string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg";
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST); saveimage(file_name);
_save_cnt++; _save_cnt++;
if(_save_cnt >= NUM_SAVE_PER_RUN) //if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true; // _RUN_DONE = true;
} }
void ShapeFromShadingAnalysis::display_results_cb(Timer& timer){ void ShapeFromShadingAnalysis::display_results_cb(Timer& timer){

View File

@ -132,6 +132,9 @@ void StrobeAnalysis::draw()
switch (_state) { switch (_state) {
case STATE_ACQUIRING: case STATE_ACQUIRING:
{
if (_frame_cnt < _frame_cnt_max)
{ {
ofEnableAlphaBlending(); ofEnableAlphaBlending();
ofColor aColour; ofColor aColour;
@ -176,8 +179,12 @@ void StrobeAnalysis::draw()
// cout << "FADE OUT STROBE TIME " << endl; // cout << "FADE OUT STROBE TIME " << endl;
} }
_frame_cnt++;
ofDisableAlphaBlending(); ofDisableAlphaBlending();
} else {
_RUN_DONE = true;
}
_frame_cnt++;
break; break;
} }
@ -225,9 +232,8 @@ void StrobeAnalysis::draw()
void StrobeAnalysis::save_cb(Timer& timer) void StrobeAnalysis::save_cb(Timer& timer)
{ {
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg"; string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg";
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name); saveimage(file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_save_cnt++; _save_cnt++;
cout << "_save_cnt" << _save_cnt << endl; cout << "_save_cnt" << _save_cnt << endl;
@ -235,9 +241,9 @@ void StrobeAnalysis::save_cb(Timer& timer)
cout << "_save_cnt_max" << _save_cnt_max << endl; cout << "_save_cnt_max" << _save_cnt_max << endl;
//TODO: something fucked here with my calc of _save_cnt_max - new structure should fix it? //TODO: something fucked here with my calc of _save_cnt_max - new structure should fix it?
if(_save_cnt >= _save_cnt_max-10) { //if(_save_cnt >= _save_cnt_max-10) {
_RUN_DONE = true; // _RUN_DONE = true;
} //}
} }