merged with tom
This commit is contained in:
commit
3649211943
@ -34,6 +34,9 @@
|
|||||||
#include "RefractiveIndex.h"
|
#include "RefractiveIndex.h"
|
||||||
#include "ofxFileHelper.h"
|
#include "ofxFileHelper.h"
|
||||||
|
|
||||||
|
|
||||||
|
vector<ofMesh> AbstractAnalysis::meshes;
|
||||||
|
|
||||||
// this is the main threaded loop for a given analysis
|
// this is the main threaded loop for a given analysis
|
||||||
void AbstractAnalysis::do_synthesize() {
|
void AbstractAnalysis::do_synthesize() {
|
||||||
_state = STATE_ACQUIRING;
|
_state = STATE_ACQUIRING;
|
||||||
@ -41,6 +44,7 @@ void AbstractAnalysis::do_synthesize() {
|
|||||||
_state = STATE_SYNTHESISING;
|
_state = STATE_SYNTHESISING;
|
||||||
synthesise();
|
synthesise();
|
||||||
_state = STATE_DISPLAY_RESULTS;
|
_state = STATE_DISPLAY_RESULTS;
|
||||||
|
display_results();
|
||||||
ofNotifyEvent(_synthesize_cb, _name);
|
ofNotifyEvent(_synthesize_cb, _name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +147,70 @@ ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnalysis:: setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh){
|
ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison, int colourValue){
|
||||||
|
//zScale is the mapping factor from pixel difference to shift on the zPlane
|
||||||
|
int zScale=200;
|
||||||
|
|
||||||
|
ofPixels imagePixels1 = image1.getPixelsRef();
|
||||||
|
ofPixels imagePixels2 = image2.getPixelsRef();
|
||||||
|
|
||||||
|
ofPixels difference;
|
||||||
|
//this unsigned char should be unnecessary - I would have thought - can't you just address the pixel locations in ofPixels directly?
|
||||||
|
unsigned char * thesePixels = new unsigned char[ imagePixels1.getWidth()*imagePixels1.getHeight()*3];
|
||||||
|
|
||||||
|
//where are we in the image pixel array
|
||||||
|
int x=0;
|
||||||
|
int y=0;
|
||||||
|
|
||||||
|
//for each pixel...
|
||||||
|
for(int i=0;i<imagePixels1.size();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
|
||||||
|
ofColor colourImage1 = imagePixels1.getColor(x, y);
|
||||||
|
ofColor colourImage2 = imagePixels2.getColor(x, y);
|
||||||
|
|
||||||
|
//COMPARE THIS PIXEL'S VALUES with the first image in the sequence
|
||||||
|
int thisDiff;
|
||||||
|
//compare Red
|
||||||
|
if (whichComparison==1) {
|
||||||
|
thisDiff=ofMap((colourImage1.r-colourImage2.r),-255,255,0,zScale);
|
||||||
|
}
|
||||||
|
//compare blue
|
||||||
|
if (whichComparison==2) {
|
||||||
|
thisDiff=ofMap((colourImage1.g-colourImage2.g),-255,255,0,zScale);
|
||||||
|
}
|
||||||
|
//compare green
|
||||||
|
if (whichComparison==3) {
|
||||||
|
thisDiff=ofMap((colourImage1.b-colourImage2.b),-255,255,0,zScale);
|
||||||
|
}
|
||||||
|
//compare hue
|
||||||
|
if (whichComparison==4) {
|
||||||
|
thisDiff=ofMap((colourImage1.getHue()-colourImage2.getHue()),-255,255,0,zScale);
|
||||||
|
}
|
||||||
|
//compare brightness
|
||||||
|
if (whichComparison==5) {
|
||||||
|
thisDiff=ofMap((colourImage1.getBrightness()-colourImage2.getBrightness()),-255,255,0,zScale);
|
||||||
|
}
|
||||||
|
thesePixels[i]=thisDiff;
|
||||||
|
thesePixels[i+1]=thisDiff;
|
||||||
|
thesePixels[i+2]=thisDiff;
|
||||||
|
|
||||||
|
x++;
|
||||||
|
//new line
|
||||||
|
if(x>imagePixels1.getWidth()){
|
||||||
|
x=0;
|
||||||
|
y++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
difference.setFromPixels(thesePixels,imagePixels1.getWidth(),imagePixels1.getHeight(), 3);
|
||||||
|
|
||||||
|
return difference;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractAnalysis::setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh){
|
||||||
int x=0;
|
int x=0;
|
||||||
int y=0;
|
int y=0;
|
||||||
|
|
||||||
@ -165,3 +232,87 @@ void AbstractAnalysis:: setMeshFromPixels(ofPixels somePixels, ofImage currentSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<string>AbstractAnalysis:: getListOfImageFilePaths(string location, string whichAnalysis){
|
||||||
|
|
||||||
|
string path = ofToDataPath("")+"debug_analysis/"+location+"/"+whichAnalysis;
|
||||||
|
//ofxDirList dirList;
|
||||||
|
ofDirectory dirList;
|
||||||
|
int numDirs = dirList.listDir(path);
|
||||||
|
|
||||||
|
vector<string>directoryNames;
|
||||||
|
|
||||||
|
//get the last folder alphabetically - this should probably change to do something fancy with date to find most recent but don't want to code that until we are sure
|
||||||
|
string dirName=dirList.getName(numDirs-1);
|
||||||
|
|
||||||
|
|
||||||
|
const char *results=dirName.c_str();
|
||||||
|
|
||||||
|
ofFile file=ofFile(path+"/"+dirName);
|
||||||
|
vector<string>fileNamesToReturn;
|
||||||
|
|
||||||
|
|
||||||
|
// get
|
||||||
|
if(file.isDirectory()){
|
||||||
|
dirList.listDir(path+"/"+dirName);
|
||||||
|
//if there are no files, exit here
|
||||||
|
if(dirList.size()==0){
|
||||||
|
//if it's empty return an error warning
|
||||||
|
fileNamesToReturn.push_back("NO FILE HERE!");
|
||||||
|
cout<<"NO FILE HERE!";
|
||||||
|
return fileNamesToReturn;
|
||||||
|
}
|
||||||
|
for (int i=0; i<dirList.size(); i++) {
|
||||||
|
|
||||||
|
string fname=dirList.getName(i);
|
||||||
|
const char *results=fname.c_str();
|
||||||
|
|
||||||
|
//full path is what actually gets written into the vector
|
||||||
|
string fullPath=path+"/"+dirName+"/"+fname;
|
||||||
|
|
||||||
|
|
||||||
|
fileNamesToReturn.push_back(fullPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
cout<<"WARNING, DIRECTORY NOT FOUND";
|
||||||
|
fileNamesToReturn.push_back("NO FILE HERE!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
@ -40,9 +46,26 @@ protected:
|
|||||||
// analysis + synthesize images - all the children (see - do_synthesize)
|
// analysis + synthesize images - all the children (see - do_synthesize)
|
||||||
virtual void synthesise() = 0;
|
virtual void synthesise() = 0;
|
||||||
|
|
||||||
virtual ofPixels calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison);
|
//added tom s 19/2 function runs a call back exactly like acquire.
|
||||||
|
virtual void display_results() = 0;
|
||||||
|
|
||||||
|
//returns ofPixels which contain the color differences between the two images. Is overloaded to include comparison with values written in to file names for some analyses
|
||||||
|
virtual ofPixels calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison);
|
||||||
|
virtual ofPixels calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison, int colourValue);
|
||||||
|
|
||||||
|
//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/viewing purposes and loads old images from middlesborough test
|
||||||
|
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);
|
||||||
|
|
||||||
|
static vector<ofMesh>meshes;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string _name;
|
string _name;
|
||||||
@ -64,7 +87,7 @@ protected:
|
|||||||
|
|
||||||
//added Tom S 19/2/12
|
//added Tom S 19/2/12
|
||||||
//each mesh in the vector is a seperate 3D point cloud which is coloured with pixel data and shifted in the z plane according to the specified type of colour difference eg red value or hue
|
//each mesh in the vector is a seperate 3D point cloud which is coloured with pixel data and shifted in the z plane according to the specified type of colour difference eg red value or hue
|
||||||
vector<ofMesh>meshes;
|
//make this vector were static
|
||||||
//how fast to move from one mesh to the next
|
//how fast to move from one mesh to the next
|
||||||
float speed;
|
float speed;
|
||||||
//the index (inside the vector of meshes) of the current mesh being displayed
|
//the index (inside the vector of meshes) of the current mesh being displayed
|
||||||
|
|||||||
@ -59,9 +59,68 @@ 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;
|
||||||
|
float iterator=1;
|
||||||
|
//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);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
@ -136,6 +195,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,9 +239,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -20,15 +20,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;
|
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,15 +41,11 @@ 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)
|
||||||
{
|
{
|
||||||
DELTA_T_SAVE = 50;//150; // the right number is about 300
|
DELTA_T_SAVE = 100;//150; // the right number is about 300
|
||||||
NUM_PHASE = 1;
|
NUM_PHASE = 1;
|
||||||
NUM_RUN = 1;
|
NUM_RUN = 1;
|
||||||
NUM_SAVE_PER_RUN = 100;//;
|
NUM_SAVE_PER_RUN = 100;//;
|
||||||
@ -90,34 +86,64 @@ void ColorMultiAnalysis::acquire()
|
|||||||
|
|
||||||
void ColorMultiAnalysis::synthesise()
|
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
|
//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
|
||||||
whichMesh=0;
|
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;
|
int index=0;
|
||||||
//for(int i=shift;i<_saved_filenames.size()-2;i+=2){
|
float iterator=1;
|
||||||
// cout<<_saved_filenames[i]<<endl;
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
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[0]) && image2.loadImage(_saved_filenames[i+1])){
|
||||||
|
cout<<"setting mesh"<<endl;
|
||||||
meshes.push_back(ofMesh());
|
meshes.push_back(ofMesh());
|
||||||
image1.loadImage("/Users/tomschofield/of_preRelease_v007_osx/apps/refracitveGitRepoFeb/RefractiveIndex/src/macro.png");
|
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_HUE), image2, &meshes[index]);
|
||||||
/*ofImage image2;
|
|
||||||
image2.loadImage(_saved_filenames[i+1]);
|
|
||||||
|
|
||||||
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BLUE), image2, &meshes[index]);
|
|
||||||
*/
|
|
||||||
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()
|
void ColorMultiAnalysis::draw()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -182,12 +208,31 @@ void ColorMultiAnalysis::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
case STATE_DISPLAY_RESULTS:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,10 +258,14 @@ void ColorMultiAnalysis::save_cb(Timer& timer)
|
|||||||
|
|
||||||
// cout<<_whole_file_path<<endl;
|
// cout<<_whole_file_path<<endl;
|
||||||
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
// _saved_filenames.push_back("/Users/tomschofield/of_preRelease_v007_osx/apps/myApps/refractiveIndexDavidFeb/bin/data/"+_whole_file_path+"/"+file_name);
|
// _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("fish.jpg");
|
||||||
|
|
||||||
|
=======
|
||||||
|
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
|
||||||
|
>>>>>>> tom
|
||||||
if(_save_cnt >= NUM_SAVE_PER_RUN){
|
if(_save_cnt >= NUM_SAVE_PER_RUN){
|
||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
}
|
}
|
||||||
@ -227,3 +276,11 @@ void ColorMultiAnalysis::save_cb(Timer& timer)
|
|||||||
//}
|
//}
|
||||||
>>>>>>> 88fa0375934e9ad87053542e88a0f9fe61af0a66
|
>>>>>>> 88fa0375934e9ad87053542e88a0f9fe61af0a66
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 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;
|
||||||
ofImage image1;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -18,7 +18,7 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
void ColorSingleAnalysis::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 = 100;
|
||||||
@ -64,9 +64,72 @@ void ColorSingleAnalysis::acquire()
|
|||||||
void ColorSingleAnalysis::synthesise()
|
void ColorSingleAnalysis::synthesise()
|
||||||
{
|
{
|
||||||
// _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;
|
||||||
|
|
||||||
|
int index=0;
|
||||||
|
float iterator=1;
|
||||||
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
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, 20); // 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()
|
void ColorSingleAnalysis::draw()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -142,6 +205,25 @@ void ColorSingleAnalysis::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;
|
||||||
|
|
||||||
|
if(whichMesh>meshes.size() -1 || whichMesh<0){
|
||||||
|
speed*=-1;
|
||||||
|
whichMesh+=speed;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +242,10 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
|
|||||||
|
|
||||||
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";
|
||||||
|
|
||||||
|
//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);
|
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;
|
//cout<<_whole_file_path+"/"+file_name<<endl;
|
||||||
|
|
||||||
@ -168,3 +253,10 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
|
|||||||
// _RUN_DONE = true;
|
// _RUN_DONE = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void ColorSingleAnalysis::display_results_cb(Timer& timer){
|
||||||
|
_results_cnt++;
|
||||||
|
if (_results_cnt>_results_cnt_max) {
|
||||||
|
_RUN_DONE=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,14 +20,16 @@ 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;
|
||||||
string fileNameTag;
|
string fileNameTag;
|
||||||
int _run_cnt, _save_cnt, _fade_cnt;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -59,11 +59,68 @@ 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;
|
||||||
|
float iterator=1;
|
||||||
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
||||||
@ -154,6 +211,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +267,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++;
|
||||||
@ -196,3 +275,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,14 +20,16 @@ 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,6 +15,8 @@ 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;
|
||||||
@ -55,11 +57,70 @@ 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;
|
||||||
|
float iterator=1;
|
||||||
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
@ -90,6 +151,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;
|
||||||
}
|
}
|
||||||
@ -97,6 +159,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,9 +202,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,15 +20,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;
|
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,7 +18,7 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
DELTA_T_SAVE = 300;
|
DELTA_T_SAVE = 130;
|
||||||
NUM_PHASE = 1;
|
NUM_PHASE = 1;
|
||||||
NUM_RUN = 3;
|
NUM_RUN = 3;
|
||||||
NUM_SAVE_PER_RUN = 100;
|
NUM_SAVE_PER_RUN = 100;
|
||||||
@ -61,8 +61,67 @@ 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;
|
||||||
|
float iterator=1;
|
||||||
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
@ -112,6 +171,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,9 +217,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,15 +21,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;
|
||||||
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,67 @@ 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;
|
||||||
|
float iterator=1;
|
||||||
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
|
||||||
|
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 +248,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 +302,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,9 +52,11 @@ 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,69 @@ 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;
|
||||||
|
float iterator=1;
|
||||||
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
|
||||||
|
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 +383,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,6 +420,7 @@ 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 +429,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,11 @@ 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,66 @@ 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;
|
||||||
|
float iterator=1;
|
||||||
|
bool debug=false;
|
||||||
|
if(debug){
|
||||||
|
_saved_filenames.clear();
|
||||||
|
_saved_filenames=getListOfImageFilePaths("MIDDLESBOROUGH", _name);
|
||||||
|
|
||||||
|
//hack to limit number of meshes.
|
||||||
|
if(_saved_filenames.size()>100){
|
||||||
|
iterator= _saved_filenames.size() /100;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//clear vector so we don't add to it on successive runs
|
||||||
|
meshes.clear();
|
||||||
|
|
||||||
|
for(float i=0;i<_saved_filenames.size()-1;i+=iterator){
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
@ -139,6 +198,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +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);
|
||||||
|
|
||||||
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++;
|
||||||
|
|
||||||
@ -166,3 +247,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,11 @@ 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