diffnoise, strobe and relaxrate updates

This commit is contained in:
Jamie Allen 2012-05-08 21:59:35 +02:00
parent ec8d6f1296
commit da5da62160
11 changed files with 1870 additions and 146 deletions

View File

@ -43,7 +43,10 @@ ofxXmlSettings RefractiveIndex::XML;
void RefractiveIndex::setup()
{
camDist=1000;
ofBackground(0, 0, 0);
ofSetBackgroundAuto(false);
//camera.setOrientation(ofVec3f(1,-1,1));
bool save_config = false;
@ -104,7 +107,6 @@ void RefractiveIndex::setup()
//void ofPixels::allocate(int w, int h, ofImageType type)
_pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR);
//TODO: whichever one of these is first - it always runs twice ?
_analysisVector.push_back(new ShadowScapesAnalysis(V)); //1
@ -150,7 +152,6 @@ void RefractiveIndex::start_analysis()
_currentAnalysis->setup(_vid_w, _vid_h);
_analysisAdapator->start();
//allocate fbo for HD
fbo.allocate(1920,1080);
@ -228,18 +229,22 @@ void RefractiveIndex::draw()
if(_currentAnalysis->meshIsComplete){
fbo.begin();
glShadeModel(GL_SMOOTH);
ofClear(0,0,0);
glShadeModel(GL_SMOOTH);
camera.begin();
//this is a hack, I don't know how to colour the fbo with black pixels so I'm drawing a massive black rectangle in the background
/*
ofPushMatrix();
ofTranslate(0, 0,-500);
ofSetColor(0, 0, 0);
ofRect(-fbo.getWidth(), -fbo.getHeight(), fbo.getWidth()*3, fbo.getHeight()*3);
ofPopMatrix();
ofSetColor(255);
*/
float xDiff= (fbo.getWidth()- 1.33333*(_currentAnalysis->_mesh_size_multiplier * _vid_w))/2;
float yDiff= (fbo.getHeight()- 1.0*(_currentAnalysis->_mesh_size_multiplier * _vid_h))/2;

View File

@ -234,7 +234,16 @@ void ColorMultiAnalysis::synthesise()
}
}
// TOM'S fix of why the last file gets overwritten again and again - but seems to prevent the files being written to the screen.
/*
_RUN_DONE = true;
*/
meshIsComplete=false;
_synth_save_cnt=0;
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3);
}

View File

@ -270,7 +270,16 @@ void ColorSingleAnalysis::synthesise()
}
}
// TOM'S fix of why the last file gets overwritten again and again - but seems to prevent the files being written to the screen.
/*
_RUN_DONE = true;
*/
meshIsComplete=false;
_synth_save_cnt=0;
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3);

View File

