GrabbingDevice.h
Go to the documentation of this file.
00001 #ifndef GRABBING_DEVICE_H
00002 #define GRABBING_DEVICE_H
00003 
00004 
00005 // unicap bindings
00006 extern "C"
00007 {
00008 #include <unicap/unicap.h>
00009 #include <unicap/ucil.h>
00010 }
00011 
00012 #include <string>
00013 #include "GrabberUtils.h"
00014 // check ..
00015 #include <sys/types.h>
00016 #include <linux/types.h>
00017 
00018 
00019 namespace puma2
00020 {
00021 
00022   // ************ FORWARDS ********************************
00023   class Image;
00024   class ColorImageRGBa8;
00025   class ColorImageRGB8;
00026 
00027   // ************ TYPEDEFS ********************************
00028   typedef std::vector<unicap_format_t*> format_ptr_vec;
00029   typedef std::vector<unicap_property_t*> property_ptr_vec;
00030   typedef std::vector<unicap_data_buffer_t*> data_buffer_ptr_vec;
00031 
00032   union property_value_t
00033   {
00034     char menuItem[128];
00035     double value;
00036     void* data;
00037     u_int64_t flags;
00038   };
00039 
00044   class GrabbingDevice
00045   {
00046     public:
00047 
00053       GrabbingDevice ( unicap_handle_t _handle );
00054 
00055       ~GrabbingDevice();
00056 
00057       //*********** DEVICE SETUP *****************************
00058 
00063       bool setFormat ( int width, int height, std::string fourcc );
00064 
00069       bool setFormat ( const uint _formatId, const uint _subformatId );
00070 
00072       bool setNumBuffers ( uint _numBuffers );
00073 
00080       bool setProperty ( const std::string &_name, const std::string &_value );
00081 
00089       bool setProperty ( const std::string &_name, double &_value, bool _normalized = true );
00090 
00092       bool setProperty ( unicap_property_t &_property );
00093 
00094 
00095       //*********** CAPTURING **********************************
00096 
00101       bool startCapture();
00102 
00104       bool stopCapture();
00105 
00112       bool grabImage ( ColorImageRGB8 &_image );
00113 
00119       bool grabData ( unsigned char  *_data, std::string fourcc );
00120 
00125       void cleanBuffers();
00126 
00127       //*********** DEVICE INFO *****************************
00128 
00130       std::string getModelName() { return std::string( m_Device.model_name ); }
00131 
00133       std::string getVendorName() { return std::string( m_Device.vendor_name ); }
00134 
00136       std::string getIdentifier() { return std::string( m_Device.identifier ); }
00137 
00139       std::string getDevice() { return std::string( m_Device.device ); }
00140 
00142       std::string getBusType() { return std::string( m_Device.cpi_layer ); }
00143 
00145       unsigned long long getSerialNumber() { return m_Device.model_id; }
00146 
00147       uint getNumBuffers();
00148 
00149       //*********** FORMATS INFO *********************************
00150 
00152       std::string getFormatsList();
00153 
00155       std::string getFormatDesc();
00156 
00158       uint getFormatDepth();
00159 
00161       uint getFrameWidth();
00162 
00164       uint getFrameHeight();
00165 
00167       uint getFrameSize();
00168 
00169 
00170       //*********** PROPERTIES *****************************
00171 
00173       std::string getPropertiesList();
00174 
00176       std::string getPropertyInfo( const std::string &_desc );
00177 
00178       bool getProperty ( unicap_property_t **_property, uint _id );
00179 
00180       bool getProperty ( unicap_property_t **_property, std::string &_desc );
00181 
00182     private:
00183 
00184       bool setOutputColorspace ( std::string fourcc );
00185 
00187       bool setOutputColorspace ( uint _fourcc );
00188 
00190       bool setFormat ( unicap_format_t* _format );
00191 
00195       bool findFormatById ( unicap_format_t** _format, const uint _formatId, const uint _subformatId );
00196 
00200       bool findPropertyById ( unicap_property_t** _property, const uint _id );
00201 
00203       std::string getFormatDesc ( const uint _formatId );
00204 
00208       bool findPropertyByDesc ( unicap_property_t** _property, const std::string &_desc );
00209 
00210       bool setProperty ( const std::string &_name, property_value_t &_value, bool _normalized = true );
00211 
00215       bool prepareBuffers();
00216 
00220       bool detectFormats();
00221 
00225       bool detectProperties();
00226 
00227       unicap_handle_t m_Handle;
00228       unicap_device_t m_Device;
00229 
00230       unsigned int m_TargetFourCC;
00231       unicap_data_buffer_t m_ConvertedBuffer;
00232 
00233       // store formats & properties infos
00234       format_ptr_vec m_Formats;
00235       property_ptr_vec m_Properties;
00236 
00237       // one elemt of m_Format
00238       unicap_format_t* m_CurrentFormat;
00239 
00240       // ******* buffers **************
00241       uint m_NumBuffers;
00242       data_buffer_ptr_vec m_Buffers;
00243   };
00244 
00245 
00246 }
00247 
00248 #endif


obj_rec_gui
Author(s): AGAS/agas@uni-koblenz.de
autogenerated on Mon Oct 6 2014 02:53:43