root / trunk / tbeta / Windows / addons / ofxTBeta / Tracking / ofxTBetaCvBlob.h @ 66
View | Annotate | Download (2.4 KB)
| 1 | /*
|
|---|---|
| 2 | * ofxTBetaCvBlob.h |
| 3 | * openFrameworks |
| 4 | * |
| 5 | * A blob is a homogenous patch represented by a polygonal contour. |
| 6 | * Typically a blob tracker uses the contour to figure out the blob's |
| 7 | * persistence and "upgrades" it with ids and other temporal |
| 8 | * information. |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #ifndef _BLOB_H
|
| 13 | #define _BLOB_H
|
| 14 | |
| 15 | #include <vector> |
| 16 | |
| 17 | class ofxTBetaCvBlob {
|
| 18 | |
| 19 | public:
|
| 20 | |
| 21 | float area;
|
| 22 | float length;
|
| 23 | ofRectangle boundingRect; |
| 24 | ofRectangle angleBoundingRect; |
| 25 | ofPoint centroid, lastCentroid, D; |
| 26 | bool hole;
|
| 27 | |
| 28 | float age; //how long the blob has been at war |
| 29 | float sitting; //how long hes been sitting in the same place |
| 30 | |
| 31 | bool simulated;
|
| 32 | |
| 33 | float maccel;
|
| 34 | |
| 35 | vector <ofPoint> pts; // the contour of the blob
|
| 36 | int nPts; // number of pts; |
| 37 | int id;
|
| 38 | float angle;
|
| 39 | |
| 40 | //----------------------------------------
|
| 41 | ofxTBetaCvBlob() {
|
| 42 | area = 0.0f; |
| 43 | length = 0.0f; |
| 44 | hole = false;
|
| 45 | nPts = 0;
|
| 46 | simulated = false;
|
| 47 | age = 0.0f; |
| 48 | sitting = 0.0f; |
| 49 | } |
| 50 | |
| 51 | //----------------------------------------
|
| 52 | void draw(float x = 0, float y = 0){ |
| 53 | |
| 54 | /* //draw contours
|
| 55 | ofNoFill(); |
| 56 | ofSetColor(0xFF00FF); |
| 57 | ofBeginShape(); |
| 58 | for (int i = 0; i < nPts; i++){
|
| 59 | ofVertex(x + pts[i].x, y + pts[i].y); |
| 60 | } |
| 61 | ofEndShape(true); |
| 62 | */ |
| 63 | //draw angled bounding box with cross-hair
|
| 64 | glPushMatrix(); |
| 65 | ofSetColor(0xFF0099);
|
| 66 | glTranslatef(x + angleBoundingRect.x, y + angleBoundingRect.y, 0.0f); |
| 67 | glRotatef(-angle, 0.0f, 0.0f, 1.0f); |
| 68 | glTranslatef(-(x + angleBoundingRect.x), -(y + angleBoundingRect.y), 0.0f); |
| 69 | ofRect(x + angleBoundingRect.x - angleBoundingRect.width/2, y + angleBoundingRect.y - angleBoundingRect.height/2, angleBoundingRect.width, angleBoundingRect.height); |
| 70 | |
| 71 | ofSetColor(0x0099FF);
|
| 72 | ofRect(x + angleBoundingRect.x, y + angleBoundingRect.y - angleBoundingRect.height, 1, angleBoundingRect.height * 2); //Horizontal Plus |
| 73 | ofRect(x + angleBoundingRect.x - angleBoundingRect.width, y + angleBoundingRect.y, angleBoundingRect.width * 2, 1); //Horizontal Plus |
| 74 | glPopMatrix(); |
| 75 | } |
| 76 | }; |
| 77 | #endif
|
| 78 | |
| 79 |
