00001 /* 00002 * Copyright (C) Gostai S.A.S., 2007. All rights reserved. 00003 * 00004 * This software is provided "as is" without warranty of any kind, 00005 * either expressed or implied, including but not limited to the 00006 * implied warranties of fitness for a particular purpose. 00007 * 00008 * See the LICENSE file for more information. 00009 * For comments, bug reports and feedback: http://www.urbiforge.com 00010 */ 00011 #ifndef LKTRACKING_HH_ 00012 #define LKTRACKING_HH_ 00013 00014 #include <iostream> 00015 #include <cv.h> 00016 #include <cxcore.h> 00017 #include <highgui.h> 00018 #include <math.h> 00019 #include <vector> 00020 #include <boost/foreach.hpp> 00021 #include "visionbehavior.hpp" 00022 #include "vision.hpp" 00023 00024 #define MAX_COUNT 200 00025 00030 class LkTracking : public VisionBehavior<CvPoints> { 00031 private: 00032 CvPoints result; 00033 IplImage* image; 00034 IplImage* grey; 00035 IplImage* prev_grey; 00036 IplImage* pyramid; 00037 IplImage* prev_pyramid; 00038 IplImage* swap_temp; 00039 int win_size; 00040 CvPoint2D32f* points[2]; 00041 CvPoint2D32f* swap_points; 00042 char* status; 00043 int count; 00044 int need_to_init; 00045 int night_mode; 00046 int flags; 00047 int add_remove_pt; 00048 CvPoint pt; 00049 CvPoints ptsToAdd; 00050 public: 00051 LkTracking(); 00052 virtual ~LkTracking(); 00053 virtual void writeOn(IplImage& img) const; 00054 virtual void actOnKeyPressed(char& key); 00055 virtual CvPoints& getResult(); 00056 void addPointsToTrack(CvPoints&); 00057 private: 00058 virtual void emptyResult(); 00059 virtual void compute(const IplImage& img); 00060 }; 00061 00062 #endif /* !LKTRACKING_HH_ */