From 71e3a9a1db5bd0072331807c842f483a87404f87 Mon Sep 17 00:00:00 2001 From: Tom Schofield Date: Sun, 19 Feb 2012 16:42:55 +0000 Subject: [PATCH] added image loading and display results stuff- changes all commented in code --- src/AbstractAnalysis.cpp | 84 ++++++++++++++++++++++++++++++++++++++ src/AbstractAnalysis.h | 10 +++++ src/CamNoiseAnalysis.cpp | 2 +- src/ColorMultiAnalysis.cpp | 40 +++++++++++++++--- src/ColorMultiAnalysis.h | 1 + 5 files changed, 131 insertions(+), 6 deletions(-) diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 4d8b78d..9623d1b 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -80,4 +80,88 @@ void AbstractAnalysis::create_dir() //////////////////////////////END DIRECTORY CREATION ////////////////////////////////////////////////// } +ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison){ + //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;iimagePixels1.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 y=0; + + //get rid of all previous vectors and colours - uncomment if re-setting the mesh on the fly - ie live rather than saving it first + //someMesh->clear(); + + unsigned char * thesePixels =currentSecondImage.getPixels(); + + for(int i=0;iaddVertex(ofVec3f(x,y,- somePixels.getColor(x, y).getBrightness() )); + // add colour from current second image of two + someMesh->addColor( currentSecondImage.getColor(x, y) ); + x++; + if(x>somePixels.getWidth()){ + x=0; + y++; + } + + } + +} diff --git a/src/AbstractAnalysis.h b/src/AbstractAnalysis.h index d53940d..a7da748 100755 --- a/src/AbstractAnalysis.h +++ b/src/AbstractAnalysis.h @@ -40,6 +40,9 @@ protected: // analysis + synthesize images - all the children (see - do_synthesize) virtual void synthesise() = 0; + virtual ofPixels calculateListOfZValues(ofImage image1, ofImage image2, int whichComparison); + + virtual void setMeshFromPixels(ofPixels somePixels, ofImage currentSecondImage, ofMesh * someMesh); public: string _name; @@ -59,5 +62,12 @@ protected: int NUM_RUN; int NUM_SAVE_PER_RUN; + //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 + vectormeshes; + //how fast to move from one mesh to the next + float speed; + //the index (inside the vector of meshes) of the current mesh being displayed + float whichMesh; friend class AnalysisAdaptor; }; \ No newline at end of file diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index b61757c..da1b400 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -59,7 +59,7 @@ void CamNoiseAnalysis::acquire() void CamNoiseAnalysis::synthesise() { - // _saved_filenames has all the file names of all the saved images + } diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 322dc00..ba21eee 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -41,14 +41,18 @@ using Poco::Timer; using Poco::TimerCallback; using Poco::Thread; - +#define COMPARE_RED 1 +#define COMPARE_BLUE 2 +#define COMPARE_GREEN 3 +#define COMPARE_HUE 4 +#define COMPARE_BRIGHTNESS 5 void ColorMultiAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 150; // the right number is about 300 + DELTA_T_SAVE = 50;//150; // the right number is about 300 NUM_PHASE = 1; NUM_RUN = 1; - NUM_SAVE_PER_RUN = 300; + NUM_SAVE_PER_RUN = 100;//; create_dir(); _frame_cnt = 0; @@ -66,7 +70,7 @@ void ColorMultiAnalysis::acquire() // RUN ROUTINE for(int i = 0; i < NUM_RUN; i++) { - + _run_cnt = i; cout << "RUN NUM = " << i; @@ -86,7 +90,31 @@ void ColorMultiAnalysis::acquire() void ColorMultiAnalysis::synthesise() { + cout<<"SYNTHESISING MULTI"; // _saved_filenames has all the file names of all the saved images + // _saved_filenames has all the file names of all the saved images + //incrementer to whichMesh + speed=0.2; + //whichMesh is the index in the vector of meshes + whichMesh=0; + + cout<<"image loaded "; + //there is a problem with natural vs alphabetical order when loading the files - we need to make a fix for this + int shift=0; + cout<<_saved_filenames.size()<<" image filenames "; + int index=0; + //for(int i=shift;i<_saved_filenames.size()-2;i+=2){ + // cout<<_saved_filenames[i]<= NUM_SAVE_PER_RUN){ _RUN_DONE = true; } diff --git a/src/ColorMultiAnalysis.h b/src/ColorMultiAnalysis.h index eff1c3a..ef4fc60 100755 --- a/src/ColorMultiAnalysis.h +++ b/src/ColorMultiAnalysis.h @@ -24,4 +24,5 @@ protected: bool _RUN_DONE; int _run_cnt, _save_cnt, _fade_cnt; float c, _frame_cnt, _frame_cnt_max; + ofImage image1; };