@ -18,15 +18,30 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
AbstractAnalysis::setup(camWidth, camHeight);
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_diffnoise", NUMBER_RUNS);
cout << "NUM_RUN DiffNoiseAnalysis " << NUM_RUN << endl;
//NUM_RUN = 5;
//flag for main sketch
meshIsComplete=false;
_gotFirstImage=false;
_mesh_size_multiplier = 2;
vertexSubsampling = 1;
chooseColour = 5;
multiplier = 0.8;
_mesh_size_multiplier=4;
blendMode = OF_BLENDMODE_ADD;
//blendMode = OF_BLENDMODE_MULTIPLY;
//blendMode = OF_BLENDMODE_SUBTRACT;
//blendMode = OF_BLENDMODE_ALPHA;
//blendMode = OF_BLENDMODE_SCREEN;
meshMode = OF_PRIMITIVE_TRIANGLES;
//meshMode = OF_PRIMITIVE_TRIANGLE_STRIP;
//meshMode = OF_PRIMITIVE_TRIANGLE_FAN;
//meshMode = OF_PRIMITIVE_LINES;
//meshMode = OF_PRIMITIVE_LINE_STRIP;
//meshMode = OF_PRIMITIVE_POINTS;
int acq_run_time; // 10 seconds of acquiring per run
@ -99,7 +114,6 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
}
@ -159,45 +173,133 @@ void DiffNoiseAnalysis::synthesise()
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvColorImage1.invert();
cvColorImage1.blur(5);
cvColorImage1.erode();
cvColorImage1.erode();
cvColorImage1.blur(5);
cvColorImage1.erode();
cvColorImage1.erode();
//cvColorImage1.erode();
//cvColorImage1.dilate();
//////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
string file_name;
//cvColorImage1.blur(5);
//cvColorImage2.blur(5);
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
//cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
file_name = ofToString(_synth_save_cnt, 2)+"_DiffNoiseAnalysis_"+ofToString(_run_cnt,2)+".jpg";
//cvGrayImage1.convertToRange(0.0, 255.0);
//cvGrayImage2.convertToRange(0.0, 255.0);
//cvGrayImage1.adaptiveThreshold( 200, 0);
//cvGrayImage2.adaptiveThreshold( 200, 0);
//cvGrayImage1.contrastStretch();
//cvGrayImage2.contrastStretch();
//cvGrayImage1.brightnessContrast(1.0,0.5);
//cvGrayImage2.brightnessContrast(1.0,0.5);
cvColorImage1.setFromGrayscalePlanarImages(cvGrayImage1, cvGrayImage1, cvGrayImage1);
//cvColorImage2.setFromGrayscalePlanarImages(cvGrayImage2, cvGrayImage2, cvGrayImage2);
cvPyrMeanShiftFiltering(cvColorImage1.getCvImage(), cvColorImage1.getCvImage(), 1, 1);
//cvPyrMeanShiftFiltering(cvColorImage2.getCvImage(), cvColorImage2.getCvImage(), 1, 1);
//cvFloatImage1 = cvColorImage1;
//cvGrayImage1 = cvColorImage1;
//cvXorS( cvColorImage1.getCvImage(), cvScalarAll(150), cvColorImage1.getCvImage(), 0 );
//cvXorS( cvColorImage2.getCvImage(), cvScalarAll(150), cvColorImage1.getCvImage(), 0 );
//cvSmooth( cvColorImage1.getCvImage(), cvColorImage1.getCvImage(), CV_GAUSSIAN, 5, 5);
//cvSmooth( cvColorImage2.getCvImage(), cvColorImage2.getCvImage(), CV_GAUSSIAN, 5, 5);
//cvCanny(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 100, 100, 3);
//cvLaplace(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0);
//cvGrayImage1 = cvCreateImage(cvSize(image1.width, image1.height),IPL_DEPTH_16S,1);
//cvSobel(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0, 1, 3);
//<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
// ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
// convert the CV image
image1.setFromPixels(cvColorImage1.getPixelsRef());
//image5.setFromPixels(cvColorImage2.getPixelsRef());
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
if(!_gotFirstImage){
cout<<"background image is"<< _saved_filenames_analysis[i]<<endl;
_background=image1;
_gotFirstImage=true;
}
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
//ofImage image;
//image.allocate(cvColorImage1.width, cvGrayImage1.height, OF_IMAGE_COLOR);
//subtract background begin///////////////
//*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
//image.setUseTexture(false);
ofPixels imagePixels1 = image1.getPixelsRef();
//ofPixels imagePixels2 = image5.getPixelsRef();
ofPixels backgroundPixels = _background.getPixelsRef();
//image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR);
//image.saveImage(_whole_file_path_synthesis+"/"+file_name);
//DIFFERENCING SUBSEQUENT IMAGES
/*
for(int i=0;i<imagePixels1.size();i++){
//unsigned char val=imagePixels1[i];
// cout<<(int)backgroundPixels[i]<< " thesePixels[i] "<<(int)imagePixels1[i]<<endl;
if(imagePixels1[i]-imagePixels2[i]>0){
imagePixels1[i]-=imagePixels2[i];
}
else{
imagePixels1[i]=0;
}
}
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
*/
//DIFFERENCING THE BACKGROUND
/*
for(int i=0;i<imagePixels1.size();i++){
//unsigned char val=imagePixels1[i];
// cout<<(int)backgroundPixels[i]<< " thesePixels[i] "<<(int)imagePixels1[i]<<endl;
if(imagePixels1[i]-backgroundPixels[i]>0){
imagePixels1[i]-=backgroundPixels[i];
}
else{
imagePixels1[i]=0;
}
}
*/
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
//update the images with their new background subtracted selves
image1.setFromPixels(imagePixels1);
//flag the main app that we aren't read yet
meshIsComplete=false;
//make a mesh - this mesh will be drawn in the main app
setMeshFromPixels(_returnDepthsAtEachPixel(image1, image1, _background), image1, image1, aMesh);
//setMeshFromPixels(_returnDepthsAtEachPixel(image1, image1, _background), image1, image1, aMesh);
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
//string file_name;
//with jpgs this was refusing to save out
meshFileName = _whole_file_path_synthesis+"/"+ofToString(_synth_save_cnt, 2)+"_DiffNoiseAnalysis_"+ofToString(_run_cnt,2)+".png";
_saved_filenames_synthesis.push_back(meshFileName);
//file_name = ofToString(_synth_save_cnt, 2)+"_ColorMultiAnalysis_"+ofToString(_run_cnt,2)+".jpg";
//flag that we are finished
meshIsComplete=true;
_synth_save_cnt++;
// }
//}
} else {
cout<<"couldn't load image from "<<_saved_filenames_analysis[i]<<endl;
}
}
// TOM'S fix of why the last file gets overwritten again and again - but seems to prevent the files being written to the screen.
/*
_RUN_DONE = true;
*/
meshIsComplete=false;
_synth_save_cnt=0;
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3);
@ -237,6 +339,26 @@ void DiffNoiseAnalysis::displayresults()
// this runs at frame rate = 33 ms for 30 FPS
void DiffNoiseAnalysis::draw()
{
ofEnableSmoothing();
ofEnableLighting();
ofEnableSeparateSpecularLight();
light.setPointLight();
light.enable();
lightStatic.enable();
light.setPosition(ofGetWidth()/2,ofGetHeight()/2,5);
lightStatic.setPosition(ofGetWidth()/2,ofGetHeight()/2,-1);
glEnable(GL_DEPTH_TEST);
ofSetLineWidth(1.0f);
glPointSize(5.0f);
ofEnableBlendMode(blendMode);
switch (_state) {
case STATE_ACQUIRING:
{
@ -283,7 +405,6 @@ void DiffNoiseAnalysis::draw()
}
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt <= _frame_cnt_max) {
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
@ -444,3 +565,408 @@ void DiffNoiseAnalysis::save_cb(Timer& timer)
saveImageAnalysis(file_name);
}
void DiffNoiseAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage currentFirstImage, ofImage currentSecondImage, ofMesh & mesh){
int x=0;
int y=0;
//get rid of all previous vectors and colours
mesh.clear();
mesh.setMode(meshMode);
ofColor meshColour=ofColor(255,255,255);
//the average z position of the matrix - used later to centre the mesh on the z axis when drawing
float zPlaneAverage=0;
for(int i=0;i<sPixels.size();i++){
zPlaneAverage+=sPixels[i];
}
if (sPixels.size()!=0) {
zPlaneAverage/=sPixels.size();
//cout<<zPlaneAverage<<" zPlaneAverage "<<endl;
}
else{
cout<<"DEPTH FLOAT ARRAY IS EMPTY";
}
if(chooseColour==1){
for(int i=0;i<sPixels.size();i++){
mesh.addColor( currentSecondImage.getColor(x, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
mesh.addColor( currentSecondImage.getColor(x, y));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
mesh.addColor( currentSecondImage.getColor(x, y));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y) );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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==2){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor = currentSecondImage.getColor(x, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor;
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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==4){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor;
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
int randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter+1),- sPixels[ (currentSecondImage.getWidth()*(y+randomJitter+1))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*((y+randomJitter)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1 ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*((y+randomJitter)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) +1 ]));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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==5){
for(int i=0;i<sPixels.size();i++){
int randomJitter2 = 0;
int randomJitter = 0;
ofColor currentSecondImageColor;
ofColor currentSecondImageBW;
currentSecondImageColor = currentSecondImage.getColor(x, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*((y)+1),- sPixels[ (currentSecondImage.getWidth()*(y+randomJitter+1))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor(currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor(currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*((y)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1 ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp() );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*((y)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp() );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter)+1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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;
}
}
}
}
}
vector<float> DiffNoiseAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImag){
ofPixels imagePixels1 = image1.getPixelsRef();
//ofPixels imagePixels2 = image2.getPixelsRef();
ofPixels backgroundPixels = backgroundImag.getPixelsRef();
vector<float> differences;
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];
for(int i=0;i<imagePixels1.size();i++){
thesePixels[i]=0;
}
int x=0;
int y=0;
int chooseComparison=1;
//comparison here to find out how close each color is to pure RED / GREEN / BLUE
if(chooseComparison==1){
//for each pixel...
float _maxPossibleDistanceToCentre=ofDist(0,0,imagePixels1.getWidth()/2, imagePixels1.getHeight()/2);
for(int i=0;i<imagePixels1.size();i+=3){
ofColor imageColor1 = imagePixels1.getColor(x, y);
//ofColor colourImage2 = imagePixels2.getColor(x, y);
float _distanceToCentre=ofDist(imagePixels1.getWidth()/2, imagePixels1.getHeight()/2, x, y);
float _presumedBrightness=ofMap(sqrt(_maxPossibleDistanceToCentre)-sqrt(_distanceToCentre), 0, sqrt(_maxPossibleDistanceToCentre), 0, 255);
//int thisDiff=abs(imageColor1.getHue());
//int thisDiff=abs(imageColor1.getBrightness());
//int thisDiff=abs(imageColor1.getBrightness()-_presumedBrightness);
int thisDiff=-abs(imageColor1.getBrightness());
//int thisDiff=abs(imageColor1.getLightness());
//int thisDiff=-abs(imageColor1.r);
//cout<<thisDiff<< " thisDiff "<<endl;
//red hue: 0
//green hue: 120
//blue hue: 240
differences.push_back(multiplier * thisDiff);
thesePixels[i]=thisDiff;
thesePixels[i+1]=thisDiff;
thesePixels[i+2]=thisDiff;
x++;
if(x>=imagePixels1.getWidth()){
x=0;
y++;
}
}
}
//difference.setFromPixels(thesePixels,imagePixels1.getWidth(),imagePixels1.getHeight(), 3);
return differences;
}

