Compare commits

..

No commits in common. "master" and "tom" have entirely different histories.
master ... tom

15 changed files with 326 additions and 382 deletions

10
README Normal file
View File

@ -0,0 +1,10 @@
WARNING: WORK IN PROGRESS...
configuring OpenFrameworks
-----------------
these files are configured according to OpenFrameworks addons - http://ofxaddons.com/howto
(1) drag-drop "ReflectiveIndex" folder into your OpenFrameworks project
(2) Install depedencies: {ofxDirList, ofxControlPanel, ofxXmlSettings};
(3) Press Play!

View File

@ -1,2 +0,0 @@
<img src="https://davidgauthier.info/rfi/img-resize/rfi3.jpg" width="100%">
<img src="https://davidgauthier.info/rfi/img-resize/rfi4.jpg" width="100%">

View File

@ -97,29 +97,29 @@ void RefractiveIndex::setup()
//TODO: whichever one of these is first - it always runs twice ?
//_analysisVector.push_back(new ShadowScapesAnalysis(V));
//_analysisVector.push_back(new ShadowScapesAnalysis(H));
//_analysisVector.push_back(new ShadowScapesAnalysis(D));
// _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());
_analysisVector.push_back(new IResponseAnalysis());
//_analysisVector.push_back(new ShapeFromShadingAnalysis());
_analysisVector.push_back(new ShapeFromShadingAnalysis());
//_analysisVector.push_back(new StrobeAnalysis());
// _analysisVector.push_back(new StrobeAnalysis());
//_analysisVector.push_back(new CamNoiseAnalysis());
_analysisVector.push_back(new CamNoiseAnalysis());
//_analysisVector.push_back(new ColorSingleAnalysis());
_analysisVector.push_back(new ColorSingleAnalysis());
//_analysisVector.push_back(new ColorMultiAnalysis());
_analysisVector.push_back(new ColorMultiAnalysis());
//_analysisVector.push_back(new DiffNoiseAnalysis());
_analysisVector.push_back(new DiffNoiseAnalysis());
_currentAnalysisIndx = 0;
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx);
_state = ISTATE_START;
@ -209,7 +209,6 @@ void RefractiveIndex::setup_camera()
ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber";
return;
}
_vidGrabber.setUseTexture(false);
_vidGrabber.listDevices();
_vidGrabber.setVerbose(true);
_vid_stream_open = true;

View File

