libeblearntools
|
00001 /*************************************************************************** 00002 * Copyright (C) 2010 by Pierre Sermanet * 00003 * pierre.sermanet@gmail.com * 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Redistribution under a license not approved by the Open Source 00014 * Initiative (http://www.opensource.org) must display the 00015 * following acknowledgement in all advertising material: 00016 * This product includes software developed at the Courant 00017 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00018 * * The names of the authors may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00025 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef CAMERA_V4L2_H_ 00034 #define CAMERA_V4L2_H_ 00035 00036 #include "camera.h" 00037 00038 using namespace std; 00039 00040 namespace ebl { 00041 00045 template <typename Tdata> class camera_v4l2 : public camera<Tdata> { 00046 public: 00047 00049 // constructors/allocation 00050 00061 camera_v4l2(const char *device, int height = -1, int width = -1, 00062 bool grayscale = false, bool mode_rgb_ = true); 00063 00065 virtual ~camera_v4l2(); 00066 00068 // frame grabbing 00069 00071 virtual idx<Tdata> grab(); 00072 /* //! Return a new YUV frame. */ 00073 /* virtual idx<Tdata> grab_yuv(); */ 00074 /* //! Return a new RGB frame. */ 00075 /* virtual idx<Tdata> grab_rgb(); */ 00076 00077 private: 00078 00079 #ifdef __LINUX__ 00080 void print_controls(); 00081 int get_control(int id); 00082 void set_integer_control(int id, int val); 00083 void set_boolean_control(int id, bool val); 00084 void start(); 00085 #endif 00086 00087 00088 // members //////////////////////////////////////////////////////// 00089 protected: 00090 using camera<Tdata>::frame; 00091 using camera<Tdata>::frame_id_; 00092 using camera<Tdata>::grabbed; 00093 using camera<Tdata>::height; 00094 using camera<Tdata>::width; 00095 using camera<Tdata>::bresize; 00096 using camera<Tdata>::grayscale; 00097 bool started; 00098 int nbuffers; 00099 void* *buffers; 00100 int *sizes; 00101 int fd; 00102 bool mode_rgb; 00103 }; 00104 00105 } // end namespace ebl 00106 00107 #include "camera_v4l2.hpp" 00108 00109 00110 #endif /* CAMERA_V4L2_H_ */