26 #include <VideoSource/VideoSource_PMD.hh>
27 #include <Utils/Param.hh>
29 #include <VideoSource/VideoShMFeederPMD.hh>
32 #include <Gui/StringConv.hh>
33 #include <Base/Debug/Exception.hh>
45 class MyApp :
public wxApp
47 virtual bool OnInit();
51 class MyFrame:
public wxFrame
55 MyFrame(
const wxString& title,
const wxPoint& pos,
const wxSize& size);
57 void OnQuit(wxCommandEvent& event);
58 void OnAbout(wxCommandEvent& event);
59 void OnFrequency(wxScrollEvent& event);
60 void OnIntegrationTime(wxScrollEvent& event);
61 void OnTimer(wxTimerEvent& event);
62 void OnGetFrequency(wxCommandEvent& event);
63 void OnGetIntegrationTime(wxCommandEvent& event);
67 wxButton *QuitButton_;
68 wxSlider *SliderFrequency_;
69 wxSlider *SliderIntegrationTime_;
73 Camera<
unsigned char> GrabImage_;
75 Camera<
float> ModCoeffImage_;
77 const
string ShmPrefix_;
90 ID_SLIDER_INTEGRATIONTIME,
99 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
100 EVT_MENU(
ID_Quit, MyFrame::OnQuit)
101 EVT_MENU(
ID_About, MyFrame::OnAbout)
102 EVT_COMMAND_SCROLL(ID_SLIDER_FREQUENCY, MyFrame::OnFrequency)
103 EVT_COMMAND_SCROLL(ID_SLIDER_INTEGRATIONTIME, MyFrame::OnIntegrationTime)
105 EVT_TIMER(
ID_TIMER, MyFrame::OnTimer)
114 new MyFrame( wxT(
"PMDCamToShm"), wxPoint(0,700), wxSize(250,300) );
121 MyFrame::MyFrame(
const wxString& title,
const wxPoint& pos,
const wxSize& size)
122 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
124 wxMenu *menuFile =
new wxMenu;
126 menuFile->Append( ID_About, wxT(
"&About...") );
127 menuFile->AppendSeparator();
128 menuFile->Append( ID_Quit, wxT(
"E&xit") );
130 wxMenuBar *menuBar =
new wxMenuBar;
131 menuBar->Append( menuFile, wxT(
"&File") );
133 SetMenuBar( menuBar );
135 wxSizer *Sizer =
new wxBoxSizer( wxVERTICAL );
137 wxStaticText *FrequencyLabel =
138 new wxStaticText(
this, -1,
AsciiToWx(
"Modulation Frequency[MHz] "));
140 new wxSlider(
this, ID_SLIDER_FREQUENCY, 20, 0, 60, wxDefaultPosition,
141 wxDefaultSize,wxSL_LABELS | wxSL_HORIZONTAL, wxDefaultValidator,
144 wxStaticText *TimeLabel =
145 new wxStaticText(
this, -1,
AsciiToWx(
"Integration Time [us]"));
146 SliderIntegrationTime_ =
147 new wxSlider(
this, ID_SLIDER_INTEGRATIONTIME, 20000, 0, 80000, wxDefaultPosition,
148 wxDefaultSize, wxSL_LABELS | wxSL_HORIZONTAL, wxDefaultValidator,
152 new wxButton(
this, ID_BUTTON_QUIT,
AsciiToWx(
"Quit"), wxDefaultPosition,
153 wxDefaultSize, 0, wxDefaultValidator,
158 Sizer->Add(FrequencyLabel, 0, wxCENTER|wxTOP|wxRIGHT|wxLEFT, 10);
159 Sizer->Add(SliderFrequency_, 0, wxCENTER|wxALL|wxEXPAND, 10);
160 Sizer->Add(TimeLabel, 0, wxCENTER|wxTOP|wxRIGHT|wxLEFT, 10);
161 Sizer->Add(SliderIntegrationTime_, 0, wxCENTER|wxALL|wxEXPAND,10);
162 Sizer->Add(QuitButton_, 0, wxCENTER|wxALL,10);
166 SetStatusText( wxT(
"") );
168 Timer_.SetOwner(
this, ID_TIMER);
169 ShmName_ =
"PMD_SHM_MIP.shm";
170 cout <<
"Using: "<<ShmName_<<endl;
177 Cam_.InitImage(GrabImage_);
183 OnGetFrequency(cevt);
184 OnGetIntegrationTime(cevt);
185 Timer_.Start(20,
true);
188 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
195 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
197 wxMessageBox(wxT(
"This Application grabs images from a PMD cam\n and stores them in a shared memory\n named: PMD_SHM_MIP"),
198 wxT(
"PMDCamToShm"), wxOK | wxICON_INFORMATION,
this);
201 void MyFrame::OnFrequency(wxScrollEvent& event)
203 int value = SliderFrequency_->GetValue();
204 int frequency = value;
205 if (Cam_.SetModulationFrequency(frequency)!=0){
206 BEXCEPTION(
"error setting camera");
208 cout <<
"setting frequency: "<<frequency<<endl;
211 void MyFrame::OnIntegrationTime(wxScrollEvent& event)
213 int value = SliderIntegrationTime_->GetValue();
215 if (Cam_.SetIntegrationTime(time)!=0){
216 BEXCEPTION(
"error setting camera");
218 cout <<
"setting integration time: "<<time<<endl;
221 void MyFrame::OnGetFrequency(wxCommandEvent& event)
223 unsigned int frequency = 0;
224 if(Cam_.GetModulationFrequency(frequency)<=0) {
225 BEXCEPTION(
"error getting camera");
227 SliderFrequency_->SetValue(frequency);
228 cout <<
"frequency: "<<frequency<<endl;
231 void MyFrame::OnGetIntegrationTime(wxCommandEvent& event)
234 unsigned int time = 0;
235 if (Cam_.GetIntegrationTime(time)<=0){
236 BEXCEPTION(
"error getting integration time");
238 SliderIntegrationTime_->SetValue(time);
239 cout <<
"integration time: "<<time<<endl;
242 void MyFrame::OnTimer(wxTimerEvent& event)
244 Cam_.GrabSingle(GrabImage_);
245 Cam_.GrabSingleDepth(DepthImage_);
246 Cam_.GrabSingleModCoeff(ModCoeffImage_);
248 pShmFeeder_->ProcessImage(&GrabImage_,&DepthImage_,&ModCoeffImage_);
249 cout <<framecount_++<<endl;
250 Timer_.Start(20,
true);
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
extends the Image by MetaData support (e.g.
class to save Images to a Sharerd memory.
Support for CamCube usb cam.