@ -4,14 +4,6 @@
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
/////////////////////////dis is the new shit///////////
/////////////////////////dis is the new shit///////////
/////////////////////////dis is the new shit///////////
/////////////////////////dis is the new shit///////////
int main() {
ofAppGlutWindow window;

View File

@ -72,8 +72,8 @@ void AbstractAnalysis::create_dir()
}
ofxFileHelper fileHelper;
_whole_file_path = ofToDataPath("") + ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ;
cout << "_whole_file_path = " << _whole_file_path << endl;
_whole_file_path = ANALYSIS_PATH + RefractiveIndex::_location + "/" + _name + "/"+replaceTime ;
//cout << "_whole_file_path = " << _whole_file_path << endl;
if(!fileHelper.doesDirectoryExist(_whole_file_path)){
fileHelper.makeDirectory(ANALYSIS_PATH);
@ -163,8 +163,7 @@ ofPixels AbstractAnalysis::calculateListOfZValues(ofImage image1, ofImage image2
int y=0;
//for each pixel...
//for(int i=0;i<imagePixels1.size();i+=3){
for(int i=0;i<20;i+=3){
for(int i=0;i<imagePixels1.size();i+=3){
//get the colour of each image at this x y location - we will use these colours for comparison according to the below criteria
ofColor colourImage1 = imagePixels1.getColor(x, y);
@ -317,20 +316,3 @@ int AbstractAnalysis::getRecordedValueFromFileName(string str){
}
void AbstractAnalysis::saveimage(string filename)
{
if(RefractiveIndex::_pixels.isAllocated()) {
string fname = _whole_file_path + "/" + filename;
cout << "saving - " << fname << endl;
ofSaveImage(RefractiveIndex::_pixels, fname, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(fname);
} else {
ofLog(OF_LOG_ERROR) << "RefractiveIndex::_pixels NOT allocated...";
}
}

View File

@ -39,7 +39,6 @@ public:
protected:
virtual void create_dir();
virtual void saveimage(string filename);
// acquire images - all the children (see - do_synthesize)
virtual void acquire() = 0;

View File

@ -132,58 +132,50 @@ void CamNoiseAnalysis::draw()
/// *** TODO *** ///
// still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** ///
if (_frame_cnt < _frame_cnt_max)
{
ofEnableAlphaBlending();
ofColor aColour;
int _fade_in_frames = _frame_cnt_max/10;
float _number_of_grey_levels=10;
float _frames_per_level = _frame_cnt_max / _number_of_grey_levels;
ofColor someColor;
if (_frame_cnt < _fade_in_frames) {
aColour.set(255, 255, 255, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
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)){
for(int i=0;i<_number_of_grey_levels;i++){
if (_frame_cnt>= _frames_per_level *( i-1) && +_frame_cnt < _frames_per_level * (i) ) {
//set colour to current grey level
c=255-( 255.0 * ( i /_number_of_grey_levels));
someColor.set(c);
}
ofSetColor(someColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
aColour.set(0, 0, 0, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
// cout << "FADE OUT STROBE TIME " << endl;
}
ofDisableAlphaBlending();
} else {
_RUN_DONE = true;
ofEnableAlphaBlending();
ofColor aColour;
int _fade_in_frames = _frame_cnt_max/10;
float _number_of_grey_levels=10;
float _frames_per_level = _frame_cnt_max / _number_of_grey_levels;
ofColor someColor;
if (_frame_cnt < _fade_in_frames) {
aColour.set(255, 255, 255, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
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)){
for(int i=0;i<_number_of_grey_levels;i++){
if (_frame_cnt>= _frames_per_level *( i-1) && +_frame_cnt < _frames_per_level * (i) ) {
//set colour to current grey level
c=255-( 255.0 * ( i /_number_of_grey_levels));
someColor.set(c);
}
ofSetColor(someColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
aColour.set(0, 0, 0, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
// cout << "FADE OUT STROBE TIME " << endl;
}
_frame_cnt++;
ofDisableAlphaBlending();
break;
}
case STATE_SYNTHESISING:
@ -233,10 +225,16 @@ void CamNoiseAnalysis::save_cb(Timer& timer)
_save_cnt++;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
string thisLocation = RefractiveIndex::_location;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
string file = _whole_file_path+"/"+file_name;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+file);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
void CamNoiseAnalysis::display_results_cb(Timer& timer){
@ -244,4 +242,4 @@ void CamNoiseAnalysis::display_results_cb(Timer& timer){
if (_results_cnt>_results_cnt_max) {
_RUN_DONE=true;
}
}
}

View File

@ -150,54 +150,43 @@ void ColorMultiAnalysis::draw()
switch (_state) {
case STATE_ACQUIRING:
{
int _fade_in_frames = _frame_cnt_max/50;
if (_frame_cnt < _frame_cnt_max)
{
if (_frame_cnt < _fade_in_frames) {
ofColor aColor;
int _fade_in_frames = _frame_cnt_max/50;
aColor.setHsb(c, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255), ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
if (_frame_cnt < _fade_in_frames) {
ofColor aColor;
aColor.setHsb(c, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255), ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
cout << "FADING IN..." << endl;
}
ofSetColor(aColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
if (_frame_cnt >= _fade_in_frames && _frame_cnt < _frame_cnt_max-_fade_in_frames){
ofColor aColor;
aColor.setHsb(c, 255, 255);
ofSetColor(aColor);
//how far are we as a percent of _frame_count_max * 360 HUE VALUES
c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
ofColor aColor;
aColor.setHsb(c, 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255), 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_fade_cnt++;
cout << "FADING OUT..." << endl;
}
} else {
_RUN_DONE = true;
cout << "FADING IN..." << endl;
}
if (_frame_cnt >= _fade_in_frames && _frame_cnt < _frame_cnt_max-_fade_in_frames){
ofColor aColor;
aColor.setHsb(c, 255, 255);
ofSetColor(aColor);
//how far are we as a percent of _frame_count_max * 360 HUE VALUES
c = 255.0 * (_frame_cnt_max - _frame_cnt)/(_frame_cnt_max);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
ofColor aColor;
aColor.setHsb(c, 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255), 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColor);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_fade_cnt++;
cout << "FADING OUT..." << endl;
}
_frame_cnt++;
@ -247,14 +236,21 @@ void ColorMultiAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE
void ColorMultiAnalysis::save_cb(Timer& timer)
{
_save_cnt++;
// UPDATE THE COLOR ON THE SCREEN
//float c_last = c;
// cout << "COLORMULTIANALYSIS::saving...\n";
// cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
_save_cnt++;
// cout<<_whole_file_path<<endl;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
if(_save_cnt >= NUM_SAVE_PER_RUN){
_RUN_DONE = true;
}
}
void ColorMultiAnalysis::display_results_cb(Timer& timer){

View File

@ -136,59 +136,51 @@ void ColorSingleAnalysis::draw()
switch (_state) {
case STATE_ACQUIRING:
{
float one_third_of_frame_count_max=_frame_cnt_max/3;
int _fade_in_frames = one_third_of_frame_count_max/10;
if (_frame_cnt < _frame_cnt_max)
{
float one_third_of_frame_count_max=_frame_cnt_max/3;
int _fade_in_frames = one_third_of_frame_count_max/10;
if (_frame_cnt < _fade_in_frames){
ofSetColor(ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255), 0, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "FADING";
}
if (_frame_cnt >= _fade_in_frames && _frame_cnt < one_third_of_frame_count_max){
r=255.0;
g=0.0;
b=0.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "RED";
}
if (_frame_cnt >= one_third_of_frame_count_max && _frame_cnt < 2*one_third_of_frame_count_max){
r=0.0;
g=255.0;
b=0.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "GREEN";
}
if (_frame_cnt >= 2*one_third_of_frame_count_max && _frame_cnt < (_frame_cnt_max-_fade_in_frames) ){
r=0.0;
g=0.0;
b=255.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "BLUE";
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max){
ofSetColor(0, 0, 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255));
cout << "255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255)"<< 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255) << endl;
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_fade_cnt++;
fileNameTag = "FADING";
}
if (_frame_cnt < _fade_in_frames){
ofSetColor(ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255), 0, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "FADING";
}
} else {
_RUN_DONE = true;
if (_frame_cnt >= _fade_in_frames && _frame_cnt < one_third_of_frame_count_max){
r=255.0;
g=0.0;
b=0.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "RED";
}
if (_frame_cnt >= one_third_of_frame_count_max && _frame_cnt < 2*one_third_of_frame_count_max){
r=0.0;
g=255.0;
b=0.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "GREEN";
}
if (_frame_cnt >= 2*one_third_of_frame_count_max && _frame_cnt < (_frame_cnt_max-_fade_in_frames) ){
r=0.0;
g=0.0;
b=255.0;
ofSetColor(r,g,b);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
fileNameTag = "BLUE";
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max){
ofSetColor(0, 0, 255-ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255));
cout << "255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255)"<< 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255) << endl;
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_fade_cnt++;
fileNameTag = "FADING";
}
_frame_cnt++;
@ -236,16 +228,21 @@ void ColorSingleAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE
void ColorSingleAnalysis::save_cb(Timer& timer)
{
//cout << "ColorSingleAnalysis::saving...\n";
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
_save_cnt++;
// cout << "ColorSingleAnalysis::saving...\n";
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
//cout<<ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
cout<<file_name<<endl;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
//cout<<_whole_file_path+"/"+file_name<<endl;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
void ColorSingleAnalysis::display_results_cb(Timer& timer){

View File

@ -126,77 +126,67 @@ void DiffNoiseAnalysis::draw()
switch (_state) {
case STATE_ACQUIRING:
{
ofColor aColour;
int rectSize = 5;
ofEnableAlphaBlending();
if (_frame_cnt < _frame_cnt_max)
{
ofColor aColour;
int rectSize = 5;
ofEnableAlphaBlending();
int _fade_in_frames = _frame_cnt_max/10;
if (_frame_cnt < _fade_in_frames) {
int _fade_in_frames = _frame_cnt_max/10;
if (_frame_cnt < _fade_in_frames) {
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
{
for (int j=1; j < ofGetWidth(); j=j+rectSize)
{
for (int j=1; j < ofGetWidth(); j=j+rectSize)
{
c = ofRandom(0,255);
aColour.set(c, c, c, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(j, i, rectSize, rectSize);
}
}
cout << "FADING IN..." << endl;
}
if (_frame_cnt >= _fade_in_frames && _frame_cnt < (_frame_cnt_max-_fade_in_frames)){
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
{
for (int j=1; j < ofGetWidth(); j=j+rectSize)
{
c = ofRandom(0,255);
aColour.set(c, c, c, 255);
ofSetColor(aColour);
ofRect(j, i, rectSize, rectSize);
}
}
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
{
for (int j=1; j < ofGetWidth(); j=j+rectSize)
{
c = ofRandom(0,255);
aColour.set(c, c, c, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(j, i, rectSize, rectSize);
}
c = ofRandom(0,255);
aColour.set(c, c, c, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(j, i, rectSize, rectSize);
}
_fade_cnt++;
cout << "FADING OUT..." << endl;
}
cout << "FADING IN..." << endl;
}
if (_frame_cnt >= _fade_in_frames && _frame_cnt < (_frame_cnt_max-_fade_in_frames)){
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
{
for (int j=1; j < ofGetWidth(); j=j+rectSize)
{
c = ofRandom(0,255);
aColour.set(c, c, c, 255);
ofSetColor(aColour);
ofRect(j, i, rectSize, rectSize);
}
}
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
for (int i=1; i < ofGetHeight() ; i=i+rectSize)
{
for (int j=1; j < ofGetWidth(); j=j+rectSize)
{
c = ofRandom(0,255);
aColour.set(c, c, c, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(j, i, rectSize, rectSize);
}
}
_fade_cnt++;
cout << "FADING OUT..." << endl;
ofDisableAlphaBlending();
} else {
_RUN_DONE = true;
}
ofDisableAlphaBlending();
_frame_cnt++;
break;
@ -252,19 +242,27 @@ void DiffNoiseAnalysis::save_cb(Timer& timer)
if (rand10 > 5.0) {
cout << "DiffNoiseAnalysis::saving...\n";
cout << "c_last... " << c << endl;
cout<<"rand10... " <<rand10<<endl;
cout << "DiffNoiseAnalysis::saving...\n";
cout << "c_last... " << c << endl;
cout<<"rand10... " <<rand10<<endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
string file = _whole_file_path+"/"+file_name;
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+file);
}
_save_cnt++;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
void DiffNoiseAnalysis::display_results_cb(Timer& timer){

View File

@ -140,8 +140,6 @@ void IResponseAnalysis::draw()
ofSetColor(c, c, c);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
c = 255.0 * (_frame_cnt_max*_frame_cnt_max - _frame_cnt*_frame_cnt)/(_frame_cnt_max*_frame_cnt_max);
} else {
_RUN_DONE = true;
}
_frame_cnt++;
@ -191,16 +189,23 @@ void IResponseAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE
void IResponseAnalysis::save_cb(Timer& timer)
{
//cout << "IResponseAnalysis::saving...\n";
//cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
{
_save_cnt++;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
cout << "IResponseAnalysis::saving...\n";
//cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
string thisLocation = RefractiveIndex::_location;
//RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
// fileName = imageSaveFolderPath+whichAnalysis+"_"+ofToString(100.0*i*scanLineSpeed/ofGetHeight(),2)+"%_"+ofToString(i)+".jpg";
//ofSaveImage(vectorOfPixels[i], fileName, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
void IResponseAnalysis::display_results_cb(Timer& timer){
_results_cnt++;

View File

@ -20,7 +20,7 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
{
DELTA_T_SAVE = 130;
NUM_PHASE = 1;
NUM_RUN = 3;
NUM_RUN = 1;
NUM_SAVE_PER_RUN = 100;
create_dir();
@ -61,7 +61,6 @@ void RelaxRateAnalysis::acquire()
void RelaxRateAnalysis::synthesise()
{
/*
//incrementer to whichMesh
speed=0.2;
//whichMesh is the index in the vector of meshes
@ -101,13 +100,10 @@ void RelaxRateAnalysis::synthesise()
index++;
}
}
*/
}
void RelaxRateAnalysis::display_results(){
/*
Timer* display_results_timer;
TimerCallback<RelaxRateAnalysis> display_results_callback(*this, &RelaxRateAnalysis::display_results_cb);
@ -123,7 +119,6 @@ void RelaxRateAnalysis::display_results(){
Thread::sleep(3);
display_results_timer->stop();
*/
}
@ -139,7 +134,7 @@ void RelaxRateAnalysis::draw()
// still need to deal with latency frames here - i.e.: there are frames
/// *** TODO *** ///
if (_frame_cnt < _frame_cnt_max)
if (_frame_cnt <= _frame_cnt_max)
{
float lightLevel=pow(_level,2);
@ -157,8 +152,7 @@ void RelaxRateAnalysis::draw()
} else {
cout << "RELAXRATE RUN COMPLETED" << endl;
//_state = STATE_SYNTHESISING;
_RUN_DONE = true;
_state = STATE_SYNTHESISING;
}
_frame_cnt++;
@ -175,7 +169,6 @@ void RelaxRateAnalysis::draw()
case STATE_DISPLAY_RESULTS:
{
/*
// display results of the synthesis
// display results of the synthesis
int imageWidth=640;
@ -197,7 +190,6 @@ void RelaxRateAnalysis::draw()
whichMesh+=speed;
}
*/
break;
}
@ -214,17 +206,20 @@ void RelaxRateAnalysis::draw()
// this runs at save_cb timer rate = DELTA_T_SAVE
void RelaxRateAnalysis::save_cb(Timer& timer)
{
//cout << "RelaxRateAnalysis::saving...\n";
_save_cnt++;
cout << "RelaxRateAnalysis::saving...\n";
//cout << "c_last... " << c << endl;
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(c,2)+"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
_save_cnt++;
string thisLocation = RefractiveIndex::_location;
string file = _whole_file_path+"/"+file_name;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
ofSaveImage(RefractiveIndex::_pixels, file, OF_IMAGE_QUALITY_BEST);
_saved_filenames.push_back(ofToDataPath("")+file);
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
void RelaxRateAnalysis::display_results_cb(Timer& timer){

View File

@ -119,14 +119,6 @@ void ShadowScapesAnalysis::synthesise()
//there is a known issue with using loadImage inside classes in other directories. the fix is to call setUseTExture(false)
image1.setUseTexture(false);
image2.setUseTexture(false);
string fnamei = _saved_filenames[i];
string fnameii = _saved_filenames[i + 1];
bool l1 = image1.loadImage(_saved_filenames[i]);
bool l2 = image2.loadImage(_saved_filenames[i+1]);
//some of the textures are not loading correctly so only make mesh if both the images load
if(image1.loadImage(_saved_filenames[i]) && image2.loadImage(_saved_filenames[i+1])){
meshes.push_back(ofMesh());
@ -134,9 +126,6 @@ void ShadowScapesAnalysis::synthesise()
setMeshFromPixels( calculateListOfZValues(image1,image2, COMPARE_BRIGHTNESS), image2, &meshes[index]);
index++;
}
image1.clear();
image2.clear();
}
}
@ -234,21 +223,21 @@ void ShadowScapesAnalysis::draw()
if(_dir == V && int(_line) >= (ofGetHeight()+4*_scanLineWidth)){
cout << "VERTICAL IS DONE - _line >= (ofGetHeight()+4*_scanLineWidth) is TRUE" << endl;
//_state = STATE_SYNTHESISING;
_state = STATE_SYNTHESISING;
_RUN_DONE = true;
}
if(_dir == H && int(_line) >= (ofGetWidth()+4*_scanLineWidth)) {
//cout << "HORIZONTAL IS DONE - _line >= (ofGetWidth()+4*_scanLineWidth)) is TRUE" << endl;
//_state = STATE_SYNTHESISING;
_state = STATE_SYNTHESISING;
_RUN_DONE = true;
}
if(_dir == D && int(_line) >= (1.5*ofGetHeight()+4*_scanLineWidth)) {
//cout << "DIAGONAL IS DONE - _line >= (1.5*ofGetHeight()+4*_scanLineWidth)) is TRUE" << endl;
//_state = STATE_SYNTHESISING;
_state = STATE_SYNTHESISING;
_RUN_DONE = true;
}
@ -299,14 +288,6 @@ void ShadowScapesAnalysis::draw()
void ShadowScapesAnalysis::save_cb(Timer& timer)
{
RefractiveIndex::_vidGrabber.grabFrame(); // get a new frame from the camera
if (RefractiveIndex::_vidGrabber.isFrameNew())
{
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
}
cout << "ShadowScapesAnalysis::saving...\n";
string file_name;
@ -321,9 +302,9 @@ void ShadowScapesAnalysis::save_cb(Timer& timer)
if(_dir == D) {
file_name = ofToString(_save_cnt, 2)+"_D_"+ofToString(_line, 2)+"_"+ofToString(_run_cnt,2)+".jpg";
}
saveimage(file_name);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_save_cnt++;
}

View File

@ -149,7 +149,7 @@ void ShapeFromShadingAnalysis::draw()
switch (_state) {
case STATE_ACQUIRING:
{
if (_frame_cnt < _frame_cnt_max)
if (_frame_cnt <= _frame_cnt_max)
{
ofEnableAlphaBlending();
@ -419,14 +419,14 @@ void ShapeFromShadingAnalysis::save_cb(Timer& timer)
{
//cout << "ShapeFromShadingAnalysis::saving...\n";
string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
string file_name = ofToString(_save_cnt,2)+"_"+ quad +"_"+ofToString(_run_cnt,2)+".jpg";
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_save_cnt++;
//if(_save_cnt >= NUM_SAVE_PER_RUN)
// _RUN_DONE = true;
if(_save_cnt >= NUM_SAVE_PER_RUN)
_RUN_DONE = true;
}
void ShapeFromShadingAnalysis::display_results_cb(Timer& timer){

View File

@ -133,58 +133,51 @@ void StrobeAnalysis::draw()
switch (_state) {
case STATE_ACQUIRING:
{
ofEnableAlphaBlending();
ofColor aColour;
int _fade_in_frames = _frame_cnt_max/10;
cout<< "_fade_in_frames" << _fade_in_frames<< endl;
if (_frame_cnt < _frame_cnt_max)
{
ofEnableAlphaBlending();
ofColor aColour;
int _fade_in_frames = _frame_cnt_max/10;
cout<< "_fade_in_frames" << _fade_in_frames<< endl;
if (_frame_cnt < _fade_in_frames) {
if (_frame_cnt < _fade_in_frames) {
aColour.set(255, 255, 255, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
//cout << "FADE IN STROBE TIME " << endl;
}
aColour.set(255, 255, 255, ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
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)){
//cout << "_frame_cnt: " << _frame_cnt << endl;
//cout << "frame_cnt % 15: " << _frame_cnt%15 << endl;
//cout << "MAIN STROBE TIME " << endl;
if (_frame_cnt%int(ofGetFrameRate()*_strobe_interval/1000) < (ofGetFrameRate()*_strobe_interval/1000)/2)
{
ofSetColor(255, 255, 255);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_strobe_cnt++;
_strobe_on = 1;
} else if (_frame_cnt%int(ofGetFrameRate()*_strobe_interval/1000) >= (ofGetFrameRate()*_strobe_interval/1000)/2)
{
ofSetColor(0, 0, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_strobe_on = 0;
}
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
aColour.set(255, 255, 255, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
// cout << "FADE OUT STROBE TIME " << endl;
}
ofDisableAlphaBlending();
} else {
_RUN_DONE = true;
}
if (_frame_cnt >= _fade_in_frames && _frame_cnt < (_frame_cnt_max-_fade_in_frames)){
//cout << "_frame_cnt: " << _frame_cnt << endl;
//cout << "frame_cnt % 15: " << _frame_cnt%15 << endl;
//cout << "MAIN STROBE TIME " << endl;
if (_frame_cnt%int(ofGetFrameRate()*_strobe_interval/1000) < (ofGetFrameRate()*_strobe_interval/1000)/2)
{
ofSetColor(255, 255, 255);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_strobe_cnt++;
_strobe_on = 1;
} else if (_frame_cnt%int(ofGetFrameRate()*_strobe_interval/1000) >= (ofGetFrameRate()*_strobe_interval/1000)/2)
{
ofSetColor(0, 0, 0);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
_strobe_on = 0;
}
}
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max) {
aColour.set(255, 255, 255, 255-ofMap(_frame_cnt, 0, _fade_in_frames, 0, 255));
ofSetColor(aColour);
ofRect(0, 0, ofGetWidth(), ofGetHeight());
// cout << "FADE OUT STROBE TIME " << endl;
}
_frame_cnt++;
ofDisableAlphaBlending();
break;
}
@ -232,8 +225,9 @@ void StrobeAnalysis::draw()
void StrobeAnalysis::save_cb(Timer& timer)
{
string file_name = ofToString(_save_cnt,2)+"_"+ ofToString(_strobe_on) +"_"+ofToString(_run_cnt,2)+".jpg";
saveimage(file_name);
_saved_filenames.push_back(ofToDataPath("")+_whole_file_path+"/"+file_name);
ofSaveImage(RefractiveIndex::_pixels, _whole_file_path+"/"+file_name, OF_IMAGE_QUALITY_BEST);
_save_cnt++;
cout << "_save_cnt" << _save_cnt << endl;
@ -241,9 +235,9 @@ void StrobeAnalysis::save_cb(Timer& timer)
cout << "_save_cnt_max" << _save_cnt_max << endl;
//TODO: something fucked here with my calc of _save_cnt_max - new structure should fix it?
//if(_save_cnt >= _save_cnt_max-10) {
// _RUN_DONE = true;
//}
if(_save_cnt >= _save_cnt_max-10) {
_RUN_DONE = true;
}
}