33 #include <Base/Common/W32Compat.hh>
34 #include <VideoSource/VideoSource_DSHOW.hh>
35 #include <VideoSource/VideoSourceCapabilities.hh>
37 #include <Base/Image/ImageIO.hh>
38 #include <Base/Image/ImageConvert.hh>
39 #include <Image/Camera.hh>
40 #include <Gui/ImageCanvas.hh>
41 #include <Gui/ConsoleRedirectIO.hh>
42 #include <Gui/StringConv.hh>
43 #include <Base/Common/FileHandling.hh>
44 #include <Gui/VideoSource_Controller.hh>
54 class MyApp :
public wxApp
56 virtual bool OnInit();
59 class MyFrame:
public wxFrame
63 MyFrame(
const wxString& title,
const wxPoint& pos,
const wxSize& size);
65 void OnQuit(wxCommandEvent& event);
66 void OnTimer(wxTimerEvent& event);
70 wxButton *QuitButton_, *WhiteBalanceButton_;
89 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
90 EVT_MENU(
ID_Quit, MyFrame::OnQuit)
92 EVT_TIMER(
ID_TIMER, MyFrame::OnTimer)
101 new MyFrame( wxT(
"Example DirectShow"), wxPoint(50,50), wxSize(800,600) );
108 MyFrame::MyFrame(
const wxString& title,
const wxPoint& pos,
const wxSize& size)
109 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
112 vector<string> devices;
114 if (devices.size() ==0) {
115 cerr <<
"No devices found. Abort."<<endl;
120 cam->GetCapabilities(caps);
122 vector<VideoSourceCapabilities::ResolutionEntry> re;
124 for (
unsigned int i=0;i<re.size();i++)
125 cout <<
" Best for "<<re[i].width<<
"x"<<re[i].height<<
" is "
126 <<re[i].colormodel<<
" at fps: "<<re[i].fps<<endl;
128 cam->SetSize(720,480);
131 wxArrayString devStrings;
132 for(
unsigned i=0;i<devices.size();i++){
133 cout<<
"Found device:"<<devices[i]<<endl;
138 wxSingleChoiceDialog wcbDlg(
this,
139 wxT(
"Select camera."),
140 wxT(
"DShow Cameras"),
142 wcbDlg.SetSelection(0);
143 int ret = wcbDlg.ShowModal();
145 camera = WxToAscii(devStrings.Item(wcbDlg.GetSelection()));
148 int res = cam->OpenDevice(camera.c_str());
151 cout<<
"Failed to open device"<<endl;
154 float shutter = cam->GetShutter();
155 cout <<
"GetShutter: "<<shutter<<endl;
157 cout<<
"Setting shutter: "<<shutter<<endl;
158 cam->SetShutter(shutter);
159 cout <<
"GetShutter: "<<cam->GetShutter()<<endl;
161 float gain = cam->GetGain();
162 cout<<
"Gain:"<<gain<<endl;
164 cout<<
"Setting Gain:"<<gain<<endl;
166 cout<<
"Gain:"<<cam->GetGain()<<endl;
174 wxMenu *menuFile =
new wxMenu;
175 menuFile->Append( ID_Quit, wxT(
"E&xit") );
177 wxMenuBar *menuBar =
new wxMenuBar;
178 menuBar->Append( menuFile, wxT(
"&File") );
180 SetMenuBar( menuBar );
181 wxStatusBar* s = CreateStatusBar(2);
182 SetStatusText( wxT(
""),1 );
184 wxSizer *Sizer =
new wxBoxSizer( wxHORIZONTAL );
187 ic_ =
new ImageCanvas(
this,s,0,-1,wxDefaultPosition,wxSize(640,480));
188 Sizer->Add(ic_,1,wxEXPAND);
193 ic_->Show(pic,
"foo");
195 controller->Show(
true);
196 Timer_.SetOwner(
this, ID_TIMER);
197 Timer_.Start(100,
true);
200 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
211 void MyFrame::OnTimer(wxTimerEvent& event)
213 cam->GrabSingle(pic);
217 ic_->Show(pic,name.str());
224 Timer_.Start(50,
true);
YUYV422, 2 channels, full luminance Y, subsampled half U,V.
void BIASGui_EXPORT ConsoleRedirectIO(std::string name=std::string(""))
Extra Console for WIN32 WinMain gui applications.
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
extends the Image by MetaData support (e.g.
display image in wx application, provides zoom and investigation functionality
This class extends VideoSource for the use of DirectShow devices you need Microsoft Windows SDK versi...
static std::string LeadingZeroString(const int &n, const unsigned int &digits=DEFAULT_LEADING_ZEROS)
Create a string with leading zeroes from number.
Checks for VideoSource capabilities.
int GetAllDevices(std::vector< std::string > &devices)
void GetBestForEachResolution(std::vector< ResolutionEntry > &res)