You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

114 lines
3.1 KiB

#ifndef __BLOB_DETECTOR_HEADER__
#define __BLOB_DETECTOR_HEADER__
#include "../../../components/base/basicVideoAnalyzer.h"
#include "../../../components/base/basicCameraPTZ.h"
//#include "../blob/blob.h"
#include "../blob/BlobResult.h"
#include "../filter/filterImage.h"
// display (native resolution of projector)
static const int WIDTH = 800; //1280
static const int HEIGHT = 600; //800
static const int BPP = 32;
// tracker parameters
static const float TMINAREA = 16.f; // minimum area of blob to track 16
static const float TMAXRADIUS = 40.f; // a blob is identified with a blob in the previous frame if it exists within this radius
enum { BLOB_NULL, BLOB_NEW, BLOB_STEADY, BLOB_MOVE }; // event types
#define V_SEGMENT_SIZE 5
#define H_SEGMENT_SIZE 5
typedef struct S_point2D {
float x, y;
}point2D;
typedef std::vector<point2D> vector2DPoints;
class cBlob {
private:
protected:
public:
unsigned int id;
int weight;
point2D location, origin; // current location and origin for defining a drag vector
Rect box; // to define our axis-aligned bounding box
float area;
int event; // event type: one of BLOB_NULL, BLOB_DOWN, BLOB_MOVE, BLOB_UP
bool tracked; // a flag to indicate this blob has been processed
Scalar color;
float dir;
vector2DPoints ConvexHull;
};
class blobDetector: public basicVideoAnalyzer{
private:
U8 m_aSegments[V_SEGMENT_SIZE][H_SEGMENT_SIZE];
filterImage *m_oFilter;
int m_nPrepMethod;
bool m_bReduceSize;
bool m_bUsePolygones;
bool m_bShowPolygones;
bool m_bShowRectangles;
bool m_bShowCentres;
float m_nMinArea;
float m_nMaxRadius;
float m_fSegmentStepX;
float m_fSegmentStepY;
CBlobResult *m_vBlobs;
IplImage *m_pIplThr;
IplImage *m_pIplOrig;
IplImage *m_pIplWork;
Mat m_oMat;
Mat tThresh;
int m_nCursorX;
int m_nCursorY;
int m_nCursorZ;
int m_nStepX;
int m_nStepY;
int m_nStepZ;
bool m_bCursorIsSet;
// instances of helper classes for obtaining blob location and bounding box
CBlobGetXCenter XCenter;
CBlobGetYCenter YCenter;
CBlobGetMinX MinX;
CBlobGetMinY MinY;
CBlobGetMaxX MaxX;
CBlobGetMaxY MaxY;
// storage of the current blobs and the blobs from the previous frame
vector<cBlob> blobs;
vector<cBlob> blobs_previous;
CBlob current_blob;
bool lookupMaxActiveSegment(U8 &x, U8 &y);
basicCameraPTZ *m_pPTZ;
int m_nCamControllCurrent;
protected:
virtual bool m_fImageAnalyzer(Mat &Picture);
public:
blobDetector();
blobDetector( float min_area, float max_radius );
~blobDetector();
virtual void markup(Mat &Picture);
vector<cBlob> &getBlobs( void );
bool attachPTZ(basicCameraPTZ *cam);
void showPolygones(bool val){ if (m_bUsePolygones) m_bShowPolygones = val; };
void showRectangles(bool val){ m_bShowRectangles = val; };
void showCentres(bool val){
m_bShowCentres = val;
};
void setUsePolygones(bool val){ m_bUsePolygones = val; };
};
#endif