16 #if MRPT_HAS_WXWIDGETS 18 #include <mrpt/otherlibs/do_opencv_includes.h> 31 IplImage*
image =
const_cast<IplImage*
>(
img.getAs<IplImage>());
32 bool free_image_at_end =
false;
36 if (
image->nChannels == 1)
40 new_image->origin =
image->origin;
41 cvCvtColor(
image, new_image, CV_GRAY2RGB);
43 free_image_at_end =
true;
47 if (
image->origin == 1) options |= CV_CVTIMG_FLIP;
48 if (
image->nChannels == 3 &&
image->channelSeq[0] ==
'B' &&
49 image->channelSeq[2] ==
'R')
50 options |= CV_CVTIMG_SWAP_RB;
53 IplImage* the_input_img =
image;
55 image = cvCreateImage(
56 cvSize(the_input_img->width, the_input_img->height),
57 the_input_img->depth, 3);
58 if (the_input_img->width && the_input_img->height)
59 cvConvertImage(the_input_img,
image, options);
61 if (free_image_at_end) cvReleaseImage(&the_input_img);
62 free_image_at_end =
true;
65 int row_in_bytes =
image->width *
image->nChannels;
66 unsigned char*
data = (
unsigned char*)malloc(row_in_bytes *
image->height);
69 if (row_in_bytes !=
image->widthStep)
71 unsigned char* trg =
data;
73 for (
int y = 0;
y <
image->height;
74 y++,
src +=
image->widthStep, trg += row_in_bytes)
83 int h =
image->height;
85 if (free_image_at_end)
87 cvReleaseImage(&
image);
95 int x,
y, lx =
img.getWidth(), ly =
img.getHeight();
96 unsigned char* imgData = (
unsigned char*)malloc(3 * lx * ly);
97 unsigned char* imgPtr = imgData;
102 if (
img.isOriginTopLeft())
104 for (
y = 0;
y < ly;
y++)
106 for (
x = 0;
x < lx;
x++)
108 *(imgPtr++) = *
img(
x,
y, 2);
109 *(imgPtr++) = *
img(
x,
y, 1);
110 *(imgPtr++) = *
img(
x,
y, 0);
116 for (
y = ly - 1;
y >= 0;
y--)
118 for (
x = 0;
x < lx;
x++)
120 *(imgPtr++) = *
img(
x,
y, 2);
121 *(imgPtr++) = *
img(
x,
y, 1);
122 *(imgPtr++) = *
img(
x,
y, 0);
130 if (
img.isOriginTopLeft())
132 for (
y = 0;
y < ly;
y++)
134 for (
x = 0;
x < lx;
x++)
136 unsigned char c = *
img(
x,
y);
145 for (
y = ly - 1;
y >= 0;
y--)
147 for (
x = 0;
x < lx;
x++)
149 unsigned char c = *
img(
x,
y);
170 IplImage*
image =
const_cast<IplImage*
>(
img.getAs<IplImage>());
171 bool free_image_at_end =
false;
175 if (
image->nChannels == 1)
177 IplImage* new_image =
179 new_image->origin =
image->origin;
180 cvCvtColor(
image, new_image, CV_GRAY2RGB);
182 free_image_at_end =
true;
186 if (
image->origin == 1) options |= CV_CVTIMG_FLIP;
187 if (
image->nChannels == 3 &&
image->channelSeq[0] ==
'B' &&
188 image->channelSeq[2] ==
'R')
189 options |= CV_CVTIMG_SWAP_RB;
192 IplImage* the_input_img =
image;
194 image = cvCreateImage(
195 cvSize(the_input_img->width, the_input_img->height),
196 the_input_img->depth, 3);
197 cvConvertImage(the_input_img,
image, options);
199 if (free_image_at_end) cvReleaseImage(&the_input_img);
200 free_image_at_end =
true;
203 int row_in_bytes =
image->width *
image->nChannels;
204 unsigned char*
data = (
unsigned char*)malloc(row_in_bytes *
image->height);
207 if (row_in_bytes !=
image->widthStep)
209 unsigned char* trg =
data;
211 for (
int y = 0;
y <
image->height;
212 y++,
src +=
image->widthStep, trg += row_in_bytes)
221 int h =
image->height;
223 if (free_image_at_end)
225 cvReleaseImage(&
image);
229 return new wxBitmap(wxImage(
w, h,
data,
false));
238 IplImage*
image =
static_cast<IplImage*
>(
img);
245 if (
image->origin == 1) options |= CV_CVTIMG_FLIP;
246 if (
image->channelSeq[0] ==
'B' &&
image->channelSeq[2] ==
'R')
247 options |= CV_CVTIMG_SWAP_RB;
254 unsigned char* imageData =
255 (
unsigned char*)malloc(row_bytes *
image->height);
259 if (row_bytes !=
image->widthStep)
261 for (
int y = 0;
y <
image->height;
y++)
263 (imageData +
y * row_bytes),
264 (
image->imageData +
y *
image->widthStep), row_bytes);
272 return new wxImage(
image->width,
image->height, imageData,
false);
283 const size_t lx =
img.GetWidth();
284 const size_t ly =
img.GetHeight();
287 lx, ly,
true,
img.GetData(),
true );
304 wxWindow* parent, wxWindowID winID,
int x,
int y,
int width,
int height)
307 this->Create(parent, winID, wxPoint(
x,
y), wxSize(
width,
height));
312 wxID_ANY, wxEVT_LEFT_DOWN,
320 std::lock_guard<std::mutex> lock(
m_img_cs);
342 std::lock_guard<std::mutex> lock(
m_img_cs);
356 std::lock_guard<std::mutex> lock(
m_img_cs);
370 std::lock_guard<std::mutex> lock(
m_img_cs);
377 dc.DrawBitmap(*
m_img, 0, 0);
382 std::lock_guard<std::mutex> lock(
m_img_cs);
447 wxStaticBoxSizer* StaticBoxSizer2;
448 wxFlexGridSizer* FlexGridSizer4;
449 wxFlexGridSizer* FlexGridSizer16;
450 wxFlexGridSizer* FlexGridSizer10;
451 wxFlexGridSizer* FlexGridSizer3;
452 wxFlexGridSizer* FlexGridSizer5;
453 wxFlexGridSizer* FlexGridSizer2;
454 wxFlexGridSizer* FlexGridSizer18;
455 wxFlexGridSizer* FlexGridSizer13;
456 wxFlexGridSizer* FlexGridSizer12;
457 wxStaticBoxSizer* StaticBoxSizer1;
458 wxFlexGridSizer* FlexGridSizer1;
459 wxFlexGridSizer* FlexGridSizer11;
462 parent,
id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL,
464 FlexGridSizer1 =
new wxFlexGridSizer(0, 1, 0, 0);
465 FlexGridSizer1->AddGrowableCol(0);
466 FlexGridSizer1->AddGrowableRow(0);
467 pagesCameras =
new wxNotebook(
468 this, ID_NOTEBOOK1, wxDefaultPosition, wxDefaultSize, 0,
470 Panel2 =
new wxPanel(
471 pagesCameras, ID_PANEL2, wxDefaultPosition, wxDefaultSize,
472 wxTAB_TRAVERSAL, _T(
"ID_PANEL2"));
473 FlexGridSizer10 =
new wxFlexGridSizer(0, 2, 0, 0);
474 FlexGridSizer10->AddGrowableCol(1);
475 StaticText1 =
new wxStaticText(
476 Panel2, ID_STATICTEXT1, _(
"Camera index:"), wxDefaultPosition,
477 wxDefaultSize, 0, _T(
"ID_STATICTEXT1"));
478 FlexGridSizer10->Add(
479 StaticText1, 1, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
480 opencvCamIndex =
new wxSpinCtrl(
481 Panel2, ID_SPINCTRL1, _T(
"0"), wxDefaultPosition, wxDefaultSize, 0, 0,
482 100, 0, _T(
"ID_SPINCTRL1"));
483 opencvCamIndex->SetValue(_T(
"0"));
484 FlexGridSizer10->Add(
485 opencvCamIndex, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
486 StaticText3 =
new wxStaticText(
487 Panel2, ID_STATICTEXT3, _(
"Camera type:"), wxDefaultPosition,
488 wxDefaultSize, 0, _T(
"ID_STATICTEXT3"));
489 FlexGridSizer10->Add(
491 wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
492 cbOpencvCamType =
new wxChoice(
493 Panel2, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 0, 0, 0,
494 wxDefaultValidator, _T(
"ID_CHOICE1"));
495 cbOpencvCamType->SetSelection(
496 cbOpencvCamType->Append(_(
"CAMERA_CV_AUTODETECT")));
497 cbOpencvCamType->Append(_(
"CAMERA_CV_DC1394"));
498 cbOpencvCamType->Append(_(
"CAMERA_CV_VFL"));
499 cbOpencvCamType->Append(_(
"CAMERA_CV_VFW"));
500 cbOpencvCamType->Append(_(
"CAMERA_CV_MIL"));
501 cbOpencvCamType->Append(_(
"CAMERA_CV_DSHOW"));
502 FlexGridSizer10->Add(
503 cbOpencvCamType, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
504 StaticText6 =
new wxStaticText(
505 Panel2, ID_STATICTEXT6, _(
"Resolution:"), wxDefaultPosition,
506 wxDefaultSize, 0, _T(
"ID_STATICTEXT6"));
507 FlexGridSizer10->Add(
508 StaticText6, 1, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
509 cbOpencvResolution =
new wxChoice(
510 Panel2, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, 0, 0, 0,
511 wxDefaultValidator, _T(
"ID_CHOICE2"));
512 cbOpencvResolution->SetSelection(cbOpencvResolution->Append(_(
"default")));
513 cbOpencvResolution->Append(_(
"320x240"));
514 cbOpencvResolution->Append(_(
"640x480"));
515 FlexGridSizer10->Add(
516 cbOpencvResolution, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL,
518 FlexGridSizer10->Add(
519 -1, -1, 1, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL,
521 Panel2->SetSizer(FlexGridSizer10);
522 FlexGridSizer10->Fit(Panel2);
523 FlexGridSizer10->SetSizeHints(Panel2);
524 Panel3 =
new wxPanel(
525 pagesCameras, ID_PANEL3, wxDefaultPosition, wxDefaultSize,
526 wxTAB_TRAVERSAL, _T(
"ID_PANEL3"));
527 FlexGridSizer11 =
new wxFlexGridSizer(0, 1, 0, 0);
528 FlexGridSizer11->AddGrowableCol(0);
529 StaticText7 =
new wxStaticText(
530 Panel3, ID_STATICTEXT7, _(
"IP Camera URL:"), wxDefaultPosition,
531 wxDefaultSize, 0, _T(
"ID_STATICTEXT7"));
532 FlexGridSizer11->Add(
533 StaticText7, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
534 edIPcamURL =
new wxTextCtrl(
535 Panel3, ID_TEXTCTRL1, _(
"rtsp://192.168.0.1/live.sdp"),
536 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator,
538 FlexGridSizer11->Add(
539 edIPcamURL, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
540 Panel3->SetSizer(FlexGridSizer11);
541 FlexGridSizer11->Fit(Panel3);
542 FlexGridSizer11->SetSizeHints(Panel3);
543 Panel4 =
new wxPanel(
544 pagesCameras, ID_PANEL4, wxDefaultPosition, wxDefaultSize,
545 wxTAB_TRAVERSAL, _T(
"ID_PANEL4"));
546 FlexGridSizer16 =
new wxFlexGridSizer(0, 1, 0, 0);
547 FlexGridSizer16->AddGrowableCol(0);
548 FlexGridSizer16->AddGrowableRow(0);
549 edCustomCamConfig =
new wxTextCtrl(
550 Panel4, ID_TEXTCTRL6,
551 _(
"// Configuration block for the CCameraSensor object.\n// Check out " 552 "its documentation at:\n// " 553 "http://reference.mrpt.org/devel/" 554 "classmrpt_1_1hwdrivers_1_1_c_camera_sensor.html\n\n[CONFIG]" 555 "\ngrabber_type = opencv \ncv_camera_index = 0\ncv_camera_type = " 556 "CAMERA_CV_AUTODETECT\n\n"),
557 wxDefaultPosition, wxDefaultSize,
558 wxTE_MULTILINE | wxHSCROLL | wxTE_DONTWRAP | wxVSCROLL |
560 wxDefaultValidator, _T(
"ID_TEXTCTRL6"));
561 wxFont edCustomCamConfigFont =
562 wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT);
563 if (!edCustomCamConfigFont.Ok())
564 edCustomCamConfigFont =
565 wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
566 edCustomCamConfigFont.SetPointSize(7);
567 edCustomCamConfig->SetFont(edCustomCamConfigFont);
568 FlexGridSizer16->Add(
569 edCustomCamConfig, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
570 Panel4->SetSizer(FlexGridSizer16);
571 FlexGridSizer16->Fit(Panel4);
572 FlexGridSizer16->SetSizeHints(Panel4);
573 Panel5 =
new wxPanel(
574 pagesCameras, ID_PANEL5, wxDefaultPosition, wxDefaultSize,
575 wxTAB_TRAVERSAL, _T(
"ID_PANEL5"));
576 FlexGridSizer12 =
new wxFlexGridSizer(0, 1, 0, 0);
577 FlexGridSizer12->AddGrowableCol(0);
578 StaticText8 =
new wxStaticText(
579 Panel5, ID_STATICTEXT8, _(
"Video file to open:"), wxDefaultPosition,
580 wxDefaultSize, 0, _T(
"ID_STATICTEXT8"));
581 FlexGridSizer12->Add(
582 StaticText8, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
583 edVideoFile =
new wxTextCtrl(
584 Panel5, ID_TEXTCTRL2, _(
"test.avi"), wxDefaultPosition, wxDefaultSize,
585 0, wxDefaultValidator, _T(
"ID_TEXTCTRL2"));
586 FlexGridSizer12->Add(
587 edVideoFile, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
588 btnBrowseVideo =
new wxButton(
589 Panel5, ID_BUTTON7, _(
"Browse..."), wxDefaultPosition, wxDefaultSize, 0,
590 wxDefaultValidator, _T(
"ID_BUTTON7"));
591 FlexGridSizer12->Add(
593 wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
594 Panel5->SetSizer(FlexGridSizer12);
595 FlexGridSizer12->Fit(Panel5);
596 FlexGridSizer12->SetSizeHints(Panel5);
597 Panel6 =
new wxPanel(
598 pagesCameras, ID_PANEL6, wxDefaultPosition, wxDefaultSize,
599 wxTAB_TRAVERSAL, _T(
"ID_PANEL6"));
600 FlexGridSizer13 =
new wxFlexGridSizer(0, 3, 0, 0);
601 FlexGridSizer13->AddGrowableCol(1);
602 StaticText9 =
new wxStaticText(
603 Panel6, ID_STATICTEXT9, _(
"Rawlog \nfile:"), wxDefaultPosition,
604 wxDefaultSize, 0, _T(
"ID_STATICTEXT9"));
605 FlexGridSizer13->Add(
606 StaticText9, 1, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
607 edRawlogFile =
new wxTextCtrl(
608 Panel6, ID_TEXTCTRL3, _(
"test.rawlog"), wxDefaultPosition,
609 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_TEXTCTRL3"));
610 FlexGridSizer13->Add(
611 edRawlogFile, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
612 btnBrowseRawlog =
new wxButton(
613 Panel6, ID_BUTTON8, _(
"Browse..."), wxDefaultPosition, wxDefaultSize, 0,
614 wxDefaultValidator, _T(
"ID_BUTTON8"));
615 FlexGridSizer13->Add(
617 wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
618 StaticText5 =
new wxStaticText(
619 Panel6, ID_STATICTEXT5, _(
"External \nimages:"), wxDefaultPosition,
620 wxDefaultSize, 0, _T(
"ID_STATICTEXT5"));
621 FlexGridSizer13->Add(
622 StaticText5, 1, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
623 edRawlogImgDir =
new wxTextCtrl(
624 Panel6, ID_TEXTCTRL7, _(
"./Images"), wxDefaultPosition, wxDefaultSize,
625 0, wxDefaultValidator, _T(
"ID_TEXTCTRL7"));
626 FlexGridSizer13->Add(
627 edRawlogImgDir, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
628 btnBrowseRawlogDir =
new wxButton(
629 Panel6, ID_BUTTON9, _(
"Browse..."), wxDefaultPosition, wxDefaultSize, 0,
630 wxDefaultValidator, _T(
"ID_BUTTON9"));
631 FlexGridSizer13->Add(
632 btnBrowseRawlogDir, 1,
633 wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
634 StaticText10 =
new wxStaticText(
635 Panel6, ID_STATICTEXT10, _(
"Sensor\nlabel:"), wxDefaultPosition,
636 wxDefaultSize, 0, _T(
"ID_STATICTEXT10"));
637 FlexGridSizer13->Add(
638 StaticText10, 1, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 5);
639 edRawlogLabel =
new wxTextCtrl(
640 Panel6, ID_TEXTCTRL8, wxEmptyString, wxDefaultPosition, wxDefaultSize,
641 0, wxDefaultValidator, _T(
"ID_TEXTCTRL8"));
642 FlexGridSizer13->Add(
643 edRawlogLabel, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
644 StaticText11 =
new wxStaticText(
645 Panel6, ID_STATICTEXT11, _(
"(empty=any)"), wxDefaultPosition,
646 wxDefaultSize, 0, _T(
"ID_STATICTEXT11"));
647 FlexGridSizer13->Add(
649 wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
650 Panel6->SetSizer(FlexGridSizer13);
651 FlexGridSizer13->Fit(Panel6);
652 FlexGridSizer13->SetSizeHints(Panel6);
653 Panel1 =
new wxPanel(
654 pagesCameras, ID_PANEL7, wxDefaultPosition, wxDefaultSize,
655 wxTAB_TRAVERSAL, _T(
"ID_PANEL7"));
656 FlexGridSizer18 =
new wxFlexGridSizer(2, 2, 0, 0);
657 wxString __wxRadioBoxChoices_1[2] = {_(
"Left"), _(
"Right")};
658 rbBumblebeeSel =
new wxRadioBox(
659 Panel1, ID_RADIOBOX1, _(
"Select monocular input"), wxDefaultPosition,
660 wxDefaultSize, 2, __wxRadioBoxChoices_1, 1, 0, wxDefaultValidator,
662 rbBumblebeeSel->SetSelection(0);
663 FlexGridSizer18->Add(
665 wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
666 cbBumblebeeRectif =
new wxCheckBox(
667 Panel1, ID_CHECKBOX1, _(
"Use vendor\'s rectify"), wxDefaultPosition,
668 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX1"));
669 cbBumblebeeRectif->SetValue(
false);
670 FlexGridSizer18->Add(
671 cbBumblebeeRectif, 1, wxALL | wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL,
673 FlexGridSizer18->Add(-1, -1, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
674 StaticText2 =
new wxStaticText(
675 Panel1, ID_STATICTEXT2, _(
"(Unchecked = raw images)"),
676 wxDefaultPosition, wxDefaultSize, 0, _T(
"ID_STATICTEXT2"));
677 FlexGridSizer18->Add(
678 StaticText2, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
679 Panel1->SetSizer(FlexGridSizer18);
680 FlexGridSizer18->Fit(Panel1);
681 FlexGridSizer18->SetSizeHints(Panel1);
682 pnSwissRanger =
new wxPanel(
683 pagesCameras, ID_PANEL1, wxDefaultPosition, wxDefaultSize,
684 wxTAB_TRAVERSAL, _T(
"ID_PANEL1"));
685 FlexGridSizer2 =
new wxFlexGridSizer(2, 3, 0, 0);
686 wxString __wxRadioBoxChoices_2[2] = {_(
"USB"), _(
"Ethernet")};
687 rbSR_usb =
new wxRadioBox(
688 pnSwissRanger, ID_RADIOBOX2, _(
"Connection"), wxDefaultPosition,
689 wxDefaultSize, 2, __wxRadioBoxChoices_2, 1, 0, wxDefaultValidator,
692 rbSR_usb, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
693 StaticText4 =
new wxStaticText(
694 pnSwissRanger, ID_STATICTEXT4, _(
"IP:"), wxDefaultPosition,
695 wxDefaultSize, 0, _T(
"ID_STATICTEXT4"));
697 StaticText4, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
698 edSR_IP =
new wxTextCtrl(
699 pnSwissRanger, ID_TEXTCTRL4, _(
"192.168.2.14"), wxDefaultPosition,
700 wxSize(120, -1), 0, wxDefaultValidator, _T(
"ID_TEXTCTRL4"));
702 edSR_IP, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
703 StaticBoxSizer1 =
new wxStaticBoxSizer(
704 wxHORIZONTAL, pnSwissRanger, _(
"Channels to grab: "));
705 FlexGridSizer3 =
new wxFlexGridSizer(4, 1, 0, 0);
706 cbSR_chIntensity =
new wxCheckBox(
707 pnSwissRanger, ID_CHECKBOX3, _(
"Grayscale intensity"),
708 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator,
710 cbSR_chIntensity->SetValue(
true);
711 cbSR_chIntensity->Disable();
713 cbSR_chIntensity, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
714 cbSR_ch3D =
new wxCheckBox(
715 pnSwissRanger, ID_CHECKBOX4, _(
"3D point cloud"), wxDefaultPosition,
716 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX4"));
717 cbSR_ch3D->SetValue(
false);
718 FlexGridSizer3->Add(cbSR_ch3D, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
719 cbSR_chRange =
new wxCheckBox(
720 pnSwissRanger, ID_CHECKBOX5, _(
"Depth image"), wxDefaultPosition,
721 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX5"));
722 cbSR_chRange->SetValue(
false);
724 cbSR_chRange, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
725 cbSR_chConf =
new wxCheckBox(
726 pnSwissRanger, ID_CHECKBOX6, _(
"Confidence"), wxDefaultPosition,
727 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX6"));
728 cbSR_chConf->SetValue(
false);
730 cbSR_chConf, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
731 StaticBoxSizer1->Add(
732 FlexGridSizer3, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_BOTTOM, 0);
734 StaticBoxSizer1, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_BOTTOM,
736 pnSwissRanger->SetSizer(FlexGridSizer2);
737 FlexGridSizer2->Fit(pnSwissRanger);
738 FlexGridSizer2->SetSizeHints(pnSwissRanger);
739 pnKinect =
new wxPanel(
740 pagesCameras, ID_PANEL8, wxDefaultPosition, wxDefaultSize,
741 wxTAB_TRAVERSAL, _T(
"ID_PANEL8"));
742 FlexGridSizer4 =
new wxFlexGridSizer(2, 3, 0, 0);
744 new wxStaticBoxSizer(wxHORIZONTAL, pnKinect, _(
"Channels to grab: "));
745 FlexGridSizer5 =
new wxFlexGridSizer(4, 1, 0, 0);
746 cbKinect_Int =
new wxCheckBox(
747 pnKinect, ID_CHECKBOX7, _(
"Intensity"), wxDefaultPosition,
748 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX7"));
749 cbKinect_Int->SetValue(
true);
750 cbKinect_Int->Disable();
752 cbKinect_Int, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
753 cbKinect_3D =
new wxCheckBox(
754 pnKinect, ID_CHECKBOX8, _(
"3D point cloud"), wxDefaultPosition,
755 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX8"));
756 cbKinect_3D->SetValue(
false);
758 cbKinect_3D, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
759 cbKinect_Depth =
new wxCheckBox(
760 pnKinect, ID_CHECKBOX9, _(
"Depth image"), wxDefaultPosition,
761 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX9"));
762 cbKinect_Depth->SetValue(
false);
764 cbKinect_Depth, 1, wxALL | wxALIGN_LEFT | wxALIGN_BOTTOM, 5);
765 StaticBoxSizer2->Add(
766 FlexGridSizer5, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_BOTTOM, 0);
768 StaticBoxSizer2, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_BOTTOM,
770 wxString __wxRadioBoxChoices_3[2] = {_(
"RGB camera"), _(
"IR camera")};
771 rbKinect_int =
new wxRadioBox(
772 pnKinect, ID_RADIOBOX3, _(
"Intensity channel:"), wxDefaultPosition,
773 wxDefaultSize, 2, __wxRadioBoxChoices_3, 1, 0, wxDefaultValidator,
775 rbKinect_int->SetSelection(0);
777 rbKinect_int, 1, wxALL | wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL, 5);
778 pnKinect->SetSizer(FlexGridSizer4);
779 FlexGridSizer4->Fit(pnKinect);
780 FlexGridSizer4->SetSizeHints(pnKinect);
781 pagesCameras->AddPage(Panel2, _(
"Camera (opencv)"),
false);
782 pagesCameras->AddPage(Panel3, _(
"Camera (FFmpeg)"),
false);
783 pagesCameras->AddPage(Panel4, _(
"Camera (custom)"),
false);
784 pagesCameras->AddPage(Panel5, _(
"Video file"),
false);
785 pagesCameras->AddPage(Panel6, _(
"Rawlog file"),
false);
786 pagesCameras->AddPage(Panel1, _(
"Bumblebee"),
false);
787 pagesCameras->AddPage(pnSwissRanger, _(
"SwissRanger ToF"),
false);
788 pagesCameras->AddPage(pnKinect, _(
"Kinect"),
false);
790 pagesCameras, 1, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 5);
791 cbGrayscale =
new wxCheckBox(
792 this, ID_CHECKBOX2, _(
"Capture in grayscale"), wxDefaultPosition,
793 wxDefaultSize, 0, wxDefaultValidator, _T(
"ID_CHECKBOX2"));
794 cbGrayscale->SetValue(
true);
796 cbGrayscale, 1, wxALL | wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP, 5);
797 SetSizer(FlexGridSizer1);
798 FlexGridSizer1->Fit(
this);
799 FlexGridSizer1->SetSizeHints(
this);
802 ID_BUTTON7, wxEVT_COMMAND_BUTTON_CLICKED,
805 ID_BUTTON8, wxEVT_COMMAND_BUTTON_CLICKED,
808 ID_BUTTON9, wxEVT_COMMAND_BUTTON_CLICKED,
810 OnbtnBrowseRawlogDirClick);
814 cbOpencvResolution->Clear();
815 cbOpencvResolution->SetSelection(cbOpencvResolution->Append(_(
"default")));
817 cbOpencvResolution->Append(_(
"320x240"));
818 cbOpencvResolution->Append(_(
"640x480"));
819 cbOpencvResolution->Append(_(
"800x600"));
820 cbOpencvResolution->Append(_(
"1024x768"));
821 cbOpencvResolution->Append(_(
"1280x1024"));
827 this, wxT(
"Choose a video to open"), wxT(
"."), wxT(
""),
828 wxT(
"Video files (*.avi;*.mpg;*.mov)|*.avi;*.mpg;*.mov|All files " 830 wxFD_OPEN | wxFD_FILE_MUST_EXIST);
832 if (dialog.ShowModal() == wxID_OK)
edVideoFile->SetValue(dialog.GetPath());
838 this, wxT(
"Choose a rawlog to open"), wxT(
"."), wxT(
""),
839 wxT(
"Rawlog files (*.rawlog;*.rawlog.gz)|*.rawlog;*.rawlog.gz|All " 841 wxFD_OPEN | wxFD_FILE_MUST_EXIST);
843 if (dialog.ShowModal() == wxID_OK)
850 string fil =
string(dialog.GetPath().mb_str());
852 fil_path +=
"/Images";
861 this, wxT(
"Choose the rawlog directory with external images"),
864 if (dialog.ShowModal() == wxID_OK)
888 cfg->
write(sect,
"grabber_type",
"opencv");
890 sect,
"cv_camera_index",
893 sect,
"cv_camera_type",
901 const size_t p = sRes.find(
"x");
902 if (
p != std::string::npos)
907 cfg->
write(sect,
"cv_frame_width", sW);
908 cfg->
write(sect,
"cv_frame_height", sH);
918 cfg->
write(sect,
"grabber_type",
"ffmpeg");
921 string(this->
edIPcamURL->GetValue().mb_str()));
932 std::vector<std::string> allSects;
934 for (
size_t idxSect = 0; idxSect < allSects.size(); idxSect++)
936 std::vector<std::string> keys;
938 for (
size_t i = 0; i < keys.size(); i++)
940 allSects[idxSect], keys[i],
941 cfgIn.
read_string(allSects[idxSect], keys[i],
""));
950 cfg->
write(sect,
"grabber_type",
"ffmpeg");
961 cfg->
write(sect,
"grabber_type",
"rawlog");
966 const string rawlog_lb =
968 if (!rawlog_lb.empty())
969 cfg->
write(sect,
"rawlog_camera_sensor_label", rawlog_lb);
980 cfg->
write(sect,
"grabber_type",
"bumblebee");
983 sect,
"bumblebee_mono",
988 cfg->
write(sect,
"bumblebee_fps", 15);
990 sect,
"bumblebee_get_rectified",
999 cfg->
write(sect,
"grabber_type",
"swissranger");
1001 cfg->
write(sect,
"sr_use_usb",
rbSR_usb->GetSelection() == 0);
1002 cfg->
write(sect,
"sr_IP",
string(
edSR_IP->GetValue().mb_str()));
1015 cfg->
write(sect,
"grabber_type",
"kinect");
1022 sect,
"kinect_video_rgb",
1029 cerr <<
"[MRPT CPanelCameraSelection] ERROR: Unknown camera " 1052 if (grab_type ==
"opencv")
1057 cfg->
read_int(sect,
"cv_camera_index", 0));
1061 const int w = cfg->
read_int(sect,
"cv_frame_width", 0);
1070 else if (grab_type ==
"ffmpeg")
1074 cfg->
read_string(sect,
"ffmpeg_url",
"rtsp://192.168.0.1/live.sdp");
1076 if (
url.substr(0, 5) ==
"rtsp:")
1087 else if (grab_type ==
"rawlog")
1095 cfg->
read_string(sect,
"rawlog_camera_sensor_label",
"");
1098 else if (grab_type ==
"bumblebee")
1103 cfg->
read_int(sect,
"bumblebee_mono", 0));
1105 cfg->
read_bool(sect,
"bumblebee_get_rectified",
false));
1107 else if (grab_type ==
"swissranger")
1112 cfg->
read_bool(sect,
"sr_use_usb",
true) ? 0 : 1);
1114 _U(cfg->
read_string(sect,
"sr_IP",
"192.168.0.1").c_str()));
1117 cfg->
read_bool(sect,
"sr_grab_grayscale",
true));
1120 cfg->
read_bool(sect,
"sr_grab_range",
false));
1122 cfg->
read_bool(sect,
"sr_grab_confidence",
false));
1126 "Error: Unknown choice in 'grabber_type': '%s'", grab_type.c_str());
1130 cfg->
read_bool(sect,
"capture_grayscale",
false));
1146 #endif // MRPT_HAS_WXWIDGETS wxTextCtrl * edRawlogFile
This class implements a config file-like interface over a memory-stored string list.
static const long ID_BUTTON9
static const long ID_CHOICE1
static const long ID_PANEL3
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
void GetBitmap(wxBitmap &bmp)
#define THROW_EXCEPTION(msg)
wxTextCtrl * edRawlogImgDir
void OnbtnBrowseRawlogDirClick(wxCommandEvent &event)
wxCheckBox * cbSR_chIntensity
static const long ID_SPINCTRL1
static const long ID_STATICTEXT9
static const long ID_STATICTEXT1
static const long ID_CHECKBOX4
static const long ID_RADIOBOX3
static const long ID_RADIOBOX2
void OnMouseMove(wxMouseEvent &ev)
static const long ID_PANEL1
static const long ID_CHECKBOX1
static const long ID_TEXTCTRL6
GLenum GLsizei GLenum GLenum const GLvoid * image
static const long ID_NOTEBOOK1
wxPoint m_last_mouse_point
virtual ~wxMRPTImageControl()
wxPoint m_last_mouse_click
wxMRPTImageControl(wxWindow *parent, wxWindowID winID, int x, int y, int width, int height)
static const long ID_CHECKBOX6
static const long ID_CHECKBOX5
wxImage * MRPTImage2wxImage(const mrpt::img::CImage &img)
Create a wxImage from a MRPT image.
void getAllKeys(const std::string §ion, 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.
wxImage * IplImage2wxImage(void *img)
Create a wxImage from a IPL image.
GLubyte GLubyte GLubyte GLubyte w
static const long ID_CHECKBOX3
static const long ID_TEXTCTRL8
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
static const long ID_TEXTCTRL3
std::shared_ptr< CImage > Ptr
#define ASSERT_(f)
Defines an assertion mechanism.
This class allows loading and storing values and vectors of different types from a configuration text...
static const long ID_TEXTCTRL1
void OnMouseClick(wxMouseEvent &ev)
static const long ID_CHECKBOX8
static const long ID_CHECKBOX7
wxCheckBox * cbKinect_Int
wxChoice * cbOpencvResolution
void OnbtnBrowseVideoClick(wxCommandEvent &event)
void readConfigIntoVideoSourcePanel(const std::string §, const mrpt::config::CConfigFileBase *cfg) const
static const long ID_CHOICE2
wxBitmap * MRPTImage2wxBitmap(const mrpt::img::CImage &img)
Create a wxBitmap from a MRPT image.
static const long ID_STATICTEXT6
wxCheckBox * cbBumblebeeRectif
static const long ID_TEXTCTRL2
static const long ID_CHECKBOX2
static const long ID_PANEL2
static const long ID_STATICTEXT3
void writeConfigFromVideoSourcePanel(const std::string §, mrpt::config::CConfigFileBase *cfg) const
static const long ID_PANEL5
GLsizei const GLchar ** string
wxRadioBox * rbBumblebeeSel
mrptKeyModifier keyEventToMrptKeyModifier(const wxKeyEvent &ev)
Extracts the key modifiers from a wxKeyEvent.
wxTextCtrl * edCustomCamConfig
static const long ID_STATICTEXT2
void getAllSections(std::vector< std::string > §ions) const override
Returns a list with all the section names.
void write(const std::string §ion, 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
wxCheckBox * cbKinect_Depth
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
wxSpinCtrl * opencvCamIndex
static const long ID_STATICTEXT10
bool read_bool(const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
static const long ID_TEXTCTRL7
static const long ID_TEXTCTRL4
wxNotebook * pagesCameras
static const long ID_STATICTEXT5
A panel to select the camera input from all the formats supported by MRPT.
void OnPaint(wxPaintEvent &ev)
static const long ID_CHECKBOX9
wxTextCtrl * edRawlogLabel
static const long ID_PANEL8
static const long ID_RADIOBOX1
static const long ID_PANEL4
GLenum GLsizei GLenum format
Classes for creating GUI windows for 2D and 3D visualization.
virtual ~CPanelCameraSelection()
static const long ID_PANEL7
void OnbtnBrowseRawlogClick(wxCommandEvent &event)
bool directoryExists(const std::string &fileName)
Test if a given directory exists (it fails if the given path refers to an existing file)...
mrpt::img::CImage::Ptr wxImage2MRPTImagePtr(const wxImage &img)
Create a MRPT image from a wxImage.
GLenum GLsizei GLsizei height
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
static const long ID_BUTTON7
GLsizei GLsizei GLenum GLenum const GLvoid * data
static void setImagesPathBase(const std::string &path)
static const long ID_STATICTEXT4
wxCheckBox * cbSR_chRange
static const long ID_STATICTEXT7
std::string extractFileDirectory(const std::string &filePath)
Extract the whole path (the directory) of a filename from a complete path plus name plus extension...
wxRadioBox * rbKinect_int
void AssignImage(wxBitmap *img)
Assigns this image.
A class for storing images as grayscale or RGB bitmaps.
static const long ID_PANEL6
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
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.
static const long ID_STATICTEXT8
wxChoice * cbOpencvCamType