Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

CameraDriverPtGrey.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_CameraDriverPtGrey_h_
00003 #define INCLUDED_CameraDriverPtGrey_h_
00004 
00005 #include "local/DeviceDriver.h"
00006 #include "local/DataSource.h"
00007 #include "Shared/get_time.h"
00008 #include "IPC/CallbackThread.h"
00009 
00010 #include <FlyCapture2.h>
00011 
00012 //! description of CameraDriverPtGrey
00013 class CameraDriverPtGrey : public virtual DeviceDriver, public virtual plist::PrimitiveListener, public DataSource
00014 {
00015 public:
00016   explicit CameraDriverPtGrey(const std::string& name)
00017     : DeviceDriver(autoRegisterCameraDriverPtGrey,name), DataSource(),
00018       index(0),
00019       thread(&CameraDriverPtGrey::threadrun,*this), lock(),
00020       cam(), frameCount(0), timestamp(0)
00021   {
00022     addEntry("Index",index,"Index of camera in PGR BusManager (should be same as flycap)");
00023   }
00024   
00025   ~CameraDriverPtGrey() {
00026     index.removePrimitiveListener(this);
00027   }
00028   
00029   virtual std::string getClassName() const { return autoRegisterCameraDriverPtGrey; }
00030   
00031   virtual void getImageSources(std::map<std::string,DataSource*>& sources) {
00032     sources.clear(); sources.insert(std::make_pair("Camera",this));
00033   }
00034   
00035   virtual unsigned int nextTimestamp() { return get_time(); }
00036   virtual const std::string& nextName() { return instanceName; }
00037   
00038   virtual bool advance();
00039   virtual void registerSource();
00040   virtual void deregisterSource();
00041   
00042   //! watches #index, triggers a close() and re-open() if it changes
00043   virtual void plistValueChanged(const plist::PrimitiveBase& pl);
00044   
00045   plist::Primitive<unsigned int> index;
00046   
00047 protected:
00048   void threadrun();
00049   CallbackThread thread;
00050   Thread::Lock lock; // buffer/img_size lock so we can't change resolution while reading
00051 
00052   void doFreeze();
00053   void doUnfreeze();
00054 
00055   void openCam();
00056   void closeCam();
00057 
00058   bool convertImage(FlyCapture2::Image & rawImage);
00059 
00060   FlyCapture2::Camera cam;
00061 
00062   unsigned int frameCount;
00063   unsigned int timestamp;
00064 
00065 private:
00066   //! holds the class name, set via registration with the DeviceDriver registry
00067   static const std::string autoRegisterCameraDriverPtGrey;
00068 };
00069 
00070 /*! @file
00071 * @brief 
00072 * @author Ethan Tira-Thompson (ejt)
00073 * @author Alex Grubb (agrubb1)
00074 */
00075 
00076 #endif

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Mon May 9 05:01:37 2016 by Doxygen 1.6.3