mode <drawing, analysing> + drawing mode file chooser
make sure you add the config.refindx to your environment
This commit is contained in:
parent
daec77d2be
commit
7d7ec3606e
@ -1,6 +1,7 @@
|
|||||||
<!-- 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,8 +27,10 @@
|
|||||||
#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;
|
||||||
@ -50,6 +52,10 @@ void RefractiveIndex::setup()
|
|||||||
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);
|
||||||
cout << "_vid_id: " << _vid_id << endl;
|
cout << "_vid_id: " << _vid_id << endl;
|
||||||
@ -82,8 +88,10 @@ 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;
|
||||||
|
|
||||||
@ -173,9 +181,13 @@ void RefractiveIndex::state_analysis()
|
|||||||
break;
|
break;
|
||||||
case ISTATE_STOP:
|
case ISTATE_STOP:
|
||||||
stop_analysis(); // blocking
|
stop_analysis(); // blocking
|
||||||
|
if(_mode == MODE_DRAWING)
|
||||||
|
_state = ISTATE_UNDEF;
|
||||||
|
else
|
||||||
_state = ISTATE_TRANSITION;
|
_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;
|
||||||
|
|||||||
@ -11,6 +11,9 @@
|
|||||||
#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:
|
||||||
@ -55,6 +58,8 @@ 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;
|
||||||
|
|||||||
@ -3,10 +3,32 @@
|
|||||||
#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)
|
||||||
|
{
|
||||||
|
case MODE_ANALYSING:
|
||||||
|
{
|
||||||
for(int i = 0; i < NUM_RUN; i++) {
|
for(int i = 0; i < NUM_RUN; i++) {
|
||||||
|
|
||||||
cout << "NUM_RUN: " << i << endl;
|
cout << "NUM_RUN: " << i << endl;
|
||||||
@ -24,10 +46,29 @@ void AbstractAnalysis::do_synthesize() {
|
|||||||
displayresults();
|
displayresults();
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
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:
|
||||||
cleanup();
|
cleanup();
|
||||||
ofNotifyEvent(_synthesize_cb, _name);
|
ofNotifyEvent(_synthesize_cb, _name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractAnalysis::create_dir_allocate_images()
|
void AbstractAnalysis::create_dir_allocate_images()
|
||||||
@ -116,6 +157,20 @@ void AbstractAnalysis::create_dir_allocate_images()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractAnalysis::read_dir_create_list(string folder_path)
|
||||||
|
{
|
||||||
|
File dir(folder_path);
|
||||||
|
|
||||||
|
if(dir.exists() && dir.isDirectory()) {
|
||||||
|
vector<string> list;
|
||||||
|
dir.list(list);
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -181,5 +236,6 @@ void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels
|
|||||||
|
|
||||||
_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename);
|
_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,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){_cam_w = camWidth; _cam_h = camHeight;}
|
virtual void setup(int camWidth, int 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,6 +37,8 @@ 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);
|
||||||
|
|
||||||
@ -55,6 +57,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
string _name;
|
string _name;
|
||||||
|
string _draw_directory;
|
||||||
|
|
||||||
// event
|
// event
|
||||||
ofEvent<string> _synthesize_cb;
|
ofEvent<string> _synthesize_cb;
|
||||||
|
|||||||
@ -15,6 +15,8 @@ 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;
|
||||||
|
|||||||
@ -14,6 +14,8 @@ 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;
|
||||||
|
|||||||
@ -15,6 +15,8 @@ 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;
|
||||||
|
|||||||
@ -15,6 +15,8 @@ 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,6 +15,8 @@ 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,6 +17,8 @@ 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,6 +19,8 @@ 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;
|
||||||
|
|||||||
@ -15,6 +15,8 @@ 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,6 +15,8 @@ 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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user