View File

@ -63,6 +63,19 @@ protected:
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
//mesh making function
void setMeshFromPixels(vector<float> sPixels, ofImage currentFirstImage, ofImage currentSecondImage, ofMesh & mesh);
//depth map function
vector<float> _returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImage);
int vertexSubsampling;
int chooseColour;
ofPrimitiveMode meshMode;
ofBlendMode blendMode;
float multiplier;
bool _gotFirstImage;
ofImage _background;

View File

@ -91,8 +91,6 @@ void IResponseAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear();
cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -100,15 +98,10 @@ void IResponseAnalysis::setup(int camWidth, int camHeight)
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
}
void IResponseAnalysis::acquire()
{
Timer* save_timer;
TimerCallback<IResponseAnalysis> save_callback(*this, &IResponseAnalysis::save_cb);
@ -205,6 +198,14 @@ void IResponseAnalysis::synthesise()
//}
}
// TOM'S fix of why the last file gets overwritten again and again - but seems to prevent the files being written to the screen.
/*
_RUN_DONE = true;
*/
meshIsComplete=false;
_synth_save_cnt=0;
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3);

View File

@ -59,9 +59,6 @@ protected:
ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
//mesh making function
void setMeshFromPixels(vector<float> sPixels, ofImage currentFirstImage, ofImage currentSecondImage, ofMesh & mesh);
//returns ofPixels but these pixels actually hold depth data.

View File

