Subversion Repositories Code-Repo

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
287 Kevin 1
#ifndef DEPTHPROCESSOR_H
2
#define DEPTHPROCESSOR_H
3
 
4
#include "GlobalDefines.h"
5
 
6
// Divisor for visualizing the depth image (16->8 bits)
7
#define SCALE_DIVISOR 16
8
 
9
// Field of view to generate horizontal map from
10
#define VFOV_MIN 100
11
#define VFOV_MAX 140
12
 
13
// Threshold for moving object recognition
14
#define FG_MASK_THRESHOLD 220
15
 
16
// Parameters for the background subtractor
17
#define BACKGROUND_SUBTRACTOR_HISTORY 150
18
#define BACKGROUND_SUBTRACTOR_NMIXTURES 1
19
 
20
// Parameters for blob detection
21
#define BLOB_MIN_DISTANCE 30
22
#define BLOB_MIN_AREA 20
23
#define BLOB_MAX_AREA 9999
24
 
25
// Multiplier for velocity line indicator
26
#define VELOCITY_MULTIPLIER 5
27
 
28
// Indicator colors
29
#define COLOR_DEPTH_FOV			QColor(255, 255, 255, 100)
30
#define COLOR_DEPTH_FOV_FILL	QColor(0, 0, 0, 100)
31
#define COLOR_DEPTH_POINT		QColor(0, 0, 255, 255)
32
#define COLOR_DEPTH_BACKGROUND	QColor(255, 0, 0, 10)
33
#define COLOR_FOV				QColor(0, 0, 0, 100)
34
#define COLOR_MOVEMENT_ZONE		QColor(255, 0, 0, 5)
35
#define COLOR_KEYPOINT			QColor(255, 255, 0, 200)
36
#define COLOR_EST_POSITION		QColor(0, 0, 255, 200)
37
#define COLOR_EST_AVGERAGE		QColor(0, 255, 0, 200)
38
 
39
class DepthProcessor : public QThread
40
{
41
	Q_OBJECT
42
 
43
public:
44
	DepthProcessor(QObject *parent = 0);
45
	~DepthProcessor();
46
 
47
	public slots:
48
	void setFOV(float width, float height);
49
	void setDisplayImage(const int, const QString &);
50
	void processDepthData(const cv::Mat &);
51
 
52
signals:
53
	void setImageTopLeft(const QImage &);
54
	void setImageTopRight(const QImage &);
55
	void setImageBotLeft(const QImage &);
56
	void setImageBotRight(const QImage &);
57
 
58
private:
59
	// Pointer to images to be displayed on the GUI
60
	QImage *topLeftImage;
61
	QImage *topRightImage;
62
	QImage *botLeftImage;
63
	QImage *botRightImage;
64
	void updateImages();
65
 
66
	void drawDepthImages();
67
	void drawFOVImages();
68
 
69
	void drawDistanceFOV(QImage &, QVector<float> &);
70
	void drawSensorFOV(QImage &image);
71
	void drawMovementZones(QImage &, QVector<float> &);
72
	void drawKeyPoints(QImage &image, std::vector<cv::KeyPoint> &);
73
	void drawMovingObjects(QImage &, std::vector<MOVING_OBJECT> &);
74
 
75
	void convertMatToQImage3C(cv::Mat &, QImage &);
76
	void convertQImageToMat3C(QImage &, cv::Mat &);
77
 
78
	float fovWidth;
79
	float fovHeight;
80
 
81
	cv::Mat rawData16;				// Raw 16-bit sensor data
82
	QImage rawDepthImage;			// Image of --^
83
	cv::Mat lastValidData16;		// Last known valid 16-bit data
84
	QImage lastValidDepthImage;		// Image of --^
85
	QImage lastValidProcessed;		// Processed image with overlay
86
 
87
	cv::Mat fgMaskMOG;				// Mask of detected movements
88
	QImage movementMaskImage;		// Image of --^
89
	cv::Mat fgMaskTmp;				// Temporary buffer for averaging mask values
90
	cv::Mat fgMaskRaw;				// Raw values for movement mask
91
	QImage movementMaskRawImage;	// Image of --^
92
	cv::Mat fgMaskAverage;			// Weighted average of mask values
93
	QImage movementMaskAverageImage;	// Image of --^
94
 
95
	cv::Ptr<cv::BackgroundSubtractor> pMOG;	// Background subtractor
96
 
97
	QImage rawHorizonImage;			// 2D image showing depth points (raw)
98
	QImage lastValidHorizonImage;	// 2D image showing depth points
99
	QImage overlayHorizonImage;		// 2D image with all overlays
100
 
101
	QVector<float> rawDepthHorizon;		// Depth points in inches (raw)
102
	QVector<float> depthHorizon;		// Depth points in inches
103
 
104
	QVector<int> movementMaskHorizon;	// 1D condensed movement mask
105
 
106
 
107
	cv::Mat movementPointsMat;		// Image showing object movement zones
108
	QImage movementPointsImage;		// Image of --^
109
	cv::SimpleBlobDetector::Params params;		// Parameters for blob detection
110
	cv::Ptr<cv::FeatureDetector> blobDetector;	// Blob detector
111
	std::vector<cv::KeyPoint> blobKeypoints;	// Keypoints from blob detector
112
 
113
	MovingPointTracker movementTracker;			// Movement tracker
114
	std::vector<MOVING_OBJECT> movementObjects;	// Results from movement tracker
115
 
116
};
117
 
118
#endif // DEPTHPROCESSOR_H