ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ContourArray.h Source File

ContourArray.h

00001 #ifndef _ROS_opencv_apps_ContourArray_h
00002 #define _ROS_opencv_apps_ContourArray_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "opencv_apps/Contour.h"
00009 
00010 namespace opencv_apps
00011 {
00012 
00013   class ContourArray : public ros::Msg
00014   {
00015     public:
00016       uint8_t contours_length;
00017       opencv_apps::Contour st_contours;
00018       opencv_apps::Contour * contours;
00019 
00020     ContourArray():
00021       contours_length(0), contours(NULL)
00022     {
00023     }
00024 
00025     virtual int serialize(unsigned char *outbuffer) const
00026     {
00027       int offset = 0;
00028       *(outbuffer + offset++) = contours_length;
00029       *(outbuffer + offset++) = 0;
00030       *(outbuffer + offset++) = 0;
00031       *(outbuffer + offset++) = 0;
00032       for( uint8_t i = 0; i < contours_length; i++){
00033       offset += this->contours[i].serialize(outbuffer + offset);
00034       }
00035       return offset;
00036     }
00037 
00038     virtual int deserialize(unsigned char *inbuffer)
00039     {
00040       int offset = 0;
00041       uint8_t contours_lengthT = *(inbuffer + offset++);
00042       if(contours_lengthT > contours_length)
00043         this->contours = (opencv_apps::Contour*)realloc(this->contours, contours_lengthT * sizeof(opencv_apps::Contour));
00044       offset += 3;
00045       contours_length = contours_lengthT;
00046       for( uint8_t i = 0; i < contours_length; i++){
00047       offset += this->st_contours.deserialize(inbuffer + offset);
00048         memcpy( &(this->contours[i]), &(this->st_contours), sizeof(opencv_apps::Contour));
00049       }
00050      return offset;
00051     }
00052 
00053     const char * getType(){ return "opencv_apps/ContourArray"; };
00054     const char * getMD5(){ return "fc54374f45559dfed248b316ccf9181d"; };
00055 
00056   };
00057 
00058 }
00059 #endif