Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

DepthCam.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_DepthCam_h_
00002 #define INCLUDED_DepthCam_h_
00003 
00004 #include "CameraStreamBehavior.h"
00005 #include "Shared/Config.h"
00006 
00007 class Socket;
00008 class FilterBankGenerator;
00009 class FilterBankEvent;
00010 
00011 class DepthCam : public CameraStreamBehavior {
00012 public:
00013   //! constructor
00014   DepthCam();
00015   
00016   //! destructor
00017   ~DepthCam() { theOne=NULL; }
00018 
00019 #ifdef PLATFORM_APERIOS
00020   static const unsigned int TCP_WIRELESS_BUFFER_SIZE=200000; //!< 200000 bytes for use up to 416x320 + 2*208x160 (double res Y, full res UV on ERS-7)
00021 #else
00022   static const unsigned int TCP_WIRELESS_BUFFER_SIZE=640*480*2 + 1024; //!< size for full 640x480 depth map + 1KB for header
00023 #endif
00024   static const unsigned int UDP_WIRELESS_BUFFER_SIZE=64*1024; //!< 64KB is the max udp packet size
00025 
00026   virtual void doStart();
00027 
00028   virtual void doStop();
00029 
00030   virtual void doEvent();
00031 
00032   static std::string getClassDescription() {
00033     char tmp[20];
00034     snprintf(tmp,20,"%d",*config->vision.depthcam.port); tmp[19]='\0';
00035     return std::string("Forwards images from camera over port ")+tmp;
00036   }
00037   virtual std::string getDescription() const { return getClassDescription(); }
00038 
00039  protected:
00040   static DepthCam* theOne;
00041 
00042   static int networkCallback(char* buf, int bytes) { return theOne->receiveData(buf,bytes); }
00043 
00044   void setupServer(); //!<setup the server socket (#visDepth)
00045   void closeServer(); //!<tear down the server socket (#visDepth)
00046 
00047   bool openPacket(FilterBankGenerator& fbkgen, unsigned int time, unsigned int layer);
00048   bool writeDepth(const FilterBankEvent& fbke);
00049 
00050         void closePacket(); //!< closes and sends a packet, does nothing if no packet open
00051 
00052   bool sendCloseConnectionPacket();
00053 
00054   Socket* visDepth;
00055   char* packet;
00056   char* cur;
00057   unsigned int avail;
00058   unsigned int max_buf;
00059   unsigned int lastProcessedTime;
00060 
00061  private:
00062   DepthCam(const DepthCam&);
00063   DepthCam& operator=(const DepthCam&);
00064 };
00065 /*! @file
00066  * @brief Describes RawCam, which forwards images from camera over wireless
00067  * @author ejt (Creator)
00068  */
00069 
00070 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:37 2016 by Doxygen 1.6.3