added synthesise and display results to all analysis classes
This commit is contained in:
parent
3fd26c1eb4
commit
6b401b8424
@ -233,8 +233,8 @@ void AbstractAnalysis::setMeshFromPixels(ofPixels somePixels, ofImage currentSec
|
|||||||
vector<string>AbstractAnalysis:: getListOfImageFilePaths(string location, string whichAnalysis){
|
vector<string>AbstractAnalysis:: getListOfImageFilePaths(string location, string whichAnalysis){
|
||||||
|
|
||||||
string path = ofToDataPath("")+"debug_analysis/"+location+"/"+whichAnalysis;
|
string path = ofToDataPath("")+"debug_analysis/"+location+"/"+whichAnalysis;
|
||||||
ofxDirList dirList;
|
//ofxDirList dirList;
|
||||||
|
ofDirectory dirList;
|
||||||
int numDirs = dirList.listDir(path);
|
int numDirs = dirList.listDir(path);
|
||||||
|
|
||||||
vector<string>directoryNames;
|
vector<string>directoryNames;
|
||||||
@ -281,3 +281,35 @@ vector<string>AbstractAnalysis:: getListOfImageFilePaths(string location, string
|
|||||||
|
|
||||||
return fileNamesToReturn;
|
return fileNamesToReturn;
|
||||||
}
|
}
|
||||||
|
int AbstractAnalysis::getRecordedValueFromFileName(string str){
|
||||||
|
//split filename by underscore - there HAS to be a quicker way of doing things - its ONE LINE in java :(
|
||||||
|
char * cstr, *p;
|
||||||
|
vector<char *>tokens;
|
||||||
|
//string str ("Please split this phrase into tokens");
|
||||||
|
|
||||||
|
//make char pointer array
|
||||||
|
cstr = new char [str.size()+1];
|
||||||
|
//copy string to char pointer array
|
||||||
|
strcpy (cstr, str.c_str());
|
||||||
|
|
||||||
|
//tokenise char p array and put first results into pointer?
|
||||||
|
p=strtok (cstr,"_");
|
||||||
|
|
||||||
|
while (p!=NULL)
|
||||||
|
{
|
||||||
|
p=strtok(NULL,"_");
|
||||||
|
//push tokenised char into vector
|
||||||
|
tokens.push_back(p);
|
||||||
|
|
||||||
|
}
|
||||||
|
delete[] cstr;
|
||||||
|
char *p1;
|
||||||
|
//cstr = new char [str.size()+1];
|
||||||
|
//strcpy (cstr, str.c_str());
|
||||||
|
|
||||||
|
p1=strtok (tokens[tokens.size()-2],".");
|
||||||
|
|
||||||
|
return ofToInt(p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,12 @@
|
|||||||
#define STATE_DISPLAY_RESULTS 0x3333
|
#define STATE_DISPLAY_RESULTS 0x3333
|
||||||
#define STATE_STOP 0xDEADBEEF
|
#define STATE_STOP 0xDEADBEEF
|
||||||
|
|
||||||
|
#define COMPARE_RED 1
|
||||||
|
#define COMPARE_BLUE 2
|
||||||
|
#define COMPARE_GREEN 3
|
||||||
|
#define COMPARE_HUE 4
|
||||||
|
#define COMPARE_BRIGHTNESS 5
|
||||||
|
|
||||||
class AbstractAnalysis {
|
class AbstractAnalysis {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -49,9 +55,15 @@ protected:
|
|||||||
|
|
||||||
//uses the returned pixels from make3DZmap to make a mesh of points whose Z positions are set by the brightness values in ofPixels - ofPixels is being used as a convenient container for a bunch of z coordinates
|
//uses the returned pixels from make3DZmap to make a mesh of points whose Z positions are set by the brightness values in ofPixels - ofPixels is being used as a convenient container for a bunch of z coordinates
|
||||||
virtual void setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh);
|
virtual void setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh);
|
||||||
|
//HELPER FUNCTIONS
|
||||||
|
|
||||||
//this is purely for debug purposes and loads old images from middlesborough test
|
//this is purely for debug/viewing purposes and loads old images from middlesborough test
|
||||||
virtual vector<string> getListOfImageFilePaths(string location, string whichAnalysis);
|
virtual vector<string> getListOfImageFilePaths(string location, string whichAnalysis);
|
||||||
|
|
||||||
|
//splits up the filename and returns the recorded value eg brightness
|
||||||
|
//EG FILENAME : DIFF_NOISE_7_85.7322.jpg RETURNS : 85.7322
|
||||||
|
virtual int getRecordedValueFromFileName(string str);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string _name;
|
string _name;
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void CamNoiseAnalysis::setup(int camWidth, int camHeight)
|
void CamNoiseAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
DELTA_T_SAVE = 200;
|
DELTA_T_SAVE = 100;//200;
|
||||||
NUM_PHASE = 1;
|
NUM_PHASE = 1;
|
||||||
NUM_RUN = 1;
|
NUM_RUN = 1;
|
||||||
NUM_SAVE_PER_RUN = 100;
|
NUM_SAVE_PER_RUN = 100;
|
||||||
@ -59,9 +59,62 @@ void CamNoiseAnalysis::acquire()
|
|||||||
|
|
||||||
void CamNoiseAnalysis::synthesise()
|
void CamNoiseAnalysis::synthesise()
|
||||||
{
|
{
|
||||||
|
//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=true;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(int i=0;i<_saved_filenames.size()-1;i++){
|
||||||
|
|
||||||
|
|
||||||
|
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[i]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
|
int _recorded_hue_value=getRecordedValueFromFileName(_saved_filenames[i]);
|
||||||
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_HUE,_recorded_hue_value), image2, &meshes[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CamNoiseAnalysis::display_results(){
|
||||||
|
|
||||||
|
Timer* display_results_timer;
|
||||||
|
|
||||||
|
TimerCallback<CamNoiseAnalysis> display_results_callback(*this, &CamNoiseAnalysis::display_results_cb);
|
||||||
|
// display results of the synthesis
|
||||||
|
|
||||||
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
|
display_results_timer->start(display_results_callback);
|
||||||
|
_RUN_DONE = false;
|
||||||
|
_results_cnt=0;
|
||||||
|
_results_cnt_max=300;
|
||||||
|
|
||||||
|
while(!_RUN_DONE)
|
||||||
|
Thread::sleep(3);
|
||||||
|
|
||||||
|
display_results_timer->stop();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// this runs at frame rate = 33 ms for 30 FPS
|
// this runs at frame rate = 33 ms for 30 FPS
|
||||||
@ -128,6 +181,27 @@ void CamNoiseAnalysis::draw()
|
|||||||
case STATE_DISPLAY_RESULTS:
|
case STATE_DISPLAY_RESULTS:
|
||||||
{
|
{
|
||||||
// display results of the synthesis
|
// display results of the synthesis
|
||||||
|
// 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;
|
||||||
|
cout<<whichMesh<<" size of meshes "<<meshes.size()<<endl;
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,9 +225,15 @@ void CamNoiseAnalysis::save_cb(Timer& timer)
|
|||||||
|
|
||||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||||
|
|
||||||
_saved_filenames.push_back(file);
|
_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 CamNoiseAnalysis::display_results_cb(Timer& timer){
|
||||||
|
_results_cnt++;
|
||||||
|
if (_results_cnt>_results_cnt_max) {
|
||||||
|
_RUN_DONE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,16 +19,18 @@ public:
|
|||||||
|
|
||||||
void setup(int camWidth, int camHeight);
|
void setup(int camWidth, int camHeight);
|
||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
|
void display_results();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void save_cb(Poco::Timer& timer);
|
void save_cb(Poco::Timer& timer);
|
||||||
|
void display_results_cb(Poco::Timer& timer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool _RUN_DONE;
|
bool _RUN_DONE;
|
||||||
int _run_cnt, _save_cnt;
|
int _run_cnt, _save_cnt;
|
||||||
float c, _frame_cnt, _frame_cnt_max,_save_cnt_max ;
|
float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -41,11 +41,7 @@ using Poco::Timer;
|
|||||||
using Poco::TimerCallback;
|
using Poco::TimerCallback;
|
||||||
using Poco::Thread;
|
using Poco::Thread;
|
||||||
|
|
||||||
#define COMPARE_RED 1
|
|
||||||
#define COMPARE_BLUE 2
|
|
||||||
#define COMPARE_GREEN 3
|
|
||||||
#define COMPARE_HUE 4
|
|
||||||
#define COMPARE_BRIGHTNESS 5
|
|
||||||
|
|
||||||
void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
@ -98,15 +94,15 @@ void ColorMultiAnalysis::synthesise()
|
|||||||
int index=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.
|
//if you want to see what this looks like with real data ignore the new filenames and load teh old ones.
|
||||||
bool debug=true;
|
bool debug=false;
|
||||||
if(debug){
|
if(debug){
|
||||||
_saved_filenames.clear();
|
_saved_filenames.clear();
|
||||||
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
}
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
for(int i=0;i<_saved_filenames.size()-2;i+=2){
|
for(int i=0;i<_saved_filenames.size()-2;i+=2){
|
||||||
|
|
||||||
meshes.push_back(ofMesh());
|
|
||||||
ofImage image1;
|
ofImage image1;
|
||||||
ofImage image2;
|
ofImage image2;
|
||||||
|
|
||||||
@ -116,6 +112,7 @@ void ColorMultiAnalysis::synthesise()
|
|||||||
//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[0]) && image2.loadImage(_saved_filenames[i+1])){
|
if(image1.loadImage(_saved_filenames[0]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
cout<<"setting mesh"<<endl;
|
cout<<"setting mesh"<<endl;
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_HUE), image2, &meshes[index]);
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_HUE), image2, &meshes[index]);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,11 +15,6 @@ using Poco::Timer;
|
|||||||
using Poco::TimerCallback;
|
using Poco::TimerCallback;
|
||||||
using Poco::Thread;
|
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)
|
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
@ -77,15 +72,15 @@ void ColorSingleAnalysis::synthesise()
|
|||||||
int index=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.
|
//if you want to see what this looks like with real data ignore the new filenames and load teh old ones.
|
||||||
bool debug=false;
|
bool debug=true;
|
||||||
if(debug){
|
if(debug){
|
||||||
_saved_filenames.clear();
|
_saved_filenames.clear();
|
||||||
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
}
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
for(int i=1;i<_saved_filenames.size()-2;i+=2){
|
for(int i=1;i<_saved_filenames.size()-2;i+=2){
|
||||||
|
|
||||||
meshes.push_back(ofMesh());
|
|
||||||
ofImage image1;
|
ofImage image1;
|
||||||
ofImage image2;
|
ofImage image2;
|
||||||
|
|
||||||
@ -94,7 +89,8 @@ void ColorSingleAnalysis::synthesise()
|
|||||||
image2.setUseTexture(false);
|
image2.setUseTexture(false);
|
||||||
//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());
|
||||||
|
|
||||||
if(i<_saved_filenames.size()/3){
|
if(i<_saved_filenames.size()/3){
|
||||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_RED), image2, &meshes[index]);
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_RED), image2, &meshes[index]);
|
||||||
}
|
}
|
||||||
@ -116,7 +112,7 @@ void ColorSingleAnalysis::display_results(){
|
|||||||
TimerCallback<ColorSingleAnalysis> display_results_callback(*this, &ColorSingleAnalysis::display_results_cb);
|
TimerCallback<ColorSingleAnalysis> display_results_callback(*this, &ColorSingleAnalysis::display_results_cb);
|
||||||
// display results of the synthesis
|
// display results of the synthesis
|
||||||
|
|
||||||
display_results_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
display_results_timer->start(display_results_callback);
|
display_results_timer->start(display_results_callback);
|
||||||
_RUN_DONE = false;
|
_RUN_DONE = false;
|
||||||
_results_cnt=0;
|
_results_cnt=0;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
|
void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
DELTA_T_SAVE = 600; // right number is about 450
|
DELTA_T_SAVE = 100;//600; // right number is about 450
|
||||||
NUM_PHASE = 1;
|
NUM_PHASE = 1;
|
||||||
NUM_RUN = 1;
|
NUM_RUN = 1;
|
||||||
NUM_SAVE_PER_RUN = 50;
|
NUM_SAVE_PER_RUN = 50;
|
||||||
@ -59,11 +59,63 @@ void DiffNoiseAnalysis::acquire()
|
|||||||
|
|
||||||
void DiffNoiseAnalysis::synthesise()
|
void DiffNoiseAnalysis::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=true;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(int i=0;i<_saved_filenames.size()-1;i++){
|
||||||
|
|
||||||
|
|
||||||
|
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[i]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
|
int _recorded_brightness_value=getRecordedValueFromFileName(_saved_filenames[i]);
|
||||||
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_HUE,_recorded_brightness_value), image2, &meshes[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiffNoiseAnalysis::display_results(){
|
||||||
|
|
||||||
|
Timer* display_results_timer;
|
||||||
|
|
||||||
|
TimerCallback<DiffNoiseAnalysis> display_results_callback(*this, &DiffNoiseAnalysis::display_results_cb);
|
||||||
|
// display results of the synthesis
|
||||||
|
|
||||||
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
|
display_results_timer->start(display_results_callback);
|
||||||
|
_RUN_DONE = false;
|
||||||
|
_results_cnt=0;
|
||||||
|
_results_cnt_max=300;
|
||||||
|
|
||||||
|
while(!_RUN_DONE)
|
||||||
|
Thread::sleep(3);
|
||||||
|
|
||||||
|
display_results_timer->stop();
|
||||||
|
|
||||||
|
}// this runs at frame rate = 33 ms for 30 FPS
|
||||||
|
|
||||||
// this runs at frame rate = 33 ms for 30 FPS
|
|
||||||
void DiffNoiseAnalysis::draw()
|
void DiffNoiseAnalysis::draw()
|
||||||
{
|
{
|
||||||
switch (_state) {
|
switch (_state) {
|
||||||
@ -144,6 +196,28 @@ void DiffNoiseAnalysis::draw()
|
|||||||
case STATE_DISPLAY_RESULTS:
|
case STATE_DISPLAY_RESULTS:
|
||||||
{
|
{
|
||||||
// display results of the synthesis
|
// display results of the synthesis
|
||||||
|
// 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;
|
||||||
|
cout<<whichMesh<<" size of meshes "<<meshes.size()<<endl;
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +252,7 @@ void DiffNoiseAnalysis::save_cb(Timer& timer)
|
|||||||
|
|
||||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||||
|
|
||||||
_saved_filenames.push_back(file);
|
_saved_filenames.push_back(ofToDataPath("")+file);
|
||||||
|
|
||||||
}
|
}
|
||||||
_save_cnt++;
|
_save_cnt++;
|
||||||
@ -186,3 +260,11 @@ void DiffNoiseAnalysis::save_cb(Timer& timer)
|
|||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void DiffNoiseAnalysis::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 setup(int camWidth, int camHeight);
|
||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
|
void display_results();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void save_cb(Poco::Timer& timer);
|
void save_cb(Poco::Timer& timer);
|
||||||
|
void display_results_cb(Poco::Timer& timer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool _RUN_DONE;
|
bool _RUN_DONE;
|
||||||
int _run_cnt, _save_cnt, _fade_cnt;
|
int _run_cnt, _save_cnt, _fade_cnt;
|
||||||
float c, _frame_cnt, _frame_cnt_max;
|
float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,12 +15,14 @@ using Poco::Timer;
|
|||||||
using Poco::TimerCallback;
|
using Poco::TimerCallback;
|
||||||
using Poco::Thread;
|
using Poco::Thread;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IResponseAnalysis::setup(int camWidth, int camHeight)
|
void IResponseAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
DELTA_T_SAVE = 100;
|
DELTA_T_SAVE = 100;
|
||||||
NUM_PHASE = 1;
|
NUM_PHASE = 1;
|
||||||
NUM_RUN = 1;
|
NUM_RUN = 1;
|
||||||
NUM_SAVE_PER_RUN = 100;
|
NUM_SAVE_PER_RUN = 50;//100;
|
||||||
|
|
||||||
create_dir();
|
create_dir();
|
||||||
_frame_cnt = 0;
|
_frame_cnt = 0;
|
||||||
@ -55,11 +57,65 @@ void IResponseAnalysis::acquire()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IResponseAnalysis::synthesise()
|
void IResponseAnalysis::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=true;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(int i=0;i<_saved_filenames.size()-1;i++){
|
||||||
|
|
||||||
|
|
||||||
|
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[i]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
|
int _recorded_brightness_value=getRecordedValueFromFileName(_saved_filenames[i]);
|
||||||
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS,_recorded_brightness_value), image2, &meshes[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IResponseAnalysis::display_results(){
|
||||||
|
|
||||||
|
Timer* display_results_timer;
|
||||||
|
|
||||||
|
TimerCallback<IResponseAnalysis> display_results_callback(*this, &IResponseAnalysis::display_results_cb);
|
||||||
|
// display results of the synthesis
|
||||||
|
|
||||||
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
|
display_results_timer->start(display_results_callback);
|
||||||
|
_RUN_DONE = false;
|
||||||
|
_results_cnt=0;
|
||||||
|
_results_cnt_max=300;
|
||||||
|
|
||||||
|
while(!_RUN_DONE)
|
||||||
|
Thread::sleep(3);
|
||||||
|
|
||||||
|
display_results_timer->stop();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// this runs at frame rate = 33 ms for 30 FPS
|
// this runs at frame rate = 33 ms for 30 FPS
|
||||||
@ -88,6 +144,7 @@ void IResponseAnalysis::draw()
|
|||||||
|
|
||||||
case STATE_SYNTHESISING:
|
case STATE_SYNTHESISING:
|
||||||
{
|
{
|
||||||
|
|
||||||
// display animation of something while the synthesis in on-going...
|
// display animation of something while the synthesis in on-going...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -95,6 +152,26 @@ void IResponseAnalysis::draw()
|
|||||||
case STATE_DISPLAY_RESULTS:
|
case STATE_DISPLAY_RESULTS:
|
||||||
{
|
{
|
||||||
// display results of the synthesis
|
// 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;
|
||||||
|
cout<<whichMesh<<" size of meshes "<<meshes.size()<<endl;
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,9 +195,18 @@ void IResponseAnalysis::save_cb(Timer& timer)
|
|||||||
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||||
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
|
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
|
||||||
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
|
//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);
|
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||||
|
|
||||||
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
if(_save_cnt >= NUM_SAVE_PER_RUN)
|
||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
}
|
}
|
||||||
|
void IResponseAnalysis::display_results_cb(Timer& timer){
|
||||||
|
_results_cnt++;
|
||||||
|
if (_results_cnt>_results_cnt_max) {
|
||||||
|
_RUN_DONE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,16 +19,18 @@ public:
|
|||||||
|
|
||||||
void setup(int camWidth, int camHeight);
|
void setup(int camWidth, int camHeight);
|
||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
|
void display_results();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void save_cb(Poco::Timer& timer);
|
void save_cb(Poco::Timer& timer);
|
||||||
|
void display_results_cb(Poco::Timer& timer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool _RUN_DONE;
|
bool _RUN_DONE;
|
||||||
int _run_cnt, _save_cnt;
|
int _run_cnt, _save_cnt;
|
||||||
float c, _frame_cnt, _frame_cnt_max;
|
float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -18,10 +18,10 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
DELTA_T_SAVE = 300;
|
DELTA_T_SAVE = 100;//300;
|
||||||
NUM_PHASE = 1;
|
NUM_PHASE = 1;
|
||||||
NUM_RUN = 1;
|
NUM_RUN = 1;
|
||||||
NUM_SAVE_PER_RUN = 100;
|
NUM_SAVE_PER_RUN = 50;//100;
|
||||||
|
|
||||||
create_dir();
|
create_dir();
|
||||||
|
|
||||||
@ -61,8 +61,62 @@ void RelaxRateAnalysis::acquire()
|
|||||||
|
|
||||||
void RelaxRateAnalysis::synthesise()
|
void RelaxRateAnalysis::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=true;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(int i=0;i<_saved_filenames.size()-1;i++){
|
||||||
|
|
||||||
|
|
||||||
|
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[i]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
|
int _recorded_brightness_value=getRecordedValueFromFileName(_saved_filenames[i]);
|
||||||
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS,_recorded_brightness_value), image2, &meshes[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void RelaxRateAnalysis::display_results(){
|
||||||
|
|
||||||
|
Timer* display_results_timer;
|
||||||
|
|
||||||
|
TimerCallback<RelaxRateAnalysis> display_results_callback(*this, &RelaxRateAnalysis::display_results_cb);
|
||||||
|
// display results of the synthesis
|
||||||
|
|
||||||
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
|
display_results_timer->start(display_results_callback);
|
||||||
|
_RUN_DONE = false;
|
||||||
|
_results_cnt=0;
|
||||||
|
_results_cnt_max=300;
|
||||||
|
|
||||||
|
while(!_RUN_DONE)
|
||||||
|
Thread::sleep(3);
|
||||||
|
|
||||||
|
display_results_timer->stop();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// this runs at frame rate = 33 ms for 30 FPS
|
// this runs at frame rate = 33 ms for 30 FPS
|
||||||
void RelaxRateAnalysis::draw()
|
void RelaxRateAnalysis::draw()
|
||||||
@ -111,6 +165,27 @@ 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
|
||||||
|
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;
|
||||||
|
cout<<whichMesh<<" size of meshes "<<meshes.size()<<endl;
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,9 +211,16 @@ void RelaxRateAnalysis::save_cb(Timer& timer)
|
|||||||
|
|
||||||
ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST);
|
ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST);
|
||||||
|
|
||||||
_saved_filenames.push_back(file);
|
_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){
|
||||||
|
_results_cnt++;
|
||||||
|
if (_results_cnt>_results_cnt_max) {
|
||||||
|
_RUN_DONE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,16 +20,18 @@ public:
|
|||||||
|
|
||||||
void setup(int camWidth, int camHeight);
|
void setup(int camWidth, int camHeight);
|
||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
|
void display_results();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void save_cb(Poco::Timer& timer);
|
void save_cb(Poco::Timer& timer);
|
||||||
|
void display_results_cb(Poco::Timer& timer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool _RUN_DONE;
|
bool _RUN_DONE;
|
||||||
float _flip, _level;
|
float _flip, _level;
|
||||||
int _run_cnt, _save_cnt;
|
int _run_cnt, _save_cnt;
|
||||||
float c, _frame_cnt, _frame_cnt_max;
|
float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -89,10 +89,62 @@ void ShadowScapesAnalysis::acquire()
|
|||||||
|
|
||||||
void ShadowScapesAnalysis::synthesise()
|
void ShadowScapesAnalysis::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);
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(int i=0;i<_saved_filenames.size()-1;i++){
|
||||||
|
|
||||||
|
|
||||||
|
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[i]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS), image2, &meshes[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ShadowScapesAnalysis::display_results(){
|
||||||
|
|
||||||
|
Timer* display_results_timer;
|
||||||
|
|
||||||
|
TimerCallback<ShadowScapesAnalysis> display_results_callback(*this, &ShadowScapesAnalysis::display_results_cb);
|
||||||
|
// display results of the synthesis
|
||||||
|
|
||||||
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
|
display_results_timer->start(display_results_callback);
|
||||||
|
_RUN_DONE = false;
|
||||||
|
_results_cnt=0;
|
||||||
|
_results_cnt_max=300;
|
||||||
|
|
||||||
|
while(!_RUN_DONE)
|
||||||
|
Thread::sleep(3);
|
||||||
|
|
||||||
|
display_results_timer->stop();
|
||||||
|
|
||||||
|
}
|
||||||
// the animation draw - and the output draw
|
// the animation draw - and the output draw
|
||||||
void ShadowScapesAnalysis::draw()
|
void ShadowScapesAnalysis::draw()
|
||||||
{
|
{
|
||||||
@ -191,13 +243,33 @@ void ShadowScapesAnalysis::draw()
|
|||||||
{
|
{
|
||||||
// display animation of something while the synthesis in on-going...
|
// display animation of something while the synthesis in on-going...
|
||||||
|
|
||||||
_state = STATE_DISPLAY_RESULTS;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case STATE_DISPLAY_RESULTS:
|
case STATE_DISPLAY_RESULTS:
|
||||||
{
|
{
|
||||||
// display results of the synthesis
|
// display results of the synthesis
|
||||||
|
// 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;
|
||||||
|
cout<<whichMesh<<" size of meshes "<<meshes.size()<<endl;
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,8 +297,16 @@ 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);
|
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||||
_save_cnt++;
|
_save_cnt++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void ShadowScapesAnalysis::display_results_cb(Timer& timer){
|
||||||
|
_results_cnt++;
|
||||||
|
if (_results_cnt>_results_cnt_max) {
|
||||||
|
_RUN_DONE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,10 +51,12 @@ public:
|
|||||||
|
|
||||||
void setup(int camWidth, int camHeight);
|
void setup(int camWidth, int camHeight);
|
||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
|
void display_results();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void save_cb(Poco::Timer& timer);
|
void save_cb(Poco::Timer& timer);
|
||||||
|
void display_results_cb(Poco::Timer& timer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -65,6 +67,6 @@ protected:
|
|||||||
float _step;
|
float _step;
|
||||||
shadow_type _dir;
|
shadow_type _dir;
|
||||||
int _run_cnt, _save_cnt;
|
int _run_cnt, _save_cnt;
|
||||||
float c, _frame_cnt, _frame_cnt_max;
|
float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -77,9 +77,64 @@ void ShapeFromShadingAnalysis::acquire()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ShapeFromShadingAnalysis::synthesise()
|
void ShapeFromShadingAnalysis::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);
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(int i=0;i<_saved_filenames.size()-1;i++){
|
||||||
|
|
||||||
|
|
||||||
|
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[i]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
|
int _recorded_brightness_value=getRecordedValueFromFileName(_saved_filenames[i]);
|
||||||
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS,_recorded_brightness_value), image2, &meshes[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShapeFromShadingAnalysis::display_results(){
|
||||||
|
|
||||||
|
Timer* display_results_timer;
|
||||||
|
|
||||||
|
TimerCallback<ShapeFromShadingAnalysis> display_results_callback(*this, &ShapeFromShadingAnalysis::display_results_cb);
|
||||||
|
// display results of the synthesis
|
||||||
|
|
||||||
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
|
display_results_timer->start(display_results_callback);
|
||||||
|
_RUN_DONE = false;
|
||||||
|
_results_cnt=0;
|
||||||
|
_results_cnt_max=300;
|
||||||
|
|
||||||
|
while(!_RUN_DONE)
|
||||||
|
Thread::sleep(3);
|
||||||
|
|
||||||
|
display_results_timer->stop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this runs at frame rate = 33 ms for 30 FPS
|
// this runs at frame rate = 33 ms for 30 FPS
|
||||||
@ -323,6 +378,26 @@ void ShapeFromShadingAnalysis::draw()
|
|||||||
case STATE_DISPLAY_RESULTS:
|
case STATE_DISPLAY_RESULTS:
|
||||||
{
|
{
|
||||||
// display results of the synthesis
|
// 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;
|
||||||
|
cout<<whichMesh<<" size of meshes "<<meshes.size()<<endl;
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +415,8 @@ 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);
|
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||||
_save_cnt++;
|
_save_cnt++;
|
||||||
|
|
||||||
@ -348,3 +424,11 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer)
|
|||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void ShapeFromShadingAnalysis::display_results_cb(Timer& timer){
|
||||||
|
_results_cnt++;
|
||||||
|
if (_results_cnt>_results_cnt_max) {
|
||||||
|
_RUN_DONE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,12 @@ public:
|
|||||||
|
|
||||||
void setup(int camWidth, int camHeight);
|
void setup(int camWidth, int camHeight);
|
||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
|
void display_results();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void save_cb(Poco::Timer& timer);
|
void save_cb(Poco::Timer& timer);
|
||||||
|
void display_results_cb(Poco::Timer& timer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -48,6 +50,6 @@ protected:
|
|||||||
int _animation_cnt15;
|
int _animation_cnt15;
|
||||||
int _animation_cnt16;
|
int _animation_cnt16;
|
||||||
int _animation_reset; // this reset part didn't get working - so using 16 different counters! yay!
|
int _animation_reset; // this reset part didn't get working - so using 16 different counters! yay!
|
||||||
float c, _frame_cnt, _frame_cnt_max;
|
float c, _frame_cnt, _frame_cnt_max, _results_cnt, _results_cnt_max;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -64,7 +64,61 @@ void StrobeAnalysis::acquire()
|
|||||||
|
|
||||||
void StrobeAnalysis::synthesise()
|
void StrobeAnalysis::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);
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(int i=0;i<_saved_filenames.size()-1;i++){
|
||||||
|
|
||||||
|
|
||||||
|
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[i]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
meshes.push_back(ofMesh());
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
|
int _recorded_brightness_value=getRecordedValueFromFileName(_saved_filenames[i]);
|
||||||
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS,_recorded_brightness_value), image2, &meshes[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void StrobeAnalysis::display_results(){
|
||||||
|
|
||||||
|
Timer* display_results_timer;
|
||||||
|
|
||||||
|
TimerCallback<StrobeAnalysis> display_results_callback(*this, &StrobeAnalysis::display_results_cb);
|
||||||
|
// display results of the synthesis
|
||||||
|
|
||||||
|
display_results_timer = new Timer(0, 20); // timing interval for saving files
|
||||||
|
display_results_timer->start(display_results_callback);
|
||||||
|
_RUN_DONE = false;
|
||||||
|
_results_cnt=0;
|
||||||
|
_results_cnt_max=300;
|
||||||
|
|
||||||
|
while(!_RUN_DONE)
|
||||||
|
Thread::sleep(3);
|
||||||
|
|
||||||
|
display_results_timer->stop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this runs at frame rate = 33 ms for 30 FPS
|
// this runs at frame rate = 33 ms for 30 FPS
|
||||||
@ -132,6 +186,26 @@ void StrobeAnalysis::draw()
|
|||||||
case STATE_DISPLAY_RESULTS:
|
case STATE_DISPLAY_RESULTS:
|
||||||
{
|
{
|
||||||
// display results of the synthesis
|
// 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;
|
||||||
|
cout<<whichMesh<<" size of meshes "<<meshes.size()<<endl;
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +220,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);
|
||||||
|
|
||||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||||
_save_cnt++;
|
_save_cnt++;
|
||||||
|
|
||||||
@ -159,3 +235,12 @@ void StrobeAnalysis::save_cb(Timer& timer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StrobeAnalysis::display_results_cb(Timer& timer){
|
||||||
|
_results_cnt++;
|
||||||
|
if (_results_cnt>_results_cnt_max) {
|
||||||
|
_RUN_DONE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,12 @@ public:
|
|||||||
|
|
||||||
void setup(int camWidth, int camHeight);
|
void setup(int camWidth, int camHeight);
|
||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
|
void display_results();
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
void save_cb(Poco::Timer& timer);
|
void save_cb(Poco::Timer& timer);
|
||||||
|
void display_results_cb(Poco::Timer& timer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -32,6 +34,8 @@ protected:
|
|||||||
int _save_cnt;
|
int _save_cnt;
|
||||||
|
|
||||||
int _frame_cnt, _frame_cnt_max, _save_cnt_max ;
|
int _frame_cnt, _frame_cnt_max, _save_cnt_max ;
|
||||||
|
float _results_cnt, _results_cnt_max;
|
||||||
|
|
||||||
int _strobe_interval;
|
int _strobe_interval;
|
||||||
bool _strobe_on;
|
bool _strobe_on;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user