Main MRPT website > C++ reference for MRPT 1.5.7
WxUtils.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "gui-precomp.h" // Precompiled headers
11 
12 #include <mrpt/gui/WxUtils.h>
13 #include <mrpt/utils/CImage.h>
14 #include <mrpt/system/filesystem.h>
15 
16 #if MRPT_HAS_WXWIDGETS
17 
18 #include <mrpt/otherlibs/do_opencv_includes.h>
19 
20 using namespace mrpt;
21 using namespace mrpt::gui;
22 using namespace mrpt::utils;
23 using namespace std;
24 
25 //------------------------------------------------------------------------
26 // An auxiliary function for passing MRPT images to wxWidgets images.
27 // The returned object MUST be deleted by hand!
28 //------------------------------------------------------------------------
30 {
31 #if MRPT_HAS_OPENCV
32  IplImage* image = const_cast<IplImage*>( img.getAs<IplImage>() );
33  bool free_image_at_end = false;
34 
35  // If the image is GRAYSCALE, we need to convert it into RGB, so do it manually:
36  if (image->nChannels==1)
37  {
38  IplImage* new_image = cvCreateImage( cvSize(image->width,image->height),image->depth, 3 );
39  new_image->origin = image->origin;
40  cvCvtColor(image,new_image, CV_GRAY2RGB);
41  image = new_image; // Use this new image instead
42  free_image_at_end = true;
43  }
44 
45  int options = 0;
46  if( image->origin == 1 ) options |= CV_CVTIMG_FLIP;
47  if( image->nChannels == 3 && image->channelSeq[0] == 'B' && image->channelSeq[2]== 'R') options |= CV_CVTIMG_SWAP_RB;
48  if( options )
49  {
50  IplImage *the_input_img = image;
51 
52  image = cvCreateImage( cvSize(the_input_img->width,the_input_img->height),the_input_img->depth, 3 );
53  if (the_input_img->width && the_input_img->height)
54  cvConvertImage(the_input_img, image, options); // convert image
55 
56  if (free_image_at_end) cvReleaseImage(&the_input_img);
57  free_image_at_end = true; // for "image"
58  }
59 
60  int row_in_bytes = image->width * image->nChannels;
61  unsigned char* data = (unsigned char*)malloc( row_in_bytes * image->height );
62 
63  // Copy row by row only if necesary:
64  if (row_in_bytes != image->widthStep)
65  {
66  unsigned char* trg = data;
67  char* src = image->imageData;
68  for (int y=0;y<image->height;y++, src+=image->widthStep, trg+= row_in_bytes)
69  memcpy(trg,src,row_in_bytes);
70  }
71  else
72  {
73  memcpy(data,image->imageData,row_in_bytes* image->height);
74  }
75 
76  int w = image->width;
77  int h = image->height;
78 
79  if (free_image_at_end)
80  {
81  cvReleaseImage(&image);
82  }
83 
84  // create and return the object
85  return new wxImage(w,h, data, false ); // memory "imgData" will be freed by the object.
86 
87 #else
88  int x, y, lx = img.getWidth(), ly = img.getHeight();
89  unsigned char *imgData = (unsigned char *)malloc( 3*lx*ly );
90  unsigned char *imgPtr = imgData;
91 
92  if (img.isColor())
93  {
94  // Is COLOR
95  if (img.isOriginTopLeft())
96  {
97  for (y=0;y<ly;y++)
98  {
99  for (x=0;x<lx;x++)
100  {
101  *(imgPtr++) = *img(x,y,2);
102  *(imgPtr++) = *img(x,y,1);
103  *(imgPtr++) = *img(x,y,0);
104  }
105  }
106  }
107  else
108  {
109  for (y=ly-1;y>=0;y--)
110  {
111  for (x=0;x<lx;x++)
112  {
113  *(imgPtr++) = *img(x,y,2);
114  *(imgPtr++) = *img(x,y,1);
115  *(imgPtr++) = *img(x,y,0);
116  }
117  }
118  }
119  }
120  else
121  {
122  // Is Grayscale:
123  if (img.isOriginTopLeft())
124  {
125  for (y=0;y<ly;y++)
126  {
127  for (x=0;x<lx;x++)
128  {
129  unsigned char c = *img(x,y);
130  *(imgPtr++) = c;
131  *(imgPtr++) = c;
132  *(imgPtr++) = c;
133  }
134  }
135  }
136  else
137  {
138  for (y=ly-1;y>=0;y--)
139  {
140  for (x=0;x<lx;x++)
141  {
142  unsigned char c = *img(x,y);
143  *(imgPtr++) = c;
144  *(imgPtr++) = c;
145  *(imgPtr++) = c;
146  }
147  }
148  }
149  }
150  return new wxImage( lx, ly, imgData, false ); // memory "imgData" will be freed by the object.
151 #endif
152 }
153 
154 //------------------------------------------------------------------------
155 // An auxiliary function for passing MRPT images to wxWidgets images.
156 // The returned object MUST be deleted by hand!
157 //------------------------------------------------------------------------
159 {
160 #if MRPT_HAS_OPENCV
161  IplImage* image = const_cast<IplImage*>( img.getAs<IplImage>() );
162  bool free_image_at_end = false;
163 
164  // If the image is GRAYSCALE, we need to convert it into RGB, so do it manually:
165  if (image->nChannels==1)
166  {
167  IplImage* new_image = cvCreateImage( cvSize(image->width,image->height),image->depth, 3 );
168  new_image->origin = image->origin;
169  cvCvtColor(image,new_image, CV_GRAY2RGB);
170  image = new_image; // Use this new image instead
171  free_image_at_end = true;
172  }
173 
174  int options = 0;
175  if( image->origin == 1 ) options |= CV_CVTIMG_FLIP;
176  if( image->nChannels == 3 && image->channelSeq[0] == 'B' && image->channelSeq[2]== 'R') options |= CV_CVTIMG_SWAP_RB;
177  if( options )
178  {
179  IplImage *the_input_img = image;
180 
181  image = cvCreateImage( cvSize(the_input_img->width,the_input_img->height),the_input_img->depth, 3 );
182  cvConvertImage(the_input_img, image, options); // convert image
183 
184  if (free_image_at_end) cvReleaseImage(&the_input_img);
185  free_image_at_end = true; // for "image"
186  }
187 
188  int row_in_bytes = image->width * image->nChannels;
189  unsigned char* data = (unsigned char*)malloc( row_in_bytes * image->height );
190 
191  // Copy row by row only if necesary:
192  if (row_in_bytes != image->widthStep)
193  {
194  unsigned char* trg = data;
195  char* src = image->imageData;
196  for (int y=0;y<image->height;y++, src+=image->widthStep, trg+= row_in_bytes)
197  memcpy(trg,src,row_in_bytes);
198  }
199  else
200  {
201  memcpy(data,image->imageData,row_in_bytes* image->height);
202  }
203 
204  int w = image->width;
205  int h = image->height;
206 
207  if (free_image_at_end)
208  {
209  cvReleaseImage(&image);
210  }
211 
212  // create and return the object
213  return new wxBitmap( wxImage(w,h, data, false ) );
214 #else
215  THROW_EXCEPTION("MRPT compiled without OpenCV")
216 #endif
217 }
218 
219 
220 #if MRPT_HAS_OPENCV
222 {
223  IplImage* image = static_cast<IplImage *>(img);
224 
225  ASSERT_(image);
226  ASSERT_(image->nChannels == 3);
227 
228  // require conversion ?
229  int options = 0;
230  if( image->origin == 1 )
231  options |= CV_CVTIMG_FLIP;
232  if( image->channelSeq[0] == 'B' && image->channelSeq[2]== 'R')
233  options |= CV_CVTIMG_SWAP_RB;
234  if( options )
235  cvConvertImage(image, image, options); // convert image "in place"
236 
237  int row_bytes = image->width * image->nChannels * ((image->depth & 255)>>3);
238 
239  unsigned char* imageData = (unsigned char *)malloc(row_bytes * image->height);
240  ASSERT_(imageData);
241 
242  // copy row by row only if necesary
243  if (row_bytes != image->widthStep)
244  {
245  for (int y = 0; y < image->height; y++)
246  memcpy( (imageData + y * row_bytes),
247  (image->imageData + y * image->widthStep),
248  row_bytes);
249  }
250  else
251  {
252  memcpy( imageData,
253  image->imageData,
254  row_bytes * image->height);
255  }
256 
257  // create and return the object
258  return new wxImage(image->width, image->height, imageData, false );
259 }
260 #endif
261 
262 //------------------------------------------------------------------------
263 // Convert wxImage -> MRPTImage
264 //------------------------------------------------------------------------
266 {
267  CImage *newImg = new CImage();
268 
269  const size_t lx = img.GetWidth();
270  const size_t ly = img.GetHeight();
271 
272  newImg->loadFromMemoryBuffer(lx,ly,true,img.GetData(), true /* swap RB */);
273 
274  return newImg;
275 }
276 
277 //------------------------------------------------------------------------
278 // Convert wxImage -> MRPTImagePtr
279 //------------------------------------------------------------------------
280 mrpt::utils::CImagePtr mrpt::gui::wxImage2MRPTImagePtr( const wxImage &img )
281 {
282  return mrpt::utils::CImagePtr(wxImage2MRPTImage(img));
283 }
284 
285 
286 
287 
288 //------------------------------------------------------------------------
289 // wxMRPTImageControl
290 //------------------------------------------------------------------------
292  wxWindow *parent,
293  wxWindowID winID,
294  int x, int y, int width, int height
295  ) : m_img(NULL)
296 {
297  this->Create(parent,winID,wxPoint(x,y),wxSize(width,height));
298 
299  Connect(wxEVT_PAINT, wxPaintEventHandler(wxMRPTImageControl::OnPaint));
300  Connect(wxEVT_MOTION, wxMouseEventHandler(wxMRPTImageControl::OnMouseMove));
301  Connect(wxID_ANY,wxEVT_LEFT_DOWN,wxMouseEventHandler(wxMRPTImageControl::OnMouseClick));
302 
303  //Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&wxMRPTImageControl::OnChar);
304 }
305 
307 {
309  if (m_img)
310  {
311  delete m_img;
312  m_img=NULL;
313  }
314 }
315 
316 void wxMRPTImageControl::OnMouseMove(wxMouseEvent& ev)
317 {
319  m_last_mouse_point = ev.GetPosition();
320 }
321 
322 void wxMRPTImageControl::OnMouseClick(wxMouseEvent& ev)
323 {
325  m_last_mouse_click= ev.GetPosition();
326 }
327 
328 
330 {
332  if (m_img)
333  {
334  delete m_img;
335  m_img=NULL;
336  }
337 
338  m_img = img;
339 }
340 
342 {
343  wxBitmap *wxImg = MRPTImage2wxBitmap(img);
344 
346  if (m_img)
347  {
348  delete m_img;
349  m_img=NULL;
350  }
351 
352  m_img = wxImg;
353 }
354 
355 void wxMRPTImageControl::OnPaint(wxPaintEvent &ev)
356 {
357  wxPaintDC dc(this);
358 
360  if (!m_img)
361  {
362  // Erase background:
363  return;
364  }
365 
366  dc.DrawBitmap(*m_img,0,0);
367 }
368 
369 void wxMRPTImageControl::GetBitmap(wxBitmap &bmp)
370 {
372  if (!m_img) return;
373  bmp = *m_img;
374 }
375 
376 
377 
378 
379 
380 // *********************************************************************
381 // CPanelCameraSelection
382 // *********************************************************************
383 
384 //(*IdInit(CPanelCameraSelection)
385 const long CPanelCameraSelection::ID_STATICTEXT1 = wxNewId();
386 const long CPanelCameraSelection::ID_SPINCTRL1 = wxNewId();
387 const long CPanelCameraSelection::ID_STATICTEXT3 = wxNewId();
388 const long CPanelCameraSelection::ID_CHOICE1 = wxNewId();
389 const long CPanelCameraSelection::ID_STATICTEXT6 = wxNewId();
390 const long CPanelCameraSelection::ID_CHOICE2 = wxNewId();
391 const long CPanelCameraSelection::ID_PANEL2 = wxNewId();
392 const long CPanelCameraSelection::ID_STATICTEXT7 = wxNewId();
393 const long CPanelCameraSelection::ID_TEXTCTRL1 = wxNewId();
394 const long CPanelCameraSelection::ID_PANEL3 = wxNewId();
395 const long CPanelCameraSelection::ID_TEXTCTRL6 = wxNewId();
396 const long CPanelCameraSelection::ID_PANEL4 = wxNewId();
397 const long CPanelCameraSelection::ID_STATICTEXT8 = wxNewId();
398 const long CPanelCameraSelection::ID_TEXTCTRL2 = wxNewId();
399 const long CPanelCameraSelection::ID_BUTTON7 = wxNewId();
400 const long CPanelCameraSelection::ID_PANEL5 = wxNewId();
401 const long CPanelCameraSelection::ID_STATICTEXT9 = wxNewId();
402 const long CPanelCameraSelection::ID_TEXTCTRL3 = wxNewId();
403 const long CPanelCameraSelection::ID_BUTTON8 = wxNewId();
404 const long CPanelCameraSelection::ID_STATICTEXT5 = wxNewId();
405 const long CPanelCameraSelection::ID_TEXTCTRL7 = wxNewId();
406 const long CPanelCameraSelection::ID_BUTTON9 = wxNewId();
407 const long CPanelCameraSelection::ID_STATICTEXT10 = wxNewId();
408 const long CPanelCameraSelection::ID_TEXTCTRL8 = wxNewId();
409 const long CPanelCameraSelection::ID_STATICTEXT11 = wxNewId();
410 const long CPanelCameraSelection::ID_PANEL6 = wxNewId();
411 const long CPanelCameraSelection::ID_RADIOBOX1 = wxNewId();
412 const long CPanelCameraSelection::ID_CHECKBOX1 = wxNewId();
413 const long CPanelCameraSelection::ID_STATICTEXT2 = wxNewId();
414 const long CPanelCameraSelection::ID_PANEL7 = wxNewId();
415 const long CPanelCameraSelection::ID_RADIOBOX2 = wxNewId();
416 const long CPanelCameraSelection::ID_STATICTEXT4 = wxNewId();
417 const long CPanelCameraSelection::ID_TEXTCTRL4 = wxNewId();
418 const long CPanelCameraSelection::ID_CHECKBOX3 = wxNewId();
419 const long CPanelCameraSelection::ID_CHECKBOX4 = wxNewId();
420 const long CPanelCameraSelection::ID_CHECKBOX5 = wxNewId();
421 const long CPanelCameraSelection::ID_CHECKBOX6 = wxNewId();
422 const long CPanelCameraSelection::ID_PANEL1 = wxNewId();
423 const long CPanelCameraSelection::ID_CHECKBOX7 = wxNewId();
424 const long CPanelCameraSelection::ID_CHECKBOX8 = wxNewId();
425 const long CPanelCameraSelection::ID_CHECKBOX9 = wxNewId();
426 const long CPanelCameraSelection::ID_RADIOBOX3 = wxNewId();
427 const long CPanelCameraSelection::ID_PANEL8 = wxNewId();
428 const long CPanelCameraSelection::ID_NOTEBOOK1 = wxNewId();
429 const long CPanelCameraSelection::ID_CHECKBOX2 = wxNewId();
430 //*)
431 
432 BEGIN_EVENT_TABLE(CPanelCameraSelection,wxPanel)
433  //(*EventTable(CPanelCameraSelection)
434  //*)
435 END_EVENT_TABLE()
436 
437 CPanelCameraSelection::CPanelCameraSelection(wxWindow* parent,wxWindowID id)
438 {
439  //(*Initialize(CPanelCameraSelection)
440  wxStaticBoxSizer* StaticBoxSizer2;
441  wxFlexGridSizer* FlexGridSizer4;
442  wxFlexGridSizer* FlexGridSizer16;
443  wxFlexGridSizer* FlexGridSizer10;
444  wxFlexGridSizer* FlexGridSizer3;
445  wxFlexGridSizer* FlexGridSizer5;
446  wxFlexGridSizer* FlexGridSizer2;
447  wxFlexGridSizer* FlexGridSizer18;
448  wxFlexGridSizer* FlexGridSizer13;
449  wxFlexGridSizer* FlexGridSizer12;
450  wxStaticBoxSizer* StaticBoxSizer1;
451  wxFlexGridSizer* FlexGridSizer1;
452  wxFlexGridSizer* FlexGridSizer11;
453 
454  Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
455  FlexGridSizer1 = new wxFlexGridSizer(0, 1, 0, 0);
456  FlexGridSizer1->AddGrowableCol(0);
457  FlexGridSizer1->AddGrowableRow(0);
458  pagesCameras = new wxNotebook(this, ID_NOTEBOOK1, wxDefaultPosition, wxDefaultSize, 0, _T("ID_NOTEBOOK1"));
459  Panel2 = new wxPanel(pagesCameras, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL2"));
460  FlexGridSizer10 = new wxFlexGridSizer(0, 2, 0, 0);
461  FlexGridSizer10->AddGrowableCol(1);
462  StaticText1 = new wxStaticText(Panel2, ID_STATICTEXT1, _("Camera index:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
463  FlexGridSizer10->Add(StaticText1, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
464  opencvCamIndex = new wxSpinCtrl(Panel2, ID_SPINCTRL1, _T("0"), wxDefaultPosition, wxDefaultSize, 0, 0, 100, 0, _T("ID_SPINCTRL1"));
465  opencvCamIndex->SetValue(_T("0"));
466  FlexGridSizer10->Add(opencvCamIndex, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
467  StaticText3 = new wxStaticText(Panel2, ID_STATICTEXT3, _("Camera type:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
468  FlexGridSizer10->Add(StaticText3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
469  cbOpencvCamType = new wxChoice(Panel2, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE1"));
470  cbOpencvCamType->SetSelection( cbOpencvCamType->Append(_("CAMERA_CV_AUTODETECT")) );
471  cbOpencvCamType->Append(_("CAMERA_CV_DC1394"));
472  cbOpencvCamType->Append(_("CAMERA_CV_VFL"));
473  cbOpencvCamType->Append(_("CAMERA_CV_VFW"));
474  cbOpencvCamType->Append(_("CAMERA_CV_MIL"));
475  cbOpencvCamType->Append(_("CAMERA_CV_DSHOW"));
476  FlexGridSizer10->Add(cbOpencvCamType, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
477  StaticText6 = new wxStaticText(Panel2, ID_STATICTEXT6, _("Resolution:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
478  FlexGridSizer10->Add(StaticText6, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
479  cbOpencvResolution = new wxChoice(Panel2, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE2"));
480  cbOpencvResolution->SetSelection( cbOpencvResolution->Append(_("default")) );
481  cbOpencvResolution->Append(_("320x240"));
482  cbOpencvResolution->Append(_("640x480"));
483  FlexGridSizer10->Add(cbOpencvResolution, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
484  FlexGridSizer10->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
485  Panel2->SetSizer(FlexGridSizer10);
486  FlexGridSizer10->Fit(Panel2);
487  FlexGridSizer10->SetSizeHints(Panel2);
488  Panel3 = new wxPanel(pagesCameras, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
489  FlexGridSizer11 = new wxFlexGridSizer(0, 1, 0, 0);
490  FlexGridSizer11->AddGrowableCol(0);
491  StaticText7 = new wxStaticText(Panel3, ID_STATICTEXT7, _("IP Camera URL:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7"));
492  FlexGridSizer11->Add(StaticText7, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
493  edIPcamURL = new wxTextCtrl(Panel3, ID_TEXTCTRL1, _("rtsp://192.168.0.1/live.sdp"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
494  FlexGridSizer11->Add(edIPcamURL, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP, 5);
495  Panel3->SetSizer(FlexGridSizer11);
496  FlexGridSizer11->Fit(Panel3);
497  FlexGridSizer11->SetSizeHints(Panel3);
498  Panel4 = new wxPanel(pagesCameras, ID_PANEL4, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL4"));
499  FlexGridSizer16 = new wxFlexGridSizer(0, 1, 0, 0);
500  FlexGridSizer16->AddGrowableCol(0);
501  FlexGridSizer16->AddGrowableRow(0);
502  edCustomCamConfig = new wxTextCtrl(Panel4, ID_TEXTCTRL6, _("// Configuration block for the CCameraSensor object.\n// Check out its documentation at:\n// http://reference.mrpt.org/devel/classmrpt_1_1hwdrivers_1_1_c_camera_sensor.html\n\n[CONFIG]\ngrabber_type = opencv \ncv_camera_index = 0\ncv_camera_type = CAMERA_CV_AUTODETECT\n\n"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxHSCROLL|wxTE_DONTWRAP|wxVSCROLL|wxALWAYS_SHOW_SB, wxDefaultValidator, _T("ID_TEXTCTRL6"));
503  wxFont edCustomCamConfigFont = wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT);
504  if ( !edCustomCamConfigFont.Ok() ) edCustomCamConfigFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
505  edCustomCamConfigFont.SetPointSize(7);
506  edCustomCamConfig->SetFont(edCustomCamConfigFont);
507  FlexGridSizer16->Add(edCustomCamConfig, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP, 5);
508  Panel4->SetSizer(FlexGridSizer16);
509  FlexGridSizer16->Fit(Panel4);
510  FlexGridSizer16->SetSizeHints(Panel4);
511  Panel5 = new wxPanel(pagesCameras, ID_PANEL5, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL5"));
512  FlexGridSizer12 = new wxFlexGridSizer(0, 1, 0, 0);
513  FlexGridSizer12->AddGrowableCol(0);
514  StaticText8 = new wxStaticText(Panel5, ID_STATICTEXT8, _("Video file to open:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8"));
515  FlexGridSizer12->Add(StaticText8, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
516  edVideoFile = new wxTextCtrl(Panel5, ID_TEXTCTRL2, _("test.avi"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
517  FlexGridSizer12->Add(edVideoFile, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP, 5);
518  btnBrowseVideo = new wxButton(Panel5, ID_BUTTON7, _("Browse..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON7"));
519  FlexGridSizer12->Add(btnBrowseVideo, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
520  Panel5->SetSizer(FlexGridSizer12);
521  FlexGridSizer12->Fit(Panel5);
522  FlexGridSizer12->SetSizeHints(Panel5);
523  Panel6 = new wxPanel(pagesCameras, ID_PANEL6, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL6"));
524  FlexGridSizer13 = new wxFlexGridSizer(0, 3, 0, 0);
525  FlexGridSizer13->AddGrowableCol(1);
526  StaticText9 = new wxStaticText(Panel6, ID_STATICTEXT9, _("Rawlog \nfile:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT9"));
527  FlexGridSizer13->Add(StaticText9, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
528  edRawlogFile = new wxTextCtrl(Panel6, ID_TEXTCTRL3, _("test.rawlog"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL3"));
529  FlexGridSizer13->Add(edRawlogFile, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP, 5);
530  btnBrowseRawlog = new wxButton(Panel6, ID_BUTTON8, _("Browse..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON8"));
531  FlexGridSizer13->Add(btnBrowseRawlog, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
532  StaticText5 = new wxStaticText(Panel6, ID_STATICTEXT5, _("External \nimages:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5"));
533  FlexGridSizer13->Add(StaticText5, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
534  edRawlogImgDir = new wxTextCtrl(Panel6, ID_TEXTCTRL7, _("./Images"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL7"));
535  FlexGridSizer13->Add(edRawlogImgDir, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP, 5);
536  btnBrowseRawlogDir = new wxButton(Panel6, ID_BUTTON9, _("Browse..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON9"));
537  FlexGridSizer13->Add(btnBrowseRawlogDir, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
538  StaticText10 = new wxStaticText(Panel6, ID_STATICTEXT10, _("Sensor\nlabel:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT10"));
539  FlexGridSizer13->Add(StaticText10, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
540  edRawlogLabel = new wxTextCtrl(Panel6, ID_TEXTCTRL8, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL8"));
541  FlexGridSizer13->Add(edRawlogLabel, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP, 5);
542  StaticText11 = new wxStaticText(Panel6, ID_STATICTEXT11, _("(empty=any)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT11"));
543  FlexGridSizer13->Add(StaticText11, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
544  Panel6->SetSizer(FlexGridSizer13);
545  FlexGridSizer13->Fit(Panel6);
546  FlexGridSizer13->SetSizeHints(Panel6);
547  Panel1 = new wxPanel(pagesCameras, ID_PANEL7, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL7"));
548  FlexGridSizer18 = new wxFlexGridSizer(2, 2, 0, 0);
549  wxString __wxRadioBoxChoices_1[2] =
550  {
551  _("Left"),
552  _("Right")
553  };
554  rbBumblebeeSel = new wxRadioBox(Panel1, ID_RADIOBOX1, _("Select monocular input"), wxDefaultPosition, wxDefaultSize, 2, __wxRadioBoxChoices_1, 1, 0, wxDefaultValidator, _T("ID_RADIOBOX1"));
555  rbBumblebeeSel->SetSelection(0);
556  FlexGridSizer18->Add(rbBumblebeeSel, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
557  cbBumblebeeRectif = new wxCheckBox(Panel1, ID_CHECKBOX1, _("Use vendor\'s rectify"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
558  cbBumblebeeRectif->SetValue(false);
559  FlexGridSizer18->Add(cbBumblebeeRectif, 1, wxALL|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 10);
560  FlexGridSizer18->Add(-1,-1,1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
561  StaticText2 = new wxStaticText(Panel1, ID_STATICTEXT2, _("(Unchecked = raw images)"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
562  FlexGridSizer18->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
563  Panel1->SetSizer(FlexGridSizer18);
564  FlexGridSizer18->Fit(Panel1);
565  FlexGridSizer18->SetSizeHints(Panel1);
566  pnSwissRanger = new wxPanel(pagesCameras, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
567  FlexGridSizer2 = new wxFlexGridSizer(2, 3, 0, 0);
568  wxString __wxRadioBoxChoices_2[2] =
569  {
570  _("USB"),
571  _("Ethernet")
572  };
573  rbSR_usb = new wxRadioBox(pnSwissRanger, ID_RADIOBOX2, _("Connection"), wxDefaultPosition, wxDefaultSize, 2, __wxRadioBoxChoices_2, 1, 0, wxDefaultValidator, _T("ID_RADIOBOX2"));
574  FlexGridSizer2->Add(rbSR_usb, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
575  StaticText4 = new wxStaticText(pnSwissRanger, ID_STATICTEXT4, _("IP:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
576  FlexGridSizer2->Add(StaticText4, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
577  edSR_IP = new wxTextCtrl(pnSwissRanger, ID_TEXTCTRL4, _("192.168.2.14"), wxDefaultPosition, wxSize(120,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL4"));
578  FlexGridSizer2->Add(edSR_IP, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
579  StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, pnSwissRanger, _("Channels to grab: "));
580  FlexGridSizer3 = new wxFlexGridSizer(4, 1, 0, 0);
581  cbSR_chIntensity = new wxCheckBox(pnSwissRanger, ID_CHECKBOX3, _("Grayscale intensity"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX3"));
582  cbSR_chIntensity->SetValue(true);
583  cbSR_chIntensity->Disable();
584  FlexGridSizer3->Add(cbSR_chIntensity, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
585  cbSR_ch3D = new wxCheckBox(pnSwissRanger, ID_CHECKBOX4, _("3D point cloud"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX4"));
586  cbSR_ch3D->SetValue(false);
587  FlexGridSizer3->Add(cbSR_ch3D, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
588  cbSR_chRange = new wxCheckBox(pnSwissRanger, ID_CHECKBOX5, _("Depth image"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX5"));
589  cbSR_chRange->SetValue(false);
590  FlexGridSizer3->Add(cbSR_chRange, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
591  cbSR_chConf = new wxCheckBox(pnSwissRanger, ID_CHECKBOX6, _("Confidence"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX6"));
592  cbSR_chConf->SetValue(false);
593  FlexGridSizer3->Add(cbSR_chConf, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
594  StaticBoxSizer1->Add(FlexGridSizer3, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 0);
595  FlexGridSizer2->Add(StaticBoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
596  pnSwissRanger->SetSizer(FlexGridSizer2);
597  FlexGridSizer2->Fit(pnSwissRanger);
598  FlexGridSizer2->SetSizeHints(pnSwissRanger);
599  pnKinect = new wxPanel(pagesCameras, ID_PANEL8, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL8"));
600  FlexGridSizer4 = new wxFlexGridSizer(2, 3, 0, 0);
601  StaticBoxSizer2 = new wxStaticBoxSizer(wxHORIZONTAL, pnKinect, _("Channels to grab: "));
602  FlexGridSizer5 = new wxFlexGridSizer(4, 1, 0, 0);
603  cbKinect_Int = new wxCheckBox(pnKinect, ID_CHECKBOX7, _("Intensity"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX7"));
604  cbKinect_Int->SetValue(true);
605  cbKinect_Int->Disable();
606  FlexGridSizer5->Add(cbKinect_Int, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
607  cbKinect_3D = new wxCheckBox(pnKinect, ID_CHECKBOX8, _("3D point cloud"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX8"));
608  cbKinect_3D->SetValue(false);
609  FlexGridSizer5->Add(cbKinect_3D, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
610  cbKinect_Depth = new wxCheckBox(pnKinect, ID_CHECKBOX9, _("Depth image"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX9"));
611  cbKinect_Depth->SetValue(false);
612  FlexGridSizer5->Add(cbKinect_Depth, 1, wxALL|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
613  StaticBoxSizer2->Add(FlexGridSizer5, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 0);
614  FlexGridSizer4->Add(StaticBoxSizer2, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_BOTTOM, 5);
615  wxString __wxRadioBoxChoices_3[2] =
616  {
617  _("RGB camera"),
618  _("IR camera")
619  };
620  rbKinect_int = new wxRadioBox(pnKinect, ID_RADIOBOX3, _("Intensity channel:"), wxDefaultPosition, wxDefaultSize, 2, __wxRadioBoxChoices_3, 1, 0, wxDefaultValidator, _T("ID_RADIOBOX3"));
621  rbKinect_int->SetSelection(0);
622  FlexGridSizer4->Add(rbKinect_int, 1, wxALL|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 5);
623  pnKinect->SetSizer(FlexGridSizer4);
624  FlexGridSizer4->Fit(pnKinect);
625  FlexGridSizer4->SetSizeHints(pnKinect);
626  pagesCameras->AddPage(Panel2, _("Camera (opencv)"), false);
627  pagesCameras->AddPage(Panel3, _("Camera (FFmpeg)"), false);
628  pagesCameras->AddPage(Panel4, _("Camera (custom)"), false);
629  pagesCameras->AddPage(Panel5, _("Video file"), false);
630  pagesCameras->AddPage(Panel6, _("Rawlog file"), false);
631  pagesCameras->AddPage(Panel1, _("Bumblebee"), false);
632  pagesCameras->AddPage(pnSwissRanger, _("SwissRanger ToF"), false);
633  pagesCameras->AddPage(pnKinect, _("Kinect"), false);
634  FlexGridSizer1->Add(pagesCameras, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
635  cbGrayscale = new wxCheckBox(this, ID_CHECKBOX2, _("Capture in grayscale"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2"));
636  cbGrayscale->SetValue(true);
637  FlexGridSizer1->Add(cbGrayscale, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_TOP, 5);
638  SetSizer(FlexGridSizer1);
639  FlexGridSizer1->Fit(this);
640  FlexGridSizer1->SetSizeHints(this);
641 
642  Connect(ID_BUTTON7,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CPanelCameraSelection::OnbtnBrowseVideoClick);
643  Connect(ID_BUTTON8,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CPanelCameraSelection::OnbtnBrowseRawlogClick);
644  Connect(ID_BUTTON9,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&CPanelCameraSelection::OnbtnBrowseRawlogDirClick);
645  //*)
646 
647  // end of automatically-generated code above:
648  cbOpencvResolution->Clear();
649  cbOpencvResolution->SetSelection( cbOpencvResolution->Append(_("default")) );
650 
651  cbOpencvResolution->Append(_("320x240"));
652  cbOpencvResolution->Append(_("640x480"));
653  cbOpencvResolution->Append(_("800x600"));
654  cbOpencvResolution->Append(_("1024x768"));
655  cbOpencvResolution->Append(_("1280x1024"));
656 
657 
658 }
659 
661 {
662  wxFileDialog dialog(
663  this,
664  wxT("Choose a video to open"),
665  wxT("."),
666  wxT(""),
667  wxT("Video files (*.avi;*.mpg;*.mov)|*.avi;*.mpg;*.mov|All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
668 
669  if (dialog.ShowModal() == wxID_OK)
670  edVideoFile->SetValue( dialog.GetPath() );
671 
672 
673 }
674 
676 {
677  wxFileDialog dialog(
678  this,
679  wxT("Choose a rawlog to open"),
680  wxT("."),
681  wxT(""),
682  wxT("Rawlog files (*.rawlog;*.rawlog.gz)|*.rawlog;*.rawlog.gz|All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
683 
684  if (dialog.ShowModal() == wxID_OK)
685  {
686  edRawlogFile->SetValue( dialog.GetPath() );
687 
688  if ( !mrpt::system::directoryExists( string(edRawlogImgDir->GetValue().mb_str()) ) )
689  {
690  string fil = string( dialog.GetPath().mb_str() );
691  string fil_path = mrpt::system::extractFileDirectory(fil);
692  fil_path += "/Images";
693  edRawlogImgDir->SetValue( _U( fil_path.c_str() ) );
694  }
695  }
696 }
697 
699 {
700  wxDirDialog dialog(
701  this,
702  wxT("Choose the rawlog directory with external images"),
703  edRawlogImgDir->GetValue(),
704  wxDD_DEFAULT_STYLE );
705 
706  if (dialog.ShowModal() == wxID_OK)
707  edRawlogImgDir->SetValue( dialog.GetPath() );
708 
709 }
710 
711 
713 {
714  //(*Destroy(CPanelCameraSelection)
715  //*)
716 }
717 
718 
719 /* ------------------------------------------------------------------------
720  writeConfigFromVideoSourcePanel
721  ------------------------------------------------------------------------ */
723  const std::string &sect,
724  mrpt::utils::CConfigFileBase *cfg ) const
725 {
726  MRPT_START
727 
728  switch (this->pagesCameras->GetSelection())
729  {
730  // OpenCV:
731  // -----------------------------------
732  case 0:
733  {
734  cfg->write(sect,"grabber_type","opencv");
735  cfg->write(sect,"cv_camera_index", format("%i",this->opencvCamIndex->GetValue()) );
736  cfg->write(sect,"cv_camera_type", string(this->cbOpencvCamType->GetStringSelection().mb_str()) );
737 
738  const std::string sRes = std::string( cbOpencvResolution->GetStringSelection().mb_str() );
739 
740  if (!sRes.empty())
741  {
742  const size_t p = sRes.find("x");
743  if (p!=std::string::npos)
744  {
745  const std::string sW = sRes.substr(0,p);
746  const std::string sH = sRes.substr(p+1);
747 
748  cfg->write(sect,"cv_frame_width",sW);
749  cfg->write(sect,"cv_frame_height",sH);
750  }
751  }
752  }
753  break;
754 
755  // Camera FFmpeg
756  // -----------------------------------
757  case 1:
758  {
759  cfg->write(sect,"grabber_type","ffmpeg");
760  cfg->write(sect,"ffmpeg_url", string(this->edIPcamURL->GetValue().mb_str()) );
761  }
762  break;
763 
764  // Camera custom
765  // -----------------------------------
766  case 2:
767  {
768  // Replicate the config sections in "edCustomCamConfig" into "cfg":
769  mrpt::utils::CConfigFileMemory cfgIn( string(edCustomCamConfig->GetValue().mb_str()) );
770  vector_string allSects;
771  cfgIn.getAllSections(allSects);
772  for (size_t idxSect=0;idxSect<allSects.size();idxSect++)
773  {
774  vector_string keys;
775  cfgIn.getAllKeys(allSects[idxSect], keys);
776  for (size_t i=0;i<keys.size();i++)
777  cfg->write(allSects[idxSect], keys[i], cfgIn.read_string(allSects[idxSect], keys[i], "") );
778  }
779  }
780  break;
781 
782  // Video file
783  // -----------------------------------
784  case 3:
785  {
786  cfg->write(sect,"grabber_type","ffmpeg");
787  cfg->write(sect,"ffmpeg_url", string(this->edVideoFile->GetValue().mb_str()) );
788  }
789  break;
790 
791  // Rawlog
792  // -----------------------------------
793  case 4:
794  {
795  cfg->write(sect,"grabber_type","rawlog");
796  cfg->write(sect,"rawlog_file", string(this->edRawlogFile->GetValue().mb_str()) );
797 
798  const string rawlog_lb = string( this->edRawlogLabel->GetValue().mb_str() );
799  if (!rawlog_lb.empty())
800  cfg->write(sect,"rawlog_camera_sensor_label", rawlog_lb );
801 
802  CImage::IMAGES_PATH_BASE = string( this->edRawlogImgDir->GetValue().mb_str() );
803  }
804  break;
805 
806  // Bumblebee
807  // -----------------------------------
808  case 5:
809  {
810  cfg->write(sect,"grabber_type","bumblebee");
811  if (this->rbBumblebeeSel->GetSelection()<2)
812  cfg->write(sect,"bumblebee_mono", format("%i\n",(int)this->rbBumblebeeSel->GetSelection() ));
813  else { /* Use stereo capture */ }
814  cfg->write(sect,"bumblebee_fps",15);
815  cfg->write(sect,"bumblebee_get_rectified", this->cbBumblebeeRectif->GetValue() );
816  }
817  break;
818 
819  // Swissranger
820  // -----------------------------------
821  case 6:
822  {
823  cfg->write(sect,"grabber_type","swissranger");
824 
825  cfg->write(sect,"sr_use_usb", rbSR_usb->GetSelection()==0 );
826  cfg->write(sect,"sr_IP", string(edSR_IP->GetValue().mb_str() ) );
827 
828  cfg->write(sect,"sr_grab_grayscale", cbSR_chIntensity->GetValue() );
829  cfg->write(sect,"sr_grab_3d", cbSR_ch3D->GetValue() );
830  cfg->write(sect,"sr_grab_range", cbSR_chRange->GetValue() );
831  cfg->write(sect,"sr_grab_confidence", cbSR_chConf->GetValue() );
832  }
833  break;
834 
835  // Kinect
836  // -----------------------------------
837  case 7:
838  {
839  cfg->write(sect,"grabber_type","kinect");
840 
841  cfg->write(sect,"kinect_grab_intensity", cbKinect_Int->GetValue() );
842  cfg->write(sect,"kinect_grab_3d", cbKinect_3D->GetValue() );
843  cfg->write(sect,"kinect_grab_range", cbKinect_Depth->GetValue() );
844 
845  cfg->write(sect,"kinect_video_rgb", rbKinect_int->GetSelection()==0 ? 1 : 0 );
846  }
847  break;
848 
849  default:
850  {
851  cerr << "[MRPT CPanelCameraSelection] ERROR: Unknown camera selection tab!\n";
852  THROW_EXCEPTION("Unknown camera selection tab!")
853  }
854  }
855 
856 
857  // Add grayscale option:
858  cfg->write(sect,"capture_grayscale", this->cbGrayscale->GetValue() );
859 
860  MRPT_END
861 }
862 
863 
864 /* ------------------------------------------------------------------------
865  readConfigIntoVideoSourcePanel
866  ------------------------------------------------------------------------ */
868  const std::string &sect,
869  const mrpt::utils::CConfigFileBase *cfg ) const
870 {
871  MRPT_START
872 
873  const std::string grab_type = cfg->read_string(sect,"grabber_type","opencv");
874 
875  if (grab_type=="opencv")
876  {
877  this->pagesCameras->SetSelection(0);
878 
879  this->opencvCamIndex->SetValue( cfg->read_int(sect,"cv_camera_index", 0 ) );
880  this->cbOpencvCamType->SetStringSelection( _U(cfg->read_string(sect,"cv_camera_type", "").c_str()));
881 
882  const int w = cfg->read_int(sect,"cv_frame_width",0);
883 
884  if (w==320)
885  this->cbOpencvResolution->SetSelection(1);
886  else if (w==640)
887  this->cbOpencvResolution->SetSelection(2);
888  else
889  this->cbOpencvResolution->SetSelection(0);
890  }
891  else if (grab_type=="ffmpeg")
892  {
893  // Page: 1 (IP), 3 (file)
894  const string url = cfg->read_string(sect,"ffmpeg_url","rtsp://192.168.0.1/live.sdp");
895 
896  if (url.substr(0,5)=="rtsp:")
897  {
898  this->pagesCameras->SetSelection(1);
899  this->edIPcamURL->SetValue( _U(url.c_str()));
900  }
901  else
902  {
903  this->pagesCameras->SetSelection(3);
904  this->edVideoFile->SetValue( _U(url.c_str()) );
905  }
906  }
907  else if (grab_type=="rawlog")
908  {
909  this->pagesCameras->SetSelection(4);
910 
911  this->edRawlogFile->SetValue(_U(cfg->read_string(sect,"rawlog_file","").c_str() ));
912 
913  const string lb = cfg->read_string(sect,"rawlog_camera_sensor_label", "" );
914  this->edRawlogLabel->SetValue(_U(lb.c_str()));
915  }
916  else if (grab_type=="bumblebee")
917  {
918  this->pagesCameras->SetSelection(5);
919 
920  this->rbBumblebeeSel->SetSelection( cfg->read_int(sect,"bumblebee_mono",0 ));
921  this->cbBumblebeeRectif->SetValue( cfg->read_bool(sect,"bumblebee_get_rectified",false ));
922  }
923  else if (grab_type=="swissranger")
924  {
925  this->pagesCameras->SetSelection(6);
926 
927  this->rbSR_usb->SetSelection( cfg->read_bool(sect,"sr_use_usb", true ) ? 0:1 );
928  this->edSR_IP->SetValue( _U( cfg->read_string(sect,"sr_IP", "192.168.0.1").c_str() ) );
929 
930  this->cbSR_chIntensity->SetValue( cfg->read_bool(sect,"sr_grab_grayscale",true));
931  this->cbSR_ch3D->SetValue( cfg->read_bool(sect,"sr_grab_3d",false));
932  this->cbSR_chRange->SetValue( cfg->read_bool(sect,"sr_grab_range",false));
933  this->cbSR_chConf->SetValue( cfg->read_bool(sect,"sr_grab_confidence",false));
934  }
935  else
936  THROW_EXCEPTION_FMT("Error: Unknown choice in 'grabber_type': '%s'",grab_type.c_str() );
937 
938  // Grayscale option:
939  this->cbGrayscale->SetValue( cfg->read_bool(sect,"capture_grayscale", false) );
940 
941  MRPT_END
942 }
943 
945 {
946  int mod = MRPTKMOD_NONE;
947  if (ev.AltDown()) mod|= MRPTKMOD_ALT;
948  if (ev.CmdDown()) mod|= MRPTKMOD_CMD;
949  if (ev.ControlDown()) mod|= MRPTKMOD_CONTROL;
950  if (ev.MetaDown()) mod|= MRPTKMOD_META;
951  if (ev.ShiftDown()) mod|= MRPTKMOD_SHIFT;
952  return mrptKeyModifier(mod);
953 }
954 
955 
956 
957 #endif // MRPT_HAS_WXWIDGETS
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy".
Definition: os.cpp:358
A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.
static const long ID_BUTTON9
Definition: WxUtils.h:250
static const long ID_CHOICE1
Definition: WxUtils.h:232
void writeConfigFromVideoSourcePanel(const std::string &sect, mrpt::utils::CConfigFileBase *cfg) const
Definition: WxUtils.cpp:722
bool read_bool(const std::string &section, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
static const long ID_PANEL3
Definition: WxUtils.h:238
void GetBitmap(wxBitmap &bmp)
Definition: WxUtils.cpp:369
#define _U(x)
Definition: WxSubsystem.h:470
void OnbtnBrowseRawlogDirClick(wxCommandEvent &event)
Definition: WxUtils.cpp:698
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
static const long ID_SPINCTRL1
Definition: WxUtils.h:230
static const long ID_STATICTEXT9
Definition: WxUtils.h:245
static const long ID_STATICTEXT1
Definition: WxUtils.h:229
static const long ID_CHECKBOX4
Definition: WxUtils.h:263
#define THROW_EXCEPTION(msg)
static const long ID_RADIOBOX3
Definition: WxUtils.h:270
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
static const long ID_RADIOBOX2
Definition: WxUtils.h:259
void OnMouseMove(wxMouseEvent &ev)
Definition: WxUtils.cpp:316
static const long ID_PANEL1
Definition: WxUtils.h:266
static const long ID_CHECKBOX1
Definition: WxUtils.h:256
static const long ID_TEXTCTRL6
Definition: WxUtils.h:239
mrptKeyModifier
Definition: keycodes.h:158
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:3522
std::string read_string(const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
static const long ID_NOTEBOOK1
Definition: WxUtils.h:272
STL namespace.
wxMRPTImageControl(wxWindow *parent, wxWindowID winID, int x, int y, int width, int height)
Definition: WxUtils.cpp:291
void readConfigIntoVideoSourcePanel(const std::string &sect, const mrpt::utils::CConfigFileBase *cfg) const
Definition: WxUtils.cpp:867
static const long ID_CHECKBOX6
Definition: WxUtils.h:265
mrpt::utils::CImagePtr GUI_IMPEXP wxImage2MRPTImagePtr(const wxImage &img)
Create a MRPT image from a wxImage.
Definition: WxUtils.cpp:280
static const long ID_CHECKBOX5
Definition: WxUtils.h:264
GLuint src
Definition: glext.h:6303
wxImage GUI_IMPEXP * IplImage2wxImage(void *img)
Create a wxImage from a IPL image.
Definition: WxUtils.cpp:221
GLenum GLsizei width
Definition: glext.h:3513
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3962
static const long ID_CHECKBOX3
Definition: WxUtils.h:262
static const long ID_TEXTCTRL8
Definition: WxUtils.h:252
void getAllSections(vector_string &sections) const MRPT_OVERRIDE
Returns a list with all the section names.
This class allows loading and storing values and vectors of different types from a configuration text...
static const long ID_TEXTCTRL3
Definition: WxUtils.h:246
This class implements a config file-like interface over a memory-stored string list.
int read_int(const std::string &section, const std::string &name, int defaultValue, bool failIfNotFound=false) const
std::vector< std::string > vector_string
A type for passing a vector of strings.
Definition: types_simple.h:30
wxBitmap GUI_IMPEXP * MRPTImage2wxBitmap(const mrpt::utils::CImage &img)
Create a wxBitmap from a MRPT image.
Definition: WxUtils.cpp:158
static const long ID_TEXTCTRL1
Definition: WxUtils.h:237
void OnMouseClick(wxMouseEvent &ev)
Definition: WxUtils.cpp:322
void loadFromMemoryBuffer(unsigned int width, unsigned int height, bool color, unsigned char *rawpixels, bool swapRedBlue=false)
Reads the image from raw pixels buffer in memory.
Definition: CImage.cpp:387
mrpt::synch::CCriticalSection m_mouse_cs
Definition: WxUtils.h:144
#define MRPT_END
static const long ID_CHECKBOX8
Definition: WxUtils.h:268
mrpt::utils::CImage GUI_IMPEXP * wxImage2MRPTImage(const wxImage &img)
Create a MRPT image from a wxImage.
Definition: WxUtils.cpp:265
static const long ID_CHECKBOX7
Definition: WxUtils.h:267
const GLubyte * c
Definition: glext.h:5590
GLint GLvoid * img
Definition: glext.h:3645
void OnbtnBrowseVideoClick(wxCommandEvent &event)
Definition: WxUtils.cpp:660
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
static const long ID_CHOICE2
Definition: WxUtils.h:234
static const long ID_STATICTEXT6
Definition: WxUtils.h:233
wxImage GUI_IMPEXP * MRPTImage2wxImage(const mrpt::utils::CImage &img)
Create a wxImage from a MRPT image.
Definition: WxUtils.cpp:29
static const long ID_TEXTCTRL2
Definition: WxUtils.h:242
static const long ID_CHECKBOX2
Definition: WxUtils.h:273
static const long ID_PANEL2
Definition: WxUtils.h:235
static const long ID_STATICTEXT3
Definition: WxUtils.h:231
static const long ID_PANEL5
Definition: WxUtils.h:244
GLsizei const GLchar ** string
Definition: glext.h:3919
mrptKeyModifier keyEventToMrptKeyModifier(const wxKeyEvent &ev)
Extracts the key modifiers from a wxKeyEvent.
Definition: WxUtils.cpp:944
static const long ID_STATICTEXT2
Definition: WxUtils.h:257
mrpt::synch::CCriticalSection m_img_cs
Definition: WxUtils.h:141
static const long ID_STATICTEXT11
Definition: WxUtils.h:253
#define MRPT_START
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void write(const std::string &section, const std::string &name, const data_t &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
static const long ID_STATICTEXT10
Definition: WxUtils.h:251
static const long ID_TEXTCTRL7
Definition: WxUtils.h:249
static const long ID_TEXTCTRL4
Definition: WxUtils.h:261
static const long ID_STATICTEXT5
Definition: WxUtils.h:248
#define ASSERT_(f)
A panel to select the camera input from all the formats supported by MRPT.
Definition: WxUtils.h:163
void OnPaint(wxPaintEvent &ev)
Definition: WxUtils.cpp:355
static const long ID_CHECKBOX9
Definition: WxUtils.h:269
GLenum GLint GLint y
Definition: glext.h:3516
static const long ID_PANEL8
Definition: WxUtils.h:271
static const long ID_RADIOBOX1
Definition: WxUtils.h:255
static const long ID_PANEL4
Definition: WxUtils.h:240
GLenum GLsizei GLenum format
Definition: glext.h:3513
Classes for creating GUI windows for 2D and 3D visualization.
static const long ID_PANEL7
Definition: WxUtils.h:258
void getAllKeys(const std::string &section, vector_string &keys) const MRPT_OVERRIDE
Returs a list with all the keys into a section.
void OnbtnBrowseRawlogClick(wxCommandEvent &event)
Definition: WxUtils.cpp:675
bool BASE_IMPEXP directoryExists(const std::string &fileName)
Test if a given directory exists (it fails if the given path refers to an existing file)...
Definition: filesystem.cpp:132
GLenum GLint x
Definition: glext.h:3516
GLenum GLsizei GLsizei height
Definition: glext.h:3523
static const long ID_BUTTON7
Definition: WxUtils.h:243
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3520
GLfloat GLfloat p
Definition: glext.h:5587
static const long ID_STATICTEXT4
Definition: WxUtils.h:260
static const long ID_STATICTEXT7
Definition: WxUtils.h:236
std::string BASE_IMPEXP extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension...
Definition: filesystem.cpp:77
void AssignImage(wxBitmap *img)
Assigns this image. This object has the ownship of the image and will delete it when appropriate...
Definition: WxUtils.cpp:329
static const long ID_PANEL6
Definition: WxUtils.h:254
static const long ID_BUTTON8
Definition: WxUtils.h:247
static const long ID_STATICTEXT8
Definition: WxUtils.h:241



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019