david commit 19:31

This commit is contained in:
Jamie Allen 2012-02-21 19:31:58 +01:00
parent 117eaca232
commit 2903c7a969
4 changed files with 38 additions and 14 deletions

View File

@ -115,7 +115,7 @@ void RefractiveIndex::setup()
_analysisVector.push_back(new DiffNoiseAnalysis());
_currentAnalysisIndx = 0;
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx);
_currentAnalysis = _analysisVector.at(_currentAnalysisIndx++);
_state = ISTATE_START;
@ -217,16 +217,19 @@ void RefractiveIndex::setup_camera()
{
stop_camera();
if(!_vidGrabber.initGrabber(_vid_w, _vid_h)) {
_vidGrabber.setDeviceID(_vid_id);
_vidGrabber.listDevices();
if(!_vidGrabber.initGrabber(_vid_w, _vid_h)) {
ofLog(OF_LOG_ERROR) << "RefractiveIndex::setup_camera - could not initialise grabber";
return;
}
_vidGrabber.setVerbose(true);
_vidGrabber.setUseTexture(false);
_vidGrabber.listDevices();
_vidGrabber.setVerbose(true);
_vid_stream_open = true;
_vidGrabber.setDeviceID(_vid_id);
cout << "CAMERA SETUP " << endl;
return;
}

View File

@ -281,6 +281,8 @@ void IResponseAnalysis::save_cb(Timer& timer)
if (RefractiveIndex::_vidGrabber.isFrameNew())
{
RefractiveIndex::_pixels = RefractiveIndex::_vidGrabber.getPixelsRef(); //get ofPixels from the camera
} else {
return;
}
//cout << "IResponseAnalysis::saving...\n";

View File

@ -5,6 +5,8 @@
#include "Poco/Thread.h"
#include "RefractiveIndex.h"
#include "ofxOpenCv.h"
using Poco::Timer;
using Poco::TimerCallback;
using Poco::Thread;
@ -16,7 +18,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
{
NUM_RUN = 1;
int acq_run_time = 20; // 10 seconds of acquiring per run
int acq_run_time = 1; // 10 seconds of acquiring per run
int screenSpan;
if (_dir == V) screenSpan = ofGetHeight();
@ -37,7 +39,7 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
_run_cnt = 0;
_save_cnt = 0;
int anim_time = 5; // 10 seconds
int anim_time = 1; // 10 seconds
_anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames
_show_image = false;
@ -48,6 +50,10 @@ void ShadowScapesAnalysis::setup(int camWidth, int camHeight)
image1.setUseTexture(false);
image2.setUseTexture(true);
cvGrayImage1.allocate(320,240);
cvGrayDiff1.allocate(320,240);
}
void ShadowScapesAnalysis::acquire()
@ -78,8 +84,6 @@ void ShadowScapesAnalysis::acquire()
void ShadowScapesAnalysis::synthesise()
{
//cvImage1.allocate(image2.getWidth(), image2.getHeight());
//cvImage1.setFromPixels(image2);
// _saved_filenames has all the file names of all the saved images
while(!_RUN_DONE)
@ -309,7 +313,15 @@ void ShadowScapesAnalysis::draw()
ofSetColor(255, 255, 255, 255);
image2.setFromPixels(image1.getPixels(),image1.width,image1.height, OF_IMAGE_COLOR);
image2.draw(0,0, ofGetWidth(), ofGetHeight());
//image2.draw(0,0, ofGetWidth(), ofGetHeight());
//cvImage1.allocate(image1.getWidth(), image2.getHeight());
cvImage1.setFromPixels(image1.getPixels(), 320, 240);
cvGrayImage1 = cvImage1;
cvGrayDiff1.absDiff(cvGrayImage1, cvGrayImage1);
cvGrayImage1.draw(0,0, ofGetWidth(), ofGetHeight());
//cvGrayDiff1.draw(0,0, ofGetWidth(), ofGetHeight());
ofDisableAlphaBlending();
}

View File

@ -44,6 +44,13 @@ protected:
bool _show_image, _image_shown;
ofImage image1;
ofImage image2;
ofxCvColorImage cvImage1;
ofxCvColorImage cvImage1;
ofxCvGrayscaleImage cvGrayImage1;
ofxCvGrayscaleImage cvGrayBg1;
ofxCvGrayscaleImage cvGrayDiff1;
ofxCvContourFinder cvContourFinder1;
};