Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ab6c3d5be5 |
@@ -1,7 +1,6 @@
|
|||||||
<!-- THIS FILE NEEDS TO GO IN THE APPLICATION /data/ folder -->
|
<!-- THIS FILE NEEDS TO GO IN THE APPLICATION /data/ folder -->
|
||||||
|
|
||||||
<config>
|
<config>
|
||||||
<mode>drawing</mode>
|
|
||||||
<camera>
|
<camera>
|
||||||
<id>1</id>
|
<id>1</id>
|
||||||
<width>640</width>
|
<width>640</width>
|
||||||
|
|||||||
@@ -27,10 +27,8 @@
|
|||||||
#define ISTATE_TRANSITION 0xCCCC
|
#define ISTATE_TRANSITION 0xCCCC
|
||||||
#define ISTATE_END 0xDDDD
|
#define ISTATE_END 0xDDDD
|
||||||
|
|
||||||
|
|
||||||
int _state = ISTATE_UNDEF;
|
int _state = ISTATE_UNDEF;
|
||||||
|
|
||||||
int RefractiveIndex::_mode;
|
|
||||||
ofPixels RefractiveIndex::_pixels;
|
ofPixels RefractiveIndex::_pixels;
|
||||||
ofVideoGrabber RefractiveIndex::_vidGrabber;
|
ofVideoGrabber RefractiveIndex::_vidGrabber;
|
||||||
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
|
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
|
||||||
@@ -51,10 +49,6 @@ void RefractiveIndex::setup()
|
|||||||
} else {
|
} else {
|
||||||
XML.loadFile("config.refindx");
|
XML.loadFile("config.refindx");
|
||||||
}
|
}
|
||||||
|
|
||||||
// <mode>
|
|
||||||
string m = XML.getValue("config:mode", "analysing");
|
|
||||||
_mode = (m == "analysing" ? MODE_ANALYSING : (m == "drawing" ? MODE_DRAWING : MODE_ANALYSING));
|
|
||||||
|
|
||||||
// <camera>
|
// <camera>
|
||||||
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
|
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
|
||||||
@@ -88,10 +82,8 @@ void RefractiveIndex::setup()
|
|||||||
cout << "* cam width = " << _vid_w << endl;
|
cout << "* cam width = " << _vid_w << endl;
|
||||||
cout << "* cam height = " << _vid_h << endl;
|
cout << "* cam height = " << _vid_h << endl;
|
||||||
|
|
||||||
if(_mode == MODE_ANALYSING) {
|
_vid_stream_open = false;
|
||||||
_vid_stream_open = false;
|
setup_camera();
|
||||||
setup_camera();
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "RRRRRREADY!" << endl;
|
cout << "RRRRRREADY!" << endl;
|
||||||
|
|
||||||
@@ -181,14 +173,10 @@ void RefractiveIndex::state_analysis()
|
|||||||
break;
|
break;
|
||||||
case ISTATE_STOP:
|
case ISTATE_STOP:
|
||||||
stop_analysis(); // blocking
|
stop_analysis(); // blocking
|
||||||
if(_mode == MODE_DRAWING)
|
_state = ISTATE_TRANSITION;
|
||||||
_state = ISTATE_UNDEF;
|
|
||||||
else
|
|
||||||
_state = ISTATE_TRANSITION;
|
|
||||||
break;
|
break;
|
||||||
case ISTATE_END:
|
case ISTATE_END:
|
||||||
if(_mode == MODE_ANALYSING)
|
stop_camera();
|
||||||
stop_camera();
|
|
||||||
::exit(1);
|
::exit(1);
|
||||||
break;
|
break;
|
||||||
case ISTATE_UNDEF:
|
case ISTATE_UNDEF:
|
||||||
|
|||||||
@@ -11,9 +11,6 @@
|
|||||||
#include "ofxOpenCv.h"
|
#include "ofxOpenCv.h"
|
||||||
#include "ofxXmlSettings.h"
|
#include "ofxXmlSettings.h"
|
||||||
|
|
||||||
#define MODE_DRAWING 0xEEFF
|
|
||||||
#define MODE_ANALYSING 0xFFEE
|
|
||||||
|
|
||||||
class RefractiveIndex : public ofBaseApp
|
class RefractiveIndex : public ofBaseApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -58,8 +55,6 @@ public:
|
|||||||
// acquisition
|
// acquisition
|
||||||
static ofPixels _pixels;
|
static ofPixels _pixels;
|
||||||
static ofVideoGrabber _vidGrabber;
|
static ofVideoGrabber _vidGrabber;
|
||||||
static int _mode;
|
|
||||||
|
|
||||||
vector<string> videoSourceList;
|
vector<string> videoSourceList;
|
||||||
static int _vid_w, _vid_h, _vid_id;
|
static int _vid_w, _vid_h, _vid_id;
|
||||||
static bool _vid_stream_open;
|
static bool _vid_stream_open;
|
||||||
|
|||||||
+22
-110
@@ -3,72 +3,36 @@
|
|||||||
#include "AbstractAnalysis.h"
|
#include "AbstractAnalysis.h"
|
||||||
#include "RefractiveIndex.h"
|
#include "RefractiveIndex.h"
|
||||||
#include "ofxFileHelper.h"
|
#include "ofxFileHelper.h"
|
||||||
#include "ofSystemUtils.h"
|
|
||||||
|
|
||||||
void AbstractAnalysis::setup(int camWidth, int camHeight) {
|
|
||||||
|
|
||||||
_cam_w = camWidth; _cam_h = camHeight;
|
|
||||||
|
|
||||||
if(RefractiveIndex::_mode == MODE_DRAWING) {
|
|
||||||
ofFileDialogResult r = ofSystemLoadDialog("choooose da folda", true);
|
|
||||||
if(!r.bSuccess) {
|
|
||||||
ofSystemAlertDialog("OOOOPS.... ERROR...");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_whole_file_path_analysis = r.filePath;
|
|
||||||
_whole_file_path_synthesis = r.filePath + "/darwings";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is the main threaded loop for a given analysis
|
// this is the main threaded loop for a given analysis
|
||||||
void AbstractAnalysis::do_synthesize() {
|
void AbstractAnalysis::do_synthesize() {
|
||||||
|
|
||||||
switch(RefractiveIndex::_mode)
|
for(int i = 0; i < NUM_RUN; i++) {
|
||||||
{
|
|
||||||
case MODE_ANALYSING:
|
cout << "NUM_RUN: " << i << endl;
|
||||||
{
|
|
||||||
for(int i = 0; i < NUM_RUN; i++) {
|
|
||||||
|
|
||||||
cout << "NUM_RUN: " << i << endl;
|
_saved_filenames_analysis.clear();
|
||||||
|
_saved_filenames_synthesis.clear();
|
||||||
_saved_filenames_analysis.clear();
|
|
||||||
_saved_filenames_synthesis.clear();
|
if(_state == STATE_STOP) goto exit;
|
||||||
|
_state = STATE_ALLOCATE;
|
||||||
_state = STATE_ACQUIRING;
|
allocate();
|
||||||
acquire();
|
if(_state == STATE_STOP) goto exit;
|
||||||
if(_state == STATE_STOP) goto exit;
|
_state = STATE_ACQUIRING;
|
||||||
_state = STATE_SYNTHESISING;
|
acquire();
|
||||||
synthesise();
|
if(_state == STATE_STOP) goto exit;
|
||||||
if(_state == STATE_STOP) goto exit;
|
_state = STATE_SYNTHESISING;
|
||||||
_state = STATE_DISPLAY_RESULTS;
|
synthesise();
|
||||||
displayresults();
|
if(_state == STATE_STOP) goto exit;
|
||||||
cleanup();
|
_state = STATE_DISPLAY_RESULTS;
|
||||||
}
|
displayresults();
|
||||||
}
|
_state = STATE_CLEANUP;
|
||||||
|
cleanup();
|
||||||
case MODE_DRAWING:
|
|
||||||
{
|
|
||||||
ofxFileHelper fileHelperDrawing;
|
|
||||||
if(!fileHelperDrawing.doesDirectoryExist(_whole_file_path_synthesis)){
|
|
||||||
fileHelperDrawing.makeDirectory(_whole_file_path_synthesis);
|
|
||||||
}
|
|
||||||
|
|
||||||
read_dir_create_list(_whole_file_path_analysis);
|
|
||||||
_state = STATE_SYNTHESISING;
|
|
||||||
synthesise();
|
|
||||||
if(_state == STATE_STOP) goto exit;
|
|
||||||
_state = STATE_DISPLAY_RESULTS;
|
|
||||||
displayresults();
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
cleanup();
|
cleanup();
|
||||||
ofNotifyEvent(_synthesize_cb, _name);
|
ofNotifyEvent(_synthesize_cb, _name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnalysis::create_dir_allocate_images()
|
void AbstractAnalysis::create_dir_allocate_images()
|
||||||
@@ -157,57 +121,6 @@ void AbstractAnalysis::create_dir_allocate_images()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cmp_file(string f0, string f1)
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
int v0 = atoi(f0.substr(0, f0.find("_")).c_str());
|
|
||||||
|
|
||||||
int v1 = atoi(f1.substr(0, f1.find("_")).c_str());
|
|
||||||
|
|
||||||
return v0 < v1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AbstractAnalysis::read_dir_create_list(string folder_path)
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
File dir(folder_path);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(dir.exists() && dir.isDirectory()) {
|
|
||||||
|
|
||||||
vector<string> list;
|
|
||||||
|
|
||||||
dir.list(list);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::sort(list.begin(), list.end(), cmp_file);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < list.size(); i++) {
|
|
||||||
|
|
||||||
string filepath = folder_path + "/" + list[i];
|
|
||||||
|
|
||||||
_saved_filenames_analysis.push_back(filepath);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AbstractAnalysis::saveImageAnalysis(string filename)
|
void AbstractAnalysis::saveImageAnalysis(string filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -272,7 +185,6 @@ void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename);
|
_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,13 @@
|
|||||||
#define ANALYSIS_PATH "analysis/"
|
#define ANALYSIS_PATH "analysis/"
|
||||||
#define SYNTHESIS_PATH "synthesis/"
|
#define SYNTHESIS_PATH "synthesis/"
|
||||||
|
|
||||||
|
#define STATE_ALLOCATE 0x0010
|
||||||
|
#define STATE_CLEANUP 0x0001
|
||||||
#define STATE_ACQUIRING 0x1111
|
#define STATE_ACQUIRING 0x1111
|
||||||
#define STATE_SYNTHESISING 0x2222
|
#define STATE_SYNTHESISING 0x2222
|
||||||
#define STATE_DISPLAY_RESULTS 0x3333
|
#define STATE_DISPLAY_RESULTS 0x3333
|
||||||
#define STATE_STOP 0xDEADBEEF
|
#define STATE_STOP 0xDEADBEEF
|
||||||
|
#define STATE_DEF 0x0000
|
||||||
|
|
||||||
class AbstractAnalysis {
|
class AbstractAnalysis {
|
||||||
|
|
||||||
@@ -25,7 +28,7 @@ public:
|
|||||||
virtual ~AbstractAnalysis(){;}
|
virtual ~AbstractAnalysis(){;}
|
||||||
|
|
||||||
// generic function to set up the camera
|
// generic function to set up the camera
|
||||||
virtual void setup(int camWidth, int camHeight);
|
virtual void setup(int camWidth, int camHeight){_cam_w = camWidth; _cam_h = camHeight;}
|
||||||
|
|
||||||
// this is the main threaded loop for a given analysis
|
// this is the main threaded loop for a given analysis
|
||||||
void do_synthesize();
|
void do_synthesize();
|
||||||
@@ -37,8 +40,6 @@ protected:
|
|||||||
|
|
||||||
virtual void create_dir_allocate_images();
|
virtual void create_dir_allocate_images();
|
||||||
|
|
||||||
virtual void read_dir_create_list(string folder_path);
|
|
||||||
|
|
||||||
virtual void saveImageAnalysis(string filename);
|
virtual void saveImageAnalysis(string filename);
|
||||||
virtual void saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType);
|
virtual void saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType);
|
||||||
|
|
||||||
@@ -50,14 +51,16 @@ protected:
|
|||||||
|
|
||||||
// display the results from disk
|
// display the results from disk
|
||||||
virtual void displayresults() = 0;
|
virtual void displayresults() = 0;
|
||||||
|
|
||||||
|
// allocate all images
|
||||||
|
virtual void allocate() {;}
|
||||||
|
|
||||||
// display the results from disk
|
// deallocate all images
|
||||||
virtual void cleanup() {;}
|
virtual void cleanup() {;}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string _name;
|
string _name;
|
||||||
string _draw_directory;
|
|
||||||
|
|
||||||
// event
|
// event
|
||||||
ofEvent<string> _synthesize_cb;
|
ofEvent<string> _synthesize_cb;
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void CamNoiseAnalysis::setup(int camWidth, int camHeight)
|
void CamNoiseAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_camnoise", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_camnoise", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN CamNoiseAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN CamNoiseAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
@@ -153,17 +151,17 @@ void CamNoiseAnalysis::synthesise()
|
|||||||
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
|
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
|
||||||
|
|
||||||
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
|
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
|
||||||
// cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
|
// cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
|
||||||
//added by tom we weren't actually setting cvgrayimage1 anywhere
|
//added by tom we weren't actually setting cvgrayimage1 anywhere
|
||||||
// cvGrayImage1.setFromPixels(cvColorImage1.getPixels(),cvColorImage1.width,cvColorImage1.height);
|
// cvGrayImage1.setFromPixels(cvColorImage1.getPixels(),cvColorImage1.width,cvColorImage1.height);
|
||||||
//cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
|
//cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
|
||||||
//cvGrayImage1=cvColorImage1;
|
//cvGrayImage1=cvColorImage1;
|
||||||
|
|
||||||
cvGrayImage1.erode();
|
cvGrayImage1.erode();
|
||||||
cvGrayImage1.erode();
|
cvGrayImage1.erode();
|
||||||
cvGrayImage1.erode();
|
cvGrayImage1.erode();
|
||||||
cvGrayImage1.blur();
|
cvGrayImage1.blur();
|
||||||
cvGrayImage1.contrastStretch();
|
cvGrayImage1.contrastStretch();
|
||||||
/* cvColorImage1.erode();
|
/* cvColorImage1.erode();
|
||||||
cvColorImage1.erode();
|
cvColorImage1.erode();
|
||||||
cvColorImage1.erode();
|
cvColorImage1.erode();
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
void ColorMultiAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_colormulti", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_colormulti", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN ColorMultiAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN ColorMultiAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
|
|||||||
+62
-64
@@ -15,8 +15,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_colorsingle", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_colorsingle", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN ColorSingleAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN ColorSingleAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
@@ -24,11 +22,11 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
|||||||
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);
|
||||||
cout << "ACQUIRE_TIME ColorSingleAnalysis " << acq_run_time << endl;
|
cout << "ACQUIRE_TIME ColorSingleAnalysis " << acq_run_time << endl;
|
||||||
|
|
||||||
//int acq_run_time = 25; // 20 seconds of acquiring per run
|
//int acq_run_time = 25; // 20 seconds of acquiring per run
|
||||||
|
|
||||||
DELTA_T_SAVE = 1*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files
|
DELTA_T_SAVE = 1*(10*acq_run_time/2); // for 20 seconds, we want this to be around 200 files
|
||||||
// or 10 times per second = every 100 ms
|
// or 10 times per second = every 100 ms
|
||||||
|
|
||||||
_frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames
|
_frame_cnt_max = acq_run_time*ofGetFrameRate(); // e.g.: 30 frames per second * 20 seconds = 600 frames
|
||||||
|
|
||||||
@@ -47,7 +45,7 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
|||||||
b = 0;
|
b = 0;
|
||||||
|
|
||||||
fileNameTag = "";
|
fileNameTag = "";
|
||||||
|
|
||||||
_show_image = false;
|
_show_image = false;
|
||||||
_image_shown = false;
|
_image_shown = false;
|
||||||
|
|
||||||
@@ -103,9 +101,9 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
|
|||||||
|
|
||||||
void ColorSingleAnalysis::acquire()
|
void ColorSingleAnalysis::acquire()
|
||||||
{
|
{
|
||||||
|
|
||||||
Timer* save_timer;
|
Timer* save_timer;
|
||||||
|
|
||||||
TimerCallback<ColorSingleAnalysis> save_callback(*this, &ColorSingleAnalysis::save_cb);
|
TimerCallback<ColorSingleAnalysis> save_callback(*this, &ColorSingleAnalysis::save_cb);
|
||||||
|
|
||||||
_run_cnt++;
|
_run_cnt++;
|
||||||
@@ -115,18 +113,18 @@ void ColorSingleAnalysis::acquire()
|
|||||||
|
|
||||||
// RUN ROUTINE
|
// RUN ROUTINE
|
||||||
//for(int i = 0; i < NUM_RUN; i++) {
|
//for(int i = 0; i < NUM_RUN; i++) {
|
||||||
// _run_cnt = i;
|
// _run_cnt = i;
|
||||||
//cout << "RUN NUM = " << i;
|
//cout << "RUN NUM = " << i;
|
||||||
|
|
||||||
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
|
save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files
|
||||||
save_timer->start(save_callback);
|
save_timer->start(save_callback);
|
||||||
|
|
||||||
while(!_RUN_DONE && _state != STATE_STOP)
|
while(!_RUN_DONE && _state != STATE_STOP)
|
||||||
Thread::sleep(3);
|
Thread::sleep(3);
|
||||||
|
|
||||||
save_timer->stop();
|
save_timer->stop();
|
||||||
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,50 +150,50 @@ void ColorSingleAnalysis::synthesise()
|
|||||||
if(image1.loadImage(_saved_filenames_analysis[i])){
|
if(image1.loadImage(_saved_filenames_analysis[i])){
|
||||||
//cout << "LOADED image1!!!" << endl;
|
//cout << "LOADED image1!!!" << endl;
|
||||||
//if(image5.loadImage(_saved_filenames_analysis[i+1])){
|
//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.erode();
|
||||||
|
cvColorImage1.erode();
|
||||||
|
cvColorImage1.erode();
|
||||||
|
cvColorImage1.erode();
|
||||||
|
|
||||||
///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
|
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
|
||||||
|
string file_name;
|
||||||
|
|
||||||
|
file_name = ofToString(_synth_save_cnt, 2)+"_ColorSingleAnalysis_"+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);
|
||||||
|
|
||||||
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
|
//_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+file_name);
|
||||||
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
|
|
||||||
|
// <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
|
||||||
|
|
||||||
cvColorImage1.blur(5);
|
saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
|
||||||
cvColorImage1.erode();
|
_synth_save_cnt++;
|
||||||
cvColorImage1.erode();
|
|
||||||
cvColorImage1.dilate();
|
|
||||||
cvColorImage1.blur(5);
|
|
||||||
cvColorImage1.erode();
|
|
||||||
cvColorImage1.erode();
|
|
||||||
cvColorImage1.erode();
|
|
||||||
cvColorImage1.erode();
|
|
||||||
|
|
||||||
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
|
// }
|
||||||
string file_name;
|
|
||||||
|
|
||||||
file_name = ofToString(_synth_save_cnt, 2)+"_ColorSingleAnalysis_"+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++;
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +242,7 @@ void ColorSingleAnalysis::draw()
|
|||||||
|
|
||||||
if (_frame_cnt < _frame_cnt_max)
|
if (_frame_cnt < _frame_cnt_max)
|
||||||
{
|
{
|
||||||
|
|
||||||
float one_third_of_frame_count_max=_frame_cnt_max/3;
|
float one_third_of_frame_count_max=_frame_cnt_max/3;
|
||||||
int _fade_in_frames = one_third_of_frame_count_max/10;
|
int _fade_in_frames = one_third_of_frame_count_max/10;
|
||||||
|
|
||||||
@@ -282,15 +280,15 @@ void ColorSingleAnalysis::draw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max){
|
if (_frame_cnt >= (_frame_cnt_max-_fade_in_frames) && _frame_cnt < _frame_cnt_max){
|
||||||
|
|
||||||
int fade = ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255);
|
int fade = ofMap(_fade_cnt, 0, _fade_in_frames, 0, 255);
|
||||||
ofSetColor(0, 0, 255-fade);
|
ofSetColor(0, 0, 255-fade);
|
||||||
|
|
||||||
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
ofRect(0, 0, ofGetWidth(), ofGetHeight());
|
||||||
_fade_cnt++;
|
_fade_cnt++;
|
||||||
fileNameTag = "FADING";
|
fileNameTag = "FADING";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//_state = STATE_SYNTHESISING;
|
//_state = STATE_SYNTHESISING;
|
||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
@@ -326,7 +324,7 @@ void ColorSingleAnalysis::draw()
|
|||||||
//ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360));
|
//ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360));
|
||||||
|
|
||||||
if (_anim_cnt < _fade_in_frames) {
|
if (_anim_cnt < _fade_in_frames) {
|
||||||
// cout << "ColorSingleAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n";
|
// cout << "ColorSingleAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n";
|
||||||
|
|
||||||
fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255);
|
fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255);
|
||||||
|
|
||||||
@@ -414,8 +412,8 @@ void ColorSingleAnalysis::draw()
|
|||||||
// display results of the synthesis
|
// display results of the synthesis
|
||||||
_RUN_DONE = true;
|
_RUN_DONE = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -432,4 +430,4 @@ void ColorSingleAnalysis::save_cb(Timer& timer)
|
|||||||
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
|
string file_name =ofToString(_save_cnt,2)+"_"+fileNameTag+"_"+ofToString(_run_cnt,2)+".jpg";
|
||||||
|
|
||||||
saveImageAnalysis(file_name);
|
saveImageAnalysis(file_name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,5 @@ protected:
|
|||||||
//this is the temporary container to allow us to convert and save out greyscale images
|
//this is the temporary container to allow us to convert and save out greyscale images
|
||||||
ofxCvColorImage cvConvertorImage;
|
ofxCvColorImage cvConvertorImage;
|
||||||
|
|
||||||
unsigned char * imagePixels;
|
|
||||||
int vectorCount;
|
|
||||||
ofVec2f * vectorField;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
|
void DiffNoiseAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_diffnoise", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_diffnoise", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN DiffNoiseAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN DiffNoiseAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void IResponseAnalysis::setup(int camWidth, int camHeight)
|
void IResponseAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_iresponse", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_iresponse", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN IResponseAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN IResponseAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_relaxrate", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_relaxrate", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN RelaxRateAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN RelaxRateAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_shadowscapes", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_shadowscapes", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN ShadowScapesAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN ShadowScapesAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
@@ -53,6 +51,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
|||||||
_show_image = false;
|
_show_image = false;
|
||||||
_image_shown = false;
|
_image_shown = false;
|
||||||
|
|
||||||
|
/*
|
||||||
image1.clear();
|
image1.clear();
|
||||||
image2.clear();
|
image2.clear();
|
||||||
image3.clear();
|
image3.clear();
|
||||||
@@ -99,6 +98,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
|
|||||||
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
cvGrayDiff2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||||
|
|
||||||
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
cvConvertorImage.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h);
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,24 +226,116 @@ void ShadowScapesAnalysis::displayresults()
|
|||||||
if(!image3.loadImage(_saved_filenames_synthesis[i])){
|
if(!image3.loadImage(_saved_filenames_synthesis[i])){
|
||||||
//couldn't load image
|
//couldn't load image
|
||||||
cout << "didn't load image" << endl;
|
cout << "didn't load image" << endl;
|
||||||
}
|
} else {
|
||||||
|
_show_image = true;
|
||||||
|
_image_shown = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
if(image3.loadImage(_saved_filenames_synthesis[i])){
|
if(image3.loadImage(_saved_filenames_synthesis[i])){
|
||||||
image3.loadImage(_saved_filenames_synthesis[i]);
|
//image3.loadImage(_saved_filenames_synthesis[i]);
|
||||||
//cout << "_show_image = true;" << endl;
|
//cout << "_show_image = true;" << endl;
|
||||||
_show_image = true;
|
_show_image = true;
|
||||||
_image_shown = false;
|
_image_shown = false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShadowScapesAnalysis::allocate()
|
||||||
|
{
|
||||||
|
_RUN_DONE = false;
|
||||||
|
|
||||||
|
image1.clear();
|
||||||
|
image3.clear();
|
||||||
|
image4.clear();
|
||||||
|
image5.clear();
|
||||||
|
|
||||||
|
image1.setUseTexture(false);
|
||||||
|
image3.setUseTexture(false);
|
||||||
|
image4.setUseTexture(false);
|
||||||
|
image5.setUseTexture(false);
|
||||||
|
|
||||||
|
image1.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);
|
||||||
|
|
||||||
|
|
||||||
|
while(!_RUN_DONE && _state != STATE_STOP)
|
||||||
|
Thread::sleep(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShadowScapesAnalysis::cleanup()
|
||||||
|
{
|
||||||
|
_RUN_DONE = false;
|
||||||
|
|
||||||
|
image1.clear();
|
||||||
|
image3.clear();
|
||||||
|
image4.clear();
|
||||||
|
image5.clear();
|
||||||
|
|
||||||
|
while(!_RUN_DONE && _state != STATE_STOP)
|
||||||
|
Thread::sleep(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// the animation draw - and the output draw
|
// the animation draw - and the output draw
|
||||||
void ShadowScapesAnalysis::draw()
|
void ShadowScapesAnalysis::draw()
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (_state) {
|
switch (_state) {
|
||||||
|
case STATE_ALLOCATE:
|
||||||
|
{
|
||||||
|
image2.clear();
|
||||||
|
image2.setUseTexture(true);
|
||||||
|
image2.allocate(RefractiveIndex::_vid_w,RefractiveIndex::_vid_h, OF_IMAGE_COLOR);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
_state = STATE_DEF;
|
||||||
|
|
||||||
|
_RUN_DONE = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_CLEANUP:
|
||||||
|
{
|
||||||
|
image2.clear();
|
||||||
|
|
||||||
|
cvColorImage1.clear();
|
||||||
|
cvGrayImage1.clear();
|
||||||
|
cvGrayDiff1.clear();
|
||||||
|
|
||||||
|
cvColorImage2.clear();
|
||||||
|
cvGrayImage2.clear();
|
||||||
|
cvGrayDiff2.clear();
|
||||||
|
|
||||||
|
_state = STATE_DEF;
|
||||||
|
|
||||||
|
_RUN_DONE = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case STATE_ACQUIRING:
|
case STATE_ACQUIRING:
|
||||||
{
|
{
|
||||||
_line += _step;
|
_line += _step;
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ public:
|
|||||||
void acquire();
|
void acquire();
|
||||||
void synthesise();
|
void synthesise();
|
||||||
void displayresults();
|
void displayresults();
|
||||||
|
|
||||||
|
void allocate();
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
|
void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_shapefromshading", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_shapefromshading", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN ShapeFromShadingAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN ShapeFromShadingAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ using Poco::Thread;
|
|||||||
|
|
||||||
void StrobeAnalysis::setup(int camWidth, int camHeight)
|
void StrobeAnalysis::setup(int camWidth, int camHeight)
|
||||||
{
|
{
|
||||||
AbstractAnalysis::setup(camWidth, camHeight);
|
|
||||||
|
|
||||||
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_strobe", NUMBER_RUNS);
|
NUM_RUN = RefractiveIndex::XML.getValue("config:analysis_NUM_RUN:NUM_RUN_strobe", NUMBER_RUNS);
|
||||||
cout << "NUM_RUN StrobeAnalysis " << NUM_RUN << endl;
|
cout << "NUM_RUN StrobeAnalysis " << NUM_RUN << endl;
|
||||||
//NUM_RUN = 5;
|
//NUM_RUN = 5;
|
||||||
|
|||||||
Reference in New Issue
Block a user