Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
RawCamBehavior.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_RawCamBehavior_h_ 00003 #define INCLUDED_RawCamBehavior_h_ 00004 00005 #include "Behaviors/BehaviorBase.h" 00006 #include "Shared/Config.h" 00007 00008 class Socket; 00009 class FilterBankGenerator; 00010 class FilterBankEvent; 00011 00012 //! Forwards images from camera over wireless 00013 /*! The format used for serialization is basically defined by the 00014 * subclass of FilterBankGenerator being used. I suggest looking at 00015 * that classes's documentation to determine the format used. 00016 * 00017 * However, RawCamBehavior will add a few fields at the beginning of 00018 * each packet to assist in processing the image stream. 00019 * 00020 * I emphasize: <i>beginning</i> of each Vision packet, <i>before</i> the FilterBankGenerator header. 00021 * - <@c string:"TekkotsuImage"> 00022 * - <<tt>Config::vision_config::encoding_t</tt>: rawcam_encoding> <i>(expect single or multiple channels, 0 means color (3 channels), 1 means intensity (1 channel))</i> 00023 * - <<tt>Config::vision_config::compression_t</tt>: rawcam_compression> <i>(0==none, 1==jpeg, 2==rle)</i> 00024 * - <@c unsigned @c int: width> <i>(this is the width of the largest channel - note different channels can be sent at different resolutions! Provides cheap "compression" of chromaticity channels)</i> 00025 * - <@c unsigned @c int: height> <i>(similarly, height of largest channel)</i> 00026 * - <@c unsigned @c int: timestamp> <i>(time image was taken, milliseconds since boot)</i> 00027 * - <@c unsigned @c int: framenumber> <i>(incremented for each frame, so we can tell if/when we drop one)</i> 00028 * 00029 * This is exactly the same protocol that is followed by the SegCamBehavior as well - the same code can parse either stream. 00030 */ 00031 class RawCamBehavior : public BehaviorBase { 00032 public: 00033 //! constructor 00034 RawCamBehavior(); 00035 00036 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) 00037 static const unsigned int UDP_WIRELESS_BUFFER_SIZE=64*1024; //!< 64KB is the max udp packet size 00038 00039 virtual void DoStart(); 00040 00041 virtual void DoStop(); 00042 00043 virtual void processEvent(const EventBase& e); 00044 00045 virtual std::string getName() const { return "RawCamServer"; } 00046 00047 static std::string getClassDescription() { 00048 char tmp[20]; 00049 sprintf(tmp,"%d",config->vision.rle_port); 00050 return std::string("Forwards images from camera over port ")+tmp; 00051 } 00052 00053 protected: 00054 //! opens a new packet, writes header info; returns true if open, false if otherwise open (check cur==NULL for error) 00055 /*! see the class documentation for RawCamBehavior for the protocol documentation */ 00056 bool openPacket(FilterBankGenerator& fbkgen, unsigned int time, unsigned int layer); 00057 bool writeColor(const FilterBankEvent& fbke); //!< writes a color image 00058 bool writeSingleChannel(const FilterBankEvent& fbke); //!< writes a single channel 00059 void closePacket(); //!< closes and sends a packet, does nothing if no packet open 00060 00061 Socket * visRaw; //!< socket for sending the image stream 00062 char * packet; //!< point to the current buffer being prepared to be sent 00063 char * cur; //!< current location within that buffer 00064 unsigned int avail; //!< the number of bytes remaining in the buffer 00065 unsigned int max_buf; //!< the buffer size requested from Wireless when the socket was allocated 00066 00067 private: 00068 RawCamBehavior(const RawCamBehavior&); //!< don't call 00069 RawCamBehavior& operator=(const RawCamBehavior&); //!< don't call 00070 }; 00071 00072 /*! @file 00073 * @brief Describes RawCamBehavior, which forwards images from camera over wireless 00074 * @author ejt (Creator) 00075 * 00076 * $Author: ejt $ 00077 * $Name: tekkotsu-2_2 $ 00078 * $Revision: 1.9 $ 00079 * $State: Exp $ 00080 * $Date: 2004/09/28 22:12:30 $ 00081 */ 00082 00083 #endif |
Tekkotsu v2.2 |
Generated Tue Oct 19 14:19:15 2004 by Doxygen 1.3.9.1 |