Go to the documentation of this file.00001
00002 #include "vvid_live_video_tableau.h"
00003
00004
00005
00006
00007 #include <vcl_iostream.h>
00008 #include <vgui/vgui.h>
00009 #include <vgui/vgui_event.h>
00010
00011 vvid_live_video_tableau::vvid_live_video_tableau()
00012 : live_(false), pixel_sample_interval_(1)
00013 {}
00014
00015
00016 vvid_live_video_tableau::vvid_live_video_tableau(int node,
00017 int pixel_sample_interval,
00018 const cmu_1394_camera_params& cp)
00019 : cam_(node, cp)
00020 {
00021 node_ = node;
00022 live_ = false;
00023 pixel_sample_interval_ = pixel_sample_interval;
00024 }
00025
00026 vvid_live_video_tableau::~vvid_live_video_tableau()
00027 {
00028 node_ = 0;
00029 live_ = false;
00030 pixel_sample_interval_ = 1;
00031 }
00032
00033 vcl_string vvid_live_video_tableau::type_name() const
00034 {
00035 return "xcv_image_tableau";
00036
00037
00038
00039 }
00040
00041
00042 bool vvid_live_video_tableau::handle(vgui_event const &e)
00043 {
00044 return base::handle(e);
00045 }
00046
00047 void vvid_live_video_tableau::set_camera_params(const cmu_1394_camera_params& cp)
00048 {
00049 if (!cam_.get_camera_present())
00050 {
00051 vcl_cout << "In vvid_live_video_tableau::set_camera_params() - warning, "
00052 << "no camera present, but param values were reassigned\n";
00053 return;
00054 }
00055 bool live =live_;
00056 if (live)
00057 this->stop_live_video();
00058 cam_.set_params(cp);
00059 cam_.update_settings();
00060
00061 if (live)
00062 this->start_live_video();
00063 }
00064
00065 bool vvid_live_video_tableau::attach_live_video()
00066 {
00067 if (!cam_.get_camera_present())
00068 {
00069 vcl_cout << "In vvid_live_video_tableau::attach_live_video() - "
00070 << "no camera present" << vcl_endl;
00071 return false;
00072 }
00073 cam_.m_cameraInitialized = false;
00074 cam_.init(node_);
00075 vcl_cout << "The Camera Attributes:\n" << cam_ << vcl_endl;
00076 return true;
00077 }
00078
00079 bool vvid_live_video_tableau::start_live_video()
00080 {
00081 if (!cam_.get_camera_present())
00082 {
00083 vcl_cout << "In vvid_live_video_tableau::startlive_video() - "
00084 << "no camera present" << vcl_endl;
00085 live_ = false;
00086 return false;
00087 }
00088 if (!cam_.start())
00089 {
00090 vcl_cout << "In vvid_live_video_tableau::startlive_video() - "
00091 << "failed to start camera\n";
00092 live_ = false;
00093 return false;
00094 }
00095
00096 live_ = true;
00097
00098 if (cam_.rgb_)
00099 {
00100 cam_.get_rgb_image(rgb_frame_, pixel_sample_interval_, true);
00101 this->set_image(rgb_frame_);
00102 }
00103 else
00104 {
00105 vcl_cout << "get image\n";
00106 cam_.get_monochrome_image(mono_frame_, pixel_sample_interval_, true);
00107 vcl_cout << "got image\n";
00108 this->set_image(mono_frame_);
00109 }
00110 return true;
00111 }
00112
00113 void vvid_live_video_tableau::update_frame()
00114 {
00115 if (!live_)
00116 return;
00117 if (cam_.rgb_)
00118 cam_.get_rgb_image(rgb_frame_, pixel_sample_interval_, true);
00119 else
00120 cam_.get_monochrome_image(mono_frame_, pixel_sample_interval_, true);
00121 this->reread_image();
00122 this->post_redraw();
00123 }
00124
00125 void vvid_live_video_tableau::stop_live_video()
00126 {
00127 if (!cam_.get_camera_present())
00128 {
00129 vcl_cout << "In vvid_live_video_tableau::stop_live_video() - "
00130 << "no camera present\n";
00131 return;
00132 }
00133 cam_.stop();
00134 live_=false;
00135 }
00136
00137 void vvid_live_video_tableau::
00138 get_camera_rgb_image(vil1_memory_image_of< vil1_rgb<unsigned char> >& im,
00139 int pix_sample_interval)
00140 {
00141 cam_.get_rgb_image(im, pix_sample_interval, false);
00142 }
00143
00144 vil1_memory_image_of< vil1_rgb<unsigned char> >
00145 vvid_live_video_tableau::get_current_rgb_image(int pix_sample_interval)
00146 {
00147 vil1_memory_image_of< vil1_rgb<unsigned char> > im;
00148 cam_.get_rgb_image(im, pix_sample_interval, false);
00149 return im;
00150 }
00151
00152 bool vvid_live_video_tableau::
00153 get_current_rgb_image(int pix_sample_interval,
00154 vil1_memory_image_of< vil1_rgb<unsigned char> >& im)
00155 {
00156 return cam_.get_rgb_image(im, pix_sample_interval, false);
00157 }
00158
00159 vil1_memory_image_of<unsigned char>
00160 vvid_live_video_tableau::get_current_mono_image(int pix_sample_interval)
00161 {
00162 vil1_memory_image_of<unsigned char> im;
00163 cam_.get_monochrome_image(im, pix_sample_interval, false);
00164 return im;
00165 }
00166
00167 bool vvid_live_video_tableau::
00168 get_current_mono_image(int pix_sample_interval,
00169 vil1_memory_image_of<unsigned char>& im )
00170 {
00171 return cam_.get_monochrome_image(im, pix_sample_interval, false);
00172 }