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_H_ 00034 #define CAMERA_H_ 00035 00036 #include "libidx.h" 00037 00038 #ifdef __GUI__ 00039 #include "libidxgui.h" 00040 #endif 00041 00042 using namespace std; 00043 00044 namespace ebl { 00045 00050 template <typename Tdata> class camera { 00051 public: 00052 // constructors/allocation ///////////////////////////////////////////////// 00053 00061 camera(int height = -1, int width = -1, std::ostream &out = std::cout, 00062 std::ostream &err = std::cerr); 00064 virtual ~camera(); 00065 00066 // frame grabbing ////////////////////////////////////////////////////////// 00067 00069 virtual idx<Tdata> grab() = 0; 00072 virtual string grab_filename(); 00076 virtual void next(); 00078 virtual void previous(); 00080 virtual bool empty(); 00082 virtual void skip(uint n); 00085 virtual void set_input_narrow(int dim, int size, int off); 00087 virtual void set_grayscale(); 00088 00089 // video recording ///////////////////////////////////////////////////////// 00090 00094 virtual bool start_recording(uint window_id = 0, const char *name = NULL); 00096 virtual bool record_frame(); 00101 virtual bool stop_recording(float fps, const char *root = NULL); 00102 00103 // info //////////////////////////////////////////////////////////////////// 00104 00106 virtual float fps(); 00108 virtual uint frame_id(); 00110 virtual string frame_name(); 00112 virtual string frame_fullname(); 00114 virtual int remaining(); 00117 virtual int size(); 00118 00119 // internal methods //////////////////////////////////////////////////////// 00120 protected: 00121 00125 virtual idx<Tdata> postprocess(); 00126 00127 // members ///////////////////////////////////////////////////////////////// 00128 protected: 00129 idx<Tdata> frame; 00130 int height; 00131 int width; 00132 bool bresize; 00133 bool mresize; 00134 uint resize_mode; 00135 uint frame_id_; 00136 string frame_name_; 00137 bool grabbed; 00138 uint wid; 00139 string recording_name; 00140 uint record_cnt; 00141 float fps_grab; 00142 string audio_filename; 00143 std::ostream &out; 00144 std::ostream &err; 00145 timer tfps; 00146 long fps_ms_elapsed; 00147 uint cntfps; 00148 int narrow_dim, narrow_size, narrow_off; 00149 bool grayscale; 00150 }; 00151 00152 } // end namespace ebl 00153 00154 #include "camera.hpp" 00155 00156 #endif /* CAMERA_H_ */