@ -26,8 +26,24 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
//flag for main sketch
meshIsComplete=false;
_gotFirstImage=false;
_mesh_size_multiplier = 2;
vertexSubsampling_x = 1; //must be at least '1'
vertexSubsampling_y = 7; //must be at least '1'
chooseColour = 2;
multiplier = 1;
_mesh_size_multiplier=4;
//blendMode = OF_BLENDMODE_ADD;
//blendMode = OF_BLENDMODE_MULTIPLY;
blendMode = OF_BLENDMODE_SUBTRACT;
//blendMode = OF_BLENDMODE_ALPHA;
//blendMode = OF_BLENDMODE_SCREEN;
//meshMode = OF_PRIMITIVE_TRIANGLES;
//meshMode = OF_PRIMITIVE_TRIANGLE_STRIP;
//meshMode = OF_PRIMITIVE_TRIANGLE_FAN;
//meshMode = OF_PRIMITIVE_LINES;
meshMode = OF_PRIMITIVE_LINE_STRIP;
//meshMode = OF_PRIMITIVE_POINTS;
int acq_run_time; // 10 seconds of acquiring per run
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_relaxrate", ACQUIRE_TIME);
@ -63,18 +79,47 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
_image_shown = false;
image1.clear();
image2.clear();
image3.clear();
image4.clear();
image5.clear();
// images use for drawing the synthesized files to the screen ///
image1.setUseTexture(false); // the non texture image that is needed to first load the image
image2.setUseTexture(true); // the image that needs to get written to the screen which takes the content of image1
// images used for re-loading and saving out the synthesized files ///
image3.setUseTexture(false);
image4.setUseTexture(false);
image5.setUseTexture(false);
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image3.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image4.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
image5.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
// clear() apparently fixes the "OF_WARNING: in allocate, reallocating a ofxCvImage"
// that we're getting in OSX/Windows and is maybe crashing Windows
// http://forum.openframeworks.cc/index.php?topic=1867.0
cvColorImage1.clear();
cvGrayImage1.clear();
cvGrayDiff1.clear();
cvColorImage2.clear();
cvGrayImage2.clear();
cvGrayDiff2.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvColorImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
}
@ -107,77 +152,195 @@ void RelaxRateAnalysis::acquire()
void RelaxRateAnalysis::synthesise()
{
//cout << "IResponseAnalysis::saving synthesis...\n";
// cout << "RelaxRate::saving synthesis...\n";
if(_state == STATE_STOP) return;
cvContourFinderVect.clear();
for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
// cout << "StrobeAnalysis::synthesis FOR LOOP...\n";
for(float i=1;i<_saved_filenames_analysis.size();i++){
// cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
if(_state == STATE_STOP) return;
if(image1.loadImage(_saved_filenames_analysis[i])){
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage1.convertToGrayscalePlanarImage(cvGrayDiff1, 1);
cvGrayDiff1.threshold(_treshold);
rfiCvContourFinder* cf = new rfiCvContourFinder();
cf->findContours(cvGrayDiff1, 20, (image1.width * image1.height) / 4, _maxblobs, true);
cvContourFinderVect.push_back(cf);
if(!image1.loadImage(_saved_filenames_analysis[i])){
//couldn't load image
// cout << "didn't load image" << endl;
}
if(image1.loadImage(_saved_filenames_analysis[i])){
//cout << "LOADED image1!!!" << endl;
if(image5.loadImage(_saved_filenames_analysis[i+1])){
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
//cvColorImage1.erode();
//cvColorImage1.erode();
//cvColorImage1.dilate();
cvColorImage1.blur(1);
cvColorImage2.blur(1);
//cvXorS( cvColorImage1.getCvImage(), cvScalarAll(150), cvColorImage1.getCvImage(), 0 );
//cvXorS( cvColorImage2.getCvImage(), cvScalarAll(150), cvColorImage1.getCvImage(), 0 );
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
//cvGrayImage1.convertToRange(0.0, 255.0);
//cvGrayImage2.convertToRange(0.0, 255.0);
//cvGrayImage1.adaptiveThreshold( 200, 0);
//cvGrayImage2.adaptiveThreshold( 200, 0);
//cvGrayImage1.contrastStretch();
//cvGrayImage2.contrastStretch();
cvGrayDiff1.absDiff(cvGrayImage1, cvGrayImage2);
//cvGrayDiff1.brightnessContrast(1.0,0.5);
//cvGrayImage1.brightnessContrast(1.0,0.5);
//cvGrayImage2.brightnessContrast(1.0,0.5);
cvColorImage1.setFromGrayscalePlanarImages(cvGrayImage1, cvGrayImage1, cvGrayImage1);
//cvColorImage2.setFromGrayscalePlanarImages(cvGrayImage2, cvGrayImage2, cvGrayImage2);
//cvPyrMeanShiftFiltering(cvColorImage1.getCvImage(), cvColorImage1.getCvImage(), 1, 1);
//cvPyrMeanShiftFiltering(cvColorImage2.getCvImage(), cvColorImage2.getCvImage(), 1, 1);
//cvFloatImage1 = cvColorImage1;
//cvGrayImage1 = cvColorImage1;
//cvSmooth( cvColorImage1.getCvImage(), cvColorImage1.getCvImage(), CV_GAUSSIAN, 5, 5);
//cvSmooth( cvColorImage2.getCvImage(), cvColorImage2.getCvImage(), CV_GAUSSIAN, 5, 5);
//cvCanny(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 100, 100, 3);
//cvLaplace(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0);
//cvGrayImage1 = cvCreateImage(cvSize(image1.width, image1.height),IPL_DEPTH_16S,1);
//cvSobel(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0, 1, 3);
// convert the CV image
image1.setFromPixels(cvColorImage1.getPixelsRef());
image5.setFromPixels(cvColorImage2.getPixelsRef());
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
if(!_gotFirstImage){
cout<<"background image is"<< _saved_filenames_analysis[i]<<endl;
_background=image1;
_gotFirstImage=true;
}
//subtract background begin///////////////
ofPixels imagePixels1 = image1.getPixelsRef();
ofPixels imagePixels2 = image5.getPixelsRef();
ofPixels backgroundPixels = _background.getPixelsRef();
//DIFFERENCING SUBSEQUENT IMAGES
/*
for(int i=0;i<imagePixels1.size();i++){
//unsigned char val=imagePixels1[i];
// cout<<(int)backgroundPixels[i]<< " thesePixels[i] "<<(int)imagePixels1[i]<<endl;
if(imagePixels1[i]-imagePixels2[i]>0){
imagePixels1[i]-=imagePixels2[i];
}
else{
imagePixels1[i]=0;
}
}
*/
//DIFFERENCING THE BACKGROUND
for(int i=0;i<imagePixels1.size();i++){
//unsigned char val=imagePixels1[i];
// cout<<(int)backgroundPixels[i]<< " thesePixels[i] "<<(int)imagePixels1[i]<<endl;
if(imagePixels1[i]-backgroundPixels[i]>0){
imagePixels1[i]-=backgroundPixels[i];
}
else{
imagePixels1[i]=0;
}
}
//update the images with their new background subtracted selves
image1.setFromPixels(imagePixels1);
//flag the main app that we aren't read yet
meshIsComplete=false;
//make a mesh - this mesh will be drawn in the main app
setMeshFromPixels(_returnDepthsAtEachPixel(image1, image1, _background), image1, image1, aMesh);
//setMeshFromPixels(_returnDepthsAtEachPixel(image1, image1, _background), image1, image1, aMesh);
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
//string file_name;
//with jpgs this was refusing to save out
meshFileName = _whole_file_path_synthesis+"/"+ofToString(_synth_save_cnt, 2)+"_RelaxRateAnalysis_"+ofToString(_run_cnt,2)+".png";
_saved_filenames_synthesis.push_back(meshFileName);
//file_name = ofToString(_synth_save_cnt, 2)+"_ColorMultiAnalysis_"+ofToString(_run_cnt,2)+".jpg";
//flag that we are finished
meshIsComplete=true;
_synth_save_cnt++;
}
} else {
cout<<"couldn't load image from "<<_saved_filenames_analysis[i]<<endl;
}
}
// TOM'S fix of why the last file gets overwritten again and again - but seems to prevent the files being written to the screen.
/*
_RUN_DONE = true;
*/
meshIsComplete=false;
_synth_save_cnt=0;
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3);
Thread::sleep(10);
}
void RelaxRateAnalysis::displayresults()
{
//cvContourFinderVectDisplay.clear();
clearcfindervectdisplay();
for(float i=1;i<_saved_filenames_synthesis.size();i++){
for(int i=1;i<cvContourFinderVect.size();i++){
if(_state == STATE_STOP) return;
if(_state == STATE_STOP){
clearcfindervectdisplay();
clearcfindervect();
return;
}
//cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
// cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
while(!_image_shown){
Thread::sleep(2);
if(_state == STATE_STOP) return;
//cout << "!_image_shown" << endl;
}
cvContourFinderVectDisplay.push_back(cvContourFinderVect[i]);
_show_image = true;
_image_shown = false;
if(!image3.loadImage(_saved_filenames_synthesis[i])){
//couldn't load image
// cout << "didn't load image" << endl;
}
if(image3.loadImage(_saved_filenames_synthesis[i])){
image3.loadImage(_saved_filenames_synthesis[i]);
//cout << "_show_image = true;" << endl;
_show_image = true;
_image_shown = false;
}
}
clearcfindervectdisplay();
clearcfindervect();
//cvContourFinderVectDisplay.clear();
//cvContourFinderVect.clear();
}
@ -185,6 +348,26 @@ void RelaxRateAnalysis::displayresults()
void RelaxRateAnalysis::draw()
{
ofEnableSmoothing();
ofEnableLighting();
ofEnableSeparateSpecularLight();
light.setPointLight();
light.enable();
lightStatic.enable();
light.setPosition(ofGetWidth()/2,ofGetHeight()/2,5);
lightStatic.setPosition(ofGetWidth()/2,ofGetHeight()/2,-1);
glEnable(GL_DEPTH_TEST);
ofSetLineWidth(2.0f);
glPointSize(1.0f);
ofEnableBlendMode(blendMode);
switch (_state) {
case STATE_ACQUIRING:
{
@ -374,3 +557,410 @@ void RelaxRateAnalysis::clearcfindervectdisplay()
cvContourFinderVectDisplay.clear();
}
void RelaxRateAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage currentFirstImage, ofImage currentSecondImage, ofMesh & mesh){
int x=0;
int y=0;
//get rid of all previous vectors and colours
mesh.clear();
mesh.setMode(meshMode);
ofColor meshColour=ofColor(255,255,255);
//the average z position of the matrix - used later to centre the mesh on the z axis when drawing
float zPlaneAverage=0;
for(int i=0;i<sPixels.size();i++){
zPlaneAverage+=sPixels[i];
}
if (sPixels.size()!=0) {
zPlaneAverage/=sPixels.size();
//cout<<zPlaneAverage<<" zPlaneAverage "<<endl;
}
else{
cout<<"DEPTH FLOAT ARRAY IS EMPTY";
}
if(chooseColour==1){
for(int i=0;i<sPixels.size();i++){
mesh.addColor( currentSecondImage.getColor(x, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
mesh.addColor( currentSecondImage.getColor(x, y));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
mesh.addColor( currentSecondImage.getColor(x, y));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y) );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling_x;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling_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==2){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor = currentSecondImage.getColor(x, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling_x;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling_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){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor;
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling_x;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling_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==4){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor;
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
int randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter+1),- sPixels[ (currentSecondImage.getWidth()*(y+randomJitter+1))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*((y+randomJitter)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1 ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*((y+randomJitter)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) +1 ]));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
x=x+vertexSubsampling_x;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling_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==5){
for(int i=0;i<sPixels.size();i++){
int randomJitter2 = 0;
int randomJitter = 0;
ofColor currentSecondImageColor;
ofColor currentSecondImageBW;
currentSecondImageColor = currentSecondImage.getColor(x, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*((y)+1),- sPixels[ (currentSecondImage.getWidth()*(y+randomJitter+1))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor(currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor(currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*((y)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1 ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp() );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*((y)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp() );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter)+1 ]));
x=x+vertexSubsampling_x;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling_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;
}
}
}
}
}
vector<float> RelaxRateAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImag){
ofPixels imagePixels1 = image1.getPixelsRef();
//ofPixels imagePixels2 = image2.getPixelsRef();
ofPixels backgroundPixels = backgroundImag.getPixelsRef();
vector<float> differences;
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];
for(int i=0;i<imagePixels1.size();i++){
thesePixels[i]=0;
}
int x=0;
int y=0;
int chooseComparison=1;
//comparison here to find out how close each color is to pure RED / GREEN / BLUE
if(chooseComparison==1){
//for each pixel...
float _maxPossibleDistanceToCentre=ofDist(0,0,imagePixels1.getWidth()/2, imagePixels1.getHeight()/2);
for(int i=0;i<imagePixels1.size();i+=3){
ofColor imageColor1 = imagePixels1.getColor(x, y);
//ofColor colourImage2 = imagePixels2.getColor(x, y);
float _distanceToCentre=ofDist(imagePixels1.getWidth()/2, imagePixels1.getHeight()/2, x, y);
float _presumedBrightness=ofMap(sqrt(_maxPossibleDistanceToCentre)-sqrt(_distanceToCentre), 0, sqrt(_maxPossibleDistanceToCentre), 0, 255);
//int thisDiff=abs(imageColor1.getHue());
//int thisDiff=abs(imageColor1.getBrightness());
//int thisDiff=abs(imageColor1.getBrightness()-_presumedBrightness);
int thisDiff=-abs(imageColor1.getBrightness());
//int thisDiff=abs(imageColor1.getLightness());
//int thisDiff=-abs(imageColor1.r);
//cout<<thisDiff<< " thisDiff "<<endl;
//red hue: 0
//green hue: 120
//blue hue: 240
differences.push_back(multiplier * thisDiff);
thesePixels[i]=thisDiff;
thesePixels[i+1]=thisDiff;
thesePixels[i+2]=thisDiff;
x++;
if(x>=imagePixels1.getWidth()){
x=0;
y++;
}
}
}
//difference.setFromPixels(thesePixels,imagePixels1.getWidth(),imagePixels1.getHeight(), 3);
return differences;
}

