catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NonMaximumSuppression.h Source File

NonMaximumSuppression.h

00001 #ifndef _ROS_SERVICE_NonMaximumSuppression_h
00002 #define _ROS_SERVICE_NonMaximumSuppression_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 #include "jsk_recognition_msgs/Rect.h"
00008 
00009 namespace jsk_recognition_msgs
00010 {
00011 
00012 static const char NONMAXIMUMSUPPRESSION[] = "jsk_recognition_msgs/NonMaximumSuppression";
00013 
00014   class NonMaximumSuppressionRequest : public ros::Msg
00015   {
00016     public:
00017       uint32_t rect_length;
00018       typedef jsk_recognition_msgs::Rect _rect_type;
00019       _rect_type st_rect;
00020       _rect_type * rect;
00021       typedef float _threshold_type;
00022       _threshold_type threshold;
00023 
00024     NonMaximumSuppressionRequest():
00025       rect_length(0), rect(NULL),
00026       threshold(0)
00027     {
00028     }
00029 
00030     virtual int serialize(unsigned char *outbuffer) const
00031     {
00032       int offset = 0;
00033       *(outbuffer + offset + 0) = (this->rect_length >> (8 * 0)) & 0xFF;
00034       *(outbuffer + offset + 1) = (this->rect_length >> (8 * 1)) & 0xFF;
00035       *(outbuffer + offset + 2) = (this->rect_length >> (8 * 2)) & 0xFF;
00036       *(outbuffer + offset + 3) = (this->rect_length >> (8 * 3)) & 0xFF;
00037       offset += sizeof(this->rect_length);
00038       for( uint32_t i = 0; i < rect_length; i++){
00039       offset += this->rect[i].serialize(outbuffer + offset);
00040       }
00041       union {
00042         float real;
00043         uint32_t base;
00044       } u_threshold;
00045       u_threshold.real = this->threshold;
00046       *(outbuffer + offset + 0) = (u_threshold.base >> (8 * 0)) & 0xFF;
00047       *(outbuffer + offset + 1) = (u_threshold.base >> (8 * 1)) & 0xFF;
00048       *(outbuffer + offset + 2) = (u_threshold.base >> (8 * 2)) & 0xFF;
00049       *(outbuffer + offset + 3) = (u_threshold.base >> (8 * 3)) & 0xFF;
00050       offset += sizeof(this->threshold);
00051       return offset;
00052     }
00053 
00054     virtual int deserialize(unsigned char *inbuffer)
00055     {
00056       int offset = 0;
00057       uint32_t rect_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00058       rect_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00059       rect_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00060       rect_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00061       offset += sizeof(this->rect_length);
00062       if(rect_lengthT > rect_length)
00063         this->rect = (jsk_recognition_msgs::Rect*)realloc(this->rect, rect_lengthT * sizeof(jsk_recognition_msgs::Rect));
00064       rect_length = rect_lengthT;
00065       for( uint32_t i = 0; i < rect_length; i++){
00066       offset += this->st_rect.deserialize(inbuffer + offset);
00067         memcpy( &(this->rect[i]), &(this->st_rect), sizeof(jsk_recognition_msgs::Rect));
00068       }
00069       union {
00070         float real;
00071         uint32_t base;
00072       } u_threshold;
00073       u_threshold.base = 0;
00074       u_threshold.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00075       u_threshold.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00076       u_threshold.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00077       u_threshold.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00078       this->threshold = u_threshold.real;
00079       offset += sizeof(this->threshold);
00080      return offset;
00081     }
00082 
00083     virtual const char * getType(){ return NONMAXIMUMSUPPRESSION; };
00084     virtual const char * getMD5(){ return "54b7e6632715e9e6592b503a3c881dfc"; };
00085 
00086   };
00087 
00088   class NonMaximumSuppressionResponse : public ros::Msg
00089   {
00090     public:
00091       uint32_t bbox_length;
00092       typedef jsk_recognition_msgs::Rect _bbox_type;
00093       _bbox_type st_bbox;
00094       _bbox_type * bbox;
00095       typedef int64_t _bbox_count_type;
00096       _bbox_count_type bbox_count;
00097 
00098     NonMaximumSuppressionResponse():
00099       bbox_length(0), bbox(NULL),
00100       bbox_count(0)
00101     {
00102     }
00103 
00104     virtual int serialize(unsigned char *outbuffer) const
00105     {
00106       int offset = 0;
00107       *(outbuffer + offset + 0) = (this->bbox_length >> (8 * 0)) & 0xFF;
00108       *(outbuffer + offset + 1) = (this->bbox_length >> (8 * 1)) & 0xFF;
00109       *(outbuffer + offset + 2) = (this->bbox_length >> (8 * 2)) & 0xFF;
00110       *(outbuffer + offset + 3) = (this->bbox_length >> (8 * 3)) & 0xFF;
00111       offset += sizeof(this->bbox_length);
00112       for( uint32_t i = 0; i < bbox_length; i++){
00113       offset += this->bbox[i].serialize(outbuffer + offset);
00114       }
00115       union {
00116         int64_t real;
00117         uint64_t base;
00118       } u_bbox_count;
00119       u_bbox_count.real = this->bbox_count;
00120       *(outbuffer + offset + 0) = (u_bbox_count.base >> (8 * 0)) & 0xFF;
00121       *(outbuffer + offset + 1) = (u_bbox_count.base >> (8 * 1)) & 0xFF;
00122       *(outbuffer + offset + 2) = (u_bbox_count.base >> (8 * 2)) & 0xFF;
00123       *(outbuffer + offset + 3) = (u_bbox_count.base >> (8 * 3)) & 0xFF;
00124       *(outbuffer + offset + 4) = (u_bbox_count.base >> (8 * 4)) & 0xFF;
00125       *(outbuffer + offset + 5) = (u_bbox_count.base >> (8 * 5)) & 0xFF;
00126       *(outbuffer + offset + 6) = (u_bbox_count.base >> (8 * 6)) & 0xFF;
00127       *(outbuffer + offset + 7) = (u_bbox_count.base >> (8 * 7)) & 0xFF;
00128       offset += sizeof(this->bbox_count);
00129       return offset;
00130     }
00131 
00132     virtual int deserialize(unsigned char *inbuffer)
00133     {
00134       int offset = 0;
00135       uint32_t bbox_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00136       bbox_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00137       bbox_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00138       bbox_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00139       offset += sizeof(this->bbox_length);
00140       if(bbox_lengthT > bbox_length)
00141         this->bbox = (jsk_recognition_msgs::Rect*)realloc(this->bbox, bbox_lengthT * sizeof(jsk_recognition_msgs::Rect));
00142       bbox_length = bbox_lengthT;
00143       for( uint32_t i = 0; i < bbox_length; i++){
00144       offset += this->st_bbox.deserialize(inbuffer + offset);
00145         memcpy( &(this->bbox[i]), &(this->st_bbox), sizeof(jsk_recognition_msgs::Rect));
00146       }
00147       union {
00148         int64_t real;
00149         uint64_t base;
00150       } u_bbox_count;
00151       u_bbox_count.base = 0;
00152       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00153       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00154       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00155       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00156       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00157       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00158       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00159       u_bbox_count.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00160       this->bbox_count = u_bbox_count.real;
00161       offset += sizeof(this->bbox_count);
00162      return offset;
00163     }
00164 
00165     virtual const char * getType(){ return NONMAXIMUMSUPPRESSION; };
00166     virtual const char * getMD5(){ return "8db21435e67f6d13fc94ccbd355f30f1"; };
00167 
00168   };
00169 
00170   class NonMaximumSuppression {
00171     public:
00172     typedef NonMaximumSuppressionRequest Request;
00173     typedef NonMaximumSuppressionResponse Response;
00174   };
00175 
00176 }
00177 #endif