root / trunk / tbeta / Windows / addons / ofxTBeta / Tracking / tracking.h @ 66
View | Annotate | Download (1.4 KB)
| 1 | /*
|
|---|---|
| 2 | * tracking.h |
| 3 | * |
| 4 | * Created by Ramsin Khoshabeh on 5/4/08. |
| 5 | * Copyright 2008 risenparadigm. All rights reserved. |
| 6 | * |
| 7 | * Changelog: |
| 8 | * 08/15/08 -- Fixed a major bug in the track algorithm |
| 9 | */ |
| 10 | |
| 11 | #ifndef __TRACKING
|
| 12 | #define __TRACKING
|
| 13 | |
| 14 | #include <list> |
| 15 | #include <map> |
| 16 | |
| 17 | #include "ofxTBetaCvContourFinder.h" |
| 18 | |
| 19 | #include "../TouchMessenger.h" |
| 20 | |
| 21 | #include "../Calibration/calibrationB.h" |
| 22 | |
| 23 | class deltaTime |
| 24 | {
|
| 25 | public:
|
| 26 | float time, lastTime;
|
| 27 | |
| 28 | deltaTime() {
|
| 29 | time= 0.0f; |
| 30 | timeOne=0.0f; |
| 31 | switcher=true;
|
| 32 | } |
| 33 | ~deltaTime() {
|
| 34 | } |
| 35 | |
| 36 | void countTime() {
|
| 37 | if(switcher) {
|
| 38 | timeOne = 0.0f; |
| 39 | timeOne = ofGetElapsedTimeMillis(); // get the first value
|
| 40 | switcher = !switcher; //flip teh switchez!
|
| 41 | } else {
|
| 42 | time = ofGetElapsedTimeMillis() - timeOne; // diff between this and that ^
|
| 43 | switcher = !switcher; // more flipzz
|
| 44 | lastTime = time; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | private:
|
| 49 | float timeOne;
|
| 50 | bool switcher;
|
| 51 | }; |
| 52 | |
| 53 | class BlobTracker : public TouchListener |
| 54 | {
|
| 55 | |
| 56 | public:
|
| 57 | |
| 58 | BlobTracker(); |
| 59 | |
| 60 | deltaTime dTime; |
| 61 | |
| 62 | calibrationB* calibrate; |
| 63 | |
| 64 | bool isCalibrating;
|
| 65 | |
| 66 | void passInCalibration(calibrationB* calibrate);
|
| 67 | |
| 68 | //assigns IDs to each blob in the contourFinder
|
| 69 | void track(ofxTBetaCvContourFinder* newBlobs);
|
| 70 | int trackKnn(ofxTBetaCvContourFinder *newBlobs, ofxTBetaCvBlob *track, int k, double thresh); |
| 71 | |
| 72 | private:
|
| 73 | |
| 74 | std::vector<ofxTBetaCvBlob> trackedBlobs; //tracked blobs
|
| 75 | int IDCounter; //counter of last blob |
| 76 | int fightMongrel;
|
| 77 | }; |
| 78 | |
| 79 | #endif
|
