colorsingle and colormulti are in interesting places -
* need to talk to tom about _mesh_size_multiplier and the camera positionings * still need to fix the file saving thing - we're getting very few frames out for the number of frames in current (threading issue)
This commit is contained in:
parent
34f3cf6ffd
commit
ec8d6f1296
@ -43,7 +43,7 @@ ofxXmlSettings RefractiveIndex::XML;
|
|||||||
void RefractiveIndex::setup()
|
void RefractiveIndex::setup()
|
||||||
{
|
{
|
||||||
camDist=1000;
|
camDist=1000;
|
||||||
|
ofBackground(0, 0, 0);
|
||||||
//camera.setOrientation(ofVec3f(1,-1,1));
|
//camera.setOrientation(ofVec3f(1,-1,1));
|
||||||
bool save_config = false;
|
bool save_config = false;
|
||||||
|
|
||||||
@ -228,40 +228,15 @@ void RefractiveIndex::draw()
|
|||||||
if(_currentAnalysis->meshIsComplete){
|
if(_currentAnalysis->meshIsComplete){
|
||||||
|
|
||||||
fbo.begin();
|
fbo.begin();
|
||||||
ofEnableSmoothing();
|
glShadeModel(GL_SMOOTH);
|
||||||
//glShadeModel(GL_SMOOTH);
|
|
||||||
//glFogf(GL_FOG_END, -200);
|
|
||||||
|
|
||||||
//glHint(GL_NICEST, GL_DONT_CARE);
|
|
||||||
|
|
||||||
//glEnable(GL_NORMALIZE);
|
|
||||||
//glEnable(GL_DEPTH_TEST);
|
|
||||||
//ofEnableSeparateSpecularLight();
|
|
||||||
|
|
||||||
//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);
|
|
||||||
|
|
||||||
//ofEnableBlendMode ( OF_BLENDMODE_ADD );
|
|
||||||
//ofEnableBlendMode ( OF_BLENDMODE_MULTIPLY );
|
|
||||||
//ofEnableBlendMode ( OF_BLENDMODE_SUBTRACT );
|
|
||||||
ofEnableBlendMode ( OF_BLENDMODE_ALPHA );
|
|
||||||
//ofEnableBlendMode ( OF_BLENDMODE_SCREEN );
|
|
||||||
|
|
||||||
ofClear(0,0,0);
|
ofClear(0,0,0);
|
||||||
|
|
||||||
camera.begin();
|
camera.begin();
|
||||||
|
|
||||||
ofSetColor(0, 0, 0);
|
|
||||||
|
|
||||||
//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
|
//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();
|
ofPushMatrix();
|
||||||
ofTranslate(0, 0,-500);
|
ofTranslate(0, 0,-500);
|
||||||
|
ofSetColor(0, 0, 0);
|
||||||
ofRect(-fbo.getWidth(), -fbo.getHeight(), fbo.getWidth()*3, fbo.getHeight()*3);
|
ofRect(-fbo.getWidth(), -fbo.getHeight(), fbo.getWidth()*3, fbo.getHeight()*3);
|
||||||
ofPopMatrix();
|
ofPopMatrix();
|
||||||
ofSetColor(255);
|
ofSetColor(255);
|
||||||
@ -271,7 +246,8 @@ void RefractiveIndex::draw()
|
|||||||
|
|
||||||
ofTranslate(xDiff,yDiff,-_currentAnalysis->zPlaneAverage );
|
ofTranslate(xDiff,yDiff,-_currentAnalysis->zPlaneAverage );
|
||||||
ofScale(1.33333,1.0,1.0);
|
ofScale(1.33333,1.0,1.0);
|
||||||
_currentAnalysis->aMesh.drawVertices();
|
//_currentAnalysis->aMesh.drawVertices(); // TODO: tom - why do you have the vertices drawing here?
|
||||||
|
_currentAnalysis->aMesh.drawFaces();
|
||||||
_currentAnalysis->aMesh.draw();
|
_currentAnalysis->aMesh.draw();
|
||||||
|
|
||||||
camera.end();
|
camera.end();
|
||||||
@ -284,7 +260,7 @@ void RefractiveIndex::draw()
|
|||||||
//saving jpgs doesn't work - pngs only!
|
//saving jpgs doesn't work - pngs only!
|
||||||
// PNG is fine - better for Final Cut anyway!
|
// PNG is fine - better for Final Cut anyway!
|
||||||
|
|
||||||
ofDisableBlendMode( ) ;
|
ofDisableBlendMode() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,6 +76,5 @@ public:
|
|||||||
ofCamera camera;
|
ofCamera camera;
|
||||||
ofPixels keepOnScreen;
|
ofPixels keepOnScreen;
|
||||||
ofFbo fbo;
|
ofFbo fbo;
|
||||||
ofLight light;
|
|
||||||
ofLight lightStatic;
|
|
||||||
};
|
};
|
||||||
@ -65,6 +65,7 @@ public:
|
|||||||
bool imageForContourAvailable;
|
bool imageForContourAvailable;
|
||||||
ofMesh aMesh;
|
ofMesh aMesh;
|
||||||
ofLight light;
|
ofLight light;
|
||||||
|
ofLight lightStatic;
|
||||||
|
|
||||||
string meshFileName;
|
string meshFileName;
|
||||||
//difference between our image size and the size of the fbo
|
//difference between our image size and the size of the fbo
|
||||||
|
|||||||
@ -24,8 +24,9 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
|||||||
meshIsComplete=false;
|
meshIsComplete=false;
|
||||||
_gotFirstImage=false;
|
_gotFirstImage=false;
|
||||||
|
|
||||||
_mesh_size_multiplier=4;
|
_mesh_size_multiplier=5;
|
||||||
|
vertexSubsampling = 1;
|
||||||
|
chooseColour=1;
|
||||||
|
|
||||||
int acq_run_time; // 10 seconds of acquiring per run
|
int acq_run_time; // 10 seconds of acquiring per run
|
||||||
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_colormulti", ACQUIRE_TIME);
|
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_colormulti", ACQUIRE_TIME);
|
||||||
@ -269,6 +270,27 @@ void ColorMultiAnalysis::displayresults()
|
|||||||
void ColorMultiAnalysis::draw()
|
void ColorMultiAnalysis::draw()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ofEnableSmoothing();
|
||||||
|
|
||||||
|
ofEnableLighting();
|
||||||
|
ofEnableSeparateSpecularLight();
|
||||||
|
light.enable();
|
||||||
|
|
||||||
|
light.setPosition(200,200,-150);
|
||||||
|
lightStatic.enable();
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
ofSetLineWidth(2.0f);
|
||||||
|
//glPointSize(4.0f);
|
||||||
|
|
||||||
|
ofEnableBlendMode ( OF_BLENDMODE_ADD );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_MULTIPLY );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_SUBTRACT );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_ALPHA );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_SCREEN );
|
||||||
|
|
||||||
|
|
||||||
switch (_state) {
|
switch (_state) {
|
||||||
case STATE_ACQUIRING:
|
case STATE_ACQUIRING:
|
||||||
{
|
{
|
||||||
@ -465,7 +487,14 @@ void ColorMultiAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curren
|
|||||||
|
|
||||||
//get rid of all previous vectors and colours
|
//get rid of all previous vectors and colours
|
||||||
mesh.clear();
|
mesh.clear();
|
||||||
mesh.setMode(OF_PRIMITIVE_LINE_STRIP);
|
|
||||||
|
mesh.setMode(OF_PRIMITIVE_TRIANGLES);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_LINES);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_LINE_STRIP);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_LINE_LOOP);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_POINTS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OF_PRIMITIVE_TRIANGLES,
|
OF_PRIMITIVE_TRIANGLES,
|
||||||
@ -478,9 +507,9 @@ void ColorMultiAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curren
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ofColor meshColour=ofColor(255,0,0);
|
ofColor meshColour=ofColor(255,255,255);
|
||||||
|
|
||||||
|
|
||||||
int chooseColour=1 ;
|
|
||||||
|
|
||||||
//the average z position of the matrix - used later to centre the mesh on the z axis when drawing
|
//the average z position of the matrix - used later to centre the mesh on the z axis when drawing
|
||||||
float zPlaneAverage=0;
|
float zPlaneAverage=0;
|
||||||
@ -518,10 +547,10 @@ void ColorMultiAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curren
|
|||||||
mesh.addColor( currentSecondImage.getColor(x+1, y) );
|
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 ]));
|
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
|
||||||
|
|
||||||
x++;
|
x=x+vertexSubsampling;
|
||||||
if(x>=currentSecondImage.getWidth()-1){
|
if(x>=currentSecondImage.getWidth()-1){
|
||||||
x=0;
|
x=0;
|
||||||
y++;
|
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?
|
//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){
|
if(y>=currentSecondImage.getHeight()-1){
|
||||||
break;
|
break;
|
||||||
@ -572,8 +601,8 @@ vector<float> ColorMultiAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofIm
|
|||||||
//int thisDiff=abs(imageColor1.getBrightness());
|
//int thisDiff=abs(imageColor1.getBrightness());
|
||||||
//int thisDiff=abs(imageColor1.getBrightness()-_presumedBrightness);
|
//int thisDiff=abs(imageColor1.getBrightness()-_presumedBrightness);
|
||||||
|
|
||||||
//int thisDiff=abs(imageColor1.getHue());
|
int thisDiff=255-abs(imageColor1.getHue());
|
||||||
int thisDiff=abs(imageColor1.getLightness());
|
//int thisDiff=abs(imageColor1.getLightness());
|
||||||
|
|
||||||
//cout<<thisDiff<< " thisDiff "<<endl;
|
//cout<<thisDiff<< " thisDiff "<<endl;
|
||||||
|
|
||||||
@ -581,7 +610,7 @@ vector<float> ColorMultiAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofIm
|
|||||||
//green hue: 120
|
//green hue: 120
|
||||||
//blue hue: 240
|
//blue hue: 240
|
||||||
|
|
||||||
float multiplier=4.0;
|
float multiplier=5.0;
|
||||||
|
|
||||||
differences.push_back(multiplier* thisDiff);
|
differences.push_back(multiplier* thisDiff);
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,9 @@ protected:
|
|||||||
//depth map function
|
//depth map function
|
||||||
vector<float> _returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImage);
|
vector<float> _returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImage);
|
||||||
|
|
||||||
|
int vertexSubsampling;
|
||||||
|
int chooseColour;
|
||||||
|
|
||||||
bool _gotFirstImage;
|
bool _gotFirstImage;
|
||||||
ofImage _background;
|
ofImage _background;
|
||||||
|
|
||||||
|
|||||||
@ -26,8 +26,11 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
|||||||
//flag for main sketch
|
//flag for main sketch
|
||||||
meshIsComplete=false;
|
meshIsComplete=false;
|
||||||
_gotFirstImage=false;
|
_gotFirstImage=false;
|
||||||
|
|
||||||
_mesh_size_multiplier=4;
|
_mesh_size_multiplier=4;
|
||||||
|
vertexSubsampling = 5;
|
||||||
|
chooseColour=1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int acq_run_time; // 10 seconds of acquiring per run
|
int acq_run_time; // 10 seconds of acquiring per run
|
||||||
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_colorsingle", ACQUIRE_TIME);
|
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_colorsingle", ACQUIRE_TIME);
|
||||||
@ -161,30 +164,40 @@ void ColorSingleAnalysis::synthesise()
|
|||||||
|
|
||||||
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
|
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
|
||||||
|
|
||||||
if(_saved_filenames_analysis[i].find("RED")>0)
|
|
||||||
|
cout << "_saved_filenames_analysis[i].find(RED): " << _saved_filenames_analysis[i].find("RED") << endl;
|
||||||
|
|
||||||
|
if(_saved_filenames_analysis[i].find("RED")<_saved_filenames_analysis[i].length())
|
||||||
{
|
{
|
||||||
fileNameColor = "RED";
|
fileNameColor = "RED";
|
||||||
cout<<"FOUND RED"<<endl;
|
cout<<"FOUND RED"<<endl;
|
||||||
}
|
} else if (_saved_filenames_analysis[i].find("GREEN")<_saved_filenames_analysis[i].length())
|
||||||
|
|
||||||
if(_saved_filenames_analysis[i].find("BLUE")>0)
|
|
||||||
{
|
|
||||||
fileNameColor = "BLUE";
|
|
||||||
cout<<"FOUND BLUE"<<endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_saved_filenames_analysis[i].find("GREEN")>0)
|
|
||||||
{
|
{
|
||||||
fileNameColor = "GREEN";
|
fileNameColor = "GREEN";
|
||||||
cout<<"FOUND GREEN"<<endl;
|
cout<<"FOUND GREEN"<<endl;
|
||||||
|
} else if(_saved_filenames_analysis[i].find("BLUE")<_saved_filenames_analysis[i].length())
|
||||||
|
{
|
||||||
|
fileNameColor = "BLUE";
|
||||||
|
cout<<"FOUND BLUE"<<endl;
|
||||||
|
} else if(_saved_filenames_analysis[i].find("FADING")<_saved_filenames_analysis[i].length())
|
||||||
|
{
|
||||||
|
fileNameColor = "FADING";
|
||||||
|
cout<<"FOUND FADING"<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
|
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
|
||||||
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
|
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
|
||||||
|
|
||||||
cvColorImage1.blur(1);
|
cvColorImage1.blur(1);
|
||||||
|
|
||||||
|
cvSmooth( cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), CV_GAUSSIAN, 3, 3 );
|
||||||
|
|
||||||
|
|
||||||
cvColorImage1.erode();
|
cvColorImage1.erode();
|
||||||
cvColorImage1.erode();
|
|
||||||
|
cvSmooth( cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), CV_GAUSSIAN, 3, 3 );
|
||||||
|
|
||||||
|
//cvColorImage1.erode();
|
||||||
|
|
||||||
//cvColorImage1.dilate();
|
//cvColorImage1.dilate();
|
||||||
//cvColorImage1.dilate();
|
//cvColorImage1.dilate();
|
||||||
@ -195,7 +208,7 @@ void ColorSingleAnalysis::synthesise()
|
|||||||
//cvGrayImage1 = cvColorImage1;
|
//cvGrayImage1 = cvColorImage1;
|
||||||
|
|
||||||
//cvXorS( cvColorImage1.getCvImage(), cvScalarAll(255), cvColorImage1.getCvImage(), 0 );
|
//cvXorS( cvColorImage1.getCvImage(), cvScalarAll(255), cvColorImage1.getCvImage(), 0 );
|
||||||
cvSmooth( cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), CV_GAUSSIAN, 3, 3 );
|
|
||||||
//cvCanny(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 100, 100, 3);
|
//cvCanny(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 100, 100, 3);
|
||||||
//cvLaplace(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0);
|
//cvLaplace(cvGrayImage1.getCvImage(), cvGrayImage1.getCvImage(), 0);
|
||||||
|
|
||||||
@ -294,12 +307,31 @@ void ColorSingleAnalysis::displayresults()
|
|||||||
|
|
||||||
void ColorSingleAnalysis::draw()
|
void ColorSingleAnalysis::draw()
|
||||||
{
|
{
|
||||||
|
ofEnableSmoothing();
|
||||||
|
|
||||||
|
ofEnableLighting();
|
||||||
|
ofEnableSeparateSpecularLight();
|
||||||
|
light.enable();
|
||||||
|
|
||||||
|
light.setPosition(200,200,-150);
|
||||||
|
lightStatic.enable();
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
//ofSetLineWidth(1.0f);
|
||||||
|
glPointSize(4.0f);
|
||||||
|
|
||||||
|
ofEnableBlendMode ( OF_BLENDMODE_ADD );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_MULTIPLY );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_SUBTRACT );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_ALPHA );
|
||||||
|
//ofEnableBlendMode ( OF_BLENDMODE_SCREEN );
|
||||||
|
|
||||||
|
|
||||||
switch (_state) {
|
switch (_state) {
|
||||||
case STATE_ACQUIRING:
|
case STATE_ACQUIRING:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (_frame_cnt < _frame_cnt_max)
|
if (_frame_cnt < _frame_cnt_max)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -498,12 +530,19 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
int x=0;
|
int x=0;
|
||||||
int y=0;
|
int y=0;
|
||||||
|
|
||||||
|
|
||||||
//get rid of all previous vectors and colours
|
//get rid of all previous vectors and colours
|
||||||
mesh.clear();
|
mesh.clear();
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_TRIANGLES);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_LINES);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_LINE_STRIP);
|
||||||
|
//mesh.setMode(OF_PRIMITIVE_LINE_LOOP);
|
||||||
mesh.setMode(OF_PRIMITIVE_POINTS);
|
mesh.setMode(OF_PRIMITIVE_POINTS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OF_PRIMITIVE_TRIANGLES,9
|
OF_PRIMITIVE_TRIANGLES,
|
||||||
OF_PRIMITIVE_TRIANGLE_STRIP,
|
OF_PRIMITIVE_TRIANGLE_STRIP,
|
||||||
OF_PRIMITIVE_TRIANGLE_FAN,
|
OF_PRIMITIVE_TRIANGLE_FAN,
|
||||||
OF_PRIMITIVE_LINES,
|
OF_PRIMITIVE_LINES,
|
||||||
@ -513,9 +552,7 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ofColor meshColour=ofColor(255,0,0);
|
ofColor meshColour=ofColor(255,255,255);
|
||||||
|
|
||||||
int chooseColour=2 ;
|
|
||||||
|
|
||||||
//the average z position of the matrix - used later to centre the mesh on the z axis when drawing
|
//the average z position of the matrix - used later to centre the mesh on the z axis when drawing
|
||||||
float zPlaneAverage=0;
|
float zPlaneAverage=0;
|
||||||
@ -523,6 +560,7 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
for(int i=0;i<sPixels.size();i++){
|
for(int i=0;i<sPixels.size();i++){
|
||||||
zPlaneAverage+=sPixels[i];
|
zPlaneAverage+=sPixels[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPixels.size()!=0) {
|
if (sPixels.size()!=0) {
|
||||||
zPlaneAverage/=sPixels.size();
|
zPlaneAverage/=sPixels.size();
|
||||||
//cout<<zPlaneAverage<<" zPlaneAverage "<<endl;
|
//cout<<zPlaneAverage<<" zPlaneAverage "<<endl;
|
||||||
@ -553,10 +591,10 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
mesh.addColor( currentSecondImage.getColor(x+1, y) );
|
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 ]));
|
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
|
||||||
|
|
||||||
x++;
|
x=x+vertexSubsampling;
|
||||||
if(x>=currentSecondImage.getWidth()-1){
|
if(x>=currentSecondImage.getWidth()-1){
|
||||||
x=0;
|
x=0;
|
||||||
y++;
|
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?
|
//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){
|
if(y>=currentSecondImage.getHeight()-1){
|
||||||
break;
|
break;
|
||||||
@ -593,10 +631,10 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
mesh.addColor( currentSecondImageColor.getBrightness());
|
mesh.addColor( currentSecondImageColor.getBrightness());
|
||||||
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
|
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
|
||||||
|
|
||||||
x++;
|
x=x+vertexSubsampling;
|
||||||
if(x>=currentSecondImage.getWidth()-1){
|
if(x>=currentSecondImage.getWidth()-1){
|
||||||
x=0;
|
x=0;
|
||||||
y++;
|
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?
|
//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){
|
if(y>=currentSecondImage.getHeight()-1){
|
||||||
break;
|
break;
|
||||||
@ -609,14 +647,36 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
|
|
||||||
ofColor currentSecondImageColor;
|
ofColor currentSecondImageColor;
|
||||||
|
|
||||||
if (fileNameColor=="RED")
|
for(int i=0;i<sPixels.size();i++){
|
||||||
|
|
||||||
|
if(fileNameColor=="RED")
|
||||||
{
|
{
|
||||||
currentSecondImageColor.r=255;
|
currentSecondImageColor.r=255;
|
||||||
currentSecondImageColor.g=0;
|
currentSecondImageColor.g=75;
|
||||||
currentSecondImageColor.b=0;
|
currentSecondImageColor.b=75;
|
||||||
}
|
currentSecondImageColor.a=255;
|
||||||
|
|
||||||
for(int i=0;i<sPixels.size();i++){
|
} else if(fileNameColor=="GREEN")
|
||||||
|
{
|
||||||
|
currentSecondImageColor.r=75;
|
||||||
|
currentSecondImageColor.g=255;
|
||||||
|
currentSecondImageColor.b=75;
|
||||||
|
currentSecondImageColor.a=255;
|
||||||
|
|
||||||
|
} else if(fileNameColor=="BLUE")
|
||||||
|
{
|
||||||
|
currentSecondImageColor.r=75;
|
||||||
|
currentSecondImageColor.g=75;
|
||||||
|
currentSecondImageColor.b=255;
|
||||||
|
currentSecondImageColor.a=255;
|
||||||
|
|
||||||
|
} else if(fileNameColor=="FADING")
|
||||||
|
{
|
||||||
|
currentSecondImageColor.r= 255;
|
||||||
|
currentSecondImageColor.g= 255;
|
||||||
|
currentSecondImageColor.b= 255;
|
||||||
|
currentSecondImageColor.a= 255;
|
||||||
|
}
|
||||||
|
|
||||||
mesh.addColor( currentSecondImageColor);
|
mesh.addColor( currentSecondImageColor);
|
||||||
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
|
mesh.addVertex(ofVec3f(_mesh_size_multiplier*x,_mesh_size_multiplier*(y+1),- sPixels[ (currentSecondImage.getWidth()*(y+1))+x ] ));
|
||||||
@ -636,10 +696,12 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
mesh.addColor( currentSecondImageColor);
|
mesh.addColor( currentSecondImageColor);
|
||||||
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
|
mesh.addVertex(ofVec3f(_mesh_size_multiplier*(x+1),_mesh_size_multiplier*y,- sPixels[(currentSecondImage.getWidth()*(y))+x +1 ]));
|
||||||
|
|
||||||
x++;
|
x=x+vertexSubsampling;
|
||||||
|
//x++;
|
||||||
if(x>=currentSecondImage.getWidth()-1){
|
if(x>=currentSecondImage.getWidth()-1){
|
||||||
x=0;
|
x=0;
|
||||||
y++;
|
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?
|
//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){
|
if(y>=currentSecondImage.getHeight()-1){
|
||||||
break;
|
break;
|
||||||
@ -648,7 +710,6 @@ void ColorSingleAnalysis::setMeshFromPixels(vector<float> sPixels, ofImage curre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vector<float> ColorSingleAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImag){
|
vector<float> ColorSingleAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImag){
|
||||||
@ -690,8 +751,31 @@ vector<float> ColorSingleAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofI
|
|||||||
//int thisDiff=abs(imageColor1.getBrightness());
|
//int thisDiff=abs(imageColor1.getBrightness());
|
||||||
//int thisDiff=abs(imageColor1.getBrightness()-_presumedBrightness);
|
//int thisDiff=abs(imageColor1.getBrightness()-_presumedBrightness);
|
||||||
|
|
||||||
//int thisDiff=abs(imageColor1.getHue());
|
int thisDiff;
|
||||||
int thisDiff=abs(imageColor1.getLightness());
|
|
||||||
|
if(fileNameColor=="RED")
|
||||||
|
{
|
||||||
|
thisDiff=abs(imageColor1.r);
|
||||||
|
|
||||||
|
//thisDiff=abs(255-imageColor1.r);
|
||||||
|
} else if(fileNameColor=="GREEN")
|
||||||
|
{
|
||||||
|
thisDiff=abs(imageColor1.g);
|
||||||
|
|
||||||
|
//thisDiff=abs(255-imageColor1.g);
|
||||||
|
|
||||||
|
} else if(fileNameColor=="BLUE")
|
||||||
|
{
|
||||||
|
thisDiff=abs(imageColor1.b);
|
||||||
|
|
||||||
|
//thisDiff=abs(255-imageColor1.b);
|
||||||
|
|
||||||
|
} else if(fileNameColor=="FADING") {
|
||||||
|
|
||||||
|
thisDiff=imageColor1.getBrightness();
|
||||||
|
//thisDiff=255-imageColor1.getBrightness();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//cout<<thisDiff<< " thisDiff "<<endl;
|
//cout<<thisDiff<< " thisDiff "<<endl;
|
||||||
|
|
||||||
@ -699,7 +783,7 @@ vector<float> ColorSingleAnalysis::_returnDepthsAtEachPixel(ofImage &image1, ofI
|
|||||||
//green hue: 120
|
//green hue: 120
|
||||||
//blue hue: 240
|
//blue hue: 240
|
||||||
|
|
||||||
float multiplier=1.0;
|
float multiplier=2.0;
|
||||||
|
|
||||||
differences.push_back(multiplier* thisDiff);
|
differences.push_back(multiplier* thisDiff);
|
||||||
|
|
||||||
|
|||||||
@ -75,6 +75,9 @@ protected:
|
|||||||
//depth map function
|
//depth map function
|
||||||
vector<float> _returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImage);
|
vector<float> _returnDepthsAtEachPixel(ofImage &image1, ofImage &image2, ofImage &backgroundImage);
|
||||||
|
|
||||||
|
int vertexSubsampling;
|
||||||
|
int chooseColour;
|
||||||
|
|
||||||
bool _gotFirstImage;
|
bool _gotFirstImage;
|
||||||
ofImage _background;
|
ofImage _background;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user