uvc.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2012 by Markus Bader *
3  * markus.bader@tuwien.ac.at *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 
22 #ifndef V4R_CAM_H
23 #define V4R_CAM_H
24 
25 #include <boost/thread/thread.hpp>
26 #include <boost/interprocess/sync/interprocess_mutex.hpp>
27 
28 #include <string>
29 #include <vector>
30 #include <sys/time.h>
31 
32 #define V4L2_CID_BASE_EXTCTR 0x009A0900
33 #define V4L2_CID_BASE_LOGITECH V4L2_CID_BASE_EXTCTR
34 
35 struct vdIn;
36 struct v4l2_queryctrl;
37 struct v4l2_control;
38 
40 class V4RCam
41 {
42 public:
43  static const int OK = 0;
44  static const int ERROR = 1;
45  static const int NA = 0;
46  static const int LOAD = 1;
47  static const int SAVE = 2;
48  typedef int FD;
50 
53  {
54  public:
55  ControlEntry(int id);
56  ~ControlEntry();
57  bool valid;
58  std::string varName;
59  v4l2_queryctrl *queryctrl;
62  std::stringstream info_msg;
63  std::stringstream error_msg;
64  std::string getQueryCtrlInfo() const;
65  bool hasValidType() const;
66  std::string pullErrorMsg();
67  std::string pullInfoMsg() ;
68  bool hasErrorMsg() const;
69  bool hasInfoMsg() const;
70  };
72  V4RCam();
73  ~V4RCam();
74 
77  bool grab();
78  ControlEntryPtr getControlEntry(std::string varName);
79 protected:
81  std::string videoDevice_;
82  std::string aviFilename_;
83  int format_;
85  int width_;
86  int height_;
87  float fps_;
88  timeval timeLastFrame_;
90  boost::interprocess::interprocess_mutex mutexImage_;
91  std::vector<ControlEntryPtr > controlEntries_;
92 
93 public:
99  FD initCamera(const std::string &videoDevice = "");
100 
102 
108  int v4lgetInfo(ControlEntryPtr entry);
115  int v4lget(ControlEntryPtr entry);
116 
123  int v4lset(ControlEntryPtr entry);
132  int v4lupdate(ControlEntryPtr entry);
133 
138  bool isBlackListed(int control);
139 
144  const std::vector<ControlEntryPtr > &detectControlEnties();
150  int save_controls(const std::string &filename);
151 
157  int load_controls(const std::string &filename);
158 
159 
160  static char removeNonAlNum(char in);
164  std::string pullErrorMsg() ;
168  std::string pullInfoMsg() ;
172  bool hasErrorMsg() const;
176  bool hasInfoMsg() const;
177 protected:
178  std::stringstream info_msg_;
179  std::stringstream error_msg_;
180 };
181 
182 #endif // V4R_CAM_H
183 
184 
static const int ERROR
Definition: uvc.h:44
bool isBlackListed(int control)
int v4lset(ControlEntryPtr entry)
Definition: uvc.cpp:181
int FD
Definition: uvc.h:48
ControlEntry(int id)
Definition: uvc.cpp:252
bool hasInfoMsg() const
returns false if therer are any error msgs waiting for pull
Definition: uvc.cpp:327
v4l2 camera abstraction
Definition: uvc.h:40
const std::vector< ControlEntryPtr > & detectControlEnties()
Definition: uvc.cpp:352
static const int SAVE
Definition: uvc.h:47
v4l2_queryctrl * queryctrl
name of the v4l2 control
Definition: uvc.h:59
int format_
not supported yet
Definition: uvc.h:83
bool hasValidType() const
creates an info string related to the v4l2 control
Definition: uvc.cpp:265
std::stringstream error_msg
info msgs stream
Definition: uvc.h:63
int height_
image width
Definition: uvc.h:86
std::string videoDevice_
pointer to the v4l2 device
Definition: uvc.h:81
static const int LOAD
Definition: uvc.h:46
boost::shared_ptr< v4l2_control > v4l2_controlPtr
Definition: uvc.h:49
std::string aviFilename_
device name /dev/videoX
Definition: uvc.h:82
std::string varName
Definition: uvc.h:58
std::string pullErrorMsg()
return true if the value type is supported
Definition: uvc.cpp:311
int grabmethod_
image formate
Definition: uvc.h:84
bool grab()
destructor
Definition: uvc.cpp:105
int save_controls(const std::string &filename)
Definition: uvc.cpp:388
static const int NA
Definition: uvc.h:45
std::stringstream error_msg_
Definition: uvc.h:179
int v4lupdate(ControlEntryPtr entry)
Definition: uvc.cpp:200
std::stringstream info_msg
target value to set after a write
Definition: uvc.h:62
timeval timeLastFrame_
frames per second
Definition: uvc.h:88
Definition: utils.c:55
static char removeNonAlNum(char in)
Definition: uvc.cpp:51
bool valid
destructor
Definition: uvc.h:57
int width_
Definition: uvc.h:85
ControlEntryPtr getControlEntry(std::string varName)
Definition: uvc.cpp:449
Definition: v4l2uvc.h:43
std::string getQueryCtrlInfo() const
error msgs in the case something happend
Definition: uvc.cpp:278
boost::interprocess::interprocess_mutex mutexImage_
duration between last and the frame before the last one
Definition: uvc.h:90
int targetValue
current value of the control after read or set
Definition: uvc.h:61
int v4lgetInfo(ControlEntryPtr entry)
v4lcontrols
Definition: uvc.cpp:128
vdIn * pVideoIn_
Definition: uvc.h:80
std::vector< ControlEntryPtr > controlEntries_
mutex to secure critical sections
Definition: uvc.h:91
int load_controls(const std::string &filename)
Definition: uvc.cpp:425
double durationLastFrame_
time stamp of the last frame
Definition: uvc.h:89
boost::shared_ptr< ControlEntry > ControlEntryPtr
Definition: uvc.h:71
int v4lget(ControlEntryPtr entry)
Definition: uvc.cpp:161
static const int OK
Definition: uvc.h:43
V4RCam()
shared pointer for ControlEntry
Definition: uvc.cpp:67
bool hasErrorMsg() const
clears the info_msgs stringstream and crates a info string
Definition: uvc.cpp:323
shared pointer for v4l2 control entries
Definition: uvc.h:52
std::stringstream info_msg_
Definition: uvc.h:178
FD initCamera(const std::string &videoDevice="")
vector of the current supported control entries
Definition: uvc.cpp:80
~V4RCam()
construtor
Definition: uvc.cpp:58
int currentValue
pointer to the original related control
Definition: uvc.h:60
float fps_
image height
Definition: uvc.h:87
std::string pullInfoMsg()
clears the error_msgs stringstream and crates a info string
Definition: uvc.cpp:317
~ControlEntry()
construtor
Definition: uvc.cpp:261


tuw_uvc
Author(s): Markus Bader
autogenerated on Mon Jun 10 2019 15:39:24