View File

@ -44,14 +44,47 @@ protected:
bool _show_image, _image_shown;
ofImage image1;
ofImage image1;
ofImage image2;
ofImage image3;
ofImage image4;
ofImage image5;
ofImage image6;
ofxCvColorImage cvColorImage1;
ofxCvColorImage cvColorImage2;
ofxCvColorImage cvColorImage3;
ofxCvColorImage cvColorImage4;
ofxCvColorImage cvColorImage5;
ofxCvColorImage cvColorImage6;
ofxCvGrayscaleImage cvGrayDiff1;
ofxCvGrayscaleImage cvGrayDiff2;
ofxCvGrayscaleImage cvGrayImage1;
ofxCvGrayscaleImage cvGrayImage2;
ofxCvGrayscaleImage cvGrayImage3;
ofxCvGrayscaleImage cvGrayImage4;
vector<rfiCvContourFinder*> cvContourFinderVect;
vector<rfiCvContourFinder*> cvContourFinderVectDisplay;
//mesh making function
void setMeshFromPixels(vector<float> sPixels, ofImage currentFirstImage, ofImage currentSecondImage, ofMesh & mesh);
//depth map function
vector<float> _returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImage);
int vertexSubsampling_x;
int vertexSubsampling_y;
int chooseColour;
ofPrimitiveMode meshMode;
ofBlendMode blendMode;
float multiplier;
bool _gotFirstImage;
ofImage _background;
};

