00001 #ifndef mvl2_video_reader_h_ 00002 #define mvl2_video_reader_h_ 00003 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief A base class for cameras/virtual cameras 00010 // \author Louise Butcher 00011 00012 #include <vxl_config.h> 00013 #include <vcl_utility.h> // for vcl_pair 00014 #include <vcl_string.h> 00015 #include <vcl_vector.h> 00016 #include <vil/vil_image_view.h> 00017 00018 00019 //: A base class for cameras/virtual cameras 00020 class mvl2_video_reader 00021 { 00022 public: 00023 00024 //: Dflt ctor 00025 mvl2_video_reader(); 00026 00027 //: Destructor 00028 virtual ~mvl2_video_reader(); 00029 00030 //: Load configurations from a file, returns a configuration's name vector 00031 vcl_vector<vcl_string> load_configs(vcl_string filename); 00032 00033 //: Use the configuration given by the configuration's name 00034 bool use_config(vcl_string configname); 00035 00036 //: Display the configurations on the standard output 00037 void display_configs(); 00038 00039 //: Initialize the camera (format can be Grey, RGB, or more complex) 00040 virtual bool initialize( int width, int height, 00041 vcl_string format, vcl_string file_name) =0; 00042 00043 //: Tidy up 00044 virtual void uninitialize() {} 00045 00046 //: Check whether camera is initialised 00047 virtual bool is_initialized() const {return is_initialized_;} 00048 00049 //: Set the size of image captured 00050 virtual void set_capture_size(int width, int height)=0; 00051 00052 //: Return width of image (in pixels) 00053 virtual int get_width() const {return width_;} 00054 00055 //: Return height of image (in pixels) 00056 virtual int get_height() const {return height_;} 00057 00058 //: Return the current frame number 00059 virtual int get_frame_number() const {return current_frame_;} 00060 00061 //: Return the frame rate in frames per second 00062 virtual double get_frame_rate () const = 0; 00063 00064 //: Set the frame rate in frames per second 00065 virtual void set_frame_rate(double frame_rate)=0; 00066 00067 //: Move frame counter on to given frame if relevant 00068 virtual int seek(int /*frame_number*/) {return current_frame_;} 00069 00070 //: Move frame counter on to next frame 00071 virtual int next_frame()=0; 00072 00073 //: Reset frame counter to zero 00074 virtual void reset_frame()=0; 00075 00076 //: Put frame data into the given image 00077 // Warning: the image is only valid until the next call to get_frame, 00078 // initialize or uninitialize. 00079 // return false if error. 00080 virtual bool get_frame(vil_image_view<vxl_byte>& image)=0; 00081 00082 //: Set the brightness of the picture 00083 virtual void set_brightness(int /*value*/) {} 00084 00085 //: Set the hue of the picture 00086 virtual void set_hue(int /*value*/) {} 00087 00088 //: Set the colour of the picture 00089 virtual void set_colour(int /*value*/) {} 00090 00091 //: Set the contrast of the picture 00092 virtual void set_contrast(int /*value*/) {} 00093 00094 //: Set the whiteness of the picture 00095 virtual void set_whiteness(int /*value*/) {} 00096 00097 //: Name of the class 00098 virtual vcl_string is_a() const; 00099 00100 //: Returns the number of frames available from the beginning of the stream or -1 if unknown 00101 virtual int length(); 00102 00103 //: Create a copy on the heap and return base class pointer 00104 virtual mvl2_video_reader* clone() const = 0; 00105 00106 protected: 00107 00108 bool use_colour_; 00109 bool is_initialized_; 00110 unsigned int current_frame_; 00111 mutable double frame_rate_; 00112 mutable int width_; 00113 mutable int height_; 00114 bool firstcall_; 00115 vcl_vector<vcl_string> config_names_; 00116 vcl_vector<vcl_pair<int,int > > config_sizes_; 00117 vcl_vector<vcl_string> config_strings_; 00118 vcl_vector<vcl_string> config_filenames_; 00119 }; 00120 00121 #endif // mvl2_video_reader_h_