VisTrackCamshift.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __VIS_TRACK_CAMSHIFT_
00027 #define __VIS_TRACK_CAMSHIFT_
00028
00029 #include <VisualTracking.h>
00030
00031 #include <opencv2/highgui/highgui.hpp>
00032 #include <opencv2/video/tracking.hpp>
00033 #include <opencv2/imgproc/imgproc_c.h>
00034
00035 namespace MipAlgorithms{
00039
00043
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 typedef struct
00057 {
00058 float x0, x1, x2, x3, x4, x5, x6;
00059 } SavgolFilter7;
00060
00061 class VisualTrackCamshiftVar : public VisualTrackVar{
00062 private:
00063 int displayRes;
00064 int videoSaving;
00065 int init;
00066
00067 public:
00068 CvSize frameSize;
00069 int depth;
00070 pthread_mutex_t _initMutex;
00071 int track;
00072
00073 CvSize refScaleFact;
00074 CvPoint imageCentre;
00075
00076 IplImage *image;
00077 IplImage *hsv;
00078 IplImage *hue;
00079 IplImage *saturation;
00080 IplImage *mask_hue;
00081 IplImage *mask_sat;
00082 IplImage *backprjct_hue;
00083 IplImage *backprjct_sat;
00084 IplImage *anddpep;
00085
00086 CvTermCriteria criterio;
00087
00088 CvVideoWriter *videoWriter;
00089
00090 CvHistogram *hist_sat;
00091 CvHistogram *hist_hue;
00092
00093 CvPoint p1, p2, p3, p4;
00094 CvPoint r1, r2, r3, r4;
00095 CvPoint corner;
00096
00097 CvConnectedComp track_comp;
00098 CvBox2D track_box;
00099
00100 int coord[2];
00101
00102 Time refTime;
00103 Decimal ref[2];
00104 Decimal dotRef[2];
00105
00106
00107 CvRect selezione;
00108
00109 int smin_hue,
00110 vmin_hue,
00111 vmax_hue;
00112
00113 int smin_sat,
00114 smax_sat,
00115 vmin_sat,
00116 vmax_sat;
00117
00118 int thresh;
00119
00120 SavgolFilter7 *uDotFil;
00121 SavgolFilter7 *vDotFil;
00122
00124 VisualTrackCamshiftVar();
00125
00127 ~VisualTrackCamshiftVar();
00128
00131 void setVar(IplImage* frame);
00132
00136 void setDisplay(int level);
00137
00140 int getDisplay() { return displayRes; }
00141
00144 void setVideoSaving(int videoFlag);
00145
00148 int getVideoSaving() { return videoSaving; }
00149
00151 void closeDisplay();
00152
00154 void setInit(int newVal) {
00155 pthread_mutex_lock(&_initMutex);
00156 init = newVal;
00157 pthread_mutex_unlock(&_initMutex);
00158 }
00159
00161 int getInit() {
00162 pthread_mutex_lock(&_initMutex);
00163 int ret = init;
00164 pthread_mutex_unlock(&_initMutex);
00165 return ret;
00166 }
00167 };
00168
00172 class VisTrackCamshift : public VisualTracking {
00173 private:
00174 VisualTrackCamshiftVar* _wv;
00175 ImageFeature* _vf;
00176 ListenerUDP* listenerUDP;
00177
00178 pthread_mutex_t _imgFeatMutex;
00179 public:
00183 VisTrackCamshift(int type, int port = 0);
00184
00186 VisTrackCamshift(int type, IplImage* img, int port = 0);
00187
00189 ~VisTrackCamshift();
00190
00192 static void VtcMouseCallback(int event, int x, int y, int flags, void*param);
00193
00196 virtual bool displayTrack(int addInfo = 1);
00197
00200 void getEstPose(Pose3D *pose);
00201
00204 void setEstPose(Pose3D *pose);
00205
00208 void getLastFeatureErr(ImageFeature& f);
00209
00212 void setFeatureErr(ImageFeature& f);
00213
00218 bool getFeatureErr(IplImage* frame, Time& newTime, ImageFeature& f);
00219
00224 bool trackReference(IplImage* frame, Time& newTime);
00225
00229 void setDisplay(int level) {
00230 _wv->setDisplay(level);
00231 }
00232
00233 VisualTrackCamshiftVar* getVar() { return _wv; }
00234
00235 Decimal sg_derive7_step( SavgolFilter7 *filter, Decimal angle );
00236 };
00237
00238
00239 };
00240
00241
00242
00243 #endif
00244
00245
00246
00247