40 char **local_argv =
new char *[argc];
41 for (
int i = 0; i < argc; i++)
42 local_argv[i] = strdup(wxString(argv[i]).mb_str());
73 : wxFrame(
NULL, -1, wxT(
"Color Gui"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE)
76 wxInitAllImageHandlers();
78 wxMenuBar *menuBar =
new wxMenuBar;
79 wxMenu *file_menu =
new wxMenu;
81 wxMenuItem *item = file_menu->Append(
ID_Reset, wxT(
"&Reset\tCtrl-R"));
84 item = file_menu->Append(wxID_EXIT, wxT(
"&Quit\tCtrl-Q"));
87 menuBar->Append(file_menu, _(
"&File"));
92 SetStatusText(_(
"Click on the image to select colors. Use scroll wheel to zoom."));
94 image_panel_ =
new wxPanel(
this, wxID_ANY, wxPoint(0, 0), wxSize(640, 480));
96 wxStaticText *rgblabel =
new wxStaticText(
this, -1, wxT(
"RGB:"));
97 rgbText_ =
new wxTextCtrl(
this, -1, wxT(
""));
99 wxStaticText *abLabel =
new wxStaticText(
this, -1, wxT(
"AB:"));
100 abText_ =
new wxTextCtrl(
this, -1, wxT(
""));
102 wxBoxSizer *hsizer1 =
new wxBoxSizer(wxHORIZONTAL);
103 wxBoxSizer *hsizer2 =
new wxBoxSizer(wxHORIZONTAL);
104 wxBoxSizer *vsizer =
new wxBoxSizer(wxVERTICAL);
106 hsizer2->Add(rgblabel, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
107 hsizer2->Add(
rgbText_, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 2);
109 hsizer2->Add(abLabel, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 10);
110 hsizer2->Add(
abText_, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 2);
111 hsizer2->Add(50, 1, 0);
114 vsizer->Add(20, 2, 0);
115 vsizer->Add(hsizer2, 0, wxALIGN_LEFT | wxEXPAND);
116 this->SetSizer(vsizer);
144 const sensor_msgs::Image img = *msg;
149 cv::Mat cvImage(image_ptr->image);
151 size = cvImage.size();
157 rgb_image_ =
new unsigned char[size.width * size.height * 3];
161 lab_image_ =
new unsigned char[size.width * size.height * 3];
176 cv::cvtColor(cvImage, cvImage, cv::COLOR_RGB2Lab);
192 wxBitmap bitmap(image);
195 memDC.SelectObject(bitmap);
198 if (xsrc < 0 || ysrc < 0)
201 dc.Blit(0, 0, 640, 480, &memDC, xsrc, ysrc);
214 dc.SetBrush(*wxTRANSPARENT_BRUSH);
223 dc.DrawRectangle(x1, y1, w, h);
237 rgbText_->SetValue(wxString::FromAscii(
""));
238 abText_->SetValue(wxString::FromAscii(
""));
243 int r, g, b, l, a, b2;
252 std::ostringstream stream1;
253 stream1 <<
"(" << r <<
", " << g <<
", " << b <<
")";
254 rgbText_->SetValue(wxString::FromAscii(stream1.str().c_str()));
260 int l_low, l_high, a_low, a_high, b_low, b_high;
264 if (a_low == 0 && a_high == 0)
269 if (b_low == 0 && b_high == 0)
283 std::ostringstream stream;
284 stream <<
"( " << a_low <<
":" << a_high <<
", "
285 << b_low <<
":" << b_high <<
" ) ";
287 abText_->SetValue(wxString::FromAscii(stream.str().c_str()));
292 if (event.GetWheelRotation() < 0)