corrected file confusion
This commit is contained in:
parent
71e3a9a1db
commit
1d5d6abbde
@ -90,34 +90,57 @@ void ColorMultiAnalysis::acquire()
|
||||
|
||||
void ColorMultiAnalysis::synthesise()
|
||||
{
|
||||
cout<<"SYNTHESISING MULTI";
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
//incrementer to whichMesh
|
||||
speed=0.2;
|
||||
//whichMesh is the index in the vector of meshes
|
||||
whichMesh=0;
|
||||
|
||||
cout<<"image loaded ";
|
||||
//there is a problem with natural vs alphabetical order when loading the files - we need to make a fix for this
|
||||
int shift=0;
|
||||
cout<<_saved_filenames.size()<<" image filenames ";
|
||||
|
||||
int index=0;
|
||||
//for(int i=shift;i<_saved_filenames.size()-2;i+=2){
|
||||
// cout<<_saved_filenames[i]<<endl;
|
||||
|
||||
//if you want to see what this looks like with real data ignore the new filenames and load teh old ones.
|
||||
bool debug=true;
|
||||
if(debug){
|
||||
_saved_filenames.clear();
|
||||
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||
}
|
||||
|
||||
for(int i=0;i<_saved_filenames.size()-2;i+=2){
|
||||
|
||||
meshes.push_back(ofMesh());
|
||||
image1.loadImage("/Users/tomschofield/of_preRelease_v007_osx/apps/refracitveGitRepoFeb/RefractiveIndex/src/macro.png");
|
||||
/*ofImage image2;
|
||||
image2.loadImage(_saved_filenames[i+1]);
|
||||
ofImage image1;
|
||||
ofImage image2;
|
||||
|
||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BLUE), image2, &meshes[index]);
|
||||
*/
|
||||
index++;
|
||||
//}
|
||||
//there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false)
|
||||
image1.setUseTexture(false);
|
||||
image2.setUseTexture(false);
|
||||
//some of the textures are not loading correctly so only make mesh if both the images load
|
||||
if(image1.loadImage(_saved_filenames[0]) && image2.loadImage(_saved_filenames[i+1])){
|
||||
cout<<"setting mesh"<<endl;
|
||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_HUE), image2, &meshes[index]);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorMultiAnalysis::display_results(){
|
||||
|
||||
Timer* display_results_timer;
|
||||
|
||||
TimerCallback<ColorMultiAnalysis> display_results_callback(*this, &ColorMultiAnalysis::display_results_cb);
|
||||
// display results of the synthesis
|
||||
|
||||
display_results_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
|
||||
display_results_timer->start(display_results_callback);
|
||||
_RUN_DONE = false;
|
||||
_results_cnt=0;
|
||||
_results_cnt_max=500;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
Thread::sleep(3);
|
||||
|
||||
display_results_timer->stop();
|
||||
|
||||
}
|
||||
void ColorMultiAnalysis::draw()
|
||||
{
|
||||
|
||||
@ -171,12 +194,31 @@ void ColorMultiAnalysis::draw()
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
// display animation of something while the synthesis in on-going...
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
{
|
||||
int imageWidth=640;
|
||||
int imageHeight =480;
|
||||
ofPushMatrix();
|
||||
ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
|
||||
ofRotateY(_results_cnt*0.3);
|
||||
//ofRotateX(90);
|
||||
//ofRotateZ(whichMesh);
|
||||
ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400;
|
||||
ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 );
|
||||
|
||||
meshes[whichMesh].drawVertices();
|
||||
ofPopMatrix();
|
||||
whichMesh+=speed;
|
||||
|
||||
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||
speed*=-1;
|
||||
whichMesh+=speed;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -202,10 +244,16 @@ void ColorMultiAnalysis::save_cb(Timer& timer)
|
||||
|
||||
// cout<<_whole_file_path<<endl;
|
||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||
// _saved_filenames.push_back("/Users/tomschofield/of_preRelease_v007_osx/apps/myApps/refractiveIndexDavidFeb/bin/data/"+_whole_file_path+"/"+file_name);
|
||||
_saved_filenames.push_back("fish.jpg");
|
||||
|
||||
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
|
||||
if(_save_cnt >= NUM_SAVE_PER_RUN){
|
||||
_RUN_DONE = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ColorMultiAnalysis::display_results_cb(Timer& timer){
|
||||
_results_cnt++;
|
||||
if (_results_cnt>_results_cnt_max) {
|
||||
_RUN_DONE=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,14 +15,15 @@ public:
|
||||
void setup(int camWidth, int camHeight);
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void display_results();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
void display_results_cb(Poco::Timer& timer);
|
||||
|
||||
protected:
|
||||
|
||||
bool _RUN_DONE;
|
||||
int _run_cnt, _save_cnt, _fade_cnt;
|
||||
float c, _frame_cnt, _frame_cnt_max;
|
||||
ofImage image1;
|
||||
float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max;
|
||||
};
|
||||
|
||||
@ -15,10 +15,15 @@ using Poco::Timer;
|
||||
using Poco::TimerCallback;
|
||||
using Poco::Thread;
|
||||
|
||||
#define COMPARE_RED 1
|
||||
#define COMPARE_BLUE 2
|
||||
#define COMPARE_GREEN 3
|
||||
#define COMPARE_HUE 4
|
||||
#define COMPARE_BRIGHTNESS 5
|
||||
|
||||
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
||||
{
|
||||
DELTA_T_SAVE = 300;
|
||||
DELTA_T_SAVE = 100;//300;
|
||||
NUM_PHASE = 1;
|
||||
NUM_RUN = 1;
|
||||
NUM_SAVE_PER_RUN = 100;
|
||||
@ -64,9 +69,65 @@ void ColorSingleAnalysis::acquire()
|
||||
void ColorSingleAnalysis::synthesise()
|
||||
{
|
||||
// _saved_filenames has all the file names of all the saved images
|
||||
//incrementer to whichMesh
|
||||
speed=0.2;
|
||||
//whichMesh is the index in the vector of meshes
|
||||
whichMesh=0;
|
||||
|
||||
int index=0;
|
||||
|
||||
//if you want to see what this looks like with real data ignore the new filenames and load teh old ones.
|
||||
bool debug=false;
|
||||
if(debug){
|
||||
_saved_filenames.clear();
|
||||
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||
}
|
||||
|
||||
for(int i=1;i<_saved_filenames.size()-2;i+=2){
|
||||
|
||||
meshes.push_back(ofMesh());
|
||||
ofImage image1;
|
||||
ofImage image2;
|
||||
|
||||
//there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false)
|
||||
image1.setUseTexture(false);
|
||||
image2.setUseTexture(false);
|
||||
//some of the textures are not loading correctly so only make mesh if both the images load
|
||||
if(image1.loadImage(_saved_filenames[1]) && image2.loadImage(_saved_filenames[i+1])){
|
||||
|
||||
if(i<_saved_filenames.size()/3){
|
||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_RED), image2, &meshes[index]);
|
||||
}
|
||||
if(i>=_saved_filenames.size()/3 && i<2* _saved_filenames.size()/3){
|
||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_GREEN), image2, &meshes[index]);
|
||||
}
|
||||
if(i>= 2* _saved_filenames.size()/3 && i<_saved_filenames.size()){
|
||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BLUE), image2, &meshes[index]);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ColorSingleAnalysis::display_results(){
|
||||
|
||||
Timer* display_results_timer;
|
||||
|
||||
TimerCallback<ColorSingleAnalysis> display_results_callback(*this, &ColorSingleAnalysis::display_results_cb);
|
||||
// display results of the synthesis
|
||||
|
||||
display_results_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
|
||||
display_results_timer->start(display_results_callback);
|
||||
_RUN_DONE = false;
|
||||
_results_cnt=0;
|
||||
_results_cnt_max=500;
|
||||
|
||||
while(!_RUN_DONE)
|
||||
Thread::sleep(3);
|
||||
|
||||
display_results_timer->stop();
|
||||
|
||||
}
|
||||
void ColorSingleAnalysis::draw()
|
||||
{
|
||||
|
||||
@ -134,6 +195,25 @@ void ColorSingleAnalysis::draw()
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
// display results of the synthesis
|
||||
int imageWidth=640;
|
||||
int imageHeight =480;
|
||||
ofPushMatrix();
|
||||
ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
|
||||
ofRotateY(_results_cnt*0.3);
|
||||
//ofRotateX(90);
|
||||
//ofRotateZ(whichMesh);
|
||||
ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2),-400;
|
||||
ofTranslate((ofGetWidth()/2)-(imageWidth/2),0,0 );
|
||||
|
||||
meshes[whichMesh].drawVertices();
|
||||
ofPopMatrix();
|
||||
whichMesh+=speed;
|
||||
|
||||
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||
speed*=-1;
|
||||
whichMesh+=speed;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -152,11 +232,21 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
|
||||
|
||||
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
|
||||
|
||||
//cout<<ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
|
||||
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;
|
||||
|
||||
}
|
||||
void ColorSingleAnalysis::display_results_cb(Timer& timer){
|
||||
_results_cnt++;
|
||||
if (_results_cnt>_results_cnt_max) {
|
||||
_RUN_DONE=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,15 +19,17 @@ public:
|
||||
|
||||
void setup(int camWidth, int camHeight);
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void synthesise();
|
||||
void display_results();
|
||||
void draw();
|
||||
|
||||
void save_cb(Poco::Timer& timer);
|
||||
void display_results_cb(Poco::Timer& timer);
|
||||
|
||||
protected:
|
||||
|
||||
bool _RUN_DONE;
|
||||
string fileNameTag;
|
||||
int _run_cnt, _save_cnt, _fade_cnt;
|
||||
float r,g,b, _frame_cnt, _frame_cnt_max;
|
||||
float r,g,b, _frame_cnt, _frame_cnt_max , _results_cnt, _results_cnt_max;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user