basically the same as dviid02_dviid_1 - just got it working...

there does seem to be some kind of strange file saving ordering problem
going on... into the 'drawing' --> folder. will look at it and try and
see what its doing wrong
This commit is contained in:
Jamie Allen 2012-04-08 20:56:28 +02:00
parent 7d7ec3606e
commit f66ce7e2e8
2 changed files with 65 additions and 62 deletions

View File

@ -28,7 +28,7 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight)
//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
@ -115,14 +115,14 @@ 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();
@ -153,49 +153,49 @@ void ColorSingleAnalysis::synthesise()
//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 ////////////////////////// ///////////////////////// PROCESS THE SAVED CAMERA IMAGES OF SHIT TO THE IMAGES //////////////////////////
cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height); cvColorImage1.setFromPixels(image1.getPixels(), image1.width, image1.height);
//cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height); //cvColorImage2.setFromPixels(image5.getPixels(), image5.width, image5.height);
cvColorImage1.blur(5); cvColorImage1.blur(5);
cvColorImage1.erode(); cvColorImage1.erode();
cvColorImage1.erode(); cvColorImage1.erode();
cvColorImage1.dilate(); cvColorImage1.dilate();
cvColorImage1.blur(5); cvColorImage1.blur(5);
cvColorImage1.erode(); cvColorImage1.erode();
cvColorImage1.erode(); cvColorImage1.erode();
cvColorImage1.erode(); cvColorImage1.erode();
cvColorImage1.erode(); cvColorImage1.erode();
/////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER //////////////////////////////// /////////////////////////////////// SAVE TO DISK IN THE SYNTHESIS FOLDER ////////////////////////////////
string file_name; string file_name;
file_name = ofToString(_synth_save_cnt, 2)+"_ColorSingleAnalysis_"+ofToString(_run_cnt,2)+".jpg"; 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 ----> //<---- 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); // ofSaveImage(cvGrayImage1.getPixelsRef(),_whole_file_path_synthesis+"/"+file_name, OF_IMAGE_QUALITY_BEST);
//<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ----> //<---- NEW SAVING - seems to fix WINDOWS saving out BLACK FRAMES PROBLEM ---->
//ofImage image; //ofImage image;
//image.allocate(cvColorImage1.width, cvColorImage1.height, OF_IMAGE_COLOR); //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.setUseTexture(false);
//image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR); //image.setFromPixels(cvColorImage1.getPixels(), cvColorImage1.width, cvColorImage1.height,OF_IMAGE_COLOR);
//image.saveImage(_whole_file_path_synthesis+"/"+file_name); //image.saveImage(_whole_file_path_synthesis+"/"+file_name);
//_saved_filenames_synthesis.push_back(_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> /// // <--- REALLY NEW SAVING METHOD --- 26 feb 2012 --- consolidated the save function into Abstract Analysis> ///
saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR); saveImageSynthesis(file_name, &cvColorImage1, OF_IMAGE_COLOR);
_synth_save_cnt++; _synth_save_cnt++;
// } // }
} }
} }
@ -326,7 +326,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);

View File

@ -65,5 +65,8 @@ 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;
}; };