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



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020