summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-08-21 15:37:26 +0100
committerTim Redfern <tim@eclectronics.org>2012-08-21 15:37:26 +0100
commit685e82c6b33038cdfc4e9836002bfe1ff2f9897a (patch)
tree10712df6d75d3dd725eafc84d6aae35de3aab0f2
parent8cc12c684eaf724832cb67b950188306fa9fd0a1 (diff)
had enough
-rw-r--r--gaunt01/bin/data/settings.xml2
-rw-r--r--gaunt01/src/testApp.cpp61
-rw-r--r--gaunt01/src/testApp.h5
3 files changed, 50 insertions, 18 deletions
diff --git a/gaunt01/bin/data/settings.xml b/gaunt01/bin/data/settings.xml
index df7427c..3ef506a 100644
--- a/gaunt01/bin/data/settings.xml
+++ b/gaunt01/bin/data/settings.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<gauntlet cam_angle="-55" threshold="24" keyChannel="6" learningRate="0.001" remove_shadows="0" />
+<gauntlet cam_angle="-55" threshold="16" keyChannel="6" learningRate="0.01" remove_shadows="0" testmovie="camoutput.mov"/>
<bounds>
<vertex x="664.309" y="866.4"></vertex>
<vertex x="844.015" y="425.757"></vertex>
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))));
diff --git a/gaunt01/src/testApp.h b/gaunt01/src/testApp.h
index 7c95e6e..82f75fe 100644
--- a/gaunt01/src/testApp.h
+++ b/gaunt01/src/testApp.h
@@ -6,6 +6,8 @@
#include "tesselator.h"
#include "ofxOpenCv.h"
+#include <opencv2/opencv.hpp>
+
#include "ofxRay.h"
#include "ofxXmlSettings.h"
@@ -21,6 +23,7 @@
#define PLAY 0
#define CALIBRATE 1
+#define CHECKACCUM 2
#define TITLES 0
#define EXPLAIN 1
@@ -77,6 +80,8 @@ class testApp : public ofBaseApp{
ofVideoPlayer vidPlayer;
ofxCvColorImage colorImg;
+
+ string testmovie;
int diffchannel;