summaryrefslogtreecommitdiff
path: root/gaunt01/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gaunt01/src/testApp.cpp')
-rw-r--r--gaunt01/src/testApp.cpp61
1 files changed, 44 insertions, 17 deletions
diff --git a/gaunt01/src/testApp.cpp b/gaunt01/src/testApp.cpp
index 8fe42cc..226e694 100644
--- a/gaunt01/src/testApp.cpp
+++ b/gaunt01/src/testApp.cpp
@@ -41,7 +41,7 @@ void testApp::setup(){
{
hasCamera=false;
useCamera=false;
- vidPlayer.loadMovie("camoutput.mov"); //footage/ camera needs to be the same res as opencv planes and output
+ vidPlayer.loadMovie(testmovie); //footage/ camera needs to be the same res as opencv planes and output
vidPlayer.setLoopState(OF_LOOP_NORMAL);
vidPlayer.play();
}
@@ -160,8 +160,8 @@ void testApp::setup(){
cam.begin();
cam.end();
-
- updatePlane();
+
+ //mog=cv::BackgroundSubtractorMOG(100,10,.1,.1);
}
@@ -501,6 +501,9 @@ void testApp::update(){
*/
cv::Mat img = colorImg.getCvImage();
+
+
+
//if (frameno%1==0) { //I THINK THIS APPROACH IS OK to attempt to lower cpu hit from accumulating?
@@ -530,6 +533,8 @@ void testApp::update(){
//get correct channel into backchan
+
+
vector<cv::Mat> chans;
@@ -606,7 +611,7 @@ void testApp::update(){
//convert back into RGB if necessary
- if (diffchannel<chan_H) cvtColor(hsvfront, outimg, CV_HSV2BGR);
+ if (diffchannel<chan_H) cvtColor(hsvfront, outimg, CV_HSV2BGR);
else outimg=hsvfront;
}else {
@@ -650,13 +655,19 @@ void testApp::update(){
// take the abs value of the difference between background and incoming and then threshold:
grayDiff.absDiff(grayBg, grayFrame);
grayDiff.threshold(threshold);
- //grayFrame.adaptiveThreshold( threshold,10,false,true); //int blockSize, int offset=0,bool invert=false, bool gauss=false);
+ //grayDiff.adaptiveThreshold( threshold,20,true,false); //int blockSize, int offset=0,bool invert=false, bool gauss=false);
//grayDiff.erode_3x3();
//grayDiff.resize(windowWidth,windowHeight);
-
-/*
+
+ /*
+
//MOG
+
mog(img, outmat, mogf);
+
+
+
+
// Complement the image
//cv::threshold(outmat, output, threshold, 255, cv::THRESH_BINARY_INV);
@@ -664,11 +675,18 @@ void testApp::update(){
//printf("tmp: %ix%i channels: %i depth:%i\n",tmp->width,tmp->height,tmp->nChannels,tmp->depth);
//printf("grayDiff: %ix%i channels: %i depth:%i\n",grayDiff.getCvImage()->width,grayDiff.getCvImage()->height,grayDiff.getCvImage()->nChannels,grayDiff.getCvImage()->depth);
grayDiff=tmp1; //copy to ofx
-*/
+
+ */
+
+
+
+ if (mode==CHECKACCUM) colorImg=grayDiff;
grayDiff.resize(windowWidth,windowHeight); //wasteful??
+
+
- contourFinder.findContours(grayDiff, 500, (640*480)/3, 20, false); // find holes
+ contourFinder.findContours(grayDiff, 500, (640*480)/3, 20,false); // find holes
blobsManager.update(contourFinder.blobs);
//check players against blob ids - bland do ray casting, update players
@@ -724,7 +742,7 @@ void testApp::draw(){
ofSetHexColor(0xffffff);
glDisable(GL_BLEND);
- if (gameState<PLAYING) colorImg.draw(0,0,windowWidth,windowHeight);
+ if (gameState<PLAYING||mode==CHECKACCUM) colorImg.draw(0,0,windowWidth,windowHeight);
else {
@@ -774,14 +792,17 @@ void testApp::draw(){
glDisable(GL_BLEND);
ofPopMatrix();
- glDisable(GL_DEPTH_TEST);
- ofSetHexColor(0xffffff);
- bindTexture(colorImg); //colorImg.getTextureReference().bind();
- map<int,player>::iterator it;
- for(int i=0;i<blobsManager.blobs.size();i++){
- if(players[blobsManager.blobs.at(i).id].active) players[blobsManager.blobs.at(i).id].draw();
+ if (mode!=CHECKACCUM) {
+ glDisable(GL_DEPTH_TEST);
+ ofSetHexColor(0xffffff);
+ bindTexture(colorImg); //colorImg.getTextureReference().bind();
+ map<int,player>::iterator it;
+ for(int i=0;i<blobsManager.blobs.size();i++){
+ //if(players[blobsManager.blobs.at(i).id].active)
+ players[blobsManager.blobs.at(i).id].draw();
+ }
+ unbindTexture(colorImg);
}
- unbindTexture(colorImg);
glEnable(GL_LIGHTING);
@@ -802,6 +823,7 @@ void testApp::draw(){
gameState++;
gameStart=ofGetElapsedTimef();
gameTime=0.0f;
+ updatePlane();
}
break;
case PLAYING:
@@ -867,6 +889,7 @@ void testApp::draw(){
break;
case CALIBRATE:
+ case CHECKACCUM:
ofSetHexColor(0xffffff);
ofPushMatrix();
@@ -1033,6 +1056,9 @@ void testApp::keyPressed(int key){
case '0':
mode=CALIBRATE;
break;
+ case '8':
+ mode=CHECKACCUM;
+ break;
case '1':
diffchannel = chan_R;
@@ -1203,6 +1229,7 @@ void testApp::loadSettings(string filename){
diffchannel=ofToInt(XML.getAttribute("gauntlet","keyChannel","none",0));
learningRate=ofToFloat(XML.getAttribute("gauntlet","learningRate","none",0));
removeShadows=ofToInt(XML.getAttribute("gauntlet","remove_shadows","none",0))==1;
+ testmovie=XML.getAttribute("gauntlet","testmovie","camoutput.move",0);
if(XML.pushTag("bounds")) {
for (int i=0;i<XML.getNumTags("vertex");i++){
border.push_back(ofVec2f(ofToFloat(XML.getAttribute("vertex","x","0",i)),ofToFloat(XML.getAttribute("vertex","y","0",i))));