From 34f3cf6ffd7d5038c35abb79cd5fc0ee00fbc3e3 Mon Sep 17 00:00:00 2001 From: Jamie Allen Date: Mon, 7 May 2012 21:59:50 +0200 Subject: [PATCH] safety commit - still working on colorsingle --- example/RefractiveIndex.cpp | 23 +++-- example/RefractiveIndex.h | 1 + src/CamNoiseAnalysis.cpp | 2 +- src/ColorSingleAnalysis.cpp | 163 ++++++++++++++++++++++++++++++------ src/ColorSingleAnalysis.h | 1 + 5 files changed, 156 insertions(+), 34 deletions(-) diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index b2cc791..d1227e5 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -228,22 +228,29 @@ void RefractiveIndex::draw() if(_currentAnalysis->meshIsComplete){ fbo.begin(); - glShadeModel(GL_SMOOTH); - glEnable(GL_NORMALIZE); + ofEnableSmoothing(); + //glShadeModel(GL_SMOOTH); + //glFogf(GL_FOG_END, -200); + + //glHint(GL_NICEST, GL_DONT_CARE); + + //glEnable(GL_NORMALIZE); //glEnable(GL_DEPTH_TEST); - //light.enable(); //ofEnableSeparateSpecularLight(); - ofEnableSmoothing(); + //ofEnableLighting(); + //light.setPosition(ofVec3f(fbo.getWidth()/2, fbo.getHeight()/2,_currentAnalysis->_mesh_size_multiplier *500)); + //lightStatic.setPosition(ofVec3f(20,50,100)); + //ofEnableSeparateSpecularLight(); + //ofGetLightingEnabled(); //ofSetLineWidth(1.0f); //glPointSize(5.0f); - - //glHint(GL_NICEST); - ofEnableBlendMode ( OF_BLENDMODE_ADD ); + + //ofEnableBlendMode ( OF_BLENDMODE_ADD ); //ofEnableBlendMode ( OF_BLENDMODE_MULTIPLY ); //ofEnableBlendMode ( OF_BLENDMODE_SUBTRACT ); - //ofEnableBlendMode ( OF_BLENDMODE_ALPHA ); + ofEnableBlendMode ( OF_BLENDMODE_ALPHA ); //ofEnableBlendMode ( OF_BLENDMODE_SCREEN ); ofClear(0,0,0); diff --git a/example/RefractiveIndex.h b/example/RefractiveIndex.h index 9b5bd26..6019d1e 100644 --- a/example/RefractiveIndex.h +++ b/example/RefractiveIndex.h @@ -77,4 +77,5 @@ public: ofPixels keepOnScreen; ofFbo fbo; ofLight light; + ofLight lightStatic; }; \ No newline at end of file diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index 5fd60c7..fab9cc7 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -163,7 +163,7 @@ void CamNoiseAnalysis::synthesise() //added by tom we weren't actually setting cvgrayimage1 anywhere // cvGrayImage1.setFromPixels(cvColorImage1.getPixels(),cvColorImage1.width,cvColorImage1.height); //cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1); -//cvGrayImage1=cvColorImage1; + //cvGrayImage1=cvColorImage1; cvGrayImage1.erode(); cvGrayImage1.erode(); diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index a68d988..2f5c656 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -1,9 +1,11 @@ #include "ColorSingleAnalysis.h" #include "ofMain.h" - #include "Poco/Timer.h" #include "Poco/Thread.h" +#include +#include + #include "RefractiveIndex.h" using Poco::Timer; @@ -32,12 +34,6 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) cout << "ACQUIRE_TIME ColorSingleAnalysis " << acq_run_time << endl; - //flag for main sketch - meshIsComplete=false; - _gotFirstImage=false; - - _mesh_size_multiplier=3; - //int acq_run_time = 25; // 20 seconds of acquiring per run DELTA_T_SAVE = 1*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files @@ -60,7 +56,8 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) b = 0; fileNameTag = ""; - + fileNameColor = ""; + _show_image = false; _image_shown = false; @@ -164,12 +161,31 @@ void ColorSingleAnalysis::synthesise() ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES ////////////////////////// + if(_saved_filenames_analysis[i].find("RED")>0) + { + fileNameColor = "RED"; + cout<<"FOUND RED"<0) + { + fileNameColor = "BLUE"; + cout<<"FOUND BLUE"<0) + { + fileNameColor = "GREEN"; + cout<<"FOUND GREEN"< sPixels, ofImage curre //get rid of all previous vectors and colours mesh.clear(); - mesh.setMode(OF_PRIMITIVE_TRIANGLES); + mesh.setMode(OF_PRIMITIVE_POINTS); + + /* + OF_PRIMITIVE_TRIANGLES,9 + OF_PRIMITIVE_TRIANGLE_STRIP, + OF_PRIMITIVE_TRIANGLE_FAN, + OF_PRIMITIVE_LINES, + OF_PRIMITIVE_LINE_STRIP, + OF_PRIMITIVE_LINE_LOOP, + OF_PRIMITIVE_POINTS + + */ ofColor meshColour=ofColor(255,0,0); - int chooseColour=1 ; + int chooseColour=2 ; //the average z position of the matrix - used later to centre the mesh on the z axis when drawing float zPlaneAverage=0; @@ -537,6 +564,90 @@ void ColorSingleAnalysis::setMeshFromPixels(vector sPixels, ofImage curre } } } + + if(chooseColour==2){ + + for(int i=0;i=currentSecondImage.getWidth()-1){ + x=0; + y++; + //something is going badly wrong with my maths for me to need this HELP TODO fix this - why am I running over the end of the vector? + if(y>=currentSecondImage.getHeight()-1){ + break; + } + } + } + } + + if(chooseColour==3){ + + ofColor currentSecondImageColor; + + if (fileNameColor=="RED") + { + currentSecondImageColor.r=255; + currentSecondImageColor.g=0; + currentSecondImageColor.b=0; + } + + for(int i=0;i=currentSecondImage.getWidth()-1){ + x=0; + y++; + //something is going badly wrong with my maths for me to need this HELP TODO fix this - why am I running over the end of the vector? + if(y>=currentSecondImage.getHeight()-1){ + break; + } + } + } + } +} } @@ -566,29 +677,32 @@ vector ColorSingleAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofI if(chooseComparison==1){ //for each pixel... float _maxPossibleDistanceToCentre=ofDist(0,0,imagePixels1.getWidth()/2, imagePixels1.getHeight()/2); - + for(int i=0;i ColorSingleAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofI //difference.setFromPixels(thesePixels,imagePixels1.getWidth(),imagePixels1.getHeight(), 3); return differences; } - diff --git a/src/ColorSingleAnalysis.h b/src/ColorSingleAnalysis.h index 3afd9b9..012384f 100755 --- a/src/ColorSingleAnalysis.h +++ b/src/ColorSingleAnalysis.h @@ -32,6 +32,7 @@ protected: bool _RUN_DONE; string fileNameTag; + string fileNameColor; float r,g,b; int _run_cnt, _save_cnt, _fade_cnt, _synth_save_cnt, _anim_cnt;