00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CAPTURECAMERA_HPP__
00019 #define __CAPTURECAMERA_HPP__
00020
00021 #include <rtt/RTT.hpp>
00022
00023 #include <rtt/TaskContext.hpp>
00024 #include <rtt/Ports.hpp>
00025 #include <rtt/Properties.hpp>
00026 #include <rtt/Command.hpp>
00027
00028 #include <rtt/TimeService.hpp>
00029 #include <rtt/Time.hpp>
00030
00031 #include <opencv/cv.h>
00032 #include <opencv/highgui.h>
00033 #include <ocl/OCL.hpp>
00034
00035 namespace OCL
00036 {
00037
00046 class CaptureCamera : public RTT::TaskContext
00047 {
00048
00049 public:
00057 CaptureCamera(std::string name);
00058 virtual ~CaptureCamera();
00059 virtual bool configureHook();
00060 virtual bool startHook();
00061 virtual void updateHook();
00062 virtual void cleanupHook();
00063
00064 protected:
00066 RTT::WriteDataPort<IplImage> _image;
00068 RTT::WriteDataPort<RTT::TimeService::ticks> _capture_time;
00070 RTT::Command<bool(void)> _newImage;
00072 RTT::Command<bool(void)> _setProperties;
00073
00075 RTT::Property<int> _camera_index;
00077 RTT::Property<std::string> _video_driver;
00079 RTT::Property<int> _capture_mode;
00081 RTT::Property<int> _capture_shutter;
00083 RTT::Property<int> _capture_gain;
00085 RTT::Property<int> _capture_convert;
00087 RTT::Property<double> _capture_fps;
00089 RTT::Property<int> _capture_width;
00091 RTT::Property<int> _capture_height;
00093 RTT::Property<bool> _show_time;
00095 RTT::Property<bool> _show_image;
00096
00097 private:
00098 virtual bool updateImage();
00099 virtual bool updateImageFinished()const;
00100 virtual bool setProperties();
00101 virtual bool setPropertiesFinished()const;
00102
00103 CvCapture *_capture;
00104 RTT::TimeService::ticks _timestamp;
00105 RTT::Seconds _elapsed;
00106
00107 IplImage* _frame;
00108 bool _update;
00109 bool _update_properties;
00110 };
00111 }
00112
00113 #endif // CAPTURECAMERA_HPP
00114