Changeset 15 in flair-src for trunk/lib/FlairSensorActuator/src/Camera.cpp
- Timestamp:
- Apr 8, 2016, 3:40:57 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/Camera.cpp
r3 r15 31 31 using namespace flair::gui; 32 32 33 namespace flair { namespace sensor { 33 namespace flair { 34 namespace sensor { 34 35 35 Camera::Camera(const FrameworkManager* parent,string name,uint16_t width,uint16_t height,cvimage::Type::Format format) : IODevice(parent,name) { 36 plot_tab=NULL; 36 Camera::Camera(const FrameworkManager *parent, string name, uint16_t width, 37 uint16_t height, cvimage::Type::Format format) 38 : IODevice(parent, name) { 39 plot_tab = NULL; 37 40 38 //do not allocate imagedata, allocation is done by the camera39 output=new cvimage((IODevice*)this,width,height,format,"out",false);41 // do not allocate imagedata, allocation is done by the camera 42 output = new cvimage((IODevice *)this, width, height, format, "out", false); 40 43 41 //station sol42 main_tab=new Tab(parent->GetTabWidget(),name);43 tab=new TabWidget(main_tab->NewRow(),name);44 sensor_tab=new Tab(tab,"Setup");45 setup_groupbox=new GroupBox(sensor_tab->NewRow(),name);46 setup_layout=new GridLayout(sensor_tab->NewRow(),"setup");44 // station sol 45 main_tab = new Tab(parent->GetTabWidget(), name); 46 tab = new TabWidget(main_tab->NewRow(), name); 47 sensor_tab = new Tab(tab, "Setup"); 48 setup_groupbox = new GroupBox(sensor_tab->NewRow(), name); 49 setup_layout = new GridLayout(sensor_tab->NewRow(), "setup"); 47 50 } 48 51 49 Camera::Camera(const IODevice* parent,std::string name) : IODevice(parent,name) { 50 plot_tab=NULL; 51 main_tab=NULL; 52 tab=NULL; 53 sensor_tab=NULL; 54 setup_groupbox=NULL; 52 Camera::Camera(const IODevice *parent, std::string name) 53 : IODevice(parent, name) { 54 plot_tab = NULL; 55 main_tab = NULL; 56 tab = NULL; 57 sensor_tab = NULL; 58 setup_groupbox = NULL; 55 59 56 output=NULL;60 output = NULL; 57 61 } 58 62 59 63 Camera::~Camera() { 60 if(main_tab!=NULL) delete main_tab; 64 if (main_tab != NULL) 65 delete main_tab; 61 66 } 62 67 63 68 DataType const &Camera::GetOutputDataType() const { 64 69 return output->GetDataType(); 65 70 } 66 71 67 GroupBox* Camera::GetGroupBox(void) const { 68 return setup_groupbox; 72 GroupBox *Camera::GetGroupBox(void) const { return setup_groupbox; } 73 74 GridLayout *Camera::GetLayout(void) const { return setup_layout; } 75 76 void Camera::UseDefaultPlot(const core::cvimage *image) { 77 if (tab == NULL) { 78 Err("not applicable for simulation part.\n"); 79 return; 80 } 81 82 plot_tab = new Tab(tab, "Picture"); 83 Picture *plot = new Picture(plot_tab->NewRow(), ObjectName(), image); 69 84 } 70 85 71 GridLayout* Camera::GetLayout(void) const { 72 return setup_layout; 86 Tab *Camera::GetPlotTab(void) const { return plot_tab; } 87 88 uint16_t Camera::Width(void) const { return output->GetDataType().GetWidth(); } 89 90 uint16_t Camera::Height(void) const { 91 return output->GetDataType().GetHeight(); 73 92 } 74 93 75 void Camera::UseDefaultPlot(const core::cvimage *image) { 76 if(tab==NULL) { 77 Err("not applicable for simulation part.\n"); 78 return; 79 } 80 81 plot_tab=new Tab(tab,"Picture"); 82 Picture* plot=new Picture(plot_tab->NewRow(),ObjectName(),image); 83 } 84 85 Tab* Camera::GetPlotTab(void) const { 86 return plot_tab; 87 } 88 89 uint16_t Camera::Width(void) const { 90 return output->GetDataType().GetWidth(); 91 } 92 93 uint16_t Camera::Height(void) const { 94 return output->GetDataType().GetHeight(); 95 } 96 97 core::cvimage* Camera::Output(void) { 98 return output; 99 } 94 core::cvimage *Camera::Output(void) { return output; } 100 95 101 96 void Camera::SaveToFile(string filename) const { 102 Printf("saving %s, size %i\n",filename.c_str(),output->img->imageSize);103 104 pFile.open(filename);105 106 107 97 Printf("saving %s, size %i\n", filename.c_str(), output->img->imageSize); 98 std::ofstream pFile; 99 pFile.open(filename); 100 output->GetMutex(); 101 pFile.write(output->img->imageData, output->img->imageSize); 102 output->ReleaseMutex(); 108 103 109 104 pFile.close(); 110 105 } 111 106
Note:
See TracChangeset
for help on using the changeset viewer.