| 8 |
8 |
*/
|
| 9 |
9 |
|
| 10 |
10 |
#include "TBetaBase.h"
|
| 11 |
|
#include "gui.h"
|
| 12 |
|
|
| 13 |
|
void TBetaBase::drawFingerOutlines(){
|
| 14 |
|
|
| 15 |
|
//Find the blobs
|
| 16 |
|
for(int i=0; i<contourFinder.nBlobs; i++)
|
| 17 |
|
{
|
| 18 |
|
//temp blob to rescale and draw on screen
|
| 19 |
|
ofxTBetaCvBlob drawBlob;
|
| 20 |
|
drawBlob = contourFinder.blobs[i];
|
| 21 |
|
|
| 22 |
|
if(bDrawOutlines)
|
| 23 |
|
{
|
| 24 |
|
//Get the contour (points) so they can be drawn
|
| 25 |
|
for( int j=0; j<contourFinder.blobs[i].nPts; j++ )
|
| 26 |
|
{
|
| 27 |
|
drawBlob.pts[j].x = (MAIN_WINDOW_WIDTH/camera.camWidth) * (drawBlob.pts[j].x);
|
| 28 |
|
drawBlob.pts[j].y = (MAIN_WINDOW_HEIGHT/camera.camHeight) * (drawBlob.pts[j].y);
|
| 29 |
|
}
|
| 30 |
|
|
| 31 |
|
//This adjusts the blob drawing for different cameras
|
| 32 |
|
drawBlob.boundingRect.width *= (MAIN_WINDOW_WIDTH/camera.camWidth);
|
| 33 |
|
drawBlob.boundingRect.height *= (MAIN_WINDOW_HEIGHT/camera.camHeight);
|
| 34 |
|
drawBlob.boundingRect.x *= (MAIN_WINDOW_WIDTH/camera.camWidth);
|
| 35 |
|
drawBlob.boundingRect.y *= (MAIN_WINDOW_HEIGHT/camera.camHeight);
|
| 36 |
|
|
| 37 |
|
//Draw contours (outlines) on the source image
|
| 38 |
|
drawBlob.draw(40, 30);
|
| 39 |
|
|
| 40 |
|
// ofSetColor(0x0099FF); //Make Plus Sign
|
| 41 |
|
// ofRect((drawBlob.centroid.x * (MAIN_WINDOW_WIDTH/camera.camWidth)) + 40, (drawBlob.centroid.y * (MAIN_WINDOW_HEIGHT/camera.camHeight)) - drawBlob.boundingRect.height + 30, .5, drawBlob.boundingRect.height * 2); //Horizontal Plus
|
| 42 |
|
// ofRect((drawBlob.centroid.x * (MAIN_WINDOW_WIDTH/camera.camWidth)) - drawBlob.boundingRect.width + 40, (drawBlob.centroid.y * (MAIN_WINDOW_HEIGHT/camera.camHeight)) + 30, drawBlob.boundingRect.width * 2, .5); //Vertical Plus
|
| 43 |
|
}
|
| 44 |
|
|
| 45 |
|
if(bShowLabels) //Show ID label;
|
| 46 |
|
{
|
| 47 |
|
float xpos = drawBlob.centroid.x * (MAIN_WINDOW_WIDTH/camera.camWidth);
|
| 48 |
|
float ypos = drawBlob.centroid.y * (MAIN_WINDOW_HEIGHT/camera.camHeight);
|
| 49 |
|
|
| 50 |
|
ofSetColor(0xCCFFCC);
|
| 51 |
|
char idStr[1024];
|
| 52 |
|
sprintf(idStr, "id: %i,(%i, %i)",drawBlob.id, drawBlob.lastCentroid.x, drawBlob.lastCentroid.y);
|
| 53 |
|
verdana.drawString(idStr, xpos + 365, ypos + drawBlob.boundingRect.height/2 + 45);
|
| 54 |
|
}
|
| 55 |
|
}
|
| 56 |
|
ofSetColor(0xFFFFFF);
|
|
11 |
#include "gui.h"
|
|
12 |
|
|
13 |
/******************************************************************************
|
|
14 |
* The setup function is run once to perform initializations in the application
|
|
15 |
*****************************************************************************/
|
|
16 |
void TBetaBase::setup()
|
|
17 |
{
|
|
18 |
//set the title to 'tbeta'
|
|
19 |
ofSetWindowTitle("tbeta");
|
|
20 |
|
|
21 |
//removes the 'x' button on windows which causes a crash due to a GLUT bug
|
|
22 |
#ifdef TARGET_WIN32
|
|
23 |
HWND hwndConsole = FindWindowA(NULL, "tbeta");
|
|
24 |
HMENU hMnu = ::GetSystemMenu(hwndConsole, FALSE);
|
|
25 |
RemoveMenu(hMnu, SC_CLOSE, MF_BYCOMMAND);
|
|
26 |
#endif
|
|
27 |
|
|
28 |
/********************
|
|
29 |
* Initalize Variables
|
|
30 |
*********************/
|
|
31 |
//Intialize FPS variables
|
|
32 |
frames = 0;
|
|
33 |
fps = 0;
|
|
34 |
lastFPSlog = 0;
|
|
35 |
//Calibration Booleans
|
|
36 |
bCalibration= false;
|
|
37 |
|
|
38 |
differenceTime = 0;
|
|
39 |
|
|
40 |
bDrawVideo = true;
|
|
41 |
bFullscreen = false;
|
|
42 |
ofSetBackgroundAuto(false);
|
|
43 |
|
|
44 |
//create filter
|
|
45 |
if( filter == NULL ) {
|
|
46 |
filter = new ofxTouchAdaptiveFilter();
|
|
47 |
}
|
|
48 |
|
|
49 |
//Load Settings from config.xml file
|
|
50 |
loadXMLSettings();
|
|
51 |
|
|
52 |
//Setup Window Properties
|
|
53 |
ofSetWindowShape(winWidth,winHeight);
|
|
54 |
ofSetFrameRate(camRate * 1.4); //This will be based on camera fps in the future
|
|
55 |
ofSetVerticalSync(false); //Set vertical sync to false for better performance?
|
|
56 |
|
|
57 |
//Pick the Source - camera or video
|
|
58 |
if(bcamera)
|
|
59 |
{
|
|
60 |
activeInput = true;
|
|
61 |
vidGrabber.listDevices();
|
|
62 |
vidGrabber.setDeviceID(deviceID);
|
|
63 |
vidGrabber.setVerbose(true);
|
|
64 |
vidGrabber.initGrabber(camWidth,camHeight);
|
|
65 |
int grabW = vidGrabber.width;
|
|
66 |
int grabH = vidGrabber.height;
|
|
67 |
printf("Camera Mode\nAsked for %i by %i - actual size is %i by %i \n\n", camWidth, camHeight, grabW, grabH);
|
|
68 |
}
|
|
69 |
else
|
|
70 |
{
|
|
71 |
activeInput = true;
|
|
72 |
vidPlayer.loadMovie("test_videos/" + videoFileName);
|
|
73 |
vidPlayer.play();
|
|
74 |
printf("Video Mode\n");
|
|
75 |
camHeight = vidPlayer.height;
|
|
76 |
camWidth = vidPlayer.width;
|
|
77 |
}
|
|
78 |
|
|
79 |
/*****************************************************************************************************
|
|
80 |
* Allocate images (needed for drawing/processing images) ----Most of These won't be needed in the end
|
|
81 |
******************************************************************************************************/
|
|
82 |
processedImg.allocate(camWidth, camHeight); //main Image that'll be processed.
|
|
83 |
processedImg.setUseTexture(false);
|
|
84 |
sourceImg.allocate(camWidth, camHeight); //Source Image
|
|
85 |
sourceImg.setUseTexture(false); //We don't need to draw this so don't create a texture
|
|
86 |
/******************************************************************************************************/
|
|
87 |
|
|
88 |
//Fonts - Is there a way to dynamically change font size?
|
|
89 |
verdana.loadFont("verdana.ttf", 8, true, true); //Font used for small images
|
|
90 |
sidebarTXT.loadFont("verdana.ttf", 8, true, true);
|
|
91 |
bigvideo.loadFont("verdana.ttf", 13, true, true); //Font used for big images.
|
|
92 |
|
|
93 |
//Static Images
|
|
94 |
background.loadImage("images/background.jpg"); //Main (Temp?) Background
|
|
95 |
|
|
96 |
gui = ofxGui::Instance(this);
|
|
97 |
setupGUI();
|
|
98 |
|
|
99 |
calib.setup(camWidth, camHeight, &tracker);
|
|
100 |
|
|
101 |
filter->allocate( camWidth, camHeight );
|
|
102 |
|
|
103 |
printf("Tbeta is setup!\n\n");
|
| 57 |
104 |
}
|
|
105 |
|
|
106 |
/****************************************************************
|
|
107 |
* Load/Save config.xml file Settings
|
|
108 |
****************************************************************/
|
|
109 |
void TBetaBase::loadXMLSettings(){
|
|
110 |
|
|
111 |
// TODO: a seperate XML to map keyboard commands to action
|
|
112 |
message = "Loading config.xml...";
|
|
113 |
// Can this load via http?
|
|
114 |
if( XML.loadFile("config.xml")){
|
|
115 |
message = "Settings Loaded!";
|
|
116 |
}else{
|
|
117 |
//FAIL!
|
|
118 |
message = "No Settings Found...";
|
|
119 |
}
|
|
120 |
//--------------------------------------------------------------
|
|
121 |
// START BINDING XML TO VARS
|
|
122 |
//--------------------------------------------------------------
|
|
123 |
//frameRate = XML.getValue("CONFIG:APPLICATION:FRAMERATE",0);
|
|
124 |
|
|
125 |
winWidth = XML.getValue("CONFIG:WINDOW:WIDTH",0);
|
|
126 |
winHeight = XML.getValue("CONFIG:WINDOW:HEIGHT",0);
|
|
127 |
minWidth = XML.getValue("CONFIG:WINDOW:MINX",0);
|
|
128 |
minHeight = XML.getValue("CONFIG:WINDOW:MINY",0);
|
|
129 |
|
|
130 |
bcamera = XML.getValue("CONFIG:CAMERA_0:USECAMERA",0);
|
|
131 |
deviceID = XML.getValue("CONFIG:CAMERA_0:DEVICE",0);
|
|
132 |
camWidth = XML.getValue("CONFIG:CAMERA_0:WIDTH",0);
|
|
133 |
camHeight = XML.getValue("CONFIG:CAMERA_0:HEIGHT",0);
|
|
134 |
camRate = XML.getValue("CONFIG:CAMERA_0:FRAMERATE",0);
|
|
135 |
|
|
136 |
videoFileName = XML.getValue("CONFIG:VIDEO:FILENAME", "RearDI.m4v");
|
|
137 |
|
|
138 |
maxBlobs = XML.getValue("CONFIG:BLOBS:MAXNUMBER", 20);
|
|
139 |
|
|
140 |
bShowLabels = XML.getValue("CONFIG:BOOLEAN:LABELS",0);
|
|
141 |
bFastMode = XML.getValue("CONFIG:BOOLEAN:FAST",0);
|
|
142 |
bDrawOutlines = XML.getValue("CONFIG:BOOLEAN:OUTLINES",0);
|
|
143 |
|
|
144 |
filter->bLearnBakground = XML.getValue("CONFIG:BOOLEAN:LEARNBG",0);
|
|
145 |
filter->bVerticalMirror = XML.getValue("CONFIG:BOOLEAN:VMIRROR",0);
|
|
146 |
filter->bHorizontalMirror = XML.getValue("CONFIG:BOOLEAN:HMIRROR",0);
|
|
147 |
|
|
148 |
//Filters
|
|
149 |
filter->bHighpass = XML.getValue("CONFIG:BOOLEAN:HIGHPASS",1);
|
|
150 |
filter->bAmplify = XML.getValue("CONFIG:BOOLEAN:AMPLIFY", 1);
|
|
151 |
filter->bSmooth = XML.getValue("CONFIG:BOOLEAN:SMOOTH", 1);
|
|
152 |
filter->bDynamicBG = XML.getValue("CONFIG:BOOLEAN:DYNAMICBG", 1);
|
|
153 |
|
|
154 |
//GPU
|
|
155 |
bGPUMode = XML.getValue("CONFIG:BOOLEAN:GPU", 0);
|
|
156 |
|
|
157 |
//Filter Settings
|
|
158 |
filter->threshold = XML.getValue("CONFIG:INT:THRESHOLD",0);
|
|
159 |
filter->highpassBlur = XML.getValue("CONFIG:INT:HIGHPASSBLUR",0);
|
|
160 |
filter->highpassNoise = XML.getValue("CONFIG:INT:HIGHPASSNOISE",0);
|
|
161 |
filter->highpassAmp = XML.getValue("CONFIG:INT:HIGHPASSAMP",0);
|
|
162 |
filter->smooth = XML.getValue("CONFIG:INT:SMOOTH",0);
|
|
163 |
|
|
164 |
//--------------------------------------------------- TODO XML NETWORK SETTINGS
|
|
165 |
bTUIOMode = XML.getValue("CONFIG:BOOLEAN:TUIO",0);
|
|
166 |
tmpLocalHost = XML.getValue("CONFIG:NETWORK:LOCALHOST", "localhost");
|
|
167 |
tmpPort = XML.getValue("CONFIG:NETWORK:TUIOPORT_OUT", 3333);
|
|
168 |
myTUIO.setup(tmpLocalHost.c_str(), tmpPort); //have to convert tmpLocalHost to a const char*
|
|
169 |
//--------------------------------------------------------------
|
|
170 |
// END XML SETUP
|
|
171 |
}
|
|
172 |
|
|
173 |
void TBetaBase::saveConfiguration()
|
|
174 |
{
|
|
175 |
XML.setValue("CONFIG:CAMERA_0:USECAMERA", bcamera);
|
|
176 |
XML.setValue("CONFIG:CAMERA_0:DEVICE", deviceID);
|
|
177 |
XML.setValue("CONFIG:CAMERA_0:WIDTH", camWidth);
|
|
178 |
XML.setValue("CONFIG:CAMERA_0:HEIGHT", camHeight);
|
|
179 |
XML.setValue("CONFIG:CAMERA_0:FRAMERATE", camRate);
|
|
180 |
|
|
181 |
XML.setValue("CONFIG:BOOLEAN:PRESSURE",bShowPressure);
|
|
182 |
XML.setValue("CONFIG:BOOLEAN:LABELS",bShowLabels);
|
|
183 |
XML.setValue("CONFIG:BOOLEAN:OUTLINES",bDrawOutlines);
|
|
184 |
XML.setValue("CONFIG:BOOLEAN:LEARNBG", filter->bLearnBakground);
|
|
185 |
XML.setValue("CONFIG:BOOLEAN:TUIO",bTUIOMode);
|
|
186 |
XML.setValue("CONFIG:BOOLEAN:VMIRROR", filter->bVerticalMirror);
|
|
187 |
XML.setValue("CONFIG:BOOLEAN:HMIRROR", filter->bHorizontalMirror);
|
|
188 |
|
|
189 |
XML.setValue("CONFIG:BOOLEAN:HIGHPASS", filter->bHighpass);
|
|
190 |
XML.setValue("CONFIG:BOOLEAN:AMPLIFY", filter->bAmplify);
|
|
191 |
XML.setValue("CONFIG:BOOLEAN:SMOOTH", filter->bSmooth);
|
|
192 |
XML.setValue("CONFIG:BOOLEAN:DYNAMICBG", filter->bDynamicBG);
|
|
193 |
|
|
194 |
XML.setValue("CONFIG:BOOLEAN:GPU", bGPUMode);
|
|
195 |
|
|
196 |
XML.setValue("CONFIG:INT:THRESHOLD", filter->threshold);
|
|
197 |
XML.setValue("CONFIG:INT:HIGHPASSBLUR", filter->highpassBlur);
|
|
198 |
XML.setValue("CONFIG:INT:HIGHPASSNOISE", filter->highpassNoise);
|
|
199 |
XML.setValue("CONFIG:INT:HIGHPASSAMP", filter->highpassAmp);
|
|
200 |
XML.setValue("CONFIG:INT:SMOOTH", filter->smooth);
|
|
201 |
|
|
202 |
// XML.setValue("CONFIG:NETWORK:LOCALHOST", *myTUIO.localHost);
|
|
203 |
// XML.setValue("CONFIG:NETWORK:TUIO_PORT_OUT",myTUIO.TUIOPort);
|
|
204 |
|
|
205 |
XML.saveFile("config.xml");
|
|
206 |
}
|
|
207 |
|
|
208 |
/******************************************************************************
|
|
209 |
* The update function runs continuously. Use it to update states and variables
|
|
210 |
*****************************************************************************/
|
|
211 |
void TBetaBase::update()
|
|
212 |
{
|
|
213 |
bNewFrame = false;
|
|
214 |
|
|
215 |
if(activeInput){
|
|
216 |
|
|
217 |
if(bcamera){
|
|
218 |
vidGrabber.grabFrame();
|
|
219 |
bNewFrame = vidGrabber.isFrameNew();
|
|
220 |
}
|
|
221 |
else{
|
|
222 |
vidPlayer.idleMovie();
|
|
223 |
bNewFrame = vidPlayer.isFrameNew();
|
|
224 |
}
|
|
225 |
|
|
226 |
if (bNewFrame)
|
|
227 |
{
|
|
228 |
ofBackground(0, 0, 0);
|
|
229 |
|
|
230 |
//Calculate FPS of Camera
|
|
231 |
frames++;
|
|
232 |
float time = ofGetElapsedTimeMillis();
|
|
233 |
if(time > (lastFPSlog + 1000)){
|
|
234 |
fps = frames;
|
|
235 |
frames = 0;
|
|
236 |
lastFPSlog = time;
|
|
237 |
}//End calculation
|
|
238 |
|
|
239 |
float beforeTime = ofGetElapsedTimeMillis();
|
|
240 |
|
|
241 |
if(bGPUMode){
|
|
242 |
grabFrameToGPU(filter->gpuSourceTex);
|
|
243 |
filter->applyGPUFilters();
|
|
244 |
contourFinder.findContours(filter->gpuReadBackImageGS, 1, (camWidth*camHeight)/25, maxBlobs, false);
|
|
245 |
}
|
|
246 |
else{
|
|
247 |
grabFrameToCPU();
|
|
248 |
filter->applyCPUFilters( processedImg );
|
|
249 |
contourFinder.findContours(processedImg, 1, (camWidth*camHeight)/25, maxBlobs, false);
|
|
250 |
}
|
|
251 |
|
|
252 |
//Track found contours/blobss
|
|
253 |
tracker.track(&contourFinder);
|
|
254 |
//get DSP time
|
|
255 |
differenceTime = ofGetElapsedTimeMillis() - beforeTime;
|
|
256 |
|
|
257 |
//Dynamic Background subtraction LearRate
|
|
258 |
if(filter->bDynamicBG){
|
|
259 |
filter->fLearnRate = 0.01f; //If there are no blobs, add the background faster.
|
|
260 |
if(contourFinder.nBlobs > 0){ //If there ARE blobs, add the background slower.
|
|
261 |
filter->fLearnRate = 0.0003f;
|
|
262 |
}
|
|
263 |
}//End Background Learning rate
|
|
264 |
|
|
265 |
if(bTUIOMode){
|
|
266 |
//We're not using frameseq right now with OSC
|
|
267 |
//myTUIO.update();
|
|
268 |
|
|
269 |
//Start sending OSC
|
|
270 |
myTUIO.sendOSC();
|
|
271 |
}
|
|
272 |
}
|
|
273 |
}
|
|
274 |
}
|
| 58 |
275 |
|
| 59 |
276 |
/************************************************
|
| 60 |
|
* FILTERS
|
|
277 |
* Frame Grab
|
| 61 |
278 |
************************************************/
|
| 62 |
|
void TBetaBase::applyGPUImageFilters(){
|
| 63 |
279 |
|
| 64 |
|
if (bLearnBakground == true){
|
| 65 |
|
camera.grabFrameToGPU(gpuBGTex);
|
| 66 |
|
bLearnBakground = false;
|
| 67 |
|
}
|
| 68 |
|
|
| 69 |
|
GLuint processedTex;
|
| 70 |
|
|
| 71 |
|
//tmp = contrastFilter->apply(gpuBGTex);
|
| 72 |
|
processedTex = subtractFilter->apply(gpuSourceTex, gpuBGTex);
|
| 73 |
|
|
| 74 |
|
if(bSmooth){//Smooth
|
| 75 |
|
gaussHFilter->parameters["kernel_size"]->value = (float)smooth;
|
| 76 |
|
gaussVFilter->parameters["kernel_size"]->value = (float)smooth;
|
| 77 |
|
processedTex = gaussHFilter->apply(processedTex);
|
| 78 |
|
processedTex = gaussVFilter->apply(processedTex);
|
| 79 |
|
}
|
| 80 |
|
|
| 81 |
|
if(bHighpass){//Highpass
|
| 82 |
|
gaussHFilter2->parameters["kernel_size"]->value = (float)highpassBlur;
|
| 83 |
|
gaussVFilter2->parameters["kernel_size"]->value = (float)highpassBlur;
|
| 84 |
|
processedTex = gaussHFilter2->apply(processedTex);
|
| 85 |
|
processedTex = gaussVFilter2->apply(processedTex);
|
| 86 |
|
processedTex = subtractFilter2->apply(gaussVFilter->output_texture, processedTex);
|
| 87 |
|
}
|
| 88 |
|
|
| 89 |
|
if(bAmplify){}//amplify
|
| 90 |
|
|
| 91 |
|
threshFilter->parameters["Threshold"]->value = (float)threshold / 255.0; //threshold
|
| 92 |
|
threshFilter->apply(processedTex);
|
| 93 |
|
|
| 94 |
|
//until the rest of the pipeline is fixed well just download the preprocessing result from the gpu and use that for the blob detection
|
| 95 |
|
//TODO: make this part not super slow ;)
|
| 96 |
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, threshFilter->output_buffer);
|
| 97 |
|
//glReadBuffer(gaussVFilter->output_buffer);
|
| 98 |
|
glReadPixels(0,0,camera.camWidth, camera.camHeight, GL_RGB, GL_UNSIGNED_BYTE, gpuReadBackBuffer);
|
| 99 |
|
gpuReadBackImage.setFromPixels(gpuReadBackBuffer, camera.camWidth, camera.camHeight);
|
| 100 |
|
gpuReadBackImageGS = gpuReadBackImage;
|
| 101 |
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
| 102 |
|
|
|
280 |
//Grab frame from CPU
|
|
281 |
void TBetaBase::grabFrameToCPU(){
|
|
282 |
//Set sourceImg as new camera/video frame
|
|
283 |
if(bcamera)
|
|
284 |
sourceImg.setFromPixels(vidGrabber.getPixels(), camWidth, camHeight);
|
|
285 |
else
|
|
286 |
sourceImg.setFromPixels(vidPlayer.getPixels(), camWidth, camHeight);
|
|
287 |
|
|
288 |
//convert to grayscale
|
|
289 |
processedImg = sourceImg;
|
| 103 |
290 |
}
|
| 104 |
291 |
|
| 105 |
|
|
| 106 |
|
void TBetaBase::applyImageFilters(){
|
| 107 |
|
|
| 108 |
|
processedImg = camera.sourceImg;
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
//Set Mirroring Horizontal/Vertical
|
| 112 |
|
if(bVerticalMirror || bHorizontalMirror)processedImg.mirror(bVerticalMirror, bHorizontalMirror);
|
| 113 |
|
|
| 114 |
|
if(!bFastMode)grayImg = processedImg; //for drawing
|
| 115 |
|
|
| 116 |
|
//Dynamic background with learn rate...eventually learnrate will have GUI sliders
|
| 117 |
|
if(bDynamicBG){
|
| 118 |
|
learnBackground( processedImg, grayBg, fiLearn, fLearnRate);
|
|
292 |
//Grab frame from GPU
|
|
293 |
void TBetaBase::grabFrameToGPU(GLuint target){
|
|
294 |
//grab the frame to a raw openGL texture
|
|
295 |
if(bcamera)
|
|
296 |
{
|
|
297 |
glEnable(GL_TEXTURE_2D);
|
|
298 |
//glPixelStorei(1);
|
|
299 |
glBindTexture(GL_TEXTURE_2D, target);
|
|
300 |
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, camWidth, camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, vidGrabber.getPixels());
|
|
301 |
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, camWidth, camHeight, GL_RGB, GL_UNSIGNED_BYTE, vidGrabber.getPixels());
|
|
302 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
303 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
304 |
glBindTexture(GL_TEXTURE_2D,0);
|
| 119 |
305 |
}
|
| 120 |
|
|
| 121 |
|
//Capture full background
|
| 122 |
|
if (bLearnBakground == true){
|
| 123 |
|
bgCapture( processedImg );
|
| 124 |
|
bLearnBakground = false;
|
|
306 |
else{
|
|
307 |
glEnable(GL_TEXTURE_2D);
|
|
308 |
glBindTexture(GL_TEXTURE_2D, target);
|
|
309 |
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, camWidth, camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, vidPlayer.getPixels());
|
|
310 |
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, camWidth, camHeight, GL_RGB, GL_UNSIGNED_BYTE, vidPlayer.getPixels());
|
|
311 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
312 |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
313 |
glBindTexture(GL_TEXTURE_2D,0);
|
| 125 |
314 |
}
|
| 126 |
|
|
| 127 |
|
processedImg.absDiff(grayBg, processedImg); //Background Subtraction
|
| 128 |
|
|
| 129 |
|
if(bSmooth){//Smooth
|
| 130 |
|
processedImg.blur((smooth * 2) + 1); //needs to be an odd number
|
| 131 |
|
if(!bFastMode)subtractBg = processedImg; //for drawing
|
| 132 |
|
}
|
| 133 |
|
|
| 134 |
|
if(bHighpass){//HighPass
|
| 135 |
|
processedImg.highpass(highpassBlur, highpassNoise);
|
| 136 |
|
if(!bFastMode)highpassImg = processedImg; //for drawing
|
| 137 |
|
}
|
| 138 |
|
|
| 139 |
|
if(bAmplify){//Amplify
|
| 140 |
|
processedImg.amplify(processedImg, highpassAmp);
|
| 141 |
|
if(!bFastMode)ampImg = processedImg; //for drawing
|
| 142 |
|
}
|
| 143 |
|
|
| 144 |
|
processedImg.threshold(threshold); //Threshold
|
| 145 |
|
if(!bFastMode)grayDiff = processedImg; //for drawing
|
| 146 |
315 |
}
|
| 147 |
316 |
|
|
317 |
|
|
318 |
/******************************************************************************
|
|
319 |
* The draw function paints the textures onto the screen. It runs after update.
|
|
320 |
*****************************************************************************/
|
|
321 |
void TBetaBase::draw(){
|
|
322 |
|
|
323 |
if(showConfiguration) {
|
|
324 |
|
|
325 |
//temporary. only auto draw if in fullscreen
|
|
326 |
if(bNewFrame && bFullscreen == false){drawToScreen();}
|
|
327 |
else{drawToScreen();}
|
|
328 |
|
|
329 |
if(!bCalibration)
|
|
330 |
gui->draw();
|
|
331 |
}
|
|
332 |
}
|
| 148 |
333 |
|
| 149 |
|
void TBetaBase::resetGPUTextures(){
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
delete gpuReadBackBuffer;
|
| 153 |
|
gpuReadBackBuffer = new unsigned char[camera.camWidth*camera.camHeight*3];
|
| 154 |
|
gpuReadBackImage.allocate(camera.camWidth, camera.camHeight);
|
| 155 |
|
gpuReadBackImageGS.allocate(camera.camWidth, camera.camHeight);
|
| 156 |
|
|
| 157 |
|
glEnable(GL_TEXTURE_2D);
|
| 158 |
|
glBindTexture(GL_TEXTURE_2D, gpuSourceTex);
|
| 159 |
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, camera.camWidth, camera.camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
| 160 |
|
glBindTexture(GL_TEXTURE_2D, gpuBGTex);
|
| 161 |
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, camera.camWidth, camera.camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
| 162 |
|
glBindTexture(GL_TEXTURE_2D, 0);
|
| 163 |
|
glDisable(GL_TEXTURE_2D);
|
| 164 |
|
|
| 165 |
|
subtractFilter = new ImageFilter("filters/absSubtract.xml", camera.camWidth, camera.camHeight);
|
| 166 |
|
subtractFilter2 = new ImageFilter("filters/subtract.xml", camera.camWidth, camera.camHeight);
|
| 167 |
|
contrastFilter = new ImageFilter("filters/contrast.xml", camera.camWidth, camera.camHeight);
|
| 168 |
|
gaussVFilter = new ImageFilter("filters/gaussV.xml", camera.camWidth, camera.camHeight);
|
| 169 |
|
gaussHFilter = new ImageFilter("filters/gauss.xml", camera.camWidth, camera.camHeight);
|
| 170 |
|
gaussVFilter2 = new ImageFilter("filters/gaussV2.xml", camera.camWidth, camera.camHeight);
|
| 171 |
|
gaussHFilter2 = new ImageFilter("filters/gauss2.xml", camera.camWidth, camera.camHeight);
|
| 172 |
|
threshFilter = new ImageFilter("filters/threshold.xml", camera.camWidth, camera.camHeight);
|
| 173 |
|
}
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
void TBetaBase::learnBackground( ofxCvGrayscaleImage & _giLive, ofxCvGrayscaleImage & _grayBg, ofxCvFloatImage & _fiLearn, float _fLearnRate )
|
| 178 |
|
{
|
| 179 |
|
_fiLearn.addWeighted( _giLive, _fLearnRate);
|
| 180 |
|
_grayBg = _fiLearn;
|
| 181 |
|
|
| 182 |
|
}
|
| 183 |
|
void TBetaBase::bgCapture( ofxCvGrayscaleImage & _giLive )
|
| 184 |
|
{
|
| 185 |
|
learnBackground( _giLive, grayBg, fiLearn, 1.0f);
|
| 186 |
|
}
|
| 187 |
|
|
| 188 |
|
/******************************************************************************
|
| 189 |
|
* OTHER FUNCTIONS
|
| 190 |
|
*****************************************************************************/
|
| 191 |
|
|
| 192 |
|
/****************************************************************
|
| 193 |
|
* Load/Save config.xml file Settings
|
| 194 |
|
****************************************************************/
|
| 195 |
|
void TBetaBase::loadXMLSettings(){
|
| 196 |
|
|
| 197 |
|
// TODO: a seperate XML to map keyboard commands to action
|
| 198 |
|
message = "Loading config.xml...";
|
| 199 |
|
// Can this load via http?
|
| 200 |
|
if( XML.loadFile("config.xml")){
|
| 201 |
|
message = "Settings Loaded!";
|
| 202 |
|
}else{
|
| 203 |
|
//FAIL!
|
| 204 |
|
message = "No Settings Found...";
|
| 205 |
|
}
|
| 206 |
|
//--------------------------------------------------------------
|
| 207 |
|
// START BINDING XML TO VARS
|
| 208 |
|
//--------------------------------------------------------------
|
| 209 |
|
//frameRate = XML.getValue("CONFIG:APPLICATION:FRAMERATE",0);
|
| 210 |
|
|
| 211 |
|
winWidth = XML.getValue("CONFIG:WINDOW:WIDTH",0);
|
| 212 |
|
winHeight = XML.getValue("CONFIG:WINDOW:HEIGHT",0);
|
| 213 |
|
minWidth = XML.getValue("CONFIG:WINDOW:MINX",0);
|
| 214 |
|
minHeight = XML.getValue("CONFIG:WINDOW:MINY",0);
|
| 215 |
|
|
| 216 |
|
camera.bcamera = XML.getValue("CONFIG:CAMERA_0:USECAMERA",0);
|
| 217 |
|
camera.deviceID = XML.getValue("CONFIG:CAMERA_0:DEVICE",0);
|
| 218 |
|
camera.camWidth = XML.getValue("CONFIG:CAMERA_0:WIDTH",0);
|
| 219 |
|
camera.camHeight = XML.getValue("CONFIG:CAMERA_0:HEIGHT",0);
|
| 220 |
|
camera.camRate = XML.getValue("CONFIG:CAMERA_0:FRAMERATE",0);
|
| 221 |
|
|
| 222 |
|
videoFileName = XML.getValue("CONFIG:VIDEO:FILENAME", "RearDI.m4v");
|
| 223 |
|
|
| 224 |
|
maxBlobs = XML.getValue("CONFIG:BLOBS:MAXNUMBER", 20);
|
| 225 |
|
|
| 226 |
|
bShowPressure = XML.getValue("CONFIG:BOOLEAN:PRESSURE",0);
|
| 227 |
|
|
| 228 |
|
bShowLabels = XML.getValue("CONFIG:BOOLEAN:LABELS",0);
|
| 229 |
|
bFastMode = XML.getValue("CONFIG:BOOLEAN:FAST",0);
|
| 230 |
|
bDrawOutlines = XML.getValue("CONFIG:BOOLEAN:OUTLINES",0);
|
| 231 |
|
bLearnBakground = XML.getValue("CONFIG:BOOLEAN:LEARNBG",0);
|
| 232 |
|
|
| 233 |
|
bVerticalMirror = XML.getValue("CONFIG:BOOLEAN:VMIRROR",0);
|
| 234 |
|
bHorizontalMirror = XML.getValue("CONFIG:BOOLEAN:HMIRROR",0);
|
| 235 |
|
|
| 236 |
|
//Filters
|
| 237 |
|
bHighpass = XML.getValue("CONFIG:BOOLEAN:HIGHPASS",1);
|
| 238 |
|
bAmplify = XML.getValue("CONFIG:BOOLEAN:AMPLIFY", 1);
|
| 239 |
|
bSmooth = XML.getValue("CONFIG:BOOLEAN:SMOOTH", 1);
|
| 240 |
|
bDynamicBG = XML.getValue("CONFIG:BOOLEAN:DYNAMICBG", 1);
|
| 241 |
|
|
| 242 |
|
//GPU
|
| 243 |
|
bGPUMode = XML.getValue("CONFIG:BOOLEAN:GPU", 0);
|
| 244 |
|
|
| 245 |
|
//Filter Settings
|
| 246 |
|
threshold = XML.getValue("CONFIG:INT:THRESHOLD",0);
|
| 247 |
|
highpassBlur = XML.getValue("CONFIG:INT:HIGHPASSBLUR",0);
|
| 248 |
|
highpassNoise = XML.getValue("CONFIG:INT:HIGHPASSNOISE",0);
|
| 249 |
|
highpassAmp = XML.getValue("CONFIG:INT:HIGHPASSAMP",0);
|
| 250 |
|
smooth = XML.getValue("CONFIG:INT:SMOOTH",0);
|
| 251 |
|
|
| 252 |
|
//--------------------------------------------------- TODO XML NETWORK SETTINGS
|
| 253 |
|
bTUIOMode = XML.getValue("CONFIG:BOOLEAN:TUIO",0);
|
| 254 |
|
tmpLocalHost = XML.getValue("CONFIG:NETWORK:LOCALHOST", "localhost");
|
| 255 |
|
tmpPort = XML.getValue("CONFIG:NETWORK:TUIOPORT_OUT", 3333);
|
| 256 |
|
myTUIO.setup(tmpLocalHost.c_str(), tmpPort); //have to convert tmpLocalHost to a const char*
|
| 257 |
|
//--------------------------------------------------------------
|
| 258 |
|
// END XML SETUP
|
| 259 |
|
}
|
| 260 |
|
|
| 261 |
|
void TBetaBase::saveConfiguration()
|
| 262 |
|
{
|
| 263 |
|
|
| 264 |
|
XML.setValue("CONFIG:CAMERA_0:USECAMERA", camera.bcamera);
|
| 265 |
|
XML.setValue("CONFIG:CAMERA_0:DEVICE", camera.deviceID);
|
| 266 |
|
XML.setValue("CONFIG:CAMERA_0:WIDTH", camera.camWidth);
|
| 267 |
|
XML.setValue("CONFIG:CAMERA_0:HEIGHT", camera.camHeight);
|
| 268 |
|
XML.setValue("CONFIG:CAMERA_0:FRAMERATE", camera.camRate);
|
| 269 |
|
|
| 270 |
|
XML.setValue("CONFIG:BOOLEAN:PRESSURE",bShowPressure);
|
| 271 |
|
XML.setValue("CONFIG:BOOLEAN:LABELS",bShowLabels);
|
| 272 |
|
XML.setValue("CONFIG:BOOLEAN:OUTLINES",bDrawOutlines);
|
| 273 |
|
XML.setValue("CONFIG:BOOLEAN:LEARNBG",bLearnBakground);
|
| 274 |
|
XML.setValue("CONFIG:BOOLEAN:TUIO",bTUIOMode);
|
| 275 |
|
XML.setValue("CONFIG:BOOLEAN:VMIRROR",bVerticalMirror);
|
| 276 |
|
XML.setValue("CONFIG:BOOLEAN:HMIRROR",bHorizontalMirror);
|
| 277 |
|
|
| 278 |
|
XML.setValue("CONFIG:BOOLEAN:HIGHPASS", bHighpass);
|
| 279 |
|
XML.setValue("CONFIG:BOOLEAN:AMPLIFY", bAmplify);
|
| 280 |
|
XML.setValue("CONFIG:BOOLEAN:SMOOTH", bSmooth);
|
| 281 |
|
XML.setValue("CONFIG:BOOLEAN:DYNAMICBG", bDynamicBG);
|
| 282 |
|
|
| 283 |
|
XML.setValue("CONFIG:BOOLEAN:GPU", bGPUMode);
|
| 284 |
|
|
| 285 |
|
XML.setValue("CONFIG:INT:THRESHOLD", threshold);
|
| 286 |
|
XML.setValue("CONFIG:INT:HIGHPASSBLUR", highpassBlur);
|
| 287 |
|
XML.setValue("CONFIG:INT:HIGHPASSNOISE",highpassNoise);
|
| 288 |
|
XML.setValue("CONFIG:INT:HIGHPASSAMP",highpassAmp);
|
| 289 |
|
XML.setValue("CONFIG:INT:SMOOTH", smooth);
|
| 290 |
|
|
| 291 |
|
// XML.setValue("CONFIG:NETWORK:LOCALHOST", *myTUIO.localHost);
|
| 292 |
|
// XML.setValue("CONFIG:NETWORK:TUIO_PORT_OUT",myTUIO.TUIOPort);
|
| 293 |
|
|
| 294 |
|
XML.saveFile("config.xml");
|
| 295 |
|
}
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
///lets start moving stuff from the testApp.h and testApp.cpp
|
| 299 |
|
|
| 300 |
334 |
void TBetaBase::drawToScreen(){
|
| 301 |
335 |
|
| 302 |
336 |
/*********************************
|
| ... | ... | |
| 310 |
344 |
calib.doCalibration();
|
| 311 |
345 |
}
|
| 312 |
346 |
|
| 313 |
|
|
| 314 |
|
|
| 315 |
347 |
/********************************
|
| 316 |
348 |
* IF SHOWING MAIN INTERFACE STUFF
|
| 317 |
349 |
********************************/
|
| ... | ... | |
| 332 |
364 |
|
| 333 |
365 |
ofSetColor(0xFFFFFF);
|
| 334 |
366 |
|
| 335 |
|
if(bGPUMode){
|
| 336 |
|
drawGLTexture(40, 30, 320, 240, gpuSourceTex);
|
| 337 |
|
//subtractFilter->drawOutputTexture(85, 392, 128, 96);
|
| 338 |
|
drawGLTexture(85, 392, 128, 96, gpuBGTex);
|
| 339 |
|
gaussVFilter->drawOutputTexture(235, 392, 128, 96);
|
| 340 |
|
subtractFilter2->drawOutputTexture(385, 392, 128, 96);
|
| 341 |
|
threshFilter->drawOutputTexture(535, 392, 128, 96);
|
| 342 |
|
gpuReadBackImageGS.draw(385, 30, 320, 240);
|
| 343 |
|
}
|
| 344 |
|
else
|
| 345 |
|
{
|
| 346 |
|
if(bShowPressure)
|
| 347 |
|
pressureMap.draw(40, 30, 320, 240);
|
| 348 |
|
else
|
| 349 |
|
grayImg.draw(40, 30, 320, 240);
|
|
367 |
if(bGPUMode) filter->drawGPU();
|
|
368 |
else filter->draw();
|
| 350 |
369 |
|
| 351 |
|
grayDiff.draw(385, 30, 320, 240);
|
| 352 |
|
fiLearn.draw(85, 392, 128, 96);
|
| 353 |
|
subtractBg.draw(235, 392, 128, 96);
|
| 354 |
|
highpassImg.draw(385, 392, 128, 96);
|
| 355 |
|
ampImg.draw(535, 392, 128, 96);
|
| 356 |
|
}
|
| 357 |
|
|
| 358 |
370 |
ofSetColor(0x000000);
|
| 359 |
371 |
if(bShowPressure){bigvideo.drawString("Pressure Map", 140, 20);}
|
| 360 |
372 |
else {bigvideo.drawString("Source Image", 140, 20);}
|
| ... | ... | |
| 367 |
379 |
string str = "DSP Milliseconds: ";
|
| 368 |
380 |
str+= ofToString(differenceTime, 0)+"\n\n";
|
| 369 |
381 |
|
| 370 |
|
if(camera.bcamera)
|
|
382 |
if(bcamera)
|
| 371 |
383 |
{
|
| 372 |
384 |
string str2 = "Camera Res: ";
|
| 373 |
|
str2+= ofToString(camera.vidGrabber.width, 0) + " x " + ofToString(camera.vidGrabber.height, 0) + "\n";
|
|
385 |
str2+= ofToString(vidGrabber.width, 0) + " x " + ofToString(vidGrabber.height, 0) + "\n";
|
| 374 |
386 |
string str4 = "Camera FPS: ";
|
| 375 |
387 |
str4+= ofToString(fps, 0)+"\n\n";
|
| 376 |
388 |
string str5 = "Blob Count: ";
|
| ... | ... | |
| 381 |
393 |
else
|
| 382 |
394 |
{
|
| 383 |
395 |
string str2 = "Video Res: ";
|
| 384 |
|
str2+= ofToString(camera.vidPlayer.width, 0) + " x " + ofToString(camera.vidPlayer.height, 0) + "\n";
|
|
396 |
str2+= ofToString(vidPlayer.width, 0) + " x " + ofToString(vidPlayer.height, 0) + "\n";
|
| 385 |
397 |
string str4 = "Video FPS: ";
|
| 386 |
398 |
str4+= ofToString(fps, 0)+"\n\n";
|
| 387 |
399 |
string str5 = "Blob Count: ";
|
| ... | ... | |
| 420 |
432 |
string str = "DSP Milliseconds: ";
|
| 421 |
433 |
str+= ofToString(differenceTime, 0)+"\n\n";
|
| 422 |
434 |
|
| 423 |
|
if(camera.bcamera)
|
|
435 |
if(bcamera)
|
| 424 |
436 |
{
|
| 425 |
437 |
string str2 = "Camera Res: ";
|
| 426 |
|
str2+= ofToString(camera.vidGrabber.width, 0) + " x " + ofToString(camera.vidGrabber.height, 0) + "\n";
|
|
438 |
str2+= ofToString(vidGrabber.width, 0) + " x " + ofToString(vidGrabber.height, 0) + "\n";
|
| 427 |
439 |
string str4 = "Camera FPS: ";
|
| 428 |
440 |
str4+= ofToString(fps, 0)+"\n";
|
| 429 |
441 |
ofSetColor(0xFFFFFF);
|
| ... | ... | |
| 432 |
444 |
else
|
| 433 |
445 |
{
|
| 434 |
446 |
string str2 = "Video Res: ";
|
| 435 |
|
str2+= ofToString(camera.vidPlayer.width, 0) + " x " + ofToString(camera.vidPlayer.height, 0) + "\n";
|
|
447 |
str2+= ofToString(vidPlayer.width, 0) + " x " + ofToString(vidPlayer.height, 0) + "\n";
|
| 436 |
448 |
string str4 = "Video FPS: ";
|
| 437 |
449 |
str4+= ofToString(fps, 0)+"\n";
|
| 438 |
450 |
ofSetColor(0xFFFFFF);
|
| ... | ... | |
| 470 |
482 |
{
|
| 471 |
483 |
drawFingerOutlines();
|
| 472 |
484 |
}
|
| 473 |
|
}
|
|
485 |
}
|
|
486 |
|
|
487 |
void TBetaBase::drawFingerOutlines(){
|
|
488 |
|
|
489 |
//Find the blobs
|
|
490 |
for(int i=0; i<contourFinder.nBlobs; i++)
|
|
491 |
{
|
|
492 |
//temp blob to rescale and draw on screen
|
|
493 |
ofxTBetaCvBlob drawBlob;
|
|
494 |
drawBlob = contourFinder.blobs[i];
|
|
495 |
|
|
496 |
if(bDrawOutlines)
|
|
497 |
{
|
|
498 |
//Get the contour (points) so they can be drawn
|
|
499 |
for( int j=0; j<contourFinder.blobs[i].nPts; j++ )
|
|
500 |
{
|
|
501 |
drawBlob.pts[j].x = (MAIN_WINDOW_WIDTH/camWidth) * (drawBlob.pts[j].x);
|
|
502 |
drawBlob.pts[j].y = (MAIN_WINDOW_HEIGHT/camHeight) * (drawBlob.pts[j].y);
|
|
503 |
}
|
|
504 |
|
|
505 |
//This adjusts the blob drawing for different cameras
|
|
506 |
drawBlob.boundingRect.width *= (MAIN_WINDOW_WIDTH/camWidth);
|
|
507 |
drawBlob.boundingRect.height *= (MAIN_WINDOW_HEIGHT/camHeight);
|
|
508 |
drawBlob.boundingRect.x *= (MAIN_WINDOW_WIDTH/camWidth);
|
|
509 |
drawBlob.boundingRect.y *= (MAIN_WINDOW_HEIGHT/camHeight);
|
|
510 |
|
|
511 |
//Draw contours (outlines) on the source image
|
|
512 |
drawBlob.draw(40, 30);
|
|
513 |
|
|
514 |
// ofSetColor(0x0099FF); //Make Plus Sign
|
|
515 |
// ofRect((drawBlob.centroid.x * (MAIN_WINDOW_WIDTH/camWidth)) + 40, (drawBlob.centroid.y * (MAIN_WINDOW_HEIGHT/camHeight)) - drawBlob.boundingRect.height + 30, .5, drawBlob.boundingRect.height * 2); //Horizontal Plus
|
|
516 |
// ofRect((drawBlob.centroid.x * (MAIN_WINDOW_WIDTH/camWidth)) - drawBlob.boundingRect.width + 40, (drawBlob.centroid.y * (MAIN_WINDOW_HEIGHT/camHeight)) + 30, drawBlob.boundingRect.width * 2, .5); //Vertical Plus
|
|
517 |
}
|
|
518 |
|
|
519 |
if(bShowLabels) //Show ID label;
|
|
520 |
{
|
|
521 |
float xpos = drawBlob.centroid.x * (MAIN_WINDOW_WIDTH/camWidth);
|
|
522 |
float ypos = drawBlob.centroid.y * (MAIN_WINDOW_HEIGHT/camHeight);
|
|
523 |
|
|
524 |
ofSetColor(0xCCFFCC);
|
|
525 |
char idStr[1024];
|
|
526 |
sprintf(idStr, "id: %i,(%i, %i)",drawBlob.id, drawBlob.lastCentroid.x, drawBlob.lastCentroid.y);
|
|
527 |
verdana.drawString(idStr, xpos + 365, ypos + drawBlob.boundingRect.height/2 + 45);
|
|
528 |
}
|
|
529 |
}
|
|
530 |
ofSetColor(0xFFFFFF);
|
|
531 |
}
|
| 474 |
532 |
|
| 475 |
|
|
| 476 |
|
void TBetaBase::TouchDown( ofxTBetaCvBlob b)
|
| 477 |
|
{
|
| 478 |
|
if(bTUIOMode)//If sending TUIO, add the blob to the map list
|
| 479 |
|
{
|
| 480 |
|
//if blob is not otuside calibration mesh
|
| 481 |
|
if(b.centroid.x != 0 && b.centroid.y != 0)
|
| 482 |
|
myTUIO.blobs[b.id] = b;
|
| 483 |
|
}
|
| 484 |
|
}
|
| 485 |
|
|
| 486 |
|
void TBetaBase::TouchUp( ofxTBetaCvBlob b)
|
| 487 |
|
{
|
| 488 |
|
if(bTUIOMode)//If sending TUIO delete Blobs from map list
|
| 489 |
|
{
|
| 490 |
|
std::map<int, ofxTBetaCvBlob>::iterator iter;
|
| 491 |
|
for(iter = myTUIO.blobs.begin(); iter != myTUIO.blobs.end(); iter++)
|
| 492 |
|
{
|
| 493 |
|
if(iter->second.id == b.id)
|
| 494 |
|
{
|
| 495 |
|
myTUIO.blobs.erase(iter);
|
| 496 |
|
break;
|
| 497 |
|
}
|
| 498 |
|
}
|
| 499 |
|
}
|
| 500 |
|
}
|
| 501 |
|
|
| 502 |
|
void TBetaBase::TouchMoved( ofxTBetaCvBlob b)
|
| 503 |
|
{
|
| 504 |
|
//printf("b: %f, %f\n", b.centroid.x, b.centroid.y);
|
| 505 |
|
if(bTUIOMode)//If sending TUIO, add the blob to the map list
|
| 506 |
|
{
|
| 507 |
|
//if blob is not otuside calibration mesh
|
| 508 |
|
if(b.centroid.x != 0 && b.centroid.y != 0)
|
| 509 |
|
myTUIO.blobs[b.id] = b;
|
| 510 |
|
}
|
| 511 |
|
}
|
| 512 |
|
|
| 513 |
|
|
| 514 |
|
|
| 515 |
|
/******************************************************************************
|
| 516 |
|
* The setup function is run once to perform initializations in the application
|
| 517 |
|
*****************************************************************************/
|
| 518 |
|
void TBetaBase::setup()
|
| 519 |
|
{
|
| 520 |
|
//set the title to 'tbeta'
|
| 521 |
|
ofSetWindowTitle("tbeta");
|
| 522 |
|
|
| 523 |
|
//removes the 'x' button on windows which causes a crash due to a GLUT bug
|
| 524 |
|
#ifdef TARGET_WIN32
|
| 525 |
|
HWND hwndConsole = FindWindowA(NULL, "tbeta");
|
| 526 |
|
HMENU hMnu = ::GetSystemMenu(hwndConsole, FALSE);
|
| 527 |
|
RemoveMenu(hMnu, SC_CLOSE, MF_BYCOMMAND);
|
| 528 |
|
#endif
|
| 529 |
|
|
| 530 |
|
|
| 531 |
|
/********************
|
| 532 |
|
* Initalize Variables
|
| 533 |
|
*********************/
|
| 534 |
|
// calibrationParticle.loadImage("images/particle.png");
|
| 535 |
|
// calibrationParticle.setUseTexture(true);
|
| 536 |
|
|
| 537 |
|
//Background Subtraction Learning Rate
|
| 538 |
|
fLearnRate = 0.0001f;
|
| 539 |
|
//Intialize FPS variables
|
| 540 |
|
frames = 0;
|
| 541 |
|
fps = 0;
|
| 542 |
|
lastFPSlog = 0;
|
| 543 |
|
//Calibration Booleans
|
| 544 |
|
bCalibration= false;
|
| 545 |
|
|
| 546 |
|
differenceTime = 0;
|
| 547 |
|
|
| 548 |
|
bDrawVideo = true;
|
| 549 |
|
bFullscreen = false;
|
| 550 |
|
ofSetBackgroundAuto(false);
|
| 551 |
|
|
| 552 |
|
//Load Settings from config.xml file
|
| 553 |
|
loadXMLSettings();
|
| 554 |
|
|
| 555 |
|
//Setup Window Properties
|
| 556 |
|
ofSetWindowShape(winWidth,winHeight);
|
| 557 |
|
ofSetFrameRate(camera.camRate * 1.4); //This will be based on camera fps in the future
|
| 558 |
|
ofSetVerticalSync(false); //Set vertical sync to false for better performance
|
| 559 |
|
|
| 560 |
|
//Pick the Source - camera or video
|
| 561 |
|
if(camera.bcamera)
|
| 562 |
|
{
|
| 563 |
|
activeInput = true;
|
| 564 |
|
camera.vidGrabber.listDevices();
|
| 565 |
|
camera.vidGrabber.setDeviceID(camera.deviceID);
|
| 566 |
|
camera.vidGrabber.setVerbose(true);
|
| 567 |
|
camera.vidGrabber.initGrabber(camera.camWidth,camera.camHeight);
|
| 568 |
|
int grabW = camera.vidGrabber.width;
|
| 569 |
|
int grabH = camera.vidGrabber.height;
|
| 570 |
|
printf("Camera Mode\nAsked for %i by %i - actual size is %i by %i \n\n", camera.camWidth, camera.camHeight, grabW, grabH);
|
| 571 |
|
}
|
| 572 |
|
else
|
| 573 |
|
{
|
| 574 |
|
activeInput = true;
|
| 575 |
|
camera.vidPlayer.loadMovie("test_videos/" + videoFileName);
|
| 576 |
|
camera.vidPlayer.play();
|
| 577 |
|
printf("Video Mode\n");
|
| 578 |
|
camera.camHeight = camera.vidPlayer.height;
|
| 579 |
|
camera.camWidth = camera.vidPlayer.width;
|
| 580 |
|
}
|
| 581 |
|
|
| 582 |
|
/*****************************************************************************************************
|
| 583 |
|
* Allocate images (needed for drawing/processing images) ----Most of These won't be needed in the end
|
| 584 |
|
******************************************************************************************************/
|
| 585 |
|
processedImg.allocate(camera.camWidth, camera.camHeight); //main Image that'll be processed.
|
| 586 |
|
processedImg.setUseTexture(false);
|
| 587 |
|
camera.sourceImg.allocate(camera.camWidth, camera.camHeight); //Source Image
|
| 588 |
|
camera.sourceImg.setUseTexture(false); //We don't need to draw this so don't create a texture
|
| 589 |
|
|
| 590 |
|
//These images are used for drawing only
|
| 591 |
|
grayImg.allocate(camera.camWidth, camera.camHeight); //Gray Image
|
| 592 |
|
grayBg.allocate(camera.camWidth, camera.camHeight); //Background Image
|
| 593 |
|
subtractBg.allocate(camera.camWidth, camera.camHeight); //Background After subtraction
|
| 594 |
|
grayDiff.allocate(camera.camWidth, camera.camHeight); //Difference Image between Background and Source
|
| 595 |
|
highpassImg.allocate(camera.camWidth, camera.camHeight); //Highpass Image
|
| 596 |
|
ampImg.allocate(camera.camWidth, camera.camHeight); //Amplied Image
|
| 597 |
|
fiLearn.allocate(camera.camWidth, camera.camHeight); //ofxFloatImage used for simple dynamic background subtracti
|
| 598 |
|
// fiLearn.setUseTexture(false);
|
| 599 |
|
pressureMap.allocate(camera.camWidth, camera.camHeight); //Pressure Map Image
|
| 600 |
|
|
| 601 |
|
/********************************************************************************************************/
|
| 602 |
|
|
| 603 |
|
|
| 604 |
|
/**********************************************************/
|
| 605 |
|
//GPU stuff initialization
|
| 606 |
|
/**********************************************************/
|
| 607 |
|
glGenTextures(1, &gpuSourceTex);
|
| 608 |
|
glGenTextures(1, &gpuBGTex);
|
| 609 |
|
|
| 610 |
|
//initialize texture once with glTexImage2D so we can use gltexSubImage2D afetrwards (fastser)
|
| 611 |
|
glEnable(GL_TEXTURE_2D);
|
| 612 |
|
glBindTexture(GL_TEXTURE_2D, gpuSourceTex);
|
| 613 |
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, camera.camWidth, camera.camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
| 614 |
|
glBindTexture(GL_TEXTURE_2D, gpuBGTex);
|
| 615 |
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, camera.camWidth, camera.camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
| 616 |
|
glBindTexture(GL_TEXTURE_2D, 0);
|
| 617 |
|
glDisable(GL_TEXTURE_2D);
|
| 618 |
|
|
| 619 |
|
camera.grabFrameToGPU(gpuBGTex);
|
| 620 |
|
|
| 621 |
|
//so very inefficient..but only for now..until i fix the gpu blob detection and geoemtry shader for variable length output
|
| 622 |
|
gpuReadBackBuffer = new unsigned char[camera.camWidth*camera.camHeight*3];
|
| 623 |
|
gpuReadBackImage.allocate(camera.camWidth, camera.camHeight);
|
| 624 |
|
gpuReadBackImageGS.allocate(camera.camWidth, camera.camHeight);
|
| 625 |
|
|
| 626 |
|
subtractFilter = new ImageFilter("filters/absSubtract.xml", camera.camWidth, camera.camHeight);
|
| 627 |
|
subtractFilter2 = new ImageFilter("filters/subtract.xml", camera.camWidth, camera.camHeight);
|
| 628 |
|
contrastFilter = new ImageFilter("filters/contrast.xml", camera.camWidth, camera.camHeight);
|
| 629 |
|
gaussVFilter = new ImageFilter("filters/gaussV.xml", camera.camWidth, camera.camHeight);
|
| 630 |
|
gaussHFilter = new ImageFilter("filters/gauss.xml", camera.camWidth, camera.camHeight);
|
| 631 |
|
gaussVFilter2 = new ImageFilter("filters/gaussV2.xml", camera.camWidth, camera.camHeight);
|
| 632 |
|
gaussHFilter2 = new ImageFilter("filters/gauss2.xml", camera.camWidth, camera.camHeight);
|
| 633 |
|
threshFilter = new ImageFilter("filters/threshold.xml", camera.camWidth, camera.camHeight);
|
| 634 |
|
|
| 635 |
|
/**********************************************************/
|
| 636 |
|
|
| 637 |
|
//Fonts - Is there a way to dynamically change font size?
|
| 638 |
|
verdana.loadFont("verdana.ttf", 8, true, true); //Font used for small images
|
| 639 |
|
sidebarTXT.loadFont("verdana.ttf", 8, true, true);
|
| 640 |
|
bigvideo.loadFont("verdana.ttf", 13, true, true); //Font used for big images.
|
| 641 |
|
|
| 642 |
|
//Static Images
|
| 643 |
|
background.loadImage("images/background.jpg"); //Main (Temp?) Background
|
| 644 |
|
|
| 645 |
|
gui = ofxGui::Instance(this);
|
| 646 |
|
setupGUI();
|
| 647 |
|
|
| 648 |
|
|
| 649 |
|
|
| 650 |
|
calib.setup(camera.camWidth, camera.camHeight, &tracker);
|
| 651 |
|
|
| 652 |
|
|
| 653 |
|
printf("Tbeta pplication is setup!\n\n");
|
| 654 |
|
}
|
| 655 |
|
|
| 656 |
|
|
| 657 |
|
/******************************************************************************
|
| 658 |
|
* The update function runs continuously. Use it to update states and variables
|
| 659 |
|
*****************************************************************************/
|
| 660 |
|
void TBetaBase::update()
|
| 661 |
|
{
|
| 662 |
|
bNewFrame = false;
|
| 663 |
|
|
| 664 |
|
if(activeInput){
|
| 665 |
|
|
| 666 |
|
if(camera.bcamera){
|
| 667 |
|
camera.vidGrabber.grabFrame();
|
| 668 |
|
bNewFrame = camera.vidGrabber.isFrameNew();
|
| 669 |
|
}
|
| 670 |
|
else{
|
| 671 |
|
camera.vidPlayer.idleMovie();
|
| 672 |
|
bNewFrame = camera.vidPlayer.isFrameNew();
|
| 673 |
|
}
|
| 674 |
|
|
| 675 |
|
if (bNewFrame)
|
| 676 |
|
{
|
| 677 |
|
ofBackground(0, 0, 0);
|
| 678 |
|
|
| 679 |
|
//Calculate FPS of Camera
|
| 680 |
|
frames++;
|
| 681 |
|
float time = ofGetElapsedTimeMillis();
|
| 682 |
|
if(time > (lastFPSlog + 1000)){
|
| 683 |
|
fps = frames;
|
| 684 |
|
frames = 0;
|
| 685 |
|
lastFPSlog = time;
|
| 686 |
|
}//End calculation
|
| 687 |
|
|
| 688 |
|
|
| 689 |
|
float beforeTime = ofGetElapsedTimeMillis();
|
| 690 |
|
if(bGPUMode){
|
| 691 |
|
camera.grabFrameToGPU(gpuSourceTex);
|
| 692 |
|
applyGPUImageFilters();
|
| 693 |
|
contourFinder.findContours(gpuReadBackImageGS, 1, (camera.camWidth*camera.camHeight)/25, maxBlobs, false);
|
| 694 |
|
}
|
| 695 |
|
else{
|
| 696 |
|
camera.grabFrameToCPU();
|
| 697 |
|
applyImageFilters();
|
| 698 |
|
contourFinder.findContours(processedImg, 1, (camera.camWidth*camera.camHeight)/25, maxBlobs, false);
|
| 699 |
|
}
|
| 700 |
|
|
| 701 |
|
//Track found contours/blobss
|
| 702 |
|
tracker.track(&contourFinder);
|
| 703 |
|
//get DSP time
|
| 704 |
|
differenceTime = ofGetElapsedTimeMillis() - beforeTime;
|
| 705 |
|
|
| 706 |
|
//Dynamic Background subtraction LearRate
|
| 707 |
|
if(bDynamicBG){
|
| 708 |
|
fLearnRate = 0.01f; //If there are no blobs, add the background faster.
|
| 709 |
|
if(contourFinder.nBlobs > 0){ //If there ARE blobs, add the background slower.
|
| 710 |
|
fLearnRate = 0.0003f;
|
| 711 |
|
}
|
| 712 |
|
}//End Background Learning rate
|
| 713 |
|
|
| 714 |
|
if(bTUIOMode){
|
| 715 |
|
//We're not using frameseq right now with OSC
|
| 716 |
|
//myTUIO.update();
|
| 717 |
|
|
| 718 |
|
//Start sending OSC
|
| 719 |
|
myTUIO.sendOSC();
|
| 720 |
|
}
|
| 721 |
|
}
|
| 722 |
|
}
|
| 723 |
|
}
|
| 724 |
|
|
| 725 |
|
/******************************************************************************
|
| 726 |
|
* The draw function paints the textures onto the screen. It runs after update.
|
| 727 |
|
*****************************************************************************/
|
| 728 |
|
void TBetaBase::draw(){
|
| 729 |
|
|
| 730 |
|
if(showConfiguration) {
|
| 731 |
|
|
| 732 |
|
//temporary. only auto draw if in fullscreen
|
| 733 |
|
if(bNewFrame && bFullscreen == false){drawToScreen();}
|
| 734 |
|
else{drawToScreen();}
|
| 735 |
|
|
| 736 |
|
if(!bCalibration)
|
| 737 |
|
gui->draw();
|
| 738 |
|
|
| 739 |
|
ofSetColor(180, 220, 180, 180);
|
| 740 |
|
ofFill();
|
| 741 |
|
ofRect(ofGetWidth() - 200,ofGetHeight() - 14, 200, 14);
|
| 742 |
|
|
| 743 |
|
ofSetColor(0x000000);
|
| 744 |
|
ofDrawBitmapString("| ~ |tbeta.nuigroup.com", ofGetWidth() - 200, ofGetHeight() - 2);
|
| 745 |
|
|
| 746 |
|
|
| 747 |
|
}
|
| 748 |
|
}
|
| 749 |
|
|
| 750 |
533 |
/*****************************************************************************
|
| 751 |
534 |
* KEY EVENTS
|
| 752 |
535 |
*****************************************************************************/
|
| 753 |
536 |
void TBetaBase::keyPressed(int key) {
|
| 754 |
537 |
if(showConfiguration) {
|
| 755 |
|
switch(key)
|
| 756 |
|
{
|
| 757 |
|
case 'b':
|
| 758 |
|
bLearnBakground = true;
|
| 759 |
|
break;
|
| 760 |
|
case 'o':
|
| 761 |
|
bDrawOutlines ? bDrawOutlines = false : bDrawOutlines = true;
|
| 762 |
|
gui->update(appPtr->trackedPanel_outlines, kofxGui_Set_Bool, &appPtr->bDrawOutlines, sizeof(bool));
|
| 763 |
|
break;
|
| 764 |
|
case 'h':
|
| 765 |
|
bHorizontalMirror ? bHorizontalMirror = false : bHorizontalMirror = true;
|
| 766 |
|
gui->update(appPtr->propertiesPanel_flipH, kofxGui_Set_Bool, &appPtr->bHorizontalMirror, sizeof(bool));
|
| 767 |
|
break;
|
| 768 |
|
case 'j':
|
| 769 |
|
bVerticalMirror ? bVerticalMirror = false : bVerticalMirror = true;
|
| 770 |
|
gui->update(appPtr->propertiesPanel_flipV, kofxGui_Set_Bool, &appPtr->bVerticalMirror, sizeof(bool));
|
| 771 |
|
break;
|
| 772 |
|
case 't':
|
| 773 |
|
if(!bCalibration && bTUIOMode)
|
| 774 |
|
{
|
| 775 |
|
bTUIOMode = false;
|
| 776 |
|
myTUIO.blobs.clear();
|
| 777 |
|
gui->update(appPtr->optionPanel_tuio, kofxGui_Set_Bool, &appPtr->bTUIOMode, sizeof(bool));
|
| 778 |
|
}
|
| 779 |
|
else
|
| 780 |
|
{
|
| 781 |
|
bTUIOMode = true;
|
| 782 |
|
gui->update(appPtr->optionPanel_tuio, kofxGui_Set_Bool, &appPtr->bTUIOMode, sizeof(bool));
|
| 783 |
|
}
|
| 784 |
|
break;
|
| 785 |
|
case 'g':
|
| 786 |
|
bGPUMode ? bGPUMode = false : bGPUMode = true;
|
| 787 |
|
gui->update(appPtr->gpuPanel_use, kofxGui_Set_Bool, &appPtr->bGPUMode, sizeof(bool));
|
| 788 |
|
bLearnBakground = true;
|
| 789 |
|
break;
|
| 790 |
|
case 'v':
|
| 791 |
|
if(camera.bcamera)
|
| 792 |
|
camera.vidGrabber.videoSettings();
|
| 793 |
|
break;
|
| 794 |
|
case 'l':
|
| 795 |
|
bShowLabels ? bShowLabels = false : bShowLabels = true;
|
| 796 |
|
gui->update(appPtr->trackedPanel_ids, kofxGui_Set_Bool, &appPtr->bShowLabels, sizeof(bool));
|
| 797 |
|
break;
|
| 798 |
|
case 'p':
|
| 799 |
|
bShowPressure ? bShowPressure = false : bShowPressure = true;
|
| 800 |
|
break;
|
| 801 |
|
case ' ':
|
| 802 |
|
if(bFastMode)
|
| 803 |
|
{
|
| 804 |
|
bFastMode = false;
|
| 805 |
|
ofSetWindowShape(950,600); //default size
|
| 806 |
|
//ofSetWindowTitle("Configuration");
|
| 807 |
|
}
|
| 808 |
|
else
|
| 809 |
|
{
|
| 810 |
|
bFastMode = true;
|
| 811 |
|
ofSetWindowShape(190,155); //minimized size
|
| 812 |
|
//ofSetWindowTitle("Mini");
|
| 813 |
|
}
|
| 814 |
|
break;
|
| 815 |
|
/***********************
|
| 816 |
|
* Keys for Calibration
|
| 817 |
|
***********************/
|
| 818 |
|
case 'x': //Begin Calibrating
|
| 819 |
|
if(bCalibration){
|
| 820 |
|
bCalibration = false;
|
| 821 |
|
calib.calibrating = false;
|
| 822 |
|
if(bFullscreen == true) ofToggleFullscreen(); bFullscreen = false; ofSetBackgroundAuto(false);
|
| 823 |
|
}
|
| 824 |
|
break;
|
|
538 |
switch(key)
|
|
539 |
{
|
|
540 |
case 'b':
|
|
541 |
filter->bLearnBakground = true;
|
|
542 |
break;
|
|
543 |
case 'o':
|
|
544 |
bDrawOutlines ? bDrawOutlines = false : bDrawOutlines = true;
|
|
545 |
gui->update(appPtr->trackedPanel_outlines, kofxGui_Set_Bool, &appPtr->bDrawOutlines, sizeof(bool));
|
|
546 |
break;
|
|
547 |
case 'h':
|
|
548 |
bHorizontalMirror ? bHorizontalMirror = false : bHorizontalMirror = true;
|
|
549 |
gui->update(appPtr->propertiesPanel_flipH, kofxGui_Set_Bool, &appPtr->bHorizontalMirror, sizeof(bool));
|
|
550 |
break;
|
|
551 |
case 'j':
|
|
552 |
bVerticalMirror ? bVerticalMirror = false : bVerticalMirror = true;
|
|
553 |
gui->update(appPtr->propertiesPanel_flipV, kofxGui_Set_Bool, &appPtr->bVerticalMirror, sizeof(bool));
|
|
554 |
break;
|
|
555 |
case 't':
|
|
556 |
if(!bCalibration && bTUIOMode)
|
|
557 |
{
|
|
558 |
bTUIOMode = false;
|
|
559 |
myTUIO.blobs.clear();
|
|
560 |
gui->update(appPtr->optionPanel_tuio, kofxGui_Set_Bool, &appPtr->bTUIOMode, sizeof(bool));
|
|
561 |
}
|
|
562 |
else
|
|
563 |
{
|
|
564 |
bTUIOMode = true;
|
|
565 |
gui->update(appPtr->optionPanel_tuio, kofxGui_Set_Bool, &appPtr->bTUIOMode, sizeof(bool));
|
|
566 |
}
|
|
567 |
break;
|
|
568 |
case 'g':
|
|
569 |
bGPUMode ? bGPUMode = false : bGPUMode = true;
|
|
570 |
gui->update(appPtr->gpuPanel_use, kofxGui_Set_Bool, &appPtr->bGPUMode, sizeof(bool));
|
|
571 |
filter->bLearnBakground = true;
|
|
572 |
break;
|
|
573 |
case 'v':
|
|
574 |
if(bcamera)
|
|
575 |
vidGrabber.videoSettings();
|
|
576 |
break;
|
|
577 |
case 'l':
|
|
578 |
bShowLabels ? bShowLabels = false : bShowLabels = true;
|
|
579 |
gui->update(appPtr->trackedPanel_ids, kofxGui_Set_Bool, &appPtr->bShowLabels, sizeof(bool));
|
|
580 |
break;
|
|
581 |
case 'p':
|
|
582 |
bShowPressure ? bShowPressure = false : bShowPressure = true;
|
|
583 |
break;
|
|
584 |
case ' ':
|
|
585 |
if(bFastMode)
|
|
586 |
{
|
|
587 |
bFastMode = false;
|
|
588 |
ofSetWindowShape(950,600); //default size
|
|
589 |
//ofSetWindowTitle("Configuration");
|
|
590 |
}
|
|
591 |
else
|
|
592 |
{
|
|
593 |
bFastMode = true;
|
|
594 |
ofSetWindowShape(190,155); //minimized size
|
|
595 |
//ofSetWindowTitle("Mini");
|
|
596 |
}
|
|
597 |
break;
|
|
598 |
/***********************
|
|
599 |
* Keys for Calibration
|
|
600 |
***********************/
|
|
601 |
case 'x': //Begin Calibrating
|
|
602 |
if(bCalibration){
|
|
603 |
bCalibration = false;
|
|
604 |
calib.calibrating = false;
|
|
605 |
if(bFullscreen == true) ofToggleFullscreen(); bFullscreen = false; ofSetBackgroundAuto(false);
|
|
606 |
}
|
|
607 |
break;
|
| 825 |
608 |
}
|
| 826 |
609 |
}
|
| 827 |
610 |
}
|
| 828 |
611 |
|
| 829 |
|
|
| 830 |
612 |
void TBetaBase::keyReleased(int key){
|
| 831 |
613 |
|
| 832 |
614 |
if(showConfiguration)
|
| ... | ... | |
| 840 |
622 |
}
|
| 841 |
623 |
|
| 842 |
624 |
if( key == '~' || key == '`') showConfiguration = !showConfiguration;
|
| 843 |
|
}
|
|
625 |
}
|
|
626 |
|
|
627 |
/*****************************************************************************
|
|
628 |
* Touch EVENTS
|
|
629 |
*****************************************************************************/
|
|
630 |
void TBetaBase::TouchDown( ofxTBetaCvBlob b)
|
|
631 |
{
|
|
632 |
if(bTUIOMode)//If sending TUIO, add the blob to the map list
|
|
633 |
{
|
|
634 |
//if blob is not otuside calibration mesh
|
|
635 |
if(b.centroid.x != 0 && b.centroid.y != 0)
|
|
636 |
myTUIO.blobs[b.id] = b;
|
|
637 |
}
|
|
638 |
}
|
|
639 |
|
|
640 |
void TBetaBase::TouchUp( ofxTBetaCvBlob b)
|
|
641 |
{
|
|
642 |
if(bTUIOMode)//If sending TUIO delete Blobs from map list
|
|
643 |
{
|
|
644 |
std::map<int, ofxTBetaCvBlob>::iterator iter;
|
|
645 |
for(iter = myTUIO.blobs.begin(); iter != myTUIO.blobs.end(); iter++)
|
|
646 |
{
|