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 WIRELESS_BUFFER_SIZE=200000; //!< 200000 bytes for use up to 416x320 + 2*208x160 (double res Y, full res UV on ERS-7) 00037 00038 virtual void DoStart(); 00039 00040 virtual void DoStop(); 00041 00042 virtual void processEvent(const EventBase& e); 00043 00044 virtual std::string getName() const { return "RawCamServer"; } 00045 00046 static std::string getClassDescription() { 00047 char tmp[20]; 00048 sprintf(tmp,"%d",config->vision.rle_port); 00049 return std::string("Forwards images from camera over port ")+tmp; 00050 } 00051 00052 protected: 00053 //! opens a new packet, writes header info; returns true if open, false if otherwise open (check cur==NULL for error) 00054 /*! see the class documentation for RawCamBehavior for the protocol documentation */ 00055 bool openPacket(FilterBankGenerator& fbkgen, unsigned int time, unsigned int layer); 00056 bool writeColor(const FilterBankEvent& fbke); //!< writes a color image 00057 bool writeSingleChannel(const FilterBankEvent& fbke); //!< writes a single channel 00058 void closePacket(); //!< closes and sends a packet, does nothing if no packet open 00059 00060 Socket * visRaw; //!< socket for sending the image stream 00061 char * packet; //!< point to the current buffer being prepared to be sent 00062 char * cur; //!< current location within that buffer 00063 unsigned int avail; //!< the number of bytes remaining in the buffer 00064 00065 private: 00066 RawCamBehavior(const RawCamBehavior&); //!< don't call 00067 RawCamBehavior& operator=(const RawCamBehavior&); //!< don't call 00068 }; 00069 00070 /*! @file 00071 * @brief Describes RawCamBehavior, which forwards images from camera over wireless 00072 * @author ejt (Creator) 00073 * 00074 * $Author: ejt $ 00075 * $Name: tekkotsu-2_1 $ 00076 * $Revision: 1.8 $ 00077 * $State: Exp $ 00078 * $Date: 2004/02/05 23:33:41 $ 00079 */ 00080 00081 #endif |
Tekkotsu v2.1 |
Generated Tue Mar 16 23:19:15 2004 by Doxygen 1.3.5 |