Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 327830a581 | |||
| 877123a2db | |||
| feedecfe04 | |||
| daec77d2be | |||
| 6d0f6422bf | |||
| 1728a128e4 | |||
| e43b78cc5a |
+37
-37
@@ -1,45 +1,45 @@
|
||||
<!-- THIS FILE NEEDS TO GO IN THE APPLICATION /data/ folder -->
|
||||
|
||||
<config>
|
||||
<camera>
|
||||
<id>1</id>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</camera>
|
||||
<display>
|
||||
<fps>30</fps>
|
||||
</display>
|
||||
<locale>
|
||||
<name>SWANSEA</name>
|
||||
</locale>
|
||||
<camera>
|
||||
<id>1</id>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</camera>
|
||||
<display>
|
||||
<fps>30</fps>
|
||||
</display>
|
||||
<locale>
|
||||
<name>SWANSEA</name>
|
||||
</locale>
|
||||
|
||||
<analysis_NUM_RUN>
|
||||
<NUM_RUN_shadowscapes> 3 </NUM_RUN_shadowscapes>
|
||||
<NUM_RUN_relaxrate> 3 </NUM_RUN_relaxrate>
|
||||
<NUM_RUN_iresponse> 3 </NUM_RUN_iresponse>
|
||||
<NUM_RUN_shapefromshading> 3 </NUM_RUN_shapefromshading>
|
||||
<NUM_RUN_strobe> 5 </NUM_RUN_strobe>
|
||||
<NUM_RUN_camnoise> 5 </NUM_RUN_camnoise>
|
||||
<NUM_RUN_colorsingle> 5 </NUM_RUN_colorsingle>
|
||||
<NUM_RUN_colormulti> 5 </NUM_RUN_colormulti>
|
||||
<NUM_RUN_diffnoise> 3 </NUM_RUN_diffnoise>
|
||||
</analysis_NUM_RUN>
|
||||
<analysis_NUM_RUN>
|
||||
<NUM_RUN_shadowscapes> 3 </NUM_RUN_shadowscapes>
|
||||
<NUM_RUN_relaxrate> 3 </NUM_RUN_relaxrate>
|
||||
<NUM_RUN_iresponse> 3 </NUM_RUN_iresponse>
|
||||
<NUM_RUN_shapefromshading> 3 </NUM_RUN_shapefromshading>
|
||||
<NUM_RUN_strobe> 5 </NUM_RUN_strobe>
|
||||
<NUM_RUN_camnoise> 5 </NUM_RUN_camnoise>
|
||||
<NUM_RUN_colorsingle> 5 </NUM_RUN_colorsingle>
|
||||
<NUM_RUN_colormulti> 5 </NUM_RUN_colormulti>
|
||||
<NUM_RUN_diffnoise> 3 </NUM_RUN_diffnoise>
|
||||
</analysis_NUM_RUN>
|
||||
|
||||
<analysis_time>
|
||||
<acquiretime_shadowscapes> 30 </acquiretime_shadowscapes>
|
||||
<acquiretime_relaxrate> 30 </acquiretime_relaxrate>
|
||||
<acquiretime_iresponse> 30 </acquiretime_iresponse>
|
||||
<acquiretime_shapefromshading> 30 </acquiretime_shapefromshading>
|
||||
<acquiretime_strobe> 30 </acquiretime_strobe>
|
||||
<acquiretime_camnoise> 30 </acquiretime_camnoise>
|
||||
<acquiretime_colorsingle> 40 </acquiretime_colorsingle>
|
||||
<acquiretime_colormulti> 40 </acquiretime_colormulti>
|
||||
<acquiretime_diffnoise> 30 </acquiretime_diffnoise>
|
||||
</analysis_time>
|
||||
<analysis_time>
|
||||
<acquiretime_shadowscapes> 30 </acquiretime_shadowscapes>
|
||||
<acquiretime_relaxrate> 30 </acquiretime_relaxrate>
|
||||
<acquiretime_iresponse> 30 </acquiretime_iresponse>
|
||||
<acquiretime_shapefromshading> 30 </acquiretime_shapefromshading>
|
||||
<acquiretime_strobe> 30 </acquiretime_strobe>
|
||||
<acquiretime_camnoise> 30 </acquiretime_camnoise>
|
||||
<acquiretime_colorsingle> 40 </acquiretime_colorsingle>
|
||||
<acquiretime_colormulti> 40 </acquiretime_colormulti>
|
||||
<acquiretime_diffnoise> 30 </acquiretime_diffnoise>
|
||||
</analysis_time>
|
||||
|
||||
<relaxrate>
|
||||
<treshold>51</treshold>
|
||||
<maxblobs>25</maxblobs>
|
||||
</relaxrate>
|
||||
<relaxrate>
|
||||
<threshold>51</threshold>
|
||||
<maxblobs>25</maxblobs>
|
||||
</relaxrate>
|
||||
|
||||
</config>
|
||||
+47
-35
@@ -27,8 +27,10 @@
|
||||
#define ISTATE_TRANSITION 0xCCCC
|
||||
#define ISTATE_END 0xDDDD
|
||||
|
||||
|
||||
int _state = ISTATE_UNDEF;
|
||||
|
||||
int RefractiveIndex::_mode;
|
||||
ofPixels RefractiveIndex::_pixels;
|
||||
ofVideoGrabber RefractiveIndex::_vidGrabber;
|
||||
int RefractiveIndex::_vid_w, RefractiveIndex::_vid_h, RefractiveIndex::_vid_id;
|
||||
@@ -50,6 +52,10 @@ void RefractiveIndex::setup()
|
||||
XML.loadFile("config.refindx");
|
||||
}
|
||||
|
||||
// <mode>
|
||||
string m = XML.getValue("config:mode", "analysing");
|
||||
_mode = (m == "analysing" ? MODE_ANALYSING : (m == "drawing" ? MODE_DRAWING : MODE_ANALYSING));
|
||||
|
||||
// <camera>
|
||||
_vid_id = XML.getValue("config:camera:id", CAMERA_ID);
|
||||
cout << "_vid_id: " << _vid_id << endl;
|
||||
@@ -82,8 +88,10 @@ void RefractiveIndex::setup()
|
||||
cout << "* cam width = " << _vid_w << endl;
|
||||
cout << "* cam height = " << _vid_h << endl;
|
||||
|
||||
if(_mode == MODE_ANALYSING) {
|
||||
_vid_stream_open = false;
|
||||
setup_camera();
|
||||
}
|
||||
|
||||
cout << "RRRRRREADY!" << endl;
|
||||
|
||||
@@ -173,9 +181,13 @@ void RefractiveIndex::state_analysis()
|
||||
break;
|
||||
case ISTATE_STOP:
|
||||
stop_analysis(); // blocking
|
||||
if(_mode == MODE_DRAWING)
|
||||
_state = ISTATE_UNDEF;
|
||||
else
|
||||
_state = ISTATE_TRANSITION;
|
||||
break;
|
||||
case ISTATE_END:
|
||||
if(_mode == MODE_ANALYSING)
|
||||
stop_camera();
|
||||
::exit(1);
|
||||
break;
|
||||
@@ -354,41 +366,41 @@ void RefractiveIndex::keyPressed (int key)
|
||||
TO DO: add a file dialog so we can save images to another hard drive...
|
||||
e.g.: http://dev.openframeworks.cc/pipermail/of-dev-openframeworks.cc/2011-April/003125.html
|
||||
|
||||
>> case 's':
|
||||
>> doSave ^= true;
|
||||
>> doLoad = false;
|
||||
>> if(doSave) {
|
||||
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to save to", true);
|
||||
>> if(r.bSuccess) {
|
||||
>> saveCounter = 0;
|
||||
>> savePath = r.getPath();
|
||||
>> ofDirectory::createDirectory(savePath + "/color/");
|
||||
>> ofDirectory::createDirectory(savePath + "/depth/");
|
||||
>> printf("SAVE %s %s\n", r.getPath().c_str(), r.getName().c_str());
|
||||
>> } else {
|
||||
>> doSave = false;
|
||||
>> }
|
||||
>>
|
||||
>> }
|
||||
>> break;
|
||||
>>
|
||||
>> case 'l':
|
||||
>> doLoad ^= true;
|
||||
>> doSave = false;
|
||||
>> if(doLoad) {
|
||||
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to load from", true);
|
||||
>> if(r.bSuccess) {
|
||||
>> loadCounter = 0;
|
||||
>> loadPath = r.getPath();
|
||||
>> ofDirectory dir;
|
||||
>> loadMaxFiles = MAX(dir.listDir(loadPath + "/color"), dir.listDir(loadPath + "/depth"));
|
||||
>> printf("LOAD %i %s %s\n", loadMaxFiles, r.getPath().c_str(), r.getName().c_str());
|
||||
>> } else {
|
||||
>> doLoad = false;
|
||||
>> }
|
||||
>>
|
||||
>> }
|
||||
>> break;
|
||||
>> case 's':
|
||||
>> doSave ^= true;
|
||||
>> doLoad = false;
|
||||
>> if(doSave) {
|
||||
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to save to", true);
|
||||
>> if(r.bSuccess) {
|
||||
>> saveCounter = 0;
|
||||
>> savePath = r.getPath();
|
||||
>> ofDirectory::createDirectory(savePath + "/color/");
|
||||
>> ofDirectory::createDirectory(savePath + "/depth/");
|
||||
>> printf("SAVE %s %s\n", r.getPath().c_str(), r.getName().c_str());
|
||||
>> } else {
|
||||
>> doSave = false;
|
||||
>> }
|
||||
>>
|
||||
>> }
|
||||
>> break;
|
||||
>>
|
||||
>> case 'l':
|
||||
>> doLoad ^= true;
|
||||
>> doSave = false;
|
||||
>> if(doLoad) {
|
||||
>> ofFileDialogResult r = ofSystemLoadDialog("Select path to load from", true);
|
||||
>> if(r.bSuccess) {
|
||||
>> loadCounter = 0;
|
||||
>> loadPath = r.getPath();
|
||||
>> ofDirectory dir;
|
||||
>> loadMaxFiles = MAX(dir.listDir(loadPath + "/color"), dir.listDir(loadPath + "/depth"));
|
||||
>> printf("LOAD %i %s %s\n", loadMaxFiles, r.getPath().c_str(), r.getName().c_str());
|
||||
>> } else {
|
||||
>> doLoad = false;
|
||||
>> }
|
||||
>>
|
||||
>> }
|
||||
>> break;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "ofxOpenCv.h"
|
||||
#include "ofxXmlSettings.h"
|
||||
|
||||
#define MODE_DRAWING 0xEEFF
|
||||
#define MODE_ANALYSING 0xFFEE
|
||||
|
||||
class RefractiveIndex : public ofBaseApp
|
||||
{
|
||||
public:
|
||||
@@ -55,6 +58,8 @@ public:
|
||||
// acquisition
|
||||
static ofPixels _pixels;
|
||||
static ofVideoGrabber _vidGrabber;
|
||||
static int _mode;
|
||||
|
||||
vector<string> videoSourceList;
|
||||
static int _vid_w, _vid_h, _vid_id;
|
||||
static bool _vid_stream_open;
|
||||
|
||||
@@ -22,9 +22,11 @@ void AbstractAnalysis::do_synthesize() {
|
||||
if(_state == STATE_STOP) goto exit;
|
||||
_state = STATE_DISPLAY_RESULTS;
|
||||
displayresults();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
exit:
|
||||
cleanup();
|
||||
ofNotifyEvent(_synthesize_cb, _name);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,10 @@ protected:
|
||||
// display the results from disk
|
||||
virtual void displayresults() = 0;
|
||||
|
||||
// display the results from disk
|
||||
virtual void cleanup() {;}
|
||||
|
||||
|
||||
public:
|
||||
string _name;
|
||||
|
||||
|
||||
@@ -246,8 +246,6 @@ void ColorMultiAnalysis::draw()
|
||||
//cout << "FADING IN..." << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (_frame_cnt >= _fade_in_frames && _frame_cnt < _frame_cnt_max-_fade_in_frames){
|
||||
|
||||
aColor.setHsb(c, 255, 255);
|
||||
|
||||
+155
-8
@@ -124,7 +124,6 @@ void ColorSingleAnalysis::acquire()
|
||||
|
||||
save_timer->stop();
|
||||
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -137,11 +136,103 @@ void ColorSingleAnalysis::synthesise()
|
||||
for(float i=1;i<_saved_filenames_analysis.size()-1;i++){
|
||||
|
||||
//cout << "ColorSingleAnalysis::synthesis FOR LOOP...\n";
|
||||
|
||||
//cout << "_saved_filenames_analysis[i]" << _saved_filenames_analysis[i] << endl;
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
image1.loadImage("Mar_02_19_00_47_2/194_9.72_1.jpg");
|
||||
image1.resize(image1.width/20, image1.height/20);
|
||||
|
||||
int width = image1.width;
|
||||
int height = image1.height;
|
||||
|
||||
// get the pixels from the image
|
||||
imagePixels = image1.getPixels();
|
||||
|
||||
// ------------------- create the vector field ------------------------------------
|
||||
|
||||
vectorCount = width * height;
|
||||
|
||||
// create a 2d vector field
|
||||
vectorField = new ofVec2f[vectorCount];
|
||||
|
||||
// set all values in vector field to 0.0
|
||||
for(int i=0; i<vectorCount; i++){
|
||||
|
||||
vectorField[i].x = 0.0;
|
||||
vectorField[i].y = 0.0;
|
||||
}
|
||||
|
||||
|
||||
// ------------------- calculate the vectors ------------------------------------
|
||||
|
||||
// loop through all of the pixels
|
||||
for(int x=1; x< width-1; x++){
|
||||
for(int y=1; y< height-1; y++){
|
||||
|
||||
char areaPixels[9];
|
||||
|
||||
// loop through the area pixels
|
||||
for(int i=-1; i<=1; i++){
|
||||
for(int j=-1; j<=1; j++){
|
||||
|
||||
// determine where to read from in the area (not optimized)
|
||||
int readPos = ((y + j) * width + (x + i)) * 3;
|
||||
|
||||
unsigned char R = imagePixels[readPos];
|
||||
unsigned char G = imagePixels[readPos+1];
|
||||
unsigned char B = imagePixels[readPos+2];
|
||||
|
||||
unsigned char BR = (0.299 * R) + (.587 * G) + (.114 * B);
|
||||
|
||||
int writePos = (j+1) * 3 + (i + 1);
|
||||
|
||||
areaPixels[writePos] = BR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
float dX = (areaPixels[0] + areaPixels[3] + areaPixels[6])/3 - (areaPixels[2] + areaPixels[5] + areaPixels[8])/3;
|
||||
float dY = (areaPixels[0] + areaPixels[1] + areaPixels[2])/3 - (areaPixels[6] + areaPixels[7] + areaPixels[8])/3;
|
||||
|
||||
int vectorPos = y * width + x;
|
||||
|
||||
//printf("dx %f\n", dX);
|
||||
|
||||
vectorField[vectorPos].x = dX;
|
||||
vectorField[vectorPos].y = dY;
|
||||
|
||||
//vectorField[vectorPos].x = -dY;
|
||||
//vectorField[vectorPos].y = dX;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------- normalize the vectors ------------------------------------
|
||||
|
||||
// variables for the maximum magnitude (absolute) in x and y
|
||||
float maxMagX = 1.0;
|
||||
float maxMagY = 1.0;
|
||||
|
||||
// loop through the vector field to find the maximum x and y values
|
||||
for(int i=0; i< vectorCount; i++){
|
||||
|
||||
if(fabs(vectorField[i].x) > maxMagX) maxMagX = fabs(vectorField[i].x);
|
||||
if(fabs(vectorField[i].y) > maxMagY) maxMagY = fabs(vectorField[i].y);
|
||||
}
|
||||
|
||||
// loop through the vector field to normalize the values
|
||||
for(int i=0; i< vectorCount; i++){
|
||||
|
||||
vectorField[i].x /= maxMagX;
|
||||
vectorField[i].y /= maxMagY;
|
||||
}
|
||||
|
||||
// COMMENTING OUT THE FILLER SYNTH ALGORITHM
|
||||
/*
|
||||
if(!image1.loadImage(_saved_filenames_analysis[i])){
|
||||
//couldn't load image
|
||||
cout << "didn't load image" << endl;
|
||||
@@ -180,7 +271,7 @@ void ColorSingleAnalysis::synthesise()
|
||||
//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? ***//
|
||||
// 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);
|
||||
@@ -194,7 +285,10 @@ void ColorSingleAnalysis::synthesise()
|
||||
_synth_save_cnt++;
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// _saved_filenames_synthesis has processed all the files in the analysis images folder
|
||||
@@ -203,8 +297,23 @@ void ColorSingleAnalysis::synthesise()
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
void ColorSingleAnalysis::displayresults()
|
||||
{
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
|
||||
_show_image = true;
|
||||
_image_shown = false;
|
||||
|
||||
//cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
|
||||
|
||||
while(!_image_shown){
|
||||
Thread::sleep(2);
|
||||
//cout << "!_image_shown" << endl;
|
||||
}
|
||||
|
||||
/*
|
||||
for(float i=1;i<_saved_filenames_synthesis.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
@@ -228,6 +337,7 @@ void ColorSingleAnalysis::displayresults()
|
||||
_image_shown = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -238,8 +348,6 @@ void ColorSingleAnalysis::draw()
|
||||
switch (_state) {
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
|
||||
|
||||
if (_frame_cnt < _frame_cnt_max)
|
||||
{
|
||||
|
||||
@@ -385,8 +493,48 @@ void ColorSingleAnalysis::draw()
|
||||
case STATE_DISPLAY_RESULTS:
|
||||
{
|
||||
|
||||
//cout << "STATE_DISPLAY_RESULTS...\n" << endl;
|
||||
cout << "case STATE_DISPLAY_RESULTS = true" << endl;
|
||||
|
||||
int width = image1.width;
|
||||
int height = image1.height;
|
||||
float spacing = 10;
|
||||
|
||||
if (_frame_cnt > 2000)
|
||||
{
|
||||
_image_shown = true;
|
||||
_frame_cnt=0;
|
||||
}
|
||||
|
||||
_frame_cnt++;
|
||||
|
||||
if (_show_image)
|
||||
{
|
||||
|
||||
|
||||
cout << "_show_image = true" << endl;
|
||||
|
||||
for(int x=0; x<width; x++){
|
||||
|
||||
float xPos = (float) x * spacing + 5;
|
||||
|
||||
for(int y=0; y<height; y++){
|
||||
float yPos = (float)y * spacing + 5;
|
||||
glPushMatrix();
|
||||
ofLine(xPos, yPos, xPos+(vectorField[y*width+x].x*spacing), yPos+(vectorField[y*width+x].y*spacing));
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
//this is where we save the full-frame software output to file... after the vectors, etc. are rendered...
|
||||
//saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
|
||||
|
||||
}
|
||||
|
||||
_RUN_DONE = true;
|
||||
break;
|
||||
|
||||
/*
|
||||
//cout << "STATE_DISPLAY_RESULTS...\n" << endl;
|
||||
|
||||
if (_frame_cnt > 2)
|
||||
{
|
||||
@@ -412,10 +560,9 @@ void ColorSingleAnalysis::draw()
|
||||
// display results of the synthesis
|
||||
_RUN_DONE = true;
|
||||
break;
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -65,5 +65,8 @@ protected:
|
||||
//this is the temporary container to allow us to convert and save out greyscale images
|
||||
ofxCvColorImage cvConvertorImage;
|
||||
|
||||
unsigned char * imagePixels;
|
||||
int vectorCount;
|
||||
ofVec2f * vectorField;
|
||||
|
||||
};
|
||||
|
||||
@@ -184,7 +184,11 @@ void IResponseAnalysis::synthesise()
|
||||
cvConvertorImage.setFromGrayscalePlanarImages(cvGrayDiff1,cvGrayDiff1,cvGrayDiff1);
|
||||
|
||||
saveImageSynthesis(file_name, &cvConvertorImage, OF_IMAGE_GRAYSCALE);
|
||||
|
||||
_synth_save_cnt++;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+47
-37
@@ -12,7 +12,7 @@ using Poco::Thread;
|
||||
|
||||
#define NUMBER_RUNS 1
|
||||
#define ACQUIRE_TIME 20
|
||||
#define TRESHOLD 80
|
||||
#define THRESHOLD 80
|
||||
#define MAXBLOBS 15
|
||||
|
||||
void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||
@@ -25,8 +25,8 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||
acq_run_time = RefractiveIndex::XML.getValue("config:analysis_time:acquiretime_relaxrate", ACQUIRE_TIME);
|
||||
cout << "ACQUIRE_TIME RelaxRateAnalysis " << acq_run_time << endl;
|
||||
|
||||
_treshold = RefractiveIndex::XML.getValue("config:relaxrate:treshold", TRESHOLD);
|
||||
cout << "TRESHOLD RelaxRateAnalysis " << _treshold << endl;
|
||||
_threshold = RefractiveIndex::XML.getValue("config:relaxrate:threshold", THRESHOLD);
|
||||
cout << "THRESHOLD RelaxRateAnalysis " << _threshold << endl;
|
||||
|
||||
_maxblobs = RefractiveIndex::XML.getValue("config:relaxrate:maxblobs", MAXBLOBS);
|
||||
cout << "MAXBLOBS RelaxRateAnalysis " << _maxblobs << endl;
|
||||
@@ -55,49 +55,18 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight)
|
||||
_image_shown = false;
|
||||
|
||||
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();
|
||||
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +104,7 @@ void RelaxRateAnalysis::synthesise()
|
||||
|
||||
cvContourFinderVect.clear();
|
||||
|
||||
|
||||
for(float i=1;i<_saved_filenames_analysis.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
@@ -146,7 +116,7 @@ void RelaxRateAnalysis::synthesise()
|
||||
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
|
||||
cvColorImage1.convertToGrayscalePlanarImage(cvGrayDiff1, 1);
|
||||
|
||||
cvGrayDiff1.threshold(_treshold);
|
||||
cvGrayDiff1.threshold(_threshold);
|
||||
|
||||
rfiCvContourFinder* cf = new rfiCvContourFinder();
|
||||
|
||||
@@ -166,11 +136,16 @@ void RelaxRateAnalysis::synthesise()
|
||||
void RelaxRateAnalysis::displayresults()
|
||||
{
|
||||
|
||||
cvContourFinderVectDisplay.clear();
|
||||
//cvContourFinderVectDisplay.clear();
|
||||
clearcfindervectdisplay();
|
||||
|
||||
for(int i=1;i<cvContourFinderVect.size();i++){
|
||||
|
||||
if(_state == STATE_STOP) return;
|
||||
if(_state == STATE_STOP){
|
||||
clearcfindervectdisplay();
|
||||
clearcfindervect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//cout << "_saved_filenames_analysis[i] - " << _saved_filenames_synthesis[i] << endl;
|
||||
@@ -187,6 +162,14 @@ void RelaxRateAnalysis::displayresults()
|
||||
|
||||
}
|
||||
|
||||
clearcfindervectdisplay();
|
||||
clearcfindervect();
|
||||
|
||||
|
||||
//cvContourFinderVectDisplay.clear();
|
||||
//cvContourFinderVect.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +181,7 @@ void RelaxRateAnalysis::draw()
|
||||
case STATE_ACQUIRING:
|
||||
{
|
||||
|
||||
|
||||
if (_frame_cnt < _frame_cnt_max)
|
||||
{
|
||||
|
||||
@@ -227,6 +211,7 @@ void RelaxRateAnalysis::draw()
|
||||
|
||||
case STATE_SYNTHESISING:
|
||||
{
|
||||
|
||||
// display animation of something while the synthesis in on-going...
|
||||
|
||||
//cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n";
|
||||
@@ -356,3 +341,28 @@ 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();
|
||||
}
|
||||
|
||||
|
||||
+6
-19
@@ -23,6 +23,7 @@ public:
|
||||
void acquire();
|
||||
void synthesise();
|
||||
void displayresults();
|
||||
void cleanup();
|
||||
|
||||
void draw();
|
||||
|
||||
@@ -30,36 +31,22 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void clearcfindervect();
|
||||
void clearcfindervectdisplay();
|
||||
|
||||
bool _RUN_DONE;
|
||||
float _flip, _level;
|
||||
int _run_cnt, _save_cnt, _synth_save_cnt, _anim_cnt;
|
||||
float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max;
|
||||
|
||||
int _treshold;
|
||||
int _threshold;
|
||||
int _maxblobs;
|
||||
|
||||
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;
|
||||
|
||||
vector<rfiCvContourFinder*> cvContourFinderVect;
|
||||
vector<rfiCvContourFinder*> cvContourFinderVectDisplay;
|
||||
|
||||
@@ -439,6 +439,9 @@ void ShadowScapesAnalysis::draw()
|
||||
|
||||
// display results of the synthesis
|
||||
_RUN_DONE = true;
|
||||
|
||||
// clear allocated memory...?
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user