View File

@ -24,8 +24,24 @@ void StrobeAnalysis::setup(int camWidth, int camHeight)
//flag for main sketch
meshIsComplete=false;
_gotFirstImage=false;
_mesh_size_multiplier = 1;
vertexSubsampling = 2;
chooseColour = 2;
multiplier = 0.5;
//blendMode = OF_BLENDMODE_ADD;
//blendMode = OF_BLENDMODE_MULTIPLY;
blendMode = OF_BLENDMODE_SUBTRACT;
//blendMode = OF_BLENDMODE_ALPHA;
//blendMode = OF_BLENDMODE_SCREEN;
//meshMode = OF_PRIMITIVE_TRIANGLES;
//meshMode = OF_PRIMITIVE_TRIANGLE_STRIP;
//meshMode = OF_PRIMITIVE_TRIANGLE_FAN;
meshMode = OF_PRIMITIVE_LINES;
//meshMode = OF_PRIMITIVE_LINE_STRIP;
//meshMode = OF_PRIMITIVE_POINTS;
_mesh_size_multiplier=4;
int acq_run_time; // 10 seconds of acquiring per run
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_strobe", ACQUIRE_TIME);
@ -87,7 +103,7 @@ void StrobeAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.clear();
cvGrayDiff2.clear();
cvConvertorImage.clear();
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
@ -97,7 +113,6 @@ void StrobeAnalysis::setup(int camWidth, int camHeight)
cvGrayImage2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
}
@ -151,60 +166,150 @@ void StrobeAnalysis::synthesise()
}
if(image1.loadImage(_saved_filenames_analysis[i])){
// cout << "LOADED image1!!!" << endl;
//cout << "LOADED image1!!!" << endl;
if(image5.loadImage(_saved_filenames_analysis[i+1])){
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
//cvColorImage1.erode();
//cvColorImage1.erode();
//cvColorImage1.dilate();
cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
cvGrayDiff1.dilate();
cvGrayDiff1.dilate();
cvGrayDiff1.contrastStretch();
cvColorImage1.blur(1);
cvColorImage2.blur(1);
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
string file_name;
//cvXorS( cvColorImage1.getCvImage(), cvScalarAll(150), cvColorImage1.getCvImage(), 0 );
//cvXorS( cvColorImage2.getCvImage(), cvScalarAll(150), cvColorImage1.getCvImage(), 0 );
file_name = ofToString(_synth_save_cnt, 2)+"_StrobeAnalysis_"+ofToString(_run_cnt,2)+".jpg";
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
//cvGrayImage1.convertToRange(0.0, 255.0);
//cvGrayImage2.convertToRange(0.0, 255.0);
//cvGrayImage1.adaptiveThreshold( 200, 0);
//cvGrayImage2.adaptiveThreshold( 200, 0);
//cvGrayImage1.contrastStretch();
//cvGrayImage2.contrastStretch();
cvGrayDiff1.absDiff(cvGrayImage1, cvGrayImage2);
cvGrayDiff1.brightnessContrast(1.0,0.5);
//cvGrayImage1.brightnessContrast(1.0,0.5);
//cvGrayImage2.brightnessContrast(1.0,0.5);
cvColorImage1.setFromGrayscalePlanarImages(cvGrayImage1, cvGrayImage1, cvGrayImage1);
//cvColorImage2.setFromGrayscalePlanarImages(cvGrayImage2, cvGrayImage2, cvGrayImage2);
//cvPyrMeanShiftFiltering(cvColorImage1.getCvImage(), cvColorImage1.getCvImage(), 1, 1);
//cvPyrMeanShiftFiltering(cvColorImage2.getCvImage(), cvColorImage2.getCvImage(), 1, 1);
//cvFloatImage1 = cvColorImage1;
//cvGrayImage1 = cvColorImage1;
//<---- THE OLD WAY OF SAVING - works on OSX but generates BLACK FRAMES on WINDOWS ---->
// ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
//cvSmooth( cvColorImage1.getCvImage(), cvColorImage1.getCvImage(), CV_GAUSSIAN, 5, 5);
//cvSmooth( cvColorImage2.getCvImage(), cvColorImage2.getCvImage(), CV_GAUSSIAN, 5, 5);
//cvCanny(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 100, 100, 3);
//cvLaplace(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0);
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
//ofImage image;
//image.allocate(cvGrayImage1.width, cvGrayImage1.height, OF_IMAGE_GRAYSCALE);
//cvGrayImage1 = cvCreateImage(cvSize(image1.width, image1.height),IPL_DEPTH_16S,1);
//cvSobel(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0, 1, 3);
//*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
//image.setUseTexture(false);
// convert the CV image
image1.setFromPixels(cvColorImage1.getPixelsRef());
image5.setFromPixels(cvColorImage2.getPixelsRef());
//image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height,OF_IMAGE_GRAYSCALE);
//image.saveImage(_whole_file_path_synthesis+"/"+file_name);
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
if(!_gotFirstImage){
cout<<"background image is"<< _saved_filenames_analysis[i]<<endl;
_background=image1;
_gotFirstImage=true;
}
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
//subtract background begin///////////////
ofPixels imagePixels1 = image1.getPixelsRef();
ofPixels imagePixels2 = image5.getPixelsRef();
ofPixels backgroundPixels = _background.getPixelsRef();
//DIFFERENCING SUBSEQUENT IMAGES
/*
for(int i=0;i<imagePixels1.size();i++){
//unsigned char val=imagePixels1[i];
// cout<<(int)backgroundPixels[i]<< " thesePixels[i] "<<(int)imagePixels1[i]<<endl;
if(imagePixels1[i]-imagePixels2[i]>0){
imagePixels1[i]-=imagePixels2[i];
}
else{
imagePixels1[i]=0;
}
}
*/
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
//DIFFERENCING THE BACKGROUND
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
_synth_save_cnt++;
for(int i=0;i<imagePixels1.size();i++){
//unsigned char val=imagePixels1[i];
// cout<<(int)backgroundPixels[i]<< " thesePixels[i] "<<(int)imagePixels1[i]<<endl;
if(imagePixels1[i]-backgroundPixels[i]>0){
imagePixels1[i]-=backgroundPixels[i];
}
else{
imagePixels1[i]=0;
}
}
//update the images with their new background subtracted selves
image1.setFromPixels(imagePixels1);
//flag the main app that we aren't read yet
meshIsComplete=false;
//make a mesh - this mesh will be drawn in the main app
setMeshFromPixels(_returnDepthsAtEachPixel(image1, image1, _background), image1, image1, aMesh);
//setMeshFromPixels(_returnDepthsAtEachPixel(image1, image1, _background), image1, image1, aMesh);
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
//string file_name;
//with jpgs this was refusing to save out
meshFileName = _whole_file_path_synthesis+"/"+ofToString(_synth_save_cnt, 2)+"_StrobeAnalysis_"+ofToString(_run_cnt,2)+".png";
_saved_filenames_synthesis.push_back(meshFileName);
//file_name = ofToString(_synth_save_cnt, 2)+"_ColorMultiAnalysis_"+ofToString(_run_cnt,2)+".jpg";
//flag that we are finished
meshIsComplete=true;
_synth_save_cnt++;
}
} else {
cout<<"couldn't load image from "<<_saved_filenames_analysis[i]<<endl;
}
}
// TOM'S fix of why the last file gets overwritten again and again - but seems to prevent the files being written to the screen.
/*
_RUN_DONE = true;
*/
meshIsComplete=false;
_synth_save_cnt=0;
// _saved_filenames_synthesis has processed all the files in the analysis images folder
while(!_RUN_DONE && _state != STATE_STOP)
Thread::sleep(3);
Thread::sleep(10);
}
void StrobeAnalysis::displayresults()
@ -241,6 +346,27 @@ void StrobeAnalysis::displayresults()
void StrobeAnalysis::draw()
{
ofEnableSmoothing();
ofEnableLighting();
ofEnableSeparateSpecularLight();
light.setPointLight();
light.enable();
lightStatic.enable();
light.setPosition(ofGetWidth()/2,ofGetHeight()/2,5);
lightStatic.setPosition(ofGetWidth()/2,ofGetHeight()/2,-1);
glEnable(GL_DEPTH_TEST);
ofSetLineWidth(1.0f);
glPointSize(5.0f);
ofEnableBlendMode(blendMode);
switch (_state) {
case STATE_ACQUIRING:
{
@ -259,7 +385,6 @@ void StrobeAnalysis::draw()
ofRect(0, 0, ofGetWidth(), ofGetHeight());
//cout << "FADE IN STROBE TIME " << endl;
}
if (_frame_cnt >= _fade_in_frames && _frame_cnt < (_frame_cnt_max-_fade_in_frames)){
@ -291,6 +416,7 @@ void StrobeAnalysis::draw()
}
ofDisableAlphaBlending();
} else {
//_state = STATE_SYNTHESISING;
_RUN_DONE = true;
@ -433,3 +559,408 @@ void StrobeAnalysis::save_cb(Timer& timer)
saveImageAnalysis(file_name);
}
void StrobeAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage currentFirstImage, ofImage currentSecondImage, ofMesh & mesh){
int x=0;
int y=0;
//get rid of all previous vectors and colours
mesh.clear();
mesh.setMode(meshMode);
ofColor meshColour=ofColor(255,255,255);
//the average z position of the matrix - used later to centre the mesh on the z axis when drawing
float zPlaneAverage=0;
for(int i=0;i<sPixels.size();i++){
zPlaneAverage+=sPixels[i];
}
if (sPixels.size()!=0) {
zPlaneAverage/=sPixels.size();
//cout<<zPlaneAverage<<" zPlaneAverage "<<endl;
}
else{
cout<<"DEPTH FLOAT ARRAY IS EMPTY";
}
if(chooseColour==1){
for(int i=0;i<sPixels.size();i++){
mesh.addColor( currentSecondImage.getColor(x, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
mesh.addColor( currentSecondImage.getColor(x, y));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y+1));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
mesh.addColor( currentSecondImage.getColor(x, y));
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
mesh.addColor( currentSecondImage.getColor(x+1, y) );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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==2){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor = currentSecondImage.getColor(x, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor;
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1 ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*(y+1),- sPixels[(currentSecondImage.getWidth()*(y+1))+x+1] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
mesh.addColor( currentSecondImageColor);
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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==4){
for(int i=0;i<sPixels.size();i++){
ofColor currentSecondImageColor;
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
int randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter+1),- sPixels[ (currentSecondImage.getWidth()*(y+randomJitter+1))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*((y+randomJitter)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1 ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*((y+randomJitter)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+randomJitter),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
mesh.addColor( currentSecondImageColor.getBrightness());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x+randomJitter)+1),_mesh_size_multiplier*(y+randomJitter),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) +1 ]));
ofSeedRandom();
currentSecondImageColor.r = ofRandom(0,255);
currentSecondImageColor.g = ofRandom(0,255);
currentSecondImageColor.b = ofRandom(0,255);
randomJitter = ofRandom(0,5);
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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==5){
for(int i=0;i<sPixels.size();i++){
int randomJitter2 = 0;
int randomJitter = 0;
ofColor currentSecondImageColor;
ofColor currentSecondImageBW;
currentSecondImageColor = currentSecondImage.getColor(x, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*((y)+1),- sPixels[ (currentSecondImage.getWidth()*(y+randomJitter+1))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor(currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor(currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*((y)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1 ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y+1);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp() );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*((y)+1),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)+1))+(x+randomJitter)+1] ));
currentSecondImageColor = currentSecondImage.getColor(x, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp());
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter) ] ));
currentSecondImageColor = currentSecondImage.getColor(x+1, y);
currentSecondImageBW.r = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.g = currentSecondImageColor.getBrightness()+randomJitter2;
currentSecondImageBW.b = currentSecondImageColor.getBrightness()+randomJitter2;
mesh.addColor( currentSecondImageBW.clamp() );
mesh.addVertex(ofVec3f(_mesh_size_multiplier*((x)+1),_mesh_size_multiplier*(y),- sPixels[(currentSecondImage.getWidth()*((y+randomJitter)))+(x+randomJitter)+1 ]));
x=x+vertexSubsampling;
if(x>=currentSecondImage.getWidth()-1){
x=0;
y=y+vertexSubsampling;
//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;
}
}
}
}
}
vector<float> StrobeAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImag){
ofPixels imagePixels1 = image1.getPixelsRef();
//ofPixels imagePixels2 = image2.getPixelsRef();
ofPixels backgroundPixels = backgroundImag.getPixelsRef();
vector<float> differences;
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];
for(int i=0;i<imagePixels1.size();i++){
thesePixels[i]=0;
}
int x=0;
int y=0;
int chooseComparison=1;
//comparison here to find out how close each color is to pure RED / GREEN / BLUE
if(chooseComparison==1){
//for each pixel...
float _maxPossibleDistanceToCentre=ofDist(0,0,imagePixels1.getWidth()/2, imagePixels1.getHeight()/2);
for(int i=0;i<imagePixels1.size();i+=3){
ofColor imageColor1 = imagePixels1.getColor(x, y);
//ofColor colourImage2 = imagePixels2.getColor(x, y);
float _distanceToCentre=ofDist(imagePixels1.getWidth()/2, imagePixels1.getHeight()/2, x, y);
float _presumedBrightness=ofMap(sqrt(_maxPossibleDistanceToCentre)-sqrt(_distanceToCentre), 0, sqrt(_maxPossibleDistanceToCentre), 0, 255);
//int thisDiff=abs(imageColor1.getHue());
//int thisDiff=abs(imageColor1.getBrightness());
//int thisDiff=abs(imageColor1.getBrightness()-_presumedBrightness);
int thisDiff=-abs(imageColor1.getBrightness());
//int thisDiff=abs(imageColor1.getLightness());
//int thisDiff=-abs(imageColor1.r);
//cout<<thisDiff<< " thisDiff "<<endl;
//red hue: 0
//green hue: 120
//blue hue: 240
differences.push_back(multiplier * thisDiff);
thesePixels[i]=thisDiff;
thesePixels[i+1]=thisDiff;
thesePixels[i+2]=thisDiff;
x++;
if(x>=imagePixels1.getWidth()){
x=0;
y++;
}
}
}
//difference.setFromPixels(thesePixels,imagePixels1.getWidth(),imagePixels1.getHeight(), 3);
return differences;
}

View File

@ -65,10 +65,20 @@ protected:
ofxCvContourFinder cvContourFinder1;
//this is the temporary container to allow us to convert and save out greyscale images
ofxCvColorImage cvConvertorImage;
//mesh making function
void setMeshFromPixels(vector<float> sPixels, ofImage currentFirstImage, ofImage currentSecondImage, ofMesh & mesh);
//depth map function
vector<float> _returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImage);
int vertexSubsampling;
int chooseColour;
ofPrimitiveMode meshMode;
ofBlendMode blendMode;
float multiplier;
bool _gotFirstImage;
ofImage _background;
};