34 #include <Gui/ImageCanvas.hh>
35 #include <Gui/StringConv.hh>
37 #include <VideoSource/VideoSource_V4L.hh>
38 #include <VideoSource/VideoSourceCapabilities.hh>
42 #include <Base/Image/ImageConvert.hh>
43 #include <Base/Image/ImageIO.hh>
44 #include <Gui/StringConv.hh>
45 #include <Image/Camera.hh>
57 class MyApp :
public wxApp
59 virtual bool OnInit();
62 class MyFrame:
public wxFrame
66 MyFrame(
const wxString& title,
const wxPoint& pos,
const wxSize& size);
68 void OnQuit(wxCommandEvent& event);
69 void OnReconnect(wxCommandEvent& event);
70 void OnTimer(wxTimerEvent& event);
74 wxButton *QuitButton_, *WhiteBalanceButton_;
93 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
94 EVT_MENU(
ID_Quit, MyFrame::OnQuit)
95 EVT_MENU(ID_Reconnect, MyFrame::OnReconnect)
97 EVT_TIMER(
ID_TIMER, MyFrame::OnTimer)
105 new MyFrame( wxT(
"Example Video4Linux"), wxPoint(50,50), wxSize(800,600) );
113 MyFrame::MyFrame(
const wxString& title,
const wxPoint& pos,
const wxSize& size)
114 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
118 vector<string> devices;
121 if (devices.size()==0) {
122 cout <<
"No V4L devices found"<<endl;
126 for (
unsigned d=0; d<devices.size(); d++ )
127 cout <<
"Foud V4L device: "<<devices[d]<<endl;
130 cout <<
"Using: "<<device<<endl;
132 if ( cam->GetCapabilities(device.c_str(),caps) == 0 ) {
134 vector<VideoSourceCapabilities::ResolutionEntry> re;
137 for (
unsigned int i=0;i<re.size();i++){
138 cout <<
" Best for "<<re[i].width<<
"x"<<re[i].height<<
" is "
139 <<re[i].colormodel<<
" at fps: "<<re[i].fps<<endl;
143 cerr<<
"failed to open "<<device<<endl;
147 cam->SetSize(320,240);
149 int res = cam->OpenDevice(device.c_str());
151 cout<<
"Failed to open device "<<device<<endl;
157 cam->SetWaitForNew(
false);
162 wxMenu *menuFile =
new wxMenu;
163 menuFile->Append( ID_Quit, wxT(
"E&xit") );
164 menuFile->Append( ID_Reconnect, wxT(
"Reconnect") );
166 wxMenuBar *menuBar =
new wxMenuBar;
167 menuBar->Append( menuFile, wxT(
"&File") );
169 SetMenuBar( menuBar );
170 wxStatusBar* s = CreateStatusBar();
171 SetStatusText( wxT(
"") );
173 wxSizer *Sizer =
new wxBoxSizer( wxHORIZONTAL );
175 ic_ =
new ImageCanvas(
this,s,0,-1,wxDefaultPosition,wxSize(640,480));
177 Sizer->Add(ic_,1,wxEXPAND);
181 ic_->Show(pic,
"foo");
182 Timer_.SetOwner(
this, ID_TIMER);
186 Timer_.Start(100,
true);
189 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
198 void MyFrame::OnReconnect(wxCommandEvent& WXUNUSED(event))
212 cam->GetCapabilities(devs[0].c_str(),caps);
213 cam->OpenDevice(device.c_str());
216 cam->SetWaitForNew(
false);
217 Timer_.Start(100,
true);
222 void MyFrame::OnTimer(wxTimerEvent& event)
224 cam->GrabSingle(pic);
226 sprintf(name,
"image_%04i",imgNo);
240 Timer_.Start(20,
true);
YUYV422, 2 channels, full luminance Y, subsampled half U,V.
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
void AssignUUID(const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
function to assign a fresh, unique ID.
int GetAllDevices(std::vector< std::string > &devices)
Checks for VideoSource capabilities.
This class extends VideoSource for the use of Video4Linux supported devices like framegrabber, USB cameras.
interface class for producing/storing Universally Unique IDentifiers
void GetBestForEachResolution(std::vector< ResolutionEntry > &res)