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 VISION_HH_ 00012 #define VISION_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 <string> 00021 #include <boost/foreach.hpp> 00022 #include <boost/variant.hpp> 00023 #include "visionbehavior.hpp" 00024 #include "vbvisitor.hpp" 00025 #include "vbkeyvisitor.hpp" 00026 00027 00056 typedef std::vector<CvPoint> CvPoints; 00057 00062 typedef boost::variant<VisionBehavior<CvSeq>*, VisionBehavior<CvPoints>*> Variant; 00063 00065 typedef std::vector<Variant> VisionBehaviors; 00066 00073 class Vision { 00074 private: 00075 IplImage* result; 00076 int delay; 00077 int wait; 00078 char keyPressed; 00079 VisionBehaviors behaviors; 00080 bool night; 00081 static std::string window_name; 00082 public: 00083 00084 Vision(int delay = 0, 00085 bool night = false); 00086 Vision(VisionBehaviors& behaviors, 00087 int delay = 0, 00088 bool night = false); 00089 ~Vision(); 00090 template <class T> 00091 void addBehavior(T* v); 00092 IplImage& workOn(const IplImage&); 00093 void workAndDisplay(CvCapture&); 00094 void setDelay(int); 00095 void setNight(bool); 00096 private: 00097 IplImage& workOn2(IplImage&); 00098 void actOnKeyPressed(); 00099 void die(std::string); 00100 void freeResult(); 00101 }; 00102 00103 00111 template <class T> 00112 void 00113 Vision::addBehavior(T* v) { 00114 behaviors.push_back(v); 00115 } 00116 00117 #endif /* !VISION_HH_ */