mode <drawing, analysing> + drawing mode file chooser
make sure you add the config.refindx to your environment
This commit is contained in:
+73
-17
@@ -3,31 +3,72 @@
|
||||
#include "AbstractAnalysis.h"
|
||||
#include "RefractiveIndex.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
|
||||
void AbstractAnalysis::do_synthesize() {
|
||||
|
||||
for(int i = 0; i < NUM_RUN; i++) {
|
||||
|
||||
cout << "NUM_RUN: " << i << endl;
|
||||
switch(RefractiveIndex::_mode)
|
||||
{
|
||||
case MODE_ANALYSING:
|
||||
{
|
||||
for(int i = 0; i < NUM_RUN; i++) {
|
||||
|
||||
_saved_filenames_analysis.clear();
|
||||
_saved_filenames_synthesis.clear();
|
||||
|
||||
_state = STATE_ACQUIRING;
|
||||
acquire();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_SYNTHESISING;
|
||||
synthesise();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
displayresults();
|
||||
cleanup();
|
||||
cout << "NUM_RUN: " << i << endl;
|
||||
|
||||
_saved_filenames_analysis.clear();
|
||||
_saved_filenames_synthesis.clear();
|
||||
|
||||
_state = STATE_ACQUIRING;
|
||||
acquire();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_SYNTHESISING;
|
||||
synthesise();
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
displayresults();
|
||||
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();
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -180,6 +235,7 @@ void AbstractAnalysis::saveImageSynthesis(string filename, ofxCvImage* newPixels
|
||||
#endif
|
||||
|
||||
_saved_filenames_synthesis.push_back(_whole_file_path_synthesis+"/"+filename);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
virtual ~AbstractAnalysis(){;}
|
||||
|
||||
// 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
|
||||
void do_synthesize();
|
||||
@@ -37,6 +37,8 @@ protected:
|
||||
|
||||
virtual void create_dir_allocate_images();
|
||||
|
||||
virtual void read_dir_create_list(string folder_path);
|
||||
|
||||
virtual void saveImageAnalysis(string filename);
|
||||
virtual void saveImageSynthesis(string filename, ofxCvImage* newPixels, ofImageType newType);
|
||||
|
||||
@@ -54,7 +56,8 @@ protected:
|
||||
|
||||
|
||||
public:
|
||||
string _name;
|
||||
string _name;
|
||||
string _draw_directory;
|
||||
|
||||
// event
|
||||
ofEvent<string> _synthesize_cb;
|
||||
|
||||
@@ -15,6 +15,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN CamNoiseAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
@@ -151,17 +153,17 @@ void CamNoiseAnalysis::synthesise()
|
||||
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
|
||||
|
||||
cvColorImage1.convertToGrayscalePlanarImage(cvGrayImage1, 1);
|
||||
// cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
|
||||
// cvColorImage2.convertToGrayscalePlanarImage(cvGrayImage2, 1);
|
||||
//added by tom we weren't actually setting cvgrayimage1 anywhere
|
||||
// cvGrayImage1.setFromPixels(cvColorImage1.getPixels(),cvColorImage1.width,cvColorImage1.height);
|
||||
//cvGrayDiff1.absDiff(cvGrayImage2, cvGrayImage1);
|
||||
//cvGrayImage1=cvColorImage1;
|
||||
|
||||
//cvGrayImage1=cvColorImage1;
|
||||
|
||||
cvGrayImage1.erode();
|
||||
cvGrayImage1.erode();
|
||||
cvGrayImage1.erode();
|
||||
cvGrayImage1.blur();
|
||||
cvGrayImage1.contrastStretch();
|
||||
cvGrayImage1.contrastStretch();
|
||||
/* cvColorImage1.erode();
|
||||
cvColorImage1.erode();
|
||||
cvColorImage1.erode();
|
||||
|
||||
@@ -14,6 +14,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN ColorMultiAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
@@ -15,6 +15,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN ColorSingleAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
@@ -15,6 +15,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN DiffNoiseAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
@@ -15,6 +15,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN IResponseAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
@@ -17,6 +17,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN RelaxRateAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
@@ -19,6 +19,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN ShadowScapesAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
@@ -15,6 +15,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN ShapeFromShadingAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
@@ -15,6 +15,8 @@ using Poco::Thread;
|
||||
|
||||
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);
|
||||
cout << "NUM_RUN StrobeAnalysis " << NUM_RUN << endl;
|
||||
//NUM_RUN = 5;
|
||||
|
||||
Reference in New Issue
Block a user