contrib/brl/vvid/cmu_1394_camera.h
Go to the documentation of this file.
00001 // This is brl/vvid/cmu_1394_camera.h
00002 #ifndef cmu_1394_camera_h_
00003 #define cmu_1394_camera_h_
00004 //--------------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \brief cmu_1394_camera
00008 // \author
00009 //   J.L.  Mundy
00010 //
00011 //  A wrapper class for the cmu 1394 camera.  Mainly to set parameters. The
00012 //  approach is inheritance so we don't have to duplicate the CMU camera
00013 //  interface. The parameters can be passed as a block to duplicate camera
00014 //  setup and to conveniently support file I/0.
00015 //
00016 // \verbatim
00017 //  Modifications:
00018 //   J.L. Mundy Aug 29, 2002    Initial version.
00019 //   J.L. Mundy Jun 01, 2003    Added methods to determine the capabilities
00020 //                              of cameras and constrain parameters to
00021 //                              match max-min ranges of a given camera
00022 // \endverbatim
00023 //--------------------------------------------------------------------------------
00024 #include <windows.h>
00025 #include <winbase.h>
00026 #include <vcl_vector.h>
00027 #include <vcl_string.h>
00028 #include <1394Camera.h>
00029 #include <vil1/vil1_rgb.h>
00030 #include <vil1/vil1_memory_image_of.h>
00031 #include <vvid/cmu_1394_camera_params.h>
00032 #include <vpro/vpro_video_process_sptr.h>
00033 #include <vcl_iosfwd.h>
00034 
00035 class cmu_1394_camera : public cmu_1394_camera_params, public C1394Camera
00036 {
00037  public:
00038   cmu_1394_camera();
00039   cmu_1394_camera(int node, const cmu_1394_camera_params& cp);
00040 
00041   ~cmu_1394_camera();
00042 
00043   //:camera status
00044   bool get_camera_present() const { return camera_present_; }
00045   bool get_running() const { return running_; }
00046 
00047   // basic camera operations
00048 
00049   //: initialize the camera
00050   bool init(int node);
00051 
00052   //: start and stop the camera
00053   bool  start();
00054   void  stop();
00055 
00056   //: update the camera driver frame store from the camera
00057   bool get_frame();
00058 
00059   //: access the frame store and map the buffer to a sampled rgb image
00060   bool  get_rgb_image(vil1_memory_image_of<vil1_rgb<unsigned char> >& im,
00061                       int pixel_sample_interval=1, bool reread = true);
00062 
00063   //: access the frame store and map the buffer to a sampled monochrome image
00064   bool  get_monochrome_image(vil1_memory_image_of<unsigned char>& im,
00065                              int pixel_sample_interval =1, bool reread = true);
00066 
00067   // caching and saving video data. The saved images are not sampled
00068 
00069   //: initialize the file capture process, provide a filename for the video
00070   void start_capture(vcl_string const & video_file_name);
00071 
00072   //: stop the file capture process, write out the video file
00073   bool stop_capture();
00074 
00075   // camera information
00076 
00077   //: send the current parameter values to the camera
00078   void update_settings();
00079 
00080   //: get string values for valid camera video configurations
00081   vcl_vector<vcl_string> get_capability_descriptions() const {return capability_desc_;}
00082 
00083   //: get the set of valid 1394 camera format values
00084   vcl_vector<int> get_valid_formats() const {return format_;}
00085 
00086   //: get the set of valid 1394 camera mode values
00087   vcl_vector<int> get_valid_modes() const {return mode_;}
00088 
00089   //: get the set of valid 1394 frame rate codes
00090   vcl_vector<int> get_valid_rates() const {return rate_;}
00091 
00092   //: get the index of the current valid configuration
00093   int get_current() const {return current_;}
00094 
00095   //: set the index of the current valid configuration
00096   void set_current(int current){current_ = current;}
00097 
00098   //: get the string description of the currently selected configuration
00099   vcl_string current_capability_desc() const {return capability_desc_[current_];}
00100 
00101   //: code value for the current configuration
00102   int current_format() const {return format_[current_];}
00103   //: code value for the current configuration
00104   int current_mode() const {return mode_[current_];}
00105   //: code value for the current configuration
00106   int current_rate() const {return rate_[current_];}
00107 
00108   //: stream output of the camera properties
00109   friend vcl_ostream& operator << (vcl_ostream& os, const cmu_1394_camera& c);
00110 
00111  private:
00112   //internal methods
00113   void print_control(C1394CameraControl const& c);
00114   void print_status(C1394CameraControl const& c);
00115   void init_capabilities();
00116   void init_control();
00117   void validate_default_configuration();
00118   void update_video_configuration();
00119   //camera status flags
00120   bool link_failed_;
00121   bool camera_present_;
00122   bool running_;
00123   bool image_valid_;
00124   bool file_capture_;
00125   bool capture_;
00126   //video process
00127   vpro_video_process_sptr vp_;
00128   //camera capability information
00129   int current_;
00130   vcl_vector<int> format_;
00131   vcl_vector<int> mode_;
00132   vcl_vector<int> rate_;
00133   vcl_vector<vcl_string> capability_desc_;
00134 };
00135 
00136 #endif // cmu_1394_camera_h_