uvc.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2012 by Markus Bader                                    *
00003  *   markus.bader@tuwien.ac.at                                             *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 
00022 #ifndef V4R_CAM_H
00023 #define V4R_CAM_H
00024 
00025 #include <boost/thread/thread.hpp>
00026 #include <boost/interprocess/sync/interprocess_mutex.hpp>
00027 
00028 #include <string>
00029 #include <vector>
00030 #include <sys/time.h>
00031 
00032 #define V4L2_CID_BASE_EXTCTR                            0x009A0900
00033 #define V4L2_CID_BASE_LOGITECH                          V4L2_CID_BASE_EXTCTR
00034 
00035 struct vdIn;
00036 struct v4l2_queryctrl;
00037 struct v4l2_control;
00038 
00040 class V4RCam
00041 {
00042 public:
00043     static const int OK = 0;
00044     static const int ERROR = 1;
00045     static const int NA = 0;
00046     static const int LOAD = 1;
00047     static const int SAVE = 2;
00048     typedef int FD;
00049     typedef boost::shared_ptr<v4l2_control> v4l2_controlPtr;  
00050     
00052     class ControlEntry
00053     {
00054     public:
00055         ControlEntry(int id); 
00056         ~ControlEntry(); 
00057         bool valid; 
00058         std::string varName; 
00059         v4l2_queryctrl *queryctrl; 
00060         int currentValue;    
00061         int targetValue;     
00062         std::stringstream info_msg;  
00063         std::stringstream error_msg; 
00064         std::string getQueryCtrlInfo() const; 
00065         bool hasValidType() const;  
00066         std::string pullErrorMsg();  
00067         std::string pullInfoMsg() ;  
00068         bool hasErrorMsg() const; 
00069         bool hasInfoMsg() const; 
00070     };
00071     typedef boost::shared_ptr<ControlEntry> ControlEntryPtr;  
00072     V4RCam(); 
00073     ~V4RCam(); 
00074 
00077     bool grab(); 
00078     ControlEntryPtr getControlEntry(std::string varName);
00079 protected:
00080     vdIn *pVideoIn_; 
00081     std::string videoDevice_; 
00082     std::string aviFilename_; 
00083     int format_; 
00084     int grabmethod_; 
00085     int width_; 
00086     int height_; 
00087     float fps_; 
00088     timeval timeLastFrame_; 
00089     double durationLastFrame_; 
00090     boost::interprocess::interprocess_mutex mutexImage_; 
00091     std::vector<ControlEntryPtr > controlEntries_;  
00092 
00093 public:
00099     FD initCamera(const std::string &videoDevice = "");
00100 
00102 
00108     int v4lgetInfo(ControlEntryPtr entry);
00115     int v4lget(ControlEntryPtr entry);
00116 
00123     int  v4lset(ControlEntryPtr entry);
00132     int  v4lupdate(ControlEntryPtr entry);
00133 
00138     bool isBlackListed(int control);
00139 
00144     const std::vector<ControlEntryPtr > &detectControlEnties();
00150     int save_controls(const std::string &filename);
00151 
00157     int load_controls(const std::string &filename);
00158 
00159 
00160     static char removeNonAlNum(char in);
00164     std::string pullErrorMsg() ;
00168     std::string pullInfoMsg() ;
00172     bool hasErrorMsg() const;
00176     bool hasInfoMsg() const;
00177 protected:
00178     std::stringstream info_msg_;
00179     std::stringstream error_msg_;
00180 };
00181 
00182 #endif // V4R_CAM_H
00183 
00184 


tuw_uvc
Author(s):
autogenerated on Sun May 29 2016 02:50:28