future everything build
This commit is contained in:
parent
f8291acdc5
commit
2699edc3ac
@ -1,7 +1,7 @@
|
||||
<!-- THIS FILE NEEDS TO GO IN THE APPLICATION /data/ folder -->
|
||||
|
||||
<config>
|
||||
<mode>drawing</mode>
|
||||
<mode>analysis</mode>
|
||||
<camera>
|
||||
<id>1</id>
|
||||
<width>640</width>
|
||||
@ -11,7 +11,7 @@
|
||||
<fps>30</fps>
|
||||
</display>
|
||||
<locale>
|
||||
<name>SWANSEA</name>
|
||||
<name>FUTURE</name>
|
||||
</locale>
|
||||
|
||||
<analysis_NUM_RUN>
|
||||
@ -34,10 +34,30 @@
|
||||
<acquiretime_strobe> 30 </acquiretime_strobe>
|
||||
<acquiretime_camnoise> 30 </acquiretime_camnoise>
|
||||
<acquiretime_colorsingle> 40 </acquiretime_colorsingle>
|
||||
<acquiretime_colormulti> 40 </acquiretime_colormulti>
|
||||
<acquiretime_colormulti> 10 </acquiretime_colormulti>
|
||||
<acquiretime_diffnoise> 30 </acquiretime_diffnoise>
|
||||
</analysis_time>
|
||||
|
||||
<algorithms>
|
||||
<vertices_per_frame>1000</vertices_per_frame>
|
||||
<pixel_per_vertex>4</pixel_per_vertex>
|
||||
<colormulti>
|
||||
<algo>2</algo>
|
||||
<scale>4</scale>
|
||||
<draw_style>2</draw_style>
|
||||
</colormulti>
|
||||
<relaxrate>
|
||||
<algo>1</algo>
|
||||
<scale>500</scale>
|
||||
<draw_style>1</draw_style>
|
||||
</relaxrate>
|
||||
<shadowscapes>
|
||||
<algo>3</algo>
|
||||
<scale>1</scale>
|
||||
<draw_style>1</draw_style>
|
||||
</shadowscapes>
|
||||
</algorithms>
|
||||
|
||||
<relaxrate>
|
||||
<treshold>51</treshold>
|
||||
<maxblobs>25</maxblobs>
|
||||
|
||||
@ -15,6 +15,11 @@
|
||||
|
||||
#include "ofxXmlSettings.h"
|
||||
|
||||
#include "ofxArcBall.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CAMERA_ID 0
|
||||
#define CAMERA_ACQU_WIDTH 640
|
||||
#define CAMERA_ACQU_HEIGHT 480
|
||||
@ -27,6 +32,22 @@
|
||||
#define ISTATE_TRANSITION 0xCCCC
|
||||
#define ISTATE_END 0xDDDD
|
||||
|
||||
static const int subdiv_pixels = 4;
|
||||
|
||||
static const int VID_W = 640, VID_H = 480;
|
||||
static const int VERTICES_X = VID_W / subdiv_pixels, VERTICES_Y = VID_W / subdiv_pixels;
|
||||
static const int TRI_W = 1000;
|
||||
|
||||
int draw_style = FACE;
|
||||
|
||||
#define ALGO_1 1
|
||||
#define ALGO_2 2
|
||||
#define ALGO_3 3
|
||||
#define ALGO_4 4
|
||||
|
||||
int algo = ALGO_2;
|
||||
float scale = 1.f;
|
||||
|
||||
|
||||
int _state = ISTATE_UNDEF;
|
||||
|
||||
@ -40,8 +61,64 @@ string RefractiveIndex::_location;
|
||||
|
||||
ofxXmlSettings RefractiveIndex::XML;
|
||||
|
||||
ofShader RefractiveIndex::_shader;
|
||||
ofVboMesh RefractiveIndex::_mesh_vbo;
|
||||
|
||||
ofxArcBall RefractiveIndex::cam;
|
||||
|
||||
string msg;
|
||||
|
||||
void RefractiveIndex::setup_shader_vbo()
|
||||
{
|
||||
|
||||
int vertices_per_frame = XML.getValue("config:algorithms:vertices_per_frame", TRI_W);
|
||||
int pixel_per_vertex = XML.getValue("config:algorithms:pixel_per_vertex", subdiv_pixels);
|
||||
|
||||
int vertices_X = _vid_w / pixel_per_vertex, vertices_Y = _vid_h / pixel_per_vertex;
|
||||
|
||||
// VBO
|
||||
for(int i = 0; i < vertices_X; i++){
|
||||
for(int j = 0; j < vertices_Y; j++) {
|
||||
_verts.push_back(ofVec3f((i / (float)vertices_X) * vertices_per_frame, (j / (float) vertices_Y) * vertices_per_frame, 0.0f));
|
||||
_tex.push_back(ofVec2f(i / (float)vertices_X * _vid_w, j / (float) vertices_Y * _vid_h));
|
||||
if( ( i + 1 < vertices_X ) && ( j + 1 < vertices_Y ) ) {
|
||||
//triangle #1
|
||||
_ind.push_back( (i+0) * vertices_Y + (j+0) );
|
||||
_ind.push_back( (i+1) * vertices_Y + (j+0) );
|
||||
_ind.push_back( (i+1) * vertices_Y + (j+1) );
|
||||
|
||||
//triangle #2
|
||||
_ind.push_back( (i+1) * vertices_Y + (j+1) );
|
||||
_ind.push_back( (i+0) * vertices_Y + (j+1) );
|
||||
_ind.push_back( (i+0) * vertices_Y + (j+0) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//ofEnableNormalizedTexCoords();
|
||||
|
||||
_mesh_vbo.addVertices(_verts);
|
||||
_mesh_vbo.addTexCoords(_tex);
|
||||
_mesh_vbo.addIndices(_ind);
|
||||
|
||||
_mesh_vbo.setMode(OF_PRIMITIVE_TRIANGLES);
|
||||
|
||||
// geometry shader
|
||||
|
||||
_shader.setGeometryInputType(GL_TRIANGLES);
|
||||
_shader.setGeometryOutputType(GL_TRIANGLES);
|
||||
_shader.setGeometryOutputCount(3);
|
||||
_shader.load("dviid/rfi.vert.glsl", "dviid/rfi.frag.glsl", "dviid/rfi.geom.glsl");
|
||||
printf("Maximum number of output vertices support is: %i\n", _shader.getGeometryMaxOutputCount());
|
||||
}
|
||||
|
||||
|
||||
void RefractiveIndex::setup()
|
||||
{
|
||||
ofSetLogLevel(OF_LOG_VERBOSE);
|
||||
|
||||
ofHideCursor();
|
||||
|
||||
bool save_config = false;
|
||||
|
||||
cout << "Loading configuration..." << endl;
|
||||
@ -99,16 +176,24 @@ void RefractiveIndex::setup()
|
||||
|
||||
//getting a warning from the OFlog that the pixels aren't allocated
|
||||
//void ofPixels::allocate(int w, int h, ofImageType type)
|
||||
_pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR);
|
||||
_pixels.allocate(_vid_w, _vid_h, OF_IMAGE_COLOR_ALPHA);
|
||||
|
||||
|
||||
setup_shader_vbo();
|
||||
|
||||
|
||||
//TODO: whichever one of these is first - it always runs twice ?
|
||||
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(V));
|
||||
|
||||
//_analysisVector.push_back(new ShadowScapesAnalysis(V));
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(H));
|
||||
|
||||
/*
|
||||
_analysisVector.push_back(new ShadowScapesAnalysis(D));
|
||||
|
||||
|
||||
*/
|
||||
_analysisVector.push_back(new RelaxRateAnalysis());
|
||||
/*
|
||||
|
||||
|
||||
_analysisVector.push_back(new IResponseAnalysis());
|
||||
@ -120,18 +205,23 @@ void RefractiveIndex::setup()
|
||||
_analysisVector.push_back(new CamNoiseAnalysis());
|
||||
|
||||
_analysisVector.push_back(new ColorSingleAnalysis());
|
||||
|
||||
*/
|
||||
|
||||
_analysisVector.push_back(new ColorMultiAnalysis());
|
||||
|
||||
_analysisVector.push_back(new DiffNoiseAnalysis());
|
||||
//_analysisVector.push_back(new DiffNoiseAnalysis());
|
||||
|
||||
|
||||
//_currentAnalysisIndx = 0;
|
||||
//_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
//_state = ISTATE_START;
|
||||
_currentAnalysisIndx = 1;
|
||||
_state = ISTATE_TRANSITION;
|
||||
|
||||
// to be idle at the beginning of the program (i.e. press keys to )
|
||||
//_currentAnalysis = NULL;
|
||||
//_state = ISTATE_UNDEF;
|
||||
|
||||
_currentAnalysis = NULL;
|
||||
_state = ISTATE_UNDEF;
|
||||
|
||||
ofSetEscapeQuitsApp(false);
|
||||
|
||||
}
|
||||
|
||||
@ -173,7 +263,6 @@ void RefractiveIndex::state_analysis()
|
||||
_currentAnalysisIndx = 0;
|
||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
_state = ISTATE_START;
|
||||
//_state = ISTATE_END;
|
||||
} else {
|
||||
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
|
||||
_state = ISTATE_START;
|
||||
@ -204,10 +293,7 @@ void RefractiveIndex::update()
|
||||
}
|
||||
|
||||
void RefractiveIndex::draw()
|
||||
{
|
||||
// refractive mauve - this doesn't work... looks weird in various places.
|
||||
//ofBackground(113, 110, 136);
|
||||
|
||||
{
|
||||
// black
|
||||
ofBackground(0, 0, 0);
|
||||
|
||||
@ -246,8 +332,21 @@ void RefractiveIndex::stop_camera()
|
||||
|
||||
void RefractiveIndex::keyPressed (int key)
|
||||
{
|
||||
|
||||
std::stringstream out;
|
||||
out << (char)key;
|
||||
msg.append(out.str());
|
||||
if(msg.find("kcuf") != string::npos) {
|
||||
cout << "alright" << endl;
|
||||
exitApp();
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if( key =='f')
|
||||
ofToggleFullscreen();
|
||||
*/
|
||||
|
||||
/* TODO: complete the below... would be good to trigger the Analysis from keypresses if needed... */
|
||||
// currently this doesn't work... the save_cb's in the individual
|
||||
@ -255,6 +354,7 @@ void RefractiveIndex::keyPressed (int key)
|
||||
|
||||
// i.e.: ask david how to shut off the prior Analysis if it's not finished running from here?
|
||||
|
||||
/*
|
||||
if(key == 'x')
|
||||
{
|
||||
if(_currentAnalysis)
|
||||
@ -361,6 +461,7 @@ void RefractiveIndex::keyPressed (int key)
|
||||
if(!_currentAnalysis)
|
||||
_state = ISTATE_TRANSITION;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
TO DO: add a file dialog so we can save images to another hard drive...
|
||||
|
||||
@ -11,9 +11,15 @@
|
||||
#include "ofxOpenCv.h"
|
||||
#include "ofxXmlSettings.h"
|
||||
|
||||
#include "ofxArcBall.h"
|
||||
|
||||
#define MODE_DRAWING 0xEEFF
|
||||
#define MODE_ANALYSING 0xFFEE
|
||||
|
||||
#define VERTS 1
|
||||
#define WIRE 2
|
||||
#define FACE 3
|
||||
|
||||
class RefractiveIndex : public ofBaseApp
|
||||
{
|
||||
public:
|
||||
@ -32,6 +38,8 @@ public:
|
||||
void stop_analysis();
|
||||
void state_analysis();
|
||||
|
||||
void setup_shader_vbo();
|
||||
|
||||
// ofx
|
||||
void keyPressed (int key);
|
||||
void keyReleased(int key){;}
|
||||
@ -69,4 +77,16 @@ public:
|
||||
static string _location;
|
||||
static ofxXmlSettings XML; // made this static so we can access RUN_NUM in the analyses
|
||||
|
||||
|
||||
static ofVboMesh _mesh_vbo;
|
||||
|
||||
vector<ofVec3f> _verts;
|
||||
vector<ofVec2f> _tex;
|
||||
vector<unsigned int> _ind;
|
||||
|
||||
static ofxArcBall cam;
|
||||
|
||||
static ofShader _shader;
|
||||
|
||||
|
||||
};
|
||||
@ -10,8 +10,8 @@ int main() {
|
||||
|
||||
bool fullscreen;
|
||||
|
||||
//fullscreen = true;
|
||||
fullscreen = false;
|
||||
fullscreen = true;
|
||||
//fullscreen = false;
|
||||
|
||||
cout << "> display configuration" << endl;
|
||||
cout << "* fullscreen: " << (fullscreen ? "yes" : "no") << endl;
|
||||
|
||||
@ -20,6 +20,16 @@ void AbstractAnalysis::setup(int camWidth, int camHeight) {
|
||||
_whole_file_path_synthesis = r.filePath + "/darwings";
|
||||
}
|
||||
|
||||
// viewport
|
||||
|
||||
tx = RefractiveIndex::XML.getValue("config:viewport:tx", 200.0);
|
||||
ty = RefractiveIndex::XML.getValue("config:viewport:ty", 50.0);
|
||||
tz = RefractiveIndex::XML.getValue("config:viewport:tz", -500.0);
|
||||
|
||||
rx = RefractiveIndex::XML.getValue("config:viewport:rx", 0.0);
|
||||
ry = RefractiveIndex::XML.getValue("config:viewport:ry", 0.0);
|
||||
rz = RefractiveIndex::XML.getValue("config:viewport:rz", 0.0);
|
||||
|
||||
}
|
||||
|
||||
// this is the main threaded loop for a given analysis
|
||||
@ -39,13 +49,14 @@ void AbstractAnalysis::do_synthesize() {
|
||||
_state = STATE_ACQUIRING;
|
||||
acquire();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_SYNTHESISING;
|
||||
synthesise();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
//_state = STATE_SYNTHESISING;
|
||||
//synthesise();
|
||||
//if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
displayresults();
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MODE_DRAWING:
|
||||
@ -60,13 +71,15 @@ void AbstractAnalysis::do_synthesize() {
|
||||
synthesise();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
displayresults();
|
||||
cleanup();
|
||||
displayresults();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
cleanup();
|
||||
ofxFileHelper::deleteFolder(_whole_file_path_analysis);
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
|
||||
}
|
||||
@ -95,7 +108,7 @@ void AbstractAnalysis::create_dir_allocate_images()
|
||||
}
|
||||
|
||||
ofxFileHelper fileHelperAnalysis;
|
||||
ofxFileHelper fileHelperSynthesis;
|
||||
//ofxFileHelper fileHelperSynthesis;
|
||||
|
||||
_whole_file_path_analysis = ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ;
|
||||
|
||||
@ -118,6 +131,7 @@ void AbstractAnalysis::create_dir_allocate_images()
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
_whole_file_path_synthesis = SYNTHESIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime;
|
||||
|
||||
if(!fileHelperSynthesis.doesDirectoryExist(_whole_file_path_synthesis)){
|
||||
@ -135,6 +149,7 @@ void AbstractAnalysis::create_dir_allocate_images()
|
||||
fileHelperSynthesis.makeDirectory(SYNTHESIS_PATH+RefractiveIndex::_location+"/"+_name+"/"+replaceTime);
|
||||
|
||||
}
|
||||
*/
|
||||
//////////////////////////////END DIRECTORY CREATION //////////////////////////////////////////////////
|
||||
|
||||
|
||||
@ -189,6 +204,7 @@ void AbstractAnalysis::saveImageAnalysis(string filename)
|
||||
if (RefractiveIndex::_vidGrabber.isFrameNew())
|
||||
{
|
||||
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,7 +79,11 @@ protected:
|
||||
float DELTA_T_SAVE;
|
||||
int NUM_PHASE;
|
||||
int NUM_RUN;
|
||||
int NUM_SAVE_PER_RUN;
|
||||
int NUM_SAVE_PER_RUN;
|
||||
|
||||
//viewport
|
||||
|
||||
float tx, ty, tz, rx, ry, rz;
|
||||
|
||||
friend class AnalysisAdaptor;
|
||||
};
|
||||
@ -12,6 +12,11 @@ using Poco::Thread;
|
||||
#define NUMBER_RUNS 1
|
||||
#define ACQUIRE_TIME 20
|
||||
|
||||
const int algo_default = 1;
|
||||
const int scale_default = 500;
|
||||
const int draw_style_default = 3;
|
||||
const float line_width_default = 0.5f;
|
||||
|
||||
void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
||||
{
|
||||
AbstractAnalysis::setup(camWidth, camHeight);
|
||||
@ -46,50 +51,21 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
||||
|
||||
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);
|
||||
|
||||
//cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
|
||||
//cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
|
||||
|
||||
// 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();
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
algo = RefractiveIndex::XML.getValue("config:algorithms:colormulti:algo", algo_default);
|
||||
scale = RefractiveIndex::XML.getValue("config:algorithms:colormulti:scale", scale_default);
|
||||
draw_style = RefractiveIndex::XML.getValue("config:algorithms:colormulti:draw_style", draw_style_default);
|
||||
line_width = RefractiveIndex::XML.getValue("config:algorithms:colormulti:line_width", line_width_default);
|
||||
|
||||
}
|
||||
|
||||
@ -127,68 +103,8 @@ void ColorMultiAnalysis::synthesise()
|
||||
|
||||
//cout << "ColorMultiAnalysis::saving synthesis...\n";
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
|
||||
|
||||
//cout << "ColorMultiAnalysis::synthesis FOR LOOP...\n";
|
||||
|
||||
//cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
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.blur(5);
|
||||
cvColorImage1.erode();
|
||||
cvColorImage1.erode();
|
||||
cvColorImage1.dilate();
|
||||
cvColorImage1.blur(5);
|
||||
cvColorImage1.dilate();
|
||||
cvColorImage1.dilate();
|
||||
cvColorImage1.dilate();
|
||||
cvColorImage1.dilate();
|
||||
|
||||
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
|
||||
string file_name;
|
||||
|
||||
file_name = ofToString(_synth_save_cnt, 2)+"_ColorMultiAnalysis_"+ofToString(_run_cnt,2)+".jpg";
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
|
||||
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
|
||||
//ofImage image;
|
||||
//image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR);
|
||||
|
||||
//*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
|
||||
//image.setUseTexture(false);
|
||||
|
||||
//image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR);
|
||||
//image.saveImage(_whole_file_path_synthesis+"/"+file_name);
|
||||
|
||||
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
|
||||
|
||||
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
|
||||
saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
|
||||
_synth_save_cnt++;
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
_RUN_DONE = false;
|
||||
|
||||
// _saved_filenames_synthesis has processed all the files in the analysis images folder
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
@ -197,7 +113,7 @@ void ColorMultiAnalysis::synthesise()
|
||||
|
||||
void ColorMultiAnalysis::displayresults()
|
||||
{
|
||||
for(float i=1;i<_saved_filenames_synthesis.size();i++){
|
||||
for(float i=1;i<_saved_filenames_analysis.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
@ -208,13 +124,15 @@ void ColorMultiAnalysis::displayresults()
|
||||
//cout << "!_image_shown" << endl;
|
||||
}
|
||||
|
||||
if(!image3.loadImage(_saved_filenames_synthesis[i])){
|
||||
_show_image = false;
|
||||
|
||||
|
||||
if(!image1.loadImage(_saved_filenames_analysis[i])){
|
||||
//couldn't load image
|
||||
cout << "didn't load image" << endl;
|
||||
}
|
||||
|
||||
if(image3.loadImage(_saved_filenames_synthesis[i])){
|
||||
image3.loadImage(_saved_filenames_synthesis[i]);
|
||||
if(image1.loadImage(_saved_filenames_analysis[i])){
|
||||
//cout << "_show_image = true;" << endl;
|
||||
_show_image = true;
|
||||
_image_shown = false;
|
||||
@ -356,8 +274,9 @@ void ColorMultiAnalysis::draw()
|
||||
_anim_cnt++;
|
||||
|
||||
} else {
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
//_state = STATE_DISPLAY_RESULTS;
|
||||
_anim_cnt=0;
|
||||
_RUN_DONE = true;
|
||||
}
|
||||
ofPopMatrix();
|
||||
ofSetRectMode(OF_RECTMODE_CORNER);
|
||||
@ -371,7 +290,6 @@ void ColorMultiAnalysis::draw()
|
||||
|
||||
//cout << "STATE_DISPLAY_RESULTS...\n" << endl;
|
||||
|
||||
|
||||
if (_frame_cnt > 2)
|
||||
{
|
||||
_image_shown = true;
|
||||
@ -380,22 +298,48 @@ void ColorMultiAnalysis::draw()
|
||||
|
||||
_frame_cnt++;
|
||||
|
||||
if (_show_image)
|
||||
{
|
||||
//cout << "_show_image...\n" << endl;
|
||||
|
||||
ofEnableAlphaBlending();
|
||||
ofEnableAlphaBlending();
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glLineWidth(line_width);
|
||||
|
||||
ofSetColor(255, 255, 255);
|
||||
image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
|
||||
image2.draw(0,0, ofGetWidth(), ofGetHeight());
|
||||
RefractiveIndex::cam.begin();
|
||||
|
||||
ofDisableAlphaBlending();
|
||||
}
|
||||
|
||||
// display results of the synthesis
|
||||
_RUN_DONE = true;
|
||||
break;
|
||||
ofTranslate(tx, ty, tz);
|
||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||
glScalef(1.5, 1, 1);
|
||||
|
||||
if (_show_image)
|
||||
image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
|
||||
|
||||
image2.bind();
|
||||
|
||||
RefractiveIndex::_shader.begin();
|
||||
|
||||
RefractiveIndex::_shader.setUniform1i("algo", algo);
|
||||
RefractiveIndex::_shader.setUniform1f("scale", scale);
|
||||
RefractiveIndex::_shader.setUniform1i("tex0", 0);
|
||||
|
||||
switch (draw_style) {
|
||||
case VERTS:
|
||||
RefractiveIndex::_mesh_vbo.drawVertices();
|
||||
break;
|
||||
case WIRE:
|
||||
RefractiveIndex::_mesh_vbo.drawWireframe();
|
||||
break;
|
||||
case FACE:
|
||||
RefractiveIndex::_mesh_vbo.drawFaces();
|
||||
break;
|
||||
}
|
||||
|
||||
RefractiveIndex::_shader.end();
|
||||
|
||||
image2.unbind();
|
||||
|
||||
RefractiveIndex::cam.end();
|
||||
|
||||
_RUN_DONE = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -31,32 +31,14 @@ protected:
|
||||
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
|
||||
|
||||
bool _show_image, _image_shown;
|
||||
|
||||
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;
|
||||
|
||||
ofxCvContourFinder cvContourFinder1;
|
||||
|
||||
//this is the temporary container to allow us to convert and save out greyscale images
|
||||
ofxCvColorImage cvConvertorImage;
|
||||
int algo;
|
||||
int scale;
|
||||
int draw_style;
|
||||
float line_width;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -15,6 +15,12 @@ using Poco::Thread;
|
||||
#define TRESHOLD 80
|
||||
#define MAXBLOBS 15
|
||||
|
||||
const int algo_default = 1;
|
||||
const int scale_default = 500;
|
||||
const int draw_style_default = 3;
|
||||
const int line_width_default = 0.5f;
|
||||
const float point_size_default = 0.5f;
|
||||
|
||||
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||
{
|
||||
AbstractAnalysis::setup(camWidth, camHeight);
|
||||
@ -57,18 +63,24 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||
_image_shown = false;
|
||||
|
||||
image1.clear();
|
||||
image2.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
|
||||
|
||||
image1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||
image2.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();
|
||||
cvGrayDiff1.clear();
|
||||
|
||||
cvColorImage1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
cvGrayDiff1.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||
|
||||
////---------
|
||||
|
||||
algo = RefractiveIndex::XML.getValue("config:algorithms:relaxrate:algo", algo_default);
|
||||
scale = RefractiveIndex::XML.getValue("config:algorithms:relaxrate:scale", scale_default);
|
||||
draw_style = RefractiveIndex::XML.getValue("config:algorithms:relaxrate:draw_style", draw_style_default);
|
||||
line_width = RefractiveIndex::XML.getValue("config:algorithms:relaxrate:line_width", line_width_default);
|
||||
point_size = RefractiveIndex::XML.getValue("config:algorithms:relaxrate:point_size", point_size_default);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -104,73 +116,43 @@ void RelaxRateAnalysis::synthesise()
|
||||
//cout << "IResponseAnalysis::saving synthesis...\n";
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
cvContourFinderVect.clear();
|
||||
|
||||
|
||||
for(float i=1;i<_saved_filenames_analysis.size();i++){
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
_RUN_DONE = false;
|
||||
|
||||
// _saved_filenames_synthesis has processed all the files in the analysis images folder
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RelaxRateAnalysis::displayresults()
|
||||
{
|
||||
|
||||
//cvContourFinderVectDisplay.clear();
|
||||
clearcfindervectdisplay();
|
||||
|
||||
for(int i=1;i<cvContourFinderVect.size();i++){
|
||||
|
||||
if(_state == STATE_STOP){
|
||||
clearcfindervectdisplay();
|
||||
clearcfindervect();
|
||||
return;
|
||||
}
|
||||
for(float i=1;i<_saved_filenames_analysis.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
//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;
|
||||
_show_image = false;
|
||||
|
||||
}
|
||||
|
||||
clearcfindervectdisplay();
|
||||
clearcfindervect();
|
||||
|
||||
|
||||
//cvContourFinderVectDisplay.clear();
|
||||
//cvContourFinderVect.clear();
|
||||
|
||||
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 << "_show_image = true;" << endl;
|
||||
_show_image = true;
|
||||
_image_shown = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -311,17 +293,49 @@ void RelaxRateAnalysis::draw()
|
||||
}
|
||||
|
||||
_frame_cnt++;
|
||||
|
||||
ofEnableAlphaBlending();
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glLineWidth(line_width);
|
||||
glPointSize(point_size);
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
|
||||
RefractiveIndex::cam.begin();
|
||||
|
||||
ofTranslate(tx, ty, tz);
|
||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||
glScalef(1.5, 1, 1);
|
||||
|
||||
if (_show_image)
|
||||
{
|
||||
for(int i=0;i<cvContourFinderVectDisplay.size();i++){
|
||||
cvContourFinderVectDisplay[i]->draw(0,0, ofGetWidth(), ofGetHeight());
|
||||
}
|
||||
|
||||
image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
|
||||
|
||||
image2.bind();
|
||||
|
||||
RefractiveIndex::_shader.begin();
|
||||
|
||||
RefractiveIndex::_shader.setUniform1i("algo", algo);
|
||||
RefractiveIndex::_shader.setUniform1f("scale", scale);
|
||||
RefractiveIndex::_shader.setUniform1i("tex0", 0);
|
||||
|
||||
switch (draw_style) {
|
||||
case VERTS:
|
||||
RefractiveIndex::_mesh_vbo.drawVertices();
|
||||
break;
|
||||
case WIRE:
|
||||
RefractiveIndex::_mesh_vbo.drawWireframe();
|
||||
break;
|
||||
case FACE:
|
||||
RefractiveIndex::_mesh_vbo.drawFaces();
|
||||
break;
|
||||
}
|
||||
|
||||
// display results of the synthesis
|
||||
_RUN_DONE = true;
|
||||
RefractiveIndex::_shader.end();
|
||||
|
||||
image2.unbind();
|
||||
|
||||
RefractiveIndex::cam.end();
|
||||
|
||||
//_RUN_DONE = true;
|
||||
break;
|
||||
|
||||
}
|
||||
@ -344,27 +358,3 @@ void RelaxRateAnalysis::save_cb(Timer& timer)
|
||||
|
||||
}
|
||||
|
||||
void RelaxRateAnalysis::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RelaxRateAnalysis::clearcfindervect()
|
||||
{
|
||||
for(int i = 0; i < cvContourFinderVect.size(); i++) {
|
||||
rfiCvContourFinder* f = cvContourFinderVect[i];
|
||||
|
||||
// maybe it's erase here? http://forum.openframeworks.cc/index.php/topic,3016.0.html
|
||||
// cvContourFinderVect.erase(i);
|
||||
|
||||
delete f;
|
||||
}
|
||||
cvContourFinderVect.clear();
|
||||
|
||||
}
|
||||
|
||||
void RelaxRateAnalysis::clearcfindervectdisplay()
|
||||
{
|
||||
cvContourFinderVectDisplay.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@ public:
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void displayresults();
|
||||
void cleanup();
|
||||
|
||||
void draw();
|
||||
|
||||
@ -31,8 +30,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void clearcfindervect();
|
||||
void clearcfindervectdisplay();
|
||||
|
||||
bool _RUN_DONE;
|
||||
float _flip, _level;
|
||||
@ -44,11 +41,13 @@ protected:
|
||||
|
||||
bool _show_image, _image_shown;
|
||||
|
||||
ofImage image1;
|
||||
ofxCvColorImage cvColorImage1;
|
||||
ofxCvGrayscaleImage cvGrayDiff1;
|
||||
ofImage image1;
|
||||
ofImage image2;
|
||||
|
||||
vector<rfiCvContourFinder*> cvContourFinderVect;
|
||||
vector<rfiCvContourFinder*> cvContourFinderVectDisplay;
|
||||
int algo;
|
||||
int scale;
|
||||
int draw_style;
|
||||
float line_width;
|
||||
float point_size;
|
||||
|
||||
};
|
||||
|
||||
@ -17,6 +17,11 @@ using Poco::Thread;
|
||||
#define NUMBER_RUNS 1
|
||||
#define ACQUIRE_TIME 20
|
||||
|
||||
const int algo_default = 1;
|
||||
const int scale_default = 500;
|
||||
const int draw_style_default = 3;
|
||||
const double line_width_default = 0.5;
|
||||
|
||||
void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||
{
|
||||
AbstractAnalysis::setup(camWidth, camHeight);
|
||||
@ -42,7 +47,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||
DELTA_T_SAVE = 3*(10*acq_run_time/2); // for 20 seconds, we want this to be around 100 files
|
||||
// or 5 times per second = every 200 ms
|
||||
|
||||
_scanLineWidth = 100.0;
|
||||
_scanLineWidth = 300.0;
|
||||
_run_cnt = 0;
|
||||
_save_cnt = 0;
|
||||
_synth_save_cnt = 0;
|
||||
@ -55,50 +60,21 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||
|
||||
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);
|
||||
|
||||
//cout << "RefractiveIndex::_vid_w " << RefractiveIndex::_vid_w << endl;
|
||||
//cout << "RefractiveIndex::_vid_h " << RefractiveIndex::_vid_h << endl;
|
||||
|
||||
// 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();
|
||||
////---------
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
algo = RefractiveIndex::XML.getValue("config:algorithms:shadowscapes:algo", algo_default);
|
||||
scale = RefractiveIndex::XML.getValue("config:algorithms:shadowscapes:scale", scale_default);
|
||||
draw_style = RefractiveIndex::XML.getValue("config:algorithms:shadowscapes:draw_style", draw_style_default);
|
||||
line_width = RefractiveIndex::XML.getValue("config:algorithms:shadowscapes:line_width", line_width_default);
|
||||
|
||||
}
|
||||
|
||||
@ -128,114 +104,43 @@ void ShadowScapesAnalysis::synthesise()
|
||||
{
|
||||
//cout << "ShadowScapesAnalysis::saving synthesis...\n";
|
||||
|
||||
for(float i=1;i<_saved_filenames_analysis.size()-1; i++){
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
// cout << "ShadowScapesAnalysis::synthesis FOR LOOP...\n";
|
||||
|
||||
// cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
if(!image1.loadImage(_saved_filenames_analysis[i])){
|
||||
//couldn't load image
|
||||
cout << "didn't load image" << endl;
|
||||
}
|
||||
|
||||
if(image1.loadImage(_saved_filenames_analysis[i])){
|
||||
|
||||
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);
|
||||
|
||||
//cvGrayImage1 = cvColorImage1;
|
||||
//cvGrayImage2 = cvColorImage2;
|
||||
|
||||
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
|
||||
cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
|
||||
|
||||
cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
|
||||
cvGrayDiff1.erode();
|
||||
cvGrayDiff1.contrastStretch();
|
||||
cvGrayDiff1.blur(5);
|
||||
cvGrayDiff1.dilate();
|
||||
|
||||
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
|
||||
string file_name;
|
||||
|
||||
if(_dir == H) {
|
||||
file_name = ofToString(_synth_save_cnt, 2)+"_H_ShadowScapesSynthesis_"+ofToString(_run_cnt,2)+".jpg";
|
||||
}
|
||||
|
||||
if(_dir == V) {
|
||||
file_name = ofToString(_synth_save_cnt, 2)+"_V_ShadowScapesSynthesis_"+ofToString(_run_cnt,2)+".jpg";
|
||||
}
|
||||
|
||||
if(_dir == D) {
|
||||
file_name = ofToString(_synth_save_cnt, 2)+"_D_ShadowScapesSynthesis_"+ofToString(_run_cnt,2)+".jpg";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//<---- 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);
|
||||
|
||||
|
||||
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
|
||||
//ofImage image;
|
||||
//image.allocate(cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE);
|
||||
|
||||
//*** This needs to be here for OSX of we get a BAD ACCESS ERROR. DOES IT BREAK WINDOWS? ***//
|
||||
//image.setUseTexture(false);
|
||||
|
||||
//image.setFromPixels(cvGrayDiff1.getPixels(), cvGrayDiff1.width, cvGrayDiff1.height, OF_IMAGE_GRAYSCALE);
|
||||
//image.saveImage(_whole_file_path_synthesis+"/"+file_name);
|
||||
|
||||
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
|
||||
|
||||
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
|
||||
cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
|
||||
|
||||
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
|
||||
_synth_save_cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
_RUN_DONE = false;
|
||||
|
||||
// _saved_filenames_synthesis has processed all the files in the analysis images folder
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
while(!_RUN_DONE && _state != STATE_STOP)
|
||||
Thread::sleep(3);
|
||||
}
|
||||
|
||||
|
||||
void ShadowScapesAnalysis::displayresults()
|
||||
{
|
||||
for(float i=1;i<_saved_filenames_synthesis.size();i++){
|
||||
for(float i=1;i<_saved_filenames_analysis.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) 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);
|
||||
//cout << "!_image_shown" << endl;
|
||||
}
|
||||
|
||||
if(!image3.loadImage(_saved_filenames_synthesis[i])){
|
||||
_show_image = false;
|
||||
|
||||
|
||||
if(!image1.loadImage(_saved_filenames_analysis[i])){
|
||||
//couldn't load image
|
||||
cout << "didn't load image" << endl;
|
||||
}
|
||||
|
||||
if(image3.loadImage(_saved_filenames_synthesis[i])){
|
||||
image3.loadImage(_saved_filenames_synthesis[i]);
|
||||
if(image1.loadImage(_saved_filenames_analysis[i])){
|
||||
//cout << "_show_image = true;" << endl;
|
||||
_show_image = true;
|
||||
_image_shown = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -423,27 +328,47 @@ void ShadowScapesAnalysis::draw()
|
||||
|
||||
_frame_cnt++;
|
||||
|
||||
|
||||
ofEnableAlphaBlending();
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glLineWidth(line_width);
|
||||
|
||||
RefractiveIndex::cam.begin();
|
||||
|
||||
ofTranslate(tx, ty, tz);
|
||||
ofRotateX(rx); ofRotateY(ry); ofRotateZ(rz);
|
||||
glScalef(1.5, 1, 1);
|
||||
|
||||
if (_show_image)
|
||||
{
|
||||
// cout << "_show_image...\n" << endl;
|
||||
|
||||
ofEnableAlphaBlending();
|
||||
|
||||
ofSetColor(255, 255, 255);
|
||||
|
||||
image2.setFromPixels(image3.getPixels(),image3.width,image3.height, OF_IMAGE_COLOR);
|
||||
image2.draw(0,0, ofGetWidth(), ofGetHeight());
|
||||
|
||||
ofDisableAlphaBlending();
|
||||
|
||||
|
||||
image2.setFromPixels(image1.getPixels(), image1.width, image1.height, OF_IMAGE_COLOR);
|
||||
|
||||
image2.bind();
|
||||
|
||||
RefractiveIndex::_shader.begin();
|
||||
|
||||
RefractiveIndex::_shader.setUniform1i("algo", algo);
|
||||
RefractiveIndex::_shader.setUniform1f("scale", scale);
|
||||
RefractiveIndex::_shader.setUniform1i("tex0", 0);
|
||||
|
||||
switch (draw_style) {
|
||||
case VERTS:
|
||||
RefractiveIndex::_mesh_vbo.drawVertices();
|
||||
break;
|
||||
case WIRE:
|
||||
RefractiveIndex::_mesh_vbo.drawWireframe();
|
||||
break;
|
||||
case FACE:
|
||||
RefractiveIndex::_mesh_vbo.drawFaces();
|
||||
break;
|
||||
}
|
||||
|
||||
// display results of the synthesis
|
||||
RefractiveIndex::_shader.end();
|
||||
|
||||
image2.unbind();
|
||||
|
||||
RefractiveIndex::cam.end();
|
||||
|
||||
_RUN_DONE = true;
|
||||
|
||||
// clear allocated memory...?
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -42,31 +42,13 @@ protected:
|
||||
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
|
||||
|
||||
bool _show_image, _image_shown;
|
||||
|
||||
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;
|
||||
|
||||
ofxCvContourFinder cvContourFinder1;
|
||||
|
||||
//this is the temporary container to allow us to convert and save out greyscale images
|
||||
ofxCvColorImage cvConvertorImage;
|
||||
int algo;
|
||||
int scale;
|
||||
int draw_style;
|
||||
double line_width;
|